From cf8c36f35141380c5f8e886760c859d0e95f6dd0 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Sun, 24 Nov 2024 18:19:11 +0100 Subject: [PATCH] [mod] add CSS (LESS) to xsl style to view rss in browser Signed-off-by: Markus Heiser --- searx/static/themes/simple/gruntfile.js | 6 +++ searx/static/themes/simple/src/less/rss.less | 45 +++++++++++++++++++ .../simple/opensearch_response_rss.xml | 2 +- .../simple/xsl => templates/simple}/rss.xsl | 1 + searx/webapp.py | 8 ++++ 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 searx/static/themes/simple/src/less/rss.less rename searx/{static/themes/simple/xsl => templates/simple}/rss.xsl (91%) diff --git a/searx/static/themes/simple/gruntfile.js b/searx/static/themes/simple/gruntfile.js index 9410a674b..c2cbad315 100644 --- a/searx/static/themes/simple/gruntfile.js +++ b/searx/static/themes/simple/gruntfile.js @@ -136,6 +136,12 @@ module.exports = function (grunt) { nonull: true, filter: file_exists, }, + { + src: ['src/less/rss.less'], + dest: 'css/rss.min.css', + nonull: true, + filter: file_exists, + }, ], }, }, diff --git a/searx/static/themes/simple/src/less/rss.less b/searx/static/themes/simple/src/less/rss.less new file mode 100644 index 000000000..0bc6622e3 --- /dev/null +++ b/searx/static/themes/simple/src/less/rss.less @@ -0,0 +1,45 @@ +@import (inline) "../../node_modules/normalize.css/normalize.css"; +@import "definitions.less"; + +.text-size-adjust (@property: 100%) { + -webkit-text-size-adjust: @property; + -ms-text-size-adjust: @property; + -moz-text-size-adjust: @property; + text-size-adjust: @property; +} + +// Reset padding and margin +html, +body, +main { + padding: 0; + margin: 0; +} + +html { + font-family: sans-serif; + font-size: 0.9em; + .text-size-adjust; + + color: var(--color-base-font); + background-color: var(--color-base-background); + + scroll-behavior: smooth; +} + +body { + margin-inline: 1rem; +} + +a { + text-decoration: none; + color: var(--color-url-font); + + &:visited { + color: var(--color-url-visited-font); + + .highlight { + color: var(--color-url-visited-font); + } + } +} diff --git a/searx/templates/simple/opensearch_response_rss.xml b/searx/templates/simple/opensearch_response_rss.xml index 574f32e69..ab732aec2 100644 --- a/searx/templates/simple/opensearch_response_rss.xml +++ b/searx/templates/simple/opensearch_response_rss.xml @@ -1,5 +1,5 @@ - + diff --git a/searx/static/themes/simple/xsl/rss.xsl b/searx/templates/simple/rss.xsl similarity index 91% rename from searx/static/themes/simple/xsl/rss.xsl rename to searx/templates/simple/rss.xsl index 7de7f8037..a3b646ae3 100644 --- a/searx/static/themes/simple/xsl/rss.xsl +++ b/searx/templates/simple/rss.xsl @@ -8,6 +8,7 @@ +
diff --git a/searx/webapp.py b/searx/webapp.py index 8158256e6..f7e7e1d5c 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -614,6 +614,14 @@ def client_token(token=None): return Response('', mimetype='text/css') +@app.route('/rss.xsl', methods=['GET', 'POST']) +def rss_xsl(): + return render_template( + f"{request.preferences.get_value('theme')}/rss.xsl", + url_for=custom_url_for, + ) + + @app.route('/search', methods=['GET', 'POST']) def search(): """Search query in q and return results.