Refactor Code. Everything Works
This commit is contained in:
parent
4bf7c42854
commit
df1c92134f
94
index.php
94
index.php
@ -62,102 +62,40 @@ negligence or otherwise) arising in any way out of the use of this
|
|||||||
software, even if advised of the possibility of such damage.
|
software, even if advised of the possibility of such damage.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once dirname( __FILE__ ) . '/libs/functions.php';
|
require_once dirname( __FILE__ ) . '/libs/functions.php';
|
||||||
$options = get_options();
|
|
||||||
|
|
||||||
$command_line=FALSE;
|
$command_line=FALSE;
|
||||||
if(isset($argv)){
|
if(isset($argv)){
|
||||||
|
require_once dirname( __FILE__ ) . '/libs/static.php';
|
||||||
define("CLI",TRUE);
|
define("CLI",TRUE);
|
||||||
echo 'Daux.io documentation generator'."\n";
|
echo 'Daux.io documentation generator'."\n";
|
||||||
|
|
||||||
if(!isset($argv[1]))
|
if(!isset($argv[1]))
|
||||||
$argv[1]= 'help';
|
$argv[1]= 'help';
|
||||||
|
|
||||||
switch ($argv[1]) {
|
switch ($argv[1]) {
|
||||||
//Generate static web documentation
|
//Generate static web documentation
|
||||||
case 'generate':
|
case 'generate':
|
||||||
clean_copy_assets(dirname(__FILE__).'/static');
|
generate_static();
|
||||||
|
echo "Finished\n";
|
||||||
//Generate index.html
|
|
||||||
$markdown_structure = array();
|
|
||||||
$base_url = '.';
|
|
||||||
$index = generate_page($options, array(''), $base_url, TRUE, $markdown_structure);
|
|
||||||
file_put_contents('./static/index.html', $index);
|
|
||||||
echo '.';
|
|
||||||
|
|
||||||
foreach ($markdown_structure as $element) {
|
|
||||||
echo '.';
|
|
||||||
$flat_tree_tmp = array();
|
|
||||||
if( preg_match('/\.\/(.*)\/(.*)$/', $element['url'], $final_folder) ){
|
|
||||||
@mkdir('./static/'.$final_folder[1]);
|
|
||||||
|
|
||||||
$url_params = preg_split('/\//',$final_folder[1] );
|
|
||||||
$folder_count = count($url_params);
|
|
||||||
array_push( $url_params , $final_folder[2] );
|
|
||||||
|
|
||||||
$base_url = relative_base($folder_count);
|
|
||||||
$file = generate_page($options, $url_params, $base_url, TRUE, $flat_tree_tmp);
|
|
||||||
file_put_contents('./static/'.$final_folder[1].'/'.$final_folder[2].'.html', $file);
|
|
||||||
}else{
|
|
||||||
$strFile = str_replace('./', '', $element['url']);
|
|
||||||
$base_url = '.';
|
|
||||||
$file = generate_page($options, array($strFile), $base_url, TRUE, $flat_tree_tmp);
|
|
||||||
file_put_contents('./static/'.$strFile.'.html', $file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
echo "finished\n";
|
|
||||||
echo "The documentation is generated in static folder\n";
|
|
||||||
break;
|
|
||||||
//Generate one-page documentation
|
|
||||||
case 'full-doc':
|
|
||||||
clean_copy_assets(dirname(__FILE__).'/static');
|
|
||||||
|
|
||||||
$options['template'] ='full-doc';
|
|
||||||
$markdown_structure = array();
|
|
||||||
//Generate index.html
|
|
||||||
$markdown_structure = array();
|
|
||||||
$base_url = '.';
|
|
||||||
$index = generate_page($options, array(''), $base_url, TRUE, $markdown_structure);
|
|
||||||
file_put_contents('./static/full-doc.html', load_tpl_block('full-doc-blocks/head', $options, $base_url).$index);
|
|
||||||
echo '.';
|
|
||||||
array_pop($markdown_structure);
|
|
||||||
|
|
||||||
foreach ($markdown_structure as $element) {
|
|
||||||
echo '.';
|
|
||||||
$flat_tree_tmp = array();
|
|
||||||
if( preg_match('/\.\/(.*)\/(.*)$/', $element['url'], $final_folder) ){
|
|
||||||
$url_params = preg_split('/\//',$final_folder[1] );
|
|
||||||
$folder_count = count($url_params);
|
|
||||||
array_push( $url_params , $final_folder[2] );
|
|
||||||
|
|
||||||
$file = generate_page($options, $url_params, $base_url, TRUE, $flat_tree_tmp);
|
|
||||||
file_put_contents('./static/full-doc.html', $file, FILE_APPEND);
|
|
||||||
}else{
|
|
||||||
$strFile = str_replace('./', '', $element['url']);
|
|
||||||
$file = generate_page($options, array($strFile), $base_url, TRUE, $flat_tree_tmp);
|
|
||||||
file_put_contents('./static/full-doc.html', $file, FILE_APPEND);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
file_put_contents('./static/full-doc.html', file_get_contents('template/full-doc-blocks/foot.tpl'), FILE_APPEND);
|
|
||||||
echo "finished\n";
|
|
||||||
echo "The documentation is generated in static folder\n";
|
echo "The documentation is generated in static folder\n";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
echo "\n";
|
echo "\n";
|
||||||
echo 'Usage:'."\n";
|
echo 'Usage:'."\n";
|
||||||
echo ' php index.php generate'."\n";
|
echo ' php index.php generate'."\n";
|
||||||
echo ' php index.php full-doc'."\n";
|
echo 'Generate static web'."\n";
|
||||||
echo "\n";
|
|
||||||
echo 'generate. Generate static web'."\n";
|
|
||||||
echo 'fulldoc. Generate one-file documentation static html'."\n";
|
|
||||||
echo "\n";
|
echo "\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
require_once(dirname( __FILE__)."/libs/live.php");
|
||||||
|
$base_path = str_replace("/index.php", "", $_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
|
||||||
define("CLI", FALSE);
|
define("CLI", FALSE);
|
||||||
|
build_tree();
|
||||||
$url_params = url_params();
|
$remove = array($base_path . '/');
|
||||||
generate_page($options, $url_params, get_base_url());
|
if (!$options['clean_urls']) $remove[] = 'index.php?';
|
||||||
|
$request = str_replace($remove, "", $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']);
|
||||||
|
if (isset($_POST['markdown']) && $options['file_editor'])
|
||||||
|
file_put_contents(clean_url_to_file($request), $_POST['markdown']);
|
||||||
|
echo generate_live($request);
|
||||||
|
@ -1,583 +1,230 @@
|
|||||||
<?php
|
<?php
|
||||||
// Enable for debugging
|
|
||||||
// ini_set('display_errors', 1);
|
|
||||||
// error_reporting(E_ALL);
|
|
||||||
|
|
||||||
/*
|
require_once(dirname( __FILE__)."/markdown_extended.php");
|
||||||
* WARNING: DO NOT EDIT THIS FILE.
|
$tree = array();
|
||||||
* If you edit this file, you will not be able to update to new versions of
|
$base = dirname(dirname(__FILE__));
|
||||||
* Daux.io without overwritting your changes. Instead use the config.json file
|
$options = get_options();
|
||||||
* in the /docs folder to customize your documentation.
|
$docs_path = $base . '/' . $options['docs_path'];
|
||||||
*
|
$multilanguage = !empty($options['languages']) ? TRUE : FALSE;
|
||||||
* Want to add a new feature? Send me a pull request or open an issue - https://github.com/justinwalsh/daux.io
|
|
||||||
*
|
// Options
|
||||||
* Learn more about what you can customize here: http://daux.io
|
function get_options() {
|
||||||
*/
|
global $base;
|
||||||
|
$options = array(
|
||||||
require_once dirname( __FILE__) . '/markdown_extended.php';
|
'title' => "Documentation",
|
||||||
|
'tagline' => false,
|
||||||
// Check for homepage
|
'image' => false,
|
||||||
$homepage = (get_uri(false) === "") ? true : false;
|
'theme' => 'red',
|
||||||
|
'docs_path' => 'docs',
|
||||||
// Stores the base url under which daux is running
|
'date_modified' => true,
|
||||||
global $base_url;
|
'float' => true,
|
||||||
$base_url = '/';
|
'repo' => false,
|
||||||
|
'toggle_code' => false,
|
||||||
// Set the base url of where the script is located
|
'twitter' => array(),
|
||||||
if (isset($_SERVER['SCRIPT_NAME']))
|
'links' => array(),
|
||||||
{
|
'colors' => false,
|
||||||
$base_url = substr($_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'] , '/')); // find the full URL to this application from server root
|
'clean_urls' => true,
|
||||||
}
|
'google_analytics' => false,
|
||||||
|
'piwik_analytics' => false,
|
||||||
// Hide annoying date() Warnings due to no Timezone being set.
|
'piwik_analytics_id' => 1,
|
||||||
if( ! ini_get('date.timezone') )
|
'ignore' => array(),
|
||||||
{
|
'languages' => array(),
|
||||||
date_default_timezone_set('GMT');
|
'file_editor' => false,
|
||||||
}
|
'template' => 'default'
|
||||||
|
);
|
||||||
|
// Load User Config
|
||||||
function get_base_url()
|
$config_file = $base . '/docs/config.json';
|
||||||
{
|
if (file_exists($config_file)) {
|
||||||
global $base_url;
|
$config = json_decode(file_get_contents($config_file), true);
|
||||||
return $base_url;
|
$options = array_merge($options, $config);
|
||||||
};
|
}
|
||||||
|
if (!isset($options['ignore']['files'])) $options['ignore']['files'] = array();
|
||||||
// Daux.io Functions
|
if (!isset($options['ignore']['folders'])) $options['ignore']['folders'] = array();
|
||||||
function get_options() {
|
|
||||||
$options = array(
|
if ($options['theme'] !== 'custom') {
|
||||||
'title' => "Documentation",
|
$themes = array("blue","navy","green","red");
|
||||||
'tagline' => false,
|
if (!in_array($options['theme'], $themes)) {
|
||||||
'image' => false,
|
echo "<strong>Daux.io Config Error:</strong><br>The theme you set is not not a valid option. Please use one of the following options: " . join(array_keys($themes), ', ') . ' or <a href="http://daux.io">learn more</a> about how to customize the colors.';
|
||||||
'theme' => 'blue',
|
exit;
|
||||||
'docs_path' => 'docs',
|
}
|
||||||
'date_modified' => true,
|
} else {
|
||||||
'float' => true,
|
if (empty($options['colors'])) {
|
||||||
'repo' => false,
|
echo '<strong>Daux.io Config Error:</strong><br>You are trying to use a custom theme, but did not setup your color options in the config. <a href="http://daux.io">Learn more</a> about how to customize the colors.';
|
||||||
'toggle_code' => false,
|
exit;
|
||||||
'twitter' => array(),
|
}
|
||||||
'links' => array(),
|
}
|
||||||
'colors' => false,
|
return $options;
|
||||||
'clean_urls' => true,
|
}
|
||||||
'google_analytics' => false,
|
|
||||||
'piwik_analytics' => false,
|
// Build Directory Tree
|
||||||
'piwik_analytics_id' => 1,
|
function build_tree() {
|
||||||
'ignore' => array(),
|
global $tree, $options, $docs_path , $multilanguage, $output_language;
|
||||||
'languages' => array(),
|
if (!$multilanguage) $tree = directory_tree($docs_path, $options['ignore']);
|
||||||
'file_editor' => false,
|
else
|
||||||
'template' => 'default'
|
foreach ($options['languages'] as $languageKey => $language) {
|
||||||
);
|
$output_language = $languageKey;
|
||||||
|
$tree[$languageKey] = directory_tree($docs_path . '/' . $languageKey, $options['ignore']);
|
||||||
// Load User Config
|
}
|
||||||
$config_file = './docs/config.json';
|
}
|
||||||
if (file_exists($config_file)) {
|
|
||||||
$config = json_decode(file_get_contents($config_file), true);
|
// Recursively add files & directories to Tree
|
||||||
$options = array_merge($options, $config);
|
function directory_tree($dir, $ignore) {
|
||||||
}
|
global $base_doc, $multilanguage, $output_language;
|
||||||
|
$tree = array();
|
||||||
if ($options['theme'] !== 'custom') {
|
$Item = array_diff(scandir($dir), array(".", "..", "index.md"));
|
||||||
// Load Theme
|
foreach ($Item as $key => $value) {
|
||||||
if (!in_array($options['theme'], array("blue","navy","green","red"))) {
|
if (is_dir($dir . '/' . $value)) {
|
||||||
echo "<strong>Daux.io Config Error:</strong><br>The theme you set is not not a valid option. Please use one of the following options: " . join(array_keys($themes), ', ') . ' or <a href="http://daux.io">learn more</a> about how to customize the colors.';
|
if (!in_array($value, $ignore['folders']))
|
||||||
exit;
|
$tree[$value] = directory_tree($dir . '/' . $value, $ignore);
|
||||||
}
|
} else if (!in_array($value, $ignore['files'])) {
|
||||||
} else {
|
if (substr($value, -3) === ".md") {
|
||||||
if (empty($options['colors'])) {
|
$tree[$value] = $value;
|
||||||
echo '<strong>Daux.io Config Error:</strong><br>You are trying to use a custom theme, but did not setup your color options in the config. <a href="http://daux.io">Learn more</a> about how to customize the colors.';
|
if ($multilanguage)
|
||||||
exit;
|
$base_doc[$output_language] = isset($base_doc[$output_language]) ? $base_doc[$output_language] : $dir . '/' . $value;
|
||||||
}
|
else $base_doc = isset($base_doc) ? $base_doc : $dir . '/' . $value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return $options;
|
}
|
||||||
}
|
return $tree;
|
||||||
|
}
|
||||||
function homepage_url($tree) {
|
|
||||||
// Check for homepage
|
// Build Navigation
|
||||||
if (isset($tree['index'])) {
|
function get_navigation($url) {
|
||||||
return '/';
|
global $tree, $multilanguage, $output_language, $output_path;
|
||||||
} else {
|
$dir = isset($output_path) ? $output_path : '';
|
||||||
return docs_url($tree, false);
|
$return = "<ul class=\"nav nav-list\">";
|
||||||
}
|
$return .= $multilanguage ? build_navigation($tree[$output_language], (($dir !== '') ? $dir . '/' : '') . $output_language, $url) : build_navigation($tree, $dir, $url);
|
||||||
}
|
$return .= "</ul>";
|
||||||
|
return $return;
|
||||||
function docs_url($tree, $branch = false) {
|
}
|
||||||
// Get next branch
|
|
||||||
if (!$branch) {
|
function build_navigation($tree, $current_dir, $url) {
|
||||||
$branch = current($tree);
|
global $mode, $base_path, $docs_path, $options;
|
||||||
}
|
$return = "";
|
||||||
|
if ($mode === 'Static') $t = relative_path($current_dir . "/.", $url) . '/';
|
||||||
if ($branch['type'] === 'file') {
|
else {
|
||||||
return $branch['url'];
|
$t = "http://" . $base_path . '/';
|
||||||
} else if (!empty($branch['tree'])) {
|
if (!$options['clean_urls']) $t .= 'index.php?';
|
||||||
return docs_url($branch['tree']);
|
$rel = clean_url($current_dir, 'Live');
|
||||||
} else {
|
$t .= ($rel === '') ? '' : $rel . '/';
|
||||||
// Try next folder...
|
}
|
||||||
$branch = next($tree);
|
foreach ($tree as $key => $node)
|
||||||
if ($branch) {
|
if (is_array($node)) {
|
||||||
return docs_url($tree, $branch);
|
$return .= "<li";
|
||||||
} else {
|
if (!(strpos($url, $key) === FALSE)) $return .= " class=\"open\"";
|
||||||
echo '<strong>Daux.io Config Error:</strong><br>Unable to find the first page in the /docs folder. Double check you have at least one file in the root of of the /docs folder. Also make sure you do not have any empty folders. Visit the docs to <a href="http://daux.io">learn more</a> about how the default routing works.';
|
$return .= ">";
|
||||||
exit;
|
$return .= "<a href=\"#\" class=\"aj-nav folder\">";
|
||||||
}
|
$return .= clean_url($key, "Title");
|
||||||
}
|
$return .= "</a>";
|
||||||
}
|
$return .= "<ul class=\"nav nav-list\">";
|
||||||
|
$dir = ($current_dir === '') ? $key : $current_dir . '/' . $key;
|
||||||
function load_page($tree, $url_params) {
|
$return .= build_navigation($node, $dir, $url);
|
||||||
if (count($url_params) > 0) {
|
$return .= "</ul>";
|
||||||
$branch = find_branch($tree, $url_params);
|
$return .= "</li>";
|
||||||
} else {
|
}
|
||||||
$branch = current($tree);
|
else {
|
||||||
}
|
$return .= "<li";
|
||||||
|
if ($url === $current_dir . '/' . $node) $return .= " class=\"active\"";
|
||||||
$page = array();
|
$return .= ">";
|
||||||
|
$link = $t . clean_url($node, $mode);
|
||||||
if (isset($branch['type']) && $branch['type'] == 'file') {
|
$return .= "<a href=\"" . $link . "\">" . clean_url($node, "Title");
|
||||||
$html = '';
|
$return .= "</a></li>";
|
||||||
if ($branch['name'] !== 'index') {
|
}
|
||||||
|
return $return;
|
||||||
$page['title'] = $branch['title'];
|
}
|
||||||
$page['modified'] = filemtime($branch['path']);
|
|
||||||
|
// Generate Documentation from Markdown file
|
||||||
}
|
function generate_page($file) {
|
||||||
$html .= MarkdownExtended(file_get_contents($branch['path']));
|
global $base, $base_doc, $base_path, $docs_path, $options, $mode, $relative_base;
|
||||||
|
$template = $options['template'];
|
||||||
// Markdown editor related
|
$filename = substr(strrchr($file, "/"), 1);
|
||||||
$page['markdown'] = file_get_contents($branch['path']);
|
if ($filename === 'index.md') $homepage = TRUE;
|
||||||
$page['path'] = $branch['path'];
|
else $homepage = FALSE;
|
||||||
|
if (!$file) {
|
||||||
$page['html'] = $html;
|
$page['path'] = '';
|
||||||
|
$page['markdown'] = '';
|
||||||
} else {
|
$page['content'] = '';
|
||||||
|
$page['title'] = 'Oh No';
|
||||||
$page['title'] = "Oh no";
|
$page['content'] = "<h3>Oh No. That page doesn't exist</h3>";
|
||||||
$page['html'] = "<h3>Oh No. That page doesn't exist</h3>";
|
$options['file_editor'] = false;
|
||||||
|
} else {
|
||||||
}
|
$page['path'] = str_replace($docs_path . '/', "", $file);
|
||||||
|
$page['markdown'] = file_get_contents($file);
|
||||||
|
$page['content'] = MarkDownExtended($page['markdown']);
|
||||||
return $page;
|
$page['title'] = clean_url($file, 'Title');
|
||||||
}
|
}
|
||||||
|
$relative_base = ($mode === 'Static') ? relative_path("", $file) : "http://" . $base_path . '/';
|
||||||
|
ob_start();
|
||||||
function find_branch($tree, $url_params) {
|
include($base . "/template/" . $template . ".tpl");
|
||||||
foreach($url_params as $peice) {
|
$return = ob_get_contents();
|
||||||
|
@ob_end_clean();
|
||||||
// Support for cyrillic URLs
|
return $return;
|
||||||
$peice = urldecode($peice);
|
}
|
||||||
|
|
||||||
// Check for homepage
|
// File to URL
|
||||||
if (empty($peice)) {
|
function clean_url($url, $mode = 'Static') {
|
||||||
$peice = 'index';
|
global $docs_path, $output_path, $options;
|
||||||
}
|
switch ($mode) {
|
||||||
|
case 'Live':
|
||||||
if (isset($tree[$peice])) {
|
$url = str_replace(array(".md", ".html", ".php"), "", $url);
|
||||||
if ($tree[$peice]['type'] == 'folder') {
|
case 'Static':
|
||||||
$tree = $tree[$peice]['tree'];
|
$url = str_replace(".md", ".html", $url);
|
||||||
} else {
|
$remove = array($docs_path . '/');
|
||||||
$tree = $tree[$peice];
|
if (isset($output_path)) $remove[] = $output_path . '/';
|
||||||
}
|
$url = str_replace($remove, "", $url);
|
||||||
} else {
|
$url = explode('/', $url);
|
||||||
return false;
|
foreach ($url as &$a) {
|
||||||
}
|
$a = explode('_', $a);
|
||||||
}
|
if (isset($a[0]) && is_numeric($a[0])) unset($a[0]);
|
||||||
|
$a = implode('_', $a);
|
||||||
return $tree;
|
}
|
||||||
}
|
$url = implode('/', $url);
|
||||||
|
return $url;
|
||||||
function url_path() {
|
case 'Title':
|
||||||
$url = parse_url((isset($_SERVER['REQUEST_URI']))?$_SERVER['REQUEST_URI']:'');
|
case 'Filename':
|
||||||
$url = $url['path'];
|
$t = substr_count($url, '/');
|
||||||
return $url;
|
if ($t > 0) $url = substr(strrchr($url, "/"), 1);
|
||||||
}
|
$url = explode('_', $url);
|
||||||
|
if (isset($url[0]) && is_numeric($url[0])) unset($url[0]);
|
||||||
function url_params() {
|
if ($mode === 'Filename') $url = implode('_', $url);
|
||||||
$url = rawurldecode(get_uri());
|
else $url = implode(' ', $url);
|
||||||
$params = explode('/', trim($url, '/'));
|
$url = str_replace(array(".md", ".html"), "", $url);
|
||||||
return $params;
|
return $url;
|
||||||
}
|
|
||||||
|
}
|
||||||
function clean_sort($text) {
|
}
|
||||||
// Remove .md file extension
|
|
||||||
$text = str_replace('.md', '', $text);
|
// Get Path based on Server. For Use in template file.
|
||||||
|
function get_url($url) {
|
||||||
// Remove sort placeholder
|
global $mode, $options, $relative_base;
|
||||||
$parts = explode('_', $text);
|
$t = clean_url($url, $mode);
|
||||||
if (isset($parts[0]) && is_numeric($parts[0])) {
|
if ($t === 'index') {
|
||||||
unset($parts[0]);
|
if ($mode === 'Static') return $relative_base . 'index.html';
|
||||||
}
|
else return $relative_base;
|
||||||
$text = implode('_', $parts);
|
}
|
||||||
|
if ($mode === 'Live' && !$options['clean_urls']) $t = 'index.php?' . $t;
|
||||||
return $text;
|
return $t;
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean_name($text) {
|
// Relative Path From Path2 to Path1
|
||||||
$text = str_replace('_', ' ', $text);
|
function relative_path($path1, $path2) {
|
||||||
return $text;
|
global $output_path, $docs_path, $base;
|
||||||
}
|
$remove = array($docs_path . '/');
|
||||||
|
if (isset($output_path)) $remove[] = $output_path . '/';
|
||||||
function RFC3986UrlEncode($string) {
|
$remove[] = $base . '/';
|
||||||
$entities = array('%21', '%2A', '%27', '%28', '%29', '%3B', '%3A', '%40', '%26', '%3D', '%2B', '%24', '%2C', '%2F', '%3F', '%25', '%23', '%5B', '%5D');
|
$path1 = str_replace($remove, "", $path1);
|
||||||
$replacements = array('!', '*', "'", "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]");
|
$path2 = str_replace($remove, "", $path2);
|
||||||
return str_replace($entities, $replacements, urlencode($string));
|
$nesting = substr_count($path2, "/");
|
||||||
}
|
if ($nesting == 0) return clean_url($path1);
|
||||||
|
$return = "";
|
||||||
function build_nav($tree, $url_params) {
|
$t = 0;
|
||||||
// Remove Index
|
while ($t < $nesting) {
|
||||||
unset($tree['index']);
|
$return .= "../";
|
||||||
|
$t += 1;
|
||||||
$url_path = url_path();
|
}
|
||||||
$html = '<ul class="nav nav-list">';
|
$return .= clean_url($path1);
|
||||||
foreach($tree as $key => $val) {
|
return $return;
|
||||||
// Active Tree Node
|
}
|
||||||
if (isset($url_params[0]) && $url_params[0] == $val['clean']) {
|
|
||||||
array_shift($url_params);
|
|
||||||
|
?>
|
||||||
// Final Node
|
|
||||||
if ($url_path == RFC3986UrlEncode($val['url'])) {
|
|
||||||
$html .= '<li class="active">';
|
|
||||||
} else {
|
|
||||||
$html .= '<li class="open">';
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$html .= '<li>';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($val['type'] == 'folder') {
|
|
||||||
$html .= '<a href="#" class="aj-nav folder">'.$val['name'].'</a>';
|
|
||||||
$html .= build_nav($val['tree'], $url_params);
|
|
||||||
} else {
|
|
||||||
$html .= '<a href="'.$val['url'].((CLI)?'.html':'').'">'.$val['name'].'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
$html .= '</li>';
|
|
||||||
}
|
|
||||||
$html .= '</ul>';
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_ignored() {
|
|
||||||
// TODO: Add support for wildcards
|
|
||||||
// TODO: Add support for specific paths, i.e. /Publish/Somefile.md vs. /Don't_Publish/Somefile.md
|
|
||||||
$options = get_options();
|
|
||||||
$default_ignored_files = array('config.json', 'cgi-bin', 'Thumbs.db');
|
|
||||||
$default_ignored_folders = array(); // To allow for easy addition of default folders if found necessary in the future
|
|
||||||
$user_ignored_files = array();
|
|
||||||
$user_ignored_folders = array();
|
|
||||||
// Check if ignore settings exist
|
|
||||||
if(array_key_exists('ignore', $options)) {
|
|
||||||
if(array_key_exists('files', $options['ignore'])) {
|
|
||||||
$user_ignored_files = $options['ignore']['files'];
|
|
||||||
}
|
|
||||||
if(array_key_exists('folders', $options['ignore'])) {
|
|
||||||
$user_ignored_folders = $options['ignore']['folders'];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Merge all ignore arrays together
|
|
||||||
$all_ignored = array_merge($default_ignored_files, $default_ignored_folders, $user_ignored_files, $user_ignored_folders);
|
|
||||||
|
|
||||||
// Return array of all ignored files and folders
|
|
||||||
return $all_ignored;
|
|
||||||
}
|
|
||||||
|
|
||||||
function get_tree($path = '.', $clean_path = '', $title = '', $first = true, $language = null, &$flat_tree = null){
|
|
||||||
$options = get_options();
|
|
||||||
$tree = array();
|
|
||||||
$ignore = get_ignored();
|
|
||||||
$dh = @opendir($path);
|
|
||||||
$index = 0;
|
|
||||||
|
|
||||||
// Build array of paths
|
|
||||||
$paths = array();
|
|
||||||
while(false !== ($file = readdir($dh))){
|
|
||||||
$paths[$file] = $file;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close the directory handle
|
|
||||||
closedir($dh);
|
|
||||||
|
|
||||||
// Sort paths
|
|
||||||
sort($paths);
|
|
||||||
|
|
||||||
if ($first && $language !== null) {
|
|
||||||
$language_path = $language . "/";
|
|
||||||
} else {
|
|
||||||
$language_path = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loop through the paths
|
|
||||||
// while(false !== ($file = readdir($dh))){
|
|
||||||
foreach($paths as $file) {
|
|
||||||
|
|
||||||
// Check that this file or folder is not to be ignored
|
|
||||||
if(!in_array($file, $ignore) && $file[0] !== '.') {
|
|
||||||
$full_path = "$path/$file";
|
|
||||||
$clean_sort = clean_sort($file);
|
|
||||||
|
|
||||||
// If clean_urls is set to false and this is the first branch of the tree, append index.php to the clean_path.
|
|
||||||
if($options['clean_urls'] == false)
|
|
||||||
{
|
|
||||||
if($first)
|
|
||||||
{
|
|
||||||
$url = $clean_path . '/' . $language_path . 'index.php/' . $clean_sort;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$url = $clean_path . '/' . $language_path . $clean_sort;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$url = $clean_path . '/' . $language_path . $clean_sort;
|
|
||||||
}
|
|
||||||
|
|
||||||
$clean_name = clean_name($clean_sort);
|
|
||||||
|
|
||||||
// Title
|
|
||||||
if (empty($title)) {
|
|
||||||
$full_title = $clean_name;
|
|
||||||
} else {
|
|
||||||
$full_title = $title . ': ' . $clean_name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(is_dir("$path/$file")) {
|
|
||||||
// Directory
|
|
||||||
$tree[$clean_sort] = array(
|
|
||||||
'type' => 'folder',
|
|
||||||
'name' => $clean_name,
|
|
||||||
'title' => $full_title,
|
|
||||||
'path' => $full_path,
|
|
||||||
'clean' => $clean_sort,
|
|
||||||
'url' => $url,
|
|
||||||
'tree'=> (isset($flat_tree) && $flat_tree!==NULL)?
|
|
||||||
get_tree($full_path, $url, $full_title, false, $language, $flat_tree):
|
|
||||||
get_tree($full_path, $url, $full_title, false, $language)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
// File
|
|
||||||
$tree[$clean_sort] = array(
|
|
||||||
'type' => 'file',
|
|
||||||
'name' => $clean_name,
|
|
||||||
'title' => $full_title,
|
|
||||||
'path' => $full_path,
|
|
||||||
'clean' => $clean_sort,
|
|
||||||
'url' => $url,
|
|
||||||
);
|
|
||||||
|
|
||||||
if(isset($flat_tree) && $flat_tree!==NULL)
|
|
||||||
array_push($flat_tree, $tree[$clean_sort]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$index++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $tree;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get's the current "pretty" URI from the URL. It will also correct the QUERY_STRING server var and the $_GET array.
|
|
||||||
* It supports all forms of mod_rewrite and the following forms of URL:
|
|
||||||
*
|
|
||||||
* http://example.com/index.php/foo (returns '/foo')
|
|
||||||
* http://example.com/index.php?/foo (returns '/foo')
|
|
||||||
* http://example.com/index.php/foo?baz=bar (returns '/foo')
|
|
||||||
* http://example.com/index.php?/foo?baz=bar (returns '/foo')
|
|
||||||
*
|
|
||||||
* Similarly using mod_rewrite to remove index.php:
|
|
||||||
* http://example.com/foo (returns '/foo')
|
|
||||||
* http://example.com/foo?baz=bar (returns '/foo')
|
|
||||||
*
|
|
||||||
* @author Dan Horrigan <http://dhorrigan.com>
|
|
||||||
* @copyright Dan Horrigan
|
|
||||||
* @license MIT License <http://www.opensource.org/licenses/mit-license.php>
|
|
||||||
* @param bool $prefix_slash whether to return the uri with a '/' in front
|
|
||||||
* @return string the uri
|
|
||||||
*/
|
|
||||||
function get_uri($prefix_slash = true)
|
|
||||||
{
|
|
||||||
if (isset($_SERVER['PATH_INFO']))
|
|
||||||
{
|
|
||||||
$uri = $_SERVER['PATH_INFO'];
|
|
||||||
}
|
|
||||||
elseif (isset($_SERVER['REQUEST_URI']))
|
|
||||||
{
|
|
||||||
$uri = $_SERVER['REQUEST_URI'];
|
|
||||||
if (strpos($uri, $_SERVER['SCRIPT_NAME']) === 0)
|
|
||||||
{
|
|
||||||
$uri = substr($uri, strlen($_SERVER['SCRIPT_NAME']));
|
|
||||||
}
|
|
||||||
elseif (strpos($uri, dirname($_SERVER['SCRIPT_NAME'])) === 0)
|
|
||||||
{
|
|
||||||
$uri = substr($uri, strlen(dirname($_SERVER['SCRIPT_NAME'])));
|
|
||||||
}
|
|
||||||
|
|
||||||
// This section ensures that even on servers that require the URI to be in the query string (Nginx) a correct
|
|
||||||
// URI is found, and also fixes the QUERY_STRING server var and $_GET array.
|
|
||||||
if (strncmp($uri, '?/', 2) === 0)
|
|
||||||
{
|
|
||||||
$uri = substr($uri, 2);
|
|
||||||
}
|
|
||||||
$parts = preg_split('#\?#i', $uri, 2);
|
|
||||||
$uri = $parts[0];
|
|
||||||
if (isset($parts[1]))
|
|
||||||
{
|
|
||||||
$_SERVER['QUERY_STRING'] = $parts[1];
|
|
||||||
parse_str($_SERVER['QUERY_STRING'], $_GET);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$_SERVER['QUERY_STRING'] = '';
|
|
||||||
$_GET = array();
|
|
||||||
}
|
|
||||||
$uri = parse_url($uri, PHP_URL_PATH);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Couldn't determine the URI, so just return false
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do some final cleaning of the URI and return it
|
|
||||||
return ($prefix_slash ? '/' : '').str_replace(array('//', '../'), '/', trim($uri, '/'));
|
|
||||||
}
|
|
||||||
|
|
||||||
function handle_editor_post($post, $page) {
|
|
||||||
if(file_exists($page["path"])) {
|
|
||||||
file_put_contents($page["path"], $post["markdown"]);
|
|
||||||
} else {
|
|
||||||
throw new Exception("File doesn't exist", 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate the page using the correct $url_params
|
|
||||||
*/
|
|
||||||
|
|
||||||
function generate_page($options, $url_params, $base_url, $return=FALSE, &$flat_tree=NULL){
|
|
||||||
//documentation folder defined in various folder languages
|
|
||||||
if (count($options['languages']) > 0 && count($url_params) > 0 && strlen($url_params[0]) > 0) {
|
|
||||||
$language = array_shift($url_params);
|
|
||||||
$base_path = $options['docs_path']. DIRECTORY_SEPARATOR . $language;
|
|
||||||
} else {
|
|
||||||
$language = null;
|
|
||||||
$base_path = $options['docs_path'];
|
|
||||||
}
|
|
||||||
|
|
||||||
// If a timezone has been set in the config file, override the default PHP timezone for this application.
|
|
||||||
if(isset($options['timezone']))
|
|
||||||
{
|
|
||||||
date_default_timezone_set($options['timezone']);
|
|
||||||
}
|
|
||||||
|
|
||||||
$tree = (isset($flat_tree))?
|
|
||||||
get_tree($base_path, $base_url, '', true, $language,$flat_tree):
|
|
||||||
get_tree($base_path, $base_url, '', true, $language);
|
|
||||||
|
|
||||||
// If a language is set in the config, rewrite urls based on the language
|
|
||||||
if (! isset($language) || $language === null) {
|
|
||||||
$homepage_url = homepage_url($tree);
|
|
||||||
} else {
|
|
||||||
$homepage_url = "/";
|
|
||||||
}
|
|
||||||
|
|
||||||
if($url_params[0]=='')
|
|
||||||
$homepage = TRUE;
|
|
||||||
else
|
|
||||||
$homepage = FALSE;
|
|
||||||
|
|
||||||
// Redirect to docs, if there is no homepage
|
|
||||||
if ($homepage && $homepage_url !== '/') {
|
|
||||||
header('Location: '.docs_url($tree));
|
|
||||||
}
|
|
||||||
|
|
||||||
$docs_url = docs_url($tree);
|
|
||||||
$page = load_page($tree, $url_params);
|
|
||||||
|
|
||||||
|
|
||||||
// Handle AJAX requests for file editing
|
|
||||||
if(isset($_POST["markdown"]) && $options["file_editor"] === true) {
|
|
||||||
handle_editor_post($_POST, $page);
|
|
||||||
die;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ob_start();
|
|
||||||
|
|
||||||
include('template/'.$options['template'].'.tpl');
|
|
||||||
if ($return === TRUE)
|
|
||||||
{
|
|
||||||
$buffer = ob_get_contents();
|
|
||||||
@ob_end_clean();
|
|
||||||
return $buffer;
|
|
||||||
}else{
|
|
||||||
ob_end_flush();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function load_tpl_block($file, $options, $base_url){
|
|
||||||
ob_start();
|
|
||||||
|
|
||||||
include('template/'.$file.'.tpl');
|
|
||||||
$buffer = ob_get_contents();
|
|
||||||
@ob_end_clean();
|
|
||||||
return $buffer;
|
|
||||||
}
|
|
||||||
|
|
||||||
function copy_recursive($source, $dest, $ignoreList = array()){
|
|
||||||
$src_folder=str_replace(array('.','/'), '', $source);
|
|
||||||
@mkdir($dest.DIRECTORY_SEPARATOR.$src_folder);
|
|
||||||
foreach (
|
|
||||||
$iterator = new RecursiveIteratorIterator(
|
|
||||||
new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
|
|
||||||
RecursiveIteratorIterator::SELF_FIRST) as $item
|
|
||||||
) {
|
|
||||||
if ($item->isDir()) {
|
|
||||||
@mkdir($dest . DIRECTORY_SEPARATOR . $src_folder . DIRECTORY_SEPARATOR .$iterator->getSubPathName());
|
|
||||||
} else {
|
|
||||||
if (!$ignoreList || !in_array($item, $ignoreList)) @copy($item, $dest . DIRECTORY_SEPARATOR .$src_folder. DIRECTORY_SEPARATOR .$iterator->getSubPathName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function clean_directory($directory){
|
|
||||||
foreach (
|
|
||||||
$iterator = new RecursiveIteratorIterator(
|
|
||||||
new RecursiveDirectoryIterator($directory, RecursiveDirectoryIterator::SKIP_DOTS),
|
|
||||||
RecursiveIteratorIterator::SELF_FIRST) as $item
|
|
||||||
) {
|
|
||||||
@unlink($directory.DIRECTORY_SEPARATOR.$iterator->getSubPathName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function relative_base($count){
|
|
||||||
$relative = '';
|
|
||||||
for ($i=0; ($i < $count); $i++ ){
|
|
||||||
if (! ($i == 0))
|
|
||||||
$relative .= '/';
|
|
||||||
$relative .= '..';
|
|
||||||
}
|
|
||||||
return $relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
function clean_copy_assets($path){
|
|
||||||
@mkdir($path);
|
|
||||||
$options = $GLOBALS["options"];
|
|
||||||
//Clean
|
|
||||||
clean_directory($path);
|
|
||||||
//Copy assets
|
|
||||||
$unnecessaryImgs = array('./img/favicon.png', './img/favicon-blue.png', './img/favicon-green.png', './img/favicon-navy.png', './img/favicon-red.png');
|
|
||||||
$unnecessaryJs = array();
|
|
||||||
if ($options['colors']) {
|
|
||||||
@mkdir($path.'/less');
|
|
||||||
@mkdir($path.'/less/import');
|
|
||||||
@copy('./less/import/daux-base.less', $path.'/less/import/daux-base.less');
|
|
||||||
$unnecessaryImgs = array_diff($unnecessaryImgs, array('./img/favicon.png'));
|
|
||||||
} else {
|
|
||||||
$unnecessaryJs = array('./js/less.min.js');
|
|
||||||
@mkdir($path.'/css');
|
|
||||||
@copy('./css/daux-'.$options['theme'].'.min.css', $path.'/css/daux-'.$options['theme'].'.min.css');
|
|
||||||
$unnecessaryImgs = array_diff($unnecessaryImgs, array('./img/favicon-'.$options['theme'].'.png'));
|
|
||||||
}
|
|
||||||
copy_recursive('./img', $path.'/', $unnecessaryImgs);
|
|
||||||
copy_recursive('./js', $path.'/', $unnecessaryJs);
|
|
||||||
}
|
|
||||||
|
51
libs/live.php
Normal file
51
libs/live.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
// Generate Page
|
||||||
|
function generate_live($page) {
|
||||||
|
global $options, $multilanguage, $output_language, $base, $base_path, $mode;
|
||||||
|
$mode = 'Live';
|
||||||
|
if ($multilanguage) {
|
||||||
|
$b = explode('/', clean_url($page, "Live"));
|
||||||
|
$output_language = $b[0];
|
||||||
|
}
|
||||||
|
return generate_page(clean_url_to_file($page));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean Live Url
|
||||||
|
function clean_live($url) {
|
||||||
|
return clean_url($url, "Live");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Retrieve File From Clean URL
|
||||||
|
function clean_url_to_file($url) {
|
||||||
|
global $tree, $docs_path;
|
||||||
|
$location = getfile($tree, $url, $docs_path);
|
||||||
|
return $location;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get File from $url
|
||||||
|
function getfile($tree, $url, $current_dir, $flag = FALSE) {
|
||||||
|
global $docs_path, $base_doc, $options;
|
||||||
|
$url = clean_url($url, "Live");
|
||||||
|
if ($url === '' || $url === 'index') {
|
||||||
|
if (is_file($docs_path . "/index.md")) return $docs_path . "/index.md";
|
||||||
|
else {
|
||||||
|
if (empty($options['languages'])) return $base_doc;
|
||||||
|
else return $base_doc[array_keys($base_doc)[0]];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$url = explode("/", $url);
|
||||||
|
$file = $docs_path;
|
||||||
|
foreach ($url as $part) {
|
||||||
|
$dirs = array_keys($tree);
|
||||||
|
$key = array_search($part, array_map("clean_live", $dirs));
|
||||||
|
if ($key === FALSE) {
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
$file .= '/' . $dirs[$key];
|
||||||
|
$tree = $tree[$dirs[$key]];
|
||||||
|
}
|
||||||
|
return $file;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
90
libs/static.php
Normal file
90
libs/static.php
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// Generate Static Documentation
|
||||||
|
function generate_static() {
|
||||||
|
global $tree, $base, $docs_path, $output_path, $options, $mode, $multilanguage, $output_language;
|
||||||
|
$mode = 'Static';
|
||||||
|
$output_path = $base . '/static';
|
||||||
|
clean_copy_assets($output_path);
|
||||||
|
build_tree();
|
||||||
|
if (!$multilanguage) generate_static_branch($tree, '');
|
||||||
|
else
|
||||||
|
foreach ($options['languages'] as $languageKey => $language) {
|
||||||
|
$output_language = $languageKey;
|
||||||
|
generate_static_branch($tree[$languageKey], $languageKey);
|
||||||
|
}
|
||||||
|
$index = $docs_path . '/index.md';
|
||||||
|
if (is_file($index)) {
|
||||||
|
$index = generate_page($index);
|
||||||
|
file_put_contents($output_path . '/index.html', $index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Generate Static Content For Given Directory
|
||||||
|
function generate_static_branch($tree, $current_dir) {
|
||||||
|
global $docs_path, $output_path;
|
||||||
|
$p = $output_path;
|
||||||
|
if ($current_dir !== '') {
|
||||||
|
$p .= '/' . clean_url($current_dir);
|
||||||
|
$current_dir .= '/';
|
||||||
|
}
|
||||||
|
if (!is_dir($p)) @mkdir($p);
|
||||||
|
foreach ($tree as $key => $node)
|
||||||
|
if (is_array($node)) generate_static_branch($node, $current_dir . $key);
|
||||||
|
else {
|
||||||
|
$html = generate_page($docs_path . '/' . $current_dir . $node);
|
||||||
|
file_put_contents($p . "/" . clean_url($node), $html);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rmdir
|
||||||
|
function clean_directory($dir) {
|
||||||
|
$it = new RecursiveDirectoryIterator($dir);
|
||||||
|
$files = new RecursiveIteratorIterator($it,
|
||||||
|
RecursiveIteratorIterator::CHILD_FIRST);
|
||||||
|
foreach($files as $file) {
|
||||||
|
if ($file->getFilename() === '.' || $file->getFilename() === '..') continue;
|
||||||
|
if ($file->isDir()) rmdir($file->getRealPath());
|
||||||
|
else unlink($file->getRealPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy Local Assets
|
||||||
|
function clean_copy_assets($path){
|
||||||
|
@mkdir($path);
|
||||||
|
$options = $GLOBALS["options"];
|
||||||
|
//Clean
|
||||||
|
clean_directory($path);
|
||||||
|
//Copy assets
|
||||||
|
$unnecessaryImgs = array('./img/favicon.png', './img/favicon-blue.png', './img/favicon-green.png', './img/favicon-navy.png', './img/favicon-red.png');
|
||||||
|
$unnecessaryJs = array();
|
||||||
|
if ($options['colors']) {
|
||||||
|
$unnecessaryLess = array('./less/daux-blue.less', './less/daux-green.less', './less/daux-navy.less', './less/daux-red.less');
|
||||||
|
copy_recursive('./less', $path.'/', $unnecessaryLess);
|
||||||
|
$unnecessaryImgs = array_diff($unnecessaryImgs, array('./img/favicon.png'));
|
||||||
|
} else {
|
||||||
|
$unnecessaryJs = array('./js/less.min.js');
|
||||||
|
@mkdir($path.'/css');
|
||||||
|
@copy('./css/daux-'.$options['theme'].'.min.css', $path.'/css/daux-'.$options['theme'].'.min.css');
|
||||||
|
$unnecessaryImgs = array_diff($unnecessaryImgs, array('./img/favicon-'.$options['theme'].'.png'));
|
||||||
|
}
|
||||||
|
copy_recursive('./img', $path.'/', $unnecessaryImgs);
|
||||||
|
copy_recursive('./js', $path.'/', $unnecessaryJs);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Copy Recursive
|
||||||
|
function copy_recursive($source, $dest, $ignoreList = array()) {
|
||||||
|
$src_folder=str_replace(array('.','/'), '', $source);
|
||||||
|
@mkdir($dest . '/' . $src_folder);
|
||||||
|
foreach (
|
||||||
|
$iterator = new RecursiveIteratorIterator(
|
||||||
|
new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
|
||||||
|
RecursiveIteratorIterator::SELF_FIRST) as $item
|
||||||
|
) {
|
||||||
|
if ($item->isDir()) @mkdir($dest . '/' . $src_folder . '/' .$iterator->getSubPathName());
|
||||||
|
else if (!$ignoreList || !in_array($item, $ignoreList)) @copy($item, $dest . '/' .$src_folder. '/' .$iterator->getSubPathName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -1,17 +1,17 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
|
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
|
||||||
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
|
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
|
||||||
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
|
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
|
||||||
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
|
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
|
||||||
<head>
|
<head>
|
||||||
<title><?php echo $options['title']; ?></title>
|
<title><?php echo $options['title']; ?></title>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
<meta name="description" content="<?php echo $options['tagline'];?>" />
|
<meta name="description" content="<?php echo $options['tagline'];?>" />
|
||||||
<meta name="author" content="<?php echo $options['title']; ?>">
|
<meta name="author" content="<?php echo $options['title']; ?>">
|
||||||
<?php if ($options['colors']) { ?>
|
<?php if ($options['colors']) { ?>
|
||||||
<link rel="icon" href="<?php echo $base_url ?>/img/favicon.png" type="image/x-icon">
|
<link rel="icon" href="<?php echo $relative_base; ?>img/favicon.png" type="image/x-icon">
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<link rel="icon" href="<?php echo $base_url ?>/img/favicon-<?php echo $options['theme'];?>.png" type="image/x-icon">
|
<link rel="icon" href="<?php echo $relative_base; ?>img/favicon-<?php echo $options['theme'];?>.png" type="image/x-icon">
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<!-- Mobile -->
|
<!-- Mobile -->
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
@ -23,22 +23,22 @@
|
|||||||
<!-- LESS -->
|
<!-- LESS -->
|
||||||
<?php if ($options['colors']) { ?>
|
<?php if ($options['colors']) { ?>
|
||||||
<style type="text/less">
|
<style type="text/less">
|
||||||
|
@import "<?php echo $relative_base; ?>less/import/daux-base.less";
|
||||||
<?php foreach($options['colors'] as $k => $v) { ?>
|
<?php foreach($options['colors'] as $k => $v) { ?>
|
||||||
@<?php echo $k;?>: <?php echo $v;?>;
|
@<?php echo $k;?>: <?php echo $v;?>;
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@import "<?php echo $base_url ?>/less/import/daux-base.less";
|
|
||||||
</style>
|
</style>
|
||||||
<script src="<?php echo $base_url ?>/js/less.min.js"></script>
|
<script src="<?php echo $relative_base; ?>js/less.min.js"></script>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<link rel="stylesheet" href="<?php echo $base_url ?>/css/daux-<?php echo $options['theme'];?>.min.css">
|
<link rel="stylesheet" href="<?php echo $relative_base; ?>css/daux-<?php echo $options['theme'];?>.min.css">
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php if ($homepage) { ?>
|
<?php if ($homepage) { ?>
|
||||||
<!-- Hompage -->
|
<!-- Homepage -->
|
||||||
<div class="navbar navbar-fixed-top">
|
<div class="navbar navbar-fixed-top">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a class="brand navbar-brand pull-left" href="<?php echo $base_url ?><?php echo $homepage_url;?>"><?php echo $options['title']; ?></a>
|
<a class="brand navbar-brand pull-left" href="<?php echo get_url('index'); ?>"><?php echo $options['title']; ?></a>
|
||||||
<p class="navbar-text pull-right">
|
<p class="navbar-text pull-right">
|
||||||
Generated by <a href="http://daux.io">Daux.io</a>
|
Generated by <a href="http://daux.io">Daux.io</a>
|
||||||
</p>
|
</p>
|
||||||
@ -57,7 +57,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-10 col-sm-offset-1">
|
<div class="col-sm-10 col-sm-offset-1">
|
||||||
<?php if ($options['image']) { ?>
|
<?php if ($options['image']) { ?>
|
||||||
<img class="homepage-image img-responsive" src="<?php echo $base_url ?>/<?php echo $options['image'];?>" alt="<?php echo $options['title'];?>">
|
<img class="homepage-image img-responsive" src="<?php echo $options['image'];?>" alt="<?php echo $options['title'];?>">
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -75,12 +75,12 @@
|
|||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if (count($options['languages']) > 0) { ?>
|
<?php if (count($options['languages']) > 0) { ?>
|
||||||
<?php foreach ($options['languages'] as $language_key => $language_name) { ?>
|
<?php foreach ($options['languages'] as $language_key => $language_name) { ?>
|
||||||
<a href="<?php echo $base_url . "/" . $language_key . "/"; ?>" class="btn btn-primary btn-hero">
|
<a href="<?php echo get_url($base_doc[$language_key]); ?>" class="btn btn-primary btn-hero">
|
||||||
<?php echo $language_name; ?>
|
<?php echo $language_name; ?>
|
||||||
</a>
|
</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<a href="<?php echo $docs_url;?>" class="btn btn-primary btn-hero">
|
<a href="<?php echo get_url($base_doc);?>" class="btn btn-primary btn-hero">
|
||||||
View Documentation
|
View Documentation
|
||||||
</a>
|
</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
@ -93,7 +93,7 @@
|
|||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-10 col-sm-offset-1">
|
<div class="col-sm-10 col-sm-offset-1">
|
||||||
<?php echo $page['html'];?>
|
<?php echo $page['content'];?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -134,7 +134,7 @@
|
|||||||
<div class="container-fluid fluid-height wrapper">
|
<div class="container-fluid fluid-height wrapper">
|
||||||
<div class="navbar navbar-fixed-top">
|
<div class="navbar navbar-fixed-top">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="brand navbar-brand pull-left" href="<?php echo $base_url ?><?php echo $homepage_url;?>"><?php echo $options['title']; ?></a>
|
<a class="brand navbar-brand pull-left" href="<?php echo get_url('index'); ?>"><?php echo $options['title']; ?></a>
|
||||||
<p class="navbar-text pull-right">
|
<p class="navbar-text pull-right">
|
||||||
Generated by <a href="http://daux.io">Daux.io</a>
|
Generated by <a href="http://daux.io">Daux.io</a>
|
||||||
</p>
|
</p>
|
||||||
@ -153,8 +153,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="sub-nav-collapse" class="sub-nav-collapse">
|
<div id="sub-nav-collapse" class="sub-nav-collapse">
|
||||||
<!-- Navigation -->
|
<!-- Navigation -->
|
||||||
<?php echo build_nav($tree, $url_params); ?>
|
<?php echo get_navigation($file); ?>
|
||||||
|
|
||||||
<?php if (!empty($options['links']) || !empty($options['twitter'])) { ?>
|
<?php if (!empty($options['links']) || !empty($options['twitter'])) { ?>
|
||||||
<div class="well well-sidebar">
|
<div class="well well-sidebar">
|
||||||
<!-- Links -->
|
<!-- Links -->
|
||||||
@ -181,7 +180,7 @@
|
|||||||
<?php if($options['date_modified'] && isset($page['modified'])) { ?>
|
<?php if($options['date_modified'] && isset($page['modified'])) { ?>
|
||||||
<div class="page-header sub-header clearfix">
|
<div class="page-header sub-header clearfix">
|
||||||
<h1><?php echo $page['title'];?>
|
<h1><?php echo $page['title'];?>
|
||||||
<?php if($options["file_editor"]) { ?>
|
<?php if ($mode === 'Live' && $options["file_editor"]) { ?>
|
||||||
<a href="javascript:;" id="editThis" class="btn">Edit this page</a>
|
<a href="javascript:;" id="editThis" class="btn">Edit this page</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</h1>
|
</h1>
|
||||||
@ -195,14 +194,14 @@
|
|||||||
<?php } else { ?>
|
<?php } else { ?>
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h1><?php echo (isset($page['title']))?$page['title']:$options['title'];?></h1>
|
<h1><?php echo (isset($page['title']))?$page['title']:$options['title'];?></h1>
|
||||||
<?php if($options["file_editor"]) { ?>
|
<?php if ($mode === 'Live' && $options["file_editor"]) { ?>
|
||||||
<a href="javascript:;" id="editThis" class="btn">Edit this page</a>
|
<a href="javascript:;" id="editThis" class="btn">Edit this page</a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php echo $page['html'];?>
|
<?php echo $page['content']; ?>
|
||||||
<?php if($options["file_editor"]) { ?>
|
<?php if ($mode === 'Live' && $options["file_editor"]) { ?>
|
||||||
<div class="editor <?php if(!$options['date_modified']) { ?>paddingTop<?php } ?>">
|
<div class="editor <?php if(!$options['date_modified']) { ?>paddingTop<?php } ?>">
|
||||||
<h3>You are editing <?php echo $page['path']; ?> <a href="javascript:;" class="closeEditor btn btn-warning">Close</a></h3>
|
<h3>You are editing <?php echo $page['path']; ?> <a href="javascript:;" class="closeEditor btn btn-warning">Close</a></h3>
|
||||||
<div class="navbar navbar-inverse navbar-default navbar-fixed-bottom" role="navigation">
|
<div class="navbar navbar-inverse navbar-default navbar-fixed-bottom" role="navigation">
|
||||||
@ -223,53 +222,51 @@
|
|||||||
|
|
||||||
<?php if ($options['google_analytics']) { ?>
|
<?php if ($options['google_analytics']) { ?>
|
||||||
<script>
|
<script>
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||||
|
|
||||||
ga('create', '<?php echo $options['google_analytics'];?>', '<?php echo (isset($_SERVER['HTTP_HOST']))?$_SERVER['HTTP_HOST']:''; ?>');
|
ga('create', '<?php echo $options['google_analytics'];?>', '<?php echo (isset($_SERVER['HTTP_HOST']))?$_SERVER['HTTP_HOST']:''; ?>');
|
||||||
ga('send', 'pageview');
|
ga('send', 'pageview');
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
<?php if ($options['piwik_analytics']) { ?>
|
<?php if ($options['piwik_analytics']) { ?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var _paq = _paq || [];
|
var _paq = _paq || [];
|
||||||
_paq.push(["trackPageView"]);
|
_paq.push(["trackPageView"]);
|
||||||
_paq.push(["enableLinkTracking"]);
|
_paq.push(["enableLinkTracking"]);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://<?php echo $options['piwik_analytics'];?>/";
|
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://<?php echo $options['piwik_analytics'];?>/";
|
||||||
_paq.push(["setTrackerUrl", u+"piwik.php"]);
|
_paq.push(["setTrackerUrl", u+"piwik.php"]);
|
||||||
_paq.push(["setSiteId", <?php echo $options['piwik_analytics_id'];?>]);
|
_paq.push(["setSiteId", <?php echo $options['piwik_analytics_id'];?>]);
|
||||||
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
|
var d=document, g=d.createElement("script"), s=d.getElementsByTagName("script")[0]; g.type="text/javascript";
|
||||||
g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
|
g.defer=true; g.async=true; g.src=u+"piwik.js"; s.parentNode.insertBefore(g,s);
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
|
||||||
<!-- hightlight.js -->
|
<!-- hightlight.js -->
|
||||||
<script src="<?php echo $base_url ?>/js/highlight.min.js"></script>
|
<script src="<?php echo $relative_base; ?>js/highlight.min.js"></script>
|
||||||
<script>hljs.initHighlightingOnLoad();</script>
|
<script>hljs.initHighlightingOnLoad();</script>
|
||||||
|
|
||||||
<!-- Navigation -->
|
<!-- Navigation -->
|
||||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
|
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
|
||||||
|
|
||||||
<?php if($options["file_editor"]) { ?>
|
|
||||||
<!-- Front end file editor -->
|
|
||||||
<script src="<?php echo $base_url ?>/js/editor.js"></script>
|
|
||||||
<?php } ?>
|
|
||||||
<script>
|
<script>
|
||||||
if (typeof jQuery == 'undefined') {
|
if (typeof jQuery == 'undefined')
|
||||||
document.write(unescape("%3Cscript src='<?php echo $base_url ?>/js/jquery-1.11.0.min.js' type='text/javascript'%3E%3C/script%3E"));
|
document.write(unescape("%3Cscript src='<?php echo $relative_base; ?>js/jquery-1.11.0.min.js' type='text/javascript'%3E%3C/script%3E"));
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
<script src="<?php echo $base_url ?>/js/bootstrap.min.js"></script>
|
<?php if ($mode === 'Live' && $options["file_editor"]) { ?>
|
||||||
<script src="<?php echo $base_url ?>/js/custom.js"></script>
|
<!-- Front end file editor -->
|
||||||
|
<script src="<?php echo $relative_base; ?>js/editor.js"></script>
|
||||||
|
<?php } ?>
|
||||||
|
<script src="<?php echo $relative_base; ?>js/bootstrap.min.js"></script>
|
||||||
|
<script src="<?php echo $relative_base; ?>js/custom.js"></script>
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
</body>
|
|
||||||
</html>
|
|
@ -1,45 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title><?php echo $options['title']; ?></title>
|
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
||||||
<meta name="description" content="<?php echo $options['tagline'];?>" />
|
|
||||||
<meta name="author" content="<?php echo $options['title']; ?>">
|
|
||||||
<?php if ($options['colors']) { ?>
|
|
||||||
<link rel="icon" href="<?php echo $base_url ?>/img/favicon.png" type="image/x-icon">
|
|
||||||
<?php } else { ?>
|
|
||||||
<link rel="icon" href="<?php echo $base_url ?>/img/favicon-<?php echo $options['theme'];?>.png" type="image/x-icon">
|
|
||||||
<?php } ?>
|
|
||||||
|
|
||||||
<!-- LESS -->
|
|
||||||
<?php if ($options['colors']) { ?>
|
|
||||||
<style type="text/less">
|
|
||||||
<?php foreach($options['colors'] as $k => $v) { ?>
|
|
||||||
@<?php echo $k;?>: <?php echo $v;?>;
|
|
||||||
<?php } ?>
|
|
||||||
@import "<?php echo $base_url ?>/less/import/daux-base.less";
|
|
||||||
</style>
|
|
||||||
<script src="<?php echo $base_url ?>/js/less.min.js"></script>
|
|
||||||
<?php } else { ?>
|
|
||||||
<link rel="stylesheet" href="<?php echo $base_url ?>/css/daux-<?php echo $options['theme'];?>.min.css">
|
|
||||||
<?php } ?>
|
|
||||||
<link rel="stylesheet" href="<?php echo $base_url ?>/css/full-doc.css">
|
|
||||||
|
|
||||||
<!-- hightlight.js -->
|
|
||||||
<script src="<?php echo $base_url ?>/js/highlight.min.js"></script>
|
|
||||||
<script>hljs.initHighlightingOnLoad();</script>
|
|
||||||
|
|
||||||
<!-- Navigation -->
|
|
||||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
|
|
||||||
<script>
|
|
||||||
if (typeof jQuery == 'undefined') {
|
|
||||||
document.write(unescape("%3Cscript src='<?php echo $base_url ?>/js/jquery-1.11.0.min.js' type='text/javascript'%3E%3C/script%3E"));
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<script src="<?php echo $base_url ?>/js/bootstrap.min.js"></script>
|
|
||||||
<script src="<?php echo $base_url ?>/js/custom.js"></script>
|
|
||||||
<!--[if lt IE 9]>
|
|
||||||
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
|
|
||||||
<![endif]-->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
@ -1,5 +0,0 @@
|
|||||||
<div class="page-header">
|
|
||||||
<h1><?php echo (isset($page['title']))?$page['title']:$options['title'];?></h1>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php echo $page['html'];?>
|
|
Loading…
Reference in New Issue
Block a user