]> git.quilime.com - plog.git/commitdiff
updated file ignores, and entries
authorGabriel Dunne <gdunne@quilime.com>
Mon, 3 Oct 2011 13:12:14 +0000 (18:42 +0530)
committerGabriel Dunne <gdunne@quilime.com>
Mon, 3 Oct 2011 13:12:14 +0000 (18:42 +0530)
content/config
lib/data.php
lib/init.php
lib/model.php
lib/output.php
templates/default.html.tpl
templates/index.html.tpl
templates/nav.html.tpl

index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..f90d27c68f639d421faa135315a7e1fc112c36e0 100644 (file)
@@ -0,0 +1 @@
+title = index
\ No newline at end of file
index f536711c06d6b2adad39d4c191a8bfe2bb2c66d9..648d5466b3580cdec7a24d5ab963372c253ebb83 100644 (file)
@@ -7,10 +7,14 @@
  */
 function get_entries( $path = "", $args = array())
 {
+       global $_FILE_IGNORES;
+
        $recursive = isset($args['recursive']) ? $args['recursive'] : 1;
        $order_by = empty($args['order_by']) ? null : $args['order_by'];
        $order = empty($args['order']) ? SORT_DESC : $args['order'];
-       $path = LOCAL_ROOT . CONTENT_DIR . $path;
+
+       $path = join(array( LOCAL_ROOT, CONTENT_DIR, $path ), DIRECTORY_SEPARATOR);
+
        if ($recursive) {
                $iterator = new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_PATHNAME);
                $dir_iterator = new RecursiveIteratorIterator($iterator, RecursiveIteratorIterator::SELF_FIRST);
@@ -20,7 +24,7 @@ function get_entries( $path = "", $args = array())
        }
        $entries = array();
        foreach ($dir_iterator as $file => $info) {
-               if (!$info->isDir() && $info->getFilename() != CONFIG_FILE) {
+               if (!$info->isDir() && !in_array($info->getFilename(), $_FILE_IGNORES)) {
                        $entries[] = parse_entry($info);
                }
        }
@@ -64,7 +68,7 @@ function get_dirs( $path = "", $args = array())
             $d['url'] = str_replace($path, "",  $info->getRealPath());
 
             if (!CLEAN_URLS) {
-               $d['url'] = WEB_ROOT . '?c=' . $d['url'];
+               $d['url'] = WEB_ROOT . '?p=' . $d['url'];
             }
 
             $d['name'] = str_replace($path, "",  $info->getRealPath());
@@ -134,11 +138,17 @@ function parse_entry($fileInfo, $page = 0)
        $cat = clean_slashes(str_replace(LOCAL_ROOT . CONTENT_DIR, "", $fileInfo->getPath()));
        $f['cat'] = $page ? null : array('name' => substr($cat,1), 'url' => $cat );
        $f['path'] = $fileInfo->getRealPath();
-       $f['url'] = ($page ? '' : substr($file['cat']['url'],1)) . $fileInfo->getFilename();
+       $f['url'] = ($page ? '' : substr($f['cat']['url'],1)) . $fileInfo->getFilename();
 
     if (!CLEAN_URLS) {
        $f['url'] = WEB_ROOT . '?p=' . $f['url'];
-    }  
-
+    }
+       
        return $f;
+}
+
+
+function parse_config ($location)
+{
+       return parse_entry(new SplFileInfo(join(array(LOCAL_ROOT, CONTENT_DIR, $location, CONFIG_FILE, DIRECTORY_SEPARATOR))));
 }
