diff --git a/project.clj b/project.clj index aa6ebd9..c4ca87b 100644 --- a/project.clj +++ b/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} ) diff --git a/src/testify/appear.clj b/src/testify/appear.clj index 20c20c8..edc17c3 100644 --- a/src/testify/appear.clj +++ b/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,12 +24,12 @@ (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) @@ -37,7 +37,7 @@ (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 diff --git a/src/testify/core.clj b/src/testify/core.clj index eb139fc..2816b65 100755 --- a/src/testify/core.clj +++ b/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 diff --git a/src/testify/process/fileops.clj b/src/testify/process/fileops.clj index 592866e..121c5d0 100644 --- a/src/testify/process/fileops.clj +++ b/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)))) \ No newline at end of file + (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))) \ No newline at end of file diff --git a/src/testify/process/transform.clj b/src/testify/process/transform.clj index 6f92f59..55e242e 100644 --- a/src/testify/process/transform.clj +++ b/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 diff --git a/src/testify/views/page.clj b/src/testify/views/page.clj index a50d2fa..debdac6 100644 --- a/src/testify/views/page.clj +++ b/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]