Merge branch 'development'

This commit is contained in:
jem 2019-12-03 16:54:10 +01:00
commit c773ed3282
6 changed files with 71 additions and 29 deletions

View file

@ -1,19 +1,30 @@
(defproject cryogen-core "0.1.53-SNAPSHOT" (defproject dda/cryogen-core "0.2.0-SNAPSHOT"
:description "Cryogen's compiler" :description "Cryogen's compiler"
:url "https://github.com/cryogen-project/cryogen-core" :url "https://github.com/cryogen-project/cryogen-core"
:license {:name "Eclipse Public License" :license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"} :url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"] :dependencies [[org.clojure/clojure "1.10.0"]
[camel-snake-kebab "0.4.0"] [camel-snake-kebab "0.4.1"]
[cheshire "5.7.0"] [cheshire "5.9.0"]
[clj-rss "0.2.3"] [clj-rss "0.2.5"]
[clj-text-decoration "0.0.3"] [clj-text-decoration "0.0.3"]
[enlive "1.1.6"] [enlive "1.1.6"]
[hawk "0.2.11"] [hawk "0.2.11"]
[hiccup "1.0.5"] [hiccup "1.0.5"]
[io.aviso/pretty "0.1.33"] [io.aviso/pretty "0.1.37"]
[me.raynes/fs "1.4.6"] [me.raynes/fs "1.4.6"]
[pandect "0.6.1"] [pandect "0.6.1"]
[selmer "1.10.6"]] [selmer "1.12.17"]]
:deploy-repositories [["snapshots" :clojars] :deploy-repositories [["snapshots" :clojars]
["releases" :clojars]]) ["releases" :clojars]]
:source-paths ["src"]
:resource-paths ["resources"]
:profiles {:dev {:source-paths ["test"]
:resource-paths ["test-resources"]
:dependencies []
:leiningen/reply
{:dependencies [[org.slf4j/jcl-over-slf4j "1.8.0-beta0"]]
:exclusions [commons-logging]}}
:test {:source-paths ["test"]
:resource-paths ["test-resources"]
:dependencies []}})

View file

@ -0,0 +1,7 @@
(ns cryogen-core.classpath-able-io
(:require [clojure.java.io :as io]
[clojure.string :as s]
[me.raynes.fs :as fs]))
(defn copy-resources-from-theme
[theme target])

View file

@ -491,7 +491,7 @@
[] []
(println (green "compiling assets...")) (println (green "compiling assets..."))
(let [{:keys [^String site-url blog-prefix rss-name recent-posts sass-dest keep-files ignored-files previews? (let [{:keys [^String site-url blog-prefix rss-name recent-posts sass-dest keep-files ignored-files previews?
author-root-uri theme debug? page-model page-root-uri ] author-root-uri theme debug? page-model page-root-uri]
:as config} (read-config) :as config} (read-config)
posts (map klipsify (add-prev-next (read-posts config))) posts (map klipsify (add-prev-next (read-posts config)))
posts-by-tag (group-by-tags posts) posts-by-tag (group-by-tags posts)
@ -500,8 +500,7 @@
klipsified-pages (map klipsify (read-pages config)) klipsified-pages (map klipsify (read-pages config))
modelled-pages (cond modelled-pages (cond
(= page-model :flat) klipsified-pages (= page-model :flat) klipsified-pages
(= page-model :hierarchic) (hierarchic/build-hierarchic-map page-root-uri klipsified-pages) (= page-model :hierarchic) (hierarchic/build-hierarchic-map page-root-uri klipsified-pages))
)
home-page (->> modelled-pages home-page (->> modelled-pages
(filter #(boolean (:home? %))) (filter #(boolean (:home? %)))
(first)) (first))
@ -522,16 +521,19 @@
:index-uri (page-uri "index.html" config) :index-uri (page-uri "index.html" config)
:tags-uri (page-uri "tags.html" config) :tags-uri (page-uri "tags.html" config)
:rss-uri (cryogen-io/path "/" blog-prefix rss-name) :rss-uri (cryogen-io/path "/" blog-prefix rss-name)
:site-url (if (.endsWith site-url "/") (.substring site-url 0 (dec (count site-url))) site-url)})] :site-url (if (.endsWith site-url "/") (.substring site-url 0 (dec (count site-url))) site-url)})
file-resource-path (str "file:resources/templates/themes/" theme)
classpath-resource-path (str "templates/themes/" theme)]
(when debug? (when debug?
(println (blue "debug: page-model:")) (println (blue "debug: page-model:"))
(println "\t-->" (cyan page-model)) (println "\t-->" (cyan page-model))
(println (blue "debug: home-page:")) (println (blue "debug: home-page:"))
(println "\t-->" (cyan (-> params :home-page))) (println "\t-->" (cyan (-> params :home-page))))
) ;; TODO: replace by file-resource-path or classpath-resource-path
(set-custom-resource-path! (str "file:resources/templates/themes/" theme)) (set-custom-resource-path! (str "file:resources/templates/themes/" theme))
(cryogen-io/wipe-public-folder keep-files) (cryogen-io/wipe-public-folder keep-files)
(println (blue "copying theme resources")) (println (blue "copying theme resources"))
;; TODO: adjust for reading from jar
(cryogen-io/copy-resources-from-theme config) (cryogen-io/copy-resources-from-theme config)
(println (blue "copying resources")) (println (blue "copying resources"))
(cryogen-io/copy-resources config) (cryogen-io/copy-resources config)

View file

View file

@ -0,0 +1,22 @@
(ns cryogen-core.classpath-able-io-test
(:require [clojure.test :refer :all]
[clojure.string :as s]
[clojure.java.io :as io]
[cryogen-core.classpath-able-io :as sut]))
(def theme "bootstrap4-test")
(def target "target/tmp")
(defn verify-file-exists [path]
(.exists (io/file path)))
(defn verify-dir-exists [path]
(and (verify-file-exists path)
(.isDirectory (io/file path))))
(deftest test-copy-resources-from-theme
(is (do
(sut/copy-resources-from-theme theme target)
(and (verify-dir-exists (str target "/js"))
(verify-file-exists (str target "/js/dummy.js"))))))

View file

@ -21,12 +21,12 @@
([tag attrs & content] ([tag attrs & content]
{:tag tag, :attrs attrs, :content content})) {:tag tag, :attrs attrs, :content content}))
(deftest filter-html-elems-test ; (deftest filter-html-elems-test
(is (= [(elt :div {:class "x"} :content [(elt :div {:class "x"} "foo")]) ; (is (= [(elt :div {:class "x"} :content [(elt :div {:class "x"} "foo")])
(elt :div {:class "x"} "foo")]) ; (elt :div {:class "x"} "foo")])
(filter-html-elems (comp #{"x"} :class :attrs) ; (filter-html-elems (comp #{"x"} :class :attrs)
[(elt :h1 {:class "y"} "things!") ; [(elt :h1 {:class "y"} "things!")
(elt :div {:class "x"} (elt :div {:class "x"} "foo"))]))) ; (elt :div {:class "x"} (elt :div {:class "x"} "foo"))])))
(deftest code-block-classes-test (deftest code-block-classes-test
(is (= ["clojure" "ruby"] (is (= ["clojure" "ruby"]