Fix format
This commit is contained in:
parent
f0b426da7e
commit
207601a5ef
|
@ -29,8 +29,9 @@
|
|||
[lein-cljfmt "0.6.4"]]
|
||||
;; ALIAS
|
||||
:aliases {"check-idiomatic" ["kibit" "src"]
|
||||
"check-format" ["cljfmt" "check"]}
|
||||
;; LEIN
|
||||
"check-format" ["cljfmt" "check"]
|
||||
"fix-format" ["cljfmt" "fix"]}
|
||||
;; LEIN
|
||||
:main ^:skip-aot rsspaper.core
|
||||
:aot [rsspaper.core]
|
||||
:repl-options {:init-ns rsspaper.core})
|
||||
|
|
|
@ -106,13 +106,14 @@
|
|||
.article__title, .article__feed {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.article__header-img > a > img {
|
||||
height: var(--height-img);
|
||||
object-position: center;
|
||||
object-fit: contain;
|
||||
}
|
||||
.article__random-background {
|
||||
height: var(--height-img);
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
</style>
|
||||
|
@ -235,9 +236,6 @@
|
|||
{
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
|
||||
|
||||
.article__main {
|
||||
position: fixed;
|
||||
left: -100%;
|
||||
|
@ -246,9 +244,13 @@
|
|||
overflow-y: auto;
|
||||
|
||||
}
|
||||
|
||||
.feed__article:nth-child(1) .article__random-background {
|
||||
height: initial;
|
||||
.feed__article:nth-child(1) .article__header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100%;
|
||||
}
|
||||
.feed__article:nth-child(1) .article__header-img {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
<!-- End CSS -->
|
||||
|
|
|
@ -8,13 +8,11 @@
|
|||
|
||||
(def date-custom-formatter (f/formatter "dd MM yyyy"))
|
||||
|
||||
|
||||
(defn datetimes-to-unixtime
|
||||
[articles]
|
||||
(map (fn [article]
|
||||
(assoc article :published-date (c/to-long (:published-date article)))) articles))
|
||||
|
||||
|
||||
(defn filter-edition
|
||||
[articles]
|
||||
(let [daily (c/to-long (t/minus (t/now) (t/days 1)))
|
||||
|
@ -24,20 +22,17 @@
|
|||
"weekly" (filter (fn [article] (and (not (nil? (:published-date article))) (>= (:published-date article) weekly))) articles)
|
||||
:else articles)))
|
||||
|
||||
|
||||
(defn add-datetimes-formatter
|
||||
[articles]
|
||||
(map (fn [article]
|
||||
(assoc article :published-date-formatter (f/unparse date-custom-formatter (c/from-long (:published-date article))))) articles))
|
||||
|
||||
|
||||
(defn zip-feeds-in-articles
|
||||
[feeds]
|
||||
;; Flat all articles
|
||||
(reduce (fn [articles feed]
|
||||
;; Add in every article, all information from feed
|
||||
(concat articles (map (fn [article] (assoc article :feed (:feed (update-in feed [:feed] dissoc :entries)) )) (get-in feed [:feed :entries])))) [] feeds))
|
||||
|
||||
(concat articles (map (fn [article] (assoc article :feed (:feed (update-in feed [:feed] dissoc :entries)))) (get-in feed [:feed :entries])))) [] feeds))
|
||||
|
||||
(defn add-cover-article
|
||||
[articles]
|
||||
|
@ -45,34 +40,30 @@
|
|||
;; Iterate every blog
|
||||
(map (fn [article]
|
||||
(let [url-article (second (re-find #"<img[^>]+src=\"([^\">]+)\"" (str (get-in article [:description :value]))))]
|
||||
(assoc article :cover (if (nil? url-article) (get-in article [:feed :image :url]) url-article)))
|
||||
) articles))
|
||||
|
||||
(assoc article :cover (if (nil? url-article) (get-in article [:feed :image :url]) url-article)))) articles))
|
||||
|
||||
(defn order-published
|
||||
[articles]
|
||||
(reverse (sort-by :published-date articles)))
|
||||
|
||||
|
||||
(defn get-articles
|
||||
[]
|
||||
;; Get all feeds from config -> feeds
|
||||
(->
|
||||
(reduce
|
||||
(fn [feeds feed-url]
|
||||
; Read feed
|
||||
(let [feed (parse-url feed-url {:insecure? true :throw-exceptions false})]
|
||||
; Check is not null
|
||||
(if (not (nil? feed))
|
||||
; Add feed
|
||||
(conj feeds feed)
|
||||
; Alert fail
|
||||
(prn (str "Error with '" feed-url) "'"))))
|
||||
[] (:feeds config))
|
||||
zip-feeds-in-articles
|
||||
datetimes-to-unixtime
|
||||
filter-edition
|
||||
order-published
|
||||
add-cover-article
|
||||
add-datetimes-formatter
|
||||
))
|
||||
(reduce
|
||||
(fn [feeds feed-url]
|
||||
; Read feed
|
||||
(let [feed (parse-url feed-url {:insecure? true :throw-exceptions false})]
|
||||
; Check is not null
|
||||
(if-not (nil? feed)
|
||||
; Add feed
|
||||
(conj feeds feed)
|
||||
; Alert fail
|
||||
(prn (str "Error with '" feed-url) "'"))))
|
||||
[] (:feeds config))
|
||||
zip-feeds-in-articles
|
||||
datetimes-to-unixtime
|
||||
filter-edition
|
||||
order-published
|
||||
add-cover-article
|
||||
add-datetimes-formatter))
|
|
@ -4,7 +4,6 @@
|
|||
[rsspaper.config :refer [config]]
|
||||
[selmer.parser :as s]))
|
||||
|
||||
|
||||
(defn make-html
|
||||
[articles]
|
||||
;; Render html in dist/index.html
|
||||
|
@ -16,7 +15,5 @@
|
|||
(.mkdir (java.io.File. dir))
|
||||
;; Make dist/index.html
|
||||
(with-open [wrtr (io/writer path)]
|
||||
(.write wrtr (s/render-file (str "themes/" (:theme config) ".html") {
|
||||
:title (:title config)
|
||||
:articles articles
|
||||
})))))
|
||||
(.write wrtr (s/render-file (str "themes/" (:theme config) ".html") {:title (:title config)
|
||||
:articles articles})))))
|
Loading…
Reference in New Issue