X-Git-Url: http://jaekl.net/gitweb/?a=blobdiff_plain;f=main.rb;h=bc175fbf51ae33205a37735d1390872a3ea630e1;hb=291671015d4e88cbb7e7f3995109a88ee993aac6;hp=8617ab0146577146d30e6ec73c21c7856ab03a1c;hpb=e9d890ae4d346ce3abe93a8db94d3a3ddf9819d9;p=quanlib.git diff --git a/main.rb b/main.rb index 8617ab0..bc175fb 100644 --- a/main.rb +++ b/main.rb @@ -1,3 +1,4 @@ +require 'store' require 'walkdir' outputDir = 'output' @@ -5,11 +6,34 @@ outputDir = 'output' books = [] imageCount = 0 +def handleArg(arg) + if "--purge" == arg + puts 'Purging database...' + @store.dropSchema() + elsif arg.start_with?("--") + abort('ERROR: Unrecognized option "' + arg + '".') + end +end + +@store = Store.new() +@store.connect() + for arg in ARGV - w = WalkDir.new(arg) - books += (w.books) + handleArg(arg) end +@store.init_db() + +for arg in ARGV + if ! arg.start_with?("--") + puts 'Scanning directory "' + arg + '"...' + w = WalkDir.new(@store, arg) + books += (w.books) + end +end + +puts 'Creating output...' + if ! Dir.exist?(outputDir) Dir.mkdir(outputDir) end @@ -26,6 +50,12 @@ open(outputDir + '/index.html', 'w') do |fd| fd.puts ' margin: 10px;' fd.puts ' border 3px solid #73ad21;' fd.puts '}' + fd.puts 'span.popup { }' + fd.puts 'span.popup:hover {text-decoration: none; background: #cfffff; z-index: 6; }' + fd.puts 'span.popup span {display: none; position: absolute; ' + fd.puts ' margin: 4px 0 0 0px; padding: 3px 3px 3px 3px;' + fd.puts ' border-style:solid; border-color:black; border-width:1px;}' + fd.puts 'span.popup:hover span {display: block; margin: 20px 0 0 0px; background: #ffffaf; z-index:6;}' fd.puts ' ' fd.puts ' ' fd.puts ' ' @@ -41,7 +71,16 @@ open(outputDir + '/index.html', 'w') do |fd| end fd.puts '
' - fd.puts ' ' + fd.puts ' ' + + heading = book.heading() + description = book.description() + if nil != description + fd.puts ' ' + else + fd.puts ' ' + end + fd.puts '
' + image + '' + book.describe() + '
' + image + '' + heading + '

' + heading + '

' + description + '

' + heading + '
' end @@ -50,3 +89,4 @@ open(outputDir + '/index.html', 'w') do |fd| fd.puts "" end +@store.disconnect()