]> git.quilime.com - plog.git/commitdiff
next prev keyboard actions dirs
authorGabriel Dunne <gdunne@quilime.com>
Sun, 23 Oct 2011 12:40:46 +0000 (18:10 +0530)
committerGabriel Dunne <gdunne@quilime.com>
Sun, 23 Oct 2011 12:40:46 +0000 (18:10 +0530)
21 files changed:
content/2011/09/arrive [moved from content/2011/09/22/arrive with 100% similarity]
content/2011/09/beg [new file with mode: 0644]
content/2011/09/habitat [moved from content/2011/09/27/habitat with 100% similarity]
content/2011/09/sriyantra [moved from content/2011/09/28/sriyantra with 100% similarity]
content/2011/10/alphabet [moved from content/2011/10/06/alphabet with 100% similarity]
content/2011/10/dreams [moved from content/2011/10/04/dreams with 100% similarity]
content/2011/10/dushera [new file with mode: 0644]
content/2011/10/islands [moved from content/2011/10/05/islands with 100% similarity]
content/2011/10/overlords [moved from content/2011/10/05/overlords with 100% similarity]
content/2011/10/smog [new file with mode: 0644]
content/2011/10/water_is_life [new file with mode: 0644]
css/style.css
js/js.js [new file with mode: 0644]
lib/data.php
lib/init.php
lib/model.php
templates/default.html.tpl
templates/footer.html.tpl
templates/head-inc.html.tpl
templates/nextprev.html.tpl [new file with mode: 0644]
templates/single.html.tpl

diff --git a/content/2011/09/beg b/content/2011/09/beg
new file mode 100644 (file)
index 0000000..5056e40
--- /dev/null
@@ -0,0 +1,9 @@
+title = beg
+date = Oct 16 2011, 15:34:03; IST 
+--
+
+
+
+<img src="photos/P1010976.jpg">
+
+Tapping on the windows, the begger kids have perfected their methods. They move their mouths into a sad frown, they use their eyes, they tap on the windows. 
\ No newline at end of file
diff --git a/content/2011/10/dushera b/content/2011/10/dushera
new file mode 100644 (file)
index 0000000..73e05b2
--- /dev/null
@@ -0,0 +1,7 @@
+title = dushera
+date = Sun, Oct 06 2011, 06:00:16 PM; IST
+draft = true
+--
+<img src="photos/IMG_1256.jpg" />
+
+dushera
\ No newline at end of file
diff --git a/content/2011/10/smog b/content/2011/10/smog
new file mode 100644 (file)
index 0000000..b5586f1
--- /dev/null
@@ -0,0 +1,5 @@
+title = sun
+date = Sun, Oct 23 2011, 06:06:33 PM; IST
+--
+
+<img src="photos/P1020004.jpg" />
diff --git a/content/2011/10/water_is_life b/content/2011/10/water_is_life
new file mode 100644 (file)
index 0000000..d60a727
--- /dev/null
@@ -0,0 +1,8 @@
+title = water_is_life
+date = Sun, Oct 23 2011, 06:04:38 PM; IST
+draft = true
+--
+
+<img src="photos/P1020037.jpg">
+
+delapitated truck left near the Quotar Minar in Dadabari. Painting on the front bumper reads "Water is Life" in Hindi.
\ No newline at end of file
index 0a3766a753830f00a0ecf649ca96a04912b87bd7..f10980ac64bab19195209b8b3a8ef95dbebf335b 100644 (file)
@@ -9,6 +9,7 @@ body {
 
 a { 
     color:rgb(198, 28, 111);
+    text-decoration:none;
 }
 a img { 
     border:0; 
@@ -55,6 +56,9 @@ pre {
     padding:50px;
     background:#fff;
 }
+#nextprev {
+    padding:0 50px 10px 50px;
+}
 #nav {
     padding:30px 50px;
     border-top:1px dotted #aaa;
diff --git a/js/js.js b/js/js.js
new file mode 100644 (file)
index 0000000..e99e654
--- /dev/null
+++ b/js/js.js
@@ -0,0 +1,26 @@
+// javascript
+
+var init = ( function () {
+
+       var LEFT = 37, RIGHT = 39;
+
+       document.onkeypress = function(e) {
+               switch (e.keyCode) {
+                       case LEFT : nextEntry(); break;
+                       case RIGHT : prevEntry(); break;
+               }
+       }
+
+       function prevEntry() { 
+               if (typeof(PREV_ENTRY) != "undefined") {
+                       window.location = PREV_ENTRY;
+               } 
+       }
+
+       function nextEntry() {
+               if (typeof(NEXT_ENTRY) != "undefined") {
+                       window.location = NEXT_ENTRY;
+               }       
+       }
+
+})();
index 5fceeb1a93e6dece81e80ca138efa3cdc89b8214..4ec23d321820fcc255f657379a6ef346ccd396de 100644 (file)
@@ -37,6 +37,7 @@ function get_entries( $path = "", $args = array())
                }
        }
 
