Sha256: 62df503ada3776bd24d484d319436857fc0834ac7d27857a856eb82b4424584d
Contents?: true
Size: 964 Bytes
Versions: 1
Compression:
Stored size: 964 Bytes
Contents
def build_version_sidebar(dir, version) raw = File.read("template-replace/resources/version_list.html") template = raw.match(/<!--template-->(.*)<!--endtemplate-->/m)[1] raw.gsub!(template, "") res = +"" i = 0 `git tag`.force_encoding("utf-8").split("\n").each.with_index do |tag| i += 1 sha = `git rev-parse #{tag}`.force_encoding("utf-8").strip version = tag.delete_prefix("v") cls = i % 2 == 0 ? "even" : "odd" if version == "." cls += " current" end res += template.gsub("!version!", version).gsub("!path!", "../" + version).gsub("!class!", cls).gsub("!sha!", sha) end i += 1 cls = i % 2 == 0 ? "even" : "odd" if version == "main" cls += " current" end sha = `git rev-parse HEAD`.force_encoding("utf-8").strip res += template.gsub("!version!", "main").gsub("!path!", "../main").gsub("!class!", cls).gsub("!sha!", sha) File.write(dir + "/version_list.html", raw.gsub("<!--replace-->", res)) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
discorb-0.4.0 | template-replace/scripts/version.rb |