This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns flockr | |
(:use compojure)) | |
(defn index [] | |
(html | |
[:h1 "Flockr"] | |
[:h2 "Twitter Portal"])) | |
(defservlet home | |
(GET "/" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns flockr.template | |
(:use compojure)) | |
(defn page | |
[title body] | |
(html | |
[:html | |
[:head | |
[:title title]] | |
[:body |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns flockr | |
(:use compojure ) | |
(:use flockr.template)) ; looks for flockr/template.clj |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn twitter-status | |
[tweet] | |
[:p.tweet | |
[:div.tweet-text (tweet "text")] | |
[:div.tweet-user (get-in tweet ["user" "name"])]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns sandbox.file-upload | |
(:use ring.adapter.jetty | |
ring.util.response | |
ring.middleware.multipart-params | |
ring.middleware.stacktrace | |
hiccup.core | |
hiccup.form-helpers | |
compojure.core | |
clojure.pprint)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns demo.core | |
(:use [ring.adapter.jetty :only (run-jetty)] | |
[ring.middleware.session :only (wrap-session)] | |
[ring.middleware.flash :only (wrap-flash)] | |
[ring.middleware.stacktrace :only (wrap-stacktrace)] | |
[hiccup.core :only (html)] | |
[hiccup.form-helpers :only (form-to label text-field submit-button)] | |
[hiccup.page-helpers :only (xhtml unordered-list)] | |
[compojure.core :only (defroutes GET POST)] | |
[compojure.route :only (not-found)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn has-access? [id password] | |
(fetch-one :pads :where {:name id :password password})) | |
(defpage "/:id" {:keys [id password]} | |
(if (has-access? id password) | |
(common/layout id (notepad id)) | |
(do (insert! :pads {:name id}) | |
(resp/redirect "/")))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn with-mc* | |
"Manages the memcache connection" | |
[mchosts func] | |
(let [^MemcachedClient con (get-connection mchosts)] | |
(debug "set up new connection") | |
(Thread/sleep 1) ; fix to workaround bug #... | |
(binding [*db* (assoc *db* :connection con :level 0)] | |
(try | |
(func) | |
(finally (.shutdown con 5 TimeUnit/SECONDS))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def action-show | |
"Action that shows the help and about page." | |
(GET "/help" [account member] | |
(normal-layout account | |
[:div | |
[:h1 "Title"] | |
[:p "lorem"]]) | |
(defroutes app-routes | |
index/action-show |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require '[clojure.string :as str]) | |
(defn parse-ints [line] | |
(for [s (str/split line #" ")] (Integer/parseInt s))) | |
(defn read-service-data [] | |
(let [[n t] (parse-ints (read-line))] | |
{:widths (parse-ints (read-line)) | |
:tests (->> (repeatedly read-line) (take n) (map parse-ints))})) |
OlderNewer