mirror of
https://github.com/tanrax/RSSPAPER.git
synced 2025-05-22 01:53:56 -04:00
Add cover
This commit is contained in:
parent
09aff8568f
commit
4b91adf208
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,3 +3,4 @@ target/
|
|||||||
/.lein-repl-history
|
/.lein-repl-history
|
||||||
/.nrepl-port
|
/.nrepl-port
|
||||||
config.yaml
|
config.yaml
|
||||||
|
config.yaml
|
||||||
|
@ -123,6 +123,9 @@
|
|||||||
{% for article in item.feed.entries %}
|
{% for article in item.feed.entries %}
|
||||||
<article class="feed__article article">
|
<article class="feed__article article">
|
||||||
<header class="article__header">
|
<header class="article__header">
|
||||||
|
<p>
|
||||||
|
<img src="{{ article.cover }}" alt="{{ article.title }}">
|
||||||
|
</p>
|
||||||
<h1 class="article__title">{{ article.title }}</h1>
|
<h1 class="article__title">{{ article.title }}</h1>
|
||||||
<h2 class="article__feed">{{ item.feed.title }}</h2>
|
<h2 class="article__feed">{{ item.feed.title }}</h2>
|
||||||
</header>
|
</header>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="Leiningen: cheshire:5.9.0" level="project" />
|
<orderEntry type="library" name="Leiningen: cheshire:5.9.0" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: clj-http:3.10.2" level="project" />
|
<orderEntry type="library" name="Leiningen: clj-http:3.10.2" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: clj-rss:0.2.6" level="project" />
|
<orderEntry type="library" name="Leiningen: clj-rss:0.2.7" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: clj-tuple:0.2.2" level="project" />
|
<orderEntry type="library" name="Leiningen: clj-tuple:0.2.2" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: clj-yaml:0.4.0" level="project" />
|
<orderEntry type="library" name="Leiningen: clj-yaml:0.4.0" level="project" />
|
||||||
<orderEntry type="library" name="Leiningen: clojure-complete:0.2.5" level="project" />
|
<orderEntry type="library" name="Leiningen: clojure-complete:0.2.5" level="project" />
|
||||||
|
@ -4,6 +4,19 @@
|
|||||||
[rsspaper.config :refer [config]]
|
[rsspaper.config :refer [config]]
|
||||||
[selmer.parser :as s]))
|
[selmer.parser :as s]))
|
||||||
|
|
||||||
|
(defn add-cover-article
|
||||||
|
[data]
|
||||||
|
;; Add cover to article search first image in description
|
||||||
|
;; Iterate every blog
|
||||||
|
(map (fn [blog]
|
||||||
|
;; Replace entries
|
||||||
|
(assoc-in blog [:feed :entries]
|
||||||
|
;; New entries with add cover
|
||||||
|
(map (fn [article]
|
||||||
|
(assoc article :cover (second (re-find #"<img[^>]+src=\"([^\">]+)\"" (str (get-in article [:description :value]))))))
|
||||||
|
(get-in blog [:feed :entries])) )
|
||||||
|
) data))
|
||||||
|
|
||||||
(defn make-html
|
(defn make-html
|
||||||
[data]
|
[data]
|
||||||
;; Render html in dist/index.html
|
;; Render html in dist/index.html
|
||||||
@ -17,5 +30,5 @@
|
|||||||
(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)
|
||||||
:data data
|
:data (add-cover-article data)
|
||||||
})))))
|
})))))
|
Loading…
x
Reference in New Issue
Block a user