Improve HTML formatting. Handle more variants of EPUB.
[quanlib.git] / main.rb
diff --git a/main.rb b/main.rb
index 4e73b07c0b490eca6eef199f504055406bfb907d..8617ab0146577146d30e6ec73c21c7856ab03a1c 100644 (file)
--- a/main.rb
+++ b/main.rb
@@ -15,22 +15,34 @@ if ! Dir.exist?(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>"
+  fd.puts '<html>'
+  fd.puts '  <head>'
+  fd.puts '    <meta charset="utf-8"/>'
+  fd.puts '    <title>Books</title>'
+  fd.puts '    <style>'
+  fd.puts 'div { '
+  fd.puts '  display: inline-block;'
+  fd.puts '  width: 400px;'
+  fd.puts '  margin: 10px;'
+  fd.puts '  border 3px solid #73ad21;'
+  fd.puts '}'
+  fd.puts '    </style>'
+  fd.puts '  </head>'
+  fd.puts '  <body>'
   
   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 + '"/>'
+      image = '<img height="200px" src="' + path + '"/>'
     else
       image = '(No cover image)'
     end
 
-    fd.puts "      <tr><td>" + image + "</td><td>" + book.describe() + "</td></tr>"
+    fd.puts '    <div><table>'
+    fd.puts '      <tr><td><a href="' + book.path + '">' + image + '</a></td><td>' + book.describe() + '</td></tr>'
+    fd.puts '    </table></div>'
   end
   
   fd.puts "    </table>"