Skip to content

Commit

Permalink
(closes #118) relax config schema
Browse files Browse the repository at this point in the history
  • Loading branch information
lacarmen committed Jun 15, 2019
1 parent 234170d commit f87a528
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 26 deletions.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject cryogen-core "0.2.0"
(defproject cryogen-core "0.2.1"
:description "Cryogen's compiler"
:url "https://github.com/cryogen-project/cryogen-core"
:license {:name "Eclipse Public License"
Expand Down
18 changes: 8 additions & 10 deletions src/cryogen_core/compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@
(let [date (if (:date page-meta)
(.parse (java.text.SimpleDateFormat. (:post-date-format config)) (:date page-meta))
(parse-post-date file-name (:post-date-format config)))
archive-fmt (java.text.SimpleDateFormat. (:archive-group-format config "yyyy MMMM") (Locale/getDefault))
archive-fmt (java.text.SimpleDateFormat. (:archive-group-format config) (Locale/getDefault))
formatted-group (.format archive-fmt date)]
{:date date
:formatted-archive-group formatted-group
Expand Down Expand Up @@ -268,7 +268,7 @@

(defn compile-posts
"Compiles all the posts into html and spits them out into the public folder"
[{:keys [blog-prefix post-root-uri disqus-shortname debug?] :as params} posts]
[{:keys [blog-prefix post-root-uri debug?] :as params} posts]
(when-not (empty? posts)
(println (blue "compiling posts"))
(cryogen-io/create-folder (cryogen-io/path "/" blog-prefix post-root-uri))
Expand All @@ -280,11 +280,10 @@
params
(render-file (str "/html/" (:layout post))
(merge params
{:active-page "posts"
:selmer/context (cryogen-io/path "/" blog-prefix "/")
:post post
:disqus-shortname disqus-shortname
:uri uri}))))))
{:active-page "posts"
:selmer/context (cryogen-io/path "/" blog-prefix "/")
:post post
:uri uri}))))))

(defn compile-tags
"Compiles all the tag pages into html and spits them out into the public folder"
Expand Down Expand Up @@ -383,7 +382,7 @@

(defn compile-index
"Compiles the index page into html and spits it out into the public folder"
[{:keys [blog-prefix disqus? debug? home-page] :as params}]
[{:keys [blog-prefix debug? home-page] :as params}]
(println (blue "compiling index"))
(let [uri (page-uri "index.html" params)]
(when debug?
Expand All @@ -394,7 +393,6 @@
(merge params
{:active-page "home"
:home true
:disqus? disqus?
:selmer/context (cryogen-io/path "/" blog-prefix "/")
:uri uri
:post home-page
Expand Down Expand Up @@ -530,7 +528,7 @@
(println (blue "generating main rss"))
(->> (rss/make-channel config posts)
(cryogen-io/create-file (cryogen-io/path "/" blog-prefix rss-name)))
(println (blue "generating filtered rss"))
(if (:rss-filters config) (println (blue "generating filtered rss")))
(rss/make-filtered-channels config posts-by-tag))))

(defn compile-assets-timed
Expand Down
6 changes: 5 additions & 1 deletion src/cryogen_core/config.clj
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,14 @@
(s/validate schemas/Config config)
(let [config (-> config
(update-in [:tag-root-uri] (fnil identity ""))
(update-in [:public-dest] (fnil identity "public"))
(update-in [:recent-posts] (fnil identity 3))
(update-in [:archive-group-format] (fnil identity "yyyy MMMM"))
(update-in [:sass-src] (fnil identity ["css"]))
(update-in [:sass-path] (fnil identity "sass"))
(update-in [:compass-path] (fnil identity "compass"))
(update-in [:public-dest] (fnil identity "public"))
(update-in [:posts-per-page] (fnil identity 5))
(update-in [:blocks-per-preview] (fnil identity 2))
(assoc :page-root-uri (root-uri :page-root-uri config)
:post-root-uri (root-uri :post-root-uri config)))
check-overlap (fn [dirs]
Expand Down
9 changes: 4 additions & 5 deletions src/cryogen_core/io.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@
(string/join "/")
(#(string/replace % #"/+" "/"))))

(defn re-filter [bool-fn re & other-res]
(let [res (conj other-res re)]
(reify java.io.FilenameFilter
(accept [this _ name]
(bool-fn (some #(re-find % name) res))))))
(defn re-filter [bool-fn & res]
(reify java.io.FilenameFilter
(accept [this _ name]
(bool-fn (some #(re-find % name) res)))))

(def match-re-filter (partial re-filter some?))
(def reject-re-filter (partial re-filter nil?))
Expand Down
19 changes: 10 additions & 9 deletions src/cryogen_core/schemas.clj
Original file line number Diff line number Diff line change
Expand Up @@ -36,29 +36,30 @@
(s/optional-key :page-root-uri) (s/maybe s/Str)
(s/optional-key :tag-root-uri) s/Str
(s/optional-key :author-root-uri) s/Str
(s/optional-key :public-dest) s/Str
:blog-prefix s/Str
:rss-name s/Str
:rss-filters [s/Str]
:recent-posts s/Int
(s/optional-key :rss-filters) [s/Str]
(s/optional-key :recent-posts) s/Int
:post-date-format s/Str
(s/optional-key :archive-group-format) s/Str
(s/optional-key :sass-src) [s/Str]
(s/optional-key :sass-path) s/Str
(s/optional-key :compass-path) s/Str
:theme s/Str
:resources [s/Str]
:keep-files [s/Str]
:disqus? s/Bool
(s/optional-key :resources) [s/Str]
(s/optional-key :keep-files) [s/Str]
(s/optional-key :disqus?) s/Bool
(s/optional-key :disqus-shortname) s/Str
:ignored-files [s/Regex]
:previews? s/Bool
(s/optional-key :ignored-files) [s/Regex]
(s/optional-key :previews?) s/Bool
(s/optional-key :posts-per-page) s/Int
(s/optional-key :blocks-per-preview) s/Int
:clean-urls (s/enum :trailing-slash
:no-trailing-slash
:dirty)
(s/optional-key :collapse-subdirs?) s/Bool
:hide-future-posts? s/Bool
(s/optional-key :hide-future-posts?) s/Bool
(s/optional-key :klipse) Klipse
:debug? s/Bool
(s/optional-key :debug?) s/Bool
s/Keyword s/Any})

0 comments on commit f87a528

Please sign in to comment.