diff options
-rwxr-xr-x | build.rb | 22 |
1 files changed, 20 insertions, 2 deletions
@@ -35,6 +35,16 @@ def forImgs(imgs, &block) end end +def placeImage(file, src, href = nil) + if href + file.puts "<a href=\"#{href}\">" + end + file.puts "<img src=\"#{src}\">" + if href + file.puts "</a>" + end +end + options = {} OptionParser.new do |opts| opts.banner = "Usage: build.rb dest" @@ -51,6 +61,9 @@ OptionParser.new do |opts| opts.on("-c", "--clean", "Cleanup unused images") do |v| options[:clean] = true end + opts.on("-b", "--linkbase URL", "Add links to images, with URL as base") do |url| + options[:base] = url + end end.parse! options[:path] = "build" unless options[:path] @@ -89,7 +102,13 @@ File.open(File.join(options[:path], "index.html"), "w") do |file| defs["groups"].each do |key, value| file.puts "<h2>#{key}</h2>" forImgs(value["imgs"]) do |img| - file.puts "<img src=\"#{files[img]}\">" + href = options[:base] + # If href is given add a filename at the end + if href + href = File.join(href, img) + end + + placeImage(file, files[img], href) end if value["what"] @@ -98,7 +117,6 @@ File.open(File.join(options[:path], "index.html"), "w") do |file| end - if options[:commit] file.puts "<p>Build from commit #{options[:commit]}</p>" end |