Create a basic html output, to validate that we're loading data correctly.
[quanlib.git] / main.rb
1 require 'walkdir'
2
3 outputDir = 'output'
4
5 books = []
6 imageCount = 0
7
8 for arg in ARGV
9   w = WalkDir.new(arg)
10   books += (w.books)
11 end
12
13 if ! Dir.exist?(outputDir)
14   Dir.mkdir(outputDir)
15 end
16
17 open(outputDir + '/index.html', 'w') do |fd|
18   fd.puts "<html>"
19   fd.puts "  <head><title>Books</title></head>"
20   fd.puts "  <body>"
21   fd.puts "    <table>"
22   
23   for book in books
24     image = nil
25     if nil != book.cover
26       imageCount += 1
27       (path, mimeType) = book.cover.writeImage(outputDir, 'image' + imageCount.to_s)
28       image = '<img src="' + path + '"/>'
29     else
30       image = '(No cover image)'
31     end
32
33     fd.puts "      <tr><td>" + image + "</td><td>" + book.describe() + "</td></tr>"
34   end
35   
36   fd.puts "    </table>"
37   fd.puts "  </body>"
38   fd.puts "</html>"
39 end
40