From 1c0bcc90f3ae65cb9dded8c8dd43053bfb3f7a81 Mon Sep 17 00:00:00 2001 From: Justin Walsh Date: Mon, 22 Jul 2013 10:48:18 -0500 Subject: [PATCH] Merge changes --- README.md | 10 ++++++++++ docs/00_Getting_Started.md | 10 ++++++++++ libs/functions.php | 32 +++++++++++++++++++++++++++++--- 3 files changed, 49 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index c9cedff..f89572d 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,16 @@ This will embed the piwik tracking code. "piwik_analytics": "my-url-for-piwik.com" } +###Ignore: +Set custom files and entire folders to ignore within your `/docs` folder. For files make sure to include the file extension in the name. For both files and folders, names are case-sensitive. + + { + "ignore": { + files: ["Work_In_Progress.md"], + folders: ["99_Not_Ready"] + } + } + ## Running Locally You can run the docs locally using Grunt.js I assume you are familiar with how to use Grunt and have the latest version of PHP 5.4 installed which is able to run a webserver. diff --git a/docs/00_Getting_Started.md b/docs/00_Getting_Started.md index c9cedff..f89572d 100644 --- a/docs/00_Getting_Started.md +++ b/docs/00_Getting_Started.md @@ -157,6 +157,16 @@ This will embed the piwik tracking code. "piwik_analytics": "my-url-for-piwik.com" } +###Ignore: +Set custom files and entire folders to ignore within your `/docs` folder. For files make sure to include the file extension in the name. For both files and folders, names are case-sensitive. + + { + "ignore": { + files: ["Work_In_Progress.md"], + folders: ["99_Not_Ready"] + } + } + ## Running Locally You can run the docs locally using Grunt.js I assume you are familiar with how to use Grunt and have the latest version of PHP 5.4 installed which is able to run a webserver. diff --git a/libs/functions.php b/libs/functions.php index dc17bc2..97a6b30 100644 --- a/libs/functions.php +++ b/libs/functions.php @@ -36,7 +36,8 @@ function get_options() { 'links' => array(), 'colors' => false, 'google_analytics' => false, - 'piwik_analytics' => false + 'piwik_analytics' => false, + 'ignore' => array() ); // Load User Config @@ -198,9 +199,34 @@ function build_nav($tree, $url_params = false) { 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', '.', '..', '.DS_Store', 'Thumbs.db', '.Trashes', '.htaccess'); + $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 = ''){ $tree = array(); - $ignore = array('config.json', 'cgi-bin', '.', '..'); + $ignore = get_ignored(); $dh = @opendir($path); $index = 0; @@ -220,7 +246,7 @@ function get_tree($path = '.', $clean_path = '', $title = ''){ // while(false !== ($file = readdir($dh))){ foreach($paths as $file) { - // Check that this file is not to be ignored + // Check that this file or folder is not to be ignored if(!in_array($file, $ignore)) { $full_path = "$path/$file"; $clean_sort = clean_sort($file);