From 192b1886c7d57b2f8a37753d47fda3ea293aca06 Mon Sep 17 00:00:00 2001 From: "kujiu (@rincevent)" Date: Thu, 3 Jun 2021 19:17:21 +0200 Subject: [PATCH] 1.0.1 release --- CHANGES | 7 +++ README.rst | 1 + setup.cfg | 2 +- setup.py | 27 ++-------- sphinx_galleria/__init__.py | 8 ++- sphinx_galleria/directive.py | 32 +++++++---- .../locale/fr/LC_MESSAGES/sphinx.mo | Bin 594 -> 594 bytes .../locale/fr/LC_MESSAGES/sphinx.po | 26 ++++++--- .../locale/nl/LC_MESSAGES/sphinx.mo | Bin 589 -> 589 bytes .../locale/nl/LC_MESSAGES/sphinx.po | 26 ++++++--- sphinx_galleria/locale/sphinx.pot | 22 +++++--- .../static/sphinxgalleria/sphinxgalleria.css | 51 ++++++++++-------- .../static/sphinxgalleria/sphinxgalleria.mjs | 15 +++--- 13 files changed, 134 insertions(+), 83 deletions(-) diff --git a/CHANGES b/CHANGES index 41fa4cc..ba9e817 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,13 @@ Changes ======= +1.0.1 (*2021-06-03*) +==================== + +- Fix translation +- Add timer option +- Better CSS and transition + 1.0.0 (*2021-05-28*) ==================== diff --git a/README.rst b/README.rst index 31a7b32..ea0bb2a 100644 --- a/README.rst +++ b/README.rst @@ -39,6 +39,7 @@ Just use the galleria directive like this: :hide_title: Flag - hide title under image (not in dialog) - image level :hide_alt: Flag - hide alternative text under image - image level :no_transition: Flag - avoid transition effect - node level + :timer: (optional) Go to next image each timer seconds :class: (optional) HTML class for gallery - node level Image level options are same for all images defined by diff --git a/setup.cfg b/setup.cfg index fa1a379..3409f63 100644 --- a/setup.cfg +++ b/setup.cfg @@ -10,7 +10,7 @@ license-files = [extract_messages] mapping_file = babel.cfg output_file = sphinx_galleria/locale/sphinx.pot -keywords = _ l_ lazy_gettext gettext ngettext +keywords = _ __ l_ lazy_gettext gettext ngettext add_comments = Translators: [init_catalog] diff --git a/setup.py b/setup.py index 5cf0dcb..9bc8ddd 100644 --- a/setup.py +++ b/setup.py @@ -1,35 +1,13 @@ from setuptools import setup -import distutils from babel.messages import frontend as babel -class TranslateCommand(distutils.cmd.Command): - description = "Translation" - - user_options = [] - sub_commands = [ - ('extract_messages', None), - ('update_catalog', None), - ('compile_catalog', None), - ] - - def initialize_options(self): - pass - - def finalize_options(self): - pass - - def run(self): - for cmd_name in self.get_sub_commands(): - self.run_command(cmd_name) - - with open("README.rst", "r") as fh: long_description = fh.read() setup( name="sphinx_galleria", - version="1.0.0", + version="1.0.1", url="https://procrastinator.nerv-project.eu/nerv-project/sphinx_galleria", license="EUPL 1.2", author="Kujiu", @@ -49,6 +27,9 @@ setup( "*.py", "static/sphinxgalleria/*.mjs", "static/sphinxgalleria/*.css", + "locale/*.pot", + "locale/*/LC_MESSAGES/*.po", + "locale/*/LC_MESSAGES/*.mo", ] }, install_requires=["sphinx>=3.0.0"], diff --git a/sphinx_galleria/__init__.py b/sphinx_galleria/__init__.py index b7a498c..ecb722b 100644 --- a/sphinx_galleria/__init__.py +++ b/sphinx_galleria/__init__.py @@ -14,7 +14,7 @@ from PIL import Image from . import directive from . import collector -__version_info__ = (1, 0, 0) +__version_info__ = (1, 0, 1) __version__ = '.'.join([str(val) for val in __version_info__]) @@ -112,4 +112,10 @@ def setup(app: Sphinx) -> Dict[str, Any]: app.add_env_collector(collector.GalleriaCollector) app.connect('env-updated', install_static_files) app.connect('env-updated', copy_images_files) + + locale_path = os.path.join( + os.path.abspath(os.path.dirname(__file__)), + 'locale' + ) + app.add_message_catalog('sphinx', locale_path) return {'version': __version__} diff --git a/sphinx_galleria/directive.py b/sphinx_galleria/directive.py index 9d4334e..7558c5a 100644 --- a/sphinx_galleria/directive.py +++ b/sphinx_galleria/directive.py @@ -21,6 +21,17 @@ from sphinx.util.osutil import relative_uri from sphinx.locale import _ +def length_or_percentage_or_unitless(argument: str): + length_units = [ + 'em', 'rem', 'ex', + 'px', 'pt', + 'in', 'cm', 'mm', 'pt', 'pc', + 'vh', 'vw', + '%', '' + ] + return directives.get_measure(argument, length_units) + + class galleria(nodes.General, nodes.Element): pass @@ -112,13 +123,14 @@ class GalleriaDirective(Directive): final_argument_whitespace = True option_spec = { - "class": directives.class_option, - "galleria": directives.unchanged, - "alt": directives.unchanged, - "title": directives.unchanged, - "thumbsize": directives.unchanged, - 'width': directives.length_or_percentage_or_unitless, - 'height': directives.length_or_unitless, + 'class': directives.class_option, + 'galleria': directives.unchanged, + 'alt': directives.unchanged, + 'title': directives.unchanged, + 'thumbsize': directives.unchanged, + 'timer': directives.nonnegative_int, + 'width': length_or_percentage_or_unitless, + 'height': length_or_percentage_or_unitless, 'align': align_choices, 'hide_title': directives.flag, 'hide_alt': directives.flag, @@ -161,11 +173,13 @@ class GalleriaDirective(Directive): if self.options.get('class'): node['class'] = ' '.join(self.options['class']) - node['options']["width"] = self.options.get('width') or 'auto' - node['options']["height"] = self.options.get('height') or 'auto' + node['options']["width"] = self.options.get('width') or 'unset' + node['options']["height"] = self.options.get('height') or 'unset' node['options']["align"] = self.options.get('align') or 'center' node['options']["no_transition"] = 'no_transition' in self.options + node['options']["timer"] = self.options.get('timer') + images_path = self.arguments for path in images_path: image = {} diff --git a/sphinx_galleria/locale/fr/LC_MESSAGES/sphinx.mo b/sphinx_galleria/locale/fr/LC_MESSAGES/sphinx.mo index c6baea533234f81165ac638fd189c038e1ddabf8..0f3a7564878e13e25447ab7acfd44a4417b761d2 100644 GIT binary patch delta 20 bcmcb_a*1UFJ0rWXf}w?#iNR(*Mi)i^JLd$= delta 18 Zcmcb_a*1UFJL6=1Mm9#{&3ue5i~uxQ1Ze;O diff --git a/sphinx_galleria/locale/fr/LC_MESSAGES/sphinx.po b/sphinx_galleria/locale/fr/LC_MESSAGES/sphinx.po index 8457f18..4ad753e 100644 --- a/sphinx_galleria/locale/fr/LC_MESSAGES/sphinx.po +++ b/sphinx_galleria/locale/fr/LC_MESSAGES/sphinx.po @@ -8,30 +8,40 @@ msgid "" msgstr "" "Project-Id-Version: sphinx_galleria 1.0.0\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2021-06-02 23:53+0200\n" +"POT-Creation-Date: 2021-06-03 18:40+0200\n" "PO-Revision-Date: 2021-06-02 23:55+0200\n" +"Last-Translator: \n" "Language: fr\n" "Language-Team: fr \n" -"Plural-Forms: nplurals=2; plural=(n > 1);\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.9.1\n" -"Last-Translator: \n" -"X-Generator: Poedit 2.4.3\n" -#: sphinx_galleria/directive.py:151 +#: sphinx_galleria/collector.py:73 +#, python-format +msgid "thumbsize %s is invalid (use 100x120 format)" +msgstr "" + +#: sphinx_galleria/collector.py:112 +#, python-format +msgid "image file not readable %s" +msgstr "" + +#: sphinx_galleria/directive.py:162 msgid "Previous" msgstr "Précédent" -#: sphinx_galleria/directive.py:152 +#: sphinx_galleria/directive.py:163 msgid "Next" msgstr "Suivant" -#: sphinx_galleria/directive.py:153 +#: sphinx_galleria/directive.py:164 msgid "Close" msgstr "Fermer" -#: sphinx_galleria/directive.py:154 +#: sphinx_galleria/directive.py:165 msgid "Thumbnail, click to enlarge" msgstr "Vignette, cliquer pour agrandir" + diff --git a/sphinx_galleria/locale/nl/LC_MESSAGES/sphinx.mo b/sphinx_galleria/locale/nl/LC_MESSAGES/sphinx.mo index ed8a914d050f8ab75fe30844cee0bdc749a075c0..ac193d0995334ffb80c37fb3721d73676d0f439d 100644 GIT binary patch delta 20 bcmX@ha+YNSJ0rWXf}w?#iNR(*Mtep8J0AqT delta 18 ZcmX@ha+YNSJL6=1Mm9#{&3ugZi~uvG1X=(9 diff --git a/sphinx_galleria/locale/nl/LC_MESSAGES/sphinx.po b/sphinx_galleria/locale/nl/LC_MESSAGES/sphinx.po index 1ea1eba..4d7348a 100644 --- a/sphinx_galleria/locale/nl/LC_MESSAGES/sphinx.po +++ b/sphinx_galleria/locale/nl/LC_MESSAGES/sphinx.po @@ -8,30 +8,40 @@ msgid "" msgstr "" "Project-Id-Version: sphinx_galleria 1.0.0\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2021-06-02 23:53+0200\n" +"POT-Creation-Date: 2021-06-03 18:40+0200\n" "PO-Revision-Date: 2021-06-02 23:57+0200\n" +"Last-Translator: \n" "Language: nl\n" "Language-Team: nl \n" -"Plural-Forms: nplurals=2; plural=(n != 1);\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.9.1\n" -"Last-Translator: \n" -"X-Generator: Poedit 2.4.3\n" -#: sphinx_galleria/directive.py:151 +#: sphinx_galleria/collector.py:73 +#, python-format +msgid "thumbsize %s is invalid (use 100x120 format)" +msgstr "" + +#: sphinx_galleria/collector.py:112 +#, python-format +msgid "image file not readable %s" +msgstr "" + +#: sphinx_galleria/directive.py:162 msgid "Previous" msgstr "Vorig" -#: sphinx_galleria/directive.py:152 +#: sphinx_galleria/directive.py:163 msgid "Next" msgstr "Volgende" -#: sphinx_galleria/directive.py:153 +#: sphinx_galleria/directive.py:164 msgid "Close" msgstr "Sluit" -#: sphinx_galleria/directive.py:154 +#: sphinx_galleria/directive.py:165 msgid "Thumbnail, click to enlarge" msgstr "Miniatuur, klik om te vergroten" + diff --git a/sphinx_galleria/locale/sphinx.pot b/sphinx_galleria/locale/sphinx.pot index 8ba538f..7e72aa8 100644 --- a/sphinx_galleria/locale/sphinx.pot +++ b/sphinx_galleria/locale/sphinx.pot @@ -7,9 +7,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: sphinx_galleria 1.0.0\n" +"Project-Id-Version: sphinx_galleria 1.0.1\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" -"POT-Creation-Date: 2021-06-02 23:53+0200\n" +"POT-Creation-Date: 2021-06-03 18:40+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -18,19 +18,29 @@ msgstr "" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 2.9.1\n" -#: sphinx_galleria/directive.py:151 +#: sphinx_galleria/collector.py:73 +#, python-format +msgid "thumbsize %s is invalid (use 100x120 format)" +msgstr "" + +#: sphinx_galleria/collector.py:112 +#, python-format +msgid "image file not readable %s" +msgstr "" + +#: sphinx_galleria/directive.py:162 msgid "Previous" msgstr "" -#: sphinx_galleria/directive.py:152 +#: sphinx_galleria/directive.py:163 msgid "Next" msgstr "" -#: sphinx_galleria/directive.py:153 +#: sphinx_galleria/directive.py:164 msgid "Close" msgstr "" -#: sphinx_galleria/directive.py:154 +#: sphinx_galleria/directive.py:165 msgid "Thumbnail, click to enlarge" msgstr "" diff --git a/sphinx_galleria/static/sphinxgalleria/sphinxgalleria.css b/sphinx_galleria/static/sphinxgalleria/sphinxgalleria.css index dd26664..2345cba 100644 --- a/sphinx_galleria/static/sphinxgalleria/sphinxgalleria.css +++ b/sphinx_galleria/static/sphinxgalleria/sphinxgalleria.css @@ -2,6 +2,8 @@ text-align: center; box-sizing: border-box; margin-bottom: 1rem; + display: flex; + flex-flow: column nowrap; } .sphinxgalleria-core.align-center { @@ -22,11 +24,17 @@ .sphinxgalleria-core figure { margin: 0; padding: 0; + flex-grow: 1000; + flex-shrink: 1000; + display: flex; + flex-flow: column nowrap; } .sphinxgalleria-core figure .row { flex-flow: row nowrap; display: flex; + flex-shrink: 1000; + flex-grow: 1000; } .sphinxgalleria-core figure .row button { @@ -44,7 +52,7 @@ border-radius: unset; box-sizing: border-box; width: 100%; - height: max-content; + height: 100%; display: flex; flex-flow: column nowrap; background-color: transparent; @@ -74,13 +82,15 @@ } .sphinxgalleria-core figure .row button.button-modal img { - margin: 0; + margin: auto; padding: 0; border: none; - width: 100%; + width: auto; height: auto; - object-fit: cover; transition: width ease .4s, height ease .4s, opacity ease .4s; + object-fit: contain; + flex-grow: 1000; + flex-shrink: 1000; } .sphinxgalleria-core.no-transition figure .row button.button-modal img { transition: unset; @@ -88,6 +98,8 @@ .sphinxgalleria-core figure input[type=range] { width: 90%; + margin-left: auto; + margin-right: auto; height: 1.5rem; border: none; -webkit-appearance: none; @@ -117,6 +129,7 @@ margin-top: -.5rem; } .sphinxgalleria-core figure input[type=range]:focus::-webkit-slider-runnable-track { + -webkit-appearance: none; background-color: hsl(0, 0%, 34%); border: none; } @@ -244,12 +257,14 @@ .sphinxgalleria-core figure button.prev, .sphinxgalleria-core figure button.next { - background-color: hsl(0, 0%, 34%); - color: white; - height: 4rem; - width: 4rem; - margin: auto .5rem auto .5rem; - border-radius: 1rem; + color: hsl(0, 0%, 34%); + background-color: transparent; + font-size: 4rem; + padding: 1rem; + height: 100%; + display: inline; + vertical-align: middle; + margin: 1; border: none; } @@ -257,26 +272,19 @@ .sphinxgalleria-core figure button.next:hover, .sphinxgalleria-core figure button.prev:focus, .sphinxgalleria-core figure button.next:focus { - background-color: hsl(0, 0%, 64%); - transition: background-color ease .4s; -} - -.sphinxgalleria-core figure button.prev { -} - -.sphinxgalleria-core figure button.next { + color: hsl(0, 0%, 64%); + transition: color ease .4s; } .sphinxgalleria-core figure button.prev::before, .sphinxgalleria-core dialog menu button.prev::before { - margin-right: 0.5rem; - content: '←'; + content: '<'; } .sphinxgalleria-core figure button.next::after, .sphinxgalleria-core dialog menu button.next::after { margin-left: 0.5rem; - content: '→'; + content: '>'; } .sphinxgalleria-core ul.thumbnails { @@ -305,5 +313,6 @@ .sphinxgalleria-core ul.thumbnails li img { margin: 0.5rem; cursor: pointer; + object-fit: cover; max-width: unset; } diff --git a/sphinx_galleria/static/sphinxgalleria/sphinxgalleria.mjs b/sphinx_galleria/static/sphinxgalleria/sphinxgalleria.mjs index c083c25..4d2aedd 100644 --- a/sphinx_galleria/static/sphinxgalleria/sphinxgalleria.mjs +++ b/sphinx_galleria/static/sphinxgalleria/sphinxgalleria.mjs @@ -146,6 +146,12 @@ export class SphinxGalleria { self.dialog_button_close_icon.addEventListener('keypress', onclose); if(!self.oneimage) { + if(self.options.timer){ + setInterval(function(){ + self.next(); + }, self.options.timer*1000); + } + var onprev = function(event) { var key = event.key; if(event.type==='keypress' && key!==" " && key!=="Enter") { @@ -314,12 +320,9 @@ export class SphinxGalleria { self.node_slider.value = idx + 1; } var current_img = current.nextSibling.childNodes[0]; - self.node_thumbnails.scrollTo({ - left: current_img.x - - self.node_thumbnails.offsetWidth/2 + - current_img.clientWidth/2, - top: 0, - behavior: 'smooth' + current_img.scrollIntoView({ + behavior: 'smooth', + inline: 'center', }); }