164 lines
6.5 KiB
PHP
164 lines
6.5 KiB
PHP
<?php
|
|
|
|
use Illuminate\Support\Facades\Route;
|
|
use App\Http\Controllers\AccountController;
|
|
use App\Http\Controllers\BookController;
|
|
use App\Http\Controllers\CalendarController;
|
|
use App\Http\Controllers\CalendarSettingsController;
|
|
use App\Http\Controllers\CardController;
|
|
use App\Http\Controllers\DavController;
|
|
use App\Http\Controllers\EventController;
|
|
use App\Http\Controllers\IcsController;
|
|
use App\Http\Controllers\LocationController;
|
|
use App\Http\Controllers\SubscriptionController;
|
|
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
|
|
|
|
/**
|
|
*
|
|
* public unauthenticated pages
|
|
*/
|
|
|
|
Route::view('/', 'welcome');
|
|
|
|
/**
|
|
*
|
|
* starter pages
|
|
* @todo replace these
|
|
*/
|
|
|
|
Route::view('/dashboard', 'dashboard')
|
|
->middleware(['auth', 'verified'])
|
|
->name('dashboard');
|
|
|
|
Route::view('/settings', 'settings')
|
|
->middleware(['auth', 'verified'])
|
|
->name('settings');
|
|
|
|
/**
|
|
*
|
|
* main authentication block
|
|
*/
|
|
|
|
Route::middleware('auth')->group(function ()
|
|
{
|
|
/* user account */
|
|
Route::middleware(['web', 'auth'])
|
|
->prefix('account')
|
|
->name('account.')
|
|
->group(function () {
|
|
|
|
// landing: send them to the first pane
|
|
Route::get('/', [AccountController::class, 'index'])->name('index');
|
|
|
|
// panes
|
|
Route::get('info', [AccountController::class, 'infoForm'])->name('info');
|
|
Route::patch('info', [AccountController::class, 'infoStore'])->name('info.store');
|
|
|
|
Route::get('addresses', [AccountController::class, 'addressesForm'])->name('addresses');
|
|
Route::patch('addresses', [AccountController::class, 'addressesStore'])->name('addresses.store');
|
|
|
|
Route::get('password', [AccountController::class, 'passwordForm'])->name('password');
|
|
Route::patch('password', [AccountController::class, 'passwordStore'])->name('password.store');
|
|
|
|
Route::get('delete', [AccountController::class, 'deleteForm'])->name('delete');
|
|
Route::get('delete/confirm', [AccountController::class, 'deleteConfirm'])->name('delete.confirm');
|
|
Route::delete('/', [AccountController::class, 'destroy'])->name('destroy');
|
|
});
|
|
|
|
/* calendar core */
|
|
Route::middleware('auth')->group(function () {
|
|
// list, create, store, show, edit, update, destroy
|
|
Route::resource('calendar', CalendarController::class)
|
|
->whereUuid('calendar'); // constrain the {calendar} param
|
|
});
|
|
|
|
/* calendar other */
|
|
Route::middleware(['web','auth'])
|
|
->prefix('calendar')
|
|
->name('calendar.')
|
|
->group(function () {
|
|
|
|
// settings landing
|
|
Route::get('settings', [CalendarSettingsController::class, 'index'])->name('settings');
|
|
|
|
// language/region settings
|
|
Route::get('settings/language', [CalendarSettingsController::class, 'languageForm'])->name('settings.language');
|
|
Route::post('settings/language', [CalendarSettingsController::class, 'languageStore'])->name('settings.language.store');
|
|
|
|
// settings / subscribe to a calendar
|
|
Route::get('settings/subscribe', [CalendarSettingsController::class, 'subscribeForm'])->name('settings.subscribe');
|
|
Route::post('settings/subscribe', [CalendarSettingsController::class, 'subscribeStore'])->name('settings.subscribe.store');
|
|
|
|
// remote calendar subscriptions
|
|
Route::resource('subscriptions', SubscriptionController::class)
|
|
->except(['show']); // index, create, store, edit, update, destroy
|
|
|
|
// calendar settings for a specific calendar instance/container
|
|
Route::get('settings/calendars/{calendarUri}', [CalendarSettingsController::class, 'calendarForm'])
|
|
->whereUuid('calendarUri') // sabre calendarid is an int
|
|
->name('settings.calendars.show');
|
|
Route::patch('settings/calendars/{calendarUri}', [CalendarSettingsController::class, 'calendarStore'])
|
|
->whereUuid('calendarUri')
|
|
->name('settings.calendars.update');
|
|
|
|
// events
|
|
Route::prefix('{calendar}')->whereUuid('calendar')->group(function () {
|
|
// create & store
|
|
Route::get ('event/create', [EventController::class, 'create'])->name('event.create');
|
|
Route::post('event', [EventController::class, 'store' ])->name('event.store');
|
|
// read
|
|
Route::get ('event/{event}', [EventController::class, 'show' ])->name('event.show');
|
|
// edit & update
|
|
Route::get ('event/{event}/edit', [EventController::class, 'edit' ])->name('event.edit');
|
|
Route::put ('event/{event}', [EventController::class, 'update'])->name('event.update');
|
|
// delete
|
|
Route::delete('event/{event}', [EventController::class, 'destroy'])->name('event.destroy');
|
|
});
|
|
});
|
|
|
|
// autocomplete suggestions for event locations
|
|
Route::get('/location/suggest', [LocationController::class, 'suggest'])
|
|
->name('location.suggest');
|
|
|
|
// address books
|
|
Route::resource('book', BookController::class)
|
|
->names('book') // books.index, books.create, …
|
|
->parameter('book', 'book'); // {book} binding
|
|
|
|
/** contacts inside a book
|
|
nested so urls look like /books/{book}/contacts/{contact} */
|
|
/*Route::resource('book.contacts', CardController::class)
|
|
->names('book.contacts')
|
|
->parameter('contacts', 'contact')
|
|
->except(['index']) // you may add an index later
|
|
->shallow();*/
|
|
});
|
|
|
|
/* Breeze auth routes (login, register, password reset, etc.) */
|
|
require __DIR__.'/auth.php';
|
|
|
|
/*
|
|
|--------------------------------------------------------------------------
|
|
| SabreDAV endpoint (CalDAV + CardDAV)
|
|
|--------------------------------------------------------------------------
|
|
| Leave this outside the auth middleware; the SabreLaravelAuthPlugin handles
|
|
| authentication for DAV clients.
|
|
*/
|
|
|
|
// default dav handling
|
|
Route::match(
|
|
['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'HEAD', 'PROPFIND', 'PROPPATCH', 'MKCOL', 'COPY', 'MOVE', 'REPORT', 'LOCK', 'UNLOCK'],
|
|
'/dav/{any?}',
|
|
[DavController::class, 'handle']
|
|
)->where('any', '.*')
|
|
->withoutMiddleware([VerifyCsrfToken::class]);
|
|
|
|
// our subscriptions
|
|
Route::get('/ics/{calendarUri}.ics', [IcsController::class, 'download']);
|
|
|
|
// remote subscriptions
|
|
Route::middleware(['auth'])->group(function () {
|
|
Route::resource('calendar/subscriptions', SubscriptionController::class)
|
|
->except(['show']); // index • create • store • edit • update • destroy
|
|
});
|