Refactor page routes
parent
f0e89f4056
commit
afa4f0cc72
|
@ -1,28 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
function getWildcard($param) {
|
||||||
|
return [
|
||||||
|
'requirements' => [ $param => '.*' ],
|
||||||
|
'defaults' => [ $param => '' ]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'routes' => [
|
'routes' => [
|
||||||
// Days and folder API
|
// Vue routes for deep links
|
||||||
['name' => 'page#main', 'url' => '/', 'verb' => 'GET'],
|
['name' => 'page#main', 'url' => '/', 'verb' => 'GET'],
|
||||||
['name' => 'page#folder', 'url' => '/folders/{path}', 'verb' => 'GET',
|
['name' => 'page#folder', 'url' => '/folders/{path}', 'verb' => 'GET', ...getWildcard('path')],
|
||||||
'requirements' => [ 'path' => '.*' ],
|
|
||||||
'defaults' => [ 'path' => '' ]
|
|
||||||
],
|
|
||||||
['name' => 'page#favorites', 'url' => '/favorites', 'verb' => 'GET'],
|
['name' => 'page#favorites', 'url' => '/favorites', 'verb' => 'GET'],
|
||||||
['name' => 'page#videos', 'url' => '/videos', 'verb' => 'GET'],
|
['name' => 'page#videos', 'url' => '/videos', 'verb' => 'GET'],
|
||||||
['name' => 'page#albums', 'url' => '/albums/{id}', 'verb' => 'GET',
|
['name' => 'page#albums', 'url' => '/albums/{id}', 'verb' => 'GET', ...getWildcard('id')],
|
||||||
'requirements' => [ 'id' => '.*' ],
|
|
||||||
'defaults' => [ 'id' => '' ]
|
|
||||||
],
|
|
||||||
['name' => 'page#archive', 'url' => '/archive', 'verb' => 'GET'],
|
['name' => 'page#archive', 'url' => '/archive', 'verb' => 'GET'],
|
||||||
['name' => 'page#thisday', 'url' => '/thisday', 'verb' => 'GET'],
|
['name' => 'page#thisday', 'url' => '/thisday', 'verb' => 'GET'],
|
||||||
['name' => 'page#people', 'url' => '/people/{name}', 'verb' => 'GET',
|
['name' => 'page#people', 'url' => '/people/{name}', 'verb' => 'GET', ...getWildcard('name')],
|
||||||
'requirements' => [ 'name' => '.*' ],
|
['name' => 'page#tags', 'url' => '/tags/{name}', 'verb' => 'GET', ...getWildcard('name')],
|
||||||
'defaults' => [ 'name' => '' ]
|
|
||||||
],
|
|
||||||
['name' => 'page#tags', 'url' => '/tags/{name}', 'verb' => 'GET',
|
|
||||||
'requirements' => [ 'name' => '.*' ],
|
|
||||||
'defaults' => [ 'name' => '' ]
|
|
||||||
],
|
|
||||||
|
|
||||||
// Public pages
|
// Public pages
|
||||||
['name' => 'page#sharedfolder', 'url' => '/s/{token}', 'verb' => 'GET'],
|
['name' => 'page#sharedfolder', 'url' => '/s/{token}', 'verb' => 'GET'],
|
||||||
|
@ -30,8 +26,8 @@ return [
|
||||||
// API Routes
|
// API Routes
|
||||||
|
|
||||||
['name' => 'days#days', 'url' => '/api/days', 'verb' => 'GET'],
|
['name' => 'days#days', 'url' => '/api/days', 'verb' => 'GET'],
|
||||||
['name' => 'days#dayPost', 'url' => '/api/days', 'verb' => 'POST'],
|
|
||||||
['name' => 'days#day', 'url' => '/api/days/{id}', 'verb' => 'GET'],
|
['name' => 'days#day', 'url' => '/api/days/{id}', 'verb' => 'GET'],
|
||||||
|
['name' => 'days#dayPost', 'url' => '/api/days', 'verb' => 'POST'],
|
||||||
|
|
||||||
['name' => 'tags#tags', 'url' => '/api/tags', 'verb' => 'GET'],
|
['name' => 'tags#tags', 'url' => '/api/tags', 'verb' => 'GET'],
|
||||||
['name' => 'tags#previews', 'url' => '/api/tag-previews', 'verb' => 'GET'],
|
['name' => 'tags#previews', 'url' => '/api/tag-previews', 'verb' => 'GET'],
|
||||||
|
|
|
@ -77,21 +77,6 @@ class DaysController extends ApiBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @NoAdminRequired
|
|
||||||
*
|
|
||||||
* @PublicPage
|
|
||||||
*/
|
|
||||||
public function dayPost(): JSONResponse
|
|
||||||
{
|
|
||||||
$id = $this->request->getParam('body_ids');
|
|
||||||
if (null === $id) {
|
|
||||||
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->day($id);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @NoAdminRequired
|
* @NoAdminRequired
|
||||||
*
|
*
|
||||||
|
@ -148,6 +133,21 @@ class DaysController extends ApiBase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @NoAdminRequired
|
||||||
|
*
|
||||||
|
* @PublicPage
|
||||||
|
*/
|
||||||
|
public function dayPost(): JSONResponse
|
||||||
|
{
|
||||||
|
$id = $this->request->getParam('body_ids');
|
||||||
|
if (null === $id) {
|
||||||
|
return new JSONResponse([], Http::STATUS_BAD_REQUEST);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->day($id);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get subfolders entry for days response.
|
* Get subfolders entry for days response.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue