From 27476d85562ea3ceb5abda338cc76c0fa05c8cc9 Mon Sep 17 00:00:00 2001 From: Dave Redfern Date: Thu, 3 Nov 2016 14:05:09 +0000 Subject: [PATCH] #64 Adding code previews --- inc/footer.php | 3 +- inc/functions.php | 31 ++++++++++++++++-- inc/head.php | 3 +- index.php | 5 +-- pattern/base/blockquote.php | 1 + pattern/base/button/1-base.php | 4 +-- pattern/branding/color.php | 1 + pattern/branding/logo/1-logo.php | 1 + pattern/branding/logo/2-favicon.php | 1 + pattern/branding/logo/3-apple.php | 1 + pattern/branding/logo/4-android.php | 1 + pattern/branding/logo/5-placeholder.php | 1 + pattern/branding/typography/1-font.php | 3 +- pattern/branding/typography/2-tester.php | 3 +- pattern/utility/color/1-fill.php | 1 + pattern/utility/color/2-text.php | 1 + src/scss/base/_text.scss | 14 ++++----- src/scss/chopchop-ui.scss | 40 ++++++++++++++++++++---- 18 files changed, 90 insertions(+), 25 deletions(-) diff --git a/inc/footer.php b/inc/footer.php index 6c0d78c5..f721d49c 100644 --- a/inc/footer.php +++ b/inc/footer.php @@ -15,6 +15,7 @@ + - \ No newline at end of file + diff --git a/inc/functions.php b/inc/functions.php index afcfc962..35c29930 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -193,6 +193,7 @@ class TemplateHelper { public function __construct($data = array(), $path, $options=array()) { $this->printTitle = isset($options['print_title']) && $options['print_title']; $this->printContainer = isset($options['print_container']) && $options['print_container']; + $this->printCode = isset($options['print_code']) && $options['print_code']; $this->data = $data; $this->path = $path; $this->options = $options; @@ -209,6 +210,10 @@ public function shouldPrintContainer(){ return $this->printContainer && $this->Container !== false; } + public function shouldPrintCode(){ + return $this->printCode && $this->Code !== false; + } + public function printTitle() { if(!$this->printTitle) { return ''; @@ -310,7 +315,7 @@ protected function pathToLocation($path) { } public function getContent($options) { - $contents = '
'; + $contents = '
'; foreach($this->children as $child) { $contents .= $child->getContent($options); } @@ -323,23 +328,43 @@ public function getContent($options) { protected function getContents($paths, $options) { $printContainer = false; + $printCode = false; ob_start(); foreach($paths as $path) { $_t = new TemplateHelper(parseComments(file_get_contents($path)), $path, $options); $printContainer |= $_t->shouldPrintContainer(); + $printCode |= $_t->shouldPrintCode(); $classes = array('cc-section'); if($_t->Section){ $classes[] = $_t->Section; } + if($printContainer) { - echo '
'; + echo '
'; } echo $_t->printTitle(); + + if($printContainer) { + echo '
'; + echo '
'; + } + include $path; if($printContainer) { - echo '
'; + echo '
'; + } + + if($printCode) { + echo '
';
+                    $html = file_get_contents($path);
+                    echo htmlentities(trim(preg_replace('/<\\?.*(\\?>|$)/Us', '', $html)));
+                echo '
'; + } + + if($printContainer) { + echo '
'; } } $contents .= ob_get_contents(); diff --git a/inc/head.php b/inc/head.php index 4f1866bf..65fc999d 100644 --- a/inc/head.php +++ b/inc/head.php @@ -6,6 +6,7 @@ + - \ No newline at end of file + diff --git a/index.php b/index.php index 8cdd3f1f..8c2c2db4 100644 --- a/index.php +++ b/index.php @@ -43,7 +43,8 @@ !((isset($_GET['title']) && $_GET['title'] === 'false')), - 'print_container' => !((isset($_GET['container']) && $_GET['container'] === 'false')) + 'print_container' => !((isset($_GET['container']) && $_GET['container'] === 'false')), + 'print_code' => !((isset($_GET['code']) && $_GET['code'] === 'false')) ); echo Section::get(getRequestPath(), $options); }?> @@ -54,6 +55,6 @@ - + diff --git a/pattern/base/blockquote.php b/pattern/base/blockquote.php index 11ef15a9..274571ff 100644 --- a/pattern/base/blockquote.php +++ b/pattern/base/blockquote.php @@ -1,6 +1,7 @@
diff --git a/pattern/base/button/1-base.php b/pattern/base/button/1-base.php index 4fa2de02..b2175caa 100644 --- a/pattern/base/button/1-base.php +++ b/pattern/base/button/1-base.php @@ -3,6 +3,4 @@ Class: <button> */ ?> -

