From 998fc077e86f76dc5baaa07f366369ff416d6e56 Mon Sep 17 00:00:00 2001 From: Torsten Uhlmann Date: Sat, 17 Dec 2016 11:29:16 +0100 Subject: [PATCH] Provided fixes make cryogen work on Windows. The path is converted to forward slash before further processed The executables for sass and compass are configurable, that's because on a Windows installation they are named sass.bat and compass.bat The default is still the Unix version. --- .gitignore | 4 +++- project.clj | 2 +- src/cryogen_core/compiler.clj | 11 ++++++++--- src/cryogen_core/sass.clj | 19 +++++++++++-------- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 36d76e7..d44b519 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,6 @@ pom.xml.asc *.class /.lein-* /.nrepl-port -.DS* \ No newline at end of file +.DS* +/.idea/ +/cryogen-core.iml diff --git a/project.clj b/project.clj index 5be016b..a906878 100644 --- a/project.clj +++ b/project.clj @@ -1,4 +1,4 @@ -(defproject cryogen-core "0.1.43" +(defproject cryogen-core "0.1.44" :description "Cryogen's compiler" :url "https://github.com/cryogen-project/cryogen-core" :license {:name "Eclipse Public License" diff --git a/src/cryogen_core/compiler.clj b/src/cryogen_core/compiler.clj index 85d5ee2..f6b0e31 100644 --- a/src/cryogen_core/compiler.clj +++ b/src/cryogen_core/compiler.clj @@ -85,7 +85,8 @@ [^java.io.File page config markup] (with-open [rdr (java.io.PushbackReader. (reader page))] (let [re-root (re-pattern (str "^.*?(" (:page-root config) "|" (:post-root config) ")/")) - page-name (s/replace (str page) re-root "") + page-fwd (s/replace (str page) "\\" "/") ;; make it work on Windows + page-name (s/replace page-fwd re-root "") file-name (s/replace page-name (re-pattern-from-ext (m/ext markup)) ".html") page-meta (read-page-meta page-name rdr) content ((m/render-fn markup) rdr config)] @@ -434,6 +435,8 @@ (update-in [:rss-filters] (fnil seq [])) (update-in [:sass-src] (fnil str "css")) (update-in [:sass-dest] (fnil str "css")) + (update-in [:sass-path] (fnil str "sass")) + (update-in [:compass-path] (fnil str "compass")) (update-in [:post-date-format] (fnil str "yyyy-MM-dd")) (update-in [:keep-files] (fnil seq [])) (update-in [:ignored-files] (fnil seq [#"^\.#.*" #".*\.swp$"])))] @@ -448,7 +451,7 @@ "Generates all the html and copies over resources specified in the config" [] (println (green "compiling assets...")) - (let [{:keys [^String site-url blog-prefix rss-name recent-posts sass-src sass-dest keep-files ignored-files previews? author-root-uri] :as config} (read-config) + (let [{:keys [^String site-url blog-prefix rss-name recent-posts sass-src sass-dest sass-path compass-path keep-files ignored-files previews? author-root-uri] :as config} (read-config) posts (add-prev-next (read-posts config)) pages (add-prev-next (read-pages config)) [navbar-pages sidebar-pages] (group-pages pages) @@ -495,7 +498,9 @@ (rss/make-filtered-channels config posts-by-tag) (println (blue "compiling sass")) (sass/compile-sass->css! - {:src-sass sass-src + {:path-sass sass-path + :path-compass compass-path + :src-sass sass-src :dest-sass (path ".." "public" blog-prefix sass-dest) :ignored-files ignored-files :base-dir "resources/templates/"}))) diff --git a/src/cryogen_core/sass.clj b/src/cryogen_core/sass.clj index 8239e96..f85bf43 100644 --- a/src/cryogen_core/sass.clj +++ b/src/cryogen_core/sass.clj @@ -11,14 +11,14 @@ (defn sass-installed? "Checks for the installation of Sass." - [] - (= 0 (:exit (sh "sass" "--version")))) + [path-sass] + (= 0 (:exit (sh path-sass "--version")))) (defn compass-installed? "Checks for the installation of Compass." - [] + [path-compass] (try - (= 0 (:exit (sh "compass" "--version"))) + (= 0 (:exit (sh path-compass "--version"))) (catch java.io.IOException _ false))) @@ -38,11 +38,13 @@ done by sh / launching the sass command." [{:keys [src-sass dest-sass + path-sass + path-compass base-dir]}] (shell/with-sh-dir base-dir - (if (compass-installed?) - (sh "sass" "--compass" "--update" (str src-sass ":" dest-sass)) - (sh "sass" "--update" (str src-sass ":" dest-sass))))) + (if (compass-installed? path-compass) + (sh path-sass "--compass" "--update" (str src-sass ":" dest-sass)) + (sh path-sass "--update" (str src-sass ":" dest-sass))))) (defn compile-sass->css! "Given a directory src-sass, looks for all sass files and compiles them into @@ -50,10 +52,11 @@ dest-sass. Prompts you to install sass if he finds sass files and can't find the command. Shows you any problems it comes across when compiling. " [{:keys [src-sass dest-sass + path-sass ignored-files base-dir] :as opts}] (when-let [sass-files (seq (find-sass-files base-dir src-sass ignored-files))] - (if (sass-installed?) + (if (sass-installed? path-sass) ;; I found sass files, ;; If sass is installed (do