Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kc0bfv/autophugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl <kc0bfv@gmail.com>2021-11-15 01:12:10 +0300
committerKarl <kc0bfv@gmail.com>2021-11-15 01:12:10 +0300
commitace7f60dc56a758b943e1067ab4c8e4feadf9f7d (patch)
tree0acb24a6700126ebe694dd94e6398a323a05b8d3
parent381e40e379d0a92bab028209b883ca28cbe9641b (diff)
Add support for tags and categories
-rw-r--r--README.md13
-rw-r--r--assets/css/main.css8
-rw-r--r--assets/js/main.js15
-rw-r--r--exampleSite/config.toml6
-rw-r--r--exampleSite/config_for_github_pages.toml6
-rw-r--r--exampleSite/content/cats/_index.md4
-rw-r--r--exampleSite/content/dogs/_index.md10
-rw-r--r--exampleSite/content/dogs/happy-dogs/running-dogs/_index.md4
-rw-r--r--exampleSite/content/dogs/happy-dogs/stationary-dogs/_index.md2
-rw-r--r--exampleSite/content/fish/_index.md8
-rw-r--r--exampleSite/content/many-simple/_index.md4
-rw-r--r--exampleSiteNoAlbum/config.toml6
-rw-r--r--layouts/_default/baseof.html24
-rw-r--r--layouts/_default/list.html111
-rw-r--r--layouts/_default/terms.html71
-rw-r--r--layouts/partials/footer.html37
-rw-r--r--layouts/partials/render_img_column_flexrow.html98
-rw-r--r--layouts/partials/sect_and_img_content.html183
18 files changed, 404 insertions, 206 deletions
diff --git a/README.md b/README.md
index 53cce11..bd7abe7 100644
--- a/README.md
+++ b/README.md
@@ -46,6 +46,7 @@ The `exampleSite` demonstrates the features unique to this theme. In your site
* `filename_as_phototitle` - if true, a humanized form of the filename will be used as the phototitle (default false)
* `images_downloadable` - if true, images have a download button (default true)
* `images_downloadable_use_orig` - if true, the download button will download the original image instead of the full size image - this will likely greatly increase the size of your site (default false)
+* `taxonomies_links` - if true, links to the taxonomy pages will be present in the footer and on the tagged items (default false)
Additionally, `Author.name` and `Author.email` in the site config will display as the author and webmaster email.
@@ -128,6 +129,18 @@ You can place images and subalbums together - the `assets` directory would conta
Default sorting for subalbums and images sorts by weight. For subalbums with the same weight it sorts by date, and for images with the same weight it sorts by filename. If you don't specify a weight for an item, the default is 0. Therefore - if you don't set any weights you'll sort by date... Lower weights come first so negative weights get sorted before unspecified weights and positive ones.
+## Tagging and Categorizing (taxonomies)
+
+You can tag and categorize your images and subalbums, and you can create other taxonomies and use those too! There are a couple site configurations to understand...
+
+`disableKinds = ["taxonomy", "term"]`
+
+If you want tags or categories do *not* have this line in your site config. If you specify these values for disableKinds in your site config you will disable all taxonomy pages. Term pages are not generated as part of this theme - the terms all appear on their taxonomy page. Regardless, if you want to have tags or categories, do *not* have the above line.
+
+You can use the `[taxonomies]` site config section to create new taxonomies or remove the defaults. More information is in the [Hugo documentation](https://gohugo.io/content-management/taxonomies/#default-taxonomies).
+
+The `taxonomies_links` parameter defaults to false, disabling links to the taxonomies pages even if they get generated... Set it to true in your site config and links will show up in the page footers and on tagged items.
+
## Building the Site
Run `hugo` to build your site. Output will be placed in the `public` directory. The original images will not be included - only the resized versions.
diff --git a/assets/css/main.css b/assets/css/main.css
index 09251ac..c8ecf62 100644
--- a/assets/css/main.css
+++ b/assets/css/main.css
@@ -315,3 +315,11 @@ body.loading #main .thumb { -moz-pointer-events: none; -webkit-pointer-events: n
.mfp-bottom-bar .download-button a:hover, .mfp-figure .mfp-close:hover { opacity: 1; }
article.thumb a:focus img { border: solid 1px #ffffff; }
+
+
+/* Other */
+.taxonomy_list div { display: flex; flex-wrap: wrap; padding: 0; }
+.tax_term { margin: 0 5px 0 0; height: fit-content; }
+.taxonomy_list h2 { margin-right: 5px; }
+.caption_tax { display: none; }
+.caption-surround .caption_tax { display: flex; flex-wrap: wrap; padding: 0; }
diff --git a/assets/js/main.js b/assets/js/main.js
index e9fb782..0542d91 100644
--- a/assets/js/main.js
+++ b/assets/js/main.js
@@ -277,8 +277,12 @@
caption += "<h2>" + item.el.attr("phototitle") + "</h2>";
}
if( item.el.attr("description") != "" ) {
- caption += '<p class="description">' +
- item.el.attr("description") + "</p>";
+ caption += '<div class="description">' +
+ item.el.attr("description") + "</div>";
+ }
+ let tax_elem = item.el.parent().find(".caption_tax");
+ if( tax_elem.length > 0 ) {
+ caption += tax_elem[0].outerHTML;
}
caption += "</div>";
return caption;
@@ -313,16 +317,19 @@
curr_item.el.attr("id") == fid[0].id )
{
// Nothing needs to happen in this case...
+ return false;
} else
{
// Otherwise we need to update the popup, so click it
fid.click();
+ return false;
}
} else {
- // Here there was an invalid hash...
+ // Some other hash was present, let the browser handle it
$.magnificPopup.close();
- window.location.hash = "";
+ return true;
}
+ return true;
}
// Check the fragment id at load
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 0a92716..9b7022c 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -4,7 +4,10 @@ languageCode = "en-us"
title = "AutoPhugo"
theme = "autophugo"
#googleAnalytics = ""
-disableKinds = ["taxonomy", "taxonomyTerm"]
+disableKinds = ["taxonomy", "term"]
+#[taxonomies]
+# tag = "tags"
+# category = "categories"
[Author]
name = "Karl Sickendick"
@@ -25,6 +28,7 @@ disableKinds = ["taxonomy", "taxonomyTerm"]
#filename_as_phototitle = false
#images_downloadable = true
#images_downloadable_use_orig = false
+ #taxonomies_links = false
# Headerbar links
# Do not put too many links here,
diff --git a/exampleSite/config_for_github_pages.toml b/exampleSite/config_for_github_pages.toml
index bc722f4..575d762 100644
--- a/exampleSite/config_for_github_pages.toml
+++ b/exampleSite/config_for_github_pages.toml
@@ -4,7 +4,10 @@ languageCode = "en-us"
title = "AutoPhugo"
theme = "autophugo"
#googleAnalytics = ""
-disableKinds = ["taxonomy", "taxonomyTerm"]
+disableKinds = ["taxonomy", "term"]
+#[taxonomies]
+# tag = "tags"
+# category = "categories"
[Author]
name = "Karl Sickendick"
@@ -25,6 +28,7 @@ disableKinds = ["taxonomy", "taxonomyTerm"]
#filename_as_phototitle = false
#images_downloadable = true
#images_downloadable_use_orig = false
+ #taxonomies_links = false
# Headerbar links
# Do not put too many links here,
diff --git a/exampleSite/content/cats/_index.md b/exampleSite/content/cats/_index.md
index c1c553a..4b6ca04 100644
--- a/exampleSite/content/cats/_index.md
+++ b/exampleSite/content/cats/_index.md
@@ -1,12 +1,16 @@
---
title: "Cats"
date: 2020-03-15T10:06:11-06:00
+tags:
+- friendly
resources:
- src: cats/cat_01.jpg
weight: 1
alt: Cat in the grass
phototitle: Grass cat
description: This cat stalks through the grass
+ categories:
+ - dark colored
- src: cats/cat_02.jpg
alt: A cat in some sort of urban setting
phototitle: Cool cat
diff --git a/exampleSite/content/dogs/_index.md b/exampleSite/content/dogs/_index.md
index 2d60313..67e96c2 100644
--- a/exampleSite/content/dogs/_index.md
+++ b/exampleSite/content/dogs/_index.md
@@ -4,6 +4,8 @@ date: 2020-03-15T14:00:00-06:00
weight: -1
albumthumb: "dogs/happy-dogs/stationary-dogs/dog_04.jpg"
draft: false
+tags:
+- friendly
## Optional additional meta info for resources list
# alt: Image alternative and screen-reader text
# phototitle: A title for the photo
@@ -13,8 +15,16 @@ resources:
weight: 10
- src: "dogs/jumping_dog_02.jpg"
weight: 20
+ tags:
+ - water
+ categories:
+ - dark colored
- src: "dogs/jumping_dog_03.jpg"
weight: 30
- src: "dogs/jumping_dog_04.jpg"
weight: 40
+ tags:
+ - water
+ categories:
+ - dark colored
---
diff --git a/exampleSite/content/dogs/happy-dogs/running-dogs/_index.md b/exampleSite/content/dogs/happy-dogs/running-dogs/_index.md
index c22a61d..700c48d 100644
--- a/exampleSite/content/dogs/happy-dogs/running-dogs/_index.md
+++ b/exampleSite/content/dogs/happy-dogs/running-dogs/_index.md
@@ -6,9 +6,13 @@ resources:
- src: dogs/happy-dogs/running-dogs/dog_05.jpg
alt: Two dogs running down a grassy trail towards the photographer
description: Clearly a dog day afternoon!
+ categories:
+ - dark colored
- src: dogs/happy-dogs/running-dogs/dog_09.jpg
alt: Two brown hounds chasing something in a field
phototitle: How Now Brown Hound
+ categories:
+ - dark colored
- src: dogs/happy-dogs/running-dogs/dog_10.jpg
alt: A brown greyhound running to the right in a grassy field on a sunny day
phototitle: A brown greyhound
diff --git a/exampleSite/content/dogs/happy-dogs/stationary-dogs/_index.md b/exampleSite/content/dogs/happy-dogs/stationary-dogs/_index.md
index 1fe2f0c..5f43722 100644
--- a/exampleSite/content/dogs/happy-dogs/stationary-dogs/_index.md
+++ b/exampleSite/content/dogs/happy-dogs/stationary-dogs/_index.md
@@ -7,6 +7,8 @@ resources:
alt: Two dogs in a field looking to the left past the photographer.
phototitle: Field of Dogs
description: Taken in some moor somewhere
+ categories:
+ - dark colored
- src: dogs/happy-dogs/stationary-dogs/dog_06.jpg
alt: A dog leaning out a window, as seen from a rear-view mirror.
phototitle: Dog Retrospective
diff --git a/exampleSite/content/fish/_index.md b/exampleSite/content/fish/_index.md
index ebc3c7d..a63f48a 100644
--- a/exampleSite/content/fish/_index.md
+++ b/exampleSite/content/fish/_index.md
@@ -11,10 +11,18 @@ resources:
alt: A clownfish poking around in some sea anemone or something
phototitle: Class Clown
description: There's one in every school
+- src: fish/fish_03.jpg
+ tags:
+ - water
+- src: fish/fish_04.jpg
+ tags:
+ - not friendly
- src: fish/fish_05.jpg
alt: A lion fish near the sea floor
phototitle: Lion Fish Time!
description: A poisonish lion fish
+ tags:
+ - not friendly
- src: fish/fish_07.jpg
alt: Blue fish in front of yellow coral
phototitle: Swimming Blue Fish
diff --git a/exampleSite/content/many-simple/_index.md b/exampleSite/content/many-simple/_index.md
index 7da6f86..782b84b 100644
--- a/exampleSite/content/many-simple/_index.md
+++ b/exampleSite/content/many-simple/_index.md
@@ -8,4 +8,8 @@ draft: false
# alt: Image alternative and screen-reader text
# phototitle: A title for the photo
# description: A sub-title or description for the photo
+resources:
+- src: many-simple/Janine.gif
+ tags:
+ - not friendly
---
diff --git a/exampleSiteNoAlbum/config.toml b/exampleSiteNoAlbum/config.toml
index 0a92716..9b7022c 100644
--- a/exampleSiteNoAlbum/config.toml
+++ b/exampleSiteNoAlbum/config.toml
@@ -4,7 +4,10 @@ languageCode = "en-us"
title = "AutoPhugo"
theme = "autophugo"
#googleAnalytics = ""
-disableKinds = ["taxonomy", "taxonomyTerm"]
+disableKinds = ["taxonomy", "term"]
+#[taxonomies]
+# tag = "tags"
+# category = "categories"
[Author]
name = "Karl Sickendick"
@@ -25,6 +28,7 @@ disableKinds = ["taxonomy", "taxonomyTerm"]
#filename_as_phototitle = false
#images_downloadable = true
#images_downloadable_use_orig = false
+ #taxonomies_links = false
# Headerbar links
# Do not put too many links here,
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index 0ffe3b5..ab1947a 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -1,28 +1,22 @@
<!DOCTYPE HTML>
-{{ partial "lang.html" . }}
+{{- partial "lang.html" . }}
<head>
<title>
{{- block "title" . }}
{{- with .Title }}{{ . }} - {{ end }}{{ .Site.Title -}}
{{- end -}}
</title>
-{{ partial "head.html" . }}
+{{- partial "head.html" . }}
</head>
<body class="loading">
-
<div id="wrapper">
-
- {{ partial "header.html" . }}
-
- {{ block "main" . }}
- {{ partial "sect_and_img_content.html" . }}
- {{ end }}
-
- {{ partial "footer.html" . }}
-
+ {{- partial "header.html" . }}
+ <div id="main">
+ {{ block "main" . }}
+ {{ end }}
+ </div>
+ {{- partial "footer.html" . }}
</div>
-
-{{ partial "scripts.html" . }}
-
+{{- partial "scripts.html" . }}
</body>
</html>
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index b733dd0..8d5942a 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -1 +1,110 @@
-{{ define "anything" }}{{ end }}
+{{ define "main" }}
+
+ {{- /* Things in site config */}}
+ {{- $thumb_width := default 480 ($.Param "thumb_width") }}
+ {{- $full_width := default 960 ($.Param "full_width") }}
+ {{- $thumb_quality := default 50 ($.Param "thumb_quality") }}
+ {{- $full_quality := default 90 ($.Param "full_quality") }}
+ {{- $filename_as_phototitle := default false ($.Param "filename_as_phototitle") }}
+
+ {{- /* Calculate thumb_ and full_size from params, unless one is provided in the config. */}}
+ {{- $thumb_size := default (printf "%dx q%d" $thumb_width $thumb_quality) ($.Param "thumb_size") }}
+ {{- $full_size := default (printf "%dx q%d" $full_width $full_quality) ($.Param "full_size") }}
+
+ {{- /* Build the list of sections and thumbnails */}}
+ {{- $.Scratch.Set "sections" (slice) }}
+ {{- range .Sections.ByDate }}
+ {{- $title := .Title }}
+ {{- $link := .RelPermalink }}
+ {{- $weight := default 0 (.Param "weight") }}
+
+ {{- partial "scratch_set_retalbumthumb.html" . }}
+ {{- /* Note that the Scratch below must come from . context, not $ */}}
+ {{- $image := .Scratch.Get "retalbumthumb" }}
+
+ {{- if not $image }}
+ {{- errorf (printf "When processing '%s', no thumbnail image found for: %s" $.Page.File.Path $title) }}
+ {{- else }}
+ {{- $thumb := $image.Resize $thumb_size }}
+ {{- $new_sect := dict "type" "link" "title" $title "link" $link "thumb" $thumb "weight" $weight }}
+
+ {{- $sections := $.Scratch.Get "sections" }}
+ {{- $sections := $sections | append $new_sect }}
+ {{- $.Scratch.Set "sections" $sections }}
+ {{- end }}
+ {{- end }}
+ {{- /* Section list is complete, now resort */}}
+ {{- $.Scratch.Set "sections" (sort ($.Scratch.Get "sections") "weight") }}
+ {{- $sections := $.Scratch.Get "sections" }}
+
+ {{- /* Get and reorder the list of images */}}
+ {{- if .File }}
+ {{- $imgglob := printf "%s" (path.Join .File.Dir "*") }}
+ {{- $.Scratch.Set "imgglob" $imgglob }}
+ {{- end }}
+ {{- $imgglob := default "*" ($.Scratch.Get "imgglob") }}
+ {{- $imageresources := where (resources.Match $imgglob) "ResourceType" "image" }}
+ {{- $TODO_DELETE_images := $imageresources }}
+
+ {{- /* Build some image objects */}}
+ {{- $.Scratch.Set "images" (slice) }}
+ {{- range $elem_index, $elem_val := $imageresources }}
+
+ {{- /* Build some scratch for upcoming search... */}}
+ {{- $img_dat := newScratch }}
+ {{- $img_dat.Set "alt" "" }}
+ {{- $img_dat.Set "description" "" }}
+ {{- $img_dat.Set "weight" 0 }}
+ {{- $img_dat.Set "taxonomies" dict }}
+
+ {{- if $filename_as_phototitle }}
+ {{- $filename := replace (path.Base $elem_val.Name) (path.Ext $elem_val.Name) "" }}
+ {{- $img_dat.Set "phototitle" (humanize $filename) }}
+ {{- else }}
+ {{- $img_dat.Set "phototitle" "" }}
+ {{- end }}
+
+ {{- /* Search the resources for a matching image src, save off details */}}
+ {{- $img_path := $elem_val.Name }}
+ {{- with $.Params.resources }}
+ {{- range first 1 (where . "src" $img_path) }}
+ {{- $found := . }}
+ {{- if isset . "alt" }}{{ $img_dat.Set "alt" .alt }}{{ end }}
+ {{- if isset . "phototitle" }}{{ $img_dat.Set "phototitle" .phototitle }}{{ end }}
+ {{- if isset . "description" }}{{ $img_dat.Set "description" .description }}{{ end }}
+ {{- if isset . "weight" }}{{ $img_dat.Set "weight" .weight }}{{ end }}
+
+ {{- /* Build an dict of arrays - the keys are taxonomy name, values are an array of terms in that taxonomy */}}
+ {{- range $taxname, $taxterms := $.Site.Taxonomies }}
+ {{- if isset $found $taxname }}
+ {{- $newentry := dict $taxname (index $found $taxname) }}
+ {{- $newvals := merge ($img_dat.Get "taxonomies") $newentry }}
+ {{- $img_dat.Set "taxonomies" $newvals }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+
+ {{- /* Save off the image object */}}
+ {{- $alt := $img_dat.Get "alt" }}
+ {{- $phototitle := $img_dat.Get "phototitle" }}
+ {{- $description := $img_dat.Get "description" }}
+ {{- $weight := $img_dat.Get "weight" }}
+ {{- $taxonomies := $img_dat.Get "taxonomies" }}
+ {{- $thumb := $elem_val.Resize $thumb_size }}
+ {{- $full := $elem_val.Resize $full_size }}
+
+ {{- $new_img := dict "type" "image" "index" $elem_index "image" $elem_val "thumb" $thumb "full" $full "alt" $alt "phototitle" $phototitle "description" $description "weight" $weight "orig" $elem_val "taxonomies" $taxonomies }}
+
+ {{- $images := $.Scratch.Get "images" }}
+ {{- $images := $images | append $new_img }}
+ {{- $.Scratch.Set "images" $images }}
+ {{- end }}
+ {{- /* Image list is complete, now resort */}}
+ {{- $.Scratch.Set "images" (sort ($.Scratch.Get "images") "weight") }}
+ {{- $images := $.Scratch.Get "images" }}
+
+ {{- $.Scratch.Set "content" ($sections | append $images) }}
+ {{- partial "render_img_column_flexrow.html" $ }}
+
+{{ end }}
diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html
new file mode 100644
index 0000000..32438a1
--- /dev/null
+++ b/layouts/_default/terms.html
@@ -0,0 +1,71 @@
+{{ define "main" }}
+ {{- $thumb_width := default 480 ($.Param "thumb_width") }}
+ {{- $thumb_quality := default 50 ($.Param "thumb_quality") }}
+
+ {{- $thumb_size := default (printf "%dx q%d" $thumb_width $thumb_quality) ($.Param "thumb_size") }}
+
+ {{- $.Scratch.Set "tags" (dict) }}
+
+ {{- range $.Site.Pages }}
+ {{- $page := . }}
+
+ {{- /* Enumerate the tags on the page */}}
+ {{- range (index $page.Params $.Data.Plural) }}
+ {{- $tag := . }}
+
+ {{- partial "scratch_set_retalbumthumb.html" $page }}
+ {{- /* Note that the Scratch below must come from $page context, not $ */}}
+ {{- $image := $page.Scratch.Get "retalbumthumb" }}
+
+ {{- if not $image }}
+ {{- errorf (printf "When processing '%s', no thumbnail image found for: %s" $page.Path $tag) }}
+ {{- end }}
+
+ {{- $thumb := $image.Resize $thumb_size }}
+
+ {{- /* Create an object representing this tag term entry */}}
+ {{- $page_desc := dict "type" "link" "link" $page.RelPermalink "title" $page.Title "thumb" $thumb }}
+
+ {{- /* Add this object to the list */}}
+ {{- $cur_entry := (index ($.Scratch.Get "tags") $tag) }}
+ {{- $new_list := $cur_entry | append $page_desc }}
+ {{- $.Scratch.Set "tags" (merge ($.Scratch.Get "tags") (dict $tag $new_list)) }}
+ {{ end }}
+
+ {{- /* Enumerate the tags on the resource images */}}
+ {{- with $page.File }}
+ {{- range resources.Match (path.Join $page.File.Dir "*") }}
+ {{- $img := . }}
+ {{- $filename := path.Base $img.Name }}
+ {{- $filedir := path.Dir $img.Name }}
+
+ {{- with $page.Params.resources }}
+ {{- range first 1 (where . "src" $img.Name) }}
+ {{- $resource := . }}
+ {{- range (index . $.Data.Plural) }}
+ {{- $tag := . }}
+
+ {{- $thumb := $img.Resize $thumb_size }}
+
+ {{- /* Create an object representing this tag term entry */}}
+ {{- $img_desc := dict "type" "link" "link" (printf "/%s/#%s" $filedir (md5 $filename)) "title" $resource.phototitle "thumb" $thumb }}
+ {{- /* Add this object to the list */}}
+ {{- $cur_entry := (index ($.Scratch.Get "tags") $tag) }}
+ {{- $new_list := $cur_entry | append $img_desc }}
+ {{- $.Scratch.Set "tags" (merge ($.Scratch.Get "tags") (dict $tag $new_list)) }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+ {{- end }}
+
+
+ {{- range $term, $term_list := $.Scratch.Get "tags" }}
+
+ <h1 id="{{ $term | urlize }}">{{ $term }}</h1>
+ {{- $.Scratch.Set "content" $term_list }}
+ {{- partial "render_img_column_flexrow.html" $ }}
+
+ {{ end }}
+{{ end }}
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
index 0154a58..04acbec 100644
--- a/layouts/partials/footer.html
+++ b/layouts/partials/footer.html
@@ -17,6 +17,43 @@
<p class="copyright">
&copy; {{ with .Site.Params.footer.copyright.name }}{{ . | markdownify }}{{ end }}. Code generated with <a href="https://gohugo.io/">Hugo</a>, theme based on <a href="https://github.com/kc0bfv/autophugo/">AutoPhugo</a>.
</p>
+
+ {{- /* Unfortunately I cannot find a way to determine if disableKinds
+ is turned on, so I cannot check that for taxonomy or term.
+ Instead I have to use this new parameter */}}
+ {{- if (default false ($.Param "taxonomies_links")) }}
+
+ {{- with $.Site.Taxonomies }}
+ <section class="taxonomy_list flexrow">
+ <h2>View all:</h2>
+ <div>
+ {{- range $taxname, $taxterms := $.Site.Taxonomies }}
+ <div class="tax_term"><a href="/{{ $taxname | urlize }}/">{{ $taxname | humanize }}</a></div>
+ {{- end }}
+ </div>
+ </section>
+ {{- end }}
+
+ {{- /* Only display the terms list if this page has some */}}
+ {{- $.Scratch.Set "terms_present" false }}
+ {{- range $taxname, $taxterms := $.Site.Taxonomies }}
+ {{- range ($.Param $taxname) }}
+ {{- $.Scratch.Set "terms_present" true }}
+ {{- end }}
+ {{- end }}
+ {{- if $.Scratch.Get "terms_present" }}
+ <section class="taxonomy_list flexrow">
+ <h2>Terms:</h2>
+ <div>
+ {{- range $taxname, $taxterms := $.Site.Taxonomies }}
+ {{- range ($.Param $taxname) }}
+ <div class="tax_term"><a href="/{{ $taxname | urlize }}/#{{ . | urlize }}">{{ . | humanize }}</a></div>
+ {{- end }}
+ {{- end }}
+ </div>
+ </section>
+ {{- end }}
+ {{- end }}
</div>
{{ if not .Site.Params.footer.contact.hide }}
<div>
diff --git a/layouts/partials/render_img_column_flexrow.html b/layouts/partials/render_img_column_flexrow.html
new file mode 100644
index 0000000..b5e164d
--- /dev/null
+++ b/layouts/partials/render_img_column_flexrow.html
@@ -0,0 +1,98 @@
+{{- /* This partial requires input context to have a Scratch with "content"
+
+ $.Scratch.Get "content" must return a slice (array) of object maps
+
+ Those objects need a "type" key, which can be "link" or something else.
+
+ See below to see what needs to be in those different types
+ */}}
+
+<div class="flexrow">
+
+ {{- $column_count := default 2 ($.Param "column_count") }}
+ {{- $downloadable := default true ($.Param "images_downloadable") }}
+ {{- $orig_download := default false ($.Param "images_downloadable_use_orig") }}
+
+ {{- /* Initialize the column storage */}}
+ {{- range $column_ind := seq $column_count }}
+ {{- $st_name := printf "col-%d" $column_ind }}
+ {{- $st_height_name := printf "col-height-%d" $column_ind }}
+ {{- $.Scratch.Set $st_name (slice) }}
+ {{- $.Scratch.Set $st_height_name 0 }}
+ {{- end }}
+
+
+ {{- /* Add the sections into the columns followed by images */}}
+ {{- range $elem_index, $elem_val := $.Scratch.Get "content" }}
+ {{- /* Find the least-filled column */}}
+ {{- $.Scratch.Set "min_height" -1 }}
+ {{- $.Scratch.Set "min_col" -1 }}
+ {{- range $column_ind := seq $column_count }}
+ {{- $st_height_name := printf "col-height-%d" $column_ind }}
+ {{- $col_height := $.Scratch.Get $st_height_name }}
+ {{- $min_height := $.Scratch.Get "min_height" }}
+ {{- if (or (eq $min_height -1) (lt $col_height $min_height)) }}
+ {{- $.Scratch.Set "min_height" $col_height }}
+ {{- $.Scratch.Set "min_col" $column_ind }}
+ {{- end }}
+ {{- end }}
+
+ {{- /* column_ind becomes the least-filled column */}}
+ {{- $column_ind := $.Scratch.Get "min_col" }}
+ {{- if eq $column_ind -1 }}
+ {{- errorf (printf "When processing '%s', failed to find a least-filled column!" $.Page.File.Path) }}
+ {{- end }}
+ {{- $st_name := printf "col-%d" $column_ind }}
+ {{- $st_height_name := printf "col-height-%d" $column_ind }}
+
+ {{- $column := $.Scratch.Get $st_name }}
+ {{- $column := $column | append $elem_val }}
+ {{- $.Scratch.Set $st_name $column }}
+
+ {{- $.Scratch.Set $st_height_name (add ($.Scratch.Get $st_height_name) $elem_val.thumb.Height) }}
+ {{- end }}
+
+ {{- /* Output the images in columns */}}
+ {{- range $column_ind := seq $column_count }}
+ {{- $st_name := printf "col-%d" $column_ind }}
+ {{- $column := $.Scratch.Get $st_name }}
+ <div class="flexcol">
+ {{- range $column }}
+ {{- $filename := path.Base .image.Name }}
+ <article class="thumb">
+ {{- if (eq .type "link") }}
+ <a href="{{ .link }}" class="link" tabindex="0"><img src="{{ .thumb.RelPermalink }}" alt="{{ .title }}" /></a>
+ <h2>{{ .title }}</h2>
+ {{- else }}
+ <a class="gallery-item" phototitle="{{ .phototitle }}"
+ description="{{ .description }}"
+ gallery_index="{{ .index }}"
+ id="{{ md5 $filename }}"
+ downloadable="{{ cond $downloadable "true" "false" }}"
+ {{- if $downloadable }}
+ download_file="{{ (cond $orig_download .orig .full).RelPermalink }}"
+ {{- end }}
+ orig_name="{{ $filename }}"
+ href="{{ .full.RelPermalink }}">
+ <div id="image_number_{{ .index }}" class="gallery-item-marker"></div>
+ <img src="{{ .thumb.RelPermalink }}"
+ {{ with .alt }} alt="{{ . }}"{{ end }}>
+ </a>
+ {{- if (default false ($.Param "taxonomies_links")) }}
+ <div class="caption_tax">
+ {{- range $taxname, $terms := .taxonomies }}
+ {{- range $terms }}
+ <div class="tax_term">
+ <a href="/{{ $taxname | urlize }}/#{{ . | urlize }}">{{ . | humanize }}</a>
+ </div>
+ {{- end }}
+ {{- end }}
+ </div>
+ {{- end }}
+ <h2>{{ .phototitle }}</h2>
+ {{- end }}
+ </article>
+ {{- end }}
+ </div>
+ {{- end }}
+</div>
diff --git a/layouts/partials/sect_and_img_content.html b/layouts/partials/sect_and_img_content.html
deleted file mode 100644
index 02c7ce5..0000000
--- a/layouts/partials/sect_and_img_content.html
+++ /dev/null
@@ -1,183 +0,0 @@
-<div id="main">
- <div class="flexrow">
-
- {{- /* Things in site config */}}
- {{- $column_count := default 2 ($.Param "column_count") }}
- {{- $thumb_width := default 480 ($.Param "thumb_width") }}
- {{- $full_width := default 960 ($.Param "full_width") }}
- {{- $thumb_quality := default 50 ($.Param "thumb_quality") }}
- {{- $full_quality := default 90 ($.Param "full_quality") }}
- {{- $filename_as_phototitle := default false ($.Param "filename_as_phototitle") }}
- {{- $downloadable := default true ($.Param "images_downloadable") }}
- {{- $orig_download := default false ($.Param "images_downloadable_use_orig") }}
-
- {{- /* Calculate thumb_ and full_size from params, unless one is provided in the config. */}}
- {{- $thumb_size := default (printf "%dx q%d" $thumb_width $thumb_quality) ($.Param "thumb_size") }}
- {{- $full_size := default (printf "%dx q%d" $full_width $full_quality) ($.Param "full_size") }}
-
- {{- /* Build the list of sections and thumbnails */}}
- {{- $.Scratch.Set "sections" (slice) }}
- {{- range .Sections.ByDate }}
- {{- $title := .Title }}
- {{- $link := .RelPermalink }}
- {{- $weight := default 0 (.Param "weight") }}
-
- {{- partial "scratch_set_retalbumthumb.html" . }}
- {{- /* Note that the Scratch below must come from . context, not $ */}}
- {{- $image := .Scratch.Get "retalbumthumb" }}
-
- {{- if not $image }}
- {{- errorf (printf "When processing '%s', no thumbnail image found for: %s" $.Page.File.Path $title) }}
- {{- else }}
- {{- $thumb := $image.Resize $thumb_size }}
- {{- $new_sect := dict "type" "sect" "title" $title "link" $link "thumb" $thumb "weight" $weight }}
-
- {{- $sections := $.Scratch.Get "sections" }}
- {{- $sections := $sections | append $new_sect }}
- {{- $.Scratch.Set "sections" $sections }}
- {{- end }}
- {{- end }}
- {{- /* Section list is complete, now resort */}}
- {{- $.Scratch.Set "sections" (sort ($.Scratch.Get "sections") "weight") }}
- {{- $sections := $.Scratch.Get "sections" }}
-
- {{- /* Get and reorder the list of images */}}
- {{- if .File }}
- {{- $imgglob := printf "%s" (path.Join .File.Dir "*") }}
- {{- $.Scratch.Set "imgglob" $imgglob }}
- {{- end }}
- {{- $imgglob := default "*" ($.Scratch.Get "imgglob") }}
- {{- $imageresources := where (resources.Match $imgglob) "ResourceType" "image" }}
- {{- $TODO_DELETE_images := $imageresources }}
-
- {{- /* Build some image objects */}}
- {{- $.Scratch.Set "images" (slice) }}
- {{- range $elem_index, $elem_val := $imageresources }}
-
- {{- /* Build some scratch for upcoming search... */}}
- {{- $img_dat := newScratch }}
- {{- $img_dat.Set "alt" "" }}
- {{- $img_dat.Set "description" "" }}
- {{- $img_dat.Set "weight" 0 }}
-
- {{- if $filename_as_phototitle }}
- {{- $filename := replace (path.Base $elem_val.Name) (path.Ext $elem_val.Name) "" }}
- {{- $img_dat.Set "phototitle" (humanize $filename) }}
- {{- else }}
- {{- $img_dat.Set "phototitle" "" }}
- {{- end }}
-
- {{- /* Search the resources for a matching image src, save off details */}}
- {{- $img_path := $elem_val.Name }}
- {{- with $.Params.resources }}
- {{- range first 1 (where . "src" $img_path) }}
- {{- if isset . "alt" }}{{ $img_dat.Set "alt" .alt }}{{ end }}
- {{- if isset . "phototitle" }}{{ $img_dat.Set "phototitle" .phototitle }}{{ end }}
- {{- if isset . "description" }}{{ $img_dat.Set "description" .description }}{{ end }}
- {{- if isset . "weight" }}{{ $img_dat.Set "weight" .weight }}{{ end }}
- {{- end }}
- {{- end }}
-
- {{- /* Save off the image object */}}
- {{- $alt := $img_dat.Get "alt" }}
- {{- $phototitle := $img_dat.Get "phototitle" }}
- {{- $description := $img_dat.Get "description" }}
- {{- $weight := $img_dat.Get "weight" }}
- {{- $thumb := $elem_val.Resize $thumb_size }}
- {{- $full := $elem_val.Resize $full_size }}
-
- {{- $new_img := dict "type" "image" "index" $elem_index "image" $elem_val "thumb" $thumb "full" $full "alt" $alt "phototitle" $phototitle "description" $description "weight" $weight "orig" $elem_val }}
-
- {{- $images := $.Scratch.Get "images" }}
- {{- $images := $images | append $new_img }}
- {{- $.Scratch.Set "images" $images }}
- {{- end }}
- {{- /* Image list is complete, now resort */}}
- {{- $.Scratch.Set "images" (sort ($.Scratch.Get "images") "weight") }}
- {{- $images := $.Scratch.Get "images" }}
-
- {{- /* Initialize the column storage */}}
- {{- range $column_ind := seq $column_count }}
- {{- $st_name := printf "col-%d" $column_ind }}
- {{- $st_height_name := printf "col-height-%d" $column_ind }}
- {{- $.Scratch.Set $st_name (slice) }}
- {{- $.Scratch.Set $st_height_name 0 }}
- {{- end }}
-
-
- {{- /* Add the sections into the columns followed by images */}}
- {{- range $elem_index, $elem_val := ($sections | append $images)}}
- {{- /* Find the least-filled column */}}
- {{- $.Scratch.Set "min_height" -1 }}
- {{- $.Scratch.Set "min_col" -1 }}
- {{- range $column_ind := seq $column_count }}
- {{- $st_height_name := printf "col-height-%d" $column_ind }}
- {{- $col_height := $.Scratch.Get $st_height_name }}
- {{- $min_height := $.Scratch.Get "min_height" }}
- {{- if (or (eq $min_height -1) (lt $col_height $min_height)) }}
- {{- $.Scratch.Set "min_height" $col_height }}
- {{- $.Scratch.Set "min_col" $column_ind }}
- {{- end }}
- {{- end }}
-
- {{- /* column_ind becomes the least-filled column */}}
- {{- $column_ind := $.Scratch.Get "min_col" }}
- {{- if eq $column_ind -1 }}
- {{- errorf (printf "When processing '%s', failed to find a least-filled column!" $.Page.File.Path) }}
- {{- end }}
- {{- $st_name := printf "col-%d" $column_ind }}
- {{- $st_height_name := printf "col-height-%d" $column_ind }}
-
- {{- $column := $.Scratch.Get $st_name }}
- {{- $column := $column | append $elem_val }}
- {{- $.Scratch.Set $st_name $column }}
-
- {{- $.Scratch.Set $st_height_name (add ($.Scratch.Get $st_height_name) $elem_val.thumb.Height) }}
- {{- end }}
-
- {{- /* Output the images in columns */}}
- {{- range $column_ind := seq $column_count }}
- {{- $st_name := printf "col-%d" $column_ind }}
- {{- $column := $.Scratch.Get $st_name }}
- <div class="flexcol">
- {{- range $column }}
- {{- $filename := path.Base .image.Name }}
- <article class="thumb">
- {{- if (eq .type "sect") }}
- <a href="{{ .link }}" class="link" tabindex="0"><img src="{{ .thumb.RelPermalink }}" alt="{{ .title }}" /></a>
- <h2>{{ .title }}</h2>
- {{- else }}
- <a class="gallery-item" phototitle="{{ .phototitle }}"
- description="{{ .description }}"
- gallery_index="{{ .index }}"
- id="{{ md5 $filename }}"
- downloadable="{{ cond $downloadable "true" "false" }}"
- {{- if $downloadable }}
- download_file="{{ (cond $orig_download .orig .full).RelPermalink }}"
- {{- end }}
- orig_name="{{ $filename }}"
- href="{{ .full.RelPermalink }}">
- <div id="image_number_{{ .index }}" class="gallery-item-marker"></div>
- <img src="{{ .thumb.RelPermalink }}"
- {{ with .alt }} alt="{{ . }}"{{ end }}>
- </a>
- <h2>{{ .phototitle }}</h2>
- {{- end }}
- </article>
- {{- end }}
- </div>
- {{- end }}
- </div>
-</div>
-
-
-
-
-
-
-
-
-
-
-
-