Add date
This commit is contained in:
parent
ff9b65a101
commit
34e59753cb
|
@ -11,6 +11,8 @@
|
|||
[clj-yaml "0.4.0"]
|
||||
;; JSON encoding
|
||||
[cheshire "5.9.0"]
|
||||
;; Date
|
||||
[clj-time "0.15.2"]
|
||||
;; Parse RSS/Atom feeds
|
||||
[remus "0.2.1"]
|
||||
;; Make RSS/Atom feeds
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
/* Global */
|
||||
:root {
|
||||
--color-black: black;
|
||||
--color-gray: gray;
|
||||
}
|
||||
body {
|
||||
margin: 0;
|
||||
|
@ -142,6 +143,11 @@
|
|||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.article__date {
|
||||
font-size: .9rem;
|
||||
color: var(--color-gray);
|
||||
}
|
||||
|
||||
.feed__article:nth-child(1) .article__title {
|
||||
font-size: 2rem;
|
||||
}
|
||||
|
@ -243,7 +249,7 @@
|
|||
{% endif %}
|
||||
<div class="article__titles">
|
||||
<h1 class="article__title">{{ article.title }}</h1>
|
||||
<h2 class="article__feed">{{ item.feed.title }}</h2>
|
||||
<h2 class="article__feed">{{ item.feed.title }} <span class="article__date">{{ article.published-date-formatter }}</span></h2>
|
||||
</div>
|
||||
</header>
|
||||
<main class="container article__main">
|
||||
|
|
|
@ -1,9 +1,39 @@
|
|||
(ns rsspaper.feeds
|
||||
(:require
|
||||
[rsspaper.config :refer [config]]
|
||||
[clj-time.coerce :as c]
|
||||
[clj-time.format :as f]
|
||||
[remus :refer [parse-url]]))
|
||||
|
||||
(def date-custom-formatter (f/formatter "dd MM yyyy"))
|
||||
|
||||
(defn datetimes-to-unixtime
|
||||
[data]
|
||||
(map (fn [blog]
|
||||
(assoc-in blog [:feed :entries]
|
||||
(map (fn [article]
|
||||
(assoc article :published-date (c/to-long (:published-date article))))
|
||||
(get-in blog [:feed :entries])))) data))
|
||||
|
||||
|
||||
(defn add-datetimes-formatter
|
||||
[data]
|
||||
(map (fn [blog]
|
||||
(assoc-in blog [:feed :entries]
|
||||
(map (fn [article]
|
||||
(assoc article :published-date-formatter (f/unparse date-custom-formatter (c/from-long (:published-date article)))))
|
||||
(get-in blog [:feed :entries])))) data))
|
||||
|
||||
|
||||
(defn get-feeds
|
||||
[]
|
||||
;; Get all feeds from config -> feeds
|
||||
(reduce (fn [feeds feed-url] (conj feeds (parse-url feed-url {:insecure? true :throw-exceptions false}))) [] (:feeds config)))
|
||||
(->
|
||||
(reduce
|
||||
(fn [feeds feed-url]
|
||||
(conj feeds
|
||||
(parse-url feed-url {:insecure? true :throw-exceptions false}))
|
||||
) [] (:feeds config))
|
||||
datetimes-to-unixtime
|
||||
add-datetimes-formatter))
|
||||
|
||||
|
|
Loading…
Reference in New Issue