Fix bug open statics

This commit is contained in:
Andros Fenollosa 2021-07-30 01:33:02 +02:00
parent 8707081966
commit 13ef07f0b4
11 changed files with 27 additions and 20 deletions

View File

@ -13,6 +13,8 @@
[cheshire "5.9.0"]
;; Date
[clj-time "0.15.2"]
;; Utils dirs
[me.raynes/fs "1.4.6"]
;; Parse RSS/Atom feeds
[remus "0.2.1"]
[org.slf4j/slf4j-log4j12 "1.7.25"]

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 155 KiB

View File

Before

Width:  |  Height:  |  Size: 115 KiB

After

Width:  |  Height:  |  Size: 115 KiB

View File

Before

Width:  |  Height:  |  Size: 155 KiB

After

Width:  |  Height:  |  Size: 155 KiB

View File

@ -28,11 +28,14 @@
<orderEntry type="library" name="Leiningen: commons-codec:1.11" level="project" />
<orderEntry type="library" name="Leiningen: commons-io:2.6" level="project" />
<orderEntry type="library" name="Leiningen: commons-logging:1.2" level="project" />
<orderEntry type="library" name="Leiningen: cpath-clj:0.1.2" level="project" />
<orderEntry type="library" name="Leiningen: hiccup:1.0.5" level="project" />
<orderEntry type="library" name="Leiningen: joda-time:2.10" level="project" />
<orderEntry type="library" name="Leiningen: json-html:0.4.4" level="project" />
<orderEntry type="library" name="Leiningen: log4j:1.2.12" level="project" />
<orderEntry type="library" name="Leiningen: me.raynes/fs:1.4.6" level="project" />
<orderEntry type="library" name="Leiningen: nrepl:0.6.0" level="project" />
<orderEntry type="library" name="Leiningen: org.apache.commons/commons-compress:1.8" level="project" />
<orderEntry type="library" name="Leiningen: org.apache.httpcomponents/httpasyncclient:4.1.4" level="project" />
<orderEntry type="library" name="Leiningen: org.apache.httpcomponents/httpclient-cache:4.5.10" level="project" />
<orderEntry type="library" name="Leiningen: org.apache.httpcomponents/httpclient:4.5.10" level="project" />
@ -43,10 +46,12 @@
<orderEntry type="library" name="Leiningen: org.clojure/core.specs.alpha:0.2.56" level="project" />
<orderEntry type="library" name="Leiningen: org.clojure/data.codec:0.1.0" level="project" />
<orderEntry type="library" name="Leiningen: org.clojure/data.xml:0.2.0-alpha6" level="project" />
<orderEntry type="library" name="Leiningen: org.clojure/java.classpath:0.2.2" level="project" />
<orderEntry type="library" name="Leiningen: org.clojure/spec.alpha:0.2.194" level="project" />
<orderEntry type="library" name="Leiningen: org.jdom/jdom2:2.0.6" level="project" />
<orderEntry type="library" name="Leiningen: org.slf4j/slf4j-api:1.7.25" level="project" />
<orderEntry type="library" name="Leiningen: org.slf4j/slf4j-log4j12:1.7.25" level="project" />
<orderEntry type="library" name="Leiningen: org.tukaani/xz:1.5" level="project" />
<orderEntry type="library" name="Leiningen: org.yaml/snakeyaml:1.5" level="project" />
<orderEntry type="library" name="Leiningen: potemkin:0.4.5" level="project" />
<orderEntry type="library" name="Leiningen: remus:0.2.1" level="project" />

View File

@ -1,33 +1,33 @@
(ns rsspaper.html
(:require
[clojure.java.io :as io]
[rsspaper.config :refer [config]]
[clojure.string :as str]
[selmer.parser :as s]))
[clojure.java.io :as io]
[rsspaper.config :refer [config]]
[clojure.string :as str]
[selmer.parser :as s]
[me.raynes.fs :as fs]
[me.raynes.fs.compression :as fsc]))
(defn copy-uri-to-file [uri file]
(with-open [in (io/input-stream uri)
out (io/output-stream file)]
(io/copy in out)))
(defn make-html
[articles]
;; Render html in dist/index.html
(let [dir-dist "dist/"
file-index "index.html"
path-theme (io/resource (str "themes/" (:theme config) "/"))
path-dist-index (str dir-dist "index.html")
]
zip-static "static.zip"
tmp-static "/tmp/rsspaper.zip"]
;; Remove old index.html
#_(when (.exists (io/file path-dist-index)) (io/delete-file path-dist-index))
(when (.exists (io/file path-dist-index)) (io/delete-file path-dist-index))
;; Make dir dist
#_(.mkdir (java.io.File. dir-dist))
(fs/mkdir dir-dist)
;; Make dist/index.html
#_(with-open [wrtr (io/writer path-dist-index)]
(.write wrtr (s/render-file (str path-theme "index.html") {:title (:title config)
:articles articles})))
(with-open [writer (io/writer path-dist-index)]
(.write writer (s/render-file (str path-theme file-index) {:title (:title config)})))
;; Make statics
;; Iterate statics
(doseq [file (.listFiles (io/file path-theme) )]
(let [path (.getPath file)
relative-path (second (str/split path #"resources/"))
relative-dist-path (str dir-dist relative-path)]
;; Remove old static
(when (.exists (io/file relative-dist-path)) (io/delete-file relative-dist-path))
;; Copy new static
(io/copy (io/file path) (io/file dir-dist))))))
(copy-uri-to-file (str path-theme zip-static) tmp-static)
(fsc/unzip tmp-static dir-dist)))