aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin J. Novack <jnovack@gmail.com>2012-09-14 13:13:36 -0400
committerJustin J. Novack <jnovack@gmail.com>2012-09-14 13:29:26 -0400
commit0c2d838a9b2f0c81d460b49ccd74775440ced828 (patch)
treee40f248e19d7f661b5099fb7c3844aa8f862d053
parent2b6643574b2a0e527aea359a240018577d861275 (diff)
downloadphorkie-0c2d838a9b2f0c81d460b49ccd74775440ced828.tar.gz
phorkie-0c2d838a9b2f0c81d460b49ccd74775440ced828.zip
Configurable index page
-rw-r--r--README.rst6
-rw-r--r--data/config.default.php3
-rw-r--r--data/templates/base.htm2
-rw-r--r--data/templates/new.htm (renamed from data/templates/index.htm)2
-rw-r--r--www/.htaccess2
-rw-r--r--www/index.php31
-rw-r--r--www/new.php34
7 files changed, 45 insertions, 35 deletions
diff --git a/README.rst b/README.rst
index 1047243..c94f29e 100644
--- a/README.rst
+++ b/README.rst
@@ -169,7 +169,7 @@ URLs
====
``/``
- Index page. Shows form for new paste
+ Index page.
``/[0-9]+``
Display page for paste
``/[0-9]/edit``
@@ -188,7 +188,8 @@ URLs
Search for term, with optional page
``/list(/[0-9])?``
List all pastes, with optional page
-
+``/new``
+ Shows form for new paste
Internal directory layout
=========================
@@ -220,6 +221,7 @@ If you use nginx, place the following lines into your ``server`` block:
rewrite ^/([0-9]+)/rev-raw/(.+)$ /raw.php?id=$1&rev=$2&file=$3;
rewrite ^/([0-9]+)/tool/([^/]+)/(.+)$ /tool.php?id=$1&tool=$2&file=$3;
+ rewrite ^/new$ /new.php;
rewrite ^/list$ /list.php;
rewrite ^/list/([0-9]+)$ /list.php?page=$1;
diff --git a/data/config.default.php b/data/config.default.php
index 8fb27a9..c40c690 100644
--- a/data/config.default.php
+++ b/data/config.default.php
@@ -9,7 +9,8 @@ $GLOBALS['phorkie']['cfg'] = array(
'topbar' => '',
'setupcheck' => true,
'elasticsearch' => null,
- 'geshi' => 'MediaWiki/geshi/geshi/geshi.php'
+ 'geshi' => 'MediaWiki/geshi/geshi/geshi.php',
+ 'index' => 'new'
);
$GLOBALS['phorkie']['tools'] = array(
'\\phorkie\\Tool_Xmllint' => true,
diff --git a/data/templates/base.htm b/data/templates/base.htm
index 0479cf6..b9c9608 100644
--- a/data/templates/base.htm
+++ b/data/templates/base.htm
@@ -20,7 +20,7 @@
</a>
<ul class="nav">
<li>
- <a href="/">New paste</a>
+ <a href="/new">New paste</a>
</li>
<li>
<a href="/list">List all</a>
diff --git a/data/templates/index.htm b/data/templates/new.htm
index 5752c1e..5b75bba 100644
--- a/data/templates/index.htm
+++ b/data/templates/new.htm
@@ -2,7 +2,7 @@
{% block title %}New paste{% endblock %}
{% block content %}
-<form method="post" action="/" enctype="multipart/form-data">
+<form method="post" action="/new" enctype="multipart/form-data">
<div class="control-group well pastedata">
<label for="description">Description</label>
<input type="text" name="description" id="description" value="{{description}}"/>
diff --git a/www/.htaccess b/www/.htaccess
index 98d92ec..a8f2eed 100644
--- a/www/.htaccess
+++ b/www/.htaccess
@@ -12,6 +12,8 @@ RewriteRule ^([0-9]+)/rev/(.+)$ /revision.php?id=$1&rev=$2
RewriteRule ^([0-9]+)/rev-raw/(.+)/(.+)$ /raw.php?id=$1&rev=$2&file=$3
RewriteRule ^([0-9]+)/tool/([^/]+)/(.+)$ /tool.php?id=$1&tool=$2&file=$3
+RewriteRule ^new$ /new.php
+
RewriteRule ^list$ /list.php
RewriteRule ^list/([0-9]+)$ /list.php?page=$1
diff --git a/www/index.php b/www/index.php
index 54b1e3a..9a05add 100644
--- a/www/index.php
+++ b/www/index.php
@@ -1,34 +1,5 @@
<?php
namespace phorkie;
-/**
- * Show paste creation form
- *
- * Elements:
- * - description
- * - file name (default: default.php)
- * - content
- *
- * Creates and redirects to display page
- */
require_once 'www-header.php';
-
-$repopo = new Repository_Post();
-if ($repopo->process($_POST)) {
- redirect($repopo->repo->getLink('display'));
-}
-
-$phork = array(
- '1' => new File(null, null)
-);
-$db = new Database();
-render(
- 'index',
- array(
- 'files' => $phork,
- 'description' => '',
- 'htmlhelper' => new HtmlHelper(),
- 'recents' => $db->getSearch()->listAll(0, 5, 'crdate', 'desc'),
- 'dh' => new \Date_HumanDiff(),
- )
-);
+require_once $GLOBALS['phorkie']['cfg']['index'].".php";
?>
diff --git a/www/new.php b/www/new.php
new file mode 100644
index 0000000..ef9daec
--- /dev/null
+++ b/www/new.php
@@ -0,0 +1,34 @@
+<?php
+namespace phorkie;
+/**
+ * Show paste creation form
+ *
+ * Elements:
+ * - description
+ * - file name (default: default.php)
+ * - content
+ *
+ * Creates and redirects to display page
+ */
+require_once 'www-header.php';
+
+$repopo = new Repository_Post();
+if ($repopo->process($_POST)) {
+ redirect($repopo->repo->getLink('display'));
+}
+
+$phork = array(
+ '1' => new File(null, null)
+);
+$db = new Database();
+render(
+ 'new',
+ array(
+ 'files' => $phork,
+ 'description' => '',
+ 'htmlhelper' => new HtmlHelper(),
+ 'recents' => $db->getSearch()->listAll(0, 5, 'crdate', 'desc'),
+ 'dh' => new \Date_HumanDiff(),
+ )
+);
+?>