diff --git a/src/NoteHub/views/common.clj b/src/NoteHub/views/common.clj index 214d221..9f70512 100644 --- a/src/NoteHub/views/common.clj +++ b/src/NoteHub/views/common.clj @@ -10,12 +10,17 @@ (html5 [:head [:title "NoteHub — " title] - [:link {:href (str "http://fonts.googleapis.com/css?family=" - "PT+Serif:700|Noticia+Text:700" - "&subset=latin,cyrillic" ) + [:link {:href + (clojure.string/replace + (str "http://fonts.googleapis.com/css?family=" + (apply str + (interpose "|" (concat ["PT+Serif:700" "Noticia+Text:700"] + (vals (select-keys params + [:header-font :text-font]))))) + "&subset=latin,cyrillic") " " "+") :rel "stylesheet" :type "text/css"}] - [:style {:type "text/css"} (global-css (params :theme))]] + [:style {:type "text/css"} (global-css params)]] (if (params :js) [:body content (javascript-tag "var CLOSURE_NO_DEPS = true;") diff --git a/src/NoteHub/views/css_generator.clj b/src/NoteHub/views/css_generator.clj index 93e23e9..f89f53f 100644 --- a/src/NoteHub/views/css_generator.clj +++ b/src/NoteHub/views/css_generator.clj @@ -2,7 +2,11 @@ (:use [cssgen] [cssgen.types])) -(defn gen-comma-list [& fonts] (apply str (interpose "," fonts))) +(defn gen-fontlist [& fonts] + (apply str + (interpose "," + (map #(str "'" % "'") + (filter identity fonts))))) (def page-width (mixin @@ -10,10 +14,10 @@ (def helvetica-neue (mixin :font-weight 300 - :font-family (gen-comma-list "'Helvetica Neue'" + :font-family (gen-fontlist "Helvetica Neue" "Helvetica" "Arial" - "'Lucida Grande'" + "Lucida Grande" "sans-serif"))) (def central-element (mixin @@ -33,8 +37,11 @@ :background-halftone :#efefef :foreground-halftone :#888 }} [theme tone])) -(defn global-css [arg] - (let [theme (if arg (keyword arg) :default) +(defn global-css [params] + (let [theme (params :theme) + theme (if theme (keyword theme) :default) + header-fonts (gen-fontlist (params :header-font) "Noticia Text" "PT Serif") + text-fonts (gen-fontlist (params :text-font) "Georgia") background (color theme :background) foreground (color theme :foreground) background-halftone (color theme :background-halftone) @@ -66,7 +73,7 @@ (rule "article" central-element :line-height (% 140) - :font-family :Georgia + :font-family text-fonts :font-size :1.2em (rule "& > h1:first-child" :text-align :center @@ -104,4 +111,4 @@ :border-bottom [:1px :dashed foreground-halftone] :margin-bottom :5em) (rule "h1, h2, h3, h4" - :font-family (gen-comma-list "'Noticia Text'" "'PT Serif'"))))) + :font-family header-fonts)))) diff --git a/src/NoteHub/views/pages.clj b/src/NoteHub/views/pages.clj index 8e20144..095aafb 100644 --- a/src/NoteHub/views/pages.clj +++ b/src/NoteHub/views/pages.clj @@ -79,11 +79,10 @@ (common/layout params title [:article (md-to-html md-text)])) (status 404 (get-page 404)))) -(defpage "/:year/:month/:day/:title/theme/:theme" {:keys [year month day title theme]} - (wrap {:theme theme} (get-note [year month day] title))) - -(defpage "/:year/:month/:day/:title" {:keys [year month day title]} - (wrap {:theme :default} (get-note [year month day] title))) +(defpage "/:year/:month/:day/:title" {:keys [year month day title theme header-font text-font] :as params} + (wrap + (select-keys params [:theme :header-font :text-font]) + (get-note [year month day] title))) (defpage "/:year/:month/:day/:title/export" {:keys [year month day title]} (let [md-text (get-note [year month day] title)]