Add new post type
This commit is contained in:
13
make-post.py
13
make-post.py
@@ -5,6 +5,13 @@ from os.path import isfile, join
|
||||
import random
|
||||
|
||||
|
||||
def post_photo():
|
||||
# get the current year as variable
|
||||
year = str(datetime.datetime.now().year)
|
||||
name = input("Give me the title\n")
|
||||
os.system(f"hugo new photos/{year}/{name.replace(' ','-').replace(',','').lower()}/index.md")
|
||||
|
||||
|
||||
def post_fc():
|
||||
# get the current year as variable
|
||||
year = str(datetime.datetime.now().year)
|
||||
@@ -26,12 +33,12 @@ def quiet_fc():
|
||||
print(f"Generated {generated}.md")
|
||||
|
||||
|
||||
ANSWER = {"post": post_fc, "quiet": quiet_fc}
|
||||
ANSWER = {"post": post_fc, "quiet": quiet_fc, 'photo': post_photo}
|
||||
|
||||
|
||||
def main_checker():
|
||||
# text = input("You need a new [post] or a new [quiet]\n") # Python 3
|
||||
text = "post"
|
||||
text = input("You need a new [post], a new [photo] or a new [quiet]\n") # Python 3
|
||||
# text = "post"
|
||||
ANSWER.get(text, main_checker)()
|
||||
|
||||
|
||||
|
||||
14
themes/fugu/archetypes/photos.md
Normal file
14
themes/fugu/archetypes/photos.md
Normal file
@@ -0,0 +1,14 @@
|
||||
---
|
||||
title: "Routine"
|
||||
date: "2023-09-28T07:57:25+01:00"
|
||||
tags:
|
||||
- challenge
|
||||
- blackandwhite
|
||||
description: "A black and white photo of a level crossing with barriers down across the road. A train coming from left to right across the image has just entered the crossing. On the far side of the tracks, brick building line the railway. On the near side, a bike rests against the warning lights."
|
||||
resources:
|
||||
- title: Routine
|
||||
src: '_D0A7928-2.jpg'
|
||||
---
|
||||
|
||||
## Challenge
|
||||
Example of the photo
|
||||
40
themes/fugu/layouts/photos/list.html
Normal file
40
themes/fugu/layouts/photos/list.html
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
{{ define "main" }}
|
||||
<!--Implementation from https://billglover.me/2023/11/07/creating-a-photography-gallery-with-hugo/ -->
|
||||
<header>
|
||||
<h1>{{ .Title }}</h1>
|
||||
{{.Content}}
|
||||
</header>
|
||||
<section class="container">
|
||||
<div class="row">
|
||||
{{ range .Pages.GroupByDate "Jan 2006" }}
|
||||
<h4>{{ .Key }}</h4>
|
||||
{{ range .Pages }}
|
||||
<div class="col-6 col-lg-4">
|
||||
{{ $banner := index (.Resources.ByType "image") 0 }}
|
||||
|
||||
{{ $tiny := ($banner.Fill "webp 400x300 q90") }}
|
||||
{{ $small := ($banner.Fill "webp 600x450 q90") }}
|
||||
{{ $medium := ($banner.Fill "webp 800x600 q90") }}
|
||||
{{ $large := ($banner.Fill "webp 1200x700 q90") }}
|
||||
<a href="{{ .RelPermalink }}" title="{{ .Title }}">
|
||||
<img
|
||||
srcset="
|
||||
{{- with $tiny.RelPermalink -}}{{.}} 480w{{- end -}}
|
||||
{{- with $small.RelPermalink -}}, {{.}} 768w{{- end -}}
|
||||
{{- with $medium.RelPermalink -}}, {{.}} 1024w{{- end -}}
|
||||
{{- with $large.RelPermalink -}}, {{.}} 1366w{{- end -}}"
|
||||
src="{{ $banner.RelPermalink }}"
|
||||
alt="{{ .Description }}" class="img-fluid lazy" loading="lazy">
|
||||
</a>
|
||||
</div>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
</div>
|
||||
</section>
|
||||
<footer></footer>
|
||||
{{- end }}
|
||||
|
||||
{{ define "header" }}
|
||||
{{- partial "header" . -}}
|
||||
{{ end }}
|
||||
183
themes/fugu/layouts/photos/single.html
Normal file
183
themes/fugu/layouts/photos/single.html
Normal file
@@ -0,0 +1,183 @@
|
||||
{{ define "main" }}
|
||||
<!--Implementation from https://billglover.me/2023/11/07/creating-a-photography-gallery-with-hugo/ -->
|
||||
|
||||
<article itemscope itemType="https://schema.org/BlogPosting">
|
||||
<header>
|
||||
<div class="container">
|
||||
<h1 class="p-name text-center">
|
||||
{{ .Title }}
|
||||
</h1>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<main itemprop="articleBody" class="md">
|
||||
|
||||
<section class="meta p-name text-center">
|
||||
{{ $dataFormat := .Site.Params.dateFormat | default "2006-01-02" }}
|
||||
<span><time datetime="{{ .Date }}" itemprop="datePublished">{{ .Date.Format $dataFormat }}</time></span>
|
||||
{{ if (and .Site.Params.showUpdated (ne .Lastmod .Date)) }}
|
||||
<span>(Updated: <time datetime="{{ .Lastmod }}" itemprop="dateModified">{{ .Lastmod.Format $dataFormat }}</time>)</span>
|
||||
{{ end }}
|
||||
|
||||
{{ with (.GetTerms "tags") }}
|
||||
<div class="text-center">
|
||||
{{ range . }}
|
||||
<a class="btn tag m-2" href='{{ "/tags/" | relLangURL }}{{ .LinkTitle | urlize }}'>
|
||||
<i class="fa-duotone theme-fundor333 fa-tags"></i> {{ .LinkTitle}}
|
||||
</a>
|
||||
{{ end }}
|
||||
</div>
|
||||
<hr>
|
||||
{{ end }}
|
||||
</section>
|
||||
|
||||
{{ with .Resources.ByType "image" }}
|
||||
{{ range . }}
|
||||
{{ $image := .Fit "1024x1024" }}
|
||||
<div class="text-center">
|
||||
|
||||
<figure class="figure">
|
||||
<img loading="lazy" class="u-photo img-fluid lazy" src="{{ $image.RelPermalink }}" width="{{ $image.Width }}" height="{{ $image.Height }}" alt="{{ $.Description }}">
|
||||
<figcaption class="figure-caption">{{ $.Description }}</figcaption>
|
||||
</figure>
|
||||
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
{{ if isset .Params "license" }}
|
||||
{{ partial "cc-license.html" (dict "license" .Params.license "title" $image.Title "workURL" $.Page.Permalink "author" $.Site.Params.Author "authorURL" $.Site.BaseURL) }}
|
||||
{{ else }}
|
||||
{{ with $.Site.Params.photolicense }}
|
||||
{{ partial "cc-license.html" (dict "license" $.Site.Params.photolicense "title" $image.Title "workURL" $.Page.Permalink "author" $.Site.Params.Author "authorURL" $.Site.BaseURL) }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ with .Exif }}
|
||||
<h2>Metadata</h2>
|
||||
<table class="table table-bordered">
|
||||
{{ with $image.Title }}
|
||||
<tr>
|
||||
<th scope="col">Title</th>
|
||||
<td>{{ . }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ with .Date }}
|
||||
<tr>
|
||||
<th scope="col">Date</th>
|
||||
<td>{{ . }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ if isset .Tags "Model" }}
|
||||
<tr>
|
||||
<th>Camera</th>
|
||||
<td>{{ .Tags.Model }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ if isset .Tags "LensModel" }}
|
||||
<tr>
|
||||
<th>Lens</th>
|
||||
<td>{{ .Tags.LensModel }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ if isset .Tags "ExposureTime" }}
|
||||
<tr>
|
||||
<th>Exposure Time</th>
|
||||
<td>{{ .Tags.ExposureTime }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ if isset .Tags "FNumber" }}
|
||||
<tr>
|
||||
<th>F Number</th>
|
||||
<td>{{ .Tags.FNumber }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ if isset .Tags "ISOSpeedRatings" }}
|
||||
<tr>
|
||||
<th>ISO</th>
|
||||
<td>{{ .Tags.ISOSpeedRatings }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ if isset .Tags "FocalLength" }}
|
||||
<tr>
|
||||
<th>Focal Length</th>
|
||||
<td>{{ .Tags.FocalLength }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ if isset .Tags "ExposureMode" }}
|
||||
<tr>
|
||||
<th>Exposure Mode</th>
|
||||
<td>
|
||||
{{ with (eq .Tags.ExposureMode 1) }}Manual{{ end }}
|
||||
{{ with (eq .Tags.ExposureMode 0) }}Auto{{ end }}
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ if isset .Tags "ExposureProgram" }}
|
||||
<tr>
|
||||
<th>Exposure Program</th>
|
||||
<td>
|
||||
{{ with (eq .Tags.WhiteBalance 1) }}Manual{{ end }}
|
||||
{{ with (eq .Tags.WhiteBalance 0) }}Auto{{ end }}
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ with .Tags.ExposureBiasValue }}
|
||||
<tr>
|
||||
<th>Exposure Compensation</th>
|
||||
<td>{{ . }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ if isset .Tags "WhiteBalance" }}
|
||||
<tr>
|
||||
<th>White Balance</th>
|
||||
<td>
|
||||
{{ with (eq .Tags.WhiteBalance 1) }}Manual{{ end }}
|
||||
{{ with (eq .Tags.WhiteBalance 0) }}Auto{{ end }}
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
{{ if isset .Tags "MeteringMode" }}
|
||||
<tr>
|
||||
<th>Metering Mode</th>
|
||||
<td>
|
||||
{{ with (eq .Tags.MeteringMode 0) }}Unknown{{ end }}
|
||||
{{ with (eq .Tags.MeteringMode 1) }}Average{{ end }}
|
||||
{{ with (eq .Tags.MeteringMode 2) }}Center Weighted Average{{ end }}
|
||||
{{ with (eq .Tags.MeteringMode 3) }}Spot{{ end }}
|
||||
{{ with (eq .Tags.MeteringMode 4) }}MultiSpot{{ end }}
|
||||
{{ with (eq .Tags.MeteringMode 5) }}Pattern{{ end }}
|
||||
{{ with (eq .Tags.MeteringMode 6) }}Partial{{ end }}
|
||||
{{ with (eq .Tags.MeteringMode 255) }}other{{ end }}
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</table>
|
||||
{{ end }}
|
||||
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ block "content" . }} {{- .Content }} {{- end }}
|
||||
</main>
|
||||
|
||||
<div class="container">
|
||||
{{- partial "webmention.html" . -}}
|
||||
</div>
|
||||
|
||||
{{ $related := .Site.RegularPages.Related . | first 4 }}
|
||||
{{ with $related }}
|
||||
<div class="flex flex-col">
|
||||
<h3 class="text-center">See Also</h3>
|
||||
{{ range . }}
|
||||
{{ .Render "summary" }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
</article>
|
||||
{{- end }}
|
||||
|
||||
{{ define "header" }}
|
||||
{{- partial "header" . -}}
|
||||
{{ end }}
|
||||
35
themes/fugu/layouts/photos/summary.html
Normal file
35
themes/fugu/layouts/photos/summary.html
Normal file
@@ -0,0 +1,35 @@
|
||||
<!--Implementation from https://billglover.me/2023/11/07/creating-a-photography-gallery-with-hugo/ -->
|
||||
<div class="col-start-2 col-10 offset-1 mb-5">
|
||||
<article class="flex flex-col items-center text-center h-entry">
|
||||
<a href="{{ .Permalink }}">
|
||||
{{ $banner := index (.Resources.ByType "image") 0 }}
|
||||
<div class="col-10 offset-1 text-center">
|
||||
|
||||
{{ $tiny := ($banner.Fill "webp 400x300 q90") }}
|
||||
{{ $small := ($banner.Fill "webp 600x450 q90") }}
|
||||
{{ $medium := ($banner.Fill "webp 800x600 q90") }}
|
||||
{{ $large := ($banner.Fill "webp 1200x700 q90") }}
|
||||
|
||||
<img
|
||||
srcset="
|
||||
{{- with $tiny.RelPermalink -}}{{.}} 480w{{- end -}}
|
||||
{{- with $small.RelPermalink -}}, {{.}} 768w{{- end -}}
|
||||
{{- with $medium.RelPermalink -}}, {{.}} 1024w{{- end -}}
|
||||
{{- with $large.RelPermalink -}}, {{.}} 1366w{{- end -}}"
|
||||
src="{{ $banner.RelPermalink }}"
|
||||
alt="{{ .Description }}" class="img-fluid lazy" loading="lazy">
|
||||
|
||||
</div>
|
||||
|
||||
</a>
|
||||
|
||||
<a href="{{ .Permalink }}">
|
||||
<h1 class="text-center p-name">{{ .Title }}</h1>
|
||||
</a>
|
||||
|
||||
<a href="{{ .Permalink }}"
|
||||
class="p-summary d-flex align-items-center justify-content-center pt-3"><p>{{ .Description }}</p></a>
|
||||
|
||||
|
||||
</article>
|
||||
</div>
|
||||
Reference in New Issue
Block a user