diff options
author | Julian T <julian@jtle.dk> | 2020-06-04 14:15:07 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2020-06-04 14:15:07 +0200 |
commit | 1ab44cebeb4a5b978d497fe44e64322093bfe715 (patch) | |
tree | e0636faa4ac55ac168416ec0e8725c556eac352d | |
parent | 9d20c74709892e2e2c429c20a315c64cafe7d184 (diff) |
Images link to originals
-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 |