]> git.agnieray.net Git - galette.git/blob - galette/includes/routes/main.routes.php
Merge branch 'hotfix/1.0.2'
[galette.git] / galette / includes / routes / main.routes.php
1 <?php
2
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5 /**
6 * Main routes
7 *
8 * PHP version 5
9 *
10 * Copyright © 2014-2023 The Galette Team
11 *
12 * This file is part of Galette (http://galette.tuxfamily.org).
13 *
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
26 *
27 * @category Routes
28 * @package Galette
29 *
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2014-2023 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
33 * @link http://galette.tuxfamily.org
34 * @since 0.8.2dev 2014-11-11
35 */
36
37 use Galette\Controllers\GaletteController;
38 use Galette\Controllers\ImagesController;
39
40 //main route
41 $app->get(
42 '/',
43 [GaletteController::class, 'slash']
44 )->setName('slash');
45
46 $app->get(
47 '/favicon.ico',
48 [GaletteController::class, 'favicon']
49 );
50
51 //logo route
52 $app->get(
53 '/logo',
54 [ImagesController::class, 'logo']
55 )->setName('logo');
56
57 //print logo route
58 $app->get(
59 '/print-logo',
60 [ImagesController::class, 'printLogo']
61 )->setName('printLogo');
62
63 //photo route
64 $app->get(
65 '/photo/{id:\d+}',
66 [ImagesController::class, 'photo']
67 )->setName('photo');
68
69 //system information - keep old route with typo ('s' on 'information') for now (0.9.4)
70 $app->get(
71 '/system-informations',
72 function ($request, $response) use ($routeparser) {
73 return $response
74 ->withStatus(302)
75 ->withHeader('Location', $routeparser->urlFor('sysinfos'));
76 }
77 );
78
79 //system information
80 $app->get(
81 '/system-information',
82 [GaletteController::class, 'systemInformation']
83 )->setName('sysinfos')->add($authenticate);
84
85 $app->post(
86 '/write-dark-css',
87 function ($request, $response) {
88 $post = $request->getParsedBody();
89 file_put_contents(GALETTE_CACHE_DIR . '/dark.css', $post);
90 return $response->withStatus(200);
91 }
92 )->setName('writeDarkCSS');
93
94 $app->get(
95 '/get-dark-css',
96 function ($request, $response) {
97 $cssfile = GALETTE_CACHE_DIR . '/dark.css';
98 if (file_exists($cssfile)) {
99 $response = $response->withHeader('Content-type', 'text/css');
100 $body = $response->getBody();
101 $body->write(file_get_contents($cssfile));
102 }
103 return $response;
104 }
105 )->setName('getDarkCSS');