diff options
-rw-r--r-- | Makefile | 16 | ||||
-rw-r--r-- | _plugins/generate-torrent.rb | 42 |
2 files changed, 12 insertions, 46 deletions
@@ -31,9 +31,14 @@ podcasts.flac = \ resources/podcasts/2020-12-19-a-test-entry.flac podcasts.ogg = $(podcasts.flac:.flac=.ogg) +screencasts.webm = \ + resources/screencasts/2021-02-07-autoqemu-automate-installation-and-ssh-setup-of-iso-os-images.webm + torrents-in = \ $(podcasts.flac) \ - $(podcasts.ogg) + $(podcasts.ogg) \ + $(screencasts.webm) + torrents = $(torrents-in:=.torrent) derived-assets = \ @@ -56,9 +61,9 @@ torrents-files.txt: $(torrents-in) torrent-files.mk: torrents-files.txt printf 'torrent-files = \\\n' > $@ - sed -e 's/^/\t/' -e 's/$$/.torrent \\/' < torrents.txt >> $@ + sed -e 's/^/\t/' -e 's/$$/.torrent \\/' < torrents-files.txt >> $@ printf '\n\n' >> $@ - awk '{ printf "%s.torrent: %s\n", $$1, $$1 }' torrents.txt >> $@ + awk '{ printf "%s.torrent: %s\n", $$1, $$1 }' torrents-files.txt >> $@ $(torrents): torrent-files.mk $(MAKE) -f Makefile.dynamic torrents @@ -80,7 +85,10 @@ check: dev-check: check clean: - rm -rf public/ $(derived-assets) + rm -rf \ + public/ \ + $(derived-assets) \ + torrents-files.txt torrent-files.mk public: jekyll-deps jekyll build diff --git a/_plugins/generate-torrent.rb b/_plugins/generate-torrent.rb deleted file mode 100644 index 580bcf8..0000000 --- a/_plugins/generate-torrent.rb +++ /dev/null @@ -1,42 +0,0 @@ -module Jekyll - class TorrentGenerator < Generator - safe true - - MEDIA_EXTENSION = { - 'podcasts' => 'ogg', - 'screencasts' => 'webm' - } - - def generate(site) - site.collections.each do |name, collection| - if ['podcasts', 'screencasts'].include? name then - collection.docs.each do |document| - date = document.data['date'].strftime('%Y-%m-%d') - slug = document.data['slug'] - extension = MEDIA_EXTENSION[name] - file = "#{date}-#{slug}.#{extension}" - media = "resources/#{name}/#{file}" - torrent = "#{media}.torrent" - - unless File.exist? torrent then - webseed = "#{site.config['url']}/#{media}" - puts "Missing '#{torrent}' file, generating..." - puts `mktorrent -f -v -d -c '#{document.content}' -n #{file} -w #{webseed} -o #{torrent} #{media}` - end - - checksum_file = "#{torrent}.checksum" - checksum = `sha256sum #{media} #{torrent} | sha256sum | awk '{ print $1 }'` - if File.exist? checksum_file then - unless checksum == File.read(checksum_file) - raise "Checksum mismatch for '#{media}'.\nRe-generate the torrent files and checksums with:\n\nrm '#{torrent}' '#{checksum_file}'" - end - else - puts "Missing checksum for '#{media}', generating..." - File.write(checksum_file, checksum) - end - end - end - end - end - end -end |