\ No newline at end of file
index a09cb34b0f75a19c5987df9c29744f748d7d9f85..a6efdde93d64c80135be98a5fb3ff21111ffd003 100644 (file)
@@ -23,7 +23,7 @@ ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . dirname(realp
 define ('CLEAN_URLS',          false);
 define ('SITE_TITLE',          'plog');
 define ('LOCAL_ROOT',          '/Users/gdunne/Sites/india/');
-define ('WEB_ROOT',            'http://localhost/~gdunne/india/');
+define ('WEB_ROOT',            '/~gdunne/india/');
 define ('CONTENT_DIR',                 'content/');
 define ('TEMPLATE_DIR',        'templates/');
 define ('PAGE_DIR',            'pages/');
@@ -32,6 +32,9 @@ define ('MORE_DELIM',                 '<!--more-->');
 define ('TITLE_DELIMITER',     ': ');
 define ('CONFIG_FILE',                 'config');
 
+# ignores
+$_FILE_IGNORES = array(CONFIG_FILE, '.DS_Store');
+
 # includes
 require_once 'data.php';
 require_once 'output.php';
index 4c9557380ceeae32dcef507a70869fd17571d6f5..4a69874ad15ebfb0a748252cc0789246a144b312 100644 (file)
@@ -7,8 +7,8 @@ class Model
        
        var $response_format = 'html';
        var $response_mime_type = 'text/html';
-       var $template = 'default.html.tpl';
        var $page_title = null;
+       var $template = 'default.html.tpl';
 
        var $entries = null;
        var $config = null;
@@ -18,42 +18,44 @@ class Model
        {
                $this->request = $request;
                list($this->response_format, $this->response_mime_type) = parse_format($this->request['extension'], 'html');
-               $this->parse_request( $request );
+               $this->parse_request( $this->request );
        }
 
        function parse_request( $request )
        {
-               $this->content_request = join(array( LOCAL_ROOT, CONTENT_DIR, $this->request['dirname'], $this->request['filename']), DIRECTORY_SEPARATOR );
-               $this->page_request    = join(array( LOCAL_ROOT, PAGE_DIR, $this->request['filename']), DIRECTORY_SEPARATOR );
+               $this->content_request = join(array($this->request['dirname'], $this->request['filename']), DIRECTORY_SEPARATOR );
+               $this->page_request    = $this->request['filename'];
 
            # check if multiple entries (dir)
            if ($this->is_multiple()) {
                        # check if config file exists
                    if ($this->has_config()) {
-                       $this->config = parse_entry(new SplFileInfo(join(array($content_request, CONFIG_FILE, DIRECTORY_SEPARATOR))));
-                       $this->template = $this->config['config']['template'] . '.' . $this->response_format . '.tpl' ;
+                       $this->config = parse_config($this->content_request);
+                       if (isset($this->config['config']['template'])) {
+                               $this->template = $this->config['config']['template'] . '.' . $this->response_format . '.tpl' ;
+                       }
                    }
-               list($this->entries, $this->total) = get_entries(join(array($this->request['dirname'], $this->request['filename'], DIRECTORY_SEPARATOR)));
-               $this->page_title = preg_replace('{^/|/$}', '', $this->request['url']);
+               list($this->entries, $this->total) = get_entries($this->content_request);
+               $this->page_title = preg_replace('{^/|/$}', '', $this->request['path']);
                } 
                # check if single
                else if ($this->is_single())
                {
-                       $this->entries = parse_entry(new SplFileInfo($this->content_request));
+                       $this->entries = parse_entry($this->content_request);
                        $this->template = 'single.'.$this->response_format.'.tpl';
                }
                # check if page
                else if ($this->is_page()) {
-               $this->entries = parse_entry(new SplFileInfo($this->page_request), 1);
+               $this->entries = parse_entry($this->page_request, 1);
                $this->template = isset($page['config']['template']) ? 
                                                        $this->entries['config']['template'] . '.' . $response_format . '.tpl' : 
                                                        'page.' . $response_format . '.tpl';
                }
-               # check if index
-               else if ($this->request['filename'] == 'index')
-               {
-               $this->template = 'index.html.tpl';
-               }
+               // # check if index
+               // else if ($this->request['filename'] == 'index')
+               // {
+               //      $this->template = 'index.html.tpl';
+               // }
                # poop 404
                else {
                $this->template = '404.html.tpl';
@@ -62,21 +64,26 @@ class Model
 
        function has_config()
        {
-               return is_file($this->content_request . '/' . CONFIG_FILE );
+               return is_file(join(array( LOCAL_ROOT, CONTENT_DIR, $this->content_request, CONFIG_FILE ), DIRECTORY_SEPARATOR ));
+       }
+
+       function get_config()
+       {
+
        }
 
        function is_multiple()
        {
-               return is_dir($this->content_request);
+               return is_dir(join(array( LOCAL_ROOT, CONTENT_DIR, $this->content_request ), DIRECTORY_SEPARATOR ));
        }
 
        function is_single()
        {
-               return is_file($this->content_request);
+               return is_file(join(array( LOCAL_ROOT, CONTENT_DIR, $this->content_request ), DIRECTORY_SEPARATOR ));
        }
 
        function is_page()
        {
-               return is_file($this->page_request);
+               return is_file(join(array( LOCAL_ROOT, PAGE_DIR, $this->page_request ), DIRECTORY_SEPARATOR ));
        }                       
-}
+}
\ No newline at end of file
index 6db7d4bd3b973474fcb439e70e818f83d6e48a84..7ec4a734bb87416f365b61d0f65d2de05d695701 100644 (file)
@@ -151,16 +151,31 @@ function get_base_href()
 
 function get_url_parts()
 {
-       $parts = explode('/', substr($_SERVER['HTTP_HOST'], strlen(get_base_dir() . '/')));
+    $parts = explode('/', substr($_SERVER['HTTP_HOST'], strlen(get_base_dir() . '/')));
        return $parts[0] ? $parts : 0;
 }
 
 
 function get_request()
-{
-    $path_info = pathinfo( $_SERVER['SCRIPT_NAME'] );
-    $path_info['url'] = preg_match("/\.\.\//", $_SERVER['SCRIPT_NAME']) ? '/' : $_SERVER['SCRIPT_NAME'];
-    //$path_info['extension'] = null;
+{   
+    if (!CLEAN_URLS && isset($_GET['p'])) {
+        $path = $_GET['p'];
+    } else {
+        // TODO
+        // this is fudged
+        if ($_SERVER['REQUEST_URI'] == WEB_ROOT) {
+            $path = '/';
+        }
+    }
+
+    $path_info = pathinfo( $path );
+    $path_info['path'] = preg_match("/\.\.\//", $path) ? '/' : $path;
+    $path_info['extension'] = null;
+
+    // echo '<pre>';
+    // print_r($path_info);
+    // exit;
+
     return $path_info; //substr($_SERVER['HTTP_HOST'], strlen(get_base_dir() . '/'));
 }
 
index 197339297d67bb8a4952a2308f1aa2680315a050..c7b1c13aa7599990bc76d4e71a6f7cbcd2b25d61 100644 (file)
     
 <div id="content">
 
-       <? foreach($data as $entry): ?>
+       <? foreach($entries as $entry): ?>
        <?  
-    if ($entry['content_short']
+    if (isset($entry['content_short'])
         $entry['content'] = $entry['content_short'] . '<br /><a class="more" href="'.$entry['url'].'">more &rarr;</a><br /><br />';
-    
-
-        $this->include_template('entry.html.tpl', array('data' => $entry)); 
-
-    
+    $this->include_template('entry.html.tpl', array('data' => $entry)); 
     ?>
        <? endforeach; ?>       
        
index 964b92ddba6e1789f9797df10e8935add922bc80..88d040818c3871e2273d4f0676a72362dd0980d5 100644 (file)
@@ -12,7 +12,7 @@
     
 <div id="content">
 
-       this is the index template
+       hello world
        
 </div>
 
index b17cb3a6da48c63a2463e3e4b2de8f0ae19093cb..b45a42a89a314ce40ad61aae728f89b3edf01f1d 100644 (file)
@@ -1,6 +1,6 @@
 <ul class="nav">          
 
-       <li><h2><a href="/"><?=SITE_TITLE;?></a></h2></li>
+       <li><h2><a href="<?=WEB_ROOT;?>"><?=SITE_TITLE;?></a></h2></li>
        
        <br />