Permalink
Browse files

added STYLE and formatted code accordingly

  • Loading branch information...
1 parent 0b8ffd6 commit 30e2b9140f0b46370dde2827e3ca10570e4a136e @jeyoor committed Feb 15, 2012
View
18 STYLE
@@ -0,0 +1,18 @@
+Prettification notes
+
+Guidelines
+ 1. Indent new levels by two spaces
+ 2. All closing parens along the same line
+ 3. Opening parens and the matching symbol along the same line
+ 4. Indent the continuation of levels beneath the level they match
+
+To prettify a file in emacs:
+Install and use ElispFormat
+http://www.emacswiki.org/emacs/ElispFormat#toc4
+
+To prettify a file in vim:
+
+
+
+
+
View
@@ -1,134 +1,100 @@
(ns testify.appear
- (:use
- net.cgrand.enlive-html
+ (:use net.cgrand.enlive-html
testify.util
- testify.html-macros
- )
- (:require
- [clojure.string :as string]
- )
-)
+ testify.html-macros)
+ (:require [clojure.string :as string]))
-(deftemplate base "testify/templates/base.html"
- [pagetitle content]
- ;if a header is passed in, give substi fun
- ;otherwise, give identity fun (leave html unchng)
- [:div#header :span#pagetitle] (maybe-appear pagetitle)
- ;no linkup on basic base
- [:div#header :a#biglink] nil
- [:div#content] (maybe-content content)
+(deftemplate base "testify/templates/base.html" [pagetitle content]
+ ;if a header is passed in, give substi fun
+ ;otherwise, give identity fun (leave html unchng)
+ [:div#header :span#pagetitle] (maybe-appear pagetitle)
+ ;no linkup on basic base
+ [:div#header :a#biglink] nil
+ [:div#content] (maybe-content content))
-)
(deftemplate link-base "testify/templates/base.html"
- [pagetitle linkname linkref content]
- ;if a header is passed in, give substi fun
- ;otherwise, give identity fun (leave html unchng)
- [:div#header :span#pagetitle] (maybe-appear pagetitle)
- [:div#header :a#biglink]
- (do->
- (maybe-content linkname)
- (maybe-href linkref)
- )
- [:div#content] (maybe-content content)
-
-
-)
-(defsnippet message "testify/templates/base.html"
- [:span.message]
- [message]
- ;TODO: make this more expressive?
- [:span.message] (maybe-content message)
-)
-(defsnippet input "testify/templates/user_input.html"
- [:input.field]
- [type name classy value]
- [:input.field] (do->
- (maybe-type type)
- (maybe-class classy)
- (maybe-name name)
- (maybe-value value)
- )
-)
+ [pagetitle linkname linkref content]
+ ;if a header is passed in, give substi fun
+ ;otherwise , give identity fun (leave html unchng)
+ [:div#header :span#pagetitle] (maybe-appear pagetitle)
+ [:div#header :a#biglink]
+ (do-> (maybe-content linkname)
+ (maybe-href linkref))
+ [:div#content] (maybe-content content))
+
+(defsnippet message "testify/templates/base.html" [:span.message]
+ [message]
+ ;TODO: make this more expressive?
+ [:span.message] (maybe-content message))
+
+(defsnippet input "testify/templates/user_input.html" [:input.field]
+ [type name classy value]
+ [:input.field]
+ (do-> (maybe-type type)
+ (maybe-class classy)
+ (maybe-name name)
+ (maybe-value value)))
(defsnippet ul-link "testify/templates/user_list.html"
- ;grab the whole unordered list
- [:ul.mainlist]
- ;take link name and ref as params
- [linkname linkref]
- ;todo check null links here?
- ;drill down to the first anchor tag
- [:ul.mainlist :li.mainlist :a.firstlink]
- (do->
- (content linkname)
- (set-attr :href linkref)
- )
-)
+ ;grab the whole unordered list
+ [:ul.mainlist]
+ ;take link name and ref as params
+ [linkname linkref]
+ ;todo check null links here?
+ ;drill down to the first anchor tag
+ [:ul.mainlist :li.mainlist :a.firstlink]
+ (do-> (content linkname)
+ (set-attr :href linkref)))
(defsnippet ul-link-delete "testify/templates/admin_list.html"
- ;grab the whole unordered list
- [:ul.mainlist]
- ;take link name and ref as params
- [linkname1 linkref1 postname postval]
- ;todo check null links here?
- ;drill down to the first anchor tag
- [:ul.mainlist :li.mainlist :a.firstlink]
- (do->
- (maybe-content linkname1)
- (maybe-href linkref1)
- )
- [:ul.mainlist :li.mainlist :input.delete]
- (do->
- (maybe-name postname)
- (maybe-value postval)
- )
-)
-
-(defsnippet form "testify/templates/user_input.html"
- [:form]
- [method action content]
- [:form] (do->
- (set-attr :action action :method method)
- (maybe-content content)
- )
-)
-
-(defsnippet save-form "testify/templates/user_input.html"
- [:form]
- [method action content]
- [:form] (do->
- (set-attr :action action :method method)
- (maybe-content content)
- (append (input "submit" "save" "saver" "Save Page"))
- )
-)
+ ;grab the whole unordered list
+ [:ul.mainlist]
+ ;take link name and ref as params
+ [linkname1 linkref1 postname postval]
+ ;TODO: check null links here?
+ ;drill down to the first anchor tag
+ [:ul.mainlist :li.mainlist :a.firstlink]
+ (do-> (maybe-content linkname1)
+ (maybe-href linkref1))
+ [:ul.mainlist :li.mainlist :input.delete]
+ (do-> (maybe-name postname)
+ (maybe-value postval)))
+
+(defsnippet form "testify/templates/user_input.html" [:form]
+ [method action content]
+ [:form]
+ (do-> (set-attr :action action
+ :method method)
+ (maybe-content content)))
+
+(defsnippet save-form "testify/templates/user_input.html" [:form]
+ [method action content]
+ [:form]
+ (do-> (set-attr :action action
+ :method method)
+ (maybe-content content)
+ (append (input "submit" "save" "saver" "Save Page"))))
;page form has a hidden field for the template name
-(defsnippet page-form "testify/templates/user_input.html"
- [:form]
- [method action template content]
- [:form] (do->
- (set-attr :action action :method method )
- (maybe-content content)
- (prepend (input "hidden" "template" "passer" template))
- (append (input "submit" "save" "saver" "Save Page"))
- )
-)
-
-
-
+(defsnippet page-form "testify/templates/user_input.html" [:form]
+ [method action template content]
+ [:form]
+ (do-> (set-attr :action action
+ :method method )
+ (maybe-content content)
+ (prepend (input "hidden" "template" "passer" template))
+ (append (input "submit" "save" "saver" "Save Page"))))
(defsnippet input-row "testify/templates/user_input.html"
- ;take the typeclass and the name, plug in into an inputrow
- ;TODO Have typing pick which field (textarea or which input) we pull
- ;TODO Give ajaxified validation based on typeclass to the user
- #{[:span.fieldname] [:textarea.field] [:br.ender]}
- [typeclass name]
- [:span.fieldname] (maybe-content (str name ":" typeclass))
- [:textarea.field] (do->
- (maybe-class typeclass)
- (maybe-name name)
- )
-
-)
+ ;take the typeclass and the name, plug in into an inputrow
+ ;TODO Have typing pick which field (textarea or which input) we pull
+ ;TODO Give ajaxified validation based on typeclass to the user
+ #{[:span.fieldname] [:textarea.field] [:br.ender]}
+ [typeclass name]
+ [:span.fieldname]
+ (maybe-content (str name ":" typeclass))
+ [:textarea.field]
+ (do-> (maybe-class typeclass)
+ (maybe-name name)))
View
@@ -1,17 +1,12 @@
(ns testify.core
(:use
- ring.adapter.jetty
- )
+ ring.adapter.jetty)
(:require
[testify.debug :as debug]
- [testify.routes :as routes]
+ [testify.routes :as routes]))
-
- )
-)
-
-(defn -main []
- (let [port (System/getenv "PORT")]
- (if port (run-jetty routes/app {:port (Integer/parseInt port)})
- (run-jetty routes/app {:port 8000}))
- ))
+(defn -main []
+ (let [port (System/getenv "PORT")]
+ (if port
+ (run-jetty routes/app {:port (Integer/parseInt port)})
+ (run-jetty routes/app {:port 8000}))))
View
@@ -1,52 +1,28 @@
(ns testify.debug
-
(:require
[redis.core :as redis]
[testify.appear :as appear]
[testify.persist :as persist]
[clojure.string :as string]
- [net.cgrand.enlive-html :as html]
- )
-)
-
-(defn echo [params]
- (str
- "<h1> hello </h1>"
- params "<br />"
- (get params :gender)
- )
-)
-
-
+ [net.cgrand.enlive-html :as html]))
+(defn echo [params]
+ (str "<h1> hello </h1>" params "<br />" (get params
+ :gender)))
+(defn dumpy [prefix]
+ (persist/gist prefix))
-(defn dumpy [prefix]
- (persist/gist prefix)
+(defn fetchy [key]
+ (str key " returned " (persist/fetch key))
)
-(defn fetchy [key]
- (str
- key " returned " (persist/fetch key)
- )
+(defn storey [key val]
+ (str "set " key " to " val " returned " (persist/store key val)))
-)
-
-(defn storey [key val]
- (str
- "set " key " to " val " returned " (persist/store key val)
- )
-)
+(defn bfetch [kay]
+ (persist/do-redis (redis/get kay)))
-(defn bfetch [kay]
- (persist/do-redis
- (redis/get kay)
- )
-)
-
-(defn bstore [kay]
- (persist/do-redis
- (redis/set kay "testvalue")
- )
-)
+(defn bstore [kay]
+ (persist/do-redis (redis/set kay "testvalue")))
@@ -1,6 +1,5 @@
(ns testify.html-macros
- (:use net.cgrand.enlive-html)
-)
+ (:use net.cgrand.enlive-html))
;courtesy of enlive-tutorial (David Nolan)
@@ -38,18 +37,15 @@
(defmacro maybe-appear
([expr] `(if-let [x# ~expr] (content x#) nil))
- ([expr & exprs] `(maybe-appear (or ~expr ~@exprs)))
-)
+ ([expr & exprs] `(maybe-appear (or ~expr ~@exprs))))
(defmacro maybe-prepend
([expr] `(if-let [x# ~expr] (prepend x#) nil))
- ([expr & exprs] `(maybe-prepend (or ~expr ~@exprs)))
-)
+ ([expr & exprs] `(maybe-prepend (or ~expr ~@exprs))))
;new macro, replaces content of nodes with id "blah"
;make it good for reduce! :-)
(defmacro content-by-id [nodes [id content]]
- `(at ~nodes
- ~(read-string (str "[:#" id "]")) (maybe-content content)
- )
-)
+ `(at ~nodes
+ ~(read-string (str "[:#" id "]")) (maybe-content content)))
+
Oops, something went wrong.

0 comments on commit 30e2b91

Please sign in to comment.