diff --git a/.gitmodules b/.gitmodules index 5310e4e00..834afec81 100644 --- a/.gitmodules +++ b/.gitmodules @@ -142,3 +142,9 @@ [submodule "similar_posts"] path = similar_posts url = https://github.com/davidlesieur/similar_posts.git +[submodule "business_cards"] + path = business_cards + url = https://github.com/native2k/pelican.plugins.business_cards.git +[submodule "qr_code"] + path = qr_code + url = https://github.com/native2k/pelican.plugins.qr_code.git diff --git a/business_cards b/business_cards new file mode 160000 index 000000000..238d8919b --- /dev/null +++ b/business_cards @@ -0,0 +1 @@ +Subproject commit 238d8919be5cee150707bf5036d85947718aaebf diff --git a/i18n_subsites/README.rst b/i18n_subsites/README.rst index 340109b13..5d210dabe 100644 --- a/i18n_subsites/README.rst +++ b/i18n_subsites/README.rst @@ -56,6 +56,7 @@ dictionary must be given (but can be empty) in the ``I18N_SUBSITES`` dictionary You must also have the following in your pelican configuration .. code-block:: python + JINJA_ENVIRONMENT = { 'extensions': ['jinja2.ext.i18n'], } @@ -145,6 +146,32 @@ to link to the main site. This short `howto <./implementing_language_buttons.rst>`_ shows two example implementations of language buttons. +Additional config option +........................ + +If you use plugins like ``photos``, ``thumbnailer`` and want to prevent +the system from copying the files into each language directory, it is possible +to set a list of directories in the variable ``I18N_LINK_DIRS``. +For each path a symbolic link is created which links to the original directory. + +.. code-block:: python + + I18N_LINK_DIRS = ['images/thumbnails', 'photos'] + +.. code-block:: + + └── output/ # base output directory + ├── images/ + │ └── thumbnails/ # original directory + ├── photos/ # original directory + └─── de/ # language subfolder + ├── photos -> /output/photos # symbolic link to original directory + └── images/ + └── thumbnails -> /output/images/thumbnails # symbolic link to original directory + + + + Usage notes =========== - It is **mandatory** to specify ``lang`` metadata for each article diff --git a/i18n_subsites/i18n_subsites.py b/i18n_subsites/i18n_subsites.py index dc27799d4..2cc74e592 100644 --- a/i18n_subsites/i18n_subsites.py +++ b/i18n_subsites/i18n_subsites.py @@ -406,6 +406,36 @@ def get_pelican_cls(settings): return cls +def create_dirs(settings): + dirs = settings.get('I18N_LINK_DIRS') or [] + if not dirs: + return + + toutput = settings['OUTPUT_PATH'] + soutput = os.path.split(toutput)[0] + + _LOGGER.debug("create dirs {} in '{}' ".format(dirs, toutput)) + + if not os.path.exists(toutput): + os.makedirs(toutput) + + for dir in dirs: + src=os.path.join(soutput, dir) + if not os.path.exists(src): + os.makedirs(src) + + destpath = os.path.split(dir)[0] + if destpath: + destpathloc = os.path.join(toutput, destpath) + if not os.path.exists(destpathloc): + os.makedirs(destpathloc) + + dest=os.path.join(toutput, dir) + if not os.path.exists(dest): + _LOGGER.debug(" create link '{}' -> '{}'".format(dest, src)) + os.symlink(src, dest) + + def create_next_subsite(pelican_obj): '''Create the next subsite using the lang-specific config @@ -433,6 +463,8 @@ def create_next_subsite(pelican_obj): new_pelican_obj = cls(settings) _LOGGER.debug(("Generating i18n subsite for language '{}' " "using class {}").format(lang, cls)) + + create_dirs(settings) new_pelican_obj.run() diff --git a/i18n_subsites/test_i18n_subsites.py b/i18n_subsites/test_i18n_subsites.py index 83d0cb986..7e5fe6de2 100644 --- a/i18n_subsites/test_i18n_subsites.py +++ b/i18n_subsites/test_i18n_subsites.py @@ -125,6 +125,9 @@ def test_sites_generation(self): 'OUTPUT_PATH': self.temp_path, 'CACHE_PATH': self.temp_cache, 'PLUGINS': [i18ns], + 'JINJA_ENVIRONMENT' : { + 'extensions': ['jinja2.ext.i18n'], +}, } ) pelican = Pelican(settings) diff --git a/photos/photos.py b/photos/photos.py index d0c1af17a..085f8d3a0 100644 --- a/photos/photos.py +++ b/photos/photos.py @@ -37,6 +37,14 @@ ispiexif = True logger.debug('piexif found.') +try: + import pyheif +except ImportError: + isheif = False + logger.error('pyheif not found! HEIC files not supported') +else: + isheif = True + logger.debug('pyheif found.') def initialized(pelican): p = os.path.expanduser('~/Pictures') @@ -251,7 +259,14 @@ def manipulate_exif(img, settings): def resize_worker(orig, resized, spec, settings): logger.info('photos: make photo {} -> {}'.format(orig, resized)) - im = Image.open(orig) + if isheif and orig.upper().endswith('.HEIC'): + with open(orig, 'rb') as file: + image = pyheif.read_heif(file) + im = Image.frombytes( + mode=image.mode, size=image.size, data=image.data) + else: + im = Image.open(orig) + im = ImageOps.exif_transpose(im) if ispiexif and settings['PHOTO_EXIF_KEEP'] and im.format == 'JPEG': # Only works with JPEG exif for sure. try: diff --git a/photos/requirements.txt b/photos/requirements.txt index 294cfab69..aec050cdb 100644 --- a/photos/requirements.txt +++ b/photos/requirements.txt @@ -1,2 +1,3 @@ Pillow piexif>=1.0.5 +pyheif diff --git a/qr_code b/qr_code new file mode 160000 index 000000000..6537bbf32 --- /dev/null +++ b/qr_code @@ -0,0 +1 @@ +Subproject commit 6537bbf3254538bf5ed2cfc5fad11d0cf54f2aa3