on master help sign in
[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>

commit04c687403e21f883f9614e6a24df9ec450cfc111 authorMarkus Heiser <markus.heiser@darmarit.de> dateWed 25 Mar 2020, 11:49 (7 years ago) parent9a2f26d
7 files changed+29−19
Makefile+10−3 searx/templates/__common__/about.html+6−6 searx/templates/courgette/github_ribbon.html+2−2 searx/templates/legacy/github_ribbon.html+1−1 searx/templates/oscar/base.html+4−4 searx/templates/simple/base.html+3−3 searx/webapp.py+3
Makefile+10−3
@@ -71,15 +71,22 @@ $(GH_PAGES)::
7171# update project files
7272# --------------------
7373
74−PHONY += project engines-languages
74+PHONY += project engines-languages searx.brand
7575
76−project: searx/data/engines_languages.json
76+project: searx/data/engines_languages.json searx.brand
7777
78−searx/data/engines_languages.json: pyenvinstall
78+engines-languages: pyenvinstall
7979 $(PY_ENV_ACT); python utils/fetch_languages.py
8080 mv engines_languages.json searx/data/engines_languages.json
8181 mv languages.py searx/languages.py
8282
83+searx.brand:
84+ $(Q)echo "build searx/brand.py"
85+ $(Q)echo "GIT_URL = '$(GIT_URL)'" > searx/brand.py
86+ $(Q)echo "SEARX_URL = '$(SEARX_URL)'" >> searx/brand.py
87+ $(Q)echo "DOCS_URL = '$(DOCS_URL)'" >> searx/brand.py
88+ $(Q)echo "PUBLIC_INSTANCES = 'https://searx.space'" >> searx/brand.py
89+
8390# test
8491# ----
8592
searx/templates/__common__/about.html+6−6
@@ -7,7 +7,7 @@
77 <ul>
88 <li>searx may not offer you as personalised results as Google, but it doesn't generate a profile about you</li>
99 <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>
10− <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>
10+ <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>
1111 </ul>
1212 <p>If you do care about privacy, want to be a conscious user, or otherwise believe
1313 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
2222
2323<h2>How can I make it my own?</h2>
2424
25−<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!
25+<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!
2626<br />The more decentralized the Internet is, the more freedom we have!</p>
2727
2828
2929<h2>More about searx</h2>
3030
3131<ul>
32− <li><a href="https://github.com/asciimoo/searx">github</a></li>
32+ <li><a href="{{ brand.GIT_URL }}">github</a></li>
3333 <li><a href="https://www.ohloh.net/p/searx/">ohloh</a></li>
3434 <li><a href="https://twitter.com/Searx_engine">twitter</a></li>
3535 <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
4848
4949<h3>New engines?</h3>
5050<ul>
51− <li>Edit your <a href="https://raw.github.com/asciimoo/searx/master/searx/settings.yml">settings.yml</a></li>
52− <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>
51+ <li>Edit your <a href="{{ brand.GIT_URL }}/blob/master/searx/settings.yml">settings.yml</a></li>
52+ <li>Create your custom engine module, check the <a href="{{ brand.GIT_URL }}/blob/master/examples/basic_engine.py">example engine</a></li>
5353</ul>
5454<p>Don't forget to restart searx after config edit!</p>
5555
5656<h3>Installation/WSGI support?</h3>
57−<p>See the <a href="https://github.com/asciimoo/searx/wiki/Installation">installation and setup</a> wiki page</p>
57+<p>See the <a href="{{ brand.DOCS_URL }}/admin/installation.html#uwsgi">installation and uwsgi setup</a></p>
5858
5959<h3>How to debug engines?</h3>
6060<p><a href="{{ url_for('stats') }}">Stats page</a> contains some useful data about the engines used.</p>
searx/templates/courgette/github_ribbon.html+2−2
@@ -1,3 +1,3 @@
1−<a href="https://github.com/asciimoo/searx" class="github">
1+<a href="{{ brand.GIT_URL }}" class="github">
22 <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"/>
3−</a>
3+</a>
searx/templates/legacy/github_ribbon.html+1−1
@@ -1,3 +1,3 @@
1−<a href="https://github.com/asciimoo/searx" class="github">
1+<a href="{{ brand.GIT_URL }}" class="github">
22 <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"/>
33</a>
searx/templates/oscar/base.html+4−4
@@ -85,10 +85,10 @@
8585 {% endblock %}
8686 <p class="text-muted">
8787 <small>
88− {{ _('Powered by') }} <a href="https://asciimoo.github.io/searx/">searx</a> - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}<br/>
89− <a href="https://github.com/asciimoo/searx">{{ _('Source code') }}</a> |
90− <a href="https://github.com/asciimoo/searx/issues">{{ _('Issue tracker') }}</a> |
91− <a href="https://searx.space/">{{ _('Public instances') }}</a>
88+ {{ _('Powered by') }} <a href="{{ brand.DOCS_URL }}">searx</a> - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}<br/>
89+ <a href="{{ brand.GIT_URL }}">{{ _('Source code') }}</a> |
90+ <a href="{{ brand.GIT_URL }}/issues">{{ _('Issue tracker') }}</a> |
91+ <a href="{{ brand.PUBLIC_INSTANCES }}">{{ _('Public instances') }}</a>
9292 </small>
9393 </p>
9494 </div>
searx/templates/simple/base.html+3−3
@@ -51,9 +51,9 @@
5151 <footer>
5252 <p>
5353 {{ _('Powered by') }} <a href="{{ url_for('about') }}">searx</a> - {{ searx_version }} - {{ _('a privacy-respecting, hackable metasearch engine') }}<br/>
54− <a href="https://github.com/asciimoo/searx">{{ _('Source code') }}</a> |
55− <a href="https://github.com/asciimoo/searx/issues">{{ _('Issue tracker') }}</a> |
56− <a href="https://searx.space/">{{ _('Public instances') }}</a>
54+ <a href="{{ brand.GIT_URL }}">{{ _('Source code') }}</a> |
55+ <a href="{{ brand.GIT_URL }}/issues">{{ _('Issue tracker') }}</a> |
56+ <a href="{{ brand.PUBLIC_INSTANCES }}">{{ _('Public instances') }}</a>
5757 </p>
5858 </footer>
5959 <!--[if gte IE 9]>-->
searx/webapp.pymode 100644 → 100755+3
@@ -57,6 +57,7 @@ from babel.support import Translations
5757import flask_babel
5858from flask_babel import Babel, gettext, format_date, format_decimal
5959from flask.json import jsonify
60+from searx import brand
6061from searx import settings, searx_dir, searx_debug
6162from searx.exceptions import SearxParameterException
6263from searx.engines import (
@@ -427,6 +428,8 @@ def render(template_name, override_theme=None, **kwargs):
427428
428429 kwargs['preferences'] = request.preferences
429430
431+ kwargs['brand'] = brand
432+
430433 kwargs['scripts'] = set()
431434 for plugin in request.user_plugins:
432435 for script in plugin.js_dependencies: