diff --git a/invenio_i18n/assets/js/invenio_i18n/app.js b/invenio_i18n/assets/js/invenio_i18n/app.js index 7d5c9b9..433231c 100644 --- a/invenio_i18n/assets/js/invenio_i18n/app.js +++ b/invenio_i18n/assets/js/invenio_i18n/app.js @@ -11,6 +11,7 @@ import angular from "angular"; import "angular-gettext/dist/angular-gettext"; import * as $ from "jquery/dist/jquery"; +// TODO: Delete this ? angular.module("langSelector", ["gettext"]).factory("setLanguage", [ "gettextCatalog", function(gettextCatalog) { diff --git a/invenio_i18n/assets/semantic-ui/js/invenio_i18n/app.js b/invenio_i18n/assets/semantic-ui/js/invenio_i18n/app.js new file mode 100644 index 0000000..92cd331 --- /dev/null +++ b/invenio_i18n/assets/semantic-ui/js/invenio_i18n/app.js @@ -0,0 +1,16 @@ +/* + * This file is part of Invenio. + * Copyright (C) 2016-2018 CERN. + * Copyright (C) 2016 TIND. + * + * Invenio 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 * as $ from "jquery/dist/jquery"; + +$(document).ready(function() { + $("#lang-code").on("change", function() { + $("#language-code-form").submit(); + }); +}); diff --git a/invenio_i18n/bundles.py b/invenio_i18n/bundles.py deleted file mode 100644 index 371da51..0000000 --- a/invenio_i18n/bundles.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- -# -# This file is part of Invenio. -# Copyright (C) 2015-2018 CERN. -# Copyright (C) 2016 TIND. -# -# Invenio is free software; you can redistribute it and/or modify it -# under the terms of the MIT License; see LICENSE file for more details. - -"""Bundles for Invenio-I18N.""" - -from __future__ import absolute_import, print_function - -from invenio_assets import NpmBundle, RequireJSFilter - -js = NpmBundle( - 'js/invenio_i18n/angularLangSelector.js', - filters=RequireJSFilter(), - output='gen/i18n.%(version)s.js', - npm={ - 'angular': '~1.4.9', - 'angular-gettext': '~2.3.8', - } -) diff --git a/invenio_i18n/static/js/invenio_i18n/angularLangSelector.js b/invenio_i18n/static/js/invenio_i18n/angularLangSelector.js deleted file mode 100644 index 10e7c0f..0000000 --- a/invenio_i18n/static/js/invenio_i18n/angularLangSelector.js +++ /dev/null @@ -1,26 +0,0 @@ -/* - * This file is part of Invenio. - * Copyright (C) 2016-2018 CERN. - * Copyright (C) 2016 TIND. - * - * Invenio is free software; you can redistribute it and/or modify it - * under the terms of the MIT License; see LICENSE file for more details. - */ - -require([ - "node_modules/angular/angular", - "node_modules/jquery/jquery.js", - "node_modules/angular-gettext/dist/angular-gettext" -], function() { - angular.module("langSelector", ["gettext"]) - .factory("setLanguage", ["gettextCatalog", function(gettextCatalog){ - function setCurrentLanguage(lang) { - gettextCatalog.setCurrentLanguage(lang); - } - }]); - $(document).ready(function() { - $('#lang-code').on('change', function() { - $('#language-code-form').submit(); - }); - }); -}); diff --git a/invenio_i18n/templates/semantic-ui/invenio_i18n/macros/language_selector.html b/invenio_i18n/templates/semantic-ui/invenio_i18n/macros/language_selector.html new file mode 100644 index 0000000..ba01621 --- /dev/null +++ b/invenio_i18n/templates/semantic-ui/invenio_i18n/macros/language_selector.html @@ -0,0 +1,24 @@ +{# -*- coding: utf-8 -*- + + This file is part of Invenio. + Copyright (C) 2015-2018 CERN. + Copyright (C) 2016 TIND. + + Invenio 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 language_selector_dropdown() %} +
+
+ + +
+
+{% endmacro %} diff --git a/invenio_i18n/webpack.py b/invenio_i18n/webpack.py index 819dcec..6db44f7 100644 --- a/invenio_i18n/webpack.py +++ b/invenio_i18n/webpack.py @@ -8,15 +8,32 @@ """Webpack bundles for Invenio-I18N.""" -from flask_webpackext import WebpackBundle +from invenio_assets.webpack import WebpackThemeBundle -i18n = WebpackBundle( +i18n = WebpackThemeBundle( __name__, 'assets', - entry={ - 'i18n_app': './js/invenio_i18n/app.js' - }, - dependencies={ - 'angular': '~1.4.9', - 'angular-gettext': '~2.3.8', - }) + default='bootstrap3', + themes={ + 'bootstrap3': dict( + entry={ + 'i18n_app': './js/invenio_i18n/app.js', + }, + dependencies={ + 'angular': '~1.4.9', + 'angular-gettext': '~2.3.8', + } + ), + 'semantic-ui': dict( + entry={ + 'i18n_app': './js/invenio_i18n/app.js', + }, + dependencies={ + 'semantic-ui-less': '~2.4.1', + 'semantic-ui-css': '~2.4.1', + 'font-awesome': '~4.4.0', + 'jquery': '~3.2.1', + }, + ), + } +) diff --git a/setup.py b/setup.py index 97e0c82..7d49cc1 100644 --- a/setup.py +++ b/setup.py @@ -72,9 +72,6 @@ include_package_data=True, platforms='any', entry_points={ - 'invenio_assets.bundles': [ - 'invenio_i18n_js = invenio_i18n.bundles:js', - ], 'invenio_base.apps': [ 'invenio_i18n = invenio_i18n:InvenioI18N', ], diff --git a/tests/test_invenio_i18n.py b/tests/test_invenio_i18n.py index 1f41f77..c926534 100644 --- a/tests/test_invenio_i18n.py +++ b/tests/test_invenio_i18n.py @@ -202,5 +202,5 @@ def test_bundles(app): InvenioAssets(app) with app.app_context(): - from invenio_i18n.bundles import js - assert js + from invenio_i18n.webpack import i18n + assert i18n