Improves handling of non-fiction classification data.
[quanlib.git] / main.rb
diff --git a/main.rb b/main.rb
index d193c22360fab18aa2850cbc5a2b6d132c2aa843..4ea9c7057de2e456b65eecb2fcad0515b3fbc283 100644 (file)
--- a/main.rb
+++ b/main.rb
@@ -1,3 +1,4 @@
+require 'navigator'
 require 'page'
 require 'store'
 require 'walkdir'
@@ -11,6 +12,9 @@ def handleArg(arg)
   if "--purge" == arg
     puts 'Purging database...'
     @store.dropSchema()
+    if File.exists?(Store.unclassified_csv)
+      File.delete(Store.unclassified_csv)
+    end
   elsif arg.start_with?("--")
     abort('ERROR:  Unrecognized option "' + arg + '".')
   end
@@ -35,35 +39,10 @@ end
 
 puts 'Creating output...'
 
-counts = {}
+navigator = Navigator.new(@store)
+navigator.write_atoz_pages()
+navigator.write_series_listing()
+navigator.write_dewey()
 
-('A'..'Z').each do |letter| 
-  book_ids = @store.query_books_by_author(letter + '%')
-  puts 'Authors starting with "' + letter + '":  ' + book_ids.length.to_s() + ' books.'
-  counts[letter] = book_ids.length
-
-  page = Page.new(@store)
-  if 'A' != letter
-    page.back = ['../output_' + (letter.ord - 1).chr + '/index.html', 'Prev']
-  end
-  if 'Z' != letter
-    page.forward = ['../output_' + (letter.ord + 1).chr + '/index.html', 'Next']
-  end
-  page.output_dir = 'output_' + letter
-  page.title = "Authors starting with '" + letter + "'"
-  page.up = ['../output/index.html', 'Index']
-
-  page.write_html(book_ids)
-end
-
-content = '<table><tr><th>Author</th><th>Books</th></tr>'
-('A'..'Z').each do |letter|
-  content += '  <tr><td><a href="../output_' + letter + '/index.html">Starting with ' + letter + '</a></td><td>' + counts[letter].to_s + '</td></tr>'
-end
-page = Page.new(@store)
-page.output_dir = 'output'
-page.special = content
-page.write_html( [] )
-  
 @store.disconnect()