Merge pull request #1593 from ArthurHoaro/fix/no-url-rewriting
This commit is contained in:
commit
81c9df1363
15 changed files with 41 additions and 16 deletions
|
@ -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
|
||||
];
|
||||
}
|
||||
|
|
|
@ -104,6 +104,7 @@ class PluginManager
|
|||
'target' => '_PAGE_',
|
||||
'loggedin' => '_LOGGEDIN_',
|
||||
'basePath' => '_BASE_PATH_',
|
||||
'rootPath' => '_ROOT_PATH_',
|
||||
'bookmarkService' => '_BOOKMARK_SERVICE_',
|
||||
];
|
||||
|
||||
|
|
|
@ -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')
|
||||
);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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!
|
||||
|
||||
|
|
|
@ -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/');
|
||||
|
|
|
@ -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>';
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
<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}" />
|
||||
|
|
|
@ -140,7 +140,7 @@
|
|||
<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>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
{/if}
|
||||
·
|
||||
{'The personal, minimalist, super-fast, database free, bookmarking service'|t} {'by the Shaarli community'|t} ·
|
||||
<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">
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -117,7 +117,7 @@
|
|||
|
||||
<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">
|
||||
|
|
Loading…
Reference in a new issue