From 33b81443044cda7d003784726f51b8c747e1b843 Mon Sep 17 00:00:00 2001 From: Gautham Warrier Date: Sat, 8 Mar 2014 11:31:32 +0530 Subject: [PATCH] Add support for passing config.json and Output directory as parameters in CLI Remove unnecessary line from libs/functions.php Add './static' to gitignore Add Default Timezone to prevent Date() Warnings --- .gitignore | 3 ++- README.md | 6 +++-- docs/00_Getting_Started.md | 52 +++++++++++++++++++++++++++++++++++--- index.php | 2 +- libs/functions.php | 9 ++++--- libs/static.php | 8 ++++-- 6 files changed, 66 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 3dcd9e9..5120c5e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules .DS_Store -/sftp-config.json \ No newline at end of file +/sftp-config.json +static diff --git a/README.md b/README.md index c7f5dd1..44223dc 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ * Git/SVN Friendly * Supports Google Analytics and Piwik Analytics * Optional code float layout +* Static Output Generation ## Demos @@ -317,11 +318,12 @@ Generating a complete set of pages, with navigation php index.php generate ``` -Generating just one big file with each doc concatenated +You can optionally pass the location of config.json and (also optionally) the output directory for the static file ```bash -php index.php full-doc +php index.php generate '\path\to\config.json' 'out\dir' ``` +If the directory has a '\' at the beginning, it is treated as an absolute path, otherwise as relative to the Daux Directory. ## Running on IIS diff --git a/docs/00_Getting_Started.md b/docs/00_Getting_Started.md index a1ccfc7..73c780e 100644 --- a/docs/00_Getting_Started.md +++ b/docs/00_Getting_Started.md @@ -15,6 +15,7 @@ * Git/SVN Friendly * Supports Google Analytics and Piwik Analytics * Optional code float layout +* Static Output Generation ## Demos @@ -22,6 +23,8 @@ This is a list of sites using Daux.io: * [Daux.io](http://daux.io) * [Munee: Standalone PHP 5.3 Asset Optimisation & Manipulation](http://mun.ee) +* [ICADMIN: An admin panel powered by CodeIgniter.](http://istocode.com/shared/ic-admin/) +* [Daux.io in Chinese - Demonstrates muti-language installations](http://daux.emx2.co.uk/) Do you use Daux.io? Send me a pull request or open an [issue](https://github.com/justinwalsh/daux.io/issues) and I will add you to the list. @@ -131,13 +134,21 @@ To create a custom color scheme, set the `theme` property to `custom` and then d ``` ###Code Floating: -By deafult your code blocks will be floated to a column on the right side of your content. To disable this feature, set the `float` property to `false`. +By default your code blocks will be floated to a column on the right side of your content. To disable this feature, set the `float` property to `false`. ```json { "float": false } ``` +###Toggling Code Blocks +Some users might wish to hide the code blocks & view just the documentation. By setting the `toggle_code` property to `true`, you can offer a toggle button on the page. + +```json +{ + "toggle_code": true +} +``` ###GitHub Repo: @@ -172,6 +183,8 @@ Include custom links in the sidebar. ``` ###File editor: +![File editor](https://f.cloud.github.com/assets/1788727/1954191/44358884-81d1-11e3-859d-254b9fb81808.png) + Enable front-end Markdown editor. _Disabled by default_. ```json @@ -245,6 +258,37 @@ If your server does not have a default timezone set in php.ini, it may return er } ``` +###Multi-language +Enables multi-language support which needs seperate directories for each language in `docs/` folder. + +```json +{ + "languages": { "en": "English", "de": "German" } +} +``` + +Directory structure: +``` +├── docs/ +│ ├── index.md +│ ├── en +│ │ ├── 00_Getting_Started.md +│ │ ├── 01_Examples +│ │ │ ├── 01_GitHub_Flavored_Markdown.md +│ │ │ ├── 05_Code_Highlighting.md +│ │ ├── 05_More_Examples +│ │ │ ├── Hello_World.md +│ │ │ ├── 05_Code_Highlighting.md +│ ├── de +│ │ ├── 00_Getting_Started.md +│ │ ├── 01_Examples +│ │ │ ├── 01_GitHub_Flavored_Markdown.md +│ │ │ ├── 05_Code_Highlighting.md +│ │ ├── 05_More_Examples +│ │ │ ├── Hello_World.md +│ │ │ ├── 05_Code_Highlighting.md +``` + ## Running Remotely Copy the files from the repo to a web server that can run PHP 5.3 or greater. @@ -274,12 +318,12 @@ Generating a complete set of pages, with navigation php index.php generate ``` -Generating just one big file with each doc concatenated +You can optionally pass the location of config.json and (also optionally) the output directory for the static file ```bash -php index.php full-doc +php index.php generate '\path\to\config.json' 'out\dir' ``` - +If the directory has a '\' at the beginning, it is treated as an absolute path, otherwise as relative to the Daux Directory. ## Running on IIS diff --git a/index.php b/index.php index cf5833e..1ed01ae 100644 --- a/index.php +++ b/index.php @@ -75,7 +75,7 @@ if(isset($argv)){ switch ($argv[1]) { //Generate static web documentation case 'generate': - generate_static(); + generate_static((isset($argv[3])) ? $argv[3] : ''); echo "Finished\n"; echo "The documentation is generated in static folder\n"; break; diff --git a/libs/functions.php b/libs/functions.php index 0204863..c65fafc 100644 --- a/libs/functions.php +++ b/libs/functions.php @@ -3,12 +3,12 @@ require_once(dirname( __FILE__)."/markdown_extended.php"); $tree = array(); $base = dirname(dirname(__FILE__)); - $options = get_options(); + $options = get_options(isset($argv[2]) ? $argv[2] : ''); $docs_path = $base . '/' . $options['docs_path']; $multilanguage = !empty($options['languages']) ? TRUE : FALSE; // Options - function get_options() { + function get_options($config_file) { global $base; $options = array( 'title' => "Documentation", @@ -33,7 +33,8 @@ 'template' => 'default' ); // Load User Config - $config_file = $base . '/docs/config.json'; + $config_file = (($config_file === '') ? 'docs/config.json' : $config_file); + if (substr($config_file, 0, 1) !== '/') $config_file = $base . '/' . $config_file; if (file_exists($config_file)) { $config = json_decode(file_get_contents($config_file), true); $options = array_merge($options, $config); @@ -53,6 +54,7 @@ exit; } } + if (!ini_get('date.timezone')) date_default_timezone_set('GMT'); return $options; } @@ -143,7 +145,6 @@ if (!$file) { $page['path'] = ''; $page['markdown'] = ''; - $page['content'] = ''; $page['title'] = 'Oh No'; $page['content'] = "

Oh No. That page doesn't exist

"; $options['file_editor'] = false; diff --git a/libs/static.php b/libs/static.php index 7edf2c6..70f2d38 100644 --- a/libs/static.php +++ b/libs/static.php @@ -1,10 +1,14 @@