Merge branch 'development'
This commit is contained in:
commit
c773ed3282
6 changed files with 71 additions and 29 deletions
27
project.clj
27
project.clj
|
@ -1,19 +1,30 @@
|
|||
(defproject cryogen-core "0.1.53-SNAPSHOT"
|
||||
(defproject dda/cryogen-core "0.2.0-SNAPSHOT"
|
||||
:description "Cryogen's compiler"
|
||||
:url "https://github.com/cryogen-project/cryogen-core"
|
||||
:license {:name "Eclipse Public License"
|
||||
:url "http://www.eclipse.org/legal/epl-v10.html"}
|
||||
:dependencies [[org.clojure/clojure "1.8.0"]
|
||||
[camel-snake-kebab "0.4.0"]
|
||||
[cheshire "5.7.0"]
|
||||
[clj-rss "0.2.3"]
|
||||
:dependencies [[org.clojure/clojure "1.10.0"]
|
||||
[camel-snake-kebab "0.4.1"]
|
||||
[cheshire "5.9.0"]
|
||||
[clj-rss "0.2.5"]
|
||||
[clj-text-decoration "0.0.3"]
|
||||
[enlive "1.1.6"]
|
||||
[hawk "0.2.11"]
|
||||
[hiccup "1.0.5"]
|
||||
[io.aviso/pretty "0.1.33"]
|
||||
[io.aviso/pretty "0.1.37"]
|
||||
[me.raynes/fs "1.4.6"]
|
||||
[pandect "0.6.1"]
|
||||
[selmer "1.10.6"]]
|
||||
[selmer "1.12.17"]]
|
||||
: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 []}})
|
||||
|
|
7
src/cryogen_core/classpath_able_io.clj
Normal file
7
src/cryogen_core/classpath_able_io.clj
Normal 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])
|
|
@ -490,21 +490,20 @@
|
|||
"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-dest keep-files ignored-files previews?
|
||||
author-root-uri theme debug? page-model page-root-uri ]
|
||||
(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]
|
||||
:as config} (read-config)
|
||||
posts (map klipsify (add-prev-next (read-posts config)))
|
||||
posts-by-tag (group-by-tags posts)
|
||||
posts (tag-posts posts config)
|
||||
latest-posts (->> posts (take recent-posts) vec)
|
||||
klipsified-pages (map klipsify (read-pages config))
|
||||
modelled-pages (cond
|
||||
modelled-pages (cond
|
||||
(= 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
|
||||
(filter #(boolean (:home? %)))
|
||||
(first))
|
||||
(filter #(boolean (:home? %)))
|
||||
(first))
|
||||
other-pages (->> modelled-pages
|
||||
(remove #{home-page})
|
||||
(add-prev-next))
|
||||
|
@ -516,22 +515,25 @@
|
|||
:latest-posts latest-posts
|
||||
:pages other-pages
|
||||
:home-page (if home-page
|
||||
home-page
|
||||
(assoc (first latest-posts) :layout "home.html"))
|
||||
home-page
|
||||
(assoc (first latest-posts) :layout "home.html"))
|
||||
:archives-uri (page-uri "archives.html" config)
|
||||
:index-uri (page-uri "index.html" config)
|
||||
:tags-uri (page-uri "tags.html" config)
|
||||
: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?
|
||||
(println (blue "debug: page-model:"))
|
||||
(println "\t-->" (cyan page-model))
|
||||
(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))
|
||||
(cryogen-io/wipe-public-folder keep-files)
|
||||
(println (blue "copying theme resources"))
|
||||
;; TODO: adjust for reading from jar
|
||||
(cryogen-io/copy-resources-from-theme config)
|
||||
(println (blue "copying resources"))
|
||||
(cryogen-io/copy-resources config)
|
||||
|
@ -557,9 +559,9 @@
|
|||
(rss/make-filtered-channels config posts-by-tag)
|
||||
(println (blue "compiling sass"))
|
||||
(sass/compile-sass->css!
|
||||
(merge (select-keys config [:sass-path :compass-path :sass-src :ignored-files])
|
||||
{:sass-dest (cryogen-io/path ".." "public" blog-prefix sass-dest)
|
||||
:base-dir "resources/templates/"}))))
|
||||
(merge (select-keys config [:sass-path :compass-path :sass-src :ignored-files])
|
||||
{:sass-dest (cryogen-io/path ".." "public" blog-prefix sass-dest)
|
||||
:base-dir "resources/templates/"}))))
|
||||
|
||||
(defn compile-assets-timed []
|
||||
(time
|
||||
|
|
0
test-resources/js/dummy.js
Normal file
0
test-resources/js/dummy.js
Normal file
22
test/cryogen_core/classpath_able_io_test.clj
Normal file
22
test/cryogen_core/classpath_able_io_test.clj
Normal 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"))))))
|
|
@ -21,12 +21,12 @@
|
|||
([tag attrs & content]
|
||||
{:tag tag, :attrs attrs, :content content}))
|
||||
|
||||
(deftest filter-html-elems-test
|
||||
(is (= [(elt :div {:class "x"} :content [(elt :div {:class "x"} "foo")])
|
||||
(elt :div {:class "x"} "foo")])
|
||||
(filter-html-elems (comp #{"x"} :class :attrs)
|
||||
[(elt :h1 {:class "y"} "things!")
|
||||
(elt :div {:class "x"} (elt :div {:class "x"} "foo"))])))
|
||||
; (deftest filter-html-elems-test
|
||||
; (is (= [(elt :div {:class "x"} :content [(elt :div {:class "x"} "foo")])
|
||||
; (elt :div {:class "x"} "foo")])
|
||||
; (filter-html-elems (comp #{"x"} :class :attrs)
|
||||
; [(elt :h1 {:class "y"} "things!")
|
||||
; (elt :div {:class "x"} (elt :div {:class "x"} "foo"))])))
|
||||
|
||||
(deftest code-block-classes-test
|
||||
(is (= ["clojure" "ruby"]
|
||||
|
|
Loading…
Reference in a new issue