forked from OpenDataGIS/ckanext-facet_scheming
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add new home to include detailed stats about portal and categories (themes) with datasets. - Improve header/footer. Move language selector and fix responsive of general web.
- Loading branch information
Showing
14 changed files
with
619 additions
and
117 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
from __future__ import annotations | ||
import logging | ||
from typing import Any | ||
|
||
import ckan.plugins as p | ||
from ckan import types | ||
|
||
import ckanext.schemingdcat.config as sdct_config | ||
from ckanext.schemingdcat.helpers import schemingdcat_update_open_data_statistics | ||
|
||
log = logging.getLogger(__name__) | ||
|
||
def get_subscriptions(): | ||
return { | ||
p.toolkit.signals.action_succeeded: [ | ||
{"sender": "bulk_update_public", "receiver": stats_changed}, | ||
{"sender": "bulk_update_private", "receiver": stats_changed}, | ||
{"sender": "bulk_update_delete", "receiver": stats_changed}, | ||
{"sender": "package_create", "receiver": stats_changed}, | ||
{"sender": "package_update", "receiver": stats_changed}, | ||
{"sender": "package_delete", "receiver": stats_changed}, | ||
{"sender": "group_create", "receiver": stats_changed}, | ||
{"sender": "group_update", "receiver": stats_changed}, | ||
{"sender": "group_delete", "receiver": stats_changed}, | ||
{"sender": "organization_create", "receiver": stats_changed}, | ||
{"sender": "organization_update", "receiver": stats_changed}, | ||
{"sender": "organization_delete", "receiver": stats_changed}, | ||
] | ||
} | ||
|
||
def stats_changed(sender: str, **kwargs: Any): | ||
""" | ||
Handles the event when certain actions are performed and updates site statistics. | ||
Args: | ||
sender (str): The name of the sender that triggered the event. | ||
**kwargs (Any): Additional keyword arguments passed to the function. | ||
Raises: | ||
Exception: If updating site statistics fails, an error is logged. | ||
""" | ||
try: | ||
schemingdcat_update_open_data_statistics() | ||
log.debug(f"schemingdcat subscription -> [{sender}]. Update Open Data site statistics") | ||
except Exception as e: | ||
log.error(f"Failed to Update Open Data site statistics: {e}") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<footer class="site-footer"> | ||
<div class="container"> | ||
{% block footer_content %} | ||
<div class="row d-flex align-items-start"> | ||
<div class="col-md-8 footer-links d-flex flex-column"> | ||
{% block footer_nav %} | ||
<div class="footer-sitelinks"> | ||
<ul class="list-unstyled"> | ||
{% block footer_links_ckan %} | ||
{% set api_url = 'http://docs.ckan.org/en/{0}/api/'.format(g.ckan_doc_version) %} | ||
<li><a href="{{ h.url_for('home.about') }}">{{ _('About {0}').format(g.site_title) }}</a></li> | ||
<li><a href="{{ api_url }}">{{ _('CKAN API') }}</a></li> | ||
<li><a href="http://www.ckan.org/">{{ _('CKAN Association') }}</a></li> | ||
<li><a href="http://www.opendefinition.org/okd/"><img src="{{ h.url_for_static('/base/images/od_80x15_blue.png') }}" alt="Open Data"></a></li> | ||
{% endblock %} | ||
</ul> | ||
</div> | ||
{% endblock %} | ||
</div> | ||
<div class="col-md-4 attribution d-flex flex-column align-items-start"> | ||
{% block footer_attribution %} | ||
<div class="footer-powered-ckan"> | ||
<p>{% trans %}<strong>Powered by</strong> <a class="hide-text ckan-footer-logo" href="http://ckan.org">CKAN</a>{% endtrans %}</p> | ||
</div> | ||
{% endblock %} | ||
{% block footer_social %} | ||
{% set social = h.schemingdcat_get_social_links() %} | ||
<div class="footer-socicons"> | ||
<a href="{{ h.url_for_static_or_external(social.github) }}" class="icon-button"> | ||
<span class="fab fa-github"></span> | ||
</a> | ||
<a href="{{ h.url_for_static_or_external(social.x) }}" class="icon-button"> | ||
<span class="fab fa-twitter"></span> | ||
</a> | ||
<a href="{{ h.url_for_static_or_external(social.linkedin) }}" class="icon-button"> | ||
<span class="fab fa-linkedin"></span> | ||
</a> | ||
</div> | ||
{% endblock %} | ||
</div> | ||
</div> | ||
{% endblock %} | ||
</div> | ||
</footer> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<div role="main"> | ||
<div class="main hero"> | ||
<div class="container"> | ||
<div class="row row1"> | ||
<div class="col-md-12"> | ||
{% block search %} | ||
{% snippet 'home/snippets/search.html', search_facets=search_facets %} | ||
{% endblock %} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="main"> | ||
<div class="container"> | ||
<div class="row row2"> | ||
<div class="col-md-12"> | ||
{% block about_portal %} | ||
{% snippet 'home/snippets/about-portal.html' %} | ||
{% endblock %} | ||
</div> | ||
</div> | ||
<div class="row row2"> | ||
<div class="col-md-6 col1"> | ||
{# Note: this featured_group block is used as an example in the theming | ||
tutorial in the docs! If you change this code, be sure to check | ||
whether you need to update the docs. #} | ||
{# Start template block example. #} | ||
{% block featured_group %} | ||
{% snippet 'home/snippets/featured_group.html' %} | ||
{% endblock %} | ||
{# End template block example. #} | ||
</div> | ||
<div class="col-md-6 col2"> | ||
{% block featured_organization %} | ||
{% snippet 'home/snippets/featured_organization.html' %} | ||
{% endblock %} | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
51 changes: 51 additions & 0 deletions
51
ckanext/schemingdcat/templates/home/snippets/about_portal.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{# | ||
Macro to render a card with an icon, count, label, URL, and aria-label. | ||
|
||
icon_class - The Font Awesome icon class. | ||
count - The count to display on the card. | ||
label - The label to display on the card. | ||
url - The URL the card should link to. | ||
target_blank - Optional boolean to open the link in a new tab with security attributes. | ||
|
||
Example: | ||
|
||
{{ render_card("fas fa-database", 123, "Datasets", "https://example.com", "Example aria label", target_blank=True) }} | ||
#} | ||
|
||
{% set stats = h.schemingdcat_get_open_data_statistics() %} | ||
{% macro render_card(icon_class, count, label, url, target_blank=False) %} | ||
<div class="sct-about-figures-alt-card mt-2"> | ||
<div class="sct-about-figures-alt-card-icon avoindata-explore-showcase"> | ||
<i class="{{ icon_class }}"></i> | ||
</div> | ||
<div class="sct-about-figures-alt-card-content"> | ||
<div class="sct-about-figures-alt-card-title"> | ||
<h3>{{ h.SI_number_span(count) }}</h3> | ||
</div> | ||
<div class="sct-about-figures-alt-card-text"> | ||
<a href="{{ url }}" {% if target_blank %}target="_blank" rel="noopener noreferrer"{% endif %}>{{ label }}</a> | ||
</div> | ||
</div> | ||
</div> | ||
{% endmacro %} | ||
|
||
<section> | ||
<div class="sct-about-figures sct-about-figures--col-3 ecl-u-mv-xl ecl-u-border-color-grey-10 ecl-u-border-width-1 ecl-u-border-all"> | ||
<div class="sct-about-h3-container"> | ||
<h3 class="sct-about-h3">{{ _('Explore and use Open Data') }}</h3> | ||
</div> | ||
<div class="sct-about-figures__items"> | ||
{{ render_card("fas fa-table-list", stats.dataset_count, _('Dataset') if stats.dataset_count == 1 else _('Datasets'), h.url_for(controller='dataset', action='search')) }} | ||
|
||
{{ render_card("fas fa-globe", stats.spatial_dataset_count, _('Spatial dataset') if stats.spatial_dataset_count == 1 else _('Spatial datasets'), h.url_for('dataset.search', dataset_scope='spatial_dataset')) }} | ||
|
||
{{ render_card("fas fa-tags", stats.tag_count, _('Tag') if stats.tag_count == 1 else _('Tags'), h.url_for('api.action', ver=3, logic_function='tag_list'), target_blank=True) }} | ||
|
||
{{ render_card("fa-solid fa-sitemap", stats.organization_count, _('Organization') if stats.organization_count == 1 else _('Organizations'), h.url_for(controller='organization', action='index')) }} | ||
|
||
{{ render_card("fa-solid fa-square-share-nodes", stats.endpoints_count, _('Catalog endpoints'), h.url_for('schemingdcat.endpoint_index')) }} | ||
|
||
{{ render_card("fas fa-folder-open", stats.group_count, _('Group') if stats.group_count == 1 else _('Groups'), h.url_for(controller='group', action='index')) }} | ||
</div> | ||
</div> | ||
</section> |
42 changes: 42 additions & 0 deletions
42
ckanext/schemingdcat/templates/home/snippets/about_themes.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{# | ||
Macro to render a card with an SVG icon, label, and URL. | ||
|
||
icon_path - The path to the SVG icon. | ||
label - The label to display on the card. | ||
count - The count to display on the card. | ||
url - The base URL the card should link to. | ||
param_name - The name of the URL parameter. | ||
param_value - The value of the URL parameter. | ||
target_blank - Optional boolean to open the link in a new tab with security attributes. | ||
|
||
Example: | ||
|
||
{{ render_svg_card("/images/icons/theme/example.svg", "Example Label", 123, "https://example.com", "theme", "example_value", target_blank=True) }} | ||
#} | ||
{% macro render_svg_card(icon_path, label, count, url, param_name, param_value, target_blank=False) %} | ||
<a href="{{ url }}?{{ param_name }}={{ param_value | urlencode }}" class="sct-about-themes-card mt-2" {% if target_blank %}target="_blank" rel="noopener noreferrer"{% endif %}> | ||
<div class="sct-about-themes-card-icon-container"> | ||
<div class="sct-about-themes-card-icon"> | ||
<img src="{{ h.url_for_static(icon_path) }}" alt="{{ label }} icon" /> | ||
</div> | ||
<div class="sct-about-themes-card-count">{{ h.SI_number_span(count) }}</div> | ||
</div> | ||
{% if label|length <= 2 %} | ||
<div class="sct-about-themes-card-acronym">{{ label.upper() }}</div> | ||
{% endif %} | ||
<div class="sct-about-themes-card-label">{{ _(label) }}</div> | ||
</a> | ||
{% endmacro %} | ||
|
||
{% set themes_stats = h.schemingdcat_get_open_data_statistics().themes_stats %} | ||
|
||
<div class="sct-about-themes"> | ||
<div class="sct-about-h4-container"> | ||
<h3 class="sct-about-h4">{{ _('Theme categories') }}</h3> | ||
</div> | ||
<div class="sct-about-themes-card-container"> | ||
{% for theme in themes_stats %} | ||
{{ render_svg_card(theme.icon, theme.label, theme.count, h.url_for('dataset.search'), theme.field_name, theme.value) }} | ||
{% endfor %} | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.