Fix format

This commit is contained in:
Andros Fenollosa 2021-07-18 13:12:59 +02:00
parent f0b426da7e
commit 207601a5ef
4 changed files with 33 additions and 42 deletions

View File

@ -29,8 +29,9 @@
[lein-cljfmt "0.6.4"]] [lein-cljfmt "0.6.4"]]
;; ALIAS ;; ALIAS
:aliases {"check-idiomatic" ["kibit" "src"] :aliases {"check-idiomatic" ["kibit" "src"]
"check-format" ["cljfmt" "check"]} "check-format" ["cljfmt" "check"]
;; LEIN "fix-format" ["cljfmt" "fix"]}
;; LEIN
:main ^:skip-aot rsspaper.core :main ^:skip-aot rsspaper.core
:aot [rsspaper.core] :aot [rsspaper.core]
:repl-options {:init-ns rsspaper.core}) :repl-options {:init-ns rsspaper.core})

View File

@ -106,13 +106,14 @@
.article__title, .article__feed { .article__title, .article__feed {
font-weight: normal; font-weight: normal;
} }
.article__header-img > a > img { .article__header-img > a > img {
height: var(--height-img); height: var(--height-img);
object-position: center; object-position: center;
object-fit: contain; object-fit: contain;
} }
.article__random-background { .article__random-background {
height: var(--height-img); height: 100%;
width: 100%; width: 100%;
} }
</style> </style>
@ -235,9 +236,6 @@
{ {
font-size: 1rem; font-size: 1rem;
} }
.article__main { .article__main {
position: fixed; position: fixed;
left: -100%; left: -100%;
@ -246,9 +244,13 @@
overflow-y: auto; overflow-y: auto;
} }
.feed__article:nth-child(1) .article__header {
.feed__article:nth-child(1) .article__random-background { display: flex;
height: initial; flex-direction: column;
height: 100%;
}
.feed__article:nth-child(1) .article__header-img {
height: 100%;
} }
</style> </style>
<!-- End CSS --> <!-- End CSS -->

View File

@ -8,13 +8,11 @@
(def date-custom-formatter (f/formatter "dd MM yyyy")) (def date-custom-formatter (f/formatter "dd MM yyyy"))
(defn datetimes-to-unixtime (defn datetimes-to-unixtime
[articles] [articles]
(map (fn [article] (map (fn [article]
(assoc article :published-date (c/to-long (:published-date article)))) articles)) (assoc article :published-date (c/to-long (:published-date article)))) articles))
(defn filter-edition (defn filter-edition
[articles] [articles]
(let [daily (c/to-long (t/minus (t/now) (t/days 1))) (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) "weekly" (filter (fn [article] (and (not (nil? (:published-date article))) (>= (:published-date article) weekly))) articles)
:else articles))) :else articles)))
(defn add-datetimes-formatter (defn add-datetimes-formatter
[articles] [articles]
(map (fn [article] (map (fn [article]
(assoc article :published-date-formatter (f/unparse date-custom-formatter (c/from-long (:published-date article))))) articles)) (assoc article :published-date-formatter (f/unparse date-custom-formatter (c/from-long (:published-date article))))) articles))
(defn zip-feeds-in-articles (defn zip-feeds-in-articles
[feeds] [feeds]
;; Flat all articles ;; Flat all articles
(reduce (fn [articles feed] (reduce (fn [articles feed]
;; Add in every article, all information from 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 (defn add-cover-article
[articles] [articles]
@ -45,15 +40,12 @@
;; Iterate every blog ;; Iterate every blog
(map (fn [article] (map (fn [article]
(let [url-article (second (re-find #"<img[^>]+src=\"([^\">]+)\"" (str (get-in article [:description :value]))))] (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))) (assoc article :cover (if (nil? url-article) (get-in article [:feed :image :url]) url-article)))) articles))
) articles))
(defn order-published (defn order-published
[articles] [articles]
(reverse (sort-by :published-date articles))) (reverse (sort-by :published-date articles)))
(defn get-articles (defn get-articles
[] []
;; Get all feeds from config -> feeds ;; Get all feeds from config -> feeds
@ -63,7 +55,7 @@
; Read feed ; Read feed
(let [feed (parse-url feed-url {:insecure? true :throw-exceptions false})] (let [feed (parse-url feed-url {:insecure? true :throw-exceptions false})]
; Check is not null ; Check is not null
(if (not (nil? feed)) (if-not (nil? feed)
; Add feed ; Add feed
(conj feeds feed) (conj feeds feed)
; Alert fail ; Alert fail
@ -74,5 +66,4 @@
filter-edition filter-edition
order-published order-published
add-cover-article add-cover-article
add-datetimes-formatter add-datetimes-formatter))
))

View File

@ -4,7 +4,6 @@
[rsspaper.config :refer [config]] [rsspaper.config :refer [config]]
[selmer.parser :as s])) [selmer.parser :as s]))
(defn make-html (defn make-html
[articles] [articles]
;; Render html in dist/index.html ;; Render html in dist/index.html
@ -16,7 +15,5 @@
(.mkdir (java.io.File. dir)) (.mkdir (java.io.File. dir))
;; Make dist/index.html ;; Make dist/index.html
(with-open [wrtr (io/writer path)] (with-open [wrtr (io/writer path)]
(.write wrtr (s/render-file (str "themes/" (:theme config) ".html") { (.write wrtr (s/render-file (str "themes/" (:theme config) ".html") {:title (:title config)
:title (:title config) :articles articles})))))
:articles articles
})))))