Remove futures

This commit is contained in:
Andros Fenollosa 2021-12-16 19:35:14 +01:00
parent ee11925e13
commit 3c63d1b5e0
4 changed files with 30 additions and 24 deletions

4
.gitignore vendored
View File

@ -6,3 +6,7 @@ config.yaml
log/logger1.log* log/logger1.log*
*.jar *.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

View File

@ -3,7 +3,6 @@
build: build:
make build.templates make build.templates
lein uberjar lein uberjar
make rm.statics
echo "Finish!" echo "Finish!"
build.templates: build.templates:

View File

@ -1,4 +1,4 @@
(defproject rsspaper "1.2.1" (defproject rsspaper "1.2.2"
:description "RSSpaper" :description "RSSpaper"
:url "https://github.com/tanrax/RSSpaper" :url "https://github.com/tanrax/RSSpaper"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0" :license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"

View File

@ -23,6 +23,10 @@
"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)
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 (defn add-datetimes-formatter
[articles] [articles]
(map (fn [article] (map (fn [article]
@ -39,7 +43,6 @@
;; Add 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 (defn add-domain-to-relative-path
[url-complete url-relative] [url-complete url-relative]
;; Converts a relative path to a path with its domain. ;; Converts a relative path to a path with its domain.
@ -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 (if is-relative (str (get url-elements 1) (get url-elements 2) url-relative) url-relative)]
url-with-domain)) url-with-domain))
(defn add-cover-article (defn add-cover-article
[articles] [articles]
;; Add cover to article search first image in description ;; 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-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)) 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] 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)] url-final-image (add-domain-to-relative-path (:feed-url article) url-valid)]
(assoc article :cover url-final-image))) articles)) (assoc article :cover url-final-image))) articles))
@ -92,6 +94,7 @@
zip-feeds-in-articles zip-feeds-in-articles
datetimes-to-unixtime datetimes-to-unixtime
filter-edition filter-edition
remove-future-editions
order-published order-published
add-cover-article add-cover-article
add-datetimes-formatter)) add-datetimes-formatter))