summaryrefslogtreecommitdiff
path: root/pictures.rb
blob: 2758436883b30fc4e20f9769bb4015d113fed14a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env ruby
require_relative 'lib'
require 'json'

html = File.read(File.join(SNIPPETS, 'head.html'))
html += nav 'pictures'
html += "<div class='gallery'>"
Dir[File.join(OUTBOX_DIR, 'create', '*.json')]
  .collect { |f| JSON.load_file(f) }
  .select { |a| a['to'].include?('https://www.w3.org/ns/activitystreams#Public') }
  .sort_by { |a| a['published'] }.reverse
  .collect { |a| a['object'] }
  .collect { |o| o['attachment'] }
  .flatten.compact
  .select { |a| a['url'] =~ %r{pictures/webp} and a['mediaType'] == 'image/webp' }
  .each do |img|
  # html += '<section>'
  html += "<img loading='lazy' "
  alt = img['name'] ? img['name'].gsub("'", '&apos;').gsub('"', '&quot;') : ''
  html += "alt='#{alt}' src='#{img['url']}'>"
  # html += '</section>'
end
html += '</div>'
html += File.read(File.join(SNIPPETS, 'tail.html'))
print_html 'pictures', html