1
Fork 0

Convert flickr shortcode to page layout

This commit is contained in:
Jake Howard 2018-08-17 23:16:54 +01:00
parent 1438ce758a
commit 6b216f56a3
Signed by: jake
GPG key ID: 57AFB45680EDD477
7 changed files with 41 additions and 37 deletions

View file

@ -1,7 +1,6 @@
---
title: Gallery
image: https://c1.staticflickr.com/5/4433/36343562896_0226cc3535_k.jpg
layout: flickr
photoset: 72157683796439222
---
{{% flickr 72157683796439222 %}}

View file

@ -1,7 +1,6 @@
---
title: Gallery
image: https://c2.staticflickr.com/8/7670/17115168179_1ef30ac6e9_b.jpg
layout: flickr
photoset: 72157651820386449
---
{{% flickr 72157651820386449 %}}

View file

@ -1,7 +1,6 @@
---
title: Gallery
image: https://c2.staticflickr.com/8/7674/17308375182_a172a341d6_h.jpg
layout: flickr
photoset: 72157651794923357
---
{{% flickr 72157651794923357 %}}

View file

@ -2,6 +2,6 @@
title: Student Robotics 2016
linkTitle: 2016
image: https://farm2.staticflickr.com/1466/26707090961_9b44a94f31_o_d.jpg
layout: flickr
photoset: 72157667801651676
---
{{% flickr 72157667801651676 %}}

View file

@ -2,6 +2,6 @@
title: Student Robotics 2017
linkTitle: 2017
image: https://farm3.staticflickr.com/2837/33771948196_bd306d2a8f_o_d.jpg
layout: flickr
photoset: 72157679850996831
---
{{% flickr 72157679850996831 %}}

View file

@ -0,0 +1,31 @@
{{ define "main" }}
<div id="main">
<div class="container">
{{ partial "content.html" . }}
{{ $id := .Params.photoset }}
{{ $query := querify "format" "json" "nojsoncallback" "1" "api_key" .Site.Data.flickr.api_key }}
{{ $method := querify "method" "flickr.photosets.getPhotos" "user_id" .Site.Data.flickr.user_id "photoset_id" $id "extras" "url_l" }}
{{ $photoset_orig:= (getJSON "https://api.flickr.com/services/rest/?" $query "&" $method).photoset }}
{{ $method := querify "method" "flickr.photosets.getPhotos" "user_id" .Site.Data.flickr.user_id "photoset_id" $id "extras" "url_sq" }}
{{ $photoset_thumb := (getJSON "https://api.flickr.com/services/rest/?" $query "&" $method).photoset }}
<div id="light-gallery" class="row">
{{ range $index, $element := $photoset_orig.photo }}
{{ $thumb := (index $photoset_thumb.photo $index).url_sq }}
<a href="{{ $element.url_l }}" title="{{ $element.title }}" class="col-2">
<img src="{{ $thumb }}" alt="{{ $element.title }}"/>
</a>
{{ end }}
</div>
<h4>
<a href="{{ .Site.Data.social.accounts.flickr.link }}sets/{{ $id }}/">
View entire <i>{{ $photoset_orig.title }}</i> album on Flickr
</a>
</h4>
</div>
</div>
{{ end }}

View file

@ -1,24 +0,0 @@
{{ $id := .Get 0 }}
{{ $query := querify "format" "json" "nojsoncallback" "1" "api_key" .Site.Data.flickr.api_key }}
{{ $method := querify "method" "flickr.photosets.getPhotos" "user_id" .Site.Data.flickr.user_id "photoset_id" $id "extras" "url_l" }}
{{ $photoset_orig:= (getJSON "https://api.flickr.com/services/rest/?" $query "&" $method).photoset }}
{{ $method := querify "method" "flickr.photosets.getPhotos" "user_id" .Site.Data.flickr.user_id "photoset_id" $id "extras" "url_sq" }}
{{ $photoset_thumb := (getJSON "https://api.flickr.com/services/rest/?" $query "&" $method).photoset }}
<div id="light-gallery" class="row">
{{ range $index, $element := $photoset_orig.photo }}
{{ $thumb := (index $photoset_thumb.photo $index).url_sq }}
<a href="{{ $element.url_l }}" title="{{ $element.title }}" class="col-2">
<img src="{{ $thumb }}" alt="{{ $element.title }}"/>
</a>
{{ end }}
</div>
<h4>
<a href="{{ .Site.Data.social.accounts.flickr.link }}sets/{{ $id }}/">
View entire <i>{{ $photoset_orig.title }}</i> album on Flickr
</a>
</h4>