From c34ff07ed03670b6fc1e16c2d3acdf7a49ed8a12 Mon Sep 17 00:00:00 2001 From: Gautham Warrier Date: Thu, 20 Nov 2014 14:49:21 +0530 Subject: [PATCH] Allow Docs directory to be specified via absolute or relative path. Fix insignificant bug in Static Gen --- generate.php | 2 +- libs/daux.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/generate.php b/generate.php index 6791a91..ab000c2 100644 --- a/generate.php +++ b/generate.php @@ -65,7 +65,7 @@ software, even if advised of the possibility of such damage. */ if (isset($argv[1])) $Daux = new \Todaymade\Daux\Daux($argv[1]); - else $Daux = new \Todaymade\Daux\Daux($argv[1]); + else $Daux = new \Todaymade\Daux\Daux(); $Daux->initialize(); if (isset($argv[2])) $Daux->generate_static($argv[2]); else $Daux->generate_static(); diff --git a/libs/daux.php b/libs/daux.php index 305d6dd..45d3764 100644 --- a/libs/daux.php +++ b/libs/daux.php @@ -87,23 +87,27 @@ 'The Global Config file is missing. Requested File : ' . $global_config_file, ErrorPage::FATAL_ERROR_TYPE); return; } + $global_config = json_decode(file_get_contents($global_config_file), true); if (!isset($global_config)) { $this->generate_error_page('Corrupt Global Config File', 'The Global Config file is corrupt. Check that the JSON encoding is correct', ErrorPage::FATAL_ERROR_TYPE); return; } + if (!isset($global_config['docs_directory'])) { $this->generate_error_page('Docs Directory not set', 'The Global Config file does not have the docs directory set.', ErrorPage::FATAL_ERROR_TYPE); return; } - $this->docs_path = $this->local_base . DIRECTORY_SEPARATOR . $global_config['docs_directory']; - if (!is_dir($this->docs_path)) { + + $this->docs_path = $global_config['docs_directory']; + if (!is_dir($this->docs_path) && !is_dir($this->docs_path = $this->local_base . DIRECTORY_SEPARATOR . $this->docs_path)) { $this->generate_error_page('Docs Directory not found', 'The Docs directory does not exist. Check the path again : ' . $this->docs_path, ErrorPage::FATAL_ERROR_TYPE); - return; + return; } + if (!isset($global_config['valid_markdown_extensions'])) static::$VALID_MARKDOWN_EXTENSIONS = array('md', 'markdown'); else static::$VALID_MARKDOWN_EXTENSIONS = $global_config['valid_markdown_extensions']; }