diff options
| author | Christian Weiske <cweiske@cweiske.de> | 2014-12-04 07:52:03 +0100 |
|---|---|---|
| committer | Christian Weiske <cweiske@cweiske.de> | 2014-12-04 07:52:03 +0100 |
| commit | 66170c339bbcd8b87e23c47daa11359a99e0d02d (patch) | |
| tree | 27477957638b2898b5c2ac28119df6243d15d2b1 | |
| parent | 5cec779b275b1bf231accf43581f16d215cb7444 (diff) | |
| download | phorkie-66170c339bbcd8b87e23c47daa11359a99e0d02d.tar.gz phorkie-66170c339bbcd8b87e23c47daa11359a99e0d02d.zip | |
Single file editing
| -rw-r--r-- | README.rst | 6 | ||||
| -rw-r--r-- | data/templates/display-file.htm | 1 | ||||
| -rw-r--r-- | data/templates/edit.htm | 4 | ||||
| -rw-r--r-- | src/phorkie/Repository.php | 3 | ||||
| -rw-r--r-- | www/.htaccess | 1 | ||||
| -rw-r--r-- | www/edit.php | 6 |
6 files changed, 20 insertions, 1 deletions
@@ -23,6 +23,7 @@ Features - delete existing files - replace file with upload - multiple files in one paste + - option to edit single files in a multi-file paste - syntax highlighting with GeSHi - rST and Markdown rendering - image upload + display @@ -297,6 +298,8 @@ URLs Display page for paste ``/[0-9]/edit`` Edit the paste +``/[0-9]/edit/(.+)`` + Edit a single file of the paste ``/[0-9]+/raw/(.+)`` Display raw file contents ``/[0-9]/tool/[a-zA-Z]+/(.+)`` @@ -352,6 +355,7 @@ If you use nginx, place the following lines into your ``server`` block: rewrite ^/([0-9]+)/delete/confirm$ /delete.php?id=$1&confirm=1; rewrite ^/([0-9]+)/doap$ /doap.php?id=$1; rewrite ^/([0-9]+)/edit$ /edit.php?id=$1; + rewrite ^/([0-9]+)/edit/(.+)$ edit.php?id=$1&file=$2 rewrite ^/([0-9]+)/fork$ /fork.php?id=$1; rewrite ^/([0-9]+)/raw/(.+)$ /raw.php?id=$1&file=$2; rewrite ^/([0-9]+)/rev/(.+)$ /revision.php?id=$1&rev=$2; @@ -361,8 +365,10 @@ If you use nginx, place the following lines into your ``server`` block: rewrite ^/fork-remote$ /fork-remote.php; rewrite ^/help$ /help.php; rewrite ^/new$ /new.php; + rewrite ^/feed/new$ /feed-new.php; rewrite ^/feed/updated$ /feed-updated.php; + rewrite ^/list$ /list.php; rewrite ^/list/([0-9]+)$ /list.php?page=$1; diff --git a/data/templates/display-file.htm b/data/templates/display-file.htm index ee3a3c2..67a584b 100644 --- a/data/templates/display-file.htm +++ b/data/templates/display-file.htm @@ -4,6 +4,7 @@ {% for toolinfo in file.getToolInfos %} <a class="btn btn-mini" href="{{toolinfo.getLink(file)}}" style="float: right;">{{toolinfo.getTitle}}</a> {% endfor %} + <a class="btn btn-mini" href="{{repo.getLink('edit', file.getFilename)}}" style="float: right;" title="edit"><i class="icon-edit"></i></a> <h3 id="{{file.getFilename|replace({' ': '-'})}}">{{file.getFilename}}<a class="anchorlink" href="{{repo.getLink('display')}}#{{file.getFilename|replace({' ': '-'})}}"></a></h3> </div> {{file.getRenderedContent(toolres)|raw}} diff --git a/data/templates/edit.htm b/data/templates/edit.htm index 542bb34..401ed00 100644 --- a/data/templates/edit.htm +++ b/data/templates/edit.htm @@ -16,7 +16,9 @@ </div> {% for fileid, file in repo.getFiles %} - {% include 'edit-file.htm' with {'file': file, 'fileid': fileid, 'newfile': false} %} + {% if not singlefile or file == singlefile %} + {% include 'edit-file.htm' with {'file': file, 'fileid': fileid, 'newfile': false} %} + {% endif %} {% endfor %} {% include 'edit-add.htm' %} diff --git a/src/phorkie/Repository.php b/src/phorkie/Repository.php index 9de2e1a..467456b 100644 --- a/src/phorkie/Repository.php +++ b/src/phorkie/Repository.php @@ -321,6 +321,9 @@ class Repository { if ($type == 'edit') { $link = $this->id . '/edit'; + if ($option !== null) { + $link .= '/' . urlencode($option); + } } else if ($type == 'display') { $link = $this->id; } else if ($type == 'fork') { diff --git a/www/.htaccess b/www/.htaccess index bf8c582..566d27c 100644 --- a/www/.htaccess +++ b/www/.htaccess @@ -10,6 +10,7 @@ RewriteRule ^([0-9]+)/delete$ delete.php?id=$1 RewriteRule ^([0-9]+)/delete/confirm$ delete.php?id=$1&confirm=1 RewriteRule ^([0-9]+)/doap$ doap.php?id=$1 RewriteRule ^([0-9]+)/edit$ edit.php?id=$1 +RewriteRule ^([0-9]+)/edit/(.+)$ edit.php?id=$1&file=$2 RewriteRule ^([0-9]+)/fork$ fork.php?id=$1 RewriteRule ^([0-9]+)/linkback$ linkback.php?id=$1 RewriteRule ^([0-9]+)/raw/(.+)$ raw.php?id=$1&file=$2 diff --git a/www/edit.php b/www/edit.php index d1853d2..e95ca3f 100644 --- a/www/edit.php +++ b/www/edit.php @@ -14,10 +14,16 @@ if ($repopo->process($_POST, $_SESSION)) { redirect($repo->getLink('display', null, true)); } +$file = null; +if (isset($_GET['file'])) { + $file = $repo->getFileByName($_GET['file']); +} + render( 'edit', array( 'repo' => $repo, + 'singlefile' => $file, 'dh' => new \Date_HumanDiff(), 'htmlhelper' => new HtmlHelper(), ) |
