Make /recipes route return json and /tmpl/recipes html

Trying to stick to this manual
https://docs.nextcloud.com/server/13/developer_manual/app/tutorial.html
/recipes should return json.
This commit is contained in:
Daniel Röhrig 2019-09-22 21:51:36 +02:00
Родитель 29e9ed47a0
Коммит 95ba8b9cfa
3 изменённых файлов: 5 добавлений и 5 удалений

Просмотреть файл

@ -12,8 +12,8 @@ return [
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
['name' => 'page#recipe', 'url' => '/recipe', 'verb' => 'GET'],
['name' => 'page#edit', 'url' => '/edit', 'verb' => 'GET'],
['name' => 'page#recipes', 'url' => '/recipes', 'verb' => 'GET'],
['name' => 'recipe#all', 'url' => '/all', 'verb' => 'GET'],
['name' => 'page#recipes', 'url' => '/tmpl/recipes', 'verb' => 'GET'],
['name' => 'recipe#index', 'url' => '/recipes', 'verb' => 'GET'],
['name' => 'recipe#add', 'url' => '/add', 'verb' => 'POST'],
['name' => 'recipe#delete', 'url' => '/delete', 'verb' => 'DELETE'],
['name' => 'recipe#update', 'url' => '/update', 'verb' => 'POST'],

Просмотреть файл

@ -77,7 +77,7 @@ Cookbook.prototype = {
loadAll: function () {
var deferred = $.Deferred();
var self = this;
$.get(this._baseUrl + '/all').done(function (recipes) {
$.get(this._baseUrl + '/recipes').done(function (recipes) {
self._recipes = recipes;
deferred.resolve();
}).fail(function () {
@ -398,7 +398,7 @@ var Nav = function (cookbook) {
*/
self.render = function () {
$.ajax({
url: cookbook._baseUrl + '/recipes?keywords=' + self.getKeywords(),
url: cookbook._baseUrl + '/tmpl/recipes?keywords=' + self.getKeywords(),
method: 'GET',
})
.done(function(html) {

Просмотреть файл

@ -27,7 +27,7 @@ class RecipeController extends Controller {
* @NoAdminRequired
* @NoCSRFRequired
*/
public function all() {
public function index() {
$data = $this->service->getAllRecipesInSearchIndex();
return new DataResponse($data, Http::STATUS_OK, [ 'Content-Type' => 'application/json' ]);