aboutsummaryrefslogtreecommitdiff
path: root/_plugins/generate-lilypond.rb
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2021-01-01 22:17:00 -0300
committerEuAndreh <eu@euandre.org>2021-01-01 22:22:30 -0300
commit8344825a7b4d006fb6a163d87636b589d8af25cc (patch)
tree2f9bd12b7bc64c661f6d2332bbf618dcfce584b4 /_plugins/generate-lilypond.rb
parentpost.html: Add trailing '/' to source tag (diff)
downloadeuandre.org-8344825a7b4d006fb6a163d87636b589d8af25cc.tar.gz
euandre.org-8344825a7b4d006fb6a163d87636b589d8af25cc.tar.xz
Add support for "Music"
Diffstat (limited to '_plugins/generate-lilypond.rb')
-rw-r--r--_plugins/generate-lilypond.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/_plugins/generate-lilypond.rb b/_plugins/generate-lilypond.rb
new file mode 100644
index 0000000..c0c1a13
--- /dev/null
+++ b/_plugins/generate-lilypond.rb
@@ -0,0 +1,28 @@
+module Jekyll
+ class LilyPondGenerator < Generator
+ safe true
+ priority :high
+
+ def generate(site)
+ site.config['musics'].each do |music|
+ ref = music['ref']
+ file = "music/#{ref}"
+ ly = "#{file}.ly"
+ pdf = "#{file}.pdf"
+ unless File.exist? pdf then
+ puts "Missing '#{pdf}', generating..."
+ puts `lilypond -o #{file} #{ly}`
+ site.static_files << Jekyll::StaticFile.new(site, site.source, '', pdf)
+ end
+
+ ogg = "#{file}.ogg"
+ midi = "#{file}.midi"
+ unless File.exist? ogg then
+ puts "Missing '#{ogg}', generating..."
+ puts `timidity -Ov #{midi}`
+ site.static_files << Jekyll::StaticFile.new(site, site.source, '', ogg)
+ end
+ end
+ end
+ end
+end