assets/data/galleries.json in j1-template-2020.0.11 vs assets/data/galleries.json in j1-template-2020.0.12

- old
+ new

@@ -1,12 +1,12 @@ --- -regenerate: true +regenerate: true --- -{% capture cache %} +{% capture cache %} -{% comment %} +{% comment %} # ----------------------------------------------------------------------------- # ~/assets/data/galleries.json # Liquid JSON template for ALL Galleries configured # # Product/Info: @@ -15,113 +15,123 @@ # Copyright (C) 2020 Juergen Adams # # J1 Template is licensed under the MIT License. # See: https://github.com/jekyll-one-org/J1 Template/blob/master/LICENSE # ----------------------------------------------------------------------------- + # The Liquid template galleries.json is used by J1 Justified Gallery. + # This template is a helper that creates the gallery (JSON) data + # for all galleries configured (if enabled or NOT). It's used by + # the J1 Template Adapter to LOAD the gallery HTML markup portion + # via AJAX get. # - # The Liquid template galleries.json is used by J1 Justified Gallery. - # This template is a helper that creates the gallery (JSON) data - # for all galleries configured (if enabled or NOT). It's used by - # the J1 Template Adapter to LOAD the gallery HTML markup portion - # via AJAX get. - # - # The Liquid template engine generates a JSON file as an object of - # arrays that contains all image data used by several sliders. See - # below the fields taken from the YAML data file: - # ~/_data/modules/j1_justified_gallery.yml. - # - # NOTE: - # Be careful changing the Liquid code. If the code is changed, check - # the integrity of the JSON data created. Corrupted JSON data makes - # the Javascript of an Adapter to fail and no functionality will - # be available for most UNCLEAR reasons. - # + # The Liquid template engine generates a JSON file as an object of + # arrays that contains all image data used by several sliders. See + # below the fields taken from the YAML data file: + # ~/_data/modules/j1_justified_gallery.yml. # ----------------------------------------------------------------------------- + # NOTE: + # Be careful changing the Liquid code. If the code is changed, check + # the integrity of the JSON data created. Corrupted JSON data makes + # the Javascript of an Adapter to fail and no functionality will + # be available for most UNCLEAR reasons. + # ----------------------------------------------------------------------------- # Test data: # {{ liquid_var | debug }} # ----------------------------------------------------------------------------- {% endcomment %} {% comment %} Process YML config data ================================================================================ {% endcomment %} {% comment %} Set config files -------------------------------------------------------------------------------- {% endcomment %} +{% assign site_config = site %} {% assign apps = site.data.apps %} {% comment %} Set config data -------------------------------------------------------------------------------- {% endcomment %} +{% assign environment = site_config.environment %} + {% assign jg_config_defaults = apps.defaults.justified_gallery.defaults %} {% assign jg_config_settings = apps.justified_gallery.settings %} {% comment %} Set config options -------------------------------------------------------------------------------- {% endcomment %} {% assign jg_config = jg_config_defaults | merge: jg_config_settings %} - { - {% for item in jg_config.galleries %} - "{{ item.gallery.id }}" : [ +{% assign production = false %} +{% if environment == 'prod' or environment == 'production' %} + {% assign production = true %} +{% endif %} - {% if item.gallery.type == "image" %} - {% for image in item.gallery.images %} - {% assign image_no = forloop.index %} - {% capture image_full_path %}{{ item.gallery.images_path }}/{{ image }}{% endcapture %} - { - {% if item.gallery.captions_lightbox %} - {% for caption in item.gallery.captions_lightbox %} - {% if forloop.index == image_no %} - "captions_lightbox": "{{ caption }}", - {% endif %} - {% endfor %} - {% endif %} - {% if item.gallery.captions_gallery %} - {% for caption in item.gallery.captions_gallery %} - {% if forloop.index == image_no %} - "captions_gallery": "{{ caption }}", - {% endif %} - {% endfor %} - {% endif %} - "img": "{{ image_full_path }}" - }{% if forloop.last %}{% else %},{% endif %} +{ +{% for item in jg_config.galleries %} + "{{ item.gallery.id }}" : [ + + {% if item.gallery.type == "image" %} + {% for image in item.gallery.images %} + {% assign image_no = forloop.index %} + {% capture image_full_path %}{{ item.gallery.images_path }}/{{ image }}{% endcapture %} + { + {% if item.gallery.captions_lightbox %} + {% for caption in item.gallery.captions_lightbox %} + {% if forloop.index == image_no %} + "captions_lightbox": "{{ caption }}", + {% endif %} {% endfor %} - {% endif %} + {% endif %} + {% if item.gallery.captions_gallery %} + {% for caption in item.gallery.captions_gallery %} + {% if forloop.index == image_no %} + "captions_gallery": "{{ caption }}", + {% endif %} + {% endfor %} + {% endif %} + "img": "{{ image_full_path }}" + }{% if forloop.last %}{% else %},{% endif %} + {% endfor %} + {% endif %} - {% if item.gallery.type == "video-html5" or item.gallery.type == "video-online"%} - {% for video in item.gallery.videos %} - {% assign image_no = forloop.index %} - { - {% if item.gallery.type == "video-html5" %} - "video_path": "{{ item.gallery.video_path }}", - "video_id": "{{ video | slugify }}", - {% endif %} - "image_path": "{{ item.gallery.image_path }}", - {% for poster in item.gallery.poster %} - {% if forloop.index == image_no %} - "poster": "{{ poster }}", - {% endif %} - {% endfor %} - "video": "{{ video }}", - {% if item.gallery.captions_lightbox %} - {% for caption in item.gallery.captions_lightbox %} - {% if forloop.index == image_no %} - "captions_lightbox": "{{ caption }}", - {% endif %} - {% endfor %} - {% endif %} - {% if item.gallery.captions_gallery %} - {% for caption in item.gallery.captions_gallery %} - {% if forloop.index == image_no %} - "captions_gallery": "{{ caption }}" - {% endif %} - {% endfor %} - {% endif %} - }{% if forloop.last %}{% else %},{% endif %} + {% if item.gallery.type == "video-html5" or item.gallery.type == "video-online"%} + {% for video in item.gallery.videos %} + {% assign image_no = forloop.index %} + { + {% if item.gallery.type == "video-html5" %} + "video_path": "{{ item.gallery.video_path }}", + "video_id": "{{ video | slugify }}", + {% endif %} + "image_path": "{{ item.gallery.image_path }}", + {% for poster in item.gallery.poster %} + {% if forloop.index == image_no %} + "poster": "{{ poster }}", + {% endif %} {% endfor %} - {% endif %} + "video": "{{ video }}", + {% if item.gallery.captions_lightbox %} + {% for caption in item.gallery.captions_lightbox %} + {% if forloop.index == image_no %} + "captions_lightbox": "{{ caption }}", + {% endif %} + {% endfor %} + {% endif %} + {% if item.gallery.captions_gallery %} + {% for caption in item.gallery.captions_gallery %} + {% if forloop.index == image_no %} + "captions_gallery": "{{ caption }}" + {% endif %} + {% endfor %} + {% endif %} + }{% if forloop.last %}{% else %},{% endif %} + {% endfor %} + {% endif %} - ]{% if forloop.last %}{% else %},{% endif %} - {% endfor %} - } + ]{% if forloop.last %}{% else %},{% endif %} +{% endfor %} +} {% endcapture %} -{{ cache | strip_empty_lines }} -{% assign cache = nil %} \ No newline at end of file +{% if production %} + {{ cache | minifyJSON }} +{% else %} + {{ cache | strip_empty_lines }} +{% endif %} +{% assign cache = nil %}