]> git.agnieray.net Git - galette.git/commitdiff
Run Galette from a subdirectory
authorJohan Cwiklinski <johan@x-tnd.be>
Thu, 2 Mar 2023 06:33:05 +0000 (07:33 +0100)
committerJohan Cwiklinski <johan@x-tnd.be>
Sat, 11 Mar 2023 14:39:12 +0000 (15:39 +0100)
Move emojis in the theme's assets
Remove TrailingSlash middleware
Few configuration precisions

galette/includes/main.inc.php
galette/index.php
galette/lib/Galette/Middleware/TrailingSlash.php [deleted file]
galette/webroot/.htaccess
galette/webroot/compat_test.php
gulpfile.js
ui/semantic/galette/elements/emoji.variables

index f4fe96007b73e24abb460d48bbc4779869fc1bce..7f27eab445c1e01aa7bd51a34a6d958f476b81db 100644 (file)
@@ -76,6 +76,17 @@ if ($needs_update) {
     $gapp = new \Galette\Core\SlimApp();
 }
 $app = $gapp->getApp();
+$app->setBasePath((function () {
+    $scriptDir = str_replace('\\', '/', dirname($_SERVER['SCRIPT_NAME']));
+    $uri = (string)parse_url('http://a' . $_SERVER['REQUEST_URI'] ?? '', PHP_URL_PATH);
+    if (stripos($uri, $_SERVER['SCRIPT_NAME']) === 0) {
+        return dirname($_SERVER['SCRIPT_NAME']);
+    }
+    if ($scriptDir !== '/' && stripos($uri, $scriptDir) === 0) {
+        return $scriptDir;
+    }
+    return '';
+})());
 
 //CONFIGURE AND START SESSION
 
