git » wikiri » commit f9d2e4c

Redirect saves and restores

author Alberto Bertogli
2008-12-13 16:13:08 UTC
committer Alberto Bertogli
2008-12-13 16:13:08 UTC
parent 1218a78cb4e0fc74ff25a148299076d6b21fb85b

Redirect saves and restores

Instead of leaving the url as /artname/save or /restore/commitid/artname,
redirect those actions to /artname.

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

wikiri.cgi +8 -3

diff --git a/wikiri.cgi b/wikiri.cgi
index 16e4b5c..da35e87 100755
--- a/wikiri.cgi
+++ b/wikiri.cgi
@@ -1055,6 +1055,11 @@ def render_style():
 	print 'Content-type: text/css\n'
 	print default_css
 
+def redirect(artname):
+	print 'Status: 303 See Other\r\n',
+	print 'Location: %s/%s\r\n' % (wiki_url, artname),
+	print
+
 def handle_cgi():
 	import cgitb; cgitb.enable()
 
@@ -1121,12 +1126,12 @@ def handle_cgi():
 			a.save(newtitle, newcontent)
 			h.add(a.qname)
 			h.commit(msg = comment, author = author)
-			render_article(a)
+			redirect(artname)
 		else:
 			a.remove()
 			h.remove(a.qname)
 			h.commit(msg = comment, author = author)
-			render_removed(a.name)
+			redirect(artname)
 	elif log:
 		a = Article(artname)
 		render_log(a.name, History().log(a.qname))
@@ -1148,7 +1153,7 @@ def handle_cgi():
 		ctime = h.get_commit(cid)['atime'].strftime("%Y-%m-%d %H:%M:%S")
 		h.commit(msg = 'Restored ' + ctime, author = author)
 
-		render_article(a)
+		redirect(artname)
 	else:
 		render_article(Article(artname))