deleting files works now
authorChristian Weiske <cweiske@cweiske.de>
Tue, 3 Apr 2012 21:23:36 +0000 (23:23 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Tue, 3 Apr 2012 21:23:36 +0000 (23:23 +0200)
README.rst
data/templates/edit-file.htm
src/phorkie/Repository/Post.php
www/phorkie.css

index af8b42e..f5c7b78 100644 (file)
@@ -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
index 37f9253..b0a4848 100644 (file)
    </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>
 
index 828dbad..1b60752 100644 (file)
@@ -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())
index a09aef1..f9f3ad0 100644 (file)
@@ -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