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 @@ protected function buildPluginParameters(?string $template): array
|
||||||
'target' => $template,
|
'target' => $template,
|
||||||
'loggedin' => $this->container->loginManager->isLoggedIn(),
|
'loggedin' => $this->container->loginManager->isLoggedIn(),
|
||||||
'basePath' => $this->container->basePath,
|
'basePath' => $this->container->basePath,
|
||||||
|
'rootPath' => preg_replace('#/index\.php$#', '', $this->container->basePath),
|
||||||
'bookmarkService' => $this->container->bookmarkService
|
'bookmarkService' => $this->container->bookmarkService
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,6 +104,7 @@ public function executeHooks($hook, &$data, $params = array())
|
||||||
'target' => '_PAGE_',
|
'target' => '_PAGE_',
|
||||||
'loggedin' => '_LOGGEDIN_',
|
'loggedin' => '_LOGGEDIN_',
|
||||||
'basePath' => '_BASE_PATH_',
|
'basePath' => '_BASE_PATH_',
|
||||||
|
'rootPath' => '_ROOT_PATH_',
|
||||||
'bookmarkService' => '_BOOKMARK_SERVICE_',
|
'bookmarkService' => '_BOOKMARK_SERVICE_',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -174,10 +174,12 @@ protected function finalize(string $basePath): void
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$rootPath = preg_replace('#/index\.php$#', '', $basePath);
|
||||||
$this->assign('base_path', $basePath);
|
$this->assign('base_path', $basePath);
|
||||||
|
$this->assign('root_path', $rootPath);
|
||||||
$this->assign(
|
$this->assign(
|
||||||
'asset_path',
|
'asset_path',
|
||||||
$basePath . '/' .
|
$rootPath . '/' .
|
||||||
rtrim($this->conf->get('resource.raintpl_tpl', 'tpl'), '/') . '/' .
|
rtrim($this->conf->get('resource.raintpl_tpl', 'tpl'), '/') . '/' .
|
||||||
$this->conf->get('resource.theme', 'default')
|
$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.
|
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
|
## 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'`.
|
`PluginManager::$PLUGINS_PATH . '/mything/template.html'`.
|
||||||
|
|
||||||
If it needs to be included in front end side (e.g. an image),
|
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_`:
|
the relative path must be prefixed with special data:
|
||||||
`($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH . '/mything/picture.png`.
|
|
||||||
|
* 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
|
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!
|
### It's not working!
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
function hook_archiveorg_render_linklist($data)
|
function hook_archiveorg_render_linklist($data)
|
||||||
{
|
{
|
||||||
$archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html');
|
$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) {
|
foreach ($data['links'] as &$value) {
|
||||||
$isNote = startsWith($value['real_url'], '/shaare/');
|
$isNote = startsWith($value['real_url'], '/shaare/');
|
||||||
|
|
|
@ -54,7 +54,7 @@ function hook_isso_render_linklist($data, $conf)
|
||||||
if ($conf->get('resource.theme') === 'default') {
|
if ($conf->get('resource.theme') === 'default') {
|
||||||
$button .= '<i class="linklist-plugin-icon fa fa-comment"></i>';
|
$button .= '<i class="linklist-plugin-icon fa fa-comment"></i>';
|
||||||
} else {
|
} 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 .= 'title="Comment on this shaare" alt="Comments" />';
|
||||||
}
|
}
|
||||||
$button .= '</a></span>';
|
$button .= '</a></span>';
|
||||||
|
|
|
@ -19,7 +19,7 @@ function hook_qrcode_render_linklist($data)
|
||||||
{
|
{
|
||||||
$qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html');
|
$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) {
|
foreach ($data['links'] as &$value) {
|
||||||
$qrcode = sprintf(
|
$qrcode = sprintf(
|
||||||
$qrcode_html,
|
$qrcode_html,
|
||||||
|
|
|
@ -45,7 +45,7 @@ function hook_wallabag_render_linklist($data, $conf)
|
||||||
$wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html');
|
$wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html');
|
||||||
|
|
||||||
$linkTitle = t('Save to wallabag');
|
$linkTitle = t('Save to wallabag');
|
||||||
$path = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
|
$path = ($data['_ROOT_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
|
||||||
|
|
||||||
foreach ($data['links'] as &$value) {
|
foreach ($data['links'] as &$value) {
|
||||||
$wallabag = sprintf(
|
$wallabag = sprintf(
|
||||||
|
|
|
@ -76,7 +76,7 @@ <h3 class="window-subtitle">
|
||||||
</div>
|
</div>
|
||||||
{if="$thumbnails_enabled && !empty($link.thumbnail)"}
|
{if="$thumbnails_enabled && !empty($link.thumbnail)"}
|
||||||
<div class="daily-entry-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=""
|
src=""
|
||||||
alt="thumbnail" width="{$thumbnails_width}" height="{$thumbnails_height}" />
|
alt="thumbnail" width="{$thumbnails_width}" height="{$thumbnails_height}" />
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -12,10 +12,10 @@
|
||||||
<link type="text/css" rel="stylesheet" href="{$asset_path}/css/markdown.min.css?v={$version_hash}#" />
|
<link type="text/css" rel="stylesheet" href="{$asset_path}/css/markdown.min.css?v={$version_hash}#" />
|
||||||
{/if}
|
{/if}
|
||||||
{loop="$plugins_includes.css_files"}
|
{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}
|
{/loop}
|
||||||
{if="is_file('data/user.css')"}
|
{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}
|
{/if}
|
||||||
<link rel="search" type="application/opensearchdescription+xml" href="{$base_path}/open-search#"
|
<link rel="search" type="application/opensearchdescription+xml" href="{$base_path}/open-search#"
|
||||||
title="Shaarli search - {$shaarlititle}" />
|
title="Shaarli search - {$shaarlititle}" />
|
||||||
|
|
|
@ -140,7 +140,7 @@
|
||||||
<div class="thumbnail">
|
<div class="thumbnail">
|
||||||
{ignore}RainTPL hack: put the 2 src on two different line to avoid path replace bug{/ignore}
|
{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">
|
<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=""
|
src=""
|
||||||
alt="" width="{$thumbnails_width}" height="{$thumbnails_height}" />
|
alt="" width="{$thumbnails_width}" height="{$thumbnails_height}" />
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
{/if}
|
{/if}
|
||||||
·
|
·
|
||||||
{'The personal, minimalist, super-fast, database free, bookmarking service'|t} {'by the Shaarli community'|t} ·
|
{'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"}
|
{loop="$plugins_footer.text"}
|
||||||
{$value}
|
{$value}
|
||||||
{/loop}
|
{/loop}
|
||||||
|
@ -25,7 +25,7 @@
|
||||||
{/loop}
|
{/loop}
|
||||||
|
|
||||||
{loop="$plugins_footer.js_files"}
|
{loop="$plugins_footer.js_files"}
|
||||||
<script src="{$base_path}/{$value}#"></script>
|
<script src="{$root_path}/{$value}#"></script>
|
||||||
{/loop}
|
{/loop}
|
||||||
|
|
||||||
<div id="js-translations" class="hidden">
|
<div id="js-translations" class="hidden">
|
||||||
|
|
|
@ -31,7 +31,7 @@ <h2 class="window-title">{'Picture Wall'|t} - {$countPics} {'pics'|t}</h2>
|
||||||
{loop="$linksToDisplay"}
|
{loop="$linksToDisplay"}
|
||||||
<div class="picwall-pictureframe" role="listitem">
|
<div class="picwall-pictureframe" role="listitem">
|
||||||
{ignore}RainTPL hack: put the 2 src on two different line to avoid path replace bug{/ignore}
|
{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=""
|
src=""
|
||||||
alt="" width="{$thumbnails_width}" height="{$thumbnails_height}" />
|
alt="" width="{$thumbnails_width}" height="{$thumbnails_height}" />
|
||||||
<a href="{$value.real_url}"><span class="info">{$value.title}</span></a>
|
<a href="{$value.real_url}"><span class="info">{$value.title}</span></a>
|
||||||
|
|
|
@ -117,7 +117,7 @@ <h3 class="window-subtitle">{'Disabled Plugins'|t}</h3>
|
||||||
|
|
||||||
<div class="center more">
|
<div class="center more">
|
||||||
{"More plugins available"|t}
|
{"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>
|
||||||
<div class="center">
|
<div class="center">
|
||||||
<input type="submit" value="{'Save'|t}" name="save">
|
<input type="submit" value="{'Save'|t}" name="save">
|
||||||
|
|
Loading…
Reference in a new issue