From 7532af8a808b361bed2b5565bfa26312bd7bcfb3 Mon Sep 17 00:00:00 2001 From: "Marcel Kapfer (mmk2410)" Date: Sat, 4 Jun 2016 09:45:59 +0200 Subject: [PATCH] init script for debugging --- bin/init_debug.php | 123 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 bin/init_debug.php diff --git a/bin/init_debug.php b/bin/init_debug.php new file mode 100644 index 0000000..aaf81c7 --- /dev/null +++ b/bin/init_debug.php @@ -0,0 +1,123 @@ +getConfig(); +} + +echo "30\n"; + +// blog part +$yaml["blog"]["title"] = get("Title of your blog", $yaml["blog"]["title"], "Example Blog"); +$yaml["blog"]["author"] = get("Your name:", $yaml["blog"]["author"], "John"); +$yaml["blog"]["description"] = get("A description of your blog:", $yaml["blog"]["description"], "A short description of your blog"); +$yaml["blog"]["home"] = getBool("Do you have a top site? (on/off)", $yaml["blog"]["home"], "on"); +if ($yaml["blog"]["home"] == "on") { + $yaml["blog"]["homeurl"] = get("Path / Url to home page", $yaml["blog"]["homeurl"], "../"); + $yaml["blog"]["homename"] = get("Name of your home page", $yaml["blog"]["homename"], "Home"); +} +$yaml["blog"]["mainname"] = get("Name of the main blog (if empty, the blog title will be used)", ""); +$yaml["blog"]["intro"] = getBool("Do you want a blog intro text? (on/off)", $yaml["blog"]["intro"], "on"); +$yaml["blog"]["disqus"] = get("Your Disqus shortname (Leave empty to disable)", $yaml["blog"]["disqus"], ""); +$yaml["blog"]["analytics"] = get("Google Analytics ID (Leave empty to disable)", $yaml["blog"]["analytics"], ""); +$yaml["blog"]["footer"] = get("The footer of your blog", $yaml["blog"]["footer"], "Example Blog 2016 CC-BY-SA 4.0"); + +// design part +$yaml["design"]["fab"] = getBool("Would you like to use the share buttons (on/off)", $yaml["design"]["blog"], "on"); +$yaml["design"]["drawer"] = getBool("Would you like the use the navigation drawer? (on/off)", $yaml["design"]["drawer"], "on"); +$themes = getDir('./themes'); +$yaml["design"]["theme"] = get("Which theme would you like to use? (" . $themes . ")", $yaml["design"]["theme"], "material-light"); +$yaml["design"]["pagination"] + = get("Which posts should be displayed on one page (0 to disable)", $yaml["design"]["pagination"], "0"); +$yaml["design"]["favicon"] = get("URL to your favicon", $yaml["design"]["favicon"], "https://example.com/fav.ico"); + +// rcc +$yaml["rcc"]["rcc"] = "off"; +$yaml["rcc"]["api"] = "off"; + +// languages +$langs = getDir('./lang'); +$yaml["language"] = get("Choose a language (" . $langs . ")", $yaml["language"], "en"); + +echo "64\n"; + +$config->writeConfig($yaml); + +echo "68\n"; + +function get($question, $value, $default) +{ + if (isset($value) && $value != "") { + $input = readline($question . " (" . $value . "): "); + if ($input == "") { + return $value; + } else { + return $input; + } + } else { + $input = readline($question . " (" . $default . ")" . ": "); + if ($input == "") { + return $default; + } else { + return $input; + } + } +} + +function getBool($question, $value, $default) +{ + if (isset($value) && $value != "") { + $input = "someval"; + while (!in_array($input, array("on", "off", ""))) { + $input = readline($question . " (" . $value . "): "); + } + if ($input == "") { + return $value; + } else { + return $input; + } + } else { + $input = ""; + while (!in_array($input, array("on", "off"))) { + $input = readline($question . " (" . $default . ")" . ": "); + } + if ($input == "") { + return $default; + } else { + return $input; + } + } + +} + +function getDir($path) +{ + $dir = scandir($path, SCANDIR_SORT_DESCENDING); + + unset($dir[sizeof($dir) - 1]); + unset($dir[sizeof($dir) - 1]); + + return implode(", ", $dir); +}