Skip to content

Commit

Permalink
Merge pull request cryogen-project#28 from dl1ely/master
Browse files Browse the repository at this point in the history
Allows for keeping files in public dir when generating
  • Loading branch information
yogthos committed Nov 28, 2014
2 parents 7ad2070 + 12c94eb commit d7def51
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ The site configuration file is found at `templates/config.edn`, this file looks
:sass-src nil
:sass-dest nil
:resources ["css" "js" "img"]
:keep-files [".git"]
:disqus? false
:disqus-shortname ""}
```
Expand All @@ -78,6 +79,7 @@ The site configuration file is found at `templates/config.edn`, this file looks
into. defaults to "css" - be sure to include this directory in
your `resources` section
* `resources` - list of folders to be copied over from `templates` to `public`
* `keep-files` - list of folders or files that are not wiped in the `public` directory. For example, this allows to keep a `.git` directory there across recompiles of the site to versionize the generated files
* `disqus?` - set to true if you want disqus enabled on your site
* `disqus-shortname` - your disqus shortname

Expand Down Expand Up @@ -187,6 +189,7 @@ folder for a server sugh as Nginx or Apache and your site is now ready for servi
* [My personal blog](http://carmenla.me/blog/index.html)
* [Yogthos blog](http://yogthos.net/)
* [Clojure :in Tunisia](http://www.clojure.tn)
* [dl1ely.github.io](http://dl1ely.github.io)

## License

Expand Down
1 change: 1 addition & 0 deletions src/leiningen/new/cryogen/config.edn
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@
:sass-src nil
:sass-dest nil
:resources ["css" "js"]
:keep-files [".git"]
:disqus? false
:disqus-shortname ""}
2 changes: 2 additions & 0 deletions src/leiningen/new/cryogen/md/posts/13-11-2014-docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ The site configuration file is found at `templates/config.edn`, this file looks
:sass-src nil
:sass-dest nil
:resources ["css" "js" "img"]
:keep-files [".git"]
:disqus? false
:disqus-shortname ""}
```
Expand All @@ -75,6 +76,7 @@ The site configuration file is found at `templates/config.edn`, this file looks
into. defaults to "css" - be sure to include this directory in
your `resources` section
* `resources` - list of folders to be copied over from `templates` to `public`
* `keep-files` - list of folders or files that are not wiped in the `public` directory. For example, this allows to keep a `.git` directory there across recompiles of the site to versionize the generated files
* `disqus?` - set to true if you want disqus enabled on your site
* `disqus-shortname` - your disqus shortname

Expand Down
7 changes: 4 additions & 3 deletions src/leiningen/new/cryogen/src/cryogen/compiler.clj
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@
(update-in [:rss-name] (fnil str "rss.xml"))
(update-in [:sass-src] (fnil str "css"))
(update-in [:sass-dest] (fnil str "css"))
(update-in [:post-date-format] (fnil str "yyyy-MM-dd")))]
(update-in [:post-date-format] (fnil str "yyyy-MM-dd"))
(update-in [:keep-files] (fnil seq [])))]
(merge
config
{:page-root (root-path :page-root config)
Expand All @@ -197,7 +198,7 @@

(defn compile-assets []
(println (green "compiling assets..."))
(let [{:keys [site-url blog-prefix rss-name recent-posts sass-src sass-dest] :as config} (read-config)
(let [{:keys [site-url blog-prefix rss-name recent-posts sass-src sass-dest keep-files] :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)
Expand All @@ -212,7 +213,7 @@
:index-uri (str blog-prefix "/index.html")
:rss-uri (str blog-prefix "/" rss-name)}]

(wipe-public-folder)
(wipe-public-folder keep-files)
(println (blue "copying resources"))
(copy-resources config)
(compile-pages default-params pages config)
Expand Down
7 changes: 4 additions & 3 deletions src/leiningen/new/cryogen/src/cryogen/io.clj
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@
(when-not (.exists loc)
(.mkdirs loc))))

(defn wipe-public-folder []
(doseq [path (.listFiles (file public))]
(fs/delete-dir path)))
(defn wipe-public-folder [keep-files]
(let [filenamefilter (reify java.io.FilenameFilter (accept [this _ filename] (not (some #{filename} keep-files))))]
(doseq [path (.listFiles (file public) filenamefilter)]
(fs/delete-dir path))))

(defn copy-resources [{:keys [blog-prefix resources]}]
(doseq [resource resources]
Expand Down

0 comments on commit d7def51

Please sign in to comment.