]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Merge pull request #1593 from ArthurHoaro/fix/no-url-rewriting
authorArthurHoaro <arthur@hoa.ro>
Fri, 16 Oct 2020 17:26:03 +0000 (19:26 +0200)
committerGitHub <noreply@github.com>
Fri, 16 Oct 2020 17:26:03 +0000 (19:26 +0200)
15 files changed:
application/front/controller/visitor/ShaarliVisitorController.php
application/plugin/PluginManager.php
application/render/PageBuilder.php
doc/md/Server-configuration.md
doc/md/dev/Plugin-system.md
plugins/archiveorg/archiveorg.php
plugins/isso/isso.php
plugins/qrcode/qrcode.php
plugins/wallabag/wallabag.php
tpl/default/daily.html
tpl/default/includes.html
tpl/default/linklist.html
tpl/default/page.footer.html
tpl/default/picwall.html
tpl/default/pluginsadmin.html

index 55c075a2a87f7ae8c7cad95c5134bf78c53e3cf5..54f9fe03fc5bd4c506b04c7cfaae02b8afea0ee5 100644 (file)
@@ -106,6 +106,7 @@ abstract class ShaarliVisitorController
             'target' => $template,
             'loggedin' => $this->container->loginManager->isLoggedIn(),
             'basePath' => $this->container->basePath,
+            'rootPath' => preg_replace('#/index\.php$#', '', $this->container->basePath),
             'bookmarkService' => $this->container->bookmarkService
         ];
     }
index 1b2197c9d8d0aa1af56d44842ed18c3fa4f619de..da66dea3952ad3cb0086a4594858f392f3270ba0 100644 (file)
@@ -104,6 +104,7 @@ class PluginManager
             'target' => '_PAGE_',
             'loggedin' => '_LOGGEDIN_',
             'basePath' => '_BASE_PATH_',
+            'rootPath' => '_ROOT_PATH_',
             'bookmarkService' => '_BOOKMARK_SERVICE_',
         ];
 
index 41b357dd72caccc9fe0525b29d3dbc2a31876db2..2d6d2dbed983d4fe2d8f0d2db00003f118e55141 100644 (file)
@@ -174,10 +174,12 @@ class PageBuilder
             }
         }
 
+        $rootPath = preg_replace('#/index\.php$#', '', $basePath);
         $this->assign('base_path', $basePath);
+        $this->assign('root_path', $rootPath);
         $this->assign(
             'asset_path',
-            $basePath . '/' .
+            $rootPath . '/' .
             rtrim($this->conf->get('resource.raintpl_tpl', 'tpl'), '/') . '/' .
             $this->conf->get('resource.theme', 'default')
         );
index 14070c8abc7dfc443c630718f0fb024a734b6a13..8cb39934603c35aaa4b4b8ebb42fb6305052fab1 100644 (file)
@@ -362,7 +362,23 @@ sudo systemctl reload nginx
 
 If Shaarli is hosted on a server behind a [reverse proxy](https://en.wikipedia.org/wiki/Reverse_proxy) (i.e. there is a proxy server between clients and the web server hosting Shaarli), configure it accordingly. See [Reverse proxy](Reverse-proxy.md) configuration.
 
+## Using Shaarli without URL rewriting
 
+By default, Shaarli uses Slim framework's URL, which requires
+URL rewriting.
+
+If you can't use URL rewriting for any reason (not supported by
+your web server, shared hosting, etc.), you *can* use Shaarli
+without URL rewriting.
+
+You just need to prefix your URL by `/index.php/`.
+Example: instead of accessing `https://shaarli.mydomain.org/`,
+use `https://shaarli.mydomain.org/index.php/`.
+
+**Recommended:**
+  * after installation, in the configuration page, set your header link to `/index.php/`.
+  * in your configuration file `config.json.php` set `general.root_url` to
+    `https://shaarli.mydomain.org/index.php/`.
 
 ## Allow import of large browser bookmarks export
 
