summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mulkcms.lisp56
-rw-r--r--site.lisp6
-rw-r--r--templates/edit_page.html28
3 files changed, 82 insertions, 8 deletions
diff --git a/mulkcms.lisp b/mulkcms.lisp
index 642be8e..546283d 100644
--- a/mulkcms.lisp
+++ b/mulkcms.lisp
@@ -122,6 +122,10 @@
(lambda () ,@body)))
+(defun invalidate-cache ()
+ (with-db (query "DELETE FROM cached_pages")))
+
+
(defun find-canonical-article-alias (article)
(query "SELECT alias FROM article_aliases WHERE article = $1 LIMIT 1"
article
@@ -470,7 +474,7 @@
FROM article_aliases
WHERE article = r.article
AND alias LIKE 'journal/%')")))
- (displayed-revisions (if full-p revisions (subseq revisions 0 10))))
+ (displayed-revisions (if full-p revisions (subseq revisions 0 5))))
(cond
((member path '("journal" "journal/") :test #'string=)
(let* ((page-skeleton (template "page_skeleton"))
@@ -746,6 +750,13 @@
:add-alias-label "+"
:articles article-data)))))))))
+(defun parse-characteristic-string (char-string)
+ (let* ((delimiter (position #\: char-string))
+ (char (subseq char-string 0 delimiter))
+ (value (subseq char-string (1+ delimiter))))
+ (values char
+ value)))
+
(defun find-article-request-handler (path params &optional action characteristics)
(with-db
(when-let ((article (query "SELECT article FROM article_aliases
@@ -760,7 +771,7 @@
(with-transaction ()
(let* ((revision (if (assoc "save" params :test #'equal)
(query "INSERT INTO article_revisions(article, title, content, author, format, status)
- VALUES ($1, $2, $3, $4, $5, $6)
+ VALUES ($1, $2, $3, $4, $5, $6)
RETURNING *"
article
(cdr (assoc "title" params :test #'equal))
@@ -782,9 +793,37 @@
:test #'equal)))
article
:row)))
- (article-params (paramify-article revision))
+ (article-params (list* (paramify-article revision)))
(editor-template (template "edit_page")))
(assert (not (null revision)))
+ (when-let (del-char-command
+ (find-if (lambda (x)
+ (starts-with-subseq "delete-char:"
+ (car x)))
+ params))
+ (let* ((char-string (subseq (car del-char-command) (length "delete-char:"))))
+ (multiple-value-bind (name value)
+ (parse-characteristic-string char-string)
+ (query "DELETE FROM article_revision_characteristics
+ WHERE revision = $1
+ AND characteristic = $2
+ AND value = $3"
+ (first revision)
+ name
+ value
+ :none))))
+ (when (assoc "add-char" params :test #'equal)
+ (let ((name (cdr (assoc "new-char-name" params
+ :test #'equal)))
+ (value (cdr (assoc "new-char-value" params
+ :test #'equal))))
+ (query "INSERT INTO article_revision_characteristics(
+ revision, characteristic, value
+ ) VALUES ($1, $2, $3)"
+ (first revision)
+ name
+ value
+ :none)))
(when (assoc "save" params :test #'equal)
(query "INSERT INTO article_revision_parenthood(parent, child)
VALUES ($1, $2)"
@@ -802,9 +841,16 @@
:test #'equal)))
(first revision)
:none))
+ (setq characteristics
+ (query "SELECT characteristic, value
+ FROM article_revision_characteristics
+ WHERE revision = $1"
+ (first revision)
+ :plists))
(expand-page editor-template
(getf article-params :title)
(list :article article-params
+ :characteristics characteristics
:title (getf article-params :title)
:root *base-uri*
:site-name *site-name*
@@ -815,7 +861,8 @@
:save-button-label "Save"
:publish-flag-label "Publish"
:title-label "Title"
- :content-label "Content"))))))))
+ :content-label "Content"
+ :characteristics-label "Characteristics"))))))))
(:view
(lambda ()
(with-db
@@ -924,7 +971,6 @@
template-params)))))))))))
-
(defun find-transaction-key-handler (path)
(when (string= path "RPC/generate-transaction-key")
(lambda ()
diff --git a/site.lisp b/site.lisp
index 7ff43c9..43410e8 100644
--- a/site.lisp
+++ b/site.lisp
@@ -26,3 +26,9 @@
;; Set the following to your Wordpress key if you want to use Akismet.
;; Otherwise, set it to NIL or comment the line out.
(defparameter *wordpress-key* nil)
+
+(defparameter *default-characteristics-precedence-list*
+ '((("language" "en"))
+ (("language" "la"))
+ (("language" "de") ("s" "long"))
+ (("language" "fr"))))
diff --git a/templates/edit_page.html b/templates/edit_page.html
index 260a911..cb02d78 100644
--- a/templates/edit_page.html
+++ b/templates/edit_page.html
@@ -14,7 +14,6 @@
<form id="editing-form" method="POST" accept-charset="UTF-8"
action="{link|html-attr-value}">
<input name="edit" type="hidden" />
- <input name="save" type="hidden" />
<input name="revision" type="hidden" value="{article.revision|html-attr-value}" />
<table id="editing-form-table">
<tr>
@@ -29,9 +28,32 @@
<td></td>
<td><input type="checkbox" id="publish-p" name="publish-p" value="t" /><label for="publish-p">{publish-flag-label|html-attr-value}</label></td>
</tr>
- <tr>
+
+ <tr>
+ <td>{characteristics-label|html}</td>
+ <td>
+ <table>
+ <tbody>
+ {.repeated section characteristics}
+ <tr>
+ <td><input type="submit" name="delete-char:{characteristic|html-attr-value}:{value|html-attr-value}" value="-"></input></td>
+ <td>{characteristic|html}</td>
+ <td>{value|html}</td>
+ </tr>
+ {.end}
+ <tr>
+ <td><input type="submit" name="add-char" value="+"></input></td>
+ <td><input type="text" name="new-char-name"></input></td>
+ <td><input type="text" name="new-char-value"></input></td>
+ </tr>
+ </tbody>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
<td></td>
- <td><input type="submit" value="{save-button-label|html-attr-value}" /></td>
+ <td><input type="submit" value="{save-button-label|html-attr-value}" name="save" /></td>
</tr>
</table>
</form>