Add `arrived` attribute (file creation timestamp) to books table.
[quanlib.git] / navigator.rb
index 16da65269054c1ab40c7ef9eac98fa71e0585671..881b1fa8237231d524197eb8f0cf188d58330268 100644 (file)
@@ -1,5 +1,5 @@
-require 'page'
-require 'store'
+require_relative 'page'
+require_relative 'store'
 
 class Navigator
   def initialize(store)
@@ -13,10 +13,11 @@ class Navigator
       atoz_counts[letter] = write_authors_starting_with(letter)
     end
 
-    content = '<table><tr><th>Author</th><th>Books</th></tr>'
+    content = '<p><table><tr><th>Author</th><th>Books</th></tr>'
     ('A'..'Z').each do |letter|
       content += '  <tr><td><a href="../atoz/output_' + letter + '.html">Starting with ' + letter + '</a></td><td>' + atoz_counts[letter].to_s + '</td></tr>'
     end
+    content += '</table></p>'
     page = Page.new(@store)
     page.output_dir = 'atoz'
     page.special = content
@@ -45,6 +46,20 @@ class Navigator
     return book_ids.length
   end
 
+  def write_dewey
+    book_ids = @store.query_books_by_ddc()
+    puts 'Non-fiction books arranged by Dewey Decimal Classification:  ' + book_ids.length.to_s() + ' books.'
+
+    page = Page.new(@store)
+    page.output_dir = 'ddc'
+    page.index_file = 'index.html'
+    page.title = "Non-fiction books arranged by Dewey Decimal call number"
+    page.up = ['../output/index.html', 'Up']
+    
+    page.write_html(book_ids)
+    return book_ids.length
+  end
+
   def write_series_for_age(age)
     series_infos = []