Browse Source

fonts can be changed now

master
Christian Mueller 14 years ago
parent
commit
a8326cea93
  1. 13
      src/NoteHub/views/common.clj
  2. 21
      src/NoteHub/views/css_generator.clj
  3. 9
      src/NoteHub/views/pages.clj

13
src/NoteHub/views/common.clj

@ -10,12 +10,17 @@
(html5 (html5
[:head [:head
[:title "NoteHub — " title] [:title "NoteHub — " title]
[:link {:href (str "http://fonts.googleapis.com/css?family=" [:link {:href
"PT+Serif:700|Noticia+Text:700" (clojure.string/replace
"&subset=latin,cyrillic" ) (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" :rel "stylesheet"
:type "text/css"}] :type "text/css"}]
[:style {:type "text/css"} (global-css (params :theme))]] [:style {:type "text/css"} (global-css params)]]
(if (params :js) (if (params :js)
[:body content [:body content
(javascript-tag "var CLOSURE_NO_DEPS = true;") (javascript-tag "var CLOSURE_NO_DEPS = true;")

21
src/NoteHub/views/css_generator.clj

@ -2,7 +2,11 @@
(:use [cssgen] (:use [cssgen]
[cssgen.types])) [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 (def page-width
(mixin (mixin
@ -10,10 +14,10 @@
(def helvetica-neue (def helvetica-neue
(mixin (mixin
:font-weight 300 :font-weight 300
:font-family (gen-comma-list "'Helvetica Neue'" :font-family (gen-fontlist "Helvetica Neue"
"Helvetica" "Helvetica"
"Arial" "Arial"
"'Lucida Grande'" "Lucida Grande"
"sans-serif"))) "sans-serif")))
(def central-element (def central-element
(mixin (mixin
@ -33,8 +37,11 @@
:background-halftone :#efefef :background-halftone :#efefef
:foreground-halftone :#888 }} [theme tone])) :foreground-halftone :#888 }} [theme tone]))
(defn global-css [arg] (defn global-css [params]
(let [theme (if arg (keyword arg) :default) (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) background (color theme :background)
foreground (color theme :foreground) foreground (color theme :foreground)
background-halftone (color theme :background-halftone) background-halftone (color theme :background-halftone)
@ -66,7 +73,7 @@
(rule "article" (rule "article"
central-element central-element
:line-height (% 140) :line-height (% 140)
:font-family :Georgia :font-family text-fonts
:font-size :1.2em :font-size :1.2em
(rule "& > h1:first-child" (rule "& > h1:first-child"
:text-align :center :text-align :center
@ -104,4 +111,4 @@
:border-bottom [:1px :dashed foreground-halftone] :border-bottom [:1px :dashed foreground-halftone]
:margin-bottom :5em) :margin-bottom :5em)
(rule "h1, h2, h3, h4" (rule "h1, h2, h3, h4"
:font-family (gen-comma-list "'Noticia Text'" "'PT Serif'"))))) :font-family header-fonts))))

9
src/NoteHub/views/pages.clj

@ -79,11 +79,10 @@
(common/layout params title [:article (md-to-html md-text)])) (common/layout params title [:article (md-to-html md-text)]))
(status 404 (get-page 404)))) (status 404 (get-page 404))))
(defpage "/:year/:month/:day/:title/theme/:theme" {:keys [year month day title theme]} (defpage "/:year/:month/:day/:title" {:keys [year month day title theme header-font text-font] :as params}
(wrap {:theme theme} (get-note [year month day] title))) (wrap
(select-keys params [:theme :header-font :text-font])
(defpage "/:year/:month/:day/:title" {:keys [year month day title]} (get-note [year month day] title)))
(wrap {:theme :default} (get-note [year month day] title)))
(defpage "/:year/:month/:day/:title/export" {:keys [year month day title]} (defpage "/:year/:month/:day/:title/export" {:keys [year month day title]}
(let [md-text (get-note [year month day] title)] (let [md-text (get-note [year month day] title)]

Loading…
Cancel
Save