clojure contrib dependency eliminated

This commit is contained in:
Christian Mueller
2013-10-26 21:22:02 +02:00
parent 2624222611
commit 31e292d860
5 changed files with 11 additions and 11 deletions
+1 -2
View File
@@ -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))))
+3 -3
View File
@@ -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
+4 -4
View File
@@ -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)