12 puts 'Purging database...'
14 elsif arg.start_with?("--")
15 abort('ERROR: Unrecognized option "' + arg + '".')
29 if ! arg.start_with?("--")
30 puts 'Scanning directory "' + arg + '"...'
31 w = WalkDir.new(@store, arg)
36 puts 'Creating output...'
40 ('A'..'Z').each do |letter|
41 book_ids = @store.query_books_by_author(letter + '%')
42 puts 'Authors starting with "' + letter + '": ' + book_ids.length.to_s() + ' books.'
43 atoz_counts[letter] = book_ids.length
45 page = Page.new(@store)
47 page.back = ['../atoz/output_' + (letter.ord - 1).chr + '.html', 'Prev']
50 page.forward = ['../atoz/output_' + (letter.ord + 1).chr + '.html', 'Next']
52 page.output_dir = 'atoz'
53 page.index_file = 'output_' + letter + '.html'
54 page.title = "Authors starting with '" + letter + "'"
55 page.up = ['../atoz/index.html', 'Index']
57 page.write_html(book_ids)
61 ages = ['beginner', 'junior', 'ya', 'adult']
66 puts 'Series for "' + age + '" readers...'
68 series_ids = @store.query_series_by_age(age)
70 series_ids.each do |id|
71 series = @store.load_series(id)
72 book_ids = @store.query_books_by_series_id(id)
73 if nil != book_ids and book_ids.length > 0
74 series_infos.push( [series, book_ids] )
78 for idx in 0 .. (series_infos.length - 1) do
79 #puts series.descr + ': ' + book_ids.length.to_s + ' books.'
85 back = series_infos[idx-1]
87 if idx < (series_infos.length - 1)
88 fwd = series_infos[idx+1]
91 cur = series_infos[idx]
95 page = Page.new(@store)
97 page.back = [back[0].key + '.html', 'Back']
100 page.forward = [fwd[0].key + '.html', 'Forward']
102 page.output_dir = 'series'
103 page.index_file = series.key + '.html'
104 page.title = 'Series “' + series.descr + '” (' + book_ids.length.to_s + ' books)'
105 page.up = ['../atoz/index.html', 'Index']
107 page.write_html(book_ids)
111 content = '<table><tr><th>Author</th><th>Books</th></tr>'
112 ('A'..'Z').each do |letter|
113 content += ' <tr><td><a href="../atoz/output_' + letter + '.html">Starting with ' + letter + '</a></td><td>' + atoz_counts[letter].to_s + '</td></tr>'
115 page = Page.new(@store)
116 page.output_dir = 'atoz'
117 page.special = content
118 page.write_html( [] )