From 25270a11ed6ff03e26284ad6bf0adcd26edec8f7 Mon Sep 17 00:00:00 2001 From: Roy Olav Purser Date: Wed, 9 Jun 2021 09:33:36 +0200 Subject: [PATCH] add style from silvermone chromecast plugin --- Dockerfile | 8 +++++--- backend/install.sh | 5 ----- backend/style.js | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 8 deletions(-) delete mode 100644 backend/install.sh create mode 100644 backend/style.js diff --git a/Dockerfile b/Dockerfile index a829a8d..a2f41f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,9 @@ -FROM roypur/inkscape:latest as base +FROM roypur/stream-build:latest as base RUN ["mkdir", "-p", "/app/version"] COPY ["tv.json", "/app/setup/tv.json"] COPY ["backend/start.sh", "/app/start.sh"] COPY ["backend/sources.py", "/app/setup/sources.py"] +COPY ["backend/style.js", "/app/setup/style.js"] COPY ["backend/stream.py", "/app/stream.py"] COPY ["backend/stream_providers.py", "/app/stream_providers.py"] COPY ["frontend/index.html", "/app/index.html"] @@ -12,11 +13,12 @@ COPY ["frontend/style.css", "/app/style.css"] RUN ["chmod", "-R", "755", "/app"] RUN ["inkscape", "--export-area-page", "--export-width=256", "--export-height=256", "/app/favicon.svg", "--export-filename=/app/favicon.png"] RUN ["rm", "/app/favicon.svg"] +RUN ["/app/setup/sources.py"] +RUN ["/app/setup/style.js"] +RUN ["rm", "-r", "/app/setup"] FROM roypur/stream-runtime:latest as venv COPY --from=base /app /app -RUN ["/app/venv/bin/python3", "/app/setup/sources.py"] -RUN ["rm", "-r", "/app/setup"] FROM scratch COPY --from=venv / / diff --git a/backend/install.sh b/backend/install.sh deleted file mode 100644 index f8886bb..0000000 --- a/backend/install.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env sh -virtualenv --python=$(which python3) /app/venv -source /app/venv/bin/activate -pip install --upgrade pip -pip install --upgrade streamlink youtube-dl tornado aiohttp aiohttp-socks diff --git a/backend/style.js b/backend/style.js new file mode 100644 index 0000000..93d3192 --- /dev/null +++ b/backend/style.js @@ -0,0 +1,26 @@ +#!/usr/bin/env node + +const fs = require("fs"); +const css = require("css"); + +fs.readFile("/app/chromecast.css", "utf-8", (err, data) => { + const ast = css.parse(data); + for(const rule of ast.stylesheet.rules) { + const decls = []; + if(Symbol.iterator in Object(rule.declarations)) { + for(const decl of rule.declarations) { + const isNotUrl = !(decl.value.toLowerCase().startsWith("url")); + const isNotContent = !(decl.property.toLowerCase() == "content"); + if(isNotContent && isNotUrl) { + decls.push(decl); + } + } + rule.declarations = decls; + } + } + fs.appendFile("/app/style.css", css.stringify(ast, {"compress": true}), (err) => { + if(err !== null) { + console.log(err); + } + }); +});