aboutsummaryrefslogtreecommitdiff
path: root/_plugins/generate-lilypond.rb
blob: c0c1a13c97ba80b0b719c453664e57f259c86e91 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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