Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom footer links and translations #3

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions ckanext/alisea/assets/webassets.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# alisea-js:
# filter: rjsmin
# output: ckanext-alisea/%(version)s-alisea.js
# contents:
# - js/alisea.js
# extra:
# preload:
# - base/main
alisea-js:
filter: rjsmin
output: ckanext-alisea/%(version)s-alisea.js
contents:
- js/alisea.js
extra:
preload:
- base/main

# alisea-css:
# filter: cssrewrite
# output: ckanext-alisea/%(version)s-alisea.css
# contents:
# - css/alisea.css
alisea-css:
filter: cssrewrite
output: ckanext-alisea/%(version)s-alisea.css
contents:
- css/alisea.css
25 changes: 25 additions & 0 deletions ckanext/alisea/i18n/ckanext-alisea.pot
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Translations template for ckanext-alisea.
# Copyright (C) 2024 ORGANIZATION
# This file is distributed under the same license as the ckanext-alisea project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: ckanext-alisea 0.0.1\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-09-02 18:36+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.10.3\n"

#: ckanext/alisea/templates/footer.html:15
msgid ""
"<strong>Powered by</strong> <a class=\"hide-text ckan-footer-logo\" "
"href=\"http://ckan.org\">CKAN</a>"
msgstr ""

27 changes: 27 additions & 0 deletions ckanext/alisea/i18n/vi/LC_MESSAGES/ckanext-alisea.po
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Vietnamese translations for ckanext-alisea.
# Copyright (C) 2024 ORGANIZATION
# This file is distributed under the same license as the ckanext-alisea
# project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2024.
#
msgid ""
msgstr ""
"Project-Id-Version: ckanext-alisea 0.0.1\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2024-09-02 18:36+0200\n"
"PO-Revision-Date: 2024-09-02 18:36+0200\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language: vi\n"
"Language-Team: vi <[email protected]>\n"
"Plural-Forms: nplurals=1; plural=0;\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 2.10.3\n"

#: ckanext/alisea/templates/footer.html:15
msgid ""
"<strong>Powered by</strong> <a class=\"hide-text ckan-footer-logo\" "
"href=\"http://ckan.org\">CKAN</a>"
msgstr ""

18 changes: 14 additions & 4 deletions ckanext/alisea/plugin.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
import ckan.plugins as plugins
import ckan.plugins.toolkit as toolkit
from ckan.lib.plugins import DefaultTranslation

from ckanext.alisea import helpers as h


class AliseaPlugin(plugins.SingletonPlugin):
class AliseaPlugin(plugins.SingletonPlugin, DefaultTranslation):
plugins.implements(plugins.IConfigurer)
plugins.implements(plugins.ITemplateHelpers)
plugins.implements(plugins.ITranslation)


# IConfigurer

def update_config(self, config_):
toolkit.add_template_directory(config_, "templates")
toolkit.add_public_directory(config_, "public")
Expand All @@ -20,7 +21,16 @@ def update_config(self, config_):
# ITemplateHelpers
def get_helpers(self):
return {
'get_google_tag':h.get_google_tag
'get_google_tag': h.get_google_tag
}


def update_config_schema(self, schema):

ignore_missing = toolkit.get_validator('ignore_missing')
validators = [ignore_missing]
schema.update({
'footer_left': validators,
'footer_right': validators,
})

return schema
13 changes: 13 additions & 0 deletions ckanext/alisea/templates/admin/config.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% ckan_extends %}

{% import 'macros/form.html' as form %}

{% block admin_form %}
{{ h.csrf_input() }}
{{ super() }}

{{ form.markdown('footer_left', label=_('Footer Left'), value=data.footer_left, error=error, placeholder=_('Enter a list of links - one per line - to be shown as a list withing the secondary footer navigation. Please format the links with Markdown (i.e. * [Example link](https://www.example.com)).'), classes=['control-full']) }}

{{ form.markdown('footer_right', label=_('Footer right'), value=data.footer_right, error=error, placeholder=_('Enter a list of links - one per line - to be shown as a list withing the secondary footer navigation. Please format the links with Markdown (i.e. * [Example link](https://www.example.com)).'), classes=['control-full']) }}

{% endblock %}
25 changes: 25 additions & 0 deletions ckanext/alisea/templates/footer.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<footer class="site-footer">
<div class="container">
{% block footer_content %}

<div class="row">
{% include "/snippets/footer_left.html" %}
{% include "/snippets/footer_right.html" %}

</div>
<div class="row">
<div class="col-md-8 footer-links">
</div>
<div class="col-md-4 attribution">
{% block footer_attribution %}
<p>{% trans %}<strong>Powered by</strong> <a class="hide-text ckan-footer-logo" href="http://ckan.org">CKAN</a>{% endtrans %}</p>
{% endblock %}
{% block footer_lang %}
{% snippet "snippets/language_selector.html" %}
{% endblock %}
</div>
</div>
{% endblock %}
</div>
</footer>

11 changes: 11 additions & 0 deletions ckanext/alisea/templates/package/read.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{# Adds dataset-extent map to dataset-page #}
{% ckan_extends %}
{% block package_description %}
{{ super() }}
{# We include a filed "spatial" through ckanext-scheming. It is not in "extras" #}
{# AS set pkg = c.pkg_dict is in template this change is made: c.pkg_dict['spatial'] -> pkg.spatial #}
{% set dataset_extent = pkg.spatial %}
{% if dataset_extent and dataset_extent != "{}" %}
{% snippet "spatial/snippets/dataset_map.html", extent=dataset_extent %}
{% endif %}
{% endblock %}
7 changes: 7 additions & 0 deletions ckanext/alisea/templates/snippets/footer_left.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% if g.footer_left %}
<div class="col-md-4 attribution">
<div class="links">
{{ h.render_markdown(g.footer_left) }}
</div>
</div>
{% endif %}
7 changes: 7 additions & 0 deletions ckanext/alisea/templates/snippets/footer_right.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{% if g.footer_right %}
<div class="col-md-4 attribution">
<div class="links">
{{ h.render_markdown(g.footer_right) }}
</div>
</div>
{% endif %}
Loading