Fix to be compatible with Tekuti

parent d98f9eed
......@@ -25,7 +25,7 @@
(colt config))
;; TODO: use cache
(get "/articles/oid/:oid"
(get "/article/oid/:oid"
#:cache #t
(lambda (rc)
(let ((article-content (tpl->html (get-one-article-by-oid (params rc "oid"))))
......@@ -33,21 +33,35 @@
(view-render "article" (the-environment)))))
;; TODO: use cache
(get "/articles/preview/oid/:oid"
(get "/article/preview/oid/:oid"
#:cache #t
(lambda (rc)
(let ((article-content (tpl->html (get-one-article-by-oid (params rc "oid")))))
(view-render "preview" (the-environment)))))
(get "/articles/preview/:name"
(get "/article/preview/:name"
#:cache #t
(lambda (rc)
(let ((article-content (get-one-article (params rc "name"))))
(view-render "preview" (the-environment)))))
(get "/articles/:name"
(get "/article/:name"
#:cache #t
(lambda (rc)
(let ((article-content (get-one-article (params rc "name")))
(account (colt-conf-get 'disqus)))
(view-render "article" (the-environment)))))
(define *archive-re* (string->irregex "/archives/(.*)"))
(define (path->url path)
(let ((m (irregex-match *archive-re* path)))
(if m
(string-downcase (irregex-match-substring m 1))
(throw 'artanis-err 404 path->url
"Invalid path `~a'" path))))
(get "/archives/.*"
#:cache #t
(lambda (rc)
(let ((article-content (get-one-article (pk "path"(path->url (rc-path rc)))))
(account (colt-conf-get 'disqus)))
(view-render "article" (the-environment)))))
......@@ -162,7 +162,7 @@
(define* (gen-one-post post mode #:optional (need-abstract? #f))
(define-syntax-rule (->url url-name)
(format #f "/articles/~a" url-name))
(format #f "/archives/~a" url-name))
(define-syntax-rule (->title title url)
`(div (@ (class "blog-post-title"))
(a (@ (href ,(->url (post-url-name post)))) ,title)))
......@@ -285,7 +285,7 @@
(let ((post (get-post-by-url-name url-name (get-all-posts))))
(when (not post)
(throw 'artanis-err 404 get-one-article
"Invalid url-name (~a)!" url-name))
"Invalid url-name `~a'!" url-name))
`(div (@ (class "article"))
,(gen-one-article post)))))
......
......@@ -25,6 +25,7 @@
#:use-module (ice-9 match)
#:use-module (ice-9 rdelim)
#:use-module (srfi srfi-1)
#:use-module (web uri)
#:export (current-blog-repo
git-ls-tree
git/get-post-objs
......@@ -152,7 +153,8 @@
(any (lambda (o) (and (string=? name (git-object-file o)) o)) obj-list))
(define (get-post-by-url-name url-name post-list)
(any (lambda (p) (and (string=? url-name (post-url-name p)) p)) post-list))
(define-syntax-rule (get-url-name p) (uri-decode (post-url-name p)))
(any (lambda (p) (and (string=? url-name (get-url-name p)) p)) post-list))
(define (get-post-by-oid oid obj-list)
(any (lambda (o) (and (string=? oid (git-object-oid o)) (get-post o))) obj-list))
......
......@@ -120,7 +120,6 @@ function show_msg_layer(msg) {
function edit_submit() {
let article_content = quill.root.innerHTML;
alert(quill.root.innerText);
let title = document.getElementById('edit-article-title').value;
let tags = document.getElementById('edit-article-tags').value;
let status = document.getElementById('edit-article-status').value
......@@ -143,8 +142,8 @@ function edit_submit() {
"tags": tags,
"update_timestamp": update_timestamp.checked
}),
success: function (data) {
if ("failed" === data)
success: function (oid) {
if ("failed" === oid)
{
show_msg_layer("Edit failed, please check!");
submit_button.innerText = "Submit";
......@@ -153,7 +152,7 @@ function edit_submit() {
else if (typeof title == 'undefined')
window.location.pathname = "/about";
else
window.location.pathname = "/articles/preview/" + data;
window.location.pathname = "/article/preview/oid/" + oid;
localStorage.setItem('colt.saved_content', "");
}
......@@ -187,13 +186,13 @@ function submit_post() {
"status": status,
"content": article_content,
}),
success: function (data) {
if ("failed" === data)
success: function (oid) {
if ("failed" === oid)
show_msg_layer("Post new article failed, please check!");
else if ("_____colt_____Intro" === title)
window.location.pathname = "/about";
else
window.location.pathname = "/articles/preview/" + data;
window.location.pathname = "/article/preview/oid/" + oid;
localStorage.setItem('colt.saved_content', "");
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment