JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
new template naming conventions, etc
authorJason Woofenden <jason@jasonwoof.com>
Mon, 19 Sep 2011 20:21:50 +0000 (16:21 -0400)
committerJason Woofenden <jason@jasonwoof.com>
Mon, 19 Sep 2011 20:22:43 +0000 (16:22 -0400)
.htaccess
admin.html
admin_images.html
admin_login.html
admin_pages.html
admin_pages.php
code/cms.php
code/wfpl
style.css [deleted file]
style.less [new file with mode: 0644]
template.html

index c2a8568..e2570ae 100644 (file)
--- a/.htaccess
+++ b/.htaccess
@@ -7,7 +7,7 @@ DirectorySlash Off
 AddDefaultCharset UTF-8
 RewriteEngine  on
 RewriteRule    ^[^/.]*$  /run.php [L]
-RewriteRule    ^style_[0-9]*.css$  /style.css [L]
+RewriteRule    ^style_[0-9]*.less$  /style.less [L]
 
 <FilesMatch "\.(css|jpg|png)$">
        ExpiresActive On
index 2cf3368..cf25af3 100644 (file)
@@ -2,12 +2,12 @@
 
 <html lang="en">
 <head>
-       <title><!--~main_title show {~-->~this_host~ Administration<!--~}~--></title>
+       <title><!--~$title show {~-->~this_host~ Administration<!--~}~--></title>
        <link rel="stylesheet" href="style.css" type="text/css" />
 </head>
 
 <body>
-       <!--~main_body show {~-->
+       <!--~$body show {~-->
                <h2>~this_host~ Administration</h2>
 
                <p><a href="admin_images">Upload/edit images</a></p>
index 3ba2adb..b8ead21 100644 (file)
@@ -2,12 +2,12 @@
 
 <html>
 <head>
-       <title><!--~main_title show {~-->Images<!--~}~--></title>
+       <title><!--~$title show {~-->Images<!--~}~--></title>
        <link rel="stylesheet" href="style.css" type="text/css">
 </head>
 
 <body>
-<!--~main_body show {~-->
+<!--~$body show {~-->
        <!--~display {~-->
                <h2>Image details</h2>
 
@@ -30,7 +30,7 @@
                </ol>
                
                <!--~smaller {~-->
-                       <div><strong>On the right: </strong>(with the page text to the left of it)</div><div><code class="html">&lt;span class="float_right"&gt;&lt;img src="~src~" width="~width~" height="~height~" alt="" /&gt;~caption html~&lt;/span&gt;</code></div>
+                       <div><strong>On the right: </strong>(with the page text to the left of it)</div><div><code class="html">&lt;span class="wfpl_ifr" style="background-image: url(~src~); width: ~width~px; padding-top: ~height~;"&gt;~caption html~&lt;/span&gt;</code></div>
                        <div><strong>On the left: </strong>(with the page text to the right of it)</div><div><code class="html">&lt;span class="float_left"&gt;&lt;img src="~src~" width="~width~" height="~height~" alt="" /&gt;~caption html~&lt;/span&gt;</code></div>
                        <div><strong>Centered: </strong>(with nothing to either side)</div><div> <code class="html">&lt;div class="mid_pic" style="width: ~width~px"&gt;&lt;img src="~src~" width="~width~" height="~height~" alt="" /&gt;~caption html~&lt;/div&gt;</code></div>
                        <div><img src="~src~" alt="" /></div>
index 9da243f..516e3f6 100644 (file)
@@ -2,11 +2,11 @@
 
 <html>
 <head>
-       <title><!--~main_title show {~-->~this_host~ Admin Login<!--~}~--></title>
+       <title><!--~$title show {~-->~this_host~ Admin Login<!--~}~--></title>
 </head>
 
 <body>
-       <!--~main_body show {~-->
+       <!--~$body show {~-->
                <!--~form {~-->
                        <h2>~this_host~ Admin Login</h2>
 
index c63a38b..56e244b 100644 (file)
@@ -2,9 +2,9 @@
 
 <html lang="en">
 <head>
-       <title><!--~main_title show {~-->~this_host~ Admin: <!--~listings {~-->Pages Listing<!--~}~--><!--~form {~--><!--~new_msg {~-->Add a new page<!--~}~--><!--~edit_msg {~-->Edit page "~title html~"<!--~}~--><!--~}~--><!--~}~--></title>
+       <title><!--~$title show {~-->~this_host~ Admin: <!--~listings {~-->Pages Listing<!--~}~--><!--~form {~--><!--~new_msg {~-->Add a new page<!--~}~--><!--~edit_msg {~-->Edit page "~title html~"<!--~}~--><!--~}~--><!--~}~--></title>
        <meta charset="utf-8" />
-       <!--~extra_headers {~-->
+       <!--~$head {~-->
        <script type="text/javascript" src="code/ckeditor/ckeditor.js"></script>
        <script type="text/javascript">
                function make_wysiwyg(name) {
@@ -36,7 +36,7 @@
 </head>
 
 <body>
-<!--~main_body show {~-->
+<!--~$body show {~-->
 
        <!--~form {~-->
                <form action="admin_pages" method="post"><!--~editing {~--><div style="display: none"><input type="hidden" name="and_then" value="~and_then attr~" /><input type="hidden" name="admin_pages_edit_id" value="~admin_pages_edit_id attr~" /></div><!--~}~-->
index cb2ecbe..8ac29d1 100644 (file)
@@ -157,5 +157,5 @@ function admin_pages_edit_main() {
        }
 
        tem_set('form', $data);
-       tem_set('extra_headers', 'show');
+       tem_set('$head', 'show'); # wysiwyg init goes in <head>
 }
index 60e53b9..c1e2589 100644 (file)
@@ -1,8 +1,6 @@
 <?php
 
 function cms_display($basename, &$tem) {
-       $tem->set('basename', $basename);
-
        $nav_items = db_get_assocs('cms_pages', "coalesce(nullif(nav_title,''), title) as title,filename", 'where navbar!=0 order by navbar');
        if($nav_items) {
                foreach($nav_items as &$nav_item) {
@@ -13,25 +11,36 @@ function cms_display($basename, &$tem) {
                                $nav_item['title'] = '-- blank --';
                        }
                }
-               $tem->set('navbar_items', $nav_items);
+               $tem->set('$navbar_items', $nav_items);
        }
 
-       $have_content = cms_display_content($tem, 'where filename=%"', $basename);
+       $cms_page_id = cms_display_content($tem, 'where filename=%"', $basename);
 
        if(logged_in_as_admin()) {
-               $tem->set('admin_links', 1);
+               $admin_links = array();
+               if($cms_page_id) {
+                       $admin_links['id'] = $cms_page_id;
+               }
+               $tem->set('$admin_links', $admin_links);
+       }
+
+       if($cms_page_id) {
+               return true;
+       } else {
+               return false;
        }
-       return $have_content;
 }
 
 function cms_display_content(&$tem /*, 'where clause %", %i', string, int */) {
        $args = array_slice(func_get_args(), 1);
-       $args = array_merge(array('cms_pages', 'id as admin_edit_page_id,title as cms_title,content as cms_body,keywords as meta_keywords,description as meta_description'), $args);
+       $args = array_merge(array('cms_pages', 'id,title,keywords,description,content'), $args);
        $row = call_user_func_array('db_get_assoc', $args);
        if($row) {
-               # dump it into the global scope:
-               $tem->sets($row);
-               return true;
+               $tem->set('$cms_title', $row['title']);
+               $tem->set('$meta_keywords', $row['keywords']);
+               $tem->set('$meta_description', $row['description']);
+               $tem->set('$cms_body', $row['content']);
+               return $row['id'];
        }
        return false;
 }
index 615c666..2d753b1 160000 (submodule)
--- a/code/wfpl
+++ b/code/wfpl
@@ -1 +1 @@
-Subproject commit 615c6667d12c7972fb08288e1ffaecea8abb16a8
+Subproject commit 2d753b1cb86b98e2995476b74f47cb5663670e4d
diff --git a/style.css b/style.css
deleted file mode 100644 (file)
index 0df4185..0000000
--- a/style.css
+++ /dev/null
@@ -1,146 +0,0 @@
-body {
-       margin: 0;
-       padding: 0;
-       color: black;
-       background: white;
-       font: 14px verdana, arial, free-sans, sans-serif;
-}
-
-nav {
-       width: 154px;
-       float: left;
-       overflow: none;
-       background: #ffe;
-}
-
-nav h3 {
-       padding-left: 10px;
-}
-
-footer {
-       float: left;
-       clear: both;
-       width: 596px;
-       margin-top: 35px;
-       text-align: center;
-       font-size: 9px;
-}
-
-#body {
-       width: 596px;
-       padding: 25px 25px 15px 25px;
-       float: left;
-}
-
-#centerer {
-       margin: 10px auto 20px;
-       width: 800px;
-}
-
-#admin_links {
-       background: #ddf;
-       margin-bottom: 20px;
-}
-
-
-/************ FLOATING IMAGES **************/
-span.float_left {
-       display: block;
-       float: left;
-       font-size: 10px;
-       text-align: right;
-       padding: 4px 15px 7px 0;
-}
-span.float_right {
-       display: block;
-       float: right;
-       font-size: 10px;
-       text-align: right;
-       padding: 4px 0 7px 15px;
-}
-span.float_left img, span.float_right img {
-       display: block;
-       padding-bottom: 1px;
-}
-span.float_center img {
-       display: inline;
-}
-div.mid_pic {
-       margin: 15px auto;
-       font-size: 10px;
-       text-align: right;
-}
-
-/************ GENERAL **************/
-/* HTML5 tags */
-header, hgroup, section, footer, aside, nav, article, figure {
-       display: block;
-}
-
-img {
-       display: block;
-}
-
-a img {
-       border: 0;
-}
-
-code.html {
-       background: #ddd;
-}
-
-.first {
-       padding-top: 0px;
-       margin-top: 0px;
-}
-.last, div.last {
-       padding-bottom: 0px;
-       margin-bottom: 0px;
-}
-
-
-/************ FORMS **************/
-div.caption {
-       font-weight: bold;
-}
-div.field {
-       margin-bottom: 20px;
-}
-div.field_notes {
-       font-size: 12px;
-       line-height: 16px;
-}
-div.field_notes ul {
-       padding-top: 0;
-       padding-bottom: 0;
-       margin-top: 0;
-       margin-bottom: 0;
-}
-div.error {
-       border: 2px solid red;
-       padding: 13px;
-       margin: 20px;
-       background: #fdd;
-}
-
-.form_section {
-       border: 1px dotted black;
-       padding: 23px 15px 15px 15px;
-       margin: 25px 0;
-       position: relative;
-}
-.form_section_header {
-       position: absolute;
-       left: 42px;
-       top: -9px;
-       background: white;
-       padding: 0 6px;
-}
-
-#cke_content {
-       /* wysiwyg area seems to be 10px narrower than cke_content */
-       /* Then we leave another 20px for the scrollbar */
-       /* And another 20px for padding */
-       width: 670px;
-       margin-left: -11px;
-}
diff --git a/style.less b/style.less
new file mode 100644 (file)
index 0000000..cbe6a27
--- /dev/null
@@ -0,0 +1,159 @@
+// dimensions
+@site-width: 940px;
+@nav-width: 200px;
+@site-gutter-width: 18px;
+@site-main-body-width: @site-width - 2*@site-gutter-width - @nav-width;
+
+// colors
+@site-header-color: #ddf;
+@nav-color:    #dff;
+@site-body-color:   #fff;
+@site-window-color: #eee;
+@site-footer-color: #ddf;
+@site-gutter-color: #fff;
+
+header, hgroup, section, footer, aside, nav, article, figure, img {
+       display: block;
+}
+
+body {
+       margin: 0;
+       padding: 0;
+       color: #000;
+       background: @site-window-color;
+       font: 14px "Verdana", sans-serif;
+}
+
+#centerer {
+       position: relative;
+       background: @nav-color;
+       margin: 0 auto;
+       width: @site-width;
+       -moz-box-shadow: 2px 2px 15px #777;
+       -webkit-box-shadow: 2px 2px 15px #777;
+       box-shadow: 2px 2px 13px #777;
+}
+
+header {
+       width: @site-width;
+       height: 100px;
+       background: @site-header-color;
+}
+
+@nav-padding: 10px;
+nav {
+       float: left;
+       width: @nav-width - 2*@nav-padding;
+       padding: @nav-padding;
+       background: @nav-color;
+       a {
+               display: block;
+       }
+}
+
+#main-body {
+       float: left;
+       width: @site-main-body-width;
+       padding: @site-gutter-width @site-gutter-width @site-gutter-width @site-gutter-width;
+       background: @site-body-color;
+}
+
+footer {
+       clear: both;
+       width: @site-width;
+       height: 50px;
+       background: @site-footer-color;
+}
+
+#wfpl_messages {
+       border: 2px solid red;
+       background: #fbb;
+       padding: 5px;
+       margin: 20px 0px;
+       p {
+               font-size: 120%;
+               padding: 5px;
+               margin: 0px;
+       }
+       hr {
+               height: 1px;
+       }
+}
+.caption {
+       margin-top: 15px;
+       font-weight: bold;
+}
+.field {
+       margin-bottom: 15px;
+}
+div.field_notes {
+       font-size: 12px;
+       line-height: 16px;
+}
+fieldset {
+       border: 1px dotted black;
+       padding: 0 15px 15px 15px;
+       margin: 15px 0;
+       position: relative;
+}
+legend {
+       padding: 0 6px;
+       font-weight: bold;
+}
+div.error {
+       border: 2px solid red;
+       padding: 13px;
+       margin: 20px;
+       background: #fdd;
+}
+
+/* hack so that vertical margins are only between siblings for the most part */
+td > :first-child,
+th > :first-child,
+legend + *,
+article > :first-child,
+section > :first-child,
+nav > :first-child,
+div > :first-child,
+.first {
+       margin-top: 0px;
+}
+td > :last-child,
+th > :last-child,
+fieldset > :last-child,
+article > :last-child,
+section > :last-child,
+nav > :last-child,
+div > :last-child,
+.last {
+       margin-bottom: 0px;
+}
+
+/************ FLOATING IMAGES (from CMS) **************/
+span.wfpl_ifl {
+       display: block;
+       float: left;
+       font-size: 10px;
+       text-align: right;
+       padding: 4px 15px 7px 0;
+}
+span.wfpl_ifr {
+       display: block;
+       float: right;
+       font-size: 10px;
+       text-align: right;
+       background-repeat: no-repeat;
+       background-position: top left;
+}
+span.float_left img, span.float_right img {
+       display: block;
+       padding-bottom: 1px;
+}
+span.float_center img {
+       display: inline;
+}
+div.mid_pic {
+       margin: 15px auto;
+       font-size: 10px;
+       text-align: right;
+}
index fd1d996..081144e 100644 (file)
@@ -1,15 +1,19 @@
 <!DOCTYPE html>
 <html lang="en">
 <head>
-       <title>~main_title html~~cms_title html~</title>
        <meta charset="utf-8" />
+       <title>~$title html~~$cms_title html~</title>
        <!--~meta_description nonempty {~--><meta name="description" content="~meta_description attr~" /><!--~}~-->
        <!--~meta_description nonempty {~--><meta name="keywords" content="~meta_keywords attr~" /><!--~}~-->
-       <!--[if IE]>
-               <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+       <!--[if lt IE 9]>
+               ~$running_locally {~<script src="/javascript/html5.js"></script>~}~
+               ~$running_locally unset {~<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>~}~
        <![endif]-->
-       <link rel="stylesheet" href="style_05.css" />
-       <!--~extra_headers~-->
+       <script>less = {env:'development'};</script>
+       <link rel="stylesheet/less" href="style_01.less" />
+       <!--~$running_locally {~--><script src="/javascript/less/less.min.js"></script><!--~}~-->
+       <!--~$running_locally unset {~--><script src="http://lesscss.googlecode.com/files/less-1.0.41.min.js"></script><!--~}~-->
+       <!--~$head~-->
 </head>
 
 <body>
                <header>
                        header image here
                </header>
-               <nav><!--~navbar_items {~-->
+               <nav><!--~$navbar_items {~-->
                        <h3><a href="~filename~">~title html~</a></h3><!--~}~-->
                </nav>
 
-               <div id="body">
-                       <!--~admin_links {~-->
-                               <div id="admin_links">You are logged in as an administrator. &nbsp; <a href="admin_pages?admin_pages_edit_id=~admin_edit_page_id~&amp;admin_pages_new=1&amp;new_filename=~basename~">Edit this page</a> &mdash; <a href="admin">Control panel</a> &mdash; <a href="logout">Log out</a></div>
+               <div id="main-body">
+                       <!--~$admin_links {~-->
+                               <div id="admin_links">You are logged in as an administrator. &nbsp; <a href="admin_pages?~id {~edit_id=~id~~}~~id unset {~&amp;new=1&amp;new_filename=~$basename~~}~">Edit this page</a> &mdash; <a href="admin">Control panel</a> &mdash; <a href="logout">Log out</a></div>
                        <!--~}~-->
-                       <!--~wfpl_messages {~-->
-                               <!--~ first {~--><div style="border: 2px solid red; background: #fbb; padding: 5px; margin: 20px 0px"><!--~}~-->
-                               <p style="font-size: 120%; padding: 5px; margin: 0px">~data html~</p>
-                               <!--~ sep {~--><hr><!--~}~-->
-                               <!--~ last {~--></div><!--~}~-->
+                       <!--~$messages once_if {~-->
+                               <div id="wfpl_messages">
+                                       <!--~$messages {~-->
+                                               <p>~message html~</p>
+                                               <!--~ sep {~-->
+                                                       <hr>
+                                               <!--~}~-->
+                                       <!--~}~-->
+                               </div>
                        <!--~}~-->
 
                        <article>
-                               ~cms_body~
+                               ~$cms_body~
 
-                               ~main_body~
+                               ~$body~
                        </article>
-                       <footer>
-                               footer text here
-                       </footer>
                </div>
+               <footer>
+                       footer text here
+               </footer>
        </div>
 </body>
 </html>