+
        switch ($order_by)
        {
                default :
@@ -46,6 +47,14 @@ function get_entries( $path = "", $args = array())
                                array_multisort( $time, $order, $entries );
        }
 
+
+       // assign next/prev for each entry
+       $num_entries = count($entries);
+       for ($i = $num_entries-1; $i>=0; $i--) {
+               $entries[$i]['prev_entry'] = isset($entries[$i+1]) ? $entries[$i+1] : null;
+               $entries[$i]['next_entry'] = isset($entries[$i-1]) ? $entries[$i-1] : null;
+       }
+
        return $entries;
 }
 
@@ -86,6 +95,7 @@ function get_dirs( $path = "", $args = array())
        return $dirs;
 }
 
+
 /**
  * get all pages
  */
@@ -146,7 +156,6 @@ function parse_entry($fileInfo, $page = false)
        $cat = clean_slashes(str_replace(LOCAL_ROOT . CONTENT_DIR, "", $fileInfo->getPath()));
        $clean_path = str_replace(LOCAL_ROOT . CONTENT_DIR, "", clean_slashes($fileInfo->getPath()));
 
-
        $f['cat'] = $page ? null : array('name' => $clean_path, 'url' => $clean_path );
        $f['path'] = $fileInfo->getRealPath();
        $f['url'] = ($page ? '' : $f['cat']['url'] . '/') . $fileInfo->getFilename();
@@ -160,17 +169,17 @@ function parse_entry($fileInfo, $page = false)
 }
 
 
-function get_entry ( $relative_entry_path ) 
+function get_entry ( $relative_path ) 
 {
-       return parse_entry(new SplFileInfo(join(array(LOCAL_ROOT, CONTENT_DIR, $relative_entry_path), DIRECTORY_SEPARATOR)));
+       return parse_entry(new SplFileInfo(join(array(LOCAL_ROOT, CONTENT_DIR, $relative_path), DIRECTORY_SEPARATOR)));
 }
 
-function get_page ( $relative_page_path )
+function get_page ( $relative_path )
 {
-       return parse_entry(new SplFileInfo(join(array(LOCAL_ROOT, PAGE_DIR, $relative_page_path), DIRECTORY_SEPARATOR)), 1);
+       return parse_entry(new SplFileInfo(join(array(LOCAL_ROOT, PAGE_DIR, $relative_path), DIRECTORY_SEPARATOR)), 1);
 }
 
 function parse_config ( $relative_path )
 {
        return parse_entry(new SplFileInfo(join(array(LOCAL_ROOT, CONTENT_DIR, $relative_path, CONFIG_FILE), DIRECTORY_SEPARATOR)));
-}
\ No newline at end of file
+}
index c2e9436923f6124c7dc21b8fac530ad95e55713a..8c030ebdaacbaecf3e4cddf5eb69d542b9776b8b 100644 (file)
@@ -40,4 +40,4 @@ require_once 'data.php';
 require_once 'output.php';
 require_once 'markdown.php';
 require_once 'model.php';
