From: Christian Weiske Date: Thu, 4 Dec 2014 06:52:03 +0000 (+0100) Subject: Single file editing X-Git-Tag: v0.5.0~13 X-Git-Url: https://git.cweiske.de/phorkie.git/commitdiff_plain/66170c339bbcd8b87e23c47daa11359a99e0d02d Single file editing --- diff --git a/README.rst b/README.rst index a755d3a..841b473 100644 --- a/README.rst +++ b/README.rst @@ -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 %} {{toolinfo.getTitle}} {% endfor %} +

{{file.getFilename}}

{{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 @@ {% 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(), )