Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

organisations: implement multilingual footer for dedicated #687

Merged
merged 2 commits into from
Nov 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 72 additions & 2 deletions data/organisations/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,42 @@
{
"code": "hepvs",
"name": "HEP Valais",
"description": "Description in **markdown**",
"description": [
{
"language": "ger",
"value": "Description in German in **markdown** format"
},
{
"language": "eng",
"value": "Description in English in **markdown** format"
},
{
"language": "fre",
"value": "Description in French in **markdown** format"
},
{
"language": "ita",
"value": "Description in Italian in **markdown** format"
}
],
"footer": [
{
"language": "ger",
"value": "Footer GER **markdown** format"
},
{
"language": "eng",
"value": "Footer ENG **markdown** format"
},
{
"language": "fre",
"value": "Footer FRE **markdown** format"
},
{
"language": "ita",
"value": "Footer ITA **markdown** format"
}
],
"isShared": true,
"isDedicated": true,
"platformName": "FREDI",
Expand All @@ -40,7 +75,42 @@
{
"code": "unifr",
"name": "Université de Fribourg",
"description": "#### Français\nFOLIA est le serveur de dépôt institutionnel de l'Université de Fribourg (Suisse). Il fournit un accès libre aux publications des chercheurs et chercheuses de l'Université. FOLIA est géré par la Bibliothèque cantonale et universitaire de Fribourg.\n#### Deutsch\nFOLIA ist das institutionelle Repositorium der Universität Freiburg (Schweiz). Es bietet freien Zugang zu den Publikationen der Forschenden der Universität. FOLIA wird von der Kantons- und Universitätsbibliothek Freiburg betreut.\n#### English\nFOLIA is the institutional repository of the University of Fribourg (Switzerland). It provides free access to the publications of the researchers of the University. FOLIA is managed by the Bibliothèque cantonale et universitaire de Fribourg.\n#### Italiano\nFOLIA è l'archivio istituzionale dell'Università di Friburgo (Svizzera). Fornisce un accesso gratuito alle pubblicazioni dei ricercatrici e ricercatori dell'Università. FOLIA è gestito dalla Bibliothèque cantonale et universitaire de Fribourg.",
"description": [
{
"language": "ger",
"value": "FOLIA ist das institutionelle Repositorium der Universität Freiburg (Schweiz). Es bietet freien Zugang zu den Publikationen der Forschenden der Universität. FOLIA wird von der Kantons- und Universitätsbibliothek Freiburg betreut."
},
{
"language": "eng",
"value": "FOLIA is the institutional repository of the University of Fribourg (Switzerland). It provides free access to the publications of the researchers of the University. FOLIA is managed by the Bibliothèque cantonale et universitaire de Fribourg."
},
{
"language": "fre",
"value": "FOLIA est le serveur de dépôt institutionnel de l'Université de Fribourg (Suisse). Il fournit un accès libre aux publications des chercheurs et chercheuses de l'Université. FOLIA est géré par la Bibliothèque cantonale et universitaire de Fribourg."
},
{
"language": "ita",
"value": "FOLIA è l'archivio istituzionale dell'Università di Friburgo (Svizzera). Fornisce un accesso gratuito alle pubblicazioni dei ricercatrici e ricercatori dell'Università. FOLIA è gestito dalla Bibliothèque cantonale et universitaire de Fribourg."
}
],
"footer": [
{
"language": "ger",
"value": "Footer GER **markdown** format"
},
{
"language": "eng",
"value": "Footer ENG **markdown** format"
},
{
"language": "fre",
"value": "Footer FRE **markdown** format"
},
{
"language": "ita",
"value": "Footer ITA **markdown** format"
}
],
"isShared": true,
"isDedicated": true,
"platformName": "# FOLIA\n#### Fribourg Open Library and Archive",
Expand Down
33 changes: 33 additions & 0 deletions sonar/common/jsonschemas/interface_language-v1.0.0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"title": "language",
"type": "string",
"enum": [
"ger",
"eng",
"fre",
"ita"
],
"form": {
"templateOptions": {
"sort": true
},
"options": [
{
"label": "lang_ger",
"value": "ger"
},
{
"label": "lang_eng",
"value": "eng"
},
{
"label": "lang_fre",
"value": "fre"
},
{
"label": "lang_ita",
"value": "ita"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,99 @@
"minLength": 1
},
"description": {
"title": "Description",
"description": "HTML markup admitted.",
"type": "string",
"minLength": 1,
"title": "Descriptions",
"type": "array",
"minItems": 1,
"items": {
"title": "Description",
"type": "object",
"additionalProperties": false,
"properties": {
"value": {
"title": "Value",
"type": "string",
"minLength": 1,
"form": {
"type": "markdown",
"templateOptions": {
"rows": 5
}
}
},
"language": {
"$ref": "interface_language-v1.0.0.json"
}
},
"propertiesOrder": [
"language",
"value"
],
"required": [
"value",
"language"
]
},
"form": {
"type": "markdown",
"templateOptions": {
"rows": 5
"validation": {
"validators": {
"uniqueValueKeysInObject": {
"keys": [
"language"
]
}
},
"messages": {
"uniqueValueKeysInObjectMessage": "Only one value per language is allowed"
}
}
}
},
"footer": {
"title": "Footers",
"type": "array",
"minItems": 1,
"items": {
"title": "Footer",
"type": "object",
"additionalProperties": false,
"properties": {
"value": {
"title": "Value",
"type": "string",
"minLength": 1,
"form": {
"type": "markdown",
"templateOptions": {
"rows": 5
}
}
},
"language": {
"$ref": "interface_language-v1.0.0.json"
}
},
"propertiesOrder": [
"language",
"value"
],
"required": [
"value",
"language"
]
},
"form": {
"hideExpression": "!field.parent.model.isDedicated",
"validation": {
"validators": {
"uniqueValueKeysInObject": {
"keys": [
"language"
]
}
},
"messages": {
"uniqueValueKeysInObjectMessage": "Only one value per language is allowed"
}
}
}
},
Expand Down Expand Up @@ -292,6 +377,7 @@
"code",
"name",
"description",
"footer",
"isShared",
"isDedicated",
"allowedIps",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,26 @@
"type": "keyword"
},
"description": {
"type": "text"
"type": "object",
"properties": {
"language": {
"type": "keyword"
},
"value": {
"type": "text"
}
}
},
"footer": {
"type": "object",
"properties": {
"language": {
"type": "keyword"
},
"value": {
"type": "text"
}
}
},
"name": {
"type": "text",
Expand Down
3 changes: 2 additions & 1 deletion sonar/modules/organisations/marshmallow/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ class OrganisationMetadataSchemaV1(StrictKeysMixin):
pid = PersistentIdentifier()
code = SanitizedUnicode(required=True)
name = SanitizedUnicode(required=True)
description = SanitizedUnicode()
description = fields.List(fields.Dict())
footer = fields.List(fields.Dict())
isShared = fields.Boolean()
isDedicated = fields.Boolean()
allowedIps = SanitizedUnicode()
Expand Down
3 changes: 2 additions & 1 deletion sonar/modules/organisations/serializers/schemas/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class ExportSchemaV1(Schema):

code = fields.String(dump_only=True)
name = fields.String(dump_only=True)
description = fields.String(dump_only=True)
description = fields.List(fields.Dict(dump_only=True))
footer = fields.List(fields.Dict(dump_only=True))
isShared = fields.Boolean(dump_only=True)
isDedicated = fields.Boolean(dump_only=True)
files = fields.Method('get_files', dump_only=True)
Expand Down
27 changes: 22 additions & 5 deletions sonar/theme/templates/sonar/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,19 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
#}

<footer id="footer" class="bg-light mt-5">
<footer id="footer" class="mt-5">
<div class="container">
<div class="row justify-content-center align-items-center">
<div class="col-lg-8 py-4 py-lg-5 text-center text-lg-left">
{% if g.get('organisation', {}).get('isDedicated') and g.organisation.get('footer') %}
<div class="row justify-content-center align-items-center bg-light">
<div class="col py-4 py-lg-5 text-center text-lg-left">
<div class="d-lg-flex flex-row">
{{ g.organisation.footer | language_value | markdown_filter | safe }}
</div>
</div>
</div>
{% else %}
<div class="row justify-content-center align-items-center bg-light">
<div class="col py-4 py-lg-5 text-center text-lg-left">
<div class="d-lg-flex flex-row">
<div>
<a href="{{ url_for('wiki.index') }}">{{ _('Help & Documentation') }}</a>
Expand All @@ -37,8 +46,16 @@
</div>
</div>
</div>
<div class="col-lg-4 py-2 py-lg-5 text-center text-lg-right">
{% trans link="https://www.rero.ch" %}Powered by <a href="{{ link }}" target="_blank" rel="noopener">RERO</a>{% endtrans %}
</div>
{% endif %}
<div class="row justify-content-center align-items-center mt-2">
<div class="col text-center p-0">
<div class="d-lg-flex flex-row">
<div class="col-lg text-center text-lg-right">
{% set link = 'https://www.rero.ch/de/products/sonar' if current_i18n.locale.language == 'de' else 'https://www.rero.ch/produits/sonar' %}
{% trans %}Powered by <a href="{{ link }}" target="_blank" rel="noopener">SONAR</a>{% endtrans %}
</div>
</div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion sonar/theme/templates/sonar/frontpage.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ <h6 class="m-0 mt-1">
{% include config['SONAR_APP_ORGANISATION_CONFIG'][g.organisation.pid]['home_template'] %}
{% else %}
{% if g.organisation.get('description') %}
{{ g.organisation.description | markdown_filter | safe }}
{{ g.organisation.description | language_value | markdown_filter | safe }}
{% endif %}
{% endif %}
</div>
Expand Down
19 changes: 18 additions & 1 deletion sonar/theme/templates/sonar/partial/organisation.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
{# -*- coding: utf-8 -*-
Swiss Open Access Repository
Copyright (C) 2021 RERO

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#}

{% if g.get('organisation') and not g.organisation['isDedicated'] %}
<div class="bg-light py-4">
<div class="container">
Expand All @@ -11,7 +28,7 @@
<div class="col-12 col-lg-{{ '10' if thumbnail else '12' }}">
<h1 class="mb-2">{{ g.organisation.name }}</h1>
{% if g.organisation.get('description') %}
<p class="mb-3 text-justify">{{ g.organisation.description | markdown_filter | safe }}</p>
<p class="mb-3 text-justify">{{ g.organisation.description | language_value | markdown_filter | safe }}</p>
{% endif %}
<div class="row">
<div class="col-12 col-lg-4">
Expand Down
17 changes: 17 additions & 0 deletions sonar/theme/templates/sonar/partial/switch_aai_dropdown.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
{# -*- coding: utf-8 -*-
Swiss Open Access Repository
Copyright (C) 2021 RERO

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
#}

<div class="dropdown">
<button class="btn btn-outline-primary btn-block dropdown-toggle dropdown-toggle-custom" type="button" id="dropdownMenuButton"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Expand Down