Browse Source

note compression added

master
Christian Mueller 12 years ago
parent
commit
d056149fa2
  1. 1
      project.clj
  2. 7
      src/notehub/storage.clj

1
project.clj

@ -2,6 +2,7 @@
:description "A free and anonymous hosting for markdown pages." :description "A free and anonymous hosting for markdown pages."
:dependencies [[org.clojure/clojure "1.5.1"] :dependencies [[org.clojure/clojure "1.5.1"]
[hiccup "1.0.0"] [hiccup "1.0.0"]
[zeus "0.1.0"]
[cheshire "5.3.1"] [cheshire "5.3.1"]
[ring/ring-core "1.2.0"] [ring/ring-core "1.2.0"]
[com.taoensso/carmine "2.4.4"] [com.taoensso/carmine "2.4.4"]

7
src/notehub/storage.clj

@ -1,5 +1,6 @@
(ns notehub.storage (ns notehub.storage
(:use [notehub.settings] (:use [notehub.settings]
[zeus.core]
[clojure.string :only (blank? replace) :rename {replace sreplace}]) [clojure.string :only (blank? replace) :rename {replace sreplace}])
(:require [taoensso.carmine :as car :refer (wcar)])) (:require [taoensso.carmine :as car :refer (wcar)]))
@ -43,12 +44,12 @@
(defn edit-note [noteID text] (defn edit-note [noteID text]
(redis :hset :edited noteID (get-current-date)) (redis :hset :edited noteID (get-current-date))
(redis :hset :note noteID text)) (redis :hset :note noteID (zip text)))
(defn add-note (defn add-note
([noteID text pid] (add-note noteID text pid nil)) ([noteID text pid] (add-note noteID text pid nil))
([noteID text pid passwd] ([noteID text pid passwd]
(redis :hset :note noteID text) (redis :hset :note noteID (zip text))
(redis :hset :published noteID (get-current-date)) (redis :hset :published noteID (get-current-date))
(redis :hset :publisher noteID pid) (redis :hset :publisher noteID pid)
(when (not (blank? passwd)) (when (not (blank? passwd))
@ -77,7 +78,7 @@
(when (note-exists? noteID) (when (note-exists? noteID)
(do (do
(redis :hincrby :views noteID 1) (redis :hincrby :views noteID 1)
(redis :hget :note noteID)))) (unzip (redis :hget :note noteID)))))
(defn short-url-exists? [url] (defn short-url-exists? [url]
(= 1 (redis :hexists :short-url url))) (= 1 (redis :hexists :short-url url)))

Loading…
Cancel
Save