index c29774de05b46e47be8ed6c5b05b5aa539e68028..f09fadc2925db027873cd2d788ac6a239a6ffa68 100644 (file)
@@ -148,11 +148,16 @@ If a file needs to be included in server end, use simple relative path:
 `PluginManager::$PLUGINS_PATH . '/mything/template.html'`.
 
 If it needs to be included in front end side (e.g. an image),
-the relative path must be prefixed with special data `_BASE_PATH_`:
-`($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH . '/mything/picture.png`.
+the relative path must be prefixed with special data:
+
+  * if it's a link that will need to be processed by Shaarli, use `_BASE_PATH_`:
+    for e.g. `$data['_BASE_PATH_'] . '/admin/tools`.
+  * if you want to include an asset, you need to add the root URL (base path without `/index.php`, for people using Shaarli without URL rewriting), then use `_ROOT_PATH_`:
+    for e.g
+`$['_ROOT_PATH_'] . '/' . PluginManager::$PLUGINS_PATH . '/mything/picture.png`.
 
 Note that special placeholders for CSS and JS files (respectively `css_files` and `js_files`) are already prefixed
-with the base path in template files.
+with the root path in template files.
 
 ### It's not working!
 
index 922b5966fe3340b203b8c98cc6f970555e4b43a5..ed2715322686e82ca4a9373d3417f57babc67da1 100644 (file)
@@ -17,7 +17,7 @@ use Shaarli\Plugin\PluginManager;
 function hook_archiveorg_render_linklist($data)
 {
     $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html');
-    $path = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
+    $path = ($data['_ROOT_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
 
     foreach ($data['links'] as &$value) {
         $isNote = startsWith($value['real_url'], '/shaare/');
index 79e7380b66f543ade34bb080e027cba26990a7bf..d46321633e9fabdc15d714a7356af2dfc23767d3 100644 (file)
@@ -54,7 +54,7 @@ function hook_isso_render_linklist($data, $conf)
         if ($conf->get('resource.theme') === 'default') {
             $button .= '<i class="linklist-plugin-icon fa fa-comment"></i>';
         } else {
-            $button .= '<img class="linklist-plugin-icon" src="plugins/isso/comment.png" ';
+            $button .= '<img class="linklist-plugin-icon" src="'. $data['_ROOT_PATH_'].'/plugins/isso/comment.png" ';
             $button .= 'title="Comment on this shaare" alt="Comments" />';
         }
         $button .= '</a></span>';
index 95499e39f5a9618cfec8bcb4f0a28ed8922537ca..24fd18baf99aefe2f6f58c7a9225735f6b54ad7e 100644 (file)
@@ -19,7 +19,7 @@ function hook_qrcode_render_linklist($data)
 {
     $qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html');
 
-    $path = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
+    $path = ($data['_ROOT_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
     foreach ($data['links'] as &$value) {
         $qrcode = sprintf(
             $qrcode_html,
index 805c1ad986aa9bc4c37b2531ca521f891e6cffd6..d0df3501d6389b40ce2e1c340675f4debada71ea 100644 (file)
@@ -45,7 +45,7 @@ function hook_wallabag_render_linklist($data, $conf)
     $wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html');
 
     $linkTitle = t('Save to wallabag');
-    $path = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
+    $path = ($data['_ROOT_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
 
     foreach ($data['links'] as &$value) {
         $wallabag = sprintf(
index 3ab8053f753280d348a00b31da3cd5c00e4d2f44..3749bffb620a317c276c4b63a2e9aa42b031a67d 100644 (file)
@@ -76,7 +76,7 @@
                   </div>
                   {if="$thumbnails_enabled && !empty($link.thumbnail)"}
                     <div class="daily-entry-thumbnail">
-                      <img data-src="{$link.thumbnail}#" class="b-lazy"
+                      <img data-src="{$root_path}/{$link.thumbnail}#" class="b-lazy"
                            src=""
                            alt="thumbnail" width="{$thumbnails_width}" height="{$thumbnails_height}" />
                     </div>
index 09768ac47905908bc5cbc274e230a407541bd946..3e3fb6640a52b366af7c3ad96b23484c5000f9b4 100644 (file)
   <link type="text/css" rel="stylesheet" href="{$asset_path}/css/markdown.min.css?v={$version_hash}#" />
 {/if}
 {loop="$plugins_includes.css_files"}
-  <link type="text/css" rel="stylesheet" href="{$base_path}/{$value}?v={$version_hash}#"/>
+  <link type="text/css" rel="stylesheet" href="{$root_path}/{$value}?v={$version_hash}#"/>
 {/loop}
 {if="is_file('data/user.css')"}
-  <link type="text/css" rel="stylesheet" href="{$base_path}/data/user.css#" />
+  <link type="text/css" rel="stylesheet" href="{$root_path}/data/user.css#" />
 {/if}
 <link rel="search" type="application/opensearchdescription+xml" href="{$base_path}/open-search#"
       title="Shaarli search - {$shaarlititle}" />
index b08773d8576162861561f359710d89346a69d509..e1fb54dd463d2626c99f83f5e0f2f061c7b6fc51 100644 (file)
                 <div class="thumbnail">
                   {ignore}RainTPL hack: put the 2 src on two different line to avoid path replace bug{/ignore}
                   <a href="{$value.real_url}" aria-hidden="true" tabindex="-1">
-                  <img data-src="{$base_path}/{$value.thumbnail}#" class="b-lazy"
+                  <img data-src="{$root_path}/{$value.thumbnail}#" class="b-lazy"
                     src=""
                     alt="" width="{$thumbnails_width}" height="{$thumbnails_height}" />
                   </a>
index 51bdb2f0b0eb0569f0b42e8d2255ccafb3a334d8..ea84aab97159a1362dda47b493e3ee8cb7670fc5 100644 (file)
@@ -10,7 +10,7 @@
     {/if}
     &middot;
     {'The personal, minimalist, super-fast, database free, bookmarking service'|t} {'by the Shaarli community'|t} &middot;
-    <a href="{$base_path}/doc/html/index.html" rel="nofollow">{'Documentation'|t}</a>
+    <a href="{$root_path}/doc/html/index.html" rel="nofollow">{'Documentation'|t}</a>
       {loop="$plugins_footer.text"}
           {$value}
       {/loop}
@@ -25,7 +25,7 @@
 {/loop}
 
 {loop="$plugins_footer.js_files"}
-       <script src="{$base_path}/{$value}#"></script>
+       <script src="{$root_path}/{$value}#"></script>
 {/loop}
 
 <div id="js-translations" class="hidden">
index b7a56c89b17fb56540e1127acff994122286d035..ac613b35d56080bf0c4a0f303324871082d2e9d4 100644 (file)
@@ -31,7 +31,7 @@
       {loop="$linksToDisplay"}
         <div class="picwall-pictureframe" role="listitem">
           {ignore}RainTPL hack: put the 2 src on two different line to avoid path replace bug{/ignore}
-          <img data-src="{$value.thumbnail}#" class="b-lazy"
+          <img data-src="{$root_path}/{$value.thumbnail}#" class="b-lazy"
                src=""
                alt="" width="{$thumbnails_width}" height="{$thumbnails_height}" />
           <a href="{$value.real_url}"><span class="info">{$value.title}</span></a>
index 05d13556231418de5528e8053a7413f14f239d9d..5c073da645d4dcf0934dfce24773d4990f2dac19 100644 (file)
 
       <div class="center more">
         {"More plugins available"|t}
-        <a href="doc/html/Community-&-Related-software/#third-party-plugins">{"in the documentation"|t}</a>.
+        <a href="{$root_path}/doc/html/Community-&-Related-software/#third-party-plugins">{"in the documentation"|t}</a>.
       </div>
       <div class="center">
         <input type="submit" value="{'Save'|t}" name="save">