@@ -230,11 +241,6 @@ $errorHandler->registerErrorRenderer('text/html', \Galette\Renderers\Html::class
  */
 $app->add(TwigMiddleware::createFromContainer($app, Twig::class));
 
-/**
- * Trailing slash middleware
- */
-$app->add(TrailingSlash::class);
-
 $app->run();
 
 if (isset($profiler)) {
index 6def913366a9692a9cf672f287e1775437071100..3f72156e6b9f75bd058c4e4e7943b715d4f6b1ff 100644 (file)
@@ -34,4 +34,4 @@
  * @link      http://galette.tuxfamily.org
  */
 
-header('location:webroot/index.php');
+header('location:webroot/');
diff --git a/galette/lib/Galette/Middleware/TrailingSlash.php b/galette/lib/Galette/Middleware/TrailingSlash.php
deleted file mode 100644 (file)
index 1abb5c6..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-<?php
-
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-/**
- * Galette Slim middleware to handle trailing slash in URLs
- *
- * PHP version 5
- *
- * Copyright © 2020-2023 The Galette Team
- *
- * This file is part of Galette (http://galette.tuxfamily.org).
- *
- * Galette is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Galette is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Galette. If not, see <http://www.gnu.org/licenses/>.
- *
- * @category  Core
- * @package   Galette
- *
- * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2020-2023 The Galette Team
- * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
- * @link      http://galette.tuxfamily.org
- * @since     Available since 0.9.4dev - 2020-05-06
- */
-
-namespace Galette\Middleware;
-
-use Psr\Http\Message\ResponseInterface;
-use Psr\Http\Message\ServerRequestInterface as Request;
-use Psr\Http\Server\RequestHandlerInterface as RequestHandler;
-use Slim\Psr7\Response;
-
-/**
- * Galette Slim middleware to handle trailing slash in URLs
- *
- * @category  Middleware
- * @name      TrailingSlash
- * @package   Galette
- * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2020-2023 The Galette Team
- * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
- * @link      http://galette.tuxfamily.org
- * @since     Available since 0.9.4dev - 2020-05-06
- */
-class TrailingSlash
-{
-    /**
-     * Middleware invokable class
-     *
-     * @param  Request        $request PSR7 request
-     * @param  RequestHandler $handler Request handler
-     *
-     * @return ResponseInterface
-     */
-    public function __invoke(Request $request, RequestHandler $handler): ResponseInterface
-    {
-        $uri = $request->getUri();
-        $path = $uri->getPath();
-
-        if ($path != '/' && substr($path, -1) == '/') {
-            // recursively remove slashes when its more than 1 slash
-            $path = rtrim($path, '/');
-
-            // permanently redirect paths with a trailing slash
-            // to their non-trailing counterpart
-            $uri = $uri->withPath($path);
-
-            if ($request->getMethod() == 'GET') {
-                $response = new Response();
-                return $response
-                    ->withHeader('Location', (string)$uri)
-                    ->withStatus(301);
-            } else {
-                $request = $request->withUri($uri);
-            }
-        }
-
-        return $handler->handle($request);
-    }
-}
index c506092e1b3642896e9e0c5776bc24e5f9941651..0c4c78c6ed7313d15d3e2e06b64b2f534c60a387 100644 (file)
@@ -4,7 +4,11 @@ RewriteEngine On
 # If you need to use the `RewriteBase` directive, it should be the
 # absolute physical path to the directory that contains this htaccess file.
 #
-# RewriteBase /
+# One known case is the use of an alias - say /mygalette/
+# that points to Galette webroot directory. In that case:
+#
+# RewriteBase /mygalette/
 
+RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^ index.php [QSA,L]
index 2f48dafdaa33f3963628dac673fd94f1e09548df..55042d277a1ca15f387cc841728483bc99f6c783 100644 (file)
@@ -7,7 +7,7 @@
  *
  * PHP version 5
  *
- * Copyright © 2013-2014 The Galette Team
+ * Copyright © 2013-2023 The Galette Team
  *
  * This file is part of Galette (http://galette.tuxfamily.org).
  *
@@ -28,7 +28,7 @@
  * @package   Galette
  *
  * @author    Johan Cwiklinski <johan@x-tnd.be>
- * @copyright 2013-2017 The Galette Team
+ * @copyright 2013-2023 The Galette Team
  * @license   http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
  * @link      http://galette.tuxfamily.org
  * @since     Available since 0.7.4dev - 2013-02-03
@@ -78,6 +78,11 @@ $cm->doCheck(false); //do not load with translations!
                 echo $cm->toHtml(false);
                 ?>
                             </ul>
+                <?php
+                if ($cm->isValid() && $phpok) {
+                    echo '<p class="ui center aligned message">You can now <a href="./installer.php">install Galette</a></p>';
+                }
+                ?>
                         </div>
                     </div>
                 </div>
index 428831e975df83d0a4f3842cbd3ff71e51181069..1bfb55db08e869183163d59613f05879ac232d93 100644 (file)
@@ -54,7 +54,8 @@ var paths = {
     js: './ui/js/*.js',
     favicon:'./ui/images/favicon.png',
     logo: './ui/images/galette.png',
-    photo:'./ui/images/default.png'
+    photo:'./ui/images/default.png',
+    emojis: './node_modules/twemoji-emojis/vendor/svg/*'
   },
   semantic: {
     src: './semantic/src/',
@@ -107,9 +108,6 @@ var paths = {
     }, {
       src: './node_modules/jquery/dist/jquery.min.js',
       dest: 'js/'
-    }, {
-      src: './node_modules/twemoji-emojis/vendor/svg/*',
-      dest: 'emojis/'
     }
   ]
 };
@@ -139,7 +137,11 @@ function theme() {
     .pipe(gulp.dest(paths.semantic.theme))
     .pipe(browserSync.stream());
 
-  return merge(config, theme);
+  emojis = gulp.src(paths.src.emojis)
+    .pipe(gulp.dest(paths.semantic.theme + 'assets/emojis'))
+    .pipe(browserSync.stream());
+
+  return merge(config, theme, emojis);
 }
 
 function clean() {
index 08c9fdd60b96626d8e2cdf2915a6b3afd4e122b2..84b9e3484997aa22a1ca005699053687b5aa8785 100644 (file)
@@ -10,4 +10,4 @@
 /*--------------
     Path
 ---------------*/
-@emojiPath: "/assets/emojis/";
+@emojiPath: "themes/galette/assets/emojis/";