From a04104ea321a74bf8b7ee9e5d8bb42f572cd85c3 Mon Sep 17 00:00:00 2001 From: mfg92 Date: Thu, 16 Aug 2018 18:24:25 +0200 Subject: [PATCH] initial commit --- README.md | 22 + layouts/shortcodes/gallery.html | 75 + .../shortcode-gallery/jquery-migrate-1.4.1.js | 752 +++++++++++ .../jquery-migrate-1.4.1.min.js | 2 + .../justified_gallery/LICENSE | 22 + .../jquery.justifiedGallery.js | 1202 +++++++++++++++++ .../jquery.justifiedGallery.min.js | 8 + .../justified_gallery/justifiedGallery.css | 102 ++ .../justifiedGallery.min.css | 102 ++ .../swipebox/css/swipebox.css | 295 ++++ .../swipebox/css/swipebox.min.css | 1 + .../shortcode-gallery/swipebox/img/icons.png | Bin 0 -> 729 bytes .../shortcode-gallery/swipebox/img/icons.svg | 1 + .../shortcode-gallery/swipebox/img/loader.gif | Bin 0 -> 2608 bytes .../swipebox/js/jquery.swipebox.js | 958 +++++++++++++ .../swipebox/js/jquery.swipebox.min.js | 2 + 16 files changed, 3544 insertions(+) create mode 100644 README.md create mode 100644 layouts/shortcodes/gallery.html create mode 100644 static/shortcode-gallery/jquery-migrate-1.4.1.js create mode 100644 static/shortcode-gallery/jquery-migrate-1.4.1.min.js create mode 100644 static/shortcode-gallery/justified_gallery/LICENSE create mode 100644 static/shortcode-gallery/justified_gallery/jquery.justifiedGallery.js create mode 100644 static/shortcode-gallery/justified_gallery/jquery.justifiedGallery.min.js create mode 100644 static/shortcode-gallery/justified_gallery/justifiedGallery.css create mode 100644 static/shortcode-gallery/justified_gallery/justifiedGallery.min.css create mode 100644 static/shortcode-gallery/swipebox/css/swipebox.css create mode 100644 static/shortcode-gallery/swipebox/css/swipebox.min.css create mode 100644 static/shortcode-gallery/swipebox/img/icons.png create mode 100644 static/shortcode-gallery/swipebox/img/icons.svg create mode 100644 static/shortcode-gallery/swipebox/img/loader.gif create mode 100644 static/shortcode-gallery/swipebox/js/jquery.swipebox.js create mode 100644 static/shortcode-gallery/swipebox/js/jquery.swipebox.min.js diff --git a/README.md b/README.md new file mode 100644 index 0000000..03f252b --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# hugo-shortcode-gallery + +This is a theme component for hugo. To read about hugos theme components and +how to use them have a look at https://gohugo.io/themes/theme-components/. + +This component contains a shortcode to include a gallery in your .md files. + +Here is an usage example: + +``` +{{< gallery match="images/*" rowHeight="150" resizeOptions="x300 q90 Lanczos" >}} +``` + +This will generate a gallery containing all images of the folder *images*. +The folder must be next to the .md file where this gallery is used in. + +The component requieres jQuery (3.+). Your hugo theme or youself must provide this. + +The component uses [Justified Gallery](http://miromannino.github.io/Justified-Gallery/) +to render the images between the text and [Swipebox](http://brutaldesign.github.io/swipebox/) +to show them fullscreen. Also jquery-migrate-1.4 is used to let Swipebox work +with newer jQuery versions. diff --git a/layouts/shortcodes/gallery.html b/layouts/shortcodes/gallery.html new file mode 100644 index 0000000..c5c29eb --- /dev/null +++ b/layouts/shortcodes/gallery.html @@ -0,0 +1,75 @@ + + +{{ $s := .Scratch}} +{{ if .Get "match"}} + {{$s.Set "images" (.Page.Resources.Match (.Get "match")) }} +{{ else }} + {{ $s.Set "images" (.Page.Resources.ByType "image") }} +{{ end }} + +{{ if .Get "rowHeight"}} + {{$s.Set "rowHeight" (.Get "rowHeight") }} +{{ else }} + {{ $s.Set "rowHeight" (.Site.Params.galleryRowHeight | default 150) }} +{{ end }} + +{{ if .Get "margins"}} + {{$s.Set "margins" (.Get "margins") }} +{{ else }} + {{ $s.Set "margins" (.Site.Params.galleryRowMargins | default 5) }} +{{ end }} + +{{ if .Get "resizeOptions"}} + {{$s.Set "resizeOptions" (.Get "resizeOptions") }} +{{ else }} + {{ $s.Set "resizeOptions" (.Site.Params.galleryResizeOptions | default "x150 q90 Lanczos") }} +{{ end }} + + +{{ if not (.Page.Scratch.Get "galleryLoaded") }} + {{ .Page.Scratch.Set "galleryLoaded" true }} + + + + + + + + +{{ end }} + + + +{{ $galleryId := (printf "gallery_%v" .Ordinal)}} + +
+ {{ range $original := $s.Get "images" }} + {{ $thumbnail := ($original.Resize ($s.Get "resizeOptions")) }} +
+ + + +
+ {{ end }} +
+ + diff --git a/static/shortcode-gallery/jquery-migrate-1.4.1.js b/static/shortcode-gallery/jquery-migrate-1.4.1.js new file mode 100644 index 0000000..89437eb --- /dev/null +++ b/static/shortcode-gallery/jquery-migrate-1.4.1.js @@ -0,0 +1,752 @@ +/*! + * jQuery Migrate - v1.4.1 - 2016-05-19 + * Copyright jQuery Foundation and other contributors + */ +(function( jQuery, window, undefined ) { +// See http://bugs.jquery.com/ticket/13335 +// "use strict"; + + +jQuery.migrateVersion = "1.4.1"; + + +var warnedAbout = {}; + +// List of warnings already given; public read only +jQuery.migrateWarnings = []; + +// Set to true to prevent console output; migrateWarnings still maintained +// jQuery.migrateMute = false; + +// Show a message on the console so devs know we're active +if ( window.console && window.console.log ) { + window.console.log( "JQMIGRATE: Migrate is installed" + + ( jQuery.migrateMute ? "" : " with logging active" ) + + ", version " + jQuery.migrateVersion ); +} + +// Set to false to disable traces that appear with warnings +if ( jQuery.migrateTrace === undefined ) { + jQuery.migrateTrace = true; +} + +// Forget any warnings we've already given; public +jQuery.migrateReset = function() { + warnedAbout = {}; + jQuery.migrateWarnings.length = 0; +}; + +function migrateWarn( msg) { + var console = window.console; + if ( !warnedAbout[ msg ] ) { + warnedAbout[ msg ] = true; + jQuery.migrateWarnings.push( msg ); + if ( console && console.warn && !jQuery.migrateMute ) { + console.warn( "JQMIGRATE: " + msg ); + if ( jQuery.migrateTrace && console.trace ) { + console.trace(); + } + } + } +} + +function migrateWarnProp( obj, prop, value, msg ) { + if ( Object.defineProperty ) { + // On ES5 browsers (non-oldIE), warn if the code tries to get prop; + // allow property to be overwritten in case some other plugin wants it + try { + Object.defineProperty( obj, prop, { + configurable: true, + enumerable: true, + get: function() { + migrateWarn( msg ); + return value; + }, + set: function( newValue ) { + migrateWarn( msg ); + value = newValue; + } + }); + return; + } catch( err ) { + // IE8 is a dope about Object.defineProperty, can't warn there + } + } + + // Non-ES5 (or broken) browser; just set the property + jQuery._definePropertyBroken = true; + obj[ prop ] = value; +} + +if ( document.compatMode === "BackCompat" ) { + // jQuery has never supported or tested Quirks Mode + migrateWarn( "jQuery is not compatible with Quirks Mode" ); +} + + +var attrFn = jQuery( "", { size: 1 } ).attr("size") && jQuery.attrFn, + oldAttr = jQuery.attr, + valueAttrGet = jQuery.attrHooks.value && jQuery.attrHooks.value.get || + function() { return null; }, + valueAttrSet = jQuery.attrHooks.value && jQuery.attrHooks.value.set || + function() { return undefined; }, + rnoType = /^(?:input|button)$/i, + rnoAttrNodeType = /^[238]$/, + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + ruseDefault = /^(?:checked|selected)$/i; + +// jQuery.attrFn +migrateWarnProp( jQuery, "attrFn", attrFn || {}, "jQuery.attrFn is deprecated" ); + +jQuery.attr = function( elem, name, value, pass ) { + var lowerName = name.toLowerCase(), + nType = elem && elem.nodeType; + + if ( pass ) { + // Since pass is used internally, we only warn for new jQuery + // versions where there isn't a pass arg in the formal params + if ( oldAttr.length < 4 ) { + migrateWarn("jQuery.fn.attr( props, pass ) is deprecated"); + } + if ( elem && !rnoAttrNodeType.test( nType ) && + (attrFn ? name in attrFn : jQuery.isFunction(jQuery.fn[name])) ) { + return jQuery( elem )[ name ]( value ); + } + } + + // Warn if user tries to set `type`, since it breaks on IE 6/7/8; by checking + // for disconnected elements we don't warn on $( "