From cd53a2fe5fc8baf9750fbd2d9b0b4c855d8694a7 Mon Sep 17 00:00:00 2001 From: pdp8 Date: Mon, 29 Jul 2024 14:21:31 +0200 Subject: rss sorting fixed, rss limited to 25 items, fediring --- Makefile | 16 ++--- climbing.rb | 28 ++++----- html.rb | 189 --------------------------------------------------------- html/style.css | 29 ++++++--- lib.rb | 35 ++++++++--- music.rb | 3 - rss.rb | 40 ++++++------ 7 files changed, 90 insertions(+), 250 deletions(-) delete mode 100755 html.rb diff --git a/Makefile b/Makefile index c8db1a6..bb2e7d3 100644 --- a/Makefile +++ b/Makefile @@ -28,11 +28,11 @@ VIDEO_WEBP := $(subst webm,webp, $(VIDEO_WEBM)) VIDEO_PNG := $(subst webm,png, $(VIDEO_WEBM)) CLIMBING_DIR := /srv/media/climbing -CLIMBING_WEBM := $(wildcard $(CLIMBING_DIR)/*.webm) +CLIMBING_WEBM := $(wildcard $(CLIMBING_DIR)/*/*.webm) CLIMBING_MP4 := $(subst webm,mp4, $(CLIMBING_WEBM)) CLIMBING_WEBP := $(subst webm,webp, $(CLIMBING_WEBM)) -HTML := index.html music.html pictures.html videos.html climbing.html about.html code.html contact.html #social/create.html social/announce.html +HTML := index.html music.html pictures.html videos.html climbing.html about.html code.html contact.html OTHER := pdp8.png 540px-PDP-8_.jpg style.css sitemap.txt rss.xml TEST_HTML := $(addprefix $(TEST_DIR)/, $(HTML)) @@ -61,12 +61,6 @@ $(TEST_DIR)/pictures.html: $(IMG_ALBUMS) $(WEBP_IMG) $(THUMB_IMG) $(TEST_DIR)/videos.html: $(VIDEO_MP4) $(VIDEO_WEBP) ./videos.rb -# $(TEST_DIR)/social/create.html: -# ./social.rb create - -# $(TEST_DIR)/social/announce.html: -# ./social.rb announce - $(TEST_DIR)/climbing.html: $(CLIMBING_MP4) $(CLIMBING_WEBP) ./climbing.rb @@ -88,14 +82,14 @@ $(TEST_DIR)/%.txt: ./html/%.txt %.mp3: %.flac ffmpeg -i $< -y -vsync 0 -ab 256k -map_metadata 0 -id3v2_version 3 $@ -%.webp: %.webm - ffmpeg -i $< -loglevel error -vf thumbnail -frames:v 1 -c:v png -f image2pipe - | magick - $@ - $(WEBP_DIR)/%.webp: $(JPEG_DIR)/%.jpeg magick $< -resize 1536x1024 -quality 85 $@ $(THUMB_DIR)/%.webp: $(JPEG_DIR)/%.jpeg magick $< -resize 150x100 -quality 85 $@ +%.webp: %.webm + ffmpeg -i $< -loglevel error -vf thumbnail -frames:v 1 -c:v png -f image2pipe - | magick - $@ + %.mp4: %.webm ffmpeg -i $< -vf scale=1280:-2 -c:v h264 -c:a aac -b:a 128k -strict -2 -movflags faststart $@ diff --git a/climbing.rb b/climbing.rb index 139925d..c016bfa 100755 --- a/climbing.rb +++ b/climbing.rb @@ -1,25 +1,23 @@ #!/usr/bin/env ruby require_relative 'lib' +climbing = Dir[File.join(MEDIA_DIR, 'climbing', '*')].select { |f| File.directory? f }.sort.reverse html = File.read(File.join(SNIPPETS, 'head.html')) html += nav 'climbing' -Dir[File.join(MEDIA_DIR, 'climbing', '*.txt')].collect do |txt| - lines = File.read(txt).lines.collect { |l| l.chomp } - { date: lines.shift, - text: lines.join('
'), - mp4: txt.sub(MEDIA_DIR, MEDIA_URL).sub('.txt', '.mp4'), - webm: txt.sub(MEDIA_DIR, MEDIA_URL).sub('.txt', '.webm'), - webp: txt.sub(MEDIA_DIR, MEDIA_URL).sub('.txt', '.webp') } -end.sort_by { |m| m[:date] }.reverse.each do |post| - html += '
' - html += "

