mirror of
https://github.com/lrsjng/h5ai.git
synced 2025-05-31 15:28:19 -04:00
Clean code.
This commit is contained in:
parent
e497612b6c
commit
9c414c92e2
2 changed files with 22 additions and 27 deletions
|
@ -9,43 +9,37 @@ modulejs.define('ext/custom', ['_', '$', 'core/settings', 'core/server', 'core/e
|
||||||
|
|
||||||
server.request({action: 'get', custom: true, customHref: item.absHref}, function (response) {
|
server.request({action: 'get', custom: true, customHref: item.absHref}, function (response) {
|
||||||
|
|
||||||
var h, f;
|
var has_header, has_footer, data, content;
|
||||||
|
|
||||||
if (response) {
|
if (response) {
|
||||||
|
resource.loadMarkdown(function (md) {
|
||||||
|
|
||||||
if (response.custom.header) {
|
data = response.custom;
|
||||||
if (response.custom.header_type === 'md') {
|
|
||||||
resource.loadMarkdown(function (md) {
|
|
||||||
|
|
||||||
if (md) {
|
if (data.header) {
|
||||||
$('#content-header').html(md.toHTML(response.custom.header)).stop().slideDown(200);
|
content = data.header;
|
||||||
}
|
if (md && data.header_type === 'md') {
|
||||||
});
|
content = md.toHTML(content);
|
||||||
} else {
|
}
|
||||||
$('#content-header').html(response.custom.header).stop().slideDown(200);
|
$('#content-header').html(content).stop().slideDown(200);
|
||||||
|
has_header = true;
|
||||||
}
|
}
|
||||||
h = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.custom.footer) {
|
if (data.footer) {
|
||||||
if (response.custom.footer_type === 'md') {
|
content = data.footer;
|
||||||
resource.loadMarkdown(function (md) {
|
if (md && data.footer_type === 'md') {
|
||||||
|
content = md.toHTML(content);
|
||||||
if (md) {
|
}
|
||||||
$('#content-footer').html(md.toHTML(response.custom.footer)).stop().slideDown(200);
|
$('#content-footer').html(content).stop().slideDown(200);
|
||||||
}
|
has_footer = true;
|
||||||
});
|
|
||||||
} else {
|
|
||||||
$('#content-footer').html(response.custom.footer).stop().slideDown(200);
|
|
||||||
}
|
}
|
||||||
f = true;
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!h) {
|
if (!has_header) {
|
||||||
$('#content-header').stop().slideUp(200);
|
$('#content-header').stop().slideUp(200);
|
||||||
}
|
}
|
||||||
if (!f) {
|
if (!has_footer) {
|
||||||
$('#content-footer').stop().slideUp(200);
|
$('#content-footer').stop().slideUp(200);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -4,6 +4,7 @@ class App {
|
||||||
|
|
||||||
private static $RE_DELIMITER = "|";
|
private static $RE_DELIMITER = "|";
|
||||||
private static $ICON_EXTS = array("svg", "png", "jpg");
|
private static $ICON_EXTS = array("svg", "png", "jpg");
|
||||||
|
private static $CUSTOM_EXTS = array("html", "md");
|
||||||
|
|
||||||
|
|
||||||
private $options;
|
private $options;
|
||||||
|
@ -269,7 +270,7 @@ class App {
|
||||||
|
|
||||||
private function read_custom_file($path, $name, &$content, &$type) {
|
private function read_custom_file($path, $name, &$content, &$type) {
|
||||||
|
|
||||||
foreach (array("html", "md") as $ext) {
|
foreach (APP::$CUSTOM_EXTS as $ext) {
|
||||||
$file = "$path/" . FILE_PREFIX . ".$name.$ext";
|
$file = "$path/" . FILE_PREFIX . ".$name.$ext";
|
||||||
if (is_readable($file)) {
|
if (is_readable($file)) {
|
||||||
$content = file_get_contents($file);
|
$content = file_get_contents($file);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue