Skip to content

Commit

Permalink
Merge pull request #6532 from OCHA-DAP/dev
Browse files Browse the repository at this point in the history
dev into prod
  • Loading branch information
danmihaila authored Feb 6, 2025
2 parents cb2d35f + 740732c commit fc310e9
Show file tree
Hide file tree
Showing 28 changed files with 185 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ $(document).ready(() => {
let resourceUrl = $("#resource-url").html();
let hxlProxyUrl = $("#hxl-proxy-url").html();
console.log(`Loading URL: ${resourceUrl}`);
let previewUrl =`${hxlProxyUrl}/api/data-preview.json?rows=20&sheet=0&url=${resourceUrl}`;
let previewUrl =`${hxlProxyUrl}/api/data-preview.json?rows=0&sheet=0&url=${resourceUrl}`;
$.get(previewUrl).done((response) => {
console.log(response.slice(1));
let columns = response.slice(0,1)[0].map((item) => { return {"title": item}; });
Expand All @@ -14,4 +14,4 @@ $(document).ready(() => {
})


});
});
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ def _prepare_facets_info(self, existing_facets, selected_facets, search_extras,
result = OrderedDict()
result['facets'] = OrderedDict()
result['filters_selected'] = False
result['selected_titles'] = []

for param in FEATURED_FACET_PARAMS:
if param in search_extras:
Expand Down Expand Up @@ -540,13 +541,14 @@ def _prepare_facets_info(self, existing_facets, selected_facets, search_extras,
category_tooltip = 'A data series is a collection of datasets that has a shared topic usually ' \
'provided by a single organization'

standard_facet_category, anything_selected = \
standard_facet_category, anything_selected, selected_titles = \
self._create_standard_facet_category(category_key, category_title, category_tooltip, item_list,
selected_facets)

result['facets'][category_key] = standard_facet_category
result['filters_selected'] = result['filters_selected'] or anything_selected

result['selected_titles'].extend(selected_titles)

cod_category = result['facets'].pop('cod_level', None)
if cod_category:
modified_cod_category = self.__create_featured_cod_facet_category(cod_category)
Expand Down Expand Up @@ -587,6 +589,12 @@ def _prepare_facets_info(self, existing_facets, selected_facets, search_extras,
# self._add_item_to_featured_facets(featured_facet_items, 'ext_archived', 'Archived datasets',
# num_of_archived, search_extras, explanation=archived_explanation)

for item in featured_facet_items:
if item['selected']:
result['selected_titles'].append(item['display_name'])

result['selected_titles_str'] = " ".join([item.replace("-", " ").capitalize() for item in result['selected_titles']])

# result['num_of_indicators'] = num_of_indicators
# result['num_of_cods'] = num_of_cods
result['num_of_subnational'] = num_of_subnational
Expand Down Expand Up @@ -625,6 +633,7 @@ def _create_standard_facet_category(self, category_key, category_title, category
selected_facets):
sorted_item_list = []
anything_selected = False
selected_titles = []
for item in item_list:
item_name = item.get('name', '')
if item_name and item_name.strip():
Expand All @@ -637,6 +646,8 @@ def _create_standard_facet_category(self, category_key, category_title, category
'display_name': item.get('display_name', ''),
'selected': selected,
}
if selected:
selected_titles.append(new_item['display_name'])
sorted_item_list.append(new_item)

sorted_item_list.sort(key=lambda x: ('a' if x.get('selected') else 'b', x.get('display_name')))
Expand All @@ -647,7 +658,7 @@ def _create_standard_facet_category(self, category_key, category_title, category
'tooltip': category_tooltip,
'show_everything': len(sorted_item_list) < 5
}
return standard_facet_category, anything_selected
return standard_facet_category, anything_selected, selected_titles

def _generate_facet_name_to_title_map(self, package_type):
facets = OrderedDict()
Expand Down
14 changes: 5 additions & 9 deletions ckanext-hdx_theme/ckanext/hdx_theme/fanstatic/homepage/count.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,11 @@ ckan.module('count', function ($, _) {
};
})(jQuery),
initialize: function () {
var currentElement = this.el;
$.ajax({
url: this.el.data('url'),
context: document.body
}).done(function(data){
var json = $.parseJSON(data); // create an object with the key of the array
//$(currentElement).html(json.count);
$(currentElement).animateNumbers(json.count, true, 1000);
})
const currentElement = this.el;
const count = parseInt($(currentElement).text());
$(currentElement).text("0");
$(currentElement).animateNumbers(count, true, 1000);

}
};
});
5 changes: 2 additions & 3 deletions ckanext-hdx_theme/ckanext/hdx_theme/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,8 @@
<title>
{%- block title -%}
{%- block subtitle %}{% endblock -%}
{%- if self.subtitle()|trim %} {{ g.template_title_deliminater }} {% endif -%}
- {{ g.site_title }}

{%- if self.subtitle()|trim %}{{ g.template_title_deliminater }}{% endif -%}
{{_(" | HDX")}}
{%- endblock -%}
</title>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@
{% block analytics_group_names %}['{{ data.country_dict.name }}']{% endblock %}
{% block analytics_group_ids %}['{{ data.country_dict.id }}']{% endblock %}

{% block subtitle %}
{{ data.country_dict.display_name }}
{% set num_of_pack = data.stats_section.num_of_datasets %}
{% set num_of_orgs = data.stats_section.num_of_organizations %}

{% block subtitle %}{{ data.country_dict.display_name }} Humanitarian Data | Crisis Response Datasets{% endblock %}
{% block meta %}
{{ super() }}
<meta name="description" content="Access {{ num_of_pack }} humanitarian datasets for {{ data.country_dict.display_name }} from {{ num_of_orgs }} organizations on HDX. Explore data to support crisis response, disaster recovery, and informed decision-making." />
{% endblock %}

{% block links %}
Expand Down Expand Up @@ -41,7 +46,6 @@ <h1 class="country-title">{{ data.country_dict.display_name }}</h1>
<div class="base-actions-menu">
<ul>
<li>
{% set num_of_pack = data.stats_section.num_of_datasets %}
{% if num_of_pack%}
<span class="sspBold14">
<a class="sspBold14" href="?#dataset-filter-start">
Expand All @@ -65,7 +69,6 @@ <h1 class="country-title">{{ data.country_dict.display_name }}</h1>
<li>
<span class="dropdown dropdown-on-hover">
<a href="#" data-bs-toggle="dropdown" data-bs-display="static">
{% set num_of_orgs = data.stats_section.num_of_organizations %}
<span class="sspBold14">{{ num_of_orgs }} {% if num_of_orgs != 1 %}{{ _('Organisations') }}{% else %}{{ _('Organisation') }}{% endif %}</span>
</a>
<div class="followers-list-popup dropdown-menu bottom">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{% extends "faq_others/faq/main.html" %}

{% block subtitle %}{{ _("Resources for Developers") }}{% endblock %}
{% block subtitle %}{{ _("Developer Resources") }} | {{ _("APIs, Documentation, and Guides") }}{% endblock %}
{% block meta_description %}
<meta name="description" content="Access developer resources for HDX, including APIs, documentation, and integration guides. Learn how to access humanitarian datasets and contribute to the platform programmatically." />
{% endblock %}

{% block breadcrumb_content %}
<li class="breadcrumb-item active">{{ h.nav_link(_('Resources for Developers'), named_route='hdx_faqs.read', category='devs') }}</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,20 @@
{% asset 'hdx_theme/faq-styles' %}
{% endblock %}

{% block meta %}
{{ super() }}
<meta name="viewport" content="width=device-width, initial-scale=1">
{% endblock %}

{% block header_core %}
{% set page_has_desktop_version = False %}
{% set page_has_mobile_version = False %}
{% snippet "header-mobile.html", page_has_desktop_version=page_has_desktop_version, page_has_mobile_version=page_has_mobile_version %}
{% endblock %}

{% block subtitle %}{{ _("Frequently Asked Questions") }}{% endblock %}
{% block meta %}
{{ super() }}
<meta name="viewport" content="width=device-width, initial-scale=1">
{% block meta_description %}
<meta name="description" content="Find answers to common questions about using HDX, accessing datasets, contributing data, and more. Explore the FAQ for detailed guidance on humanitarian data." />
{% endblock %}
{% endblock %}

{% block breadcrumb_content %}
<li class="breadcrumb-item active">{{ h.nav_link(_('FAQ'), named_route='hdx_main_faq.main_faq') }}</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{% extends "faq_others/faq/main.html" %}

{% block subtitle %}{{ _("Data Licenses") }}{% endblock %}
{% block subtitle %}{{ _("Data Licenses Explained") }} | {{ _("Usage and Attribution Guidelines") }}{% endblock %}
{% block meta_description %}
<meta name="description" content="Learn about data licenses on HDX, including usage rights, attribution requirements, and guidelines for sharing humanitarian datasets. Ensure compliant data use." />
{% endblock %}

{% block breadcrumb_content %}
<li class="breadcrumb-item active">{{ h.nav_link(_('DATA LICENSES'), named_route='hdx_faqs.read', category='licenses') }}</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{% extends "faq_others/faq/main.html" %}

{% block subtitle %}{{ _("Terms of Service") }}{% endblock %}
{% block meta_description %}
<meta name="description" content="Review the Terms of Service for using the Humanitarian Data Exchange (HDX). Learn about user responsibilities, data usage policies, and platform guidelines." />
{% endblock %}

