From de06337ae2d30c4227fda4fbaa7d620352007c00 Mon Sep 17 00:00:00 2001 From: mb Date: Fri, 17 Jul 2020 15:12:30 +0200 Subject: [PATCH] frontpage data first draft designing the frontpage with recent uploads and segment for contact us. --- .../less/invenio_theme_tugraz/frontpage.less | 30 +++ .../less/invenio_theme_tugraz/theme.less | 1 + invenio_theme_tugraz/config.py | 2 +- invenio_theme_tugraz/search.py | 30 +++ .../templates/invenio_theme_tugraz/index.html | 189 ++++++++---------- .../invenio_theme_tugraz/macros/authors.html | 26 +++ invenio_theme_tugraz/views.py | 7 +- setup.py | 12 ++ 8 files changed, 190 insertions(+), 107 deletions(-) create mode 100644 invenio_theme_tugraz/assets/semantic-ui/less/invenio_theme_tugraz/frontpage.less create mode 100644 invenio_theme_tugraz/search.py create mode 100644 invenio_theme_tugraz/templates/invenio_theme_tugraz/macros/authors.html diff --git a/invenio_theme_tugraz/assets/semantic-ui/less/invenio_theme_tugraz/frontpage.less b/invenio_theme_tugraz/assets/semantic-ui/less/invenio_theme_tugraz/frontpage.less new file mode 100644 index 0000000..ddae5b5 --- /dev/null +++ b/invenio_theme_tugraz/assets/semantic-ui/less/invenio_theme_tugraz/frontpage.less @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 TUGRAZ. + * Copyright (C) 2020 mojib wali. + * + * 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. + */ + +h4{ + display: block; + margin-block-start: 1.33em; + margin-block-end: 1.33em; + margin-inline-start: 0px; + margin-inline-end: 0px; +} + +h2{ + margin-block-start: 0.83em; + margin-block-end: 0.83em; + margin-inline-start: 0px; + margin-inline-end: 0px; +} + +p{ + display: block; + margin-block-start: 1em; + margin-block-end: 1em; + margin-inline-start: 0px; + margin-inline-end: 0px; +} diff --git a/invenio_theme_tugraz/assets/semantic-ui/less/invenio_theme_tugraz/theme.less b/invenio_theme_tugraz/assets/semantic-ui/less/invenio_theme_tugraz/theme.less index 0ad4ef5..03b19e2 100644 --- a/invenio_theme_tugraz/assets/semantic-ui/less/invenio_theme_tugraz/theme.less +++ b/invenio_theme_tugraz/assets/semantic-ui/less/invenio_theme_tugraz/theme.less @@ -9,6 +9,7 @@ @import "header"; @import "footer"; @import "overrides"; +@import "frontpage"; @import (css) url("https://fonts.googleapis.com/css?family=Source+Sans+Pro&display=swap"); diff --git a/invenio_theme_tugraz/config.py b/invenio_theme_tugraz/config.py index 492a25c..c1719cb 100644 --- a/invenio_theme_tugraz/config.py +++ b/invenio_theme_tugraz/config.py @@ -43,7 +43,7 @@ THEME_FOOTER_TEMPLATE = 'invenio_theme_tugraz/footer.html' THEME_FRONTPAGE_TITLE = _('Frontpage Title') """Frontpage title.""" -THEME_SITENAME = _('Application Name') +THEME_SITENAME = _('Repository') """Site name.""" # Invenio-accounts diff --git a/invenio_theme_tugraz/search.py b/invenio_theme_tugraz/search.py new file mode 100644 index 0000000..a956243 --- /dev/null +++ b/invenio_theme_tugraz/search.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2020 TU Graz. +# Copyright (C) 2020 mojib wali. +# +# 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. + +"""Frontpage records.""" + +from __future__ import absolute_import, print_function + +from elasticsearch_dsl.query import Q +from invenio_search.api import RecordsSearch + + +class FrontpageRecordsSearch(RecordsSearch): + """Search class for records that goes on the frontpage.""" + + class Meta: + """Default index and filter for frontpage search.""" + + index = 'records' + default_filter = Q( + 'query_string', + query=( + 'access_right:open ' + ) + ) diff --git a/invenio_theme_tugraz/templates/invenio_theme_tugraz/index.html b/invenio_theme_tugraz/templates/invenio_theme_tugraz/index.html index c273cfa..79ed2c5 100644 --- a/invenio_theme_tugraz/templates/invenio_theme_tugraz/index.html +++ b/invenio_theme_tugraz/templates/invenio_theme_tugraz/index.html @@ -9,122 +9,103 @@ {%- extends config.INVENIO_THEME_TUGRAZ_BASE_TEMPLATE %} +{%- from "invenio_theme_tugraz/macros/authors.html" import authors -%} + + {%- block page_body %}
- {{_('Welcome to %(module_name)s', module_name=module_name)}} - -

- - Features -

+
-
+
+

{{_('Recent uploads')}}

-
-
-
-

Research-Data

-

- Research data can take many forms. It might be: - documents, spreadsheets - laboratory notebooks, field notebooks, diaries - questionnaires, transcripts, codebooks - audiotapes, videotapes - photographs, films - test responses - slides, artefacts, specimens, samples - collections of digital outputs - data files - database contents (video, audio, text, images) - models, algorithms, scripts - contents of an application (input, output, logfiles for analysis software, simulation software, schemas) - methodologies and workflows - standard operating procedures and protocols -

-
-
-

Open educational resources (OER)

-

Open educational resources (OER) are freely accessible, openly licensed text, media, and other digital assets - that are useful for teaching, learning, and assessing as well as for research purposes.

