bugs fixed; tests repaired
This commit is contained in:
+11
-8
@@ -12,15 +12,15 @@
|
||||
|
||||
(defn set-note [date title text]
|
||||
(let [key (build-key date title)]
|
||||
(do
|
||||
(redis/hset db views key 0)
|
||||
(redis/hset db note key text))))
|
||||
(redis/hset db note key text)))
|
||||
|
||||
(defn get-note [date title]
|
||||
(let [key (build-key date title)]
|
||||
(do
|
||||
(redis/hincrby db views key 1)
|
||||
(redis/hget db note key))))
|
||||
(let [key (build-key date title)
|
||||
text (redis/hget db note key)]
|
||||
(when text
|
||||
(do
|
||||
(redis/hincrby db views key 1)
|
||||
text))))
|
||||
|
||||
(defn get-views [date title]
|
||||
(redis/hget db views (build-key date title)))
|
||||
@@ -29,4 +29,7 @@
|
||||
(redis/hexists db note (build-key date title)))
|
||||
|
||||
(defn delete-note [date title]
|
||||
(redis/hdel db note (build-key date title)))
|
||||
(let [key (build-key date title)]
|
||||
(do
|
||||
(redis/hdel db views key)
|
||||
(redis/hdel db note key))))
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
(apply str
|
||||
(interpose "|" (concat ["PT+Serif:700" "Noticia+Text:700"]
|
||||
(vals (select-keys params
|
||||
[:header-font :text-font])))))
|
||||
[:header-font :text-font])))))
|
||||
"&subset=latin,cyrillic") " " "+")
|
||||
:rel "stylesheet"
|
||||
:type "text/css"}]
|
||||
|
||||
@@ -11,14 +11,15 @@
|
||||
(def page-width
|
||||
(mixin
|
||||
:width :800px))
|
||||
|
||||
(def helvetica-neue
|
||||
(mixin
|
||||
:font-weight 300
|
||||
:font-family (gen-fontlist "Helvetica Neue"
|
||||
"Helvetica"
|
||||
"Arial"
|
||||
"Lucida Grande"
|
||||
"sans-serif")))
|
||||
"Helvetica"
|
||||
"Arial"
|
||||
"Lucida Grande"
|
||||
"sans-serif")))
|
||||
(def central-element
|
||||
(mixin
|
||||
page-width
|
||||
@@ -29,13 +30,13 @@
|
||||
|
||||
(defn color [theme tone]
|
||||
(get-in {:dark {:background :#333
|
||||
:foreground :#ccc
|
||||
:background-halftone :#444
|
||||
:foreground-halftone :#bbb }
|
||||
:foreground :#ccc
|
||||
:background-halftone :#444
|
||||
:foreground-halftone :#bbb }
|
||||
:default {:background :#fff
|
||||
:foreground :#333
|
||||
:background-halftone :#efefef
|
||||
:foreground-halftone :#888 }} [theme tone]))
|
||||
:foreground :#333
|
||||
:background-halftone :#efefef
|
||||
:foreground-halftone :#888 }} [theme tone]))
|
||||
|
||||
(defn global-css [params]
|
||||
(let [theme (params :theme)
|
||||
@@ -46,69 +47,71 @@
|
||||
foreground (color theme :foreground)
|
||||
background-halftone (color theme :background-halftone)
|
||||
foreground-halftone (color theme :foreground-halftone)]
|
||||
(css
|
||||
(rule ".landing-button"
|
||||
:box-shadow [0 :2px :5px :#aaa]
|
||||
:text-decoration :none
|
||||
:font-size :1.5em
|
||||
:background :#0a2
|
||||
:color :white
|
||||
:border :none
|
||||
:border-radius :10px
|
||||
:padding :10px
|
||||
helvetica-neue
|
||||
(rule "&:hover"
|
||||
:background :#0b2))
|
||||
(rule "html, body"
|
||||
:background background
|
||||
:color foreground
|
||||
:margin 0
|
||||
:padding 0)
|
||||
(rule "#hero"
|
||||
:padding-top :5em
|
||||
:padding-bottom :5em
|
||||
:text-align :center
|
||||
(rule "h2"
|
||||
helvetica-neue))
|
||||
(rule "article"
|
||||
central-element
|
||||
:line-height (% 140)
|
||||
:font-family text-fonts
|
||||
:font-size :1.2em
|
||||
(rule "& > h1:first-child"
|
||||
:text-align :center
|
||||
:margin :2em))
|
||||
(rule "pre"
|
||||
:border-radius :3px
|
||||
:padding :1em
|
||||
:border [:1px :dotted foreground-halftone]
|
||||
:background background-halftone)
|
||||
(rule "*:focus"
|
||||
:outline [:0px :none :transparent])
|
||||
(rule "textarea"
|
||||
page-width
|
||||
:font-family :Courier
|
||||
:font-size :1.2em
|
||||
:border :none
|
||||
; TODO: make this dynamic
|
||||
:height :500px
|
||||
:margin-bottom :2em)
|
||||
(rule ".hidden"
|
||||
:display :none)
|
||||
(rule ".button"
|
||||
:border-radius :3px
|
||||
helvetica-neue
|
||||
:cursor :pointer
|
||||
:border [:1px :solid foreground]
|
||||
:opacity 0.8
|
||||
:font-size :1em
|
||||
:background background)
|
||||
(rule ".central-element"
|
||||
central-element)
|
||||
(rule "h1"
|
||||
:font-size :2em)
|
||||
(rule "#preview-start-line"
|
||||
:border-bottom [:1px :dashed foreground-halftone]
|
||||
:margin-bottom :5em)
|
||||
(rule "h1, h2, h3, h4"
|
||||
:font-family header-fonts))))
|
||||
(css
|
||||
(rule ".landing-button"
|
||||
:box-shadow [0 :2px :5px :#aaa]
|
||||
:text-decoration :none
|
||||
:font-size :1.5em
|
||||
:background :#0a2
|
||||
:color :white
|
||||
:border :none
|
||||
:border-radius :10px
|
||||
:padding :10px
|
||||
helvetica-neue
|
||||
(rule "&:hover"
|
||||
:background :#0b2))
|
||||
(rule "html, body"
|
||||
:background background
|
||||
:color foreground
|
||||
:margin 0
|
||||
:padding 0)
|
||||
(rule ".helvetica-neue"
|
||||
helvetica-neue)
|
||||
(rule "#hero"
|
||||
:padding-top :5em
|
||||
:padding-bottom :5em
|
||||
:text-align :center
|
||||
(rule "h2"
|
||||
helvetica-neue))
|
||||
(rule "article"
|
||||
central-element
|
||||
:line-height (% 140)
|
||||
:font-family text-fonts
|
||||
:font-size :1.2em
|
||||
(rule "& > h1:first-child"
|
||||
:text-align :center
|
||||
:margin :2em))
|
||||
(rule "pre"
|
||||
:border-radius :3px
|
||||
:padding :1em
|
||||
:border [:1px :dotted foreground-halftone]
|
||||
:background background-halftone)
|
||||
(rule "*:focus"
|
||||
:outline [:0px :none :transparent])
|
||||
(rule "textarea"
|
||||
page-width
|
||||
:font-family :Courier
|
||||
:font-size :1.2em
|
||||
:border :none
|
||||
; TODO: make this dynamic
|
||||
:height :500px
|
||||
:margin-bottom :2em)
|
||||
(rule ".hidden"
|
||||
:display :none)
|
||||
(rule ".button"
|
||||
:border-radius :3px
|
||||
helvetica-neue
|
||||
:cursor :pointer
|
||||
:border [:1px :solid foreground]
|
||||
:opacity 0.8
|
||||
:font-size :1em
|
||||
:background background)
|
||||
(rule ".central-element"
|
||||
central-element)
|
||||
(rule "h1"
|
||||
:font-size :2em)
|
||||
(rule "#preview-start-line"
|
||||
:border-bottom [:1px :dashed foreground-halftone]
|
||||
:margin-bottom :5em)
|
||||
(rule "h1, h2, h3, h4"
|
||||
:font-family header-fonts))))
|
||||
|
||||
@@ -86,22 +86,21 @@
|
||||
|
||||
(defpage "/:year/:month/:day/:title/export" {:keys [year month day title]}
|
||||
(let [md-text (get-note [year month day] title)]
|
||||
(if md-text md-text (get-page 404))))
|
||||
(if md-text md-text (status 404 (get-page 404)))))
|
||||
|
||||
(defpage "/:year/:month/:day/:title/stat" {:keys [year month day title]}
|
||||
(let [views (get-views [year month day] title)]
|
||||
(if views
|
||||
(common/layout "Statistics"
|
||||
[:article
|
||||
[:article.helvetica-neue
|
||||
[:table {:style "width: 100%"}
|
||||
[:tr
|
||||
[:td "Published"]
|
||||
[:td (interpose "-" [year month day])]]
|
||||
[:td (interpose "-" [year month day])]]
|
||||
[:tr
|
||||
[:td "Article views"]
|
||||
[:td views]]
|
||||
]])
|
||||
(get-page 404))))
|
||||
[:td views]]]])
|
||||
(status 404 (get-page 404)))))
|
||||
|
||||
; New Note Posting
|
||||
(defpage [:post "/post-note"] {:keys [draft session-key session-value]}
|
||||
|
||||
Reference in New Issue
Block a user