]> git.quilime.com - plog.git/commitdiff
added testing content, and ability to add config files at root level
authorGabriel Dunne <gdunne@quilime.com>
Sun, 11 Jul 2010 02:01:16 +0000 (19:01 -0700)
committerGabriel Dunne <gdunne@quilime.com>
Sun, 11 Jul 2010 02:01:16 +0000 (19:01 -0700)
content/cat1/anothertest [new file with mode: 0644]
content/cat2/another_test
content/cat2/test_post
lib/data.php
lib/init.php
lib/template.php
public/index.php
templates/404.html.tpl [new file with mode: 0644]
templates/default.html.tpl
templates/index.html.tpl [new file with mode: 0644]
templates/test.html.tpl [new file with mode: 0644]

diff --git a/content/cat1/anothertest b/content/cat1/anothertest
new file mode 100644 (file)
index 0000000..de453e6
--- /dev/null
@@ -0,0 +1,3 @@
+title = another test
+--
+yeah some more content for another test post in category1
\ No newline at end of file
index 399940cf1a827b63645a8f376bcd274cbeb5c42b..80672cc179c63a950b8983aaebc3798ba59a2973 100644 (file)
@@ -1,3 +1,3 @@
 title = another test post
 --
-this is some content yo yo yo
\ No newline at end of file
+this is some content yo yo yo CATEGORY 2 in DA HIZ
\ No newline at end of file
index 63f03f90c7bb471176cabcddada9441cfb47a58d..b56893043731737a36a944249329d78c549cd6e4 100644 (file)
@@ -6,3 +6,5 @@ tags = with different tags
 this is an older test post!
 
 `some code`
+
+CAT 222 in DA HIZ
\ No newline at end of file
index 05bb0810d72d0e802e4ffa69f0c57073bda91936..9bee7eaebffe9ec0d5e941d65fe0c3c07b8d5add 100644 (file)
@@ -22,7 +22,7 @@ function get_entries( $path = "", $args = array())
        
        $entries = array();
        foreach ($dir_iterator as $file => $info) {
-               if (!$info->isDir()) {
+               if (!$info->isDir() && $info->getFilename() != CONFIG_FILE) {
                        $entries[] = parse_entry($info);
                }
        }
index 51fa8f6b67e47853c652a5fc88d9930275928cd3..7d5725632c0a5c058ef9880a815a15257ae04c50 100644 (file)
@@ -5,13 +5,15 @@
        ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . dirname(realpath(__FILE__)));
 
        define ('SITE_TITLE', 'plog');
-       define ('LOCAL_ROOT', '/local/root/to/plog/');
-       define ('WEB_ROOT', 'http://www.webroot.com/');
+       define ('LOCAL_ROOT', '/home/quilime/plog/plog/');
+       define ('WEB_ROOT', 'http://dev.quilime.com/');
        
        define ('CONTENT_DIR', 'content');
        define ('TEMPLATE_DIR', 'templates');
        define ('PAGE_DIR', 'pages');   
        define ('CONFIG_DELIMITER', '--');      
+       define ('TITLE_DELIMITER', ': ');
+       define ('CONFIG_FILE', 'config');       
        
     require_once 'data.php';
     require_once 'output.php';
index a4558e9a9256847135d8c882e587b01631bef0e1..c470488eb9e758331df48b12d3f5e5f4ddeec867 100644 (file)
@@ -39,20 +39,17 @@ class Template
        public function render( $template )
        {
                extract( $this->_tpl_vars );
-               
-               
+
                if (is_file( $this->template_dir . DIRECTORY_SEPARATOR . $template ))
                        include( $this->template_dir . DIRECTORY_SEPARATOR . $template );
                else
                        include( $this->template_dir . DIRECTORY_SEPARATOR . 'default.' . $this->response_format . '.tpl');
-                       
-
        }
        
        
        public function page_title($delim)
        {
-               return SITE_TITLE . (isset($this->_tpl_vars['page_title']) ? $delim . $this->_tpl_vars['page_title'] : "");
+               return isset($this->_tpl_vars['page_title']) ? $delim . $this->_tpl_vars['page_title'] : "";
        }
 }
 
index 70f255006cc8d8392468d5decfdb7ad78b39c02c..fbb2931c88e26da17245ea0716697b9e72f52644 100644 (file)
@@ -2,37 +2,47 @@
 
     require_once '../lib/init.php';
 
-    $url_parts = get_url();
+    $url = get_url();
 
-    list($response_format, $response_mime_type) = parse_format($url_parts['extension'], 'html');
+    list($response_format, $response_mime_type) = parse_format($url['extension'], 'html');
 
     # setup template
     $t = get_template_instance();
     $t->response_format = $response_format;
     $t->assign('view', $_GET['v']);
 
