]> git.mjollnir.org Git - s9y.git/commitdiff
Also support "last X" REST interface
authorgarvinhicking <garvinhicking>
Wed, 2 Aug 2006 10:07:34 +0000 (10:07 +0000)
committergarvinhicking <garvinhicking>
Wed, 2 Aug 2006 10:07:34 +0000 (10:07 +0000)
docs/NEWS
index.php

index 519cdcda81941504a3bf0404075a5cb75769ce4d..3be3170f10fe56ea2e710d5776e0c6b31113e399 100644 (file)
--- a/docs/NEWS
+++ b/docs/NEWS
@@ -6,6 +6,9 @@ Version 1.1-alpha7()
     * Add new template 'comments_by_author' which show comments made
       by authors. New permalink structure:
        "/comments/[AUTHORNAME]/comments|trackbacks|comments_and_trackbacks/P[PAGENUMBER]/FROM [YYYY-MM-DD]/TO [YYYY-MM-DD]"
+      Instead of /FROM and /TO you can also use /F and /T.
+      Instead of /FROM and /TO you can also specify /last_X, where X 
+      is the amount of past days to show comments for.
       (garvinhicking)
 
     * Add "Comments and Trackbacks" feed feature (stm99..)
index 82706e37d50ab91d36d6b165d36a003c1b26eec8..b44a781f3ab7d3802bdc309c01ac7c690734a143 100644 (file)
--- a/index.php
+++ b/index.php
@@ -483,11 +483,19 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
                 unset($_args[$k]);
                 unset($serendipity['uriArguments'][$k]);
             }
-        } elseif (preg_match('@^(f|t|from|to)[\s_-]*([\d-/ ]+)$@', strtolower(urldecode($v)), $m)) {
+        } elseif (preg_match('@^(last|f|t|from|to)[\s_-]*([\d-/ ]+)$@', strtolower(urldecode($v)), $m)) {
+            if ($m[1] == 'last') {
+                $usetime = time() - ($m[2]*86400);
+                $serendipity['GET']['commentStartTime'] = $usetime;
+                $timedesc['start'] = serendipity_strftime(DATE_FORMAT_SHORT, $usetime);
+                continue;
+            }
+
             $date = strtotime($m[2]);
             if ($date < 1) {
                 continue;
             }
+            
             if ($m[1] == 'f' || $m[1] == 'from') {
                 $serendipity['GET']['commentStartTime'] = $date;
                 $timedesc['start'] = serendipity_strftime(DATE_FORMAT_SHORT, $date);
@@ -497,7 +505,8 @@ if (preg_match(PAT_ARCHIVES, $uri, $matches) || isset($serendipity['GET']['range
             }
         } elseif ($v == 'trackbacks' || $v == 'comments_and_trackbacks' || $v == 'comments') {
             $serendipity['GET']['commentMode'] = $v;
-        } else {
+        } elseif (!empty($v)) {
+            echo "XX: $v<br />\n";
             $serendipity['GET']['viewCommentAuthor'] = urldecode($v);
         }
     }