From 67f6c4eb61130cae2e33dfbf633315c67d7c8373 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sun, 8 Jan 2017 10:02:07 +0100 Subject: [PATCH] turned bootstrap template variants into logic --- cfg/conf.ini.sample | 2 +- lib/View.php | 3 ++- tpl/bootstrap-compact-page.php | 3 --- tpl/bootstrap-compact.php | 3 --- tpl/bootstrap-dark-page.php | 3 --- tpl/bootstrap-dark.php | 3 --- tpl/bootstrap-page.php | 3 --- tpl/bootstrap.php | 7 +++---- tst/ViewTest.php | 19 +++++++++++++++++++ 9 files changed, 25 insertions(+), 21 deletions(-) delete mode 100644 tpl/bootstrap-compact-page.php delete mode 100644 tpl/bootstrap-compact.php delete mode 100644 tpl/bootstrap-dark-page.php delete mode 100644 tpl/bootstrap-dark.php delete mode 100644 tpl/bootstrap-page.php diff --git a/cfg/conf.ini.sample b/cfg/conf.ini.sample index eec2bd3..1343df0 100644 --- a/cfg/conf.ini.sample +++ b/cfg/conf.ini.sample @@ -31,7 +31,7 @@ defaultformatter = "plaintext" ; size limit per paste or comment in bytes, defaults to 2 Mebibytes sizelimit = 2097152 -; template to include, default is "bootstrap" (tpl/bootstrap.html) +; template to include, default is "bootstrap" (tpl/bootstrap.php) template = "bootstrap" ; (optional) notice to display diff --git a/lib/View.php b/lib/View.php index 6ee8fa7..d7ecaa2 100644 --- a/lib/View.php +++ b/lib/View.php @@ -52,7 +52,8 @@ class View */ public function draw($template) { - $path = PATH . 'tpl' . DIRECTORY_SEPARATOR . $template . '.php'; + $file = substr($template, 0, 9) === 'bootstrap' ? 'bootstrap' : $template; + $path = PATH . 'tpl' . DIRECTORY_SEPARATOR . $file . '.php'; if (!file_exists($path)) { throw new Exception('Template ' . $template . ' not found!', 80); } diff --git a/tpl/bootstrap-compact-page.php b/tpl/bootstrap-compact-page.php deleted file mode 100644 index 6290f3b..0000000 --- a/tpl/bootstrap-compact-page.php +++ /dev/null @@ -1,3 +0,0 @@ - diff --git a/tst/ViewTest.php b/tst/ViewTest.php index 484ad46..7d3c727 100644 --- a/tst/ViewTest.php +++ b/tst/ViewTest.php @@ -67,6 +67,25 @@ class ViewTest extends PHPUnit_Framework_TestCase ob_end_clean(); } } + // check bootstrap variants + $template = 'bootstrap-page'; + ob_start(); + $page->draw($template); + $this->_content[$template] = ob_get_contents(); + ob_end_clean(); + foreach (array('-dark', '-compact') as $suffix) { + $template = 'bootstrap' . $suffix; + ob_start(); + $page->draw($template); + $this->_content[$template] = ob_get_contents(); + ob_end_clean(); + + $template .= '-page'; + ob_start(); + $page->draw($template); + $this->_content[$template] = ob_get_contents(); + ob_end_clean(); + } } public function tearDown()