web/build_site.rb in rubyvis-0.1.7 vs web/build_site.rb in rubyvis-0.2.0
- old
+ new
@@ -63,10 +63,26 @@
# Create an html file with svg included inside
page.source=CodeRay.scan(source_a.join(), :ruby).div
page.title=title
page.text=text
page.svg_file=base+".svg"
-
+ # Read svg size
+ width=350
+ height=200
+ if File.exists? "examples/#{page.svg_file}"
+ File.open("examples/#{page.svg_file}","r") {|fp|
+ header=fp.gets(">")
+ if header=~/\sheight='([^']+)'/
+ height=$1
+ end
+ if header=~/\swidth='([^']+)'/
+ width=$1
+ end
+ }
+ end
+ page.svg_width=width.to_f.ceil
+ page.svg_height=height.to_f.ceil
+
end
pages.each do |name,page|
html_file="examples/#{page.name}.html"
File.open(html_file,"w") {|fp|