X-Git-Url: http://jaekl.net/gitweb/?p=quanlib.git;a=blobdiff_plain;f=main.rb;h=e294b4a15e3391a0e4b84d41235b2eee1265ca31;hp=d193c22360fab18aa2850cbc5a2b6d132c2aa843;hb=HEAD;hpb=b31122c5ed23e2e77b527c0979b6355e9e3dda1f diff --git a/main.rb b/main.rb index d193c22..e294b4a 100644 --- a/main.rb +++ b/main.rb @@ -1,69 +1,56 @@ -require 'page' -require 'store' -require 'walkdir' +require_relative 'navigator' +require_relative 'page' +require_relative 'store' +require_relative 'walk_dir' -outputDir = 'output' +@outputDir = 'output' -book_ids = [] -imageCount = 0 +@config_file = 'quanlib.ini' +@skip_class = false def handleArg(arg) - if "--purge" == arg + if arg.start_with?("--config=") + @config_file = arg[9..-1] + puts 'Using config file "' + @config_file + '".' + elsif "--purge" == arg puts 'Purging database...' @store.dropSchema() + if File.exists?(@store.unclassified_csv) + File.delete(@store.unclassified_csv) + end + elsif "--skip-class" == arg + puts 'Skipping load of classification table.' + @skip_class = true elsif arg.start_with?("--") abort('ERROR: Unrecognized option "' + arg + '".') end end -@store = Store.new() +@store = Store.new(@config_file) @store.connect() for arg in ARGV handleArg(arg) end -@store.init_db() +@store.init_db(@skip_class) for arg in ARGV if ! arg.start_with?("--") puts 'Scanning directory "' + arg + '"...' - w = WalkDir.new(@store, arg) - book_ids += (w.books) + w = WalkDir.new(@config_file, arg) + w.books end end -puts 'Creating output...' - -counts = {} +@store.cross_reference_lists -('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'] +puts 'Creating output...' - page.write_html(book_ids) -end +navigator = Navigator.new(@store) +navigator.write_atoz_pages() +navigator.write_series_listing() +navigator.write_dewey() -content = '' -('A'..'Z').each do |letter| - content += ' ' -end -page = Page.new(@store) -page.output_dir = 'output' -page.special = content -page.write_html( [] ) - @store.disconnect()
AuthorBooks
Starting with ' + letter + '' + counts[letter].to_s + '