From 5f115b1abd8228b349f94a6268d1bad68c0330bf Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Mon, 23 Feb 2009 17:42:41 +0100 Subject: Reformat code. --- cljssss-g.clj | 123 ++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 67 insertions(+), 56 deletions(-) diff --git a/cljssss-g.clj b/cljssss-g.clj index 4f781db..59441db 100644 --- a/cljssss-g.clj +++ b/cljssss-g.clj @@ -33,59 +33,72 @@ (sql/with-query-results results ["SELECT feed.uri, feed.link, user_feed_link.title FROM feed, user_feed_link WHERE user_feed_link.feed=feed.id AND user_feed_link.user=?" id] - (str "" - "blah" - "Gödel-Gentzen Clojure Syndication Services Super System Feed Export" + (str + "" + "blah" + "Gödel-Gentzen Clojure Syndication Services Super System Feed Export" (loop [clstr "" r results] - (if (first r) - (recur - (str clstr - "") - (rest r)) - clstr)) + (if (first r) + (recur + (str clstr + "") + (rest r)) + clstr)) "")))) (defn lynxy-feedlist [id] (with-dbt (sql/with-query-results results - ["SELECT feed.id, feed.uri, feed.link, user_feed_link.title FROM feed, user_feed_link WHERE user_feed_link.feed=feed.id AND user_feed_link.user=?" id] - (html `[html [head [title "Gödel-Gentzen Clojure Syndication Services Super System"]] - [body [ul - ~@(loop [back '[] r results] - (if (first r) - (recur (concat back `[[li - [a {:href ~(str "lynxy-showfeed?feed=" (:id (first r)))} - ~(:title (first r)) " - " - ~(:link (first r)) - ]]]) - (rest r)) - back))]]])))) + [(str "SELECT feed.id, feed.uri, feed.link, user_feed_link.title" + " FROM feed, user_feed_link" + " WHERE user_feed_link.feed=feed.id AND user_feed_link.user=?") + id] + (html + `[html + [head [title "Gödel-Gentzen Clojure Syndication Services Super System"]] + [body [ul + ~@(loop [back '[] r results] + (if (first r) + (recur (concat back `[[li + [a {:href ~(str "lynxy-showfeed?feed=" (:id (first r)))} + ~(:title (first r)) " - " + ~(:link (first r)) + ]]]) + (rest r)) + back))]]])))) (defn lynxy-showfeed [id feednum] (with-dbt (sql/with-query-results results - ["SELECT entry.link, entry.title FROM entry, feed_entry_link, user_feed_link WHERE entry.id = feed_entry_link.entry AND feed_entry_link.feed = user_feed_link.feed AND user_feed_link.user = ? AND user_feed_link.feed = ?" id feednum] - (html `[html [head [title "Gödel-Gentzen Clojure Syndication Services Super System"]] - [body [ul - ~@(loop [back '[] r results] - (if (first r) - (recur (concat back `[[li - [a {:href ~(:link (first r))} - ~(:title (first r)) " - " - ~(:link (first r)) - ]]]) - (rest r)) - back))] - [a {:href "lynxy-feedlist.html"} "« To Feedlist"] - ]])))) + [(str "SELECT entry.link, entry.title" + " FROM entry, feed_entry_link, user_feed_link" + " WHERE entry.id = feed_entry_link.entry" + " AND feed_entry_link.feed = user_feed_link.feed" + " AND user_feed_link.user = ?" + " AND user_feed_link.feed = ?") + id feednum] + (html + `[html + [head [title "Gödel-Gentzen Clojure Syndication Services Super System"]] + [body [ul + ~@(loop [back '[] r results] + (if (first r) + (recur (concat back `[[li + [a {:href ~(:link (first r))} + ~(:title (first r)) " - " + ~(:link (first r)) + ]]]) + (rest r)) + back))] + [a {:href "lynxy-feedlist.html"} "« To Feedlist"]]])))) (defmacro with-session [& body] `(if (not (~'session :id)) @@ -96,19 +109,17 @@ (defservlet cljssss-g (GET "/login" (if (= (params :valuesofbetawillgiverisetodom) "true") - (.toString (doto - (.getInstanceOf templates "login") - (.setAttributes {"logintext" "Login failed"}))) - (.toString (doto - (.getInstanceOf templates "login") - (.setAttributes {"logintext" "Login"}))))) + (.toString (doto (.getInstanceOf templates "login") + (.setAttributes {"logintext" "Login failed"}))) + (.toString (doto (.getInstanceOf templates "login") + (.setAttributes {"logintext" "Login"}))))) (POST "/login" - (dosync - (with-db - (sql/with-query-results [{id :id password :password}] - ["SELECT id, password FROM user WHERE name = ?" - (params :name)] - (if (= password (params :password)) + (dosync + (with-db + (sql/with-query-results [{id :id password :password}] + ["SELECT id, password FROM user WHERE name = ?" + (params :name)] + (if (= password (params :password)) (do (alter session assoc :id id) (redirect-to "/")) @@ -119,13 +130,13 @@ (with-session (lynxy-feedlist (session :id)))) (GET "/lynxy-showfeed" (with-session - (lynxy-showfeed (session :id) (. Integer parseInt (params :feed))))) + (lynxy-showfeed (session :id) (. Integer parseInt (params :feed))))) (GET "/" (with-session (.toString (doto (.getInstanceOf templates "index") - (.setAttributes {"title" "Subscriptions", - "mainParagraph" "Hi there!"}))))) + (.setAttributes {"title" "Subscriptions", + "mainParagraph" "Hi there!"}))))) (ANY "*" (page-not-found))) -- cgit v1.2.3