cssgen & clojurescript dependencies deletes
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
(ns NoteHub.crossover.lib
|
||||
(:refer-clojure :exclude [hash]))
|
||||
|
||||
(defn hash
|
||||
"A simple hash-function, which computes a hash from the text field
|
||||
content and given session number. It is intended to be used as a spam
|
||||
protection / captcha alternative (let's see whether spambots evaluate heavy JS).
|
||||
(Probably doesn't work for UTF-16)"
|
||||
[f s]
|
||||
(let [short-mod #(mod % 32767)
|
||||
char-codes (map f (remove #(contains? #{"\n" "\r"} %) (map str s)))
|
||||
zip-with-index (map list char-codes (range))]
|
||||
(reduce
|
||||
#(short-mod (+ %
|
||||
(short-mod (* (first %2)
|
||||
((if (odd? %)
|
||||
bit-xor
|
||||
bit-and) 16381 (second %2))))))
|
||||
0 zip-with-index)))
|
||||
@@ -41,8 +41,9 @@
|
||||
(defn update-note
|
||||
"Updates a note with the given store key if the specified password is correct"
|
||||
[key text passwd]
|
||||
(when (= passwd (redis/hget db password key))
|
||||
(redis/hset db note key text)))
|
||||
(let [stored-password (redis/hget db password key)]
|
||||
(when (and stored-password (= passwd stored-password))
|
||||
(redis/hset db note key text))))
|
||||
|
||||
(defn set-note
|
||||
"Creates a note with the given title and text in the given date namespace"
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
(ns NoteHub.views.common
|
||||
(:use
|
||||
[NoteHub.settings :only [get-message]]
|
||||
[NoteHub.views.css]
|
||||
[noir.core :only [defpartial]]
|
||||
[noir.options :only [dev-mode?]]
|
||||
[hiccup.util :only [escape-html]]
|
||||
@@ -40,16 +39,16 @@
|
||||
:rel "stylesheet"
|
||||
:type "text/css"}]
|
||||
; generating the global CSS
|
||||
[:style {:type "text/css"} (global-css params)]
|
||||
[:link {:rel "stylesheet" :type "text/css" :href "/style.css"}]
|
||||
; google analytics code should appear in prod mode only
|
||||
(if-not (dev-mode?) (include-js "/js/google-analytics.js"))]
|
||||
[:body content
|
||||
; we only need JS during a new note creation, so don't render it otherwise
|
||||
(when (params :js)
|
||||
(html
|
||||
(javascript-tag "var CLOSURE_NO_DEPS = true;")
|
||||
(include-js "/js/md5.js")
|
||||
(include-js "/js/pagedown/Markdown.Converter.js")
|
||||
(include-js "/cljs/main.js")))])))
|
||||
(include-js "/js/main.js")))])))
|
||||
|
||||
(defn layout
|
||||
"Generates the main html layout"
|
||||
|
||||
@@ -1,179 +0,0 @@
|
||||
(ns NoteHub.views.css
|
||||
(:use
|
||||
[cssgen]
|
||||
[cssgen.types :only [px %]]
|
||||
[NoteHub.settings]))
|
||||
|
||||
(defn- gen-fontlist [& fonts]
|
||||
(apply str
|
||||
(interpose ","
|
||||
(map #(str "'" % "'")
|
||||
(filter identity fonts)))))
|
||||
|
||||
; CSS Mixins
|
||||
(def page-width
|
||||
(get-setting :page-width #(Integer/parseInt %) 800))
|
||||
|
||||
(def helvetica-neue
|
||||
(mixin
|
||||
:font-weight 300
|
||||
:font-family (gen-fontlist "Helvetica Neue"
|
||||
"Helvetica"
|
||||
"Arial"
|
||||
"Lucida Grande"
|
||||
"sans-serif")))
|
||||
|
||||
(def central-element
|
||||
(mixin
|
||||
:width (px page-width)
|
||||
:margin-left "auto"
|
||||
:margin-right "auto"))
|
||||
|
||||
(defn thin-border [foreground]
|
||||
(mixin :border-radius :3px
|
||||
:border [:1px :solid foreground]))
|
||||
|
||||
; Resolves the theme name & tone parameter to a concrete color
|
||||
(defn- color [& keys]
|
||||
(get-in {:dark {:background :#333
|
||||
:foreground :#ccc
|
||||
:background-halftone :#444
|
||||
:foreground-halftone :#bbb
|
||||
:link {:fresh :#6b8
|
||||
:visited :#496
|
||||
:hover :#7c9 }}
|
||||
:solarized {:background :#073642
|
||||
:foreground :#93a1a1
|
||||
:background-halftone :#002b36
|
||||
:foreground-halftone :#eee8d5
|
||||
:link {:fresh :#cb4b16
|
||||
:visited :#b58900
|
||||
:hover :#dc322f }}
|
||||
:default {:background :#fff
|
||||
:foreground :#333
|
||||
:background-halftone :#efefef
|
||||
:foreground-halftone :#888
|
||||
:link {:fresh :#097
|
||||
:visited :#054
|
||||
:hover :#0a8 }}} keys))
|
||||
|
||||
(defn global-css
|
||||
"Generates the entire CSS rules of the app"
|
||||
[params]
|
||||
(let [theme (params :theme)
|
||||
theme (if theme (keyword theme) :default)
|
||||
header-fonts (gen-fontlist (params :header-font) "Noticia Text" "PT Serif" "Georgia")
|
||||
text-fonts (gen-fontlist (params :text-font) "Georgia")
|
||||
background (color theme :background)
|
||||
foreground (color theme :foreground)
|
||||
background-halftone (color theme :background-halftone)
|
||||
foreground-halftone (color theme :foreground-halftone)
|
||||
link-fresh (color theme :link :fresh)
|
||||
link-visited (color theme :link :visited)
|
||||
link-hover (color theme :link :hover)]
|
||||
(css
|
||||
(rule "a"
|
||||
:color link-fresh
|
||||
:text-decoration :none
|
||||
:border-bottom [:1px :dotted]
|
||||
(rule "&:hover"
|
||||
:color link-hover)
|
||||
(rule "&:visited"
|
||||
:color link-visited))
|
||||
(rule "#draft"
|
||||
:margin-bottom :3em)
|
||||
(rule ".ui-border"
|
||||
(thin-border foreground))
|
||||
(rule ".button"
|
||||
:cursor :pointer)
|
||||
(rule ".ui-elem"
|
||||
helvetica-neue
|
||||
(thin-border foreground)
|
||||
:padding :0.3em
|
||||
:opacity 0.8
|
||||
:font-size :1em
|
||||
:background background)
|
||||
(rule ".landing-button, table, tr, td, textarea, fieldset"
|
||||
:border :none)
|
||||
(rule ".landing-button"
|
||||
:box-shadow [0 :2px :5px :#aaa]
|
||||
:text-decoration :none
|
||||
:font-size :1.5em
|
||||
:background :#0a2
|
||||
:border-radius :10px
|
||||
:padding :10px
|
||||
helvetica-neue
|
||||
(rule "&:hover"
|
||||
:background :#0b2))
|
||||
(rule "#panel"
|
||||
helvetica-neue
|
||||
:position :fixed
|
||||
:width (% 100)
|
||||
:border-top [:1px :dotted foreground-halftone]
|
||||
:background background-halftone
|
||||
:padding :0.2em
|
||||
:bottom :0px
|
||||
:font-size :0.7em
|
||||
:text-align :center
|
||||
(rule "a"
|
||||
:border :none))
|
||||
(rule "html, body"
|
||||
:background background
|
||||
:color foreground
|
||||
:margin 0
|
||||
:padding 0)
|
||||
(rule "#stats"
|
||||
(rule "tr"
|
||||
(rule "& > td:first-child"
|
||||
:text-align :right)))
|
||||
(rule ".helvetica-neue"
|
||||
helvetica-neue)
|
||||
(rule "#hero"
|
||||
:padding-top :5em
|
||||
:padding-bottom :5em
|
||||
:text-align :center
|
||||
(rule "h1"
|
||||
:font-size :2.5em)
|
||||
(rule "h2"
|
||||
helvetica-neue
|
||||
:margin :2em))
|
||||
(rule "article"
|
||||
central-element
|
||||
:margin-top :5em
|
||||
:font-family text-fonts
|
||||
:text-align :justify
|
||||
:font-size :1.2em
|
||||
(rule "p"
|
||||
:line-height (% 140))
|
||||
(rule "& > h1:first-child"
|
||||
:text-align :center
|
||||
:margin :2em))
|
||||
(rule ".centered"
|
||||
:text-align :center)
|
||||
(rule ".bottom-space"
|
||||
:margin-bottom :7em)
|
||||
(rule "pre"
|
||||
:border-radius :3px
|
||||
:padding :0.5em
|
||||
:border [:1px :dotted foreground-halftone]
|
||||
:background background-halftone)
|
||||
(rule "*:focus"
|
||||
:outline [:0px :none :transparent])
|
||||
(rule "textarea"
|
||||
:width (px page-width)
|
||||
:border-radius :5px
|
||||
:font-family :Courier
|
||||
:font-size :1em
|
||||
:height :500px)
|
||||
(rule ".hidden"
|
||||
:display :none)
|
||||
(rule ".central-element"
|
||||
central-element)
|
||||
(rule "h1"
|
||||
:font-size :2em)
|
||||
(rule "#dashed-line"
|
||||
:border-bottom [:1px :dashed foreground-halftone]
|
||||
:margin-top :3em
|
||||
:margin-bottom :3em)
|
||||
(rule "h1, h2, h3, h4, h5, h6"
|
||||
:font-family header-fonts))))
|
||||
@@ -1,6 +1,5 @@
|
||||
(ns NoteHub.views.pages
|
||||
(:require [NoteHub.crossover.lib :as lib]
|
||||
[hiccup.util :as util])
|
||||
(:require [hiccup.util :as util])
|
||||
(:use
|
||||
[NoteHub.storage]
|
||||
[NoteHub.settings]
|
||||
@@ -26,6 +25,22 @@
|
||||
(defn md-to-html [md-text]
|
||||
(.markdownToHtml md-processor md-text))
|
||||
|
||||
(defn get-hash
|
||||
"A simple hash-function, which computes a hash from the text field
|
||||
content and given session number. It is intended to be used as a spam
|
||||
protection / captcha alternative. (Probably doesn't work for UTF-16)"
|
||||
[s]
|
||||
(let [short-mod #(mod % 32767)
|
||||
char-codes (map #(.codePointAt % 0) (remove #(contains? #{"\n" "\r"} %) (map str s)))
|
||||
zip-with-index (map list char-codes (range))]
|
||||
(reduce
|
||||
#(short-mod (+ %
|
||||
(short-mod (* (first %2)
|
||||
((if (odd? %)
|
||||
bit-xor
|
||||
bit-and) 16381 (second %2))))))
|
||||
0 zip-with-index)))
|
||||
|
||||
; Sets a custom message for each needed HTTP status.
|
||||
; The message to be assigned is extracted with a dynamically generated key
|
||||
(doseq [code [400 403 404 500]]
|
||||
@@ -151,7 +166,7 @@
|
||||
; is the hash code correct?
|
||||
valid-hash (try
|
||||
(= (Short/parseShort session-value)
|
||||
(lib/hash #(.codePointAt % 0) (str draft session-key)))
|
||||
(get-hash (str draft session-key)))
|
||||
(catch Exception e nil))]
|
||||
; check whether the new note can be added
|
||||
(if (and valid-session valid-draft valid-hash)
|
||||
|
||||
Reference in New Issue
Block a user