diff --git a/project.clj b/project.clj index 19eb522..5a7c0ff 100644 --- a/project.clj +++ b/project.clj @@ -13,6 +13,8 @@ [cheshire "5.9.0"] ;; Date [clj-time "0.15.2"] + ;; HTTP client + [clj-http "3.12.3"] ;; Utils dirs [me.raynes/fs "1.4.6"] ;; Parse RSS/Atom feeds diff --git a/resources/themes/light/index.html b/resources/themes/light/index.html index e9b97dd..16a1cec 100644 --- a/resources/themes/light/index.html +++ b/resources/themes/light/index.html @@ -24,8 +24,8 @@ - - + + diff --git a/resources/themes/light/static.zip b/resources/themes/light/static.zip index 52bc03a..0a066c7 100644 Binary files a/resources/themes/light/static.zip and b/resources/themes/light/static.zip differ diff --git a/resources/themes/light/static/css/desktop.css b/resources/themes/light/static/css/desktop.css index e69de29..57918dc 100644 --- a/resources/themes/light/static/css/desktop.css +++ b/resources/themes/light/static/css/desktop.css @@ -0,0 +1,135 @@ +/* Desktop */ +.main { + display: grid; + grid-gap: 1rem; + grid-template-columns: repeat(12, 1fr); +} + +/* First column. */ +.feed__article:nth-child(3n-2){ + grid-column: 9 / 13; +} + +/* Second column */ +.feed__article:nth-child(3n+2){ + grid-column: 1 / 5; +} + +/* Third column */ +.feed__article:nth-child(3n+3) { + grid-column: 5 / 9; +} + +.article__title { + font-size: 1.5rem; +} + +.article__feed { + font-size: 1rem; +} + +.article__date { + font-size: .9rem; + color: var(--color-gray); +} + +.feed__article:nth-child(1) .article__title { + font-size: 2rem; +} + +.feed__article:nth-child(1) .article__feed { + font-size: 1rem; +} + +.feed__article:nth-child(1) { + grid-column: 1 / 9; + grid-row: 1 / 4; + text-align: center; +} + +.feed__article:nth-child(2) { + grid-column: 9 / 13; + grid-row: 1 / 2; + +} + +.feed__article:nth-child(3) { + grid-column: 9 / 13; + grid-row: 2 / 3; + +} + +.feed__article:nth-child(4) { + grid-column: 9 / 13; + grid-row: 3 / 4; +} + +.feed__article:nth-child(2) .article__header, +.feed__article:nth-child(3) .article__header, +.feed__article:nth-child(4) .article__header +{ + display: flex; + justify-content: space-between; + flex-direction: row-reverse; + grid-gap: 1rem; +} + +.article__header > p { + margin: 0; +} + +.article__header-img > img { + height: var(--height-img); +} + +.feed__article:nth-child(1) .article__header-img > img, +.feed__article:nth-child(2) .article__header-img > img, +.feed__article:nth-child(3) .article__header-img > img, +.feed__article:nth-child(4) .article__header-img > img +{ + height: initial; +} + +.feed__article:nth-child(2) .article__titles, +.feed__article:nth-child(3) .article__titles, +.feed__article:nth-child(4) .article__titles, +.feed__article:nth-child(2) .article__header-img, +.feed__article:nth-child(3) .article__header-img, +.feed__article:nth-child(4) .article__header-img +{ + width: 50%; +} + +.feed__article:nth-child(2) .article__title, +.feed__article:nth-child(3) .article__title, +.feed__article:nth-child(4) .article__title +{ + font-size: 1.2rem; +} + +.feed__article:nth-child(2) .article__feed, +.feed__article:nth-child(3) .article__feed, +.feed__article:nth-child(4) .article__feed +{ + font-size: 1rem; +} +.article__main { + position: fixed; + left: -100%; + top: 0; + bottom: 0; + overflow-y: auto; + +} +.feed__article:nth-child(1) .article__header { + display: flex; + flex-direction: column; + height: 100%; +} +.feed__article:nth-child(1) .article__header-img { + height: 100%; +} + +.feed__article:first-child img { + height: 100%; +} \ No newline at end of file diff --git a/resources/themes/light/static/css/main.css b/resources/themes/light/static/css/main.css index fc613d1..f0edd79 100644 --- a/resources/themes/light/static/css/main.css +++ b/resources/themes/light/static/css/main.css @@ -7,7 +7,7 @@ @font-face { font-family: Newsreader; - src: url("static/fonts/Newsreader-VariableFont_opsz,wght.woff2"); + src: url("../fonts/Newsreader-VariableFont_opsz,wght.woff2"); } body { @@ -15,6 +15,8 @@ body { padding: 0; font-family: Newsreader, serif; color: var(--color-black); + background-image: url("../img/background.jpg"); + background-size: 100%; } img { object-fit: cover; diff --git a/resources/themes/light/static/css/mobile.css b/resources/themes/light/static/css/mobile.css index 04fe641..afb941a 100644 --- a/resources/themes/light/static/css/mobile.css +++ b/resources/themes/light/static/css/mobile.css @@ -1,131 +1,7 @@ -/* Desktop */ -.main { - display: grid; - grid-gap: 1rem; - grid-template-columns: repeat(12, 1fr); +.title { + font-size: 3rem } -/* First column. */ -.feed__article:nth-child(3n-2){ - grid-column: 9 / 13; -} - -/* Second column */ -.feed__article:nth-child(3n+2){ - grid-column: 1 / 5; -} - -/* Third column */ -.feed__article:nth-child(3n+3) { - grid-column: 5 / 9; -} - -.article__title { - font-size: 1.5rem; -} - -.article__feed { +.subtitle { font-size: 1rem; -} - -.article__date { - font-size: .9rem; - color: var(--color-gray); -} - -.feed__article:nth-child(1) .article__title { - font-size: 2rem; -} - -.feed__article:nth-child(1) .article__feed { - font-size: 1rem; -} - -.feed__article:nth-child(1) { - grid-column: 1 / 9; - grid-row: 1 / 4; - text-align: center; -} - -.feed__article:nth-child(2) { - grid-column: 9 / 13; - grid-row: 1 / 2; - -} - -.feed__article:nth-child(3) { - grid-column: 9 / 13; - grid-row: 2 / 3; - -} - -.feed__article:nth-child(4) { - grid-column: 9 / 13; - grid-row: 3 / 4; -} - -.feed__article:nth-child(2) .article__header, -.feed__article:nth-child(3) .article__header, -.feed__article:nth-child(4) .article__header -{ - display: flex; - justify-content: space-between; - flex-direction: row-reverse; - grid-gap: 1rem; -} - -.article__header > p { - margin: 0; -} - -.article__header-img > img { - height: var(--height-img); -} - -.feed__article:nth-child(1) .article__header-img > img, -.feed__article:nth-child(2) .article__header-img > img, -.feed__article:nth-child(3) .article__header-img > img, -.feed__article:nth-child(4) .article__header-img > img -{ - height: initial; -} - -.feed__article:nth-child(2) .article__titles, -.feed__article:nth-child(3) .article__titles, -.feed__article:nth-child(4) .article__titles, -.feed__article:nth-child(2) .article__header-img, -.feed__article:nth-child(3) .article__header-img, -.feed__article:nth-child(4) .article__header-img -{ - width: 50%; -} - -.feed__article:nth-child(2) .article__title, -.feed__article:nth-child(3) .article__title, -.feed__article:nth-child(4) .article__title -{ - font-size: 1.2rem; -} - -.feed__article:nth-child(2) .article__feed, -.feed__article:nth-child(3) .article__feed, -.feed__article:nth-child(4) .article__feed -{ - font-size: 1rem; -} -.article__main { - position: fixed; - left: -100%; - top: 0; - bottom: 0; - overflow-y: auto; - -} -.feed__article:nth-child(1) .article__header { - display: flex; - flex-direction: column; - height: 100%; -} -.feed__article:nth-child(1) .article__header-img { - height: 100%; } \ No newline at end of file diff --git a/resources/themes/light/static/img/background.jpg b/resources/themes/light/static/img/background.jpg new file mode 100644 index 0000000..5e3d49b Binary files /dev/null and b/resources/themes/light/static/img/background.jpg differ diff --git a/rsspaper.iml b/rsspaper.iml index 9b9311d..0033074 100644 --- a/rsspaper.iml +++ b/rsspaper.iml @@ -14,7 +14,7 @@ - + @@ -26,7 +26,7 @@ - + @@ -36,11 +36,11 @@ - - + + - - + + diff --git a/src/rsspaper/feeds.clj b/src/rsspaper/feeds.clj index 64a91fe..bb2dc75 100644 --- a/src/rsspaper/feeds.clj +++ b/src/rsspaper/feeds.clj @@ -1,6 +1,7 @@ (ns rsspaper.feeds (:require [rsspaper.config :refer [config]] + [clj-http.client :as client] [clj-time.core :as t] [clj-time.coerce :as c] [clj-time.format :as f] @@ -20,7 +21,7 @@ (case (:edition config) "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) - :else articles))) + articles))) (defn add-datetimes-formatter [articles] @@ -39,11 +40,18 @@ ;; Add cover to article search first image in description ;; Iterate every blog (map (fn [article] - (let [url-article (second (re-find #"]+src=\"([^\">]+)\"" (str (get-in article [:description :value]))))] - (assoc article :cover (if (nil? url-article) (get-in article [:feed :image :url]) url-article)))) articles)) + (let [url-article (get-in article [:feed :link]) + html (:body (client/get url-article {:insecure? true})) + first-content (second (re-find #"]+)\".*property=\"og:image(?::url)?\".*>" html)) + second-content (second (re-find #"]+)\".*>" html)) + first-image (second (re-find #"]+src=\"([^\">]+)\"" html)) + images [first-content second-content first-image] + final-image (first (filter (fn [item] (not (nil? item))) images))] + (assoc article :cover final-image))) articles)) (defn order-published [articles] + ;; Order articles (reverse (sort-by :published-date articles))) (defn get-articles