Browse Source

[fix] brands: add variables from build env to jinja templating

We have some variables in the build environment which are also needed in the
templating process.  Theses variables are relavant if one creates a fork with
its own branding.  We treat these variables under the term 'brands'.

Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Markus Heiser 5 years ago
parent
commit
04c687403e

+ 10 - 3
Makefile

@@ -71,15 +71,22 @@ $(GH_PAGES)::
 # update project files
 # update project files
 # --------------------
 # --------------------
 
 
-PHONY += project engines-languages
+PHONY += project engines-languages searx.brand
 
 
-project: searx/data/engines_languages.json
+project: searx/data/engines_languages.json searx.brand
 
 
-searx/data/engines_languages.json:  pyenvinstall
+engines-languages:  pyenvinstall
 	$(PY_ENV_ACT); python utils/fetch_languages.py
 	$(PY_ENV_ACT); python utils/fetch_languages.py
 	mv engines_languages.json searx/data/engines_languages.json
 	mv engines_languages.json searx/data/engines_languages.json
 	mv languages.py searx/languages.py
 	mv languages.py searx/languages.py
 
 
+searx.brand:
+	$(Q)echo "build searx/brand.py"
+	$(Q)echo "GIT_URL = '$(GIT_URL)'"  > searx/brand.py
+	$(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py
+	$(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py
+	$(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py
+
 # test
 # test
 # ----
 # ----
 
 

+ 6 - 6
searx/templates/__common__/about.html

@@ -7,7 +7,7 @@
     <ul>
     <ul>
         <li>searx may not offer you as personalised results as Google, but it doesn't generate a profile about you</li>
         <li>searx may not offer you as personalised results as Google, but it doesn't generate a profile about you</li>
         <li>searx doesn't care about what you search for, never shares anything with a third party, and it can't be used to compromise you</li>
         <li>searx doesn't care about what you search for, never shares anything with a third party, and it can't be used to compromise you</li>
-        <li>searx is free software, the code is 100% open and you can help to make it better. See more on <a href="https://github.com/asciimoo/searx">github</a></li>
+        <li>searx is free software, the code is 100% open and you can help to make it better. See more on <a href="{{ brand.GIT_URL }}">github</a></li>
     </ul>
     </ul>
     <p>If you do care about privacy, want to be a conscious user, or otherwise believe
     <p>If you do care about privacy, want to be a conscious user, or otherwise believe
     in digital freedom, make searx your default search engine or run it on your own server</p>
     in digital freedom, make searx your default search engine or run it on your own server</p>
@@ -22,14 +22,14 @@ Searx can be added to your browser's search bar; moreover, it can be set as the
 
 
 <h2>How can I make it my own?</h2>
 <h2>How can I make it my own?</h2>
 
 
-<p>Searx appreciates your concern regarding logs, so take the <a href="https://github.com/asciimoo/searx">code</a> and run it yourself! <br />Add your Searx to this <a href="https://searx.space/">list</a> to help other people reclaim their privacy and make the Internet freer!
+<p>Searx appreciates your concern regarding logs, so take the <a href="{{ brand.GIT_URL }}">code</a> and run it yourself! <br />Add your Searx to this <a href="{{ brand.SEARX_URL }}">list</a> to help other people reclaim their privacy and make the Internet freer!
 <br />The more decentralized the Internet is, the more freedom we have!</p>
 <br />The more decentralized the Internet is, the more freedom we have!</p>
 
 
 
 
 <h2>More about searx</h2>
 <h2>More about searx</h2>
 
 
 <ul>
 <ul>
-    <li><a href="https://github.com/asciimoo/searx">github</a></li>
+    <li><a href="{{ brand.GIT_URL }}">github</a></li>
     <li><a href="https://www.ohloh.net/p/searx/">ohloh</a></li>
     <li><a href="https://www.ohloh.net/p/searx/">ohloh</a></li>
     <li><a href="https://twitter.com/Searx_engine">twitter</a></li>
     <li><a href="https://twitter.com/Searx_engine">twitter</a></li>
     <li>IRC: #searx @ freenode (<a href="https://kiwiirc.com/client/irc.freenode.com/searx">webclient</a>)</li>
     <li>IRC: #searx @ freenode (<a href="https://kiwiirc.com/client/irc.freenode.com/searx">webclient</a>)</li>
@@ -48,13 +48,13 @@ Searx can be added to your browser's search bar; moreover, it can be set as the
 
 
 <h3>New engines?</h3>
 <h3>New engines?</h3>
 <ul>
 <ul>
-    <li>Edit your <a href="https://raw.github.com/asciimoo/searx/master/searx/settings.yml">settings.yml</a></li>
-    <li>Create your custom engine module, check the <a href="https://github.com/asciimoo/searx/blob/master/examples/basic_engine.py">example engine</a></li>
+    <li>Edit your <a href="{{ brand.GIT_URL }}/blob/master/searx/settings.yml">settings.yml</a></li>
+    <li>Create your custom engine module, check the <a href="{{ brand.GIT_URL }}/blob/master/examples/basic_engine.py">example engine</a></li>
 </ul>
 </ul>
 <p>Don't forget to restart searx after config edit!</p>
 <p>Don't forget to restart searx after config edit!</p>
 
 
 <h3>Installation/WSGI support?</h3>
 <h3>Installation/WSGI support?</h3>
-<p>See the <a href="https://github.com/asciimoo/searx/wiki/Installation">installation and setup</a> wiki page</p>
+<p>See the <a href="{{ brand.DOCS_URL }}/admin/installation.html#uwsgi">installation and uwsgi setup</a></p>
 
 
 <h3>How to debug engines?</h3>
 <h3>How to debug engines?</h3>
 <p><a href="{{ url_for('stats') }}">Stats page</a> contains some useful data about the engines used.</p>
 <p><a href="{{ url_for('stats') }}">Stats page</a> contains some useful data about the engines used.</p>

+ 2 - 2
searx/templates/courgette/github_ribbon.html

@@ -1,3 +1,3 @@
-<a href="https://github.com/asciimoo/searx" class="github">
+<a href="{{ brand.GIT_URL }}" class="github">
     <img style="position: absolute; top: 0; right: 0; border: 0;" src="{{ url_for('static', filename='img/github_ribbon.png') }}" alt="Fork me on GitHub"  class="github"/>
     <img style="position: absolute; top: 0; right: 0; border: 0;" src="{{ url_for('static', filename='img/github_ribbon.png') }}" alt="Fork me on GitHub"  class="github"/>
-</a>
+</a>

+ 1 - 1
searx/templates/legacy/github_ribbon.html

@@ -1,3 +1,3 @@
-<a href="https://github.com/asciimoo/searx" class="github">
+<a href="{{ brand.GIT_URL }}" class="github">
     <img style="position: absolute; top: 0; right: 0; border: 0;" src="{{ url_for('static', filename='img/github_ribbon.png') }}" alt="Fork me on GitHub"  class="github"/>
     <img style="position: absolute; top: 0; right: 0; border: 0;" src="{{ url_for('static', filename='img/github_ribbon.png') }}" alt="Fork me on GitHub"  class="github"/>
 </a>
 </a>

+ 4 - 4
searx/templates/oscar/base.html

@@ -85,10 +85,10 @@
             {% endblock %}
             {% endblock %}
             <p class="text-muted">
             <p class="text-muted">
                 <small>
                 <small>
-                    {{ _('Powered by') }} <a href="https://asciimoo.github.io/searx/">searx</a> - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}<br/>
-                    <a href="https://github.com/asciimoo/searx">{{ _('Source code') }}</a> |
-                    <a href="https://github.com/asciimoo/searx/issues">{{ _('Issue tracker') }}</a> |
-                    <a href="https://searx.space/">{{ _('Public instances') }}</a>
+                    {{ _('Powered by') }} <a href="{{ brand.DOCS_URL }}">searx</a> - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}<br/>
+                    <a href="{{ brand.GIT_URL }}">{{ _('Source code') }}</a> |
+                    <a href="{{ brand.GIT_URL }}/issues">{{ _('Issue tracker') }}</a> |
+                    <a href="{{ brand.PUBLIC_INSTANCES }}">{{ _('Public instances') }}</a>
                 </small>
                 </small>
             </p>
             </p>
         </div>
         </div>

+ 3 - 3
searx/templates/simple/base.html

@@ -51,9 +51,9 @@
   <footer>
   <footer>
     <p>
     <p>
     {{ _('Powered by') }} <a href="{{ url_for('about') }}">searx</a> - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}<br/>
     {{ _('Powered by') }} <a href="{{ url_for('about') }}">searx</a> - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}<br/>