+ {%- for r in records %} + {%- set creation_date = r._created|from_isodatetime -%} + {%- set record_url = url_for('invenio_records_ui.recid', pid_value=r['recid']) %} + + + {{_('View')}} + +
+ + + {{ r.publication_date }} + {{ (' | ' ~ r.version ~ '') if r.version else ' | Version' }} + + + {{r.resource_type.type}} + + + + + {{_('Open Access')}}
+ +

{{r.titles[0].title}}

+

{{ authors(r.creators) }}

+ + + +
{% trans user=userprofile, date=creation_date|dateformat('long') %}Uploaded on + {{date}}{% endtrans %}
+ + {%- if not loop.last %} +
+ {%- else%} + {{_('More')}} + {%- endif %} + {%- endfor %}
-
-
-

Thesis

-

A thesis statement focuses your ideas into one or two sentences. It should present the topic of your paper - and also make a comment about your position in relation to the topic. Your thesis statement should tell your - reader what the paper is about and also help guide your writing and keep your argument focused.

+ + + +
+ + +
+

Need help?

+ +

{{config.THEME_SITENAME}} prioritizes all requested related to the COVID-19 outbreak.

+

We can help with:

+ +
    +
  • Uploading your research data, software, preprints, etc.
  • +
  • One-on-one with {{config.THEME_SITENAME}} supporters.
  • +
  • Quota increases beyond our default policy.
  • +
  • Scripts for automated uploading of larger datasets.
  • +
+
-
-

Publications

-

To publish is to make content available to the general public. While specific use of the term may vary among - countries, it is usually applied to text, images, or other audio-visual content, including paper. The word - publication means the act of publishing, and also refers to any printed copies.

+ +
+

Why use {{config.THEME_SITENAME}}?

+
    +
  • Safe — your research is stored safely for the future in CERN’s Data Centre for as long as + CERN exists.
  • +
  • Trusted — built and operated by CERN and OpenAIRE to ensure that everyone can join in + Open Science.
  • +
  • Citeable — every upload is assigned a Digital Object Identifier (DOI), to make them + citable and trackable.
  • +
  • No waiting time — Uploads are made available online as soon as you hit publish, and your + DOI is registered within seconds.
  • +
  • Open or closed — Share e.g. anonymized clinical trial data with only medical + professionals via our restricted access mode.
  • +
  • Versioning — Easily update your dataset with our versioning feature.
  • +
  • Usage statisics — All uploads display standards compliant usage statistics
  • +
+ +
-
- - -
- - -

- - Statistic -

- - -
- -
-
-
- 15000 -
-
- Recorda -
-
- - -
-
- 30 -
-
- Communities -
-
- -
-
- 500 -
-
- Users -
-
- -
-
- 50 -
-
- Members -
-
- - -
- - -
- -
-{%- endblock %} +
+{%- endblock %} \ No newline at end of file diff --git a/invenio_theme_tugraz/templates/invenio_theme_tugraz/macros/authors.html b/invenio_theme_tugraz/templates/invenio_theme_tugraz/macros/authors.html new file mode 100644 index 0000000..4105f32 --- /dev/null +++ b/invenio_theme_tugraz/templates/invenio_theme_tugraz/macros/authors.html @@ -0,0 +1,26 @@ +{# + Copyright (C) 2020 Zenodo + Copyright (C) 2020 TUGRAZ + Copyright (C) 2020 mojib wali. + + 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. + #} + +{%- macro authors(authors_list) %} +{%- for author in authors_list %} +{%- if author.orcid %} + +{%- endif %} +{{author.name}}{% if not loop.last %}; {% endif %} +{%- endfor %} +{%- endmacro %} + + +{%- macro contributors(contributors_list) %} +{%- for group in contributors_list|groupby('type')%} +
{{group.grouper|contributortype_title}}(s)
+{{authors(group.list)}} +{%- endfor %} +{%- endmacro %} \ No newline at end of file diff --git a/invenio_theme_tugraz/views.py b/invenio_theme_tugraz/views.py index b7b4ad8..7e556cb 100644 --- a/invenio_theme_tugraz/views.py +++ b/invenio_theme_tugraz/views.py @@ -14,6 +14,8 @@ from flask import Blueprint, render_template from flask_babelex import gettext as _ +from .search import FrontpageRecordsSearch + blueprint = Blueprint( 'invenio_theme_tugraz', __name__, @@ -24,7 +26,8 @@ blueprint = Blueprint( @blueprint.route("/") def index(): - """Render a basic view.""" + """Render frontpage view.""" return render_template( "invenio_theme_tugraz/index.html", - module_name=_('invenio-theme-tugraz')) + module_name=_('invenio-theme-tugraz'), + records=FrontpageRecordsSearch()[:10].sort('-_created').execute(),) diff --git a/setup.py b/setup.py index f0f18fa..3e5db2a 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,15 @@ extras_require = { 'docs': [ 'Sphinx>=1.5.1', ], + 'mysql': [ + 'invenio-db[mysql]>=1.0.0', + ], + 'postgresql': [ + 'invenio-db[postgresql]>=1.0.0', + ], + 'sqlite': [ + 'invenio-db>=1.0.0', + ], 'tests': tests_require, } @@ -46,6 +55,9 @@ install_requires = [ 'Flask-WebpackExt>=1.0.0', 'invenio-assets>=1.2.0,<1.3.0', 'invenio-i18n>=1.2.0', + 'elasticsearch_dsl>=7.2.1', + 'invenio_search>=1.3.1', + ] packages = find_packages()