clojure contrib dependency eliminated
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
(defproject NoteHub "0.1.0-SNAPSHOT"
|
||||
:description "A free and anonymous hosting for markdown pages."
|
||||
:dependencies [[org.clojure/clojure "1.3.0"]
|
||||
[org.clojure/clojure-contrib "1.2.0"]
|
||||
[hiccup "1.0.0"]
|
||||
[ring/ring-core "1.1.0"]
|
||||
[cssgen "0.2.6"]
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
(ns NoteHub.settings
|
||||
(:require [clojure.contrib.string :as ccs])
|
||||
(:refer-clojure :exclude [replace reverse])
|
||||
(:use [clojure.string]))
|
||||
|
||||
@@ -8,7 +7,7 @@
|
||||
(defn- get-pairs-map [file]
|
||||
(let [file-content (slurp file)
|
||||
pairs (map #(map trim (split % #"=" 2))
|
||||
(remove ccs/blank? (ccs/split-lines file-content)))]
|
||||
(remove blank? (split-lines file-content)))]
|
||||
(apply hash-map
|
||||
(mapcat #(list (keyword (first %)) (second %)) pairs))))
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
(ns NoteHub.storage
|
||||
(:use [NoteHub.settings]
|
||||
[clojure.string :only (blank?)]
|
||||
[noir.util.crypt :only [encrypt]]
|
||||
[noir.options :only [dev-mode?]])
|
||||
(:require [clj-redis.client :as redis]
|
||||
[clojure.contrib.string :as ccs]))
|
||||
(:require [clj-redis.client :as redis]))
|
||||
|
||||
; Initialize the data base
|
||||
(def db
|
||||
@@ -51,7 +51,7 @@
|
||||
(let [key (build-key date title)]
|
||||
(do
|
||||
(redis/hset db note key text)
|
||||
(when (not (ccs/blank? passwd))
|
||||
(when (not (blank? passwd))
|
||||
(redis/hset db password key passwd))))))
|
||||
|
||||
(defn get-note
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
(ns NoteHub.views.pages
|
||||
(:require [NoteHub.crossover.lib :as lib]
|
||||
[clojure.contrib.string :as ccs]
|
||||
[hiccup.util :as util])
|
||||
(:use
|
||||
[NoteHub.storage]
|
||||
[NoteHub.settings]
|
||||
[NoteHub.views.common]
|
||||
[clojure.string :rename {replace sreplace} :only [split replace lower-case]]
|
||||
[clojure.string :rename {replace sreplace}
|
||||
:only [split replace blank? split-lines lower-case]]
|
||||
[clojure.core.incubator :only [-?>]]
|
||||
[hiccup.form]
|
||||
[hiccup.core]
|
||||
@@ -149,7 +149,7 @@
|
||||
(defpage [:post "/post-note"] {:keys [draft password session-key session-value]}
|
||||
; first we collect all info needed to evaluate the validity of the note creation request
|
||||
(let [valid-session (invalidate-session session-key) ; was the note posted from a newly generated form?
|
||||
valid-draft (not (ccs/blank? draft)) ; has the note a meaningful content?
|
||||
valid-draft (not (blank? draft)) ; has the note a meaningful content?
|
||||
; is the hash code correct?
|
||||
valid-hash (try
|
||||
(= (Short/parseShort session-value)
|
||||
@@ -162,7 +162,7 @@
|
||||
; if not, append "-n", where "n" is the next free number
|
||||
(let [[year month day] (get-date)
|
||||
untrimmed-line (filter #(or (= \- %) (Character/isLetterOrDigit %))
|
||||
(-> draft ccs/split-lines first (sreplace " " "-") lower-case))
|
||||
(-> draft split-lines first (sreplace " " "-") lower-case))
|
||||
trim (fn [s] (apply str (drop-while #(= \- %) s)))
|
||||
title-uncut (-> untrimmed-line trim reverse trim reverse)
|
||||
max-length (get-setting :max-title-length #(Integer/parseInt %) 80)
|
||||
|
||||
@@ -2,11 +2,13 @@
|
||||
(:require [NoteHub.crossover.lib :as lib])
|
||||
(:use [NoteHub.views.pages]
|
||||
[noir.util.test]
|
||||
[clojure.contrib.string :only [substring?]]
|
||||
[NoteHub.views.common :only [url]]
|
||||
[NoteHub.storage]
|
||||
[clojure.test]))
|
||||
|
||||
(defn substring? [a b]
|
||||
(not (= nil
|
||||
(re-matches (re-pattern (str "(?s).*" a ".*")) b))))
|
||||
(def date [2012 6 3])
|
||||
(def test-title "some-title")
|
||||
(def test-note "# This is a test note.\nHello _world_. Motörhead, тест.")
|
||||
|
||||
Reference in New Issue
Block a user