Skip to content

Commit

Permalink
Make site title configurable via the theme hook.
Browse files Browse the repository at this point in the history
  • Loading branch information
rtibbles committed Oct 19, 2023
1 parent 3c012b2 commit 883e83a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion kolibri/core/templates/kolibri/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="google" content="notranslate">
{% theme_favicon %}
<title>{% trans "Kolibri" %}</title>
<title>{% site_title %}</title>
{% if LANGUAGE_CODE == "ach-ug" %}
<script type="text/javascript">
var _jipt = [];
Expand Down
2 changes: 1 addition & 1 deletion kolibri/core/templates/kolibri/unsupported_browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="google" content="notranslate">
{% theme_favicon %}
<title>{% trans "Kolibri" %}</title>
<title>{% site_title %}</title>
<style>
body {
margin: 0;
Expand Down
10 changes: 10 additions & 0 deletions kolibri/core/templatetags/core_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from kolibri.core.hooks import FrontEndBaseHeadHook
from kolibri.core.hooks import FrontEndBaseSyncHook
from kolibri.core.theme_hook import ThemeHook
from kolibri.utils.translation import ugettext as _

register = template.Library()

Expand Down Expand Up @@ -71,3 +72,12 @@ def theme_favicon():
favicon_url = favicon_urls[0] if favicon_urls else static("assets/logo.ico")

return format_html('<link rel="shortcut icon" href="{}">', favicon_url)


@register.simple_tag()
def site_title():
"""
Return the text of the site title, if provided by the theme. If not, the
default will be returned.
"""
return ThemeHook.get_theme().get("siteTitle", _("Kolibri"))
4 changes: 2 additions & 2 deletions kolibri/plugins/pwa/templates/pwa/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
{% get_current_language_bidi as LANGUAGE_BIDI %}
{% get_current_language as LANGUAGE_CODE %}
{
"name": "{% trans 'Kolibri'|escapejs %}",
"short_name": "{% trans 'Kolibri'|escapejs %}",
"name": "{% site_title|escapejs %}",
"short_name": "{% site_title|escapejs %}",
"dir": "{{ LANGUAGE_BIDI|yesno:'rtl,ltr'|escapejs }}",
"lang": "{{ LANGUAGE_CODE|escapejs }}",
"icons": [
Expand Down

0 comments on commit 883e83a

Please sign in to comment.