aboutsummaryrefslogtreecommitdiff
path: root/_plugins/linter.rb
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--_plugins/linter.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/_plugins/linter.rb b/_plugins/linter.rb
index 5d78c17..aa55c8c 100644
--- a/_plugins/linter.rb
+++ b/_plugins/linter.rb
@@ -134,9 +134,50 @@ module Jekyll
end
end
+ def assert_media_metadata(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']
+ file = "resources/#{name}/#{date}-#{slug}.flac"
+ if name == 'podcasts'
+ stdout = `metaflac --export-tags-to=- #{file}`
+ file_metadata = stdout.strip.split("\n")
+ expected = [
+ "COMMENTS=#{site.config['url']}/#{file}",
+ 'ARTIST=EuAndreh',
+ "DATE=#{date}",
+ "TITLE=#{document.data['title']}",
+ "ALBUM=#{site.config['t']['podcasts']['feed']['title'][document.data['lang']]}"
+ ]
+ expected.each do |metadata|
+ unless file_metadata.include? metadata
+ tags = expected.join('\\n').gsub(/'/, "'\"'\"'")
+ add_metadata_cmd = "metaflac --remove-all #{file}\nprintf '#{tags}\\n' | metaflac --import-tags-from=- #{file}"
+ check_metadata_cmd = "metaflac --export-tags-to=- #{file}"
+ raise "Missing metadata entry '#{metadata}' in '#{file}'.\nAdd it with:\n\n#{add_metadata_cmd}\n\nCheck with:\n #{check_metadata_cmd}"
+ end
+ end
+
+ check_cover_cmd = "metaflac #{file} --export-picture-to=- | diff - static/favicon.svg"
+ `#{check_cover_cmd}`
+ unless $?.success? then
+ add_cover_cmd = "metaflac #{file} --import-picture-from='3|image/svg+xml||420x420x24|static/favicon.svg'"
+ raise "Cover art from '#{file}' doesn't match 'static/favicon.svg'.\nFix it with:\n\n#{add_cover_cmd}\n\nCheck with:\n #{check_cover_cmd}"
+ end
+ elsif name == 'screencasts' then
+ p document
+ end
+ end
+ end
+ end
+ end
+
def generate(site)
assert_unique_ids(site)
assert_frontmatter(site)
+ assert_media_metadata(site)
assert_git_annex(site)
end