summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-11-25 12:40:50 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-11-25 12:40:50 +0100
commit3ce458b5af552ca44080d3b4f7c8abd5b8fc2731 (patch)
tree9ec514ef69272f9f822e5de0c23b2760d4687df0
parent25a96fa649aebebe495f7c7c89eeb4bff0a12c37 (diff)
Wiki: Skip database update when a page is submitted unmodified.
-rw-r--r--src/mulk/benki/wiki.clj14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/mulk/benki/wiki.clj b/src/mulk/benki/wiki.clj
index 40a7a03..3a5a5ec 100644
--- a/src/mulk/benki/wiki.clj
+++ b/src/mulk/benki/wiki.clj
@@ -103,12 +103,14 @@
(select (where (=* :title title)))
(sort [:date#desc]))
revision (first @revisions)
- page (:page revision)]
+ page (:page revision)
+ dbcontent (unwikilinkify content)]
(if-let [user (Integer. (session/get :user))]
(let [page-id (if page page (:id (insert-empty-page)))]
- (sql/insert-values
- :wiki_page_revisions
- [:page :title :content :author :format]
- [page-id title (unwikilinkify content) user "html5"])
- {:stetus 200, :headers {}, :body (wikilinkify (unwikilinkify content))})
+ (when-not (= (:content revision) dbcontent) ;skip if content unmodified
+ (sql/insert-values
+ :wiki_page_revisions
+ [:page :title :content :author :format]
+ [page-id title dbcontent user "html5"]))
+ {:stetus 200, :headers {}, :body (wikilinkify dbcontent)})
{:status 403, :headers {}, :body ""}))))