- -

+ diff --git a/pattern/branding/color.php b/pattern/branding/color.php index 2f3bf0f5..2c2e6bba 100644 --- a/pattern/branding/color.php +++ b/pattern/branding/color.php @@ -1,5 +1,6 @@

diff --git a/pattern/branding/logo/2-favicon.php b/pattern/branding/logo/2-favicon.php index 29131383..101b5a0a 100755 --- a/pattern/branding/logo/2-favicon.php +++ b/pattern/branding/logo/2-favicon.php @@ -1,5 +1,6 @@
diff --git a/pattern/branding/logo/3-apple.php b/pattern/branding/logo/3-apple.php index d2038034..82f6ec4a 100755 --- a/pattern/branding/logo/3-apple.php +++ b/pattern/branding/logo/3-apple.php @@ -1,5 +1,6 @@
    diff --git a/pattern/branding/logo/4-android.php b/pattern/branding/logo/4-android.php index 530001e1..61f35fb1 100755 --- a/pattern/branding/logo/4-android.php +++ b/pattern/branding/logo/4-android.php @@ -1,5 +1,6 @@
    diff --git a/pattern/branding/logo/5-placeholder.php b/pattern/branding/logo/5-placeholder.php index 56e58506..3542c078 100755 --- a/pattern/branding/logo/5-placeholder.php +++ b/pattern/branding/logo/5-placeholder.php @@ -1,5 +1,6 @@

    diff --git a/pattern/branding/typography/1-font.php b/pattern/branding/typography/1-font.php index c467ec73..f85251ca 100644 --- a/pattern/branding/typography/1-font.php +++ b/pattern/branding/typography/1-font.php @@ -1,10 +1,11 @@
    a b c d e f g h i j k l m n o p q r s t u v w x y z
    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    1 2 3 4 5 6 7 8 9 0 -
    \ No newline at end of file +
    diff --git a/pattern/branding/typography/2-tester.php b/pattern/branding/typography/2-tester.php index 9d5774e3..c2a3af85 100644 --- a/pattern/branding/typography/2-tester.php +++ b/pattern/branding/typography/2-tester.php @@ -1,5 +1,6 @@
    @@ -73,4 +74,4 @@

    Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac turpis quis ligula lacinia aliquet. Mauris ipsum. This is bold. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. This is an i tag. Quisque volutpat condimentum velit.

    -
    \ No newline at end of file +
diff --git a/pattern/utility/color/1-fill.php b/pattern/utility/color/1-fill.php index 32375042..5b25d4a2 100644 --- a/pattern/utility/color/1-fill.php +++ b/pattern/utility/color/1-fill.php @@ -1,6 +1,7 @@
diff --git a/pattern/utility/color/2-text.php b/pattern/utility/color/2-text.php index f03c4dcf..ef1a44bd 100644 --- a/pattern/utility/color/2-text.php +++ b/pattern/utility/color/2-text.php @@ -1,6 +1,7 @@
*:last-child { margin-bottom: 0; + border-bottom: 2px solid color(grey,lighter); + padding-bottom: 20px; } } @@ -313,3 +318,26 @@ // display: block; // position: static; //} + + +// ============================================= +// Code +// ============================================= + +.cc-code { + margin: 0 !important; + display: block; + max-height: 20em; + overflow: scroll; + background-color: color(grey,lighter) !important; +} + + +// ============================================= +// Pattern +// ============================================= + +.cc-pattern { + margin-top: 60px; + margin-bottom: 60px; +}