summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-06-04 14:15:07 +0200
committerJulian T <julian@jtle.dk>2020-06-04 14:15:07 +0200
commit1ab44cebeb4a5b978d497fe44e64322093bfe715 (patch)
treee0636faa4ac55ac168416ec0e8725c556eac352d
parent9d20c74709892e2e2c429c20a315c64cafe7d184 (diff)
Images link to originals
-rwxr-xr-xbuild.rb22
1 files changed, 20 insertions, 2 deletions
diff --git a/build.rb b/build.rb
index 53b6a99..608c6aa 100755
--- a/build.rb
+++ b/build.rb
@@ -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