Skip to content

Commit

Permalink
asd
Browse files Browse the repository at this point in the history
  • Loading branch information
Pineirin committed Feb 27, 2023
1 parent 93e22ea commit 491edd5
Show file tree
Hide file tree
Showing 11 changed files with 98 additions and 0 deletions.
59 changes: 59 additions & 0 deletions invenio_app_rdm/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from datetime import datetime, timedelta

from celery.schedules import crontab
from flask import url_for
from flask_principal import Denial
from invenio_access.permissions import any_user
from invenio_rdm_records.config import RDM_NAMESPACES
Expand Down Expand Up @@ -701,6 +702,7 @@ def files_rest_permission_factory(obj, action):
"invenio_app_rdm/records/details/side_bar/manage_menu.html",
"invenio_app_rdm/records/details/side_bar/metrics.html",
"invenio_app_rdm/records/details/side_bar/versions.html",
"invenio_app_rdm/records/details/side_bar/external_resources.html",
"invenio_app_rdm/records/details/side_bar/keywords_subjects.html",
"invenio_app_rdm/records/details/side_bar/details.html",
"invenio_app_rdm/records/details/side_bar/licenses.html",
Expand Down Expand Up @@ -829,3 +831,60 @@ def files_rest_permission_factory(obj, action):
("invenio_app_rdm/default_static_page.html", "Default"),
]
"""List of available templates for pages."""

def external_resource_obj(identifiers, badge, icon, title=lambda x: x, subtitle=lambda x: None):
for identifier in identifiers:
if identifier["scheme"] == "url" and badge in identifier.get("identifier", []):
return {
"url": identifier.get("identifier"),
"title": title(identifier.get("identifier")),
"subtitle": subtitle(identifier.get("identifier")),
"icon": icon,
}
return None

def dryad_link_render(identifiers):
return external_resource_obj(identifiers, "datadryad", "dryad.png", lambda x: "Dryad")

def github_link_render(identifiers):
return external_resource_obj(identifiers, "github", "github.png", lambda x: x.replace("https://github.com/", ""))

def openaire_link_render(identifiers):
return external_resource_obj(identifiers, "openaire", "openaire.png", lambda x: "OpenAIRE EXPLORE")

def inspire_link_render(identifiers):
return external_resource_obj(identifiers, "inspirehep", "inspire.png", lambda x: "INSPIRE")

def f1000_link_render(identifiers):
return external_resource_obj(identifiers, "f1000research", "f1000.png", lambda x: "F1000")

def reana_link_render(identifiers):
return external_resource_obj(identifiers, "reanahub", "reana.png", lambda x: "Reana")


APP_RDM_RECORD_LANDING_PAGE_EXTERNAL_LINKS = [
{
"id": "dryad",
"render": dryad_link_render,
},
{
"id": "github",
"render": github_link_render,
},
{
"id": "openaire",
"render": openaire_link_render,
},
{
"id": "inspire",
"render": inspire_link_render,
},
{
"id": "f1000",
"render": f1000_link_render,
},
{
"id": "reana",
"render": reana_link_render,
},
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{#
Copyright (C) 2023 CERN.

Invenio RDM Records is free software; you can redistribute it and/or modify
it under the terms of the MIT License; see LICENSE file for more details.
#}

{% if record.metadata.identifiers %}
<section id="external-resources" aria-label="{{ _('External resources') }}" class="ui segment rdm-sidebar">
<h2 class="ui small header">{{ _('External resources') }}</h2>
{%- for obj in config.get("APP_RDM_RECORD_LANDING_PAGE_EXTERNAL_LINKS", {}) -%}
{% set resource = obj.render(record.metadata.identifiers) %}
{% if resource %}
<div class="content">
<img class="resource-logo" src="{{ url_for('static', filename='images/' + resource.icon) }}" />
<div>
<b><a href="{{ resource.url }}">{{resource.title}}</a></b>
{% if resource.subtitle %}
{{resource.subtitle}}
{% endif %}
</div>
</div>
{% endif %}
{%- endfor -%}
</section>
{% endif %}
Original file line number Diff line number Diff line change
Expand Up @@ -500,3 +500,16 @@ dl.details-list {
.highlight-background {
background-color: @highlightHeaderColor;
}

#external-resources .content {
display: flex;
align-items: center;
}

#external-resources .resource-logo {
flex-shrink: 0;
margin-right: 5px;
align-self: stretch;
aspect-ratio: 1;
height: 20px;
}
Binary file added invenio_app_rdm/theme/static/images/F1000(2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added invenio_app_rdm/theme/static/images/F1000.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added invenio_app_rdm/theme/static/images/INSPIRE.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added invenio_app_rdm/theme/static/images/dryad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added invenio_app_rdm/theme/static/images/github.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added invenio_app_rdm/theme/static/images/openaire.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added invenio_app_rdm/theme/static/images/reana(2).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added invenio_app_rdm/theme/static/images/reana.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 491edd5

Please sign in to comment.