shithub: werc

Download patch

ref: ae5651af321ad198bf495c223d0d20765fc21aef
parent: d88ddc9100732c695926ad0a4c6cdb1c525e69e0
author: uriel <uriel@engel.se.cat-v.org>
date: Sat Jan 17 04:43:31 EST 2009

Dirdir wiki engine updates, cleaned up some code, now one can save from preview page.

--- a/apps/dirdir/app.rc
+++ b/apps/dirdir/app.rc
@@ -5,10 +5,10 @@
 
 fn dirdir_controls {
     # Display 'Edit', 'History', etc, links
-    echo '<div><form action="/_apps/dirdir/edit" method="POST">'
+    echo '<form action="/_apps/dirdir/edit" method="POST">'
     echo '<input type="hidden" name="edit_wiki_page" value="'^$req_path^'" />'
     echo '<input type="submit" name="" value="Edit page" />'
-    echo '</form></div>'
+    echo '</form>'
 
 
 }
--- a/lib/_apps/dirdir/edit.tpl
+++ b/lib/_apps/dirdir/edit.tpl
@@ -5,16 +5,38 @@
 # This is a start, but should be way more careful
 edit_file = `{echo $sitedir/$edit_wiki_page.md|sed 's/\.\.*/./g'}
 
-if(! ~ $"edit_preview '') {
+if (~ $"edit_save '') {
 %}
+<div>
+    <h1>Editing %($edit_wiki_page%)</h1>
+    <br />
+    <form action="/_apps/dirdir/edit" method="post">
+        <input type="hidden" name="edit_wiki_page" value="%($edit_wiki_page%)"
+        <textarea name="edit_text" id="edit_text" cols="80" rows="43">%{
+
+if(~ $#edit_text 0 && test -f $edit_file)
+    cat $edit_file | escape_html
+if not
+    echo $edit_text | escape_html
+
+        %}</textarea>
+        <br />
+        <input type="submit" name="edit_save" value="Save"/>
+        <input type="submit" name="edit_preview" value="Preview" />
+        <small>DirDir documents are written using <a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a>.</small>
+    </form>
+</div>
+% }
+
+% if(! ~ $"edit_preview '') {
             <H2>Preview:</H2>
             <div id="preview">
 %               echo $edit_text | $formatter
             </div>
             <hr /><hr />
+% }
+% if not if(! ~ $"edit_save '') {
 %{
-}
-if not if (! ~ $"edit_save '') {
     dirdir_dir = $edit_file^'_werc/dirdir/'
 
     if(! test -d  $dirdir_dir)
@@ -28,29 +50,5 @@
     echo $edit_text > $edit_file
 %}
 <h1>Saved <a href="%($edit_wiki_page%)">%($edit_wiki_page%)!</a></h1>
-%{
-}
-if not {
-%}
-
-<div>
-    <h1>Editing %($req_path%)</h1>
-    <br />
-    <form action="/_apps/dirdir/edit" method="post">
-        <input type="hidden" name="edit_wiki_page" value="%($edit_wiki_page%)"
-        <textarea name="edit_text" id="edit_text" cols="80" rows="43">%{
-
-if(~ $#edit_text 0 && test -f $edit_file)
-    cat $edit_file | escape_html
-if not
-    echo $edit_text | escape_html
-
-        %}</textarea>
-        <br />
-        <input type="submit" name="edit_save" value="Save"/>
-        <input type="submit" name="edit_preview" value="Preview" />
-        <small>DirDir documents are written using <a href="http://daringfireball.net/projects/markdown/syntax">Markdown syntax</a>.</small>
-    </form>
-</div>
 % }