Browse files

template files found on path now

  • Loading branch information...
1 parent ee89091 commit 0543ce75277072a2ce6aa0b5bdd319f2c0edb770 @jeyoor committed Feb 23, 2012
Showing with 29 additions and 18 deletions.
  1. +1 −1 project.clj
  2. +10 −10 src/testify/appear.clj
  3. +2 −0 src/testify/core.clj
  4. +10 −4 src/testify/process/fileops.clj
  5. +5 −2 src/testify/process/transform.clj
  6. +1 −1 src/testify/views/page.clj
View
2 project.clj
@@ -11,5 +11,5 @@
[org.clojars.tavisrudd/redis-clojure "1.3.1-SNAPSHOT"]
]
:dev-dependencies [[lein-ring "0.4.5"]]
- :ring {:handler testify.core/app}
+ :ring {:handler testify.routes/app}
)
View
20 src/testify/appear.clj
@@ -5,7 +5,7 @@
(:require [clojure.string :as string]))
-(deftemplate base "testify/templates/base.html" [pagetitle content]
+(deftemplate base "../resources/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)
@@ -14,7 +14,7 @@
[:div#content] (maybe-content content))
-(deftemplate link-base "testify/templates/base.html"
+(deftemplate link-base "../resources/templates/base.html"
[pagetitle linkname linkref content]
;if a header is passed in, give substi fun
;otherwise , give identity fun (leave html unchng)
@@ -24,20 +24,20 @@
(maybe-href linkref))
[:div#content] (maybe-content content))
-(defsnippet message "testify/templates/base.html" [:span.message]
+(defsnippet message "../resources/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]
+(defsnippet input "../resources/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"
+(defsnippet ul-link "../resources/templates/user_list.html"
;grab the whole unordered list
[:ul.mainlist]
;take link name and ref as params
@@ -48,7 +48,7 @@
(do-> (content linkname)
(set-attr :href linkref)))
-(defsnippet ul-link-delete "testify/templates/admin_list.html"
+(defsnippet ul-link-delete "../resources/templates/admin_list.html"
;grab the whole unordered list
[:ul.mainlist]
;take link name and ref as params
@@ -62,14 +62,14 @@
(do-> (maybe-name postname)
(maybe-value postval)))
-(defsnippet form "testify/templates/user_input.html" [:form]
+(defsnippet form "../resources/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]
+(defsnippet save-form "../resources/templates/user_input.html" [:form]
[method action content]
[:form]
(do-> (set-attr :action action
@@ -78,7 +78,7 @@
(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]
+(defsnippet page-form "../resources/templates/user_input.html" [:form]
[method action template content]
[:form]
(do-> (set-attr :action action
@@ -87,7 +87,7 @@
(prepend (input "hidden" "template" "passer" template))
(append (input "submit" "save" "saver" "Save Page"))))
-(defsnippet input-row "testify/templates/user_input.html"
+(defsnippet input-row "../resources/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
View
2 src/testify/core.clj
@@ -5,6 +5,8 @@
[testify.debug :as debug]
[testify.routes :as routes]))
+;;This main is used from a Java environment (lein run)
+;;lein-ring's main is specified in project.clj
(defn -main []
(let [port (System/getenv "PORT")]
(if port
View
14 src/testify/process/fileops.clj
@@ -2,7 +2,13 @@
;;differentiate cloud foundry & other paths by env variable
(defn real-dir [relpath]
- (let [testifydir (. System getenv "TESTIFYDIR") ]
- (cond (nil? testifydir)
- (str "/resources/" relpath)
- :else (str testifydir "/" relpath))))
+ (let [testifyenv (. System getenv "TESTIFYDIR")
+ userdir (.. System (getProperties) (get "user.dir"))]
+ (cond (nil? testifyenv)
+ (str userdir "/resources/" relpath)
+ :else (str userdir testifyenv "/" relpath))))
+
+(defn find-template
+ "given a template filename, return the full path to the template"
+ [tname]
+ (real-dir (str "templates/" tname)))
View
7 src/testify/process/transform.clj
@@ -67,7 +67,7 @@
(defn process-fname
"Take a function name string and return the appropriate Clojure symbol"
[fname]
- (load-string (str "html/" (.trim fname))))
+ (load-string (str "net.cgrand.enlive-html/" (.trim fname))))
(defn single-transform
"take one user-script transformation statement and apply it to the given HTML nodes"
@@ -99,7 +99,10 @@
(defn bulk-transform
"apply a user transformation from the specified transform file to the the specified HTML file"
[#^java.lang.String html #^java.lang.String transform ]
- (apply str (html/emit* (make-transform (html/html-snippet (slurp html)) (slurp transform)))))
+ (apply str (html/emit* (make-transform (html/html-snippet (slurp (fileops/find-template html))) (slurp (fileops/find-template transform))))))
+
+;;TODO: code generic bulk and specific file or redis string retrieval
+
;;;;Testing/debugging
View
2 src/testify/views/page.clj
@@ -21,7 +21,7 @@
;;use the ids to populate a linklist
;;TODO: switch this to use template context
;;(link-base nil "Add Page?" "/template" (linknodes pagelist "/page/view?pname="))
- (bulk-transform "../templates/base.html" "../templates/main.tr")))
+ (bulk-transform "base.html" "main.tr")))
(defn form-page [template]

0 comments on commit 0543ce7

Please sign in to comment.