Adds optional custom headers/footers that are propageted to all subfolders.
This commit is contained in:
parent
8a2451474a
commit
289ce2993c
4 changed files with 55 additions and 18 deletions
|
@ -65,8 +65,9 @@ It profits from these great projects:
|
||||||
* drops support for IE7+8 (simple fallback, same as no javascript)
|
* drops support for IE7+8 (simple fallback, same as no javascript)
|
||||||
* uses History API if available (way faster browsing)
|
* uses History API if available (way faster browsing)
|
||||||
* faster thumbnail generation if EXIF thumbnails available
|
* faster thumbnail generation if EXIF thumbnails available
|
||||||
* improves previews
|
* adds optional custom headers/footers that are propageted to all subfolders
|
||||||
* improves packaged downloads
|
* some fixes on previews
|
||||||
|
* speeds up packaged downloads
|
||||||
* add line wrap and line highlighting (on hover) to text preview
|
* add line wrap and line highlighting (on hover) to text preview
|
||||||
* new design (colors, images)
|
* new design (colors, images)
|
||||||
* now uses `SVG` images for the interface
|
* now uses `SVG` images for the interface
|
||||||
|
|
|
@ -2,25 +2,30 @@
|
||||||
modulejs.define('ext/custom', ['_', '$', 'core/settings', 'core/server', 'core/event'], function (_, $, allsettings, server, event) {
|
modulejs.define('ext/custom', ['_', '$', 'core/settings', 'core/server', 'core/event'], function (_, $, allsettings, server, event) {
|
||||||
|
|
||||||
var settings = _.extend({
|
var settings = _.extend({
|
||||||
enabled: false,
|
enabled: false
|
||||||
header: '_h5ai.header.html',
|
|
||||||
footer: '_h5ai.footer.html'
|
|
||||||
}, allsettings.custom),
|
}, allsettings.custom),
|
||||||
|
|
||||||
onLocationChanged = function () {
|
onLocationChanged = function () {
|
||||||
|
|
||||||
$('#content-header, #content-footer').stop(true, true).slideUp(200);
|
|
||||||
|
|
||||||
server.request({action: 'get', custom: true}, function (response) {
|
server.request({action: 'get', custom: true}, function (response) {
|
||||||
|
|
||||||
|
var h, f;
|
||||||
if (response) {
|
if (response) {
|
||||||
if (response.custom.header) {
|
if (response.custom.header) {
|
||||||
$('#content-header').html(response.custom.header).stop(true, true).slideDown(400);
|
$('#content-header').html(response.custom.header).stop().slideDown(200);
|
||||||
|
h = true;
|
||||||
}
|
}
|
||||||
if (response.custom.footer) {
|
if (response.custom.footer) {
|
||||||
$('#content-footer').html(response.custom.footer).stop(true, true).slideDown(400);
|
$('#content-footer').html(response.custom.footer).stop().slideDown(200);
|
||||||
|
f = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!h) {
|
||||||
|
$('#content-header').stop().slideUp(200);
|
||||||
|
}
|
||||||
|
if (!f) {
|
||||||
|
$('#content-footer').stop().slideUp(200);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ Options
|
||||||
- binaryPrefix: set to true uses 1024B=1KiB when formatting file sizes (see http://en.wikipedia.org/wiki/Binary_prefix)
|
- binaryPrefix: set to true uses 1024B=1KiB when formatting file sizes (see http://en.wikipedia.org/wiki/Binary_prefix)
|
||||||
- indexFiles: consider folder with those files as non {{pkg.name}} folders
|
- indexFiles: consider folder with those files as non {{pkg.name}} folders
|
||||||
- ignore: don't list items matching these regular expressions
|
- ignore: don't list items matching these regular expressions
|
||||||
- smartBrowsing: use browser history if available (no need to reload the whole page)
|
- smartBrowsing: use History API if available (no need to reload the whole page)
|
||||||
- extInNewWindow: open non-h5ai links in new window/tab
|
- extInNewWindow: open non-h5ai links in new window/tab
|
||||||
*/
|
*/
|
||||||
"view": {
|
"view": {
|
||||||
|
@ -67,13 +67,16 @@ Options
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Filenames of customized header and footer files to look for
|
Allow customized header and footer files.
|
||||||
in each folder.
|
First looks for files "_h5ai.header.html" and "_h5ai.footer.html"
|
||||||
|
in the current directory.
|
||||||
|
If not found it looks in all parent directories (starting in the
|
||||||
|
current directory) for files "_h5ai.headers.html" and "_h5ai.footers.html"
|
||||||
|
until it finds one.
|
||||||
|
Note the different filenames: header (only current) - headers (recursive)!
|
||||||
*/
|
*/
|
||||||
"custom": {
|
"custom": {
|
||||||
"enabled": true,
|
"enabled": true
|
||||||
"header": "_{{pkg.name}}.header.html",
|
|
||||||
"footer": "_{{pkg.name}}.footer.html"
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/* [EXPERIMENTAL]
|
/* [EXPERIMENTAL]
|
||||||
|
|
|
@ -312,12 +312,40 @@ class App {
|
||||||
|
|
||||||
public function get_customizations($abs_href) {
|
public function get_customizations($abs_href) {
|
||||||
|
|
||||||
$abs_path = $this->get_abs_path($abs_href);
|
if (!$this->options["custom"]["enabled"]) {
|
||||||
|
return array(
|
||||||
|
"header" => null,
|
||||||
|
"footer" => null
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$abs_path = $this->get_abs_path($abs_href);
|
||||||
$file = $abs_path . "/" . App::$FILE_PREFIX . ".header.html";
|
$file = $abs_path . "/" . App::$FILE_PREFIX . ".header.html";
|
||||||
$header = is_string($file) && file_exists($file) ? file_get_contents($file) : null;
|
$header = is_readable($file) ? file_get_contents($file) : null;
|
||||||
$file = $abs_path . "/" . App::$FILE_PREFIX . ".footer.html";
|
$file = $abs_path . "/" . App::$FILE_PREFIX . ".footer.html";
|
||||||
$footer = is_string($file) && file_exists($file) ? file_get_contents($file) : null;
|
$footer = is_readable($file) ? file_get_contents($file) : null;
|
||||||
|
|
||||||
|
$p = $abs_path;
|
||||||
|
while ($header === null || $footer === null) {
|
||||||
|
|
||||||
|
if ($header === null) {
|
||||||
|
$file = $p . "/" . App::$FILE_PREFIX . ".headers.html";
|
||||||
|
$header = is_readable($file) ? file_get_contents($file) : null;
|
||||||
|
}
|
||||||
|
if ($footer === null) {
|
||||||
|
$file = $p . "/" . App::$FILE_PREFIX . ".footers.html";
|
||||||
|
$footer = is_readable($file) ? file_get_contents($file) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($p === $this->root_abs_path) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$pp = normalize_path(dirname($p));
|
||||||
|
if ($pp === $p) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
$p = $pp;
|
||||||
|
}
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
"header" => $header,
|
"header" => $header,
|
||||||
|
|
Loading…
Add table
Reference in a new issue