diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-10-16 12:47:11 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-10-16 12:47:11 +0200 |
commit | 7f5250421be4832b9679d8140bc4a71c8005dfa3 (patch) | |
tree | a47e846cef666dbd1c2c7d05a01fd32aa8311d4f | |
parent | ec457491879893c8cfcc9dd6542d1593aa5c91f5 (diff) | |
download | Shaarli-7f5250421be4832b9679d8140bc4a71c8005dfa3.tar.gz Shaarli-7f5250421be4832b9679d8140bc4a71c8005dfa3.tar.zst Shaarli-7f5250421be4832b9679d8140bc4a71c8005dfa3.zip |
Support using Shaarli without URL rewriting
- Shaarli can be fully used by prefixing any URL with /index.php/
- {$base_path} used in templates already works with this configuration
- Assets path (outside of theme's assets) must be prefixed with {$root_url}/
- Documentation section in « Server configuration »
Fixes #1590
-rw-r--r-- | application/render/PageBuilder.php | 4 | ||||
-rw-r--r-- | doc/md/Server-configuration.md | 16 | ||||
-rw-r--r-- | plugins/archiveorg/archiveorg.php | 3 | ||||
-rw-r--r-- | plugins/qrcode/qrcode.php | 3 | ||||
-rw-r--r-- | tpl/default/daily.html | 2 | ||||
-rw-r--r-- | tpl/default/includes.html | 4 | ||||
-rw-r--r-- | tpl/default/linklist.html | 2 | ||||
-rw-r--r-- | tpl/default/page.footer.html | 4 | ||||
-rw-r--r-- | tpl/default/picwall.html | 2 | ||||
-rw-r--r-- | tpl/default/pluginsadmin.html | 2 |
10 files changed, 31 insertions, 11 deletions
diff --git a/application/render/PageBuilder.php b/application/render/PageBuilder.php index 41b357dd..2d6d2dbe 100644 --- a/application/render/PageBuilder.php +++ b/application/render/PageBuilder.php | |||
@@ -174,10 +174,12 @@ class PageBuilder | |||
174 | } | 174 | } |
175 | } | 175 | } |
176 | 176 | ||
177 | $rootPath = preg_replace('#/index\.php$#', '', $basePath); | ||
177 | $this->assign('base_path', $basePath); | 178 | $this->assign('base_path', $basePath); |
179 | $this->assign('root_path', $rootPath); | ||
178 | $this->assign( | 180 | $this->assign( |
179 | 'asset_path', | 181 | 'asset_path', |
180 | $basePath . '/' . | 182 | $rootPath . '/' . |
181 | rtrim($this->conf->get('resource.raintpl_tpl', 'tpl'), '/') . '/' . | 183 | rtrim($this->conf->get('resource.raintpl_tpl', 'tpl'), '/') . '/' . |
182 | $this->conf->get('resource.theme', 'default') | 184 | $this->conf->get('resource.theme', 'default') |
183 | ); | 185 | ); |
diff --git a/doc/md/Server-configuration.md b/doc/md/Server-configuration.md index 14070c8a..73302bc6 100644 --- a/doc/md/Server-configuration.md +++ b/doc/md/Server-configuration.md | |||
@@ -362,7 +362,23 @@ sudo systemctl reload nginx | |||
362 | 362 | ||
363 | 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. | 363 | 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. |
364 | 364 | ||
365 | ## Using Shaarli without URL rewriting | ||
365 | 366 | ||
367 | By default, Shaarli uses Slim framework's URL, which requires | ||
368 | URL rewriting. | ||
369 | |||
370 | If you can't use URL rewriting for any reason (not supported by | ||
371 | your web server, shared hosting, etc.), you *can* use Shaarli | ||
372 | without URL rewriting. | ||
373 | |||
374 | You just need to prefix your URL by `/index.php/`. | ||
375 | Example: instead of accessing `https://shaarli.mydomain.org/`, | ||
376 | use `https://shaarli.mydomain.org/index.php/`. | ||
377 | |||
378 | **Recommended:** | ||
379 | * after installation, in the configuration page, set your header link to `/index.php/`. | ||
380 | * in you `config.json.php` set `general.root_url` to | ||
381 | `https://shaarli.mydomain.org/index.php/`. | ||
366 | 382 | ||
367 | ## Allow import of large browser bookmarks export | 383 | ## Allow import of large browser bookmarks export |
368 | 384 | ||
diff --git a/plugins/archiveorg/archiveorg.php b/plugins/archiveorg/archiveorg.php index 922b5966..a7b595e1 100644 --- a/plugins/archiveorg/archiveorg.php +++ b/plugins/archiveorg/archiveorg.php | |||
@@ -17,7 +17,8 @@ use Shaarli\Plugin\PluginManager; | |||
17 | function hook_archiveorg_render_linklist($data) | 17 | function hook_archiveorg_render_linklist($data) |
18 | { | 18 | { |
19 | $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html'); | 19 | $archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html'); |
20 | $path = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH; | 20 | $rootPath = preg_replace('#/index\.php$#', '', $data['_BASE_PATH_'] ?? ''); |
21 | $path = $rootPath . '/' . PluginManager::$PLUGINS_PATH; | ||
21 | 22 | ||
22 | foreach ($data['links'] as &$value) { | 23 | foreach ($data['links'] as &$value) { |
23 | $isNote = startsWith($value['real_url'], '/shaare/'); | 24 | $isNote = startsWith($value['real_url'], '/shaare/'); |
diff --git a/plugins/qrcode/qrcode.php b/plugins/qrcode/qrcode.php index 95499e39..45712859 100644 --- a/plugins/qrcode/qrcode.php +++ b/plugins/qrcode/qrcode.php | |||
@@ -19,7 +19,8 @@ function hook_qrcode_render_linklist($data) | |||
19 | { | 19 | { |
20 | $qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html'); | 20 | $qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html'); |
21 | 21 | ||
22 | $path = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH; | 22 | $rootPath = preg_replace('#/index\.php$#', '', $data['_BASE_PATH_'] ?? ''); |
23 | $path = $rootPath . '/' . PluginManager::$PLUGINS_PATH; | ||
23 | foreach ($data['links'] as &$value) { | 24 | foreach ($data['links'] as &$value) { |
24 | $qrcode = sprintf( | 25 | $qrcode = sprintf( |
25 | $qrcode_html, | 26 | $qrcode_html, |
diff --git a/tpl/default/daily.html b/tpl/default/daily.html index 3ab8053f..3749bffb 100644 --- a/tpl/default/daily.html +++ b/tpl/default/daily.html | |||
@@ -76,7 +76,7 @@ | |||
76 | </div> | 76 | </div> |
77 | {if="$thumbnails_enabled && !empty($link.thumbnail)"} | 77 | {if="$thumbnails_enabled && !empty($link.thumbnail)"} |
78 | <div class="daily-entry-thumbnail"> | 78 | <div class="daily-entry-thumbnail"> |
79 | <img data-src="{$link.thumbnail}#" class="b-lazy" | 79 | <img data-src="{$root_path}/{$link.thumbnail}#" class="b-lazy" |
80 | src="" | 80 | src="" |
81 | alt="thumbnail" width="{$thumbnails_width}" height="{$thumbnails_height}" /> | 81 | alt="thumbnail" width="{$thumbnails_width}" height="{$thumbnails_height}" /> |
82 | </div> | 82 | </div> |
diff --git a/tpl/default/includes.html b/tpl/default/includes.html index 09768ac4..3e3fb664 100644 --- a/tpl/default/includes.html +++ b/tpl/default/includes.html | |||
@@ -12,10 +12,10 @@ | |||
12 | <link type="text/css" rel="stylesheet" href="{$asset_path}/css/markdown.min.css?v={$version_hash}#" /> | 12 | <link type="text/css" rel="stylesheet" href="{$asset_path}/css/markdown.min.css?v={$version_hash}#" /> |
13 | {/if} | 13 | {/if} |
14 | {loop="$plugins_includes.css_files"} | 14 | {loop="$plugins_includes.css_files"} |
15 | <link type="text/css" rel="stylesheet" href="{$base_path}/{$value}?v={$version_hash}#"/> | 15 | <link type="text/css" rel="stylesheet" href="{$root_path}/{$value}?v={$version_hash}#"/> |
16 | {/loop} | 16 | {/loop} |
17 | {if="is_file('data/user.css')"} | 17 | {if="is_file('data/user.css')"} |
18 | <link type="text/css" rel="stylesheet" href="{$base_path}/data/user.css#" /> | 18 | <link type="text/css" rel="stylesheet" href="{$root_path}/data/user.css#" /> |
19 | {/if} | 19 | {/if} |
20 | <link rel="search" type="application/opensearchdescription+xml" href="{$base_path}/open-search#" | 20 | <link rel="search" type="application/opensearchdescription+xml" href="{$base_path}/open-search#" |
21 | title="Shaarli search - {$shaarlititle}" /> | 21 | title="Shaarli search - {$shaarlititle}" /> |
diff --git a/tpl/default/linklist.html b/tpl/default/linklist.html index b08773d8..e1fb54dd 100644 --- a/tpl/default/linklist.html +++ b/tpl/default/linklist.html | |||
@@ -140,7 +140,7 @@ | |||
140 | <div class="thumbnail"> | 140 | <div class="thumbnail"> |
141 | {ignore}RainTPL hack: put the 2 src on two different line to avoid path replace bug{/ignore} | 141 | {ignore}RainTPL hack: put the 2 src on two different line to avoid path replace bug{/ignore} |
142 | <a href="{$value.real_url}" aria-hidden="true" tabindex="-1"> | 142 | <a href="{$value.real_url}" aria-hidden="true" tabindex="-1"> |
143 | <img data-src="{$base_path}/{$value.thumbnail}#" class="b-lazy" | 143 | <img data-src="{$root_path}/{$value.thumbnail}#" class="b-lazy" |
144 | src="" | 144 | src="" |
145 | alt="" width="{$thumbnails_width}" height="{$thumbnails_height}" /> | 145 | alt="" width="{$thumbnails_width}" height="{$thumbnails_height}" /> |
146 | </a> | 146 | </a> |
diff --git a/tpl/default/page.footer.html b/tpl/default/page.footer.html index 51bdb2f0..ea84aab9 100644 --- a/tpl/default/page.footer.html +++ b/tpl/default/page.footer.html | |||
@@ -10,7 +10,7 @@ | |||
10 | {/if} | 10 | {/if} |
11 | · | 11 | · |
12 | {'The personal, minimalist, super-fast, database free, bookmarking service'|t} {'by the Shaarli community'|t} · | 12 | {'The personal, minimalist, super-fast, database free, bookmarking service'|t} {'by the Shaarli community'|t} · |
13 | <a href="{$base_path}/doc/html/index.html" rel="nofollow">{'Documentation'|t}</a> | 13 | <a href="{$root_path}/doc/html/index.html" rel="nofollow">{'Documentation'|t}</a> |
14 | {loop="$plugins_footer.text"} | 14 | {loop="$plugins_footer.text"} |
15 | {$value} | 15 | {$value} |
16 | {/loop} | 16 | {/loop} |
@@ -25,7 +25,7 @@ | |||
25 | {/loop} | 25 | {/loop} |
26 | 26 | ||
27 | {loop="$plugins_footer.js_files"} | 27 | {loop="$plugins_footer.js_files"} |
28 | <script src="{$base_path}/{$value}#"></script> | 28 | <script src="{$root_path}/{$value}#"></script> |
29 | {/loop} | 29 | {/loop} |
30 | 30 | ||
31 | <div id="js-translations" class="hidden"> | 31 | <div id="js-translations" class="hidden"> |
diff --git a/tpl/default/picwall.html b/tpl/default/picwall.html index b7a56c89..ac613b35 100644 --- a/tpl/default/picwall.html +++ b/tpl/default/picwall.html | |||
@@ -31,7 +31,7 @@ | |||
31 | {loop="$linksToDisplay"} | 31 | {loop="$linksToDisplay"} |
32 | <div class="picwall-pictureframe" role="listitem"> | 32 | <div class="picwall-pictureframe" role="listitem"> |
33 | {ignore}RainTPL hack: put the 2 src on two different line to avoid path replace bug{/ignore} | 33 | {ignore}RainTPL hack: put the 2 src on two different line to avoid path replace bug{/ignore} |
34 | <img data-src="{$value.thumbnail}#" class="b-lazy" | 34 | <img data-src="{$root_path}/{$value.thumbnail}#" class="b-lazy" |
35 | src="" | 35 | src="" |
36 | alt="" width="{$thumbnails_width}" height="{$thumbnails_height}" /> | 36 | alt="" width="{$thumbnails_width}" height="{$thumbnails_height}" /> |
37 | <a href="{$value.real_url}"><span class="info">{$value.title}</span></a> | 37 | <a href="{$value.real_url}"><span class="info">{$value.title}</span></a> |
diff --git a/tpl/default/pluginsadmin.html b/tpl/default/pluginsadmin.html index 05d13556..5c073da6 100644 --- a/tpl/default/pluginsadmin.html +++ b/tpl/default/pluginsadmin.html | |||
@@ -117,7 +117,7 @@ | |||
117 | 117 | ||
118 | <div class="center more"> | 118 | <div class="center more"> |
119 | {"More plugins available"|t} | 119 | {"More plugins available"|t} |
120 | <a href="doc/html/Community-&-Related-software/#third-party-plugins">{"in the documentation"|t}</a>. | 120 | <a href="{$root_path}/doc/html/Community-&-Related-software/#third-party-plugins">{"in the documentation"|t}</a>. |
121 | </div> | 121 | </div> |
122 | <div class="center"> | 122 | <div class="center"> |
123 | <input type="submit" value="{'Save'|t}" name="save"> | 123 | <input type="submit" value="{'Save'|t}" name="save"> |