jonnybarnes.uk/routes/web.php
Jonny Barnes c52f0e17d7 Add CORS headers to the media endpoint
Squashed commit of the following:

commit 0a620148dfad998f7b00804cae1db8208b23cc02
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Mar 2 15:08:36 2018 +0000

    Add tests for the Cors Headers

commit dd8518d279cdf3857597fa7ee6150bf383203fe1
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Mar 2 15:08:20 2018 +0000

    Only add Cors Headers to requests to the media endpoint

commit 6c79ca5632581345ef406f211b1576a4b7f400fe
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Mar 2 15:07:53 2018 +0000

    Add CorsHeaders to middleware array

commit e12d48ca1e837b14b75bbd87d6197d59d60cf32e
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Mar 2 15:06:32 2018 +0000

    We need to send something to the OPTIONS request to the media endpoint

commit f11c638be464373bff09bf015d4a989e48e61f0c
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Fri Mar 2 15:05:45 2018 +0000

    Change routes to allow for responses to an OPTIONS request to the media endpoint
2018-03-02 15:49:07 +00:00

173 lines
6.8 KiB
PHP

<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
Route::group(['domain' => config('url.longurl')], function () {
Route::get('/', 'NotesController@index');
//Static project page
Route::view('projects', 'projects');
//Static colophon page
Route::view('colophon', 'colophon');
//The login routes to get authe'd for admin
Route::get('login', 'AuthController@showLogin')->name('login');
Route::post('login', 'AuthController@login');
//Admin pages grouped for filter
Route::group([
'middleware' => 'myauth',
'namespace' => 'Admin',
'prefix' => 'admin',
], function () {
Route::get('/', 'HomeController@welcome');
//Articles
Route::group(['prefix' => 'blog'], function () {
Route::get('/', 'ArticlesController@index');
Route::get('/create', 'ArticlesController@create');
Route::post('/', 'ArticlesController@store');
Route::get('/{id}/edit', 'ArticlesController@edit');
Route::put('/{id}', 'ArticlesController@update');
Route::delete('/{id}', 'ArticlesController@destroy');
});
//Notes
Route::group(['prefix' => 'notes'], function () {
Route::get('/', 'NotesController@index');
Route::get('/create', 'NotesController@create');
Route::post('/', 'NotesController@store');
Route::get('/{id}/edit', 'NotesController@edit');
Route::put('/{id}', 'NotesController@update');
Route::delete('/{id}', 'NotesController@destroy');
});
//Micropub Clients
Route::group(['prefix' => 'clients'], function () {
Route::get('/', 'ClientsController@index');
Route::get('/create', 'ClientsController@create');
Route::post('/', 'ClientsController@store');
Route::get('/{id}/edit', 'ClientsController@edit');
Route::put('/{id}', 'ClientsController@update');
Route::delete('/{id}', 'ClientsController@destroy');
});
//Contacts
Route::group(['prefix' => 'contacts'], function () {
Route::get('/', 'ContactsController@index');
Route::get('/create', 'ContactsController@create');
Route::post('/', 'ContactsController@store');
Route::get('/{id}/edit', 'ContactsController@edit');
Route::put('/{id}', 'ContactsController@update');
Route::delete('/{id}', 'ContactsController@destroy');
Route::get('/{id}/getavatar', 'ContactsController@getAvatar');
});
//Places
Route::group(['prefix' => 'places'], function () {
Route::get('/', 'PlacesController@index');
Route::get('/create', 'PlacesController@create');
Route::post('/', 'PlacesController@store');
Route::get('/{id}/edit', 'PlacesController@edit');
Route::put('/{id}', 'PlacesController@update');
Route::get('/{id}/merge', 'PlacesController@mergeIndex');
Route::get('/{place1_id}/merge/{place2_id}', 'PlacesController@mergeEdit');
Route::post('/merge', 'PlacesController@mergeStore');
Route::delete('/{id}', 'PlacesController@destroy');
});
//Likes
Route::group(['prefix' => 'likes'], function () {
Route::get('/', 'LikesController@index');
Route::get('/create', 'LikesController@create');
Route::post('/', 'LikesController@store');
Route::get('/{id}/edit', 'LikesController@edit');
Route::put('/{id}', 'LikesController@update');
Route::delete('/{id}', 'LikesController@destroy');
});
});
//Blog pages using ArticlesController
Route::group(['prefix' => 'blog'], function () {
Route::get('/feed.rss', 'FeedsController@blogRss');
Route::get('/feed.atom', 'FeedsController@blogAtom');
Route::get('/feed.json', 'FeedsController@blogJson');
Route::get('/s/{id}', 'ArticlesController@onlyIdInURL');
Route::get('/{year?}/{month?}', 'ArticlesController@index');
Route::get('/{year}/{month}/{slug}', 'ArticlesController@show');
});
//Notes pages using NotesController
Route::group(['prefix' => 'notes'], function () {
Route::get('/', 'NotesController@index');
Route::get('/feed.rss', 'FeedsController@notesRss');
Route::get('/feed.atom', 'FeedsController@notesAtom');
Route::get('/feed.json', 'FeedsController@notesJson');
Route::get('/{id}', 'NotesController@show');
Route::get('/tagged/{tag}', 'NotesController@tagged');
});
Route::get('note/{id}', 'NotesController@redirect'); // for legacy note URLs
// Likes
Route::group(['prefix' => 'likes'], function () {
Route::get('/', 'LikesController@index');
Route::get('/{like}', 'LikesController@show');
});
// Bookmarks
Route::group(['prefix' => 'bookmarks'], function () {
Route::get('/', 'BookmarksController@index');
Route::get('/{bookmark}', 'BookmarksController@show');
});
// Token Endpoint
Route::post('api/token', 'TokenEndpointController@create');
// Micropub Endpoints
Route::get('api/post', 'MicropubController@get')->middleware('micropub.token');
Route::post('api/post', 'MicropubController@post')->middleware('micropub.token');
Route::post('api/media', 'MicropubController@media')->middleware('micropub.token', 'cors')->name('media-endpoint');
Route::options('/api/media', 'MicropubController@mediaOptionsResponse')->middleware('cors');
//webmention
Route::get('webmention', 'WebMentionsController@get');
Route::post('webmention', 'WebMentionsController@receive');
//Contacts
Route::get('contacts', 'ContactsController@index');
Route::get('contacts/{nick}', 'ContactsController@show');
//Places
Route::get('places', 'PlacesController@index');
Route::get('places/{slug}', 'PlacesController@show');
Route::get('search', 'SearchController@search');
Route::post('update-colour-scheme', 'SessionStoreController@saveColour');
});
//Short URL
Route::group(['domain' => config('url.shorturl')], function () {
Route::get('/', 'ShortURLsController@baseURL');
Route::get('@', 'ShortURLsController@twitter');
Route::get('+', 'ShortURLsController@googlePlus');
Route::get('{type}/{id}', 'ShortURLsController@expandType')->where(
[
'type' => '[bt]',
'id' => '[0-9A-HJ-NP-Z_a-km-z]+',
]
);
Route::get('h/{id}', 'ShortURLsController@redirect');
});