aboutsummaryrefslogtreecommitdiff
path: root/www
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2012-03-27 07:50:58 +0200
committerChristian Weiske <cweiske@cweiske.de>2012-03-27 07:50:58 +0200
commit4d3b1690a86631b4b1abc74dfa4c4e5bde8faf10 (patch)
tree0da5e9ace9d5b5eb359308dfaa81d7fbf5a147b0 /www
parentc12906d4181a185db6de00e4a1dc11897a1d4718 (diff)
downloadphorkie-4d3b1690a86631b4b1abc74dfa4c4e5bde8faf10.tar.gz
phorkie-4d3b1690a86631b4b1abc74dfa4c4e5bde8faf10.zip
listing all pastes works
Diffstat (limited to 'www')
-rw-r--r--www/.htaccess2
-rw-r--r--www/list.php38
2 files changed, 40 insertions, 0 deletions
diff --git a/www/.htaccess b/www/.htaccess
index bf82bc2..d053ca7 100644
--- a/www/.htaccess
+++ b/www/.htaccess
@@ -5,3 +5,5 @@ RewriteBase /
RewriteRule ^([0-9]+)$ /display.php?id=$1
RewriteRule ^([0-9]+)/raw/(.+)$ /raw.php?id=$1&file=$2
RewriteRule ^([0-9]+)/fork$ /fork.php?id=$1
+RewriteRule ^list$ /list.php
+RewriteRule ^list/([0-9])+$ /list.php?page=$1
diff --git a/www/list.php b/www/list.php
new file mode 100644
index 0000000..a212322
--- /dev/null
+++ b/www/list.php
@@ -0,0 +1,38 @@
+<?php
+/**
+ * Fork a repository
+ */
+namespace Phorkie;
+require_once 'www-header.php';
+$rs = new Repositories();
+
+$page = 0;
+if (isset($_GET['page'])) {
+ if (!is_numeric($_GET['page'])) {
+ throw new Exception_Input('List page is not numeric');
+ }
+ $page = (int)$_GET['page'];
+}
+
+$perPage = 10;
+$repos = $rs->getList($page, $perPage);
+
+$links = array('prev' => null, 'next' => null);
+if ($page > 0) {
+ $links['prev'] = '/list/' . ($page - 1);
+ if ($page - 1 == 0) {
+ $links['prev'] = '/list';
+ }
+}
+if (count($repos) && count($repos) == $perPage) {
+ $links['next'] = '/list/' . ($page + 1);
+}
+
+render(
+ 'list',
+ array(
+ 'repos' => $repos,
+ 'links' => $links,
+ )
+);
+?>