Browse Source

[mod] add CSS (LESS) to xsl style to view rss in browser

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Markus Heiser 5 months ago
parent
commit
cf8c36f351

+ 6 - 0
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,
+          },
         ],
       },
     },

+ 45 - 0
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);
+    }
+  }
+}

+ 1 - 1
searx/templates/simple/opensearch_response_rss.xml

@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="{{ url_for('static', filename='xsl/rss.xsl') }}" type="text/xsl"?>
+<?xml-stylesheet href="{{ url_for('rss_xsl') }}" type="text/xsl"?>
 <rss version="2.0"
      xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/"
      xmlns:atom="http://www.w3.org/2005/Atom">

+ 1 - 0
searx/static/themes/simple/xsl/rss.xsl → searx/templates/simple/rss.xsl

@@ -8,6 +8,7 @@
         <meta charset="UTF-8" />
         <meta http-equiv="x-ua-compatible" content="IE=edge,chrome=1" />
         <meta name="viewport" content="width=device-width,initial-scale=1" />
+	<link rel="stylesheet" href="{{ url_for('static', filename='css/rss.min.css') }}" type="text/css" media="screen"/>
       </head>
       <body>
         <header>

+ 8 - 0
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.