-        <a href="https://github.com/asciimoo/searx">{{ _('Source code') }}</a> |
-        <a href="https://github.com/asciimoo/searx/issues">{{ _('Issue tracker') }}</a> |
-        <a href="https://searx.space/">{{ _('Public instances') }}</a>
+        <a href="{{ brand.GIT_URL }}">{{ _('Source code') }}</a> |
+        <a href="{{ brand.GIT_URL }}/issues">{{ _('Issue tracker') }}</a> |
+        <a href="{{ brand.PUBLIC_INSTANCES }}">{{ _('Public instances') }}</a>
     </p>
     </p>
   </footer>
   </footer>
   <!--[if gte IE 9]>-->
   <!--[if gte IE 9]>-->

+ 3 - 0
searx/webapp.py

@@ -57,6 +57,7 @@ from babel.support import Translations
 import flask_babel
 import flask_babel
 from flask_babel import Babel, gettext, format_date, format_decimal
 from flask_babel import Babel, gettext, format_date, format_decimal
 from flask.json import jsonify
 from flask.json import jsonify
+from searx import brand
 from searx import settings, searx_dir, searx_debug
 from searx import settings, searx_dir, searx_debug
 from searx.exceptions import SearxParameterException
 from searx.exceptions import SearxParameterException
 from searx.engines import (
 from searx.engines import (
@@ -427,6 +428,8 @@ def render(template_name, override_theme=None, **kwargs):
 
 
     kwargs['preferences'] = request.preferences
     kwargs['preferences'] = request.preferences
 
 
+    kwargs['brand'] = brand
+
     kwargs['scripts'] = set()
     kwargs['scripts'] = set()
     for plugin in request.user_plugins:
     for plugin in request.user_plugins:
         for script in plugin.js_dependencies:
         for script in plugin.js_dependencies: