Skip to content

Commit

Permalink
horizon: update header, footer and redirection
Browse files Browse the repository at this point in the history
formatting: fixed formatting issues
  • Loading branch information
Fatimah authored and kpsherva committed Feb 9, 2024
1 parent 7f9cdd9 commit 8364721
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 33 deletions.
6 changes: 6 additions & 0 deletions site/zenodo_rdm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .params import ZenodoArgsSchema, ZenodoSearchOptions
from .redirector import (
communities_detail_view_function,
communities_home_view_function,
communities_records_search,
communities_requests_view_function,
communities_settings_view_function,
Expand Down Expand Up @@ -232,6 +233,11 @@
"rule_options": {"strict_slashes": False},
"target": communities_settings_view_function,
},
"redirect_communities_home": {
"source": "/communities/<community_id>",
"rule_options": {"strict_slashes": False},
"target": communities_home_view_function,
},
"redirect_communities_search": {
"source": "/communities/<community_id>/search",
"rule_options": {"strict_slashes": False},
Expand Down
32 changes: 32 additions & 0 deletions site/zenodo_rdm/redirector.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@

"""Redirector functions and rules."""

from urllib.parse import urlencode

from flask import abort, current_app, request, url_for
from invenio_app_rdm.redirector.resource import RedirectorConfig, RedirectorResource
from invenio_communities import current_communities
from invenio_records_resources.services.base.config import FromConfig
from invenio_requests.proxies import current_requests_service

Expand Down Expand Up @@ -77,6 +80,35 @@ def communities_settings_view_function():
return target


def communities_home_view_function():
"""Implements redirector view function for community landing page.
The following routes are redirected as follows:
- /communities/<community_id>/ -> GET /communities/<community_id>/records
- /communities/<community_id>?q=<query> -> GET /communities/<community_id>/records?q=<query>
:return: url for the view 'invenio_app_rdm_communities.communities_detail'
:rtype: str
"""
_id = request.view_args["community_id"]
community = current_communities.service.record_cls.pid.resolve(_id)
values = {"pid_value": _id}
query_params = request.args

if query_params:
# If there are query parameters, redirect to records page
query_string = urlencode(query_params)
url = url_for("invenio_app_rdm_communities.communities_detail", **values)
target = f"{url}?{query_string}"
return target
elif community.theme and community.theme.get("enabled", False):
# If theme is enabled, redirect to the home page of the community
return url_for("invenio_communities.communities_home", **values)
else:
# If theme is not enabled and no query parameters, redirect to records page of the community
return url_for("invenio_app_rdm_communities.communities_detail", **values)


def communities_requests_view_function():
"""Implements redirector view function for communities requests.
Expand Down
42 changes: 14 additions & 28 deletions templates/themes/horizon/invenio_app_rdm/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Invenio App RDM is free software; you can redistribute it and/or modify it
under the terms of the MIT License; see LICENSE file for more details.
#}

{% set horizon_url="https://about.zenodo.org/projects/horizon-zen/" %}
<div class="footer-top theme-primary horizon-footer">
<div class="ui container">

Expand All @@ -30,36 +32,20 @@ <h2 class="ui small header">{{ _("Contact") }}</h2>
<div class="ui grid">
<div class="three wide five wide tablet column">
<h2 class="ui small header">{{ _("About") }}</h2>
{% trans invenio_rdm_chatroom="https://discord.gg/8qatqBC" %}
<p><a href="{{ invenio_rdm_chatroom }}">How it works?</a></p>
{% endtrans %}
{% trans invenio_rdm_talk="https://invenio-talk.web.cern.ch/c/projects/invenio-rdm" %}
<p><a href="{{ invenio_rdm_talk }}">FAQ</a></p>
{% endtrans %}
{% trans invenio_events="https://inveniosoftware.org/events/" %}
<p><a href="{{ invenio_events }}">Contact</a></p>
{% endtrans %}
<p><a href="{{ horizon_url }}">How it works?</a></p>
<p><a href="{{ horizon_url }}">FAQ</a></p>
<p><a href="https://about.zenodo.org/contact">Contact</a></p>
</div>
<div class="three wide computer five wide tablet column">
<h2 class="ui small header">{{ _("FAIR publishing") }}</h2>
{% trans invenio_rdm_chatroom="https://discord.gg/8qatqBC" %}
<p><a href="{{ invenio_rdm_chatroom }}">Getting started </a></p>
{% endtrans %}
{% trans invenio_rdm_talk="https://invenio-talk.web.cern.ch/c/projects/invenio-rdm" %}
<p><a href="{{ invenio_rdm_talk }}">Submit your research</a></p>
{% endtrans %}
</div>
<div class="three wide computer five wide tablet column">
<h2 class="ui small header">{{ _("Integrations") }}</h2>
{% trans invenio_rdm_chatroom="https://discord.gg/8qatqBC" %}
<p><a href="{{ invenio_rdm_chatroom }}">REST API</a></p>
{% endtrans %}
{% trans invenio_rdm_talk="https://invenio-talk.web.cern.ch/c/projects/invenio-rdm" %}
<p><a href="{{ invenio_rdm_talk }}">OAI-PMH</a></p>
{% endtrans %}
{% trans invenio_events="https://inveniosoftware.org/events/" %}
<p><a href="{{ invenio_events }}">FAIR Evaluation tools</a></p>
{% endtrans %}
<p><a href="{{ horizon_url }}">Getting started </a></p>
<p><a href="{{community.slug}}/upload">Submit your research</a></p>
</div>
<div class="three wide computer five wide tablet column">
<h2 class="ui small header">{{ _("Integrations") }}</h2>
<p><a href="https://developers.zenodo.org/">REST API</a></p>
<p><a href="https://developers.zenodo.org/#oai-pmh/">OAI-PMH</a></p>
<p><a href="{{ horizon_url }}">FAIR Evaluation tools</a></p>
</div>
</div>
</div>
Expand All @@ -68,4 +54,4 @@ <h2 class="ui small header">{{ _("Integrations") }}</h2>
</div>

</div>

16 changes: 11 additions & 5 deletions templates/themes/horizon/invenio_communities/details/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<div class="ui relaxed container grid">
<div class="row pb-0">
<div
class="sixteen wide mobile sixteen wide tablet thirteen wide computer column">
class="sixteen wide mobile sixteen wide tablet twelve wide computer column">
<div
class="community-header flex align-items-center column-mobile align-items-start-mobile">
<div class="flex align-items-center">
Expand Down Expand Up @@ -106,15 +106,21 @@ <h1 class="ui medium header mb-0">{{ community.metadata.title }} </h1>
</div>
</div>

<div
class="sixteen wide mobile sixteen wide tablet three wide computer right aligned middle aligned column">
<div
class="sixteen wide mobile sixteen wide tablet four wide computer right aligned middle aligned column">
{%- if not community_use_jinja_header %}
<a href="/uploads/new?community={{ community.slug }}"
class="ui positive button labeled icon rel-mt-1 theme-secondary">
class="ui positive button labeled icon rel-mt-1 theme-secondary">
<i class="upload icon" aria-hidden="true"></i>
{{ _("New upload") }}
</a>
{% endif %}
{% endif %}
<a href="{{'/support/'}}"
target="_blank"
class="ui positive item button labeled theme-primary icon rel-mt-1">
<i class="users icon" aria-hidden="true"></i>
{{ _("Join waiting list") }}
</a>
{% if permissions.can_moderate %}
<a
href="{{ url_for('administration.communities', q='slug:'+community.slug) }}"
Expand Down

0 comments on commit 8364721

Please sign in to comment.