{% block breadcrumb_content %}
<li class="breadcrumb-item active">{{ h.nav_link(_('TERMS OF SERVICE'), named_route='hdx_faqs.read', category='terms') }}</li>
Expand Down
14 changes: 7 additions & 7 deletions ckanext-hdx_theme/ckanext/hdx_theme/templates/home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

{% set carouselItems = h.hdx_get_carousel_list() %}
{% set mobileCarouselItems = carouselItems|batch(2)|list %}
{% set page_subtitle = data.page_subtitle if data and data.page_subtitle else _("Welcome") %}
{% set page_subtitle = data.page_subtitle if data and data.page_subtitle else _("Humanitarian Data Exchange | Find & Use Crisis Data") %}

{% block subtitle %}{{ page_subtitle }}{% endblock %}

Expand All @@ -18,6 +18,7 @@
{% block meta %}
{{ super() }}
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Access and share humanitarian data across crises and organizations. Explore on HDX {{count.datasets}} datasets from {{count.locations}} locations and {{count.sources}} sources to support effective humanitarian response." />
{% endblock %}

{% block header_core %}
Expand Down Expand Up @@ -50,9 +51,8 @@ <h1 class="section-title">The Humanitarian Data Exchange</h1>
<div class="row">
<div class="col-12 item-count">
<a href="{% url_for 'dataset.search' %}"
data-module="count hdx_click_stopper" data-module-link_type="find data box"
data-url="{% url_for 'hdx_count.dataset' %}">
0
data-module="count hdx_click_stopper" data-module-link_type="find data box">
{{ count.datasets }}
</a>
</div>
</div>
Expand All @@ -68,7 +68,7 @@ <h1 class="section-title">The Humanitarian Data Exchange</h1>
<a href="{% url_for 'group.index' %}"
data-module="count hdx_click_stopper" data-module-link_type="find data box"
data-url="{% url_for 'hdx_count.country' %}">
0
{{ count.locations }}
</a>
</div>
</div>
Expand All @@ -81,10 +81,10 @@ <h1 class="section-title">The Humanitarian Data Exchange</h1>
<div class="col-4">
<div class="row">
<div class="col-12 item-count">
<a href="javascript:void(0);"
<a
data-module="count hdx_click_stopper" data-module-link_type="find data box"
data-url="{% url_for 'hdx_count.source' %}">
0
{{ count.sources }}
</a>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{% extends "page_light.html" %}

