diff options
author | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2011-03-15 00:11:54 +0100 |
---|---|---|
committer | Matthias Andreas Benkard <code@mail.matthias.benkard.de> | 2011-03-15 00:11:54 +0100 |
commit | cf2b6c8b3e50e4d68c6bc7f0abdb820882e1d741 (patch) | |
tree | 51e2f99e2c207c43f472bf5a6f2a42e8b59991d3 | |
parent | 8a1ee16835571d4a590cd66f6ce21926ff02a875 (diff) |
Support comment submission.
-rw-r--r-- | mulkcms.lisp | 62 | ||||
-rw-r--r-- | templates/article.html | 8 | ||||
-rw-r--r-- | templates/journal_page.html | 10 |
3 files changed, 72 insertions, 8 deletions
diff --git a/mulkcms.lisp b/mulkcms.lisp index e3f5c35..3bef1f5 100644 --- a/mulkcms.lisp +++ b/mulkcms.lisp @@ -124,11 +124,25 @@ :commentary (if commentary-p (list :comments comments) nil) :comment-submission (when commentary-p (list :fields (list (list :field-id "name" - :field-label "Name")) + :field-label "Name") + (list :field-id "website" + :field-label "Website") + (list :field-id "email" + :field-label "E-Mail")) :body-label "Message" :submit-button-label "Submit" :title "Submit a comment" - :notes "<p>NOTE: Do something.</p>" + :notes "<p><strong>Note:</strong> + This website uses <a + href=\"http://akismet.com/\">Akismet</a> + for spam detection. + E-mail addresses are never + disclosed to + anyone (including Akismet) + other than the site owner. + Comment format is plain + text. Use blank lines to + separate paragraphs.</p>" :action (link-to :post-comment :article-id article))) :edit-link (link-to :edit :article-id article) :edit-button-label "Edit" @@ -506,7 +520,6 @@ :aliases aliases :revisions revision-data :revision-num (length revision-data)))))) - (when (assoc "add-alias" params :test #'equal) (with-transaction () (query "INSERT INTO article_aliases(article, alias) VALUES ($1, $2)" @@ -649,10 +662,51 @@ :root *base-uri* :site-name *site-name* :site-subtitle "" - :link ""))) + :link "")) + (submission-notice nil)) + (when (assoc "post-comment" params :test #'equal) + (let ((name (cdr (assoc "name" params :test #'equal))) + (website (cdr (assoc "website" params :test #'equal))) + (email (cdr (assoc "email" params :test #'equal))) + (body (cdr (assoc "body" params :test #'equal))) + (article (cdr (assoc "article" params :test #'equal))) + (revision (cdr (assoc "revision" params :test #'equal)))) + (with-transaction () + (let ((comment (query "INSERT INTO comments(article, global_id) + VALUES ($1, $2) + RETURNING id" + article + (format nil "urn:uuid:~A" (make-uuid)) + :single!)) + (author (query "INSERT INTO users(name, status, email, website) + VALUES ($1, 'visitor', $2, $3) + RETURNING id" + name + email + website + :single!))) + (query "INSERT INTO comment_revisions(comment, content, author, format, status, article_revision, submitter_ip, submitter_user_agent) + VALUES ($1, $2, $3, 'text', 'pending', $4, $5, $6)" + comment + body + author + revision + (hunchentoot:real-remote-addr) + (hunchentoot:user-agent) + :none) + (setq submission-notice + "<p><strong>Note:</strong></p> + + <p>Your message has been received and put + into the moderation queue. It is now + waiting for approval by one of the site's + administrators.</p>"))))) (expand-page page-template (getf article-params :title) (list* :articles (list article-params) + :warnings (if submission-notice + (list submission-notice) + nil) template-params)))))))))) diff --git a/templates/article.html b/templates/article.html index 25013d6..c4ebff4 100644 --- a/templates/article.html +++ b/templates/article.html @@ -61,8 +61,9 @@ <form action="{action|html-attr-value}" accept-charset="UTF-8" enctype="application/x-www-form-urlencoded" method="post"> <div style="display: none"> - <input name="id" type="hidden" value="{article-id|html-attr-value}" /> - <input name="action" type="hidden" value="post-comment" /> + <input name="article" type="hidden" value="{article-id|html-attr-value}" /> + <input name="revision" type="hidden" value="{revision|html-attr-value}" /> + <input name="post-comment" type="hidden" /> </div> <div class="comment-form-table"> {.repeated section fields} @@ -83,8 +84,7 @@ </div> <div class="comment-form-input"> <textarea id="comment-body" cols="60" rows="15" - name="comment-body"> - </textarea> + name="body"></textarea> </div> </div> </div> diff --git a/templates/journal_page.html b/templates/journal_page.html index d9646f3..2e0ed61 100644 --- a/templates/journal_page.html +++ b/templates/journal_page.html @@ -10,6 +10,16 @@ <h1 id="main-title">{site-name|html}</h1> <div id="main-subtitle">{site-subtitle|html}</div> + {.section warnings} + <div id="warnings"> + {.repeated section @} + <div class="journal-warning"> + {@} + </div> + {.end} + </div> + {.end} + <div id="articles"> {.repeated section articles} {@|article-html} |