diff --git a/src/_h5ai/private/conf/options.json b/src/_h5ai/private/conf/options.json index a570da26..96d17e89 100644 --- a/src/_h5ai/private/conf/options.json +++ b/src/_h5ai/private/conf/options.json @@ -26,6 +26,17 @@ ] }, + /* + Custom Page Titles + - Placeholders available: DIR, PATH + - Link on "mydomain.com/foo/bar" with Pattern "MyShare DIR - PATH" generates "MyShare bar - foo/bar" + - If DIR is "" (doc root) fallback to "index" + (title has 65 and meta has 155 max. chars) + */ + "pagetitle": { + "title": "DIR - powered by h5ai", + "desc": "shared files: PATH" + }, /* diff --git a/src/_h5ai/private/php/core/class-context.php b/src/_h5ai/private/php/core/class-context.php index 0a72cea5..c4711a2f 100644 --- a/src/_h5ai/private/php/core/class-context.php +++ b/src/_h5ai/private/php/core/class-context.php @@ -289,6 +289,18 @@ class Context { $html = ''; + $title = $this->query_option('pagetitle.title', "DIR index - powered by h5ai"); + $meta = $this->query_option('pagetitle.desc', "shared files in PATH"); + + $path = trim($this->setup->get('REQUEST_HREF'), '/') ?: "index"; // fallback to index if root + $dir = substr(strrchr($path, '/'), 1) ?: $path; // fallback to dir = path if path contains no / + + $title = str_replace('DIR', $dir, str_replace('PATH', $path, $title)); + $meta = str_replace('DIR', $dir, str_replace('PATH', $path, $meta )); + + $html .= '' . $title . ''; + $html .= ''; + foreach ($styles as $href) { $html .= ''; } diff --git a/src/_h5ai/private/php/pages/index.php.pug b/src/_h5ai/private/php/pages/index.php.pug index 522a3e78..61810b17 100644 --- a/src/_h5ai/private/php/pages/index.php.pug +++ b/src/_h5ai/private/php/pages/index.php.pug @@ -1,7 +1,6 @@ extends ./page.tpl.pug block init - - var title = `index - powered by h5ai v${pkg.version} (${pkg.homepage})` - var module = 'index' block body diff --git a/src/_h5ai/private/php/pages/info.php.pug b/src/_h5ai/private/php/pages/info.php.pug index 31f8e5a2..208a4176 100644 --- a/src/_h5ai/private/php/pages/info.php.pug +++ b/src/_h5ai/private/php/pages/info.php.pug @@ -1,7 +1,6 @@ extends ./page.tpl.pug block init - - var title = `h5ai info page - v${pkg.version}` - var module = 'info' block body diff --git a/src/_h5ai/private/php/pages/page.tpl.pug b/src/_h5ai/private/php/pages/page.tpl.pug index 9a7526b1..004e507f 100644 --- a/src/_h5ai/private/php/pages/page.tpl.pug +++ b/src/_h5ai/private/php/pages/page.tpl.pug @@ -7,10 +7,9 @@ html(class='no-js', lang='en') head meta(charset='utf-8') meta(http-equiv='x-ua-compatible', content='ie=edge') - title #{title} - meta(name='description', content=title) meta(name='viewport', content='width=device-width, initial-scale=1') link(rel='shortcut icon', href!='images/favicon/favicon-16-32.ico') + meta(property='og:image', content!='images/favicon/favicon-152.png') link(rel='apple-touch-icon-precomposed', type='image/png', href!='images/favicon/favicon-152.png') link(rel='stylesheet', href!='css/styles.css')