From 9c29a0f029f01c566decfed4204c46cd77fad6c7 Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Thu, 24 Dec 2020 18:45:16 -0300 Subject: lint-hook.rb: Make Jekyll aware of the generated ogg files --- _plugins/lint-hook.rb | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to '_plugins/lint-hook.rb') diff --git a/_plugins/lint-hook.rb b/_plugins/lint-hook.rb index 57c2e27..634db80 100644 --- a/_plugins/lint-hook.rb +++ b/_plugins/lint-hook.rb @@ -67,7 +67,7 @@ module Jekyll 'screencasts' => 'cast' } - def assert_frontmatter_fields(config, name, document) + def assert_frontmatter_fields(site, name, document) title = assert_field document, 'title' lang = assert_field document, 'lang' ref = assert_field document, 'ref' @@ -112,16 +112,17 @@ module Jekyll raise "Missing FLAC file '#{flac}'" end + file = "#{date}-#{slug}.ogg" ogg = "resources/podcasts/#{date}-#{slug}.ogg" unless File.exist? ogg then puts "Missing '#{ogg}' file, generating..." puts `ffmpeg -i #{flac} -ar 48000 -vn -c:a libvorbis -b:a 320k #{ogg}` + site.static_files << Jekyll::StaticFile.new(site, site.source, '', ogg) end torrent = "#{ogg}.torrent" unless File.exist? torrent then - webseed = "#{config['url']}/#{ogg}" - file = "#{date}-#{slug}.ogg" + webseed = "#{site.config['url']}/#{ogg}" puts "Missing '#{torrent}' file, generating..." puts `mktorrent #{TRACKERS} -f -v -d -c '#{document.content}' -n #{file} -w #{webseed} -o #{torrent} #{ogg}` end @@ -135,7 +136,7 @@ module Jekyll torrent = "#{mkv}.torrent" unless File.exist? torrent then - webseed = "#{config['url']}/#{mkv}" + webseed = "#{site.config['url']}/#{mkv}" file = "#{date}-#{slug}.mkv" puts "Missing '#{torrent}' file, generating..." puts `mktorrent #{TRACKERS} -f -v -d -c '#{document.content}' -n #{file} -w #{webseed} -o #{torrent} #{mkv}` @@ -146,13 +147,13 @@ module Jekyll def assert_frontmatter(site) site.collections.each do |name, collection| collection.docs.each do |document| - assert_frontmatter_fields site.config, name, document + assert_frontmatter_fields site, name, document end end site.pages.each do |page| unless IGNORED_PAGES.include? page.path - assert_frontmatter_fields site.config, 'page', page + assert_frontmatter_fields site, 'page', page end end end -- cgit v1.2.3