Skip to content

Commit

Permalink
Merge pull request #6465 from OCHA-DAP/fix/HDX-10263-GSC_mobile_pages
Browse files Browse the repository at this point in the history
HDX-10263 - Google Search Console - research why google bot is evalua…
  • Loading branch information
danmihaila authored Oct 29, 2024
2 parents b113f32 + 42b5232 commit aefc7ec
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
{{ data.country_dict.display_name }}
{% endblock %}

{% block links %}
<link rel="alternate" media="{{ h.HDX_CONST('MOBILE_MEDIA') }}" href="{{ h.hdx_switch_url_path(force=False) }}">
{{ super() }}
{% endblock %}

{% block crisis_map %}
{% block crisis_actions %}
{% endblock %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
{% endif %}
</span>
{% endblock %}

{% block links %}
<link rel="alternate" media="{{ h.HDX_CONST('MOBILE_MEDIA') }}" href="{{ h.hdx_switch_url_path(force=False) }}">
{{ super() }}
{% endblock %}

{% block breadcrumb_content %}
{% snippet "snippets/other_breadcrumb_item.html", title=_('Groups'), controller='group', action='index', position=2 %}
<li class="breadcrumb-item active">{{ h.nav_link(data.country_title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
{% asset 'hdx_theme/organizations-styles' %}
{% 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 %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{% asset 'hdx_theme/organization-light-styles' %}
{% endblock -%}

{% block subtitle %}{{ org.title }}{% 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
Expand Up @@ -6,6 +6,8 @@
{% asset 'hdx_theme/search-light-styles' %}
{% endblock -%}

{% block subtitle %}{{ _("Search for a Dataset") }}{% endblock %}

{% block links %}
<link rel="canonical" href="{{ h.hdx_switch_url_path(force=False) }}">
{{ super() }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{% extends "page.html" %}
{% set page_has_mobile_version = True %}

{% block links %}
<link rel="alternate" media="{{ h.HDX_CONST('MOBILE_MEDIA') }}" href="{{ h.hdx_switch_url_path(force=False) }}">
{{ super() }}
{% endblock %}

{% block styles %}
{{ super() }}
{% asset 'hdx_theme/custom-org-search-facets-styles' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
{% set is_sys_admin = c.userobj.sysadmin %}
{% block subtitle %}{{ _('Organisations') }}{% endblock %}

{% block links %}
<link rel="alternate" media="{{ h.HDX_CONST('MOBILE_MEDIA') }}" href="{{ h.hdx_switch_url_path(force=False) }}">
{{ super() }}
{% endblock %}

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

{% block links %}
<link rel="alternate" media="{{ h.HDX_CONST('MOBILE_MEDIA') }}" href="{{ h.hdx_switch_url_path(force=False) }}">
{{ super() }}
{% if 'country_dict' in org_dict %}
{% set group_dict = org_dict %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

{% block subtitle %}{{ data.title or data.name }}{% endblock %}

{% block links %}
<link rel="alternate" media="{{ h.HDX_CONST('MOBILE_MEDIA') }}" href="{{ h.hdx_switch_url_path(force=False) }}">
{{ super() }}
{% endblock %}

{% block breadcrumb_content %}
<li class="breadcrumb-item"><a>{{ data.type }}</a></li>
{% if data.type == 'event' %}
Expand Down
19 changes: 19 additions & 0 deletions ckanext-hdx_theme/ckanext/hdx_theme/util/light_redirect.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,24 @@ def switch_url_path(path=None, force=True):
new_path = urlparse.urlunparse(
parsed_url[0:4] + (query + force_query,) + parsed_url[5:]
)
else:
parsed_url = urlparse.urlparse(new_path)
query_params = urlparse.parse_qs(parsed_url.query, True)

if FORCE_REDIRECT_URL_PARAM in query_params:
del query_params[FORCE_REDIRECT_URL_PARAM]

# Reconstruct the URL
new_query = urlparse.urlencode(query_params, doseq=True)
new_url = urlparse.urlunparse((
parsed_url.scheme,
parsed_url.netloc,
parsed_url.path,
parsed_url.params,
new_query,
parsed_url.fragment
))

new_path = new_url

return new_path

0 comments on commit aefc7ec

Please sign in to comment.