added ability to select one page as home-page (add :home? true as meta)
instead of newest post.
This commit is contained in:
parent
e3d2d3f433
commit
60b395e047
3 changed files with 30 additions and 12 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -10,3 +10,4 @@ pom.xml.asc
|
||||||
.DS*
|
.DS*
|
||||||
/.idea/
|
/.idea/
|
||||||
/cryogen-core.iml
|
/cryogen-core.iml
|
||||||
|
/bin/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
(defproject cryogen-core "0.1.46"
|
(defproject org.domaindrivenarchitecture/cryogen-core "0.1.47-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"
|
||||||
|
@ -14,4 +14,6 @@
|
||||||
[selmer "1.10.2"]
|
[selmer "1.10.2"]
|
||||||
[pandect "0.6.1"]
|
[pandect "0.6.1"]
|
||||||
[hawk "0.2.11"]
|
[hawk "0.2.11"]
|
||||||
[clj-tagsoup "0.3.0" :exclusions [org.clojure/clojure]]])
|
[clj-tagsoup "0.3.0" :exclusions [org.clojure/clojure]]]
|
||||||
|
:deploy-repositories [["snapshots" :clojars]
|
||||||
|
["releases" :clojars]])
|
||||||
|
|
|
@ -231,11 +231,13 @@
|
||||||
(create-folder (path "/" blog-prefix page-root-uri))
|
(create-folder (path "/" blog-prefix page-root-uri))
|
||||||
(doseq [{:keys [uri] :as page} pages]
|
(doseq [{:keys [uri] :as page} pages]
|
||||||
(println "\t-->" (cyan uri))
|
(println "\t-->" (cyan uri))
|
||||||
|
(println "\t-->" (cyan page))
|
||||||
(write-html uri
|
(write-html uri
|
||||||
params
|
params
|
||||||
(render-file (str "/html/" (:layout page))
|
(render-file (str "/html/" (:layout page))
|
||||||
(merge params
|
(merge params
|
||||||
{:active-page "pages"
|
{:active-page "pages"
|
||||||
|
:home false
|
||||||
:servlet-context (path "/" blog-prefix "/")
|
:servlet-context (path "/" blog-prefix "/")
|
||||||
:page page
|
:page page
|
||||||
:uri uri}))))))
|
:uri uri}))))))
|
||||||
|
@ -248,6 +250,7 @@
|
||||||
(create-folder (path "/" blog-prefix post-root-uri))
|
(create-folder (path "/" blog-prefix post-root-uri))
|
||||||
(doseq [post posts]
|
(doseq [post posts]
|
||||||
(println "\t-->" (cyan (:uri post)))
|
(println "\t-->" (cyan (:uri post)))
|
||||||
|
(println "\t-->" (cyan post))
|
||||||
(write-html (:uri post)
|
(write-html (:uri post)
|
||||||
params
|
params
|
||||||
(render-file (str "/html/" (:layout post))
|
(render-file (str "/html/" (:layout post))
|
||||||
|
@ -350,16 +353,21 @@
|
||||||
"Compiles the index page into html and spits it out into the public folder"
|
"Compiles the index page into html and spits it out into the public folder"
|
||||||
[{:keys [disqus?] :as params}]
|
[{:keys [disqus?] :as params}]
|
||||||
(println (blue "compiling index"))
|
(println (blue "compiling index"))
|
||||||
(let [uri (page-uri "index.html" params)]
|
(let [uri (page-uri "index.html" params)
|
||||||
(write-html uri
|
home-page (-> params :home-page)
|
||||||
params
|
meta {:active-page "home"
|
||||||
(render-file "/html/home.html"
|
|
||||||
(merge params
|
|
||||||
{:active-page "home"
|
|
||||||
:home true
|
:home true
|
||||||
:disqus? disqus?
|
:disqus? disqus?
|
||||||
:post (get-in params [:latest-posts 0])
|
:uri uri
|
||||||
:uri uri})))))
|
:post home-page
|
||||||
|
:page home-page}]
|
||||||
|
(println "\t-->" (cyan meta))
|
||||||
|
(println "\t-->" (cyan (first (-> params :latest-posts))))
|
||||||
|
(write-html uri
|
||||||
|
params
|
||||||
|
(render-file (str "/html/" (:layout home-page))
|
||||||
|
(merge params
|
||||||
|
meta)))))
|
||||||
|
|
||||||
(defn compile-archives
|
(defn compile-archives
|
||||||
"Compiles the archives page into html and spits it out into the public folder"
|
"Compiles the archives page into html and spits it out into the public folder"
|
||||||
|
@ -455,17 +463,24 @@
|
||||||
(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)
|
(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))
|
posts (add-prev-next (read-posts config))
|
||||||
pages (add-prev-next (read-pages config))
|
pages (add-prev-next (read-pages config))
|
||||||
[navbar-pages sidebar-pages] (group-pages pages)
|
home-pages (filter #(boolean (:home? %)) pages)
|
||||||
|
pages-without-home (filter #(boolean (not (:home? %))) pages)
|
||||||
|
[navbar-pages sidebar-pages] (group-pages pages-without-home)
|
||||||
posts-by-tag (group-by-tags posts)
|
posts-by-tag (group-by-tags posts)
|
||||||
posts (tag-posts posts config)
|
posts (tag-posts posts config)
|
||||||
|
latest-posts (->> posts (take recent-posts) vec)
|
||||||
params (merge config
|
params (merge config
|
||||||
{:today (java.util.Date.)
|
{:today (java.util.Date.)
|
||||||
:title (:site-title config)
|
:title (:site-title config)
|
||||||
:active-page "home"
|
:active-page "home"
|
||||||
:tags (map (partial tag-info config) (keys posts-by-tag))
|
:tags (map (partial tag-info config) (keys posts-by-tag))
|
||||||
:latest-posts (->> posts (take recent-posts) vec)
|
:latest-posts latest-posts
|
||||||
:navbar-pages navbar-pages
|
:navbar-pages navbar-pages
|
||||||
:sidebar-pages sidebar-pages
|
:sidebar-pages sidebar-pages
|
||||||
|
:home-page (if (not-empty home-pages)
|
||||||
|
(first home-pages)
|
||||||
|
(merge (first latest-posts)
|
||||||
|
{:layout "home.html"}))
|
||||||
:archives-uri (page-uri "archives.html" config)
|
:archives-uri (page-uri "archives.html" config)
|
||||||
: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)
|
||||||
|
@ -480,7 +495,7 @@
|
||||||
(println (blue "copying resources"))
|
(println (blue "copying resources"))
|
||||||
(copy-resources config)
|
(copy-resources config)
|
||||||
(copy-resources-from-markup-folders config)
|
(copy-resources-from-markup-folders config)
|
||||||
(compile-pages params pages)
|
(compile-pages params pages-without-home)
|
||||||
(compile-posts params posts)
|
(compile-posts params posts)
|
||||||
(compile-tags params posts-by-tag)
|
(compile-tags params posts-by-tag)
|
||||||
(compile-tags-page params)
|
(compile-tags-page params)
|
||||||
|
|
Loading…
Reference in a new issue