{# The line below is for google analytics #}
{% block subtitle %}{{ pkg.title or pkg.name }}{% endblock %}
{% block analytics_org_name %}{{ pkg.organization.name }}{% endblock %}
{% block analytics_org_id %}{{ pkg.organization.id }}{% endblock %}
{% block analytics_is_cod %}{{ analytics.is_cod }}{% endblock %}
Expand All @@ -24,6 +23,14 @@
{% set org_title = pkg.organization.title %}
{% set url_org = h.url_for(controller='organization', action='read', id=pkg.organization.id) or '#' %}

{% set page_title = pkg.title or pkg.name %}
{% block subtitle %}{{ page_title }} | Humanitarian Dataset{% endblock %}

{% block meta %}
{{ super() }}
<meta name="description" content="{{pkg.notes}} Access the {{ page_title }} dataset to support humanitarian efforts." />
{% endblock %}

{% block breadcrumb_content %}
{% block breadcrum_parent_item %}
{% snippet "snippets/other_breadcrumb_item.html", title=_('Dataset'), named_route='hdx_dataset.search', position=2 %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{% extends "page_light.html" %}

{% block subtitle %}{{ _("Locations") }}{% endblock %}
{% block subtitle %}{{ _('Humanitarian Data by Location') }} | {{ _('Country Datasets')}}{% endblock %}
{% block meta %}
{{ super() }}
<meta name="description" content="Explore humanitarian datasets organized by country and region on HDX. Access data for specific locations to support crisis response and decision-making." />
{% endblock %}

{% block breadcrumb_content %}
<li class="breadcrumb-item active">{% link_for _('Locations'), controller='group', action='index' %}</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@
{% block analytics_group_names %}['{{ data.country_dict.name }}']{% endblock %}
{% block analytics_group_ids %}['{{ data.country_dict.id }}']{% endblock %}

{% block subtitle %}
{{ data.country_dict.display_name }}
{% set num_of_pack = data.stats_section.num_of_datasets %}
{% set num_of_orgs = data.stats_section.num_of_organizations %}

{% block subtitle %}{{ data.country_dict.display_name }} Humanitarian Data | Crisis Response Datasets{% endblock %}
{% block meta %}
{{ super() }}
<meta name="description" content="Access {{ num_of_pack }} humanitarian datasets for {{ data.country_dict.display_name }} from {{ num_of_orgs }} organizations on HDX. Explore data to support crisis response, disaster recovery, and informed decision-making." />
{% endblock %}


{% block breadcrumb_content %}
{% block breadcrum_parent_item %}
{% snippet "snippets/other_breadcrumb_item.html", title=_('Locations'), controller='group', action='index', position=2 %}
Expand All @@ -44,7 +50,6 @@ <h1 class="mTop20">{{ grp.title }}</h1>
<span class="base-actions-menu" style="flex-shrink: 1; flex-grow: 1; min-width: 100px;">
<ul>
<li>
{% set num_of_pack = data.stats_section.num_of_datasets %}
{% if num_of_pack%}
<span class="sspBold14">
<a class="sspBold14" href="?#dataset-filter-start">
Expand All @@ -63,7 +68,6 @@ <h1 class="mTop20">{{ grp.title }}</h1>
<span class="sspBold14">{{ num_of_followers }} {% if num_of_followers != 1 %}{{ _('Followers') }}{% else %}{{ _('Follower') }}{% endif %}</span>
</li>
<li>
{% set num_of_orgs = data.stats_section.num_of_organizations %}
<a href="#" >
<span class="sspBold14">{{ num_of_orgs }} {% if num_of_orgs != 1 %}{{ _('Organisations') }}{% else %}{{ _('Organisation') }}{% endif %}</span>
</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,19 @@
{% asset 'hdx_theme/organizations-styles' %}
{% endblock %}

{% block subtitle %}{{ _('Explore Humanitarian Organizations | Data Contributors ') }}{% endblock %}
{% block meta %}
{{ super() }}
<meta name="description" content="Discover {{page.item_count}} organizations contributing reliable humanitarian data on HDX. Explore datasets from global NGOs, UN agencies, and research institutions supporting crisis response." />
{% endblock %}

{% block links %}
<link rel="canonical" href="{{ h.hdx_switch_url_path(force=False) }}">
{{ super() }}
{% endblock %}

{% set logged_in = true if c.userobj else false %}
{% set is_sys_admin = c.userobj.sysadmin %}
{% block subtitle %}{{ _('Organisations') }}{% endblock %}

{% block breadcrumb_content %}
<li class="breadcrumb-item active">{% link_for _('Organisations'), controller='organization', action='index' %}</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,24 @@
{% asset 'hdx_theme/search-light-styles' %}
{% endblock -%}

{% block subtitle %}{{ _("Search for a Dataset") }}{% endblock %}
{% set filters_no = data.full_facet_info.get('selected_titles') | length %}
{% set selected_titles_str = data.full_facet_info.get('selected_titles_str') %}

{% if filters_no < 1 %}
{% set page_title = "Humanitarian Datasets | Find Crisis Data" %}}
{% else %}
{% set page_title = selected_titles_str ~ " Humanitarian Datasets | Find Crisis Data" %}}
{% endif %}

{% block subtitle %}{{page_title}}{% endblock %}
{% block meta %}
{{ super() }}
{% if filters_no < 1 %}
<meta name="description" content="Explore a comprehensive collection of humanitarian datasets curated by HDX. Access reliable data to support crisis response and informed decision-making." />
{% else %}
<meta name="description" content="Explore {{ selected_titles_str }} datasets on HDX. Access reliable data to support humanitarian efforts and informed decision making." />
{% endif %}
{% endblock %}

{% block links %}
<link rel="canonical" href="{{ h.hdx_switch_url_path(force=False) }}">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{% extends "organization/read.html" %}

{% block subtitle %}{{ _('Activity Stream') }} - {{ org_dict.title or org_dict.name }}{% endblock %}
{% block subtitle_suffix %}{{ _('Activity Stream') }}{% endblock %}
{% block meta_description %}
<meta name="description" content="Explore recent activity for the {{ org_dict.display_name }} organization on HDX. Recent dataset updates are listed in this section." />
{% endblock %}


{% block primary_content_inner %}
<h2 class="hide-heading">{% block page_heading %}{{ _('Activity Stream') }}{% endblock %}</h2>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
{% block analytics_org_name %}{{ data.org_info.name }}{% endblock %}
{% block analytics_org_id %}{{ data.org_info.id }}{% endblock %}

{% block subtitle %}{{ data.org_info.display_name }}{% endblock %}
{% block subtitle %}{{ data.org_info.display_name }} Humanitarian Data | {{data.search_template_data.item_count}} Datasets {% endblock %}
{% block meta %}
{{ super() }}
<meta name="description" content="Explore {{data.search_template_data.item_count}} humanitarian datasets from the {{ data.org_info.display_name }} on HDX. Access critical data supporting disaster relief, crisis response, and recovery efforts worldwide." />
{% endblock %}

{% block breadcrumb_content %}
{% snippet "snippets/other_breadcrumb_item.html", title=_('Organizations'), controller='organization', action='index', position=2 %}
Expand Down
Loading

0 comments on commit fc310e9

Please sign in to comment.