-require_once 'view.php';
+require_once 'view.php';
\ No newline at end of file
index 56dffca0596fa736cc61d435042edfa590315cae..d4f49910d9571ba0f579596e02d1f619528eedf1 100644 (file)
@@ -25,11 +25,9 @@ class Model
 
        function parse_request( $request )
        {
-
                $this->content_request = join(array($this->request['dirname'], $this->request['filename']), DIRECTORY_SEPARATOR );
                $this->page_request    = $this->request['filename'];
 
-
            # if entries (dir in CONTENT dir)
            if ($this->is_multiple()) {
                        # check if config file exists in dir
@@ -48,6 +46,17 @@ class Model
                else if ($this->is_single())
                {
                        $this->entry = get_entry( $this->content_request );
+
+                       // heavy handed prev/next
+                       $entries = get_entries();
+                       for($i = count($entries)-1; $i>=0; $i--) {
+                               if ($this->entry['url'] == $entries[$i]['url']) {
+                                       $this->entry['prev_entry'] = $entries[$i]['prev_entry'];
+                                       $this->entry['next_entry'] = $entries[$i]['next_entry'];
+                                       break;
+                               }
+                       }
+
                        $this->template = 'single.' . $this->response_format . '.tpl';
                }
 
@@ -60,7 +69,6 @@ class Model
                                                        'page.' . $this->response_format . '.tpl';
                }
 
-
                # not found
                else {
                $this->template = '404.html.tpl';
index 7b6927c343a77f5c3266c166ecd4ad4d54e20bc9..9ae7ca85cebf869db4b0b717b38d36ef41e539a4 100644 (file)
@@ -8,7 +8,6 @@
 </head>
 <body>
     
-    <? $this->include_template('nav.html.tpl') ?>
     
 <div id="content">
 
@@ -24,6 +23,7 @@
 </div>
 
        <? $this->include_template('footer.html.tpl') ?>
+    <? $this->include_template('nav.html.tpl') ?>
 
 </body>
 </html>
index 4ff0285257a0a02d290e204f0034a48d315020d0..ec5b9223ae42a54648d0857e126abc210b7c4200 100644 (file)
@@ -1,2 +1,4 @@
 
 <!-- footer -->
+
+<script src="<?=get_base_dir();?>/js/js.js"></script>
index 5f3b193b5052e6673465a1374f3e51b93b50119b..ae6fd8ff3050a1b89254f2c19fc1a697ebf99edd 100644 (file)
@@ -3,3 +3,4 @@
 
 <link rel="alternate" type="application/rss+xml" title="RSS" href="<?=get_base_dir();?>/.rss" />
 <link rel="stylesheet" href="<?=get_base_dir();?>/css/style.css" type="text/css">
+
diff --git a/templates/nextprev.html.tpl b/templates/nextprev.html.tpl
new file mode 100644 (file)
index 0000000..ea2b652
--- /dev/null
@@ -0,0 +1,10 @@
+
+<? if (isset($entry['prev_entry'])) : ?> 
+       <a href="<?=$entry['prev_entry']['url']?>">prev</a>
+       <script>var PREV_ENTRY = '<?=$entry['prev_entry']['url']?>'</script>
+<? endif; ?>
+
+<? if (isset($entry['next_entry'])) : ?> 
+       <a href="<?=$entry['next_entry']['url']?>">next</a>
+       <script>var NEXT_ENTRY = '<?=$entry['next_entry']['url']?>'</script>
+<? endif; ?>
index b2348d06a1d5e4f8c330bf941408ec89c35fb237..cae3f0234eddb2c62a96abede5a6c77d8fa83144 100644 (file)
@@ -8,13 +8,15 @@
 </head>
 <body>
     
-    
        <div id="content">
-               <? $this->include_template('entry.html.tpl'); ?>        
+               <? $this->include_template('entry.html.tpl'); ?>
        </div>
 
-       <? $this->include_template('nav.html.tpl') ?>   
+       <div id="nextprev">
+               <? $this->include_template('nextprev.html.tpl'); ?>
+       </div>
 
+       <? $this->include_template('nav.html.tpl') ?>   
        <? $this->include_template('footer.html.tpl') ?>
 
 </body>