8
0

Merge pull request #153 from khaledh/master

Adds support for landing page per folder (index.md) #38
Dieser Commit ist enthalten in:
Denis Kisselev 2014-05-17 10:56:43 -07:00
Commit ebc53ac80f
2 geänderte Dateien mit 18 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -73,7 +73,7 @@
function directory_tree($dir, $ignore) {
global $base_doc, $multilanguage, $output_language;
$tree = array();
$Item = array_diff(scandir($dir), array(".", "..", "index.md"));
$Item = array_diff(scandir($dir), array(".", ".."));
foreach ($Item as $key => $value) {
if (is_dir($dir . '/' . $value)) {
if (!in_array($value, $ignore['folders']))
@ -115,7 +115,13 @@
$return .= "<li";
if (!(strpos($url, $key) === FALSE)) $return .= " class=\"open\"";
$return .= ">";
$return .= "<a href=\"#\" class=\"aj-nav folder\">";
$link = "#";
$nav_class = "aj-nav ";
if(in_array("index.md", $node)) {
$link = $t . clean_url($key, $mode);
$nav_class = "";
}
$return .= "<a href=\"" . $link . "\" class=\"" . $nav_class . "folder\">";
$return .= clean_url($key, "Title");
$return .= "</a>";
$return .= "<ul class=\"nav nav-list\">";
@ -124,7 +130,7 @@
$return .= "</ul>";
$return .= "</li>";
}
else {
else if($node !== "index.md") {
$return .= "<li";
if ($url === $current_dir . '/' . $node) $return .= " class=\"active\"";
$return .= ">";
@ -139,8 +145,8 @@
function generate_page($file) {
global $base, $base_doc, $base_path, $docs_path, $options, $mode, $relative_base;
$template = $options['template'];
$filename = substr(strrchr($file, "/"), 1);
if ($filename === 'index.md') $homepage = TRUE;
$file_relative_path = str_replace($docs_path . '/', "", $file);
if ($file_relative_path === 'index.md') $homepage = TRUE;
else $homepage = FALSE;
if (!$file) {
$page['path'] = '';
@ -149,7 +155,7 @@
$page['content'] = "<h3>Oh No. That page doesn't exist</h3>";
$options['file_editor'] = false;
} else {
$page['path'] = str_replace($docs_path . '/', "", $file);
$page['path'] = $file_relative_path;
$page['markdown'] = file_get_contents($file);
$page['modified'] = filemtime($file);
$page['content'] = MarkDownExtended($page['markdown']);
@ -184,8 +190,11 @@
return $url;
case 'Title':
case 'Filename':
$t = substr_count($url, '/');
if ($t > 0) $url = substr(strrchr($url, "/"), 1);
$parts = array_reverse(explode('/', $url));
if (isset($parts[0])) {
if ($parts[0] === "index.md" && isset($parts[1])) $url = $parts[1];
else $url = $parts[0];
}
$url = explode('_', $url);
if (isset($url[0]) && is_numeric($url[0])) unset($url[0]);
if ($mode === 'Filename') $url = implode('_', $url);

Datei anzeigen

@ -51,6 +51,7 @@
$file .= '/' . $dirs[$key];
$tree = $tree[$dirs[$key]];
}
if (is_file($file . "/index.md")) $file = $file . "/index.md";
return $file;
}
}