Remove futures
This commit is contained in:
parent
ee11925e13
commit
3c63d1b5e0
|
@ -5,4 +5,8 @@ target/
|
|||
config.yaml
|
||||
log/logger1.log*
|
||||
*.jar
|
||||
resources/*.tar
|
||||
resources/*.tar
|
||||
resources/themes/clojure/static.tar
|
||||
resources/themes/dark/static.tar
|
||||
resources/themes/light/static.tar
|
||||
resources/themes/sepia/static.tar
|
||||
|
|
1
Makefile
1
Makefile
|
@ -3,7 +3,6 @@
|
|||
build:
|
||||
make build.templates
|
||||
lein uberjar
|
||||
make rm.statics
|
||||
echo "Finish!"
|
||||
|
||||
build.templates:
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
(defproject rsspaper "1.2.1"
|
||||
(defproject rsspaper "1.2.2"
|
||||
:description "RSSpaper"
|
||||
:url "https://github.com/tanrax/RSSpaper"
|
||||
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
|
||||
|
|
|
@ -16,13 +16,17 @@
|
|||
|
||||
(defn filter-edition
|
||||
[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)))
|
||||
weekly (c/to-long (t/minus (t/now) (t/weeks 1)))]
|
||||
(case (:edition config)
|
||||
"daily" (filter (fn [article] (and (not (nil? (:published-date article))) (>= (:published-date article) daily))) articles)
|
||||
"daily" (filter (fn [article] (and (not (nil? (:published-date article))) (>= (:published-date article) daily))) articles)
|
||||
"weekly" (filter (fn [article] (and (not (nil? (:published-date article))) (>= (:published-date article) weekly))) articles)
|
||||
articles)))
|
||||
|
||||
(defn remove-future-editions
|
||||
[articles]
|
||||
(filter (fn [article] (and (not (nil? (:published-date article))) (< (:published-date article) (c/to-long (t/now))))) articles))
|
||||
|
||||
(defn add-datetimes-formatter
|
||||
[articles]
|
||||
(map (fn [article]
|
||||
|
@ -35,10 +39,9 @@
|
|||
;; Add in every article, all information from feed
|
||||
(concat articles (map (fn [article] (assoc
|
||||
;; Add feed-url
|
||||
(assoc article :feed
|
||||
(assoc article :feed
|
||||
;; Add feed
|
||||
(:feed (update-in feed [:feed] dissoc :entries))) :feed-url (:feed-url feed))) (get-in feed [:feed :entries])))) [] feeds))
|
||||
|
||||
(:feed (update-in feed [:feed] dissoc :entries))) :feed-url (:feed-url feed))) (get-in feed [:feed :entries])))) [] feeds))
|
||||
|
||||
(defn add-domain-to-relative-path
|
||||
[url-complete url-relative]
|
||||
|
@ -49,7 +52,6 @@
|
|||
url-with-domain (if is-relative (str (get url-elements 1) (get url-elements 2) url-relative) url-relative)]
|
||||
url-with-domain))
|
||||
|
||||
|
||||
(defn add-cover-article
|
||||
[articles]
|
||||
;; Add cover to article search first image in description
|
||||
|
@ -63,7 +65,7 @@
|
|||
url-og-image (second (re-find #"<meta[^>].*?property=\"og:image(?::url)?\".*?content=\"(.*?)\".*?>|<meta[^>].*?content=\"(.*?)\".*?property=\"og:image(?::url)?\".*?>" html))
|
||||
url-first-image (second (re-find #"<main.*>[\s\S]+<img[^>]+src=\"([^\">]+)\"|id=['\"] ?main ?['\"]>[\s\S]+<img[^>]+src=\"([^\">]+)\"|class=['\"] ?main ?[\'\"]>[\s\S]+<img[^>]+src=\"([^\">]+)\"" html))
|
||||
images [url-og-image url-first-image]
|
||||
url-valid (first (filter (fn [item] (not (nil? item))) images))
|
||||
url-valid (first (remove nil? images))
|
||||
url-final-image (add-domain-to-relative-path (:feed-url article) url-valid)]
|
||||
(assoc article :cover url-final-image))) articles))
|
||||
|
||||
|
@ -76,22 +78,23 @@
|
|||
[]
|
||||
;; Get all feeds from config -> feeds
|
||||
(->
|
||||
(reduce
|
||||
(fn [feeds feed-url]
|
||||
(reduce
|
||||
(fn [feeds feed-url]
|
||||
; Read feed
|
||||
(let [feed (parse-url feed-url {:insecure? true :throw-exceptions false})]
|
||||
(let [feed (parse-url feed-url {:insecure? true :throw-exceptions false})]
|
||||
; User feedback
|
||||
(prn (str "Reading RSS > " feed-url))
|
||||
(prn (str "Reading RSS > " feed-url))
|
||||
; Check is not null
|
||||
(if-not (nil? feed)
|
||||
(if-not (nil? feed)
|
||||
; Add feed and add key feed original
|
||||
(conj feeds (assoc feed :feed-url feed-url))
|
||||
(conj feeds (assoc feed :feed-url feed-url))
|
||||
; 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))
|
||||
(prn (str "Error with '" feed-url) "'"))))
|
||||
[] (:feeds config))
|
||||
zip-feeds-in-articles
|
||||
datetimes-to-unixtime
|
||||
filter-edition
|
||||
remove-future-editions
|
||||
order-published
|
||||
add-cover-article
|
||||
add-datetimes-formatter))
|
||||
|
|
Loading…
Reference in New Issue