-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
frontpage: Replace recent uploads React version with jinja version
- Loading branch information
Showing
10 changed files
with
217 additions
and
61 deletions.
There are no files selected for viewing
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
20 changes: 1 addition & 19 deletions
20
invenio_app_rdm/theme/assets/semantic-ui/js/invenio_app_rdm/frontpage/index.js
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 |
---|---|---|
@@ -1,23 +1,5 @@ | ||
// This file is part of InvenioRDM | ||
// Copyright (C) 2022 CERN. | ||
// Copyright (C) 2023 CERN. | ||
// | ||
// Invenio 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. | ||
|
||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import { RecordsListOverridable } from "./RecordsList"; | ||
import { OverridableContext, overrideStore } from "react-overridable"; | ||
|
||
const overriddenComponents = overrideStore.getAll(); | ||
const recordsListContainer = document.getElementById("records-list"); | ||
const title = recordsListContainer.dataset.title; | ||
const fetchUrl = recordsListContainer.dataset.fetchUrl; | ||
const appName = "InvenioAppRDM.RecordsList"; | ||
|
||
ReactDOM.render( | ||
<OverridableContext.Provider value={overriddenComponents}> | ||
<RecordsListOverridable title={title} fetchUrl={fetchUrl} appName={appName} /> | ||
</OverridableContext.Provider>, | ||
recordsListContainer | ||
); |
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
54 changes: 54 additions & 0 deletions
54
invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/macros/creators.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,54 @@ | ||
{# | ||
Copyright (C) 2023 CERN | ||
|
||
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. | ||
#} | ||
|
||
{% macro creators(creators=None) %} | ||
{% for creator in creators %} | ||
{% set creator_name = creator.person_or_org.get("name", "No name") if creator.person_or_org %} | ||
{% set ids = creator.person_or_org.get("identifiers", []) if creator.person_or_org %} | ||
|
||
<span class="creatibutor-wrap separated"> | ||
<a | ||
class="creatibutor-link" | ||
href="/search?q=metadata.creators.person_or_org.name:{{ creator_name }}" | ||
title="{{ creator_name }}: {{_('Search')}}" | ||
> | ||
<span class="creatibutor-name">{{ creator_name }}</span> | ||
</a> | ||
|
||
{{ creator_icons(creator_name=creator_name, ids=ids) }} | ||
</span> | ||
{% endfor%} | ||
{% endmacro %} | ||
|
||
|
||
{% macro creator_icons(creator_name=None, ids=None) %} | ||
{% for id in ids %} | ||
{% if id.scheme == "orcid" %} | ||
{% set link = "https://orcid.org/{identifier}".format(identifier=id.identifier) %} | ||
{% set link_title = _("ORCID profile") %} | ||
{% set icon = "/static/images/orcid.svg" %} | ||
|
||
{% elif id.scheme == "ror" %} | ||
{% set link = "https://ror.org/{identifier}".format(identifier=id.identifier) %} | ||
{% set link_title = _("ROR profile") %} | ||
{% set icon = "/static/images/ror-icon.svg" %} | ||
|
||
{% elif id.scheme == "gnd" %} | ||
{% set link = "https://d-nb.info/gnd/{identifier}".format(identifier=id.identifier) %} | ||
{% set link_title = _("GND profile") %} | ||
{% set icon = "/static/images/gnd-icon.svg" %} | ||
{% endif %} | ||
<a | ||
class="no-text-decoration mr-0" | ||
href="{{ link }}" | ||
aria-label="{{ creator_name }}: {{ link_title }}" | ||
title="{{ creator_name }}: {{ link_title }}" | ||
> | ||
<img class="inline-id-icon ml-5" src="{{ icon }}" alt="" /> | ||
</a> | ||
{% endfor %} | ||
{% endmacro %} |
105 changes: 105 additions & 0 deletions
105
invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/macros/record_item.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,105 @@ | ||
{# | ||
Copyright (C) 2023 CERN | ||
|
||
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. | ||
#} | ||
|
||
{% from "invenio_app_rdm/macros/creators.html" import creators %} | ||
|
||
{% macro record_item(record=None) %} | ||
<li class="item"> | ||
<div class="content"> | ||
|
||
{# Top labels #} | ||
<div class="extra labels-actions"> | ||
<div class="ui small horizontal primary label"> | ||
{{ record.ui.publication_date_l10n_long }} ({{ record.ui.version }}) | ||
</div> | ||
<div class="ui small horizontal neutral label"> | ||
{{ record.ui.resource_type.title_l10n }} | ||
</div> | ||
|
||
{% set access_status_id = record.ui.access_status.get("id", "open") %} | ||
{% set access_status = record.ui.access_status.get("title_l10n", _("Open")) %} | ||
{% set access_status_icon = record.ui.access_status.get("icon", "unlock") %} | ||
|
||
<div class="ui small horizontal label access-status {{ access_status_id }}"> | ||
<i class="icon {{ access_status_icon }}" aria-hidden="true"></i> | ||
{{ access_status }} | ||
</div> | ||
</div> | ||
|
||
{# Title #} | ||
<div class="header"> | ||
<a href="/records/{{ record.id }}">{{ record.metadata.title }}</a> | ||
</div> | ||
|
||
{# Creators #} | ||
<div class="ui item creatibutors"> | ||
{% set creators_list = record.ui.creators.creators %} | ||
{% set creators_sliced = creators_list[:3] %} | ||
|
||
{{ creators(creators=creators_sliced) }} | ||
</div> | ||
|
||
{# Description #} | ||
<p class="description"> | ||
{% set description = record.ui.get("description_stripped", "No description") %} | ||
|
||
{{ description | truncate(length=350, end='...') }} | ||
</p> | ||
|
||
<div class="extra"> | ||
<div class="flex justify-space-between align-items-end"> | ||
{# Publishing details #} | ||
{% set created_date = record.ui.created_date_l10n_long %} | ||
{% set publishing_journal = record.ui.publishing_information.get("journal") if record.ui.publishing_information %} | ||
|
||
<small> | ||
{% if created_date %} | ||
{{ _("Uploaded on:")}} {{ created_date }} | ||
{% endif %} | ||
|
||
{% if publishing_journal %} | ||
{{ _("Published in:") }} {{ publishing_journal }} | ||
{% endif %} | ||
</small> | ||
|
||
{# Versions info #} | ||
{% if record.versions.index > 1 %} | ||
<small> | ||
<p>{{ record.versions.index - 1 }} {{ _("more versions exist for this record") }}</p> | ||
</small> | ||
{% endif %} | ||
|
||
{# Statistics #} | ||
{% set unique_downloads = record.stats.all_versions.unique_downloads %} | ||
{% set unique_views = record.stats.all_versions.unique_views %} | ||
|
||
<small> | ||
{% if unique_views is defined %} | ||
<div class="ui transparent label stats-popup" data-variation="tiny"> | ||
<i class="ui eye icon" aria-label="{{ _('Unique views') }}"></i> | ||
{{ unique_views }} | ||
</div> | ||
<div class="ui popup"> | ||
{{ _("Unique views") }} | ||
</div> | ||
{% endif %} | ||
|
||
{% if unique_downloads is defined %} | ||
<div class="ui transparent label stats-popup" data-variation="tiny"> | ||
<i class="ui download icon" aria-label="{{ _('Unique downloads') }}"></i> | ||
{{ unique_downloads}} | ||
</div> | ||
<div class="ui popup"> | ||
{{ _("Unique downloads") }} | ||
</div> | ||
{% endif %} | ||
</small> | ||
</div> | ||
</div> | ||
</div> | ||
</li> | ||
{% endmacro %} |
53 changes: 17 additions & 36 deletions
53
invenio_app_rdm/theme/templates/semantic-ui/invenio_app_rdm/macros/records_list.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 |
---|---|---|
@@ -1,48 +1,29 @@ | ||
{# | ||
Copyright (C) 2019-2022 CERN | ||
Copyright (C) 2023 CERN | ||
|
||
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. | ||
#} | ||
|
||
{% macro records_list( | ||
title="Recent uploads", | ||
fetch_url="/api/records?sort=newest&size=10" | ||
) | ||
%} | ||
<div | ||
id="records-list" | ||
data-fetch-url="{{ fetch_url }}" | ||
data-title="{{ title }}" | ||
> | ||
{% from "invenio_app_rdm/macros/record_item.html" import record_item %} | ||
|
||
<h2 class="ui header">{{ title }}</h2> | ||
{% macro records_list(title=_("Recent uploads"), records=None) %} | ||
<div id="records-list" data-title="{{ title }}"> | ||
|
||
{% for n in range(10) %} | ||
<div class="ui fluid placeholder rel-mt-3"> | ||
<div class="header"> | ||
<div class="line"></div> | ||
</div> | ||
<h2 class="ui header">{{ title }}</h2> | ||
|
||
<div class="paragraph"> | ||
<div class="line"></div> | ||
</div> | ||
|
||
<div class="paragraph"> | ||
<div class="line"></div> | ||
<div class="line"></div> | ||
</div> | ||
|
||
<div class="paragraph"> | ||
<div class="line"></div> | ||
</div> | ||
<div class="ui container rel-mb-2"> | ||
<ul class="ui divided link relaxed items pl-0"> | ||
{% for record in records %} | ||
{{ record_item(record=record) }} | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
|
||
{% if n < 9 %} | ||
<div class="ui divider rel-mt-2 rel-mb-2"></div> | ||
{% endif %} | ||
{% endfor %} | ||
</div> | ||
|
||
{{ webpack["invenio-app-rdm-frontpage.js"]}} | ||
<div class="ui center aligned container"> | ||
<a class="ui button" href="/search" aria-label="{{ _('See more records') }}"> | ||
{{ _("More") }} | ||
</a> | ||
</div> | ||
</div> | ||
{% endmacro %} |
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