-    # is folder
-    if (is_dir(LOCAL_ROOT . CONTENT_DIR . $url_parts['url']) && $url_parts['url'] != "/") {
-        list($data, $total) = get_entries($url_parts['url']);
+    $content_request = LOCAL_ROOT . CONTENT_DIR . $url['dirname'] . '/' . $url['filename'];
+    $page_request =  LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . $url['filename'];
+
+    # content exists, and is a folder
+    if (is_dir($content_request)) {
+        # get config in folder, if exists
+        if (is_file($content_request . '/' . CONFIG_FILE )) {
+            $config = parse_entry(new SplFileInfo($content_request . '/' . CONFIG_FILE));
+            $template = $config['config']['template'] . '.' . $response_format . '.tpl' ;
+        }
+        list($data, $total) = get_entries($url['dirname'] . '/' . $url['filename']);
         $t->assign('data', $data);
-        $t->assign('page_title', preg_replace('{^/|/$}', '', $url_parts['url']));
+        $t->assign('page_title', preg_replace('{^/|/$}', '', $url['url']));
     }
-    # is file
-    else if (is_file( LOCAL_ROOT . CONTENT_DIR . $url_parts['dirname'] . '/' . $url_parts['filename'])) {
-        $t->assign('data', parse_entry(new SplFileInfo(LOCAL_ROOT . CONTENT_DIR . $url_parts['dirname'] . '/' . $url_parts['filename'])));
+    
+    # content exists, and is a single entry
+    else if (is_file($content_request)) {
+        $t->assign('data', parse_entry(new SplFileInfo($content_request)));
         $t->assign('single', true);
         $template = 'single.'.$response_format.'.tpl';
     }
-    # is page
-    else if (is_file( LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . $url_parts['filename'])) {
-        $page = parse_entry(new SplFileInfo(LOCAL_ROOT . PAGE_DIR . DIRECTORY_SEPARATOR . $url_parts['filename']), 1);
+    
+    # content exists, and is a page
+    else if (is_file($page_request)) {
+        $page = parse_entry(new SplFileInfo($page_request), 1);
         $t->assign('data', $page);
         $template = $page['config']['template'] ? $page['config']['template'] . '.' . $response_format . '.tpl' : 'page.' . $response_format . '.tpl';
     }
-    # default (all entries)
+    
+    # 404
     else {
-        list($data, $total) = get_entries();
-        $t->assign('data', $data);
+        $template = '404.html.tpl';
     }
 
     # render
diff --git a/templates/404.html.tpl b/templates/404.html.tpl
new file mode 100644 (file)
index 0000000..a0ed8af
--- /dev/null
@@ -0,0 +1,23 @@
+<html>
+<head>
+    
+    <? $this->include_template('head-inc.html.tpl') ?>
+    
+    <title><?=SITE_TITLE?>: 404</title>
+    
+</head>
+<body>
+    
+    <? $this->include_template('nav.html.tpl') ?>
+    
+<div id="content">
+
+       oops <br /><br />
+       404
+       
+</div>
+
+       <? $this->include_template('footer.html.tpl') ?>
+
+</body>
+</html>
index f353bb4494103bda34729d054e58c394b1465aa6..7972f030059bf9172019e6325bbc697a069f0710 100644 (file)
@@ -3,7 +3,7 @@
     
     <? $this->include_template('head-inc.html.tpl') ?>
     
-    <title><?=$this->page_title(TITLE_DELIMITER);?></title>
+    <title><?=SITE_TITLE?><?=$this->page_title(TITLE_DELIMITER);?></title>
     
 </head>
 <body>
diff --git a/templates/index.html.tpl b/templates/index.html.tpl
new file mode 100644 (file)
index 0000000..964b92d
--- /dev/null
@@ -0,0 +1,22 @@
+<html>
+<head>
+    
+    <? $this->include_template('head-inc.html.tpl') ?>
+    
+    <title><?=SITE_TITLE?></title>
+    
+</head>
+<body>
+    
+    <? $this->include_template('nav.html.tpl') ?>
+    
+<div id="content">
+
+       this is the index template
+       
+</div>
+
+       <? $this->include_template('footer.html.tpl') ?>
+
+</body>
+</html>
diff --git a/templates/test.html.tpl b/templates/test.html.tpl
new file mode 100644 (file)
index 0000000..d71de86
--- /dev/null
@@ -0,0 +1,22 @@
+<html>
+<head>
+    
+    <? $this->include_template('head-inc.html.tpl') ?>
+    
+    <title><?=SITE_TITLE?><?=$this->page_title(TITLE_DELIMITER);?></title>
+    
+</head>
+<body>
+    
+    <? $this->include_template('nav.html.tpl') ?>
+    
+<div id="content">
+
+       this is the TEST TEST TEST template
+       
+</div>
+
+       <? $this->include_template('footer.html.tpl') ?>
+
+</body>
+</html>