From: garvinhicking Date: Wed, 2 Aug 2006 10:07:34 +0000 (+0000) Subject: Also support "last X" REST interface X-Git-Tag: 1.1~157 X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=322b13ca48a4a835c166f1557670d4cdf5859831;p=s9y.git Also support "last X" REST interface --- diff --git a/docs/NEWS b/docs/NEWS index 519cdcd..3be3170 100644 --- 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..) diff --git a/index.php b/index.php index 82706e3..b44a781 100644 --- 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
\n"; $serendipity['GET']['viewCommentAuthor'] = urldecode($v); } }