#{post[:date]}

" - html += "
+ +
+
+ fediring: + + random + +
+
+ faircamp: + + random + +
+
+ + " html end diff --git a/music.rb b/music.rb index c63f17d..c01faf8 100755 --- a/music.rb +++ b/music.rb @@ -5,9 +5,6 @@ require_relative 'lib' music = Dir[File.join(MEDIA_DIR, 'music', '20*')].sort.reverse html = File.read(File.join(SNIPPETS, 'head.html')) html += nav 'music' -html += '
-faircamp webring:   -← prev | random | next →
' music.each do |dir| date = File.basename(dir).split('_')[0] html += "
" diff --git a/rss.rb b/rss.rb index eb163d4..68c9632 100755 --- a/rss.rb +++ b/rss.rb @@ -1,28 +1,41 @@ #!/usr/bin/env ruby +require_relative 'lib' require 'date' +require 'time' require 'json' -MEDIA = '/srv/media/' -SOCIAL = '/srv/social/outbox/object/note/' -WWW = '/srv/www/pdp8-test/' +# SOCIAL = '/srv/social/outbox/object/note/' items = [] -%w[music videos].each do |cat| - Dir[File.join(MEDIA, cat, '*')].each do |dir| +%w[music videos climbing].each do |cat| + Dir[File.join(MEDIA_DIR, cat, '*')].each do |dir| next unless File.basename(dir).match(/^\d/) date = File.basename(dir).split('_')[0] updated = Date.parse(date) + title = File.basename(dir).split('_')[1..-1].join(' ') + description = File.read(File.join(dir, 'README')).chomp.sub(/^\n/, '').sub("\n\n", "\n") + title = description if title.empty? + # title = date if title.empty? items << { - title: File.basename(dir).split('_')[1..-1].join(' '), + title: title, link: File.join('https://pdp8.info', cat + '.html#' + date), guid: File.join('https://pdp8.info', cat + '.html#' + date), - description: '', + description: "", pubDate: updated.httpdate } end end +Dir[File.join MEDIA_DIR, 'pictures', 'albums', '*'].each do |album| + items << { + title: File.basename(album).sub('_', ' '), + link: File.join('https://pdp8.info', 'pictures.html#' + File.basename(album)), + guid: File.join('https://pdp8.info', 'pictures.html#' + File.basename(album)), + pubDate: File.mtime(album).httpdate + } +end + # duplication of music/video posts? # Dir[File.join(SOCIAL, '*.json')].each do |json| # note = JSON.parse(File.read(json)) @@ -39,14 +52,7 @@ end # } # end -date = Dir[File.join(MEDIA, 'pictures', '*.jpeg')].last.split('_')[0] -updated = Date.parse(date) -items << { - title: 'pictures', - link: 'https://pdp8.info/pictures.html', - guid: 'https://pdp8.info/pictures.html', - pubDate: updated.httpdate -} +# jj items.sort_by { |i| DateTime.parse(i[:pubDate]) }.reverse xml = [' date = DateTime.now xml << " #{date.httpdate}" -items.sort_by { |i| i['pubDate'] }.each do |item| +items.sort_by { |i| DateTime.parse(i[:pubDate]) }.reverse[0..24].each do |item| xml << ' ' item.each do |k, v| xml << " <#{k}>#{v}" @@ -72,4 +78,4 @@ end xml << ' ' -File.open(File.join(WWW, 'rss.xml'), 'w+') { |f| f.puts xml.join("\n") } +File.open(File.join(WWW_DIR, 'rss.xml'), 'w+') { |f| f.puts xml.join("\n") } -- cgit v1.2.3