Configurable index page
authorJustin J. Novack <jnovack@gmail.com>
Fri, 14 Sep 2012 17:13:36 +0000 (13:13 -0400)
committerJustin J. Novack <jnovack@gmail.com>
Fri, 14 Sep 2012 17:29:26 +0000 (13:29 -0400)
README.rst
data/config.default.php
data/templates/base.htm
data/templates/new.htm [moved from data/templates/index.htm with 91% similarity]
www/.htaccess
www/index.php
www/new.php [new file with mode: 0644]

index 10472432ad9dafe1f41d051958d8e517009d6265..c94f29ed886a4c76d1afe6eae823fafcbf99fe64 100644 (file)
@@ -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;
 
index 8fb27a9dae7cc7cb68831c9afba455d2a5ba1e0f..c40c6900b50ace84e623da721a6909d22407ced9 100644 (file)
@@ -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,
index 0479cf6968e3a9c6c1693b2632ff5a1696e45c6d..b9c9608616a612355584f5e9f38a5d1c9b721322 100644 (file)
@@ -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>
similarity index 91%
rename from data/templates/index.htm
rename to data/templates/new.htm
index 5752c1e5a9fe3767a589ca379d58ca0493989fda..5b75bbac62d2a5587536b288574b62d9f1800d89 100644 (file)
@@ -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}}"/>
index 98d92ecb844a277d7f7483ca6e253f01001806b7..a8f2eedc4b3e60e3f7e5b62d77a41e026d1c454b 100644 (file)
@@ -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
 
index 54b1e3aa692795e57a0b789fad959f8e91201648..9a05add9b9741d78ce46a87345123577fe4821dc 100644 (file)
@@ -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 (file)
index 0000000..ef9daec
--- /dev/null
@@ -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(),
+    )
+);
+?>