diff --git a/sonar/config.py b/sonar/config.py index 336caece..e1ad7952 100644 --- a/sonar/config.py +++ b/sonar/config.py @@ -44,7 +44,8 @@ def _(x): BABEL_DEFAULT_TIMEZONE = 'Europe/Zurich' #: Other supported languages (do not include the default language in list). I18N_LANGUAGES = [ - ('fr', _('French')) + ('fr', _('French')), + ('de', _('German')) ] # Base templates @@ -179,6 +180,7 @@ def _(x): SEARCH_UI_JSTEMPLATE_SELECT_BOX = 'templates/documents/search_ui/'\ 'select_box.html' SEARCH_UI_JSTEMPLATE_LOADING = 'templates/documents/search_ui/loading.html' +SEARCH_UI_JSTEMPLATE_FACETS = 'templates/documents/search_ui/facets.html' SECURITY_LOGIN_USER_TEMPLATE = 'sonar/accounts/login.html' SECURITY_FORGOT_PASSWORD_TEMPLATE = 'sonar/accounts/forgot_password.html' @@ -265,13 +267,48 @@ def _(x): RECORDS_REST_FACETS = { 'documents': dict( + aggs=dict( + institution=dict(terms=dict(field='institution.pid')), + language=dict(terms=dict(field='languages.language')), + author=dict(terms=dict(field='facet_authors')), + subject=dict(terms=dict(field='facet_subjects')) + ), filters={ - _('institution'): terms_filter('institution.pid') + _('institution'): terms_filter('institution.pid'), + _('language'): terms_filter('languages.language'), + _('author'): terms_filter('facet_authors'), + _('subject'): terms_filter('facet_subjects'), } ) } """REST search facets.""" +RECORDS_REST_SORT_OPTIONS = dict( + documents=dict( + bestmatch=dict( + title=_('Best match'), + fields=['_score'], + default_order='desc', + order=2, + ), + mostrecent=dict( + title=_('Most recent'), + fields=['-_created'], + default_order='asc', + order=1, + ), + ) +) +"""Setup sorting options.""" + +RECORDS_REST_DEFAULT_SORT = dict( + documents=dict( + query='bestmatch', + noquery='mostrecent', + ), +) +"""Set default sorting options.""" + SONAR_ENDPOINTS_ENABLED = True """Enable/disable automatic endpoint registration.""" diff --git a/sonar/modules/documents/dojson/contrib/marc21tojson/model.py b/sonar/modules/documents/dojson/contrib/marc21tojson/model.py index 5753767c..19ee78c1 100644 --- a/sonar/modules/documents/dojson/contrib/marc21tojson/model.py +++ b/sonar/modules/documents/dojson/contrib/marc21tojson/model.py @@ -380,7 +380,6 @@ def marc21_to_is_part_of(self, key, value): @marc21tojson.over('subjects', '^6....') -@utils.for_each_value @utils.ignore_value def marc21_to_subjects(self, key, value): """Get subjects. @@ -388,4 +387,4 @@ def marc21_to_subjects(self, key, value): subjects: 6xx [duplicates could exist between several vocabularies, if possible deduplicate] """ - return value.get('a') + return value.get('a').split(' ; ') diff --git a/sonar/modules/documents/mappings/v6/documents/document-v1.0.0.json b/sonar/modules/documents/mappings/v6/documents/document-v1.0.0.json index f61046a2..77ff0583 100644 --- a/sonar/modules/documents/mappings/v6/documents/document-v1.0.0.json +++ b/sonar/modules/documents/mappings/v6/documents/document-v1.0.0.json @@ -21,6 +21,9 @@ "type": "text", "copy_to": "facet_subjects" }, + "facet_subjects": { + "type": "keyword" + }, "identifiers": { "type": "object", "properties": { @@ -50,10 +53,14 @@ "type": "object", "properties": { "name": { - "type": "text" + "type": "text", + "copy_to": "facet_authors" } } }, + "facet_authors": { + "type": "keyword" + }, "extent": { "type": "keyword" }, @@ -67,7 +74,7 @@ "type": "keyword" }, "name": { - "type": "text" + "type": "keyword" } } }, diff --git a/sonar/modules/documents/static/templates/documents/search_ui/facets.html b/sonar/modules/documents/static/templates/documents/search_ui/facets.html new file mode 100644 index 00000000..b82d51e8 --- /dev/null +++ b/sonar/modules/documents/static/templates/documents/search_ui/facets.html @@ -0,0 +1,45 @@ +
+
+
+
{{ aggr.key }}
+ + +
    +
  • + {{ selectedValue }} (0) +
  • +
