1
0
mirror of https://github.com/danbee/danbarber.me.hugo.git synced 2025-03-04 08:59:18 +00:00

Compare commits

...

2 Commits

Author SHA1 Message Date
2b00bc0a01 Add I Destroy Silence post 2024-04-21 22:19:03 -05:00
e941f99229 Add Ruby script to generate photo post 2024-04-21 22:18:45 -05:00
7 changed files with 102 additions and 0 deletions

View File

@ -1 +1,2 @@
hugo extended_0.120.4
ruby 3.2.2

5
Gemfile Normal file
View File

@ -0,0 +1,5 @@
source "https://rubygems.org"
gem "erb"
gem "exiftool"
gem "pry"

26
Gemfile.lock Normal file
View File

@ -0,0 +1,26 @@
GEM
remote: https://rubygems.org/
specs:
cgi (0.4.1)
coderay (1.1.3)
erb (4.0.4)
cgi (>= 0.3.3)
exiftool (1.2.5)
json
json (2.7.2)
method_source (1.1.0)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
PLATFORMS
arm64-darwin-23
ruby
DEPENDENCIES
erb
exiftool
pry
BUNDLED WITH
2.5.9

View File

@ -0,0 +1,20 @@
---
title: "<%= photo[:title] %>"
date: <%= date %>
categories:
tags:
layout: post
image: <%= photo[:file_name] %>
---
<figure class="photo photo--wide">
<img src="<%= photo[:file_name] %>" alt="<%= photo[:image_description] %>">
<figcaption>
<%= photo[:model] %>,
<%= (photo[:focal_length35efl] || photo[:focal_length]).gsub(" mm", "mm") %>,
ISO <%= photo[:iso] %>,
<%= photo[:shutter_speed] %>
at ƒ/<%= photo[:f_number] %>
</figcaption>
</figure>

30
bin/create_photo Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env ruby
require "erb"
require "exiftool"
require "i18n"
require "pry"
I18n.config.available_locales = :en
def parameterize(string)
I18n.transliterate(string)
.downcase
.gsub(/[^a-z]+/, "-")
end
photo_path = ARGV.first
photo = Exiftool.new(photo_path)
date = Date.today.iso8601
template = ERB.new(File.read("archetypes/photos/index.md.erb"))
post_dir = "content/photos/#{date}-#{parameterize(photo[:title])}"
if !Dir.exist?(post_dir)
Dir.mkdir(post_dir)
end
FileUtils.cp(photo_path, "#{post_dir}/#{photo[:file_name]}")
File.write("#{post_dir}/index.md", template.result)

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

View File

@ -0,0 +1,20 @@
---
title: "I Destroy Silence"
date: 2024-04-21
categories:
tags:
layout: post
image: IMG_6362.jpeg
---
<figure class="photo photo--wide">
<img src="IMG_6362.jpeg" alt="Sofía and I at my SMC gig on Saturday">
<figcaption>
iPhone 15 Pro Max,
6.8mm (35mm equivalent: 24.0mm),
ISO 3200,
1/15
at ƒ/1.8
</figcaption>
</figure>