git » wikiri » commit ee58e01

Keep the change summary on preview

author Alberto Bertogli
2008-11-24 17:37:29 UTC
committer Alberto Bertogli
2008-11-24 18:08:47 UTC
parent a2d4f3204620565ca93a575fb36df0a4642204cb

Keep the change summary on preview

Signed-off-by: Alberto Bertogli <albertito@blitiri.com.ar>

wikiri.cgi +9 -8

diff --git a/wikiri.cgi b/wikiri.cgi
index 37b0b4f..b1f5046 100755
--- a/wikiri.cgi
+++ b/wikiri.cgi
@@ -180,7 +180,7 @@ default_edit_page = """
 
 <label for="comment">Change summary: </label>
 <input id="comment" type="text" name="comment"
-  size="50" value=""/><p/>
+  size="50" value="%(comment)s"/><p/>
 
 <button name="submit" type="submit" value="submit">Save</button>
 <button name="preview" type="submit" value="preview">Preview</button>
@@ -471,10 +471,11 @@ class Templates (object):
 			return open(p).read() % avars
 		return default_article_footer % avars
 
-	def get_edit_page(self, article):
+	def get_edit_page(self, article, comment):
 		avars = self.art_vars(article)
 		avars.update( {
 			'content': article.raw_content,
+			'comment': comment,
 		} )
 		p = self.tpath + '/edit_page.html'
 		if os.path.isfile(p):
@@ -846,7 +847,7 @@ def render_article(art):
 	print template.get_article_footer(art)
 	print template.get_main_footer()
 
-def render_edit(art, preview = False):
+def render_edit(art, preview = False, comment = ""):
 	template = Templates()
 	print 'Content-type: text/html; charset=utf-8\n'
 	print template.get_main_header()
@@ -854,7 +855,7 @@ def render_edit(art, preview = False):
 		print template.get_article_header(art)
 		print art.to_html()
 		print template.get_article_footer(art)
-	print template.get_edit_page(art)
+	print template.get_edit_page(art, comment)
 	print template.get_main_footer()
 
 def render_removed(artname):
@@ -905,9 +906,7 @@ def handle_cgi():
 	newcontent = form.getfirst("newcontent", '')
 	newtitle = form.getfirst("newtitle", '').strip()
 	preview = form.getfirst("preview", '').strip()
-	comment = form.getfirst("comment", 'No comment').strip()
-	if not comment:
-		comment = "No comment"
+	comment = form.getfirst("comment", '').strip()
 
 	remoteip = os.environ.get("REMOTE_ADDR", "unknownip")
 	author = "Somebody <%s@wikiri>" % remoteip
@@ -948,10 +947,12 @@ def handle_cgi():
 				title = newtitle,
 				content = newcontent,
 				has_header = False)
-			render_edit(art, preview = True)
+			render_edit(art, preview = True, comment = comment)
 		else:
 			render_edit(Article(artname))
 	elif save:
+		if not comment:
+			comment = "No comment"
 		h = History()
 		a = Article(artname)
 		if newcontent.strip():