aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Weiske <cweiske@cweiske.de>2012-04-03 23:23:36 +0200
committerChristian Weiske <cweiske@cweiske.de>2012-04-03 23:23:36 +0200
commitcdc99846c94bacdd7a2a0681d77bac3de45c4f2a (patch)
tree153dc4c866345a114c1279caecb5af555f7ff9fd
parent61cb5ecf53731fbe3dbb632dbea059db88d672f1 (diff)
downloadphorkie-cdc99846c94bacdd7a2a0681d77bac3de45c4f2a.tar.gz
phorkie-cdc99846c94bacdd7a2a0681d77bac3de45c4f2a.zip
deleting files works now
-rw-r--r--README.rst3
-rw-r--r--data/templates/edit-file.htm13
-rw-r--r--src/phorkie/Repository/Post.php10
-rw-r--r--www/phorkie.css4
4 files changed, 29 insertions, 1 deletions
diff --git a/README.rst b/README.rst
index af8b42e..f5c7b78 100644
--- a/README.rst
+++ b/README.rst
@@ -13,6 +13,9 @@ Features
========
- every paste is a git repository
- paste editing
+
+ - add new files
+ - delete existing files
- multiple files in one paste
- syntax highlighting with GeSHi
- rST rendering
diff --git a/data/templates/edit-file.htm b/data/templates/edit-file.htm
index 37f9253..b0a4848 100644
--- a/data/templates/edit-file.htm
+++ b/data/templates/edit-file.htm
@@ -14,5 +14,18 @@
</div>
</div>
<textarea name="files[{{fileid}}][content]" id="content_{{fileid}}" cols="80" rows="15" class="content">{{file.getContent}}</textarea>
+ <div class="row-fluid">
+ <div class="span9">
+ &nbsp;
+ <!--
+ <label for="upload_{{fileid}}" class="inline">Replace with file upload:</label>
+ <input type="file" name="files[{{fileid}}][upload]" id="upload_{{fileid}}" class="btn"/>
+ -->
+ </div>
+ <div class="span3" style="text-align: right">
+ <input type="checkbox" name="files[{{fileid}}][delete]" value="1" id="delete_{{fileid}}"/>
+ <label for="delete_{{fileid}}" class="inline">delete file</label>
+ </div>
+ </div>
</div>
diff --git a/src/phorkie/Repository/Post.php b/src/phorkie/Repository/Post.php
index 828dbad..1b60752 100644
--- a/src/phorkie/Repository/Post.php
+++ b/src/phorkie/Repository/Post.php
@@ -44,6 +44,7 @@ class Repository_Post
}
$bNew = false;
+ $bDelete = false;
if (!isset($orignalName) || $orignalName == '') {
//new file
$bNew = true;
@@ -51,6 +52,8 @@ class Repository_Post
//unknown file
//FIXME: Show error message
continue;
+ } else if (isset($arFile['delete']) && $arFile['delete'] == 1) {
+ $bDelete = true;
} else if ($orignalName != $name) {
//FIXME: what to do with overwrites?
$vc->getCommand('mv')
@@ -61,7 +64,12 @@ class Repository_Post
}
$file = $this->repo->getFileByName($name, false);
- if ($bNew || $file->getContent() != $arFile['content']) {
+ if ($bDelete) {
+ $command = $vc->getCommand('rm')
+ ->addArgument($file->getFilename())
+ ->execute();
+ $bChanged = true;
+ } else if ($bNew || $file->getContent() != $arFile['content']) {
file_put_contents($file->getPath(), $arFile['content']);
$command = $vc->getCommand('add')
->addArgument($file->getFilename())
diff --git a/www/phorkie.css b/www/phorkie.css
index a09aef1..f9f3ad0 100644
--- a/www/phorkie.css
+++ b/www/phorkie.css
@@ -62,4 +62,8 @@ form input#description {
box-sizing: border-box;
height: 2em;
width: 100%;
+}
+
+form label.inline {
+ display: inline;
} \ No newline at end of file