layout: improve

* add frontpage overview

* change recent uploads to global search

* add overview to dashboard

* change default link of the dashboard menu entry from uploads to
  overview

* change text of 'my uploads' buggy
This commit is contained in:
Christoph Ladurner
2023-10-17 23:19:45 +02:00
parent 105db720ea
commit fffd744731
16 changed files with 365 additions and 121 deletions

View File

@@ -150,7 +150,6 @@ pre {
&.metadata-only { &.metadata-only {
background-color: @accessRightMetadata; background-color: @accessRightMetadata;
} }
} }
@font-face { @font-face {
@@ -166,3 +165,15 @@ pre {
font-weight: 400; font-weight: 400;
font-style: italic; font-style: italic;
} }
/**
* mainly for the overview. maybe this should be written more specific to apply
* only for the overview use case.
*/
.ui.segment:first-child {
margin-top: 1em;
}
.ui.equal.height .ui.segment {
height: 100%;
}

View File

@@ -37,3 +37,7 @@
.nowrap-link { .nowrap-link {
white-space: nowrap; white-space: nowrap;
} }
.ui.label.schema {
border: 1px solid #bfb5b5;
}

View File

@@ -23,6 +23,8 @@
@accessRightClosed : @accessRightEmbargoed; @accessRightClosed : @accessRightEmbargoed;
@accessRightMetadata : #2185D0; @accessRightMetadata : #2185D0;
@schema: #17b3f3;
// primary colors TU Graz // primary colors TU Graz
@tugrazBlack: #231f20; @tugrazBlack: #231f20;
@tugrazRed : #e4154b; @tugrazRed : #e4154b;

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# #
# Copyright (C) 2020-2021 Graz University of Technology. # Copyright (C) 2020-2023 Graz University of Technology.
# #
# invenio-theme-tugraz is free software; you can redistribute it and/or # invenio-theme-tugraz is free software; you can redistribute it and/or
# modify it under the terms of the MIT License; see LICENSE file for more # modify it under the terms of the MIT License; see LICENSE file for more
@@ -9,7 +9,6 @@
"""Frontpage records.""" """Frontpage records."""
from invenio_search.api import RecordsSearch from invenio_search.api import RecordsSearch
from invenio_search.engine import dsl
class FrontpageRecordsSearch(RecordsSearch): class FrontpageRecordsSearch(RecordsSearch):
@@ -18,8 +17,4 @@ class FrontpageRecordsSearch(RecordsSearch):
class Meta: class Meta:
"""Default index and filter for frontpage search.""" """Default index and filter for frontpage search."""
index = "rdmrecords-records" index = "dublin-core"
default_filter = dsl.Q(
"query_string",
query=("access.record:public " "AND versions.is_latest:true"),
)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -0,0 +1,104 @@
{#
Copyright (C) 2020-2023 Graz University of Technology.
invenio-theme-tugraz is free software; you can redistribute it and/or
modify it under the terms of the MIT License; see LICENSE file for more
details.
#}
<div class="sixteen wide column random-records-frontpage">
<div class="four column ui equal height grid">
<div class="column">
<div class="ui segment image">
<h2>{{ _("Research Result") }}</h2>
<div>
this is a short description for what research results could be found in this repository. there are three links.
one link will lead you to a browse functionality which shows what is inside of the repository. one link will
lead you to the search page which gives the possibility to search explicitly in the research results. the last
link leads to the upload page to upload new research results to the repository
</div>
<ul>
<li>
<a href="research-results/browse">Browse</a>
</li>
<li>
<a href="records/search">Search</a>
</li>
<li>
<a href="me/uploads">Upload</a>
</li>
</ul>
<!-- <img alt="Research Result" src="{{ url_for('static', filename='images/cyan_400x400.png') }}"> -->
</div>
</div>
<div class="column">
<div class="ui segment image">
<h2>{{ _("Communities") }}</h2>
<div>
this short description shows what communities represents in the repository. there are three links. one will
lead to the browsing feature, one to the search functionality and the last to the creation side.
</div>
<ul>
<li>
<a href="communities/browse">Browse</a>
</li>
<li>
<a href="communities">Search</a>
</li>
<li>
<a href="communities/new">Upload</a>
</li>
</ul>
<!-- <img alt="Communities" src="{{ url_for('static', filename='images/dark_blue_400x400.png') }}"> -->
</div>
</div>
<div class="column">
<div class="ui segment image">
<h2>{{ _("Publications") }}</h2>
<div>
this short description describes what publication means within this repository. there are two links. one lead
to a browse function and one to the search. publications are not meant to be open for everyone, but for
librarians only.
</div>
<ul>
<li>
<a href="publications/browse">Browse</a>
</li>
<li>
<a href="marc/search">Search</a>
</li>
</ul>
<!--<img alt="Publications" src="{{ url_for('static', filename='images/red_400x400.png') }}"> -->
</div>
</div>
<div class="column">
<div class="ui segment image">
<h2>{{ _("OER") }}</h2>
<div>
this short description describes what OER's are. there are three links. as the others already introduced there
is a link to the browse functionality, one to the search and one to the upload. about the upload you get more
information what is necessary to be allowed to upload if you click on the upload button.
</div>
<ul>
<li>
<a href="oer/browse">Browse</a>
</li>
<li>
<a href="lom/search">Search</a>
</li>
<li>
<a href="lom/uploads">Upload</a>
</li>
</ul>
<!--<img alt="Open Educational Resources" src="{{ url_for('static', filename='images/rosa_400x400.png') }}"> -->
</div>
</div>
</div>
</div>

View File

@@ -1,5 +1,5 @@
{# {#
Copyright (C) 2020-2021 Graz University of Technology. Copyright (C) 2020-2023 Graz University of Technology.
invenio-theme-tugraz is free software; you can redistribute it and/or invenio-theme-tugraz is free software; you can redistribute it and/or
modify it under the terms of the MIT License; see LICENSE file for more modify it under the terms of the MIT License; see LICENSE file for more
@@ -37,24 +37,17 @@
transform="translate(-279.72 -403.28)"> transform="translate(-279.72 -403.28)">
</polyline> </polyline>
</svg> </svg>
{{_ ("Home")}} {{ _("Home") }}
</span> </span>
</a> </a>
</div> </div>
{%- for item in current_menu.submenu('main').children|sort(attribute='order') if item.visible recursive %}
<div class="two wide column main-menu-entry"> <div class="two wide column main-menu-entry">
<a role="menuitem" href="{{ item.url }}" class="no-decoration">{{ item.text|safe }}</a> <a role="menuitem" href="/communities" class="no-decoration">{{ _("Communities") }}</a>
</div> </div>
{% endfor %}
{% for item in current_menu.submenu('actions').children|sort(attribute='order') if item.visible recursive %}
<div class="two wide column main-menu-entry"> <div class="two wide column main-menu-entry">
<a role="menuitem" href="{{ item.url }}" class="no-decoration">{{ item.text|safe }}</a> <a role="menuitem" href="/me/overview" class="no-decoration">{{ _("My dashboard") }}</a>
</div> </div>
{% endfor %}
</div> </div>
<div id="margin-divider" class="ui divider main-menu-underline-line"> <div id="margin-divider" class="ui divider main-menu-underline-line">
@@ -73,10 +66,4 @@
{{ flashed_messages() }} {{ flashed_messages() }}
{%- endblock %} {%- endblock %}
</header> </header>
{#
{%- block breadcrumbs %}
{%- include "invenio_theme/breadcrumbs.html" %}
{%- endblock breadcrumbs %}
#}
</div> </div>

View File

@@ -12,8 +12,6 @@
{{ webpack['invenio-theme-tugraz-js.js'] }} {{ webpack['invenio-theme-tugraz-js.js'] }}
{%- endblock javascript %} {%- endblock javascript %}
{%- from "invenio_theme_tugraz/macros/authors.html" import creators -%}
{%- block page_body %} {%- block page_body %}
<div class="ui container"> <div class="ui container">
@@ -21,91 +19,13 @@
<div class="ui stackable grid"> <div class="ui stackable grid">
<!---Recent uploads--> {% include "invenio_theme_tugraz/frontpage_overview.html" %}
<div class="ten wide column random-records-frontpage">
<h2>{{ _('Recent uploads') }}</h2>
{% if not records %}
<div class="ui centered grid">
<p style="font-size: medium;">{{ _('There are no public records to show.') }}</p>
</div>
{% endif %}
{%- for r in records %}
{%- set creation_date = r.created|from_isodatetime -%}
{%- set record_url = url_for('invenio_app_rdm_records.record_detail', pid_value=r.id) %}
<article>
<!--TODO:
something with doi
-->
<div class="badges">
<!--Publication date/Version badge-->
<span class="ui label blue" data-tooltip="{{ _('Publication date') }}" data-inverted="">
{{ r.metadata.publication_date }} {{ '(' ~ r.metadata.version ~ ')' if r.metadata.version }}
</span>
<!--Resource type badge-->
<span class="ui label grey" data-tooltip="{{ _('Resource type') }}" data-inverted>
{{ r.ui.resource_type.title_l10n }}
</span>
<span class="ui label access-status {{ r.ui.access_status.id }}" data-tooltip="{{ r.ui.access_status.description_l10n }}" data-inverted="">
{% if r.ui.access_status.icon %}<i class="icon {{ r.ui.access_status.icon }}"></i>{% endif %}
{{ r.ui.access_status.title_l10n }}
</span>
<span class="label record-version">
<!--TODO: add subtype--->
</span>
</div>
<h4>
<a href="{{ record_url }}" class="no-decoration">
{{ r.metadata.title }}
</a>
</h4>
<p>
{{ creators(r.metadata.creators) }}
</p>
<p class="hidden-xs">
<a href="{{record_url}}" class="no-decoration">
{{ r.metadata.description | striptags | truncate(300) }}
</a>
</p>
<div class="ui grid">
<div class="two column row">
<div class="left floated column">
{%- for s in r.metadata.subjects %}
<div class="ui tiny label">{{ s.subject }}</div>
{%- endfor %}
<div>
<small>
{% trans user=userprofile, date=creation_date | dateformat('long')%}
Uploaded on {{date}}
{% endtrans %}
</small>
</div>
</div>
</div>
</div>
</article>
{%- endfor %}
{% if records %}
<div class="ui centered grid">
<a class="ui button more" href="{{ url_for('invenio_search_ui.search') }}">{{ _('More') }}</a>
</div>
{%- endif %}
</div>
{% include "invenio_theme_tugraz/recent_uploads.html" %}
<!---segments--> <!---segments-->
<div class="six wide column"> <div class="six wide column">
{#
<div class="ui segment" style="padding-bottom: 10px;"> <div class="ui segment" style="padding-bottom: 10px;">
<h4>{{ _("You can upload different types of records:") }}</h4> <h4>{{ _("You can upload different types of records:") }}</h4>
@@ -134,6 +54,7 @@
</div> </div>
</div> </div>
</div> </div>
#}
<!--contact us--> <!--contact us-->
<div class="ui segment"> <div class="ui segment">

View File

@@ -1,5 +1,5 @@
{# {#
Copyright (C) 2020-2022 Graz University of Technology. Copyright (C) 2020-2023 Graz University of Technology.
invenio-theme-tugraz is free software; you can redistribute it and/or invenio-theme-tugraz is free software; you can redistribute it and/or
modify it under the terms of the MIT License; see LICENSE file for more modify it under the terms of the MIT License; see LICENSE file for more
@@ -9,12 +9,12 @@
{% set options = [ {% set options = [
{ {
"key": "records", "key": "records",
"text": _("All") + " " + config.THEME_SITENAME, "text": _("All"),
"value": url_for("invenio_search_ui.search"), "value": url_for("invenio_search_ui.search"),
"title": "repo", "title": "repo",
},{ },{
"key": "rdm", "key": "rdm",
"text": _("Research Data"), "text": _("Research Results"),
"value": "/records/search", "value": "/records/search",
"title": "Research Data", "title": "Research Data",
},{ },{

View File

@@ -0,0 +1,76 @@
{#
Copyright (C) 2020-2023 Graz University of Technology.
invenio-theme-tugraz is free software; you can redistribute it and/or
modify it under the terms of the MIT License; see LICENSE file for more
details.
#}
{%- extends config.INVENIO_THEME_TUGRAZ_BASE_TEMPLATE %}
{%- set active_dashboard_menu_item = 'overview' %}
{%- set title = _("Overview") %}
{%- block page_body %}
{%- block user_dashboard_header %}
{% include "invenio_app_rdm/users/header.html" %}
{%- endblock user_dashboard_header %}
<div class="ui container rel-mt-2">
<h2>Overview</h2>
<div class="ui two column stackable grid overview">
<div class="column">
<div class="ui segment" style="height: 480px">
<h2>{{ _("Research Result") }}</h2>
<div class="ui left floated image">
<img alt="Research Result" src="{{ url_for('static', filename='images/cyan_400x400.png') }}">
</div>
<div class="ui right floated text">
describe research results
</div>
</div>
</div>
<div class="column">
<div class="ui segment" style="height: 480px">
<h2>{{ _("Communities") }}</h2>
<img class="ui left floated image" alt="Communities" src="{{ url_for('static', filename='images/dark_blue_400x400.png') }}">
<div>
describe the communities
</div>
</div>
</div>
<div class="column">
<div class="ui segment" style="height: 480px">
<h2>{{ _("Requests") }}</h2>
<img class="ui left floated image" alt="Requests" src="{{ url_for('static', filename='images/light_green_400x400.png') }}">
<div>
describe requests
</div>
</div>
</div>
<div class="column">
<div class="ui segment" style="height: 480px">
<h2>{{ _("Publications") }}</h2>
<img class="ui left floated image" alt="Publications" src="{{ url_for('static', filename='images/red_400x400.png') }}">
<div>
describe publications
</div>
</div>
</div>
<div class="column">
<div class="ui segment" style="height: 480px">
<h2>{{ _("OER") }}</h2>
<img class="ui left floated image" alt="Open Educational Resources" src="{{ url_for('static', filename='images/rosa_400x400.png') }}">
<div>
describe open educational resources
</div>
</div>
</div>
</div>
</div>
{%- endblock %}

View File

@@ -0,0 +1,101 @@
{#
Copyright (C) 2020-2023 Graz University of Technology.
invenio-theme-tugraz is free software; you can redistribute it and/or
modify it under the terms of the MIT License; see LICENSE file for more
details.
#}
<!---Recent uploads-->
<div class="ten wide column random-records-frontpage">
<h2>{{ _("Recent uploads") }}</h2>
{% if not records %}
<div class="ui centered grid">
<p style="font-size: medium;">{{ _("There are no public records to show.") }}</p>
</div>
{% endif %}
{%- for r in records %}
{%- set creation_date = r.created | from_isodatetime -%}
{%- set record_url = r.original.view %}
<article>
<div class="badges">
<!--Publication date/Version badge-->
<span class="ui label blue" data-tooltip="{{ _('Publication date') }}" data-inverted="">
{{ r.metadata.dates[0] }}
</span>
<!--Resource type badge-->
<span class="ui label grey" data-tooltip="{{ _('Resource type') }}" data-inverted>
{%- for type in r.metadata.types %}
{{ type }}
{%- endfor %}
</span>
<span class="ui label access-status {{ r.access_status.id }}" data-tooltip="{{
r.access_status.description_l10n }}" data-inverted="">
<i class="icon {{ r.access_status.icon }}"></i>
{{ r.access_status.title_l10n }}
</span>
<span class="ui label schema">
{%- if r.original.schema == "lom" %}
{{ _("OER") }}
{%- elif r.original.schema == "rdm" %}
{{ _("Research Result") }}
{%- elif r.original.schema == "marc21" %}
{{ _("Publication") }}
{%- endif %}
</span>
</div>
<h4>
<a href="{{ record_url }}" class="no-decoration">
{{ r.metadata.titles[0] }}
</a>
</h4>
<p>
{%- for creator in r.metadata.creators %}
<span>{{ creator }}</span>
{%- endfor %}
</p>
<p class="hidden-xs">
<a href="{{record_url}}" class="no-decoration">
{{ r.metadata.descriptions | join(" ") | striptags | truncate(300) }}
</a>
</p>
<div class="ui grid">
<div class="two column row">
<div class="left floated column">
{%- for subject in r.metadata.subjects %}
<div class="ui tiny label">{{ subject }}</div>
{%- endfor %}
<div>
<small>
{#
{% trans user=userprofile, date=creation_date | dateformat("long")%}
Uploaded on {{date}}
{% endtrans %}
#}
</small>
</div>
</div>
</div>
</div>
</article>
{%- endfor %}
{% if records %}
<div class="ui centered grid">
<a class="ui button more" href="{{ url_for('invenio_search_ui.search') }}">{{ _("More") }}</a>
</div>
{%- endif %}
</div>

View File

@@ -10,8 +10,14 @@
from typing import Dict from typing import Dict
from flask import Blueprint, render_template from flask import Blueprint, g, render_template
from invenio_rdm_records.resources.serializers import UIJSONSerializer from flask_login import current_user, login_required
from flask_menu import current_menu
from invenio_i18n import lazy_gettext as _
# from invenio_rdm_records.resources.serializers import UIJSONSerializer
from invenio_records_dublin_core.resources.serializers import DublinCoreJSONSerializer
from invenio_users_resources.proxies import current_user_resources
from opensearch_dsl.utils import AttrDict from opensearch_dsl.utils import AttrDict
from .search import FrontpageRecordsSearch from .search import FrontpageRecordsSearch
@@ -24,6 +30,19 @@ blueprint = Blueprint(
) )
@blueprint.route("/me/overview")
@login_required
def overview():
"""Overview."""
url = current_user_resources.users_service.links_item_tpl.expand(
g.identity, current_user
)["avatar"]
return render_template(
"invenio_theme_tugraz/overview.html",
user_avatar=url,
)
@blueprint.app_template_filter("make_dict_like") @blueprint.app_template_filter("make_dict_like")
def make_dict_like(value: str, key: str) -> Dict[str, str]: def make_dict_like(value: str, key: str) -> Dict[str, str]:
"""Convert the value to a dict like structure. """Convert the value to a dict like structure.
@@ -39,6 +58,32 @@ def cast_to_dict(attr_dict):
return AttrDict.to_dict(attr_dict) return AttrDict.to_dict(attr_dict)
@blueprint.before_app_first_request
def modify_user_dashboard():
"""Modify user dashboard."""
user_dashboard_menu = current_menu.submenu("dashboard")
# order matters, this has to be here, otherwise it want override the orginal
# entry
user_dashboard_menu.submenu("uploads").register(
"invenio_app_rdm_users.uploads",
text=_("Research Results"),
order=1,
)
user_dashboard_menu.submenu("overview").register(
"invenio_theme_tugraz.overview",
text=_("Overview"),
order=0,
)
current_menu.submenu("actions.deposit").register(
"invenio_theme_tugraz.overview",
_("My dashboard"),
order=1,
)
def ui_blueprint(app): def ui_blueprint(app):
"""Blueprint for the routes and resources provided by Invenio-theme-tugraz.""" """Blueprint for the routes and resources provided by Invenio-theme-tugraz."""
routes = app.config.get("TUG_ROUTES") routes = app.config.get("TUG_ROUTES")
@@ -51,10 +96,8 @@ def ui_blueprint(app):
def records_serializer(records=None): def records_serializer(records=None):
"""Serialize list of records.""" """Serialize list of records."""
record_list = [] serializer = DublinCoreJSONSerializer()
for record in records: return [serializer.dump_obj(r.to_dict()) for r in records]
record_list.append(UIJSONSerializer().dump_obj(record.to_dict()))
return record_list
def index(): def index():