Create a basic html output, to validate that we're loading data correctly.
[quanlib.git] / main.rb
diff --git a/main.rb b/main.rb
index 76f543e61cffd9019e2a1eee49b4860e7e6ebbf4..4e73b07c0b490eca6eef199f504055406bfb907d 100644 (file)
--- a/main.rb
+++ b/main.rb
@@ -1,10 +1,40 @@
-require './walkdir'
+require 'walkdir'
+
+outputDir = 'output'
 
 books = []
+imageCount = 0
 
 for arg in ARGV
   w = WalkDir.new(arg)
-  books.push(w.books)
+  books += (w.books)
+end
+
+if ! Dir.exist?(outputDir)
+  Dir.mkdir(outputDir)
+end
+
+open(outputDir + '/index.html', 'w') do |fd|
+  fd.puts "<html>"
+  fd.puts "  <head><title>Books</title></head>"
+  fd.puts "  <body>"
+  fd.puts "    <table>"
+  
+  for book in books
+    image = nil
+    if nil != book.cover
+      imageCount += 1
+      (path, mimeType) = book.cover.writeImage(outputDir, 'image' + imageCount.to_s)
+      image = '<img src="' + path + '"/>'
+    else
+      image = '(No cover image)'
+    end
+
+    fd.puts "      <tr><td>" + image + "</td><td>" + book.describe() + "</td></tr>"
+  end
+  
+  fd.puts "    </table>"
+  fd.puts "  </body>"
+  fd.puts "</html>"
 end
 
-puts books