+
+
+
\ No newline at end of file diff --git a/sonar/theme/templates/sonar/partial/navbar.html b/sonar/theme/templates/sonar/partial/navbar.html index d8b11a05..e6c82b9f 100644 --- a/sonar/theme/templates/sonar/partial/navbar.html +++ b/sonar/theme/templates/sonar/partial/navbar.html @@ -23,7 +23,7 @@
- + diff --git a/sonar/theme/templates/sonar/search.html b/sonar/theme/templates/sonar/search.html index 2542c6fe..8dca8496 100644 --- a/sonar/theme/templates/sonar/search.html +++ b/sonar/theme/templates/sonar/search.html @@ -42,7 +42,7 @@ {%- if sort_options %}
- Sort by: + {{ _('Sort by') }}
{%- block search_sort_select scoped %} @@ -68,28 +68,32 @@ {%- endblock search_sort %}
-
- - - - - - - - - - - - +
+
+ + +
+
+ + + + + + + + + + +
{%- endblock page_body -%} \ No newline at end of file diff --git a/sonar/translations/fr/LC_MESSAGES/messages.po b/sonar/translations/fr/LC_MESSAGES/messages.po new file mode 100644 index 00000000..0abbe71e --- /dev/null +++ b/sonar/translations/fr/LC_MESSAGES/messages.po @@ -0,0 +1,241 @@ +# French translations for sonar. +# Copyright (C) 2019 RERO +# This file is distributed under the same license as the sonar project. +# FIRST AUTHOR , 2019. +# +msgid "" +msgstr "" +"Project-Id-Version: sonar 0.0.1\n" +"Report-Msgid-Bugs-To: software@rero.ch\n" +"POT-Creation-Date: 2019-06-06 12:05+0200\n" +"PO-Revision-Date: 2019-06-06 11:09+0200\n" +"Last-Translator: FULL NAME \n" +"Language: fr\n" +"Language-Team: fr \n" +"Plural-Forms: nplurals=2; plural=(n > 1)\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.7.0\n" + +#: sonar/config.py:47 +msgid "French" +msgstr "" + +#: sonar/config.py:48 +msgid "German" +msgstr "" + +#: sonar/config.py:68 sonar/config.py:72 +msgid "Swiss Open Access Repository" +msgstr "" + +#: sonar/config.py:95 +msgid "Welcome to Swiss Open Access Repository!" +msgstr "" + +#: sonar/config.py:289 +msgid "Best match" +msgstr "Meilleure correspondance" + +#: sonar/config.py:295 +msgid "Most recent" +msgstr "Les plus récents" + +#: sonar/theme/templates/sonar/401.html:13 +msgid "Unauthorized" +msgstr "" + +#: sonar/theme/templates/sonar/401.html:14 +msgid "You need to be authenticated to view this page." +msgstr "" + +#: sonar/theme/templates/sonar/403.html:13 +msgid "Permission required" +msgstr "" + +#: sonar/theme/templates/sonar/403.html:14 +msgid "You do not have sufficient permissions to view this page." +msgstr "" + +#: sonar/theme/templates/sonar/404.html:13 +msgid "Page not found" +msgstr "Page non trouvée" + +#: sonar/theme/templates/sonar/404.html:14 +msgid "The page you are looking for could not be found." +msgstr "" + +#: sonar/theme/templates/sonar/500.html:13 +msgid "Internal server error" +msgstr "" + +#: sonar/theme/templates/sonar/500.html:15 +msgid "Error identifier" +msgstr "" + +#: sonar/theme/templates/sonar/admin_header.html:72 +#: sonar/theme/templates/sonar/partial/dropdown_user.html:8 +msgid "Logout" +msgstr "" + +#: sonar/theme/templates/sonar/footer.html:19 +msgid "Language:" +msgstr "" + +#: sonar/theme/templates/sonar/footer.html:32 +msgid "Help" +msgstr "" + +#: sonar/theme/templates/sonar/footer.html:35 +msgid "About" +msgstr "" + +#: sonar/theme/templates/sonar/footer.html:38 +msgid "Contact" +msgstr "" + +#: sonar/theme/templates/sonar/footer.html:43 +#, python-format +msgid "Powered by RERO" +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:33 +msgid "Search publications, authors, projects, ..." +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:35 +msgid "Advanced search" +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:57 +msgid "The project" +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:58 +msgid "" +"The SONAR project aims to create a scholarly archive that collects, " +"promotes and preserves the publications of authors affiliated with Swiss " +"public research institutions." +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:59 +msgid "Further info on the project page" +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:62 +msgid "Institution views (test)" +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:66 +msgid "Follow us" +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:71 +msgid "Project website on" +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:77 +msgid "Source code on" +msgstr "" + +#: sonar/theme/templates/sonar/page.html:34 +#: sonar/theme/templates/sonar/page_admin.html:34 +msgid "Invenio" +msgstr "" + +#: sonar/theme/templates/sonar/page_settings.html:19 +msgid "Settings" +msgstr "" + +#: sonar/theme/templates/sonar/search.html:45 +msgid "Sort by" +msgstr "Trier par" + +#: sonar/theme/templates/sonar/search.html:80 +msgid "Loading..." +msgstr "" + +#: sonar/theme/templates/sonar/search.html:87 +msgid "Search failed." +msgstr "" + +#: sonar/theme/templates/sonar/accounts/forgot_password.html:11 +#: sonar/theme/templates/sonar/accounts/forgot_password.html:21 +msgid "Reset Password" +msgstr "" + +#: sonar/theme/templates/sonar/accounts/forgot_password.html:17 +msgid "" +"Enter your email address below and we will send you a link to reset your " +"password." +msgstr "" + +#: sonar/theme/templates/sonar/accounts/forgot_password.html:28 +#: sonar/theme/templates/sonar/accounts/login.html:16 +#: sonar/theme/templates/sonar/accounts/signup.html:31 +msgid "Log In" +msgstr "" + +#: sonar/theme/templates/sonar/accounts/forgot_password.html:30 +#: sonar/theme/templates/sonar/accounts/login.html:24 +#: sonar/theme/templates/sonar/accounts/signup.html:25 +msgid "Sign Up" +msgstr "" + +#: sonar/theme/templates/sonar/accounts/login.html:9 +msgid "Log in to account" +msgstr "" + +#: sonar/theme/templates/sonar/accounts/login.html:22 +msgid "Forgot password?" +msgstr "" + +#: sonar/theme/templates/sonar/accounts/signup.html:10 +#, python-format +msgid "Sign up for a %(sitename)s account!" +msgstr "" + +#: sonar/theme/templates/sonar/partial/dropdown_user.html:5 +msgid "Profile" +msgstr "" + +#: sonar/theme/templates/sonar/partial/navbar.html:26 +msgid "Search" +msgstr "" + +#: sonar/theme/templates/sonar/partial/navbar.html:36 +msgid "Back to SONAR" +msgstr "" + +#: sonar/theme/templates/sonar/partial/navbar.html:44 +msgid "Log in" +msgstr "" + +#~ msgid "institution" +#~ msgstr "" + +#~ msgid "language" +#~ msgstr "" + +#~ msgid "author" +#~ msgstr "Auteur" + +#~ msgid "subject" +#~ msgstr "" + +#~ msgid "Language:" +#~ msgstr "" + +#~ msgid "Institution" +#~ msgstr "Institution" + +#~ msgid "Language" +#~ msgstr "Langue" + +#~ msgid "Author" +#~ msgstr "Auteur" + +#~ msgid "Subject" +#~ msgstr "Sujet" + diff --git a/sonar/translations/messages.pot b/sonar/translations/messages.pot new file mode 100644 index 00000000..eeccd083 --- /dev/null +++ b/sonar/translations/messages.pot @@ -0,0 +1,213 @@ +# Translations template for sonar. +# Copyright (C) 2019 RERO +# This file is distributed under the same license as the sonar project. +# FIRST AUTHOR , 2019. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: sonar 0.0.1\n" +"Report-Msgid-Bugs-To: software@rero.ch\n" +"POT-Creation-Date: 2019-06-06 12:05+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=utf-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Generated-By: Babel 2.7.0\n" + +#: sonar/config.py:47 +msgid "French" +msgstr "" + +#: sonar/config.py:48 +msgid "German" +msgstr "" + +#: sonar/config.py:68 sonar/config.py:72 +msgid "Swiss Open Access Repository" +msgstr "" + +#: sonar/config.py:95 +msgid "Welcome to Swiss Open Access Repository!" +msgstr "" + +#: sonar/config.py:289 +msgid "Best match" +msgstr "" + +#: sonar/config.py:295 +msgid "Most recent" +msgstr "" + +#: sonar/theme/templates/sonar/401.html:13 +msgid "Unauthorized" +msgstr "" + +#: sonar/theme/templates/sonar/401.html:14 +msgid "You need to be authenticated to view this page." +msgstr "" + +#: sonar/theme/templates/sonar/403.html:13 +msgid "Permission required" +msgstr "" + +#: sonar/theme/templates/sonar/403.html:14 +msgid "You do not have sufficient permissions to view this page." +msgstr "" + +#: sonar/theme/templates/sonar/404.html:13 +msgid "Page not found" +msgstr "" + +#: sonar/theme/templates/sonar/404.html:14 +msgid "The page you are looking for could not be found." +msgstr "" + +#: sonar/theme/templates/sonar/500.html:13 +msgid "Internal server error" +msgstr "" + +#: sonar/theme/templates/sonar/500.html:15 +msgid "Error identifier" +msgstr "" + +#: sonar/theme/templates/sonar/admin_header.html:72 +#: sonar/theme/templates/sonar/partial/dropdown_user.html:8 +msgid "Logout" +msgstr "" + +#: sonar/theme/templates/sonar/footer.html:19 +msgid "Language:" +msgstr "" + +#: sonar/theme/templates/sonar/footer.html:32 +msgid "Help" +msgstr "" + +#: sonar/theme/templates/sonar/footer.html:35 +msgid "About" +msgstr "" + +#: sonar/theme/templates/sonar/footer.html:38 +msgid "Contact" +msgstr "" + +#: sonar/theme/templates/sonar/footer.html:43 +#, python-format +msgid "Powered by RERO" +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:33 +msgid "Search publications, authors, projects, ..." +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:35 +msgid "Advanced search" +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:57 +msgid "The project" +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:58 +msgid "" +"The SONAR project aims to create a scholarly archive that collects, " +"promotes and preserves the publications of authors affiliated with Swiss " +"public research institutions." +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:59 +msgid "Further info on the project page" +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:62 +msgid "Institution views (test)" +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:66 +msgid "Follow us" +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:71 +msgid "Project website on" +msgstr "" + +#: sonar/theme/templates/sonar/frontpage.html:77 +msgid "Source code on" +msgstr "" + +#: sonar/theme/templates/sonar/page.html:34 +#: sonar/theme/templates/sonar/page_admin.html:34 +msgid "Invenio" +msgstr "" + +#: sonar/theme/templates/sonar/page_settings.html:19 +msgid "Settings" +msgstr "" + +#: sonar/theme/templates/sonar/search.html:45 +msgid "Sort by" +msgstr "" + +#: sonar/theme/templates/sonar/search.html:80 +msgid "Loading..." +msgstr "" + +#: sonar/theme/templates/sonar/search.html:87 +msgid "Search failed." +msgstr "" + +#: sonar/theme/templates/sonar/accounts/forgot_password.html:11 +#: sonar/theme/templates/sonar/accounts/forgot_password.html:21 +msgid "Reset Password" +msgstr "" + +#: sonar/theme/templates/sonar/accounts/forgot_password.html:17 +msgid "" +"Enter your email address below and we will send you a link to reset your " +"password." +msgstr "" + +#: sonar/theme/templates/sonar/accounts/forgot_password.html:28 +#: sonar/theme/templates/sonar/accounts/login.html:16 +#: sonar/theme/templates/sonar/accounts/signup.html:31 +msgid "Log In" +msgstr "" + +#: sonar/theme/templates/sonar/accounts/forgot_password.html:30 +#: sonar/theme/templates/sonar/accounts/login.html:24 +#: sonar/theme/templates/sonar/accounts/signup.html:25 +msgid "Sign Up" +msgstr "" + +#: sonar/theme/templates/sonar/accounts/login.html:9 +msgid "Log in to account" +msgstr "" + +#: sonar/theme/templates/sonar/accounts/login.html:22 +msgid "Forgot password?" +msgstr "" + +#: sonar/theme/templates/sonar/accounts/signup.html:10 +#, python-format +msgid "Sign up for a %(sitename)s account!" +msgstr "" + +#: sonar/theme/templates/sonar/partial/dropdown_user.html:5 +msgid "Profile" +msgstr "" + +#: sonar/theme/templates/sonar/partial/navbar.html:26 +msgid "Search" +msgstr "" + +#: sonar/theme/templates/sonar/partial/navbar.html:36 +msgid "Back to SONAR" +msgstr "" + +#: sonar/theme/templates/sonar/partial/navbar.html:44 +msgid "Log in" +msgstr "" + diff --git a/tests/ui/documents/test_marc21tojson.py b/tests/ui/documents/test_marc21tojson.py index 57982b76..b3be1adc 100644 --- a/tests/ui/documents/test_marc21tojson.py +++ b/tests/ui/documents/test_marc21tojson.py @@ -549,17 +549,14 @@ def test_marc21_to_subjects(): marc21xml = """ - - subjects 600 - - subjects 666 + subject 1 ; subject 2 """ marc21json = create_record(marc21xml) data = marc21tojson.do(marc21json) - assert data.get('subjects') == ['subjects 600', 'subjects 666'] + assert data.get('subjects') == ['subject 1', 'subject 2'] def test_marc21_to_pid():