From f18e78db42e05a4e1c817d2b25b01fd27bfe73a0 Mon Sep 17 00:00:00 2001 From: Andros Fenollosa Date: Tue, 20 Jul 2021 01:00:40 +0200 Subject: [PATCH] update statics --- .../img/icons/android-chrome-192x192.png | Bin .../img/icons/android-chrome-512x512.png | Bin .../icons/android-chrome-maskable-192x192.png | Bin .../icons/android-chrome-maskable-512x512.png | Bin .../light}/img/icons/default-alpha.png | Bin .../light}/img/icons/default.png | Bin .../themes/{light.html => light/index.html} | 10 ------- .../{static => themes/light}/manifest.json | 12 ++++---- src/rsspaper/html.clj | 28 +++++++++++++----- 9 files changed, 27 insertions(+), 23 deletions(-) rename resources/{static => themes/light}/img/icons/android-chrome-192x192.png (100%) rename resources/{static => themes/light}/img/icons/android-chrome-512x512.png (100%) rename resources/{static => themes/light}/img/icons/android-chrome-maskable-192x192.png (100%) rename resources/{static => themes/light}/img/icons/android-chrome-maskable-512x512.png (100%) rename resources/{static => themes/light}/img/icons/default-alpha.png (100%) rename resources/{static => themes/light}/img/icons/default.png (100%) rename resources/themes/{light.html => light/index.html} (94%) rename resources/{static => themes/light}/manifest.json (58%) diff --git a/resources/static/img/icons/android-chrome-192x192.png b/resources/themes/light/img/icons/android-chrome-192x192.png similarity index 100% rename from resources/static/img/icons/android-chrome-192x192.png rename to resources/themes/light/img/icons/android-chrome-192x192.png diff --git a/resources/static/img/icons/android-chrome-512x512.png b/resources/themes/light/img/icons/android-chrome-512x512.png similarity index 100% rename from resources/static/img/icons/android-chrome-512x512.png rename to resources/themes/light/img/icons/android-chrome-512x512.png diff --git a/resources/static/img/icons/android-chrome-maskable-192x192.png b/resources/themes/light/img/icons/android-chrome-maskable-192x192.png similarity index 100% rename from resources/static/img/icons/android-chrome-maskable-192x192.png rename to resources/themes/light/img/icons/android-chrome-maskable-192x192.png diff --git a/resources/static/img/icons/android-chrome-maskable-512x512.png b/resources/themes/light/img/icons/android-chrome-maskable-512x512.png similarity index 100% rename from resources/static/img/icons/android-chrome-maskable-512x512.png rename to resources/themes/light/img/icons/android-chrome-maskable-512x512.png diff --git a/resources/static/img/icons/default-alpha.png b/resources/themes/light/img/icons/default-alpha.png similarity index 100% rename from resources/static/img/icons/default-alpha.png rename to resources/themes/light/img/icons/default-alpha.png diff --git a/resources/static/img/icons/default.png b/resources/themes/light/img/icons/default.png similarity index 100% rename from resources/static/img/icons/default.png rename to resources/themes/light/img/icons/default.png diff --git a/resources/themes/light.html b/resources/themes/light/index.html similarity index 94% rename from resources/themes/light.html rename to resources/themes/light/index.html index d089d1e..cfdf659 100644 --- a/resources/themes/light.html +++ b/resources/themes/light/index.html @@ -22,20 +22,10 @@ - - - - - - - - - - diff --git a/resources/static/manifest.json b/resources/themes/light/manifest.json similarity index 58% rename from resources/static/manifest.json rename to resources/themes/light/manifest.json index 6cbd956..a837896 100644 --- a/resources/static/manifest.json +++ b/resources/themes/light/manifest.json @@ -1,26 +1,26 @@ { - "name": "RSSPaper", - "short_name": "RSSPaper", + "name": "RSSPAPER", + "short_name": "RSSPAPER", "theme_color": "#ffffff", "icons": [ { - "src": "./static/img/icons/android-chrome-192x192.png", + "src": "img/icons/android-chrome-192x192.png", "sizes": "192x192", "type": "image/png" }, { - "src": "./static/img/icons/android-chrome-512x512.png", + "src": "img/icons/android-chrome-512x512.png", "sizes": "512x512", "type": "image/png" }, { - "src": "./static/img/icons/android-chrome-maskable-192x192.png", + "src": "img/icons/android-chrome-maskable-192x192.png", "sizes": "192x192", "type": "image/png", "purpose": "maskable" }, { - "src": "./static/img/icons/android-chrome-maskable-512x512.png", + "src": "img/icons/android-chrome-maskable-512x512.png", "sizes": "512x512", "type": "image/png", "purpose": "maskable" diff --git a/src/rsspaper/html.clj b/src/rsspaper/html.clj index 0ab76ab..ec31507 100644 --- a/src/rsspaper/html.clj +++ b/src/rsspaper/html.clj @@ -2,18 +2,32 @@ (:require [clojure.java.io :as io] [rsspaper.config :refer [config]] + [clojure.string :as str] [selmer.parser :as s])) (defn make-html [articles] ;; Render html in dist/index.html - (let [dir "dist" - path (str dir "/index.html")] + (let [dir-dist "dist/" + path-theme (io/resource (str "themes/" (:theme config) "/")) + path-dist-index (str dir-dist "index.html") + + ] ;; Remove old index.html - (when (.exists (io/file path)) (io/delete-file path)) + #_(when (.exists (io/file path-dist-index)) (io/delete-file path-dist-index)) ;; Make dir dist - (.mkdir (java.io.File. dir)) + #_(.mkdir (java.io.File. dir-dist)) ;; Make dist/index.html - (with-open [wrtr (io/writer path)] - (.write wrtr (s/render-file (str "themes/" (:theme config) ".html") {:title (:title config) - :articles articles}))))) \ No newline at end of file + #_(with-open [wrtr (io/writer path-dist-index)] + (.write wrtr (s/render-file (str path-theme "index.html") {:title (:title config) + :articles articles}))) + ;; Make statics + ;; Iterate statics + (doseq [file (.listFiles (io/file path-theme) )] + (let [path (.getPath file) + relative-path (second (str/split path #"resources/")) + relative-dist-path (str dir-dist relative-path)] + ;; Remove old static + (when (.exists (io/file relative-dist-path)) (io/delete-file relative-dist-path)) + ;; Copy new static + (io/copy (io/file path) (io/file dir-dist))))))