From 0c4c1608a90f8363db117b29ae758abced96e0cc Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 16 Dec 2008 19:54:36 -0500 Subject: close html

tag for "letter" class --- lib/sisu/v0/harvest_authors.rb | 4 ++-- lib/sisu/v0/harvest_topics.rb | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/harvest_authors.rb b/lib/sisu/v0/harvest_authors.rb index a9a2be03..8d4d3e15 100644 --- a/lib/sisu/v0/harvest_authors.rb +++ b/lib/sisu/v0/harvest_authors.rb @@ -275,9 +275,9 @@ WOK if @alph.length > 0 @letter=@alph.shift if @output[:html_mnt].class == File - @output[:html_mnt] << %{\n

#{@letter}

} + @output[:html_mnt] << %{\n

#{@letter}

} end - @output[:html] << %{\n

#{@letter}

} + @output[:html] << %{\n

#{@letter}

} else break end end diff --git a/lib/sisu/v0/harvest_topics.rb b/lib/sisu/v0/harvest_topics.rb index 51f55b2b..918c289f 100644 --- a/lib/sisu/v0/harvest_topics.rb +++ b/lib/sisu/v0/harvest_topics.rb @@ -363,9 +363,9 @@ WOK if @alph.length > 0 @letter=@alph.shift if @output[:html_mnt].class == File - @output[:html_mnt] << %{\n

#{@letter}

} + @output[:html_mnt] << %{\n

#{@letter}

} end - @output[:html] << %{\n

#{@letter}

} + @output[:html] << %{\n

#{@letter}

} else break end end -- cgit v1.2.3 From b2d26ed38292409b1f10017af7a6c6cd56c73983 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 16 Dec 2008 19:55:01 -0500 Subject: html & css cosmetic changes (index & concordance), run "sisu -CC"; changelog --- lib/sisu/v0/concordance.rb | 4 ++-- lib/sisu/v0/css.rb | 12 ++++++++++++ lib/sisu/v0/dal_idx.rb | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/concordance.rb b/lib/sisu/v0/concordance.rb index aea5e556..45cc27b2 100644 --- a/lib/sisu/v0/concordance.rb +++ b/lib/sisu/v0/concordance.rb @@ -319,14 +319,14 @@ WOK alph.each {|x| @file_concordance << %{#{x}, }} @file_concordance << '

' letter=alph.shift - @file_concordance << %{\n
\n

A

} + @file_concordance << %{\n

A

} for word in @freq.keys.sort! {|a,b| a.downcase<=>b.downcase} f=/^(\S)/.match(word)[1] if letter < f.upcase while letter < f.upcase if alph.length > 0 letter=alph.shift - @file_concordance << %{\n
\n

#{letter}

} + @file_concordance << %{\n

#{letter}

} else break end end diff --git a/lib/sisu/v0/css.rb b/lib/sisu/v0/css.rb index 927a253f..22e26d62 100644 --- a/lib/sisu/v0/css.rb +++ b/lib/sisu/v0/css.rb @@ -585,6 +585,18 @@ WOK text-align: center; } + p.letter { + font-weight: bold; + font-size: 80%; + margin-left: 0em; + margin-top: 2px; + margin-bottom: 2px; + margin-right: 6px; + text-align: left; + color: white; + background: #880000; + } + label.ocn { width: 2%; float: right; diff --git a/lib/sisu/v0/dal_idx.rb b/lib/sisu/v0/dal_idx.rb index 8633579f..0e231064 100644 --- a/lib/sisu/v0/dal_idx.rb +++ b/lib/sisu/v0/dal_idx.rb @@ -186,7 +186,7 @@ module SiSU_book_index while letter < f if alph.length > 0 letter=alph.shift - @idx[:html] << %{\n
\n

#{letter}

} + @idx[:html] << %{\n

#{letter}

} else break end end -- cgit v1.2.3 From 2f97cf3f9e13280da9d161d39b8d9b0d66555307 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 17 Dec 2008 20:57:46 -0500 Subject: SiSU's sqlite module still broken for the time being: inconsistent ruby dbi api for sqlite3, (unable to begin and commit transaction) provide explicit message problem noted already in v.0.66.2 (2008-04) and last in v.0.66.3 (2008-05) module (& rb dbi) apparently worked at end 2007 (v.0.62.4) and start of 2008 (v.0.64.0) ... (did not expect broken state to last, sorry) include maintenance mode info with -M flag --- lib/sisu/v0/db_dbi.rb | 20 ++++++++++---------- lib/sisu/v0/db_import.rb | 20 ++++++++++++++++++++ lib/sisu/v0/db_load_tuple.rb | 4 ++++ lib/sisu/v0/db_remove.rb | 3 ++- lib/sisu/v0/db_select.rb | 16 ++++++++++------ lib/sisu/v0/dbi.rb | 20 ++++++++++++++++---- lib/sisu/v0/urls.rb | 4 ++-- 7 files changed, 64 insertions(+), 23 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/db_dbi.rb b/lib/sisu/v0/db_dbi.rb index 3a54fd46..4256efb9 100644 --- a/lib/sisu/v0/db_dbi.rb +++ b/lib/sisu/v0/db_dbi.rb @@ -70,25 +70,25 @@ module SiSU_DB_DBI require "#{SiSU_lib}/db_import" class Column_size < SiSU_DB_columns::Column_size end - class Test < SiSU_DB_tests::Test + class Test < SiSU_DB_tests::Test #% db_tests.rb end - class Create @fn[:xhtml], #'B (Docbook XML)'=>@fn[:docbook], 'D[iu] (DBI import/update postgresql)'=>'dbi psql', - 'd[iu] (DBI import/update sqlite)'=>'dbi sqlite', + 'd[iu] (DBI import/update sqlite)'=>'dbi sqlite3', 'e (Plain-text (endnotes))'=>@fn[:plain], 'E (Plain-text (endnotes) dos)'=>@fn[:plain], 'h (HTML segmented)'=>@fn[:toc], @@ -221,7 +221,7 @@ module SiSU_urls end if x=~/^d/ \ and @opt.cmd =~/d/ - tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x} DBI sqlite","sqlite #{@env.path.output}/sisu_sqlite.db", "#{y}") + tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x} DBI sqlite","sqlite3 #{@env.path.output}/sisu_sqlite.db", "#{y}") tell.result unless @opt.cmd =~/q/ @opt.cmd.gsub!(/d[iu]/,'') end -- cgit v1.2.3 From 71223cf6cd035b3e395f6d4c3e4c41b79ed29510 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Mon, 22 Dec 2008 01:08:06 -0500 Subject: sqlite3 fix, populate do using rb sqlite3 driver directly (rb dbi problematic at present) sqlite fix, change ruby driver used to populate sisu sqlite3 db to rb sqlite3 for the time being. Use rb sqlite3 driver directly rather (than more convenient when working) rb dbi interface to populate content. Used to bypass problems with rb dbi sqlite3 interface noted in sisu 0.66.2 (2008-04-25) and 0.66.3 (2008-05-11) that have have persisted (apparently worked at end 2007 (v.0.62.4) and start of 2008 (v.0.64.0) * sqlite dropall, fix * fix to auto-generated sqlite cgi script sample, only works if at least one existing populated sisu sqlite database is found during the generation process --- lib/sisu/v0/cgi_sqlite.rb | 2 +- lib/sisu/v0/db_drop.rb | 64 +++++++++++++++++++++++++++----------------- lib/sisu/v0/db_import.rb | 48 ++++++++++++++++++--------------- lib/sisu/v0/db_load_tuple.rb | 6 ++--- lib/sisu/v0/db_remove.rb | 55 +++++++++++++++++++------------------ lib/sisu/v0/db_select.rb | 12 +++------ lib/sisu/v0/dbi.rb | 7 +++-- lib/sisu/v0/sysenv.rb | 14 +++++++++- 8 files changed, 117 insertions(+), 91 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v0/cgi_sqlite.rb b/lib/sisu/v0/cgi_sqlite.rb index 08897f54..56bcecf6 100644 --- a/lib/sisu/v0/cgi_sqlite.rb +++ b/lib/sisu/v0/cgi_sqlite.rb @@ -94,7 +94,7 @@ module SiSU_CGI_sqlite serve.each do |x| f3 << %{ when /SiSU_#{x}/; "#{@env.path.webserv}/#{x}/sisu_sqlite.db"\n} end - f3 << " end\n" + f3 << "else #{@env.path.webserv}/#{serve[0]}/sisu_sqlite.db\n end\n" if FileTest.writable?('.') output=File.open('sisu_sqlite.cgi','w') output << header0 << header1 << header_desc << header2 << f1 << buttons1 << buttons2 << search_request << search_statement << search_statement_common << search_query1 << @common.pages << search_query2 << @common.tail << @common.main1 << f2 << f3 << dbi_connect << @common.main2 diff --git a/lib/sisu/v0/db_drop.rb b/lib/sisu/v0/db_drop.rb index f41325b2..93b27e6d 100644 --- a/lib/sisu/v0/db_drop.rb +++ b/lib/sisu/v0/db_drop.rb @@ -60,40 +60,56 @@ =end module SiSU_DB_drop class Drop - def initialize(opt,conn,file,sql_type='') - @opt,@conn,@file,@sql_type=opt,conn,file,sql_type + require "#{SiSU_lib}/response" + def initialize(opt,conn,db_info,sql_type='') + @opt,@conn,@db_info,@sql_type=opt,conn,db_info,sql_type + @ans=SiSU_Response::Response.new + case @sql_type + when /sqlite/ + cascade='' + else + cascade='CASCADE' + end + @drop_table=[ + "DROP TABLE metadata #{cascade};", + "DROP TABLE documents #{cascade};", + "DROP TABLE urls #{cascade};", + "DROP TABLE endnotes #{cascade};", + "DROP TABLE endnotes_asterisk #{cascade};", + "DROP TABLE endnotes_plus #{cascade};", + ] end def drop def tables #% drop all tables begin + msg_sqlite="as not all disk space is recovered after dropping the database << #{@db_info.sqlite.db} >>, you may be better off deleting the file, and recreating it as necessary" case @sql_type when /sqlite/ - cascade='' - commit=@conn.commit + @conn.transaction + @drop_table.each do |d| + @conn.execute(d) + end + @conn.commit + puts msg_sqlite + ans=@ans.response?('remove sql database?') + if ans and File.exist?(@db_info.sqlite.db) + File.unlink(@db_info.sqlite.db) + end else - cascade='CASCADE' - commit='' + @conn.do(@drop_table.join('')) end - @conn.do(%{ - DROP TABLE metadata #{cascade}; - DROP TABLE documents #{cascade}; - DROP TABLE urls #{cascade}; - DROP TABLE endnotes #{cascade}; - DROP TABLE endnotes_asterisk #{cascade}; - DROP TABLE endnotes_plus #{cascade}; - }) - commit rescue - @conn.do(%{ - DROP TABLE endnotes; - DROP TABLE endnotes_asterisk; - DROP TABLE endnotes_plus; - DROP TABLE urls #{cascade}; - DROP TABLE documents #{cascade}; - DROP TABLE metadata #{cascade}; - }) + case @sql_type + when /sqlite/ + #system("rm -vi #{@db_info.sqlite.db}") + ans=@ans.response?('remove sql database?') + if ans and File.exist?(@db_info.sqlite.db); File.unlink(@db_info.sqlite.db) + end + else + @conn.do(@drop_table.join('')) + end ensure - commit + #commit end end def indexes #% drop all indexes diff --git a/lib/sisu/v0/db_import.rb b/lib/sisu/v0/db_import.rb index bcdfc497..03f72065 100644 --- a/lib/sisu/v0/db_import.rb +++ b/lib/sisu/v0/db_import.rb @@ -8,7 +8,7 @@ * Author: Ralph Amissah * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007, 2008 Ralph Amissah All Rights Reserved. + 2007, 2008, 2009 Ralph Amissah All Rights Reserved. * License: GPL 3 or later: @@ -62,7 +62,7 @@ module SiSU_DB_import require "#{SiSU_lib}/db_columns" require "#{SiSU_lib}/db_load_tuple" require "#{SiSU_lib}/shared_html_lite" - #require 'sqlite3' + require 'sqlite3' class Import < SiSU_DB_columns::Column_size include SiSU_Param include SiSU_Screen @@ -85,18 +85,30 @@ module SiSU_DB_import @col=Hash.new('') @col[:ocn]='' @counter={} + @db=SiSU_Env::Info_db.new + @driver_sqlite3=false + @driver_sqlite3=true if @conn.inspect.match(/^(.{10})/)[1] == @db.sqlite.conn_sqlite3.inspect.match(/^(.{10})/)[1] sql='SELECT MAX(lid) FROM documents' begin @col[:lid] ||=0 - @col[:lid]=@conn.execute( sql ) { |x| x.fetch_all.to_s.to_i } + @col[:lid]=if @driver_sqlite3 + @conn.execute( sql ).join.to_i + else @conn.execute( sql ) { |x| x.fetch_all.to_s.to_i } + end rescue + puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ end @col[:lid] =0 if @col[:lid].nil? or @col[:lid].to_s.empty? sql='SELECT MAX(nid) FROM endnotes' begin @id_n ||=0 - @id_n=@conn.execute( sql ) { |x| x.fetch_all.to_s.to_i } + @id_n=if @driver_sqlite3 + @conn.execute( sql ).join.to_i + else + @id_n=@conn.execute( sql ) { |x| x.fetch_all.to_s.to_i } + end rescue + puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ end @id_n =0 if @col[:lid].nil? or @col[:lid].to_s.empty? @col[:lv1]=@col[:lv2]=@col[:lv3]=@col[:lv4]=@col[:lv5]=@col[:lv6]=0 @@ -112,15 +124,8 @@ module SiSU_DB_import tell.print_grey if @opt.cmd =~/v/ case @sql_type when /sqlite/ #fix logic for sqlite ! -#sqlite watch -unless @opt.cmd =~/[MVv]/ - puts "\nSiSU's sqlite module for the time being broken: inconsistent ruby dbi api for sqlite3, (unable to begin and commit transaction)\n".upcase - p @conn.methods.sort - #p "here #{__FILE__} #{__LINE__}" - exit -else + #sqlite watch #pf_db_import_transaction_open if @opt =~/M/ - #@conn.begin db_import_metadata db_import_documents(@dal_array) db_import_urls(@dal_array,@fnm) #import OID on/off @@ -128,15 +133,10 @@ else #@conn.commit #@conn.close #@conn.disconnect - puts "\nSiSU's sqlite module for the time being broken: inconsistent ruby dbi api for sqlite3, (unable to begin and commit transaction)\n".upcase - p @conn.methods.sort - if @opt.cmd =~/M/ - puts "\n" + @conn.inspect - puts "\nat #{__FILE__} #{__LINE__}" - end - exit -end -#sqlite watch + if @opt.cmd =~/M/ + puts "\n" + @conn.inspect + puts "\nat #{__FILE__} #{__LINE__}" + end else file_exist=@conn.select_one(%{ SELECT metadata.tid FROM metadata WHERE metadata.filename ~ '#{@opt.fns}'; }) unless file_exist @@ -191,9 +191,13 @@ end sql='SELECT MAX(tid) FROM metadata' begin @@id_t ||=0 - id_t=@conn.execute( sql ) { |x| x.fetch_all.to_s.to_i } + id_t=if @driver_sqlite3 + @conn.execute( sql ).join.to_i # { |x| id_t=x.join.to_i } + else @conn.execute( sql ) { |x| x.fetch_all.to_s.to_i } + end @@id_t=id_t if id_t rescue + puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/ end @@id_t =0 if @col[:lid].nil? or @col[:lid].to_s.empty? @@id_t+=1 #bug related, needs to be performed once at start of file, but consider moving, as, placed here it means program will fail if document header lacks 0~title diff --git a/lib/sisu/v0/db_load_tuple.rb b/lib/sisu/v0/db_load_tuple.rb index 512d5933..c5169b4e 100644 --- a/lib/sisu/v0/db_load_tuple.rb +++ b/lib/sisu/v0/db_load_tuple.rb @@ -121,7 +121,7 @@ module SiSU_DB_tuple if @opt.cmd =~/M/ puts "maintenance mode on: creating sql transaction file (for last transaction set (document) only):\n\t#{@file.inspect}" @file.puts sql_entry - else @conn.execute(%{#{sql_entry}}) + else @conn.execute(sql_entry) end end end @@ -133,7 +133,7 @@ module SiSU_DB_tuple sql_entry="INSERT INTO urls (#{@f[:txt]} #{@f[:html_toc]} #{@f[:html_doc]} #{@f[:xhtml]} #{@f[:xml_sax]} #{@f[:xml_dom]} #{@f[:odf]} #{@f[:pdf_p]} #{@f[:pdf_l]} #{@f[:concordance]} #{@f[:latex_p]} #{@f[:latex_l]} #{@f[:manifest]} #{@f[:digest]} #{@f[:markup]} #{@f[:sisupod]} metadata_tid) VALUES (#{@u[:txt]} #{@u[:html_toc]} #{@u[:html_doc]} #{@u[:xhtml]} #{@u[:xml_sax]} #{@u[:xml_dom]} #{@u[:odf]} #{@u[:pdf_p]} #{@u[:pdf_l]} #{@u[:concordance]} #{@u[:latex_p]} #{@u[:latex_l]} #{@u[:manifest]} #{@u[:digest]} #{@u[:markup]} #{@u[:sisupod]} #{@id});" if @opt.cmd =~/M/ @file.puts sql_entry - else @conn.execute(%{#{sql_entry}}) + else @conn.execute(sql_entry) end end end @@ -145,7 +145,7 @@ module SiSU_DB_tuple sql_entry="INSERT INTO #{@en[:type]} (nid, document_lid, nr, clean, body, ocn, ocnd, ocns, metadata_tid, digest_clean) VALUES ('#{@en[:id]}', '#{@en[:lid]}', '#{@en[:nr]}', '#{@en[:txt]}', '#{@en[:body]}', '#{@en[:ocn]}', '#{@en[:ocnd]}', '#{@en[:ocns]}', '#{@en[:id_t]}', '#{@en[:hash]}');" if @opt.cmd =~/M/ @file.puts sql_entry - else @conn.execute(%{#{sql_entry}}) + else @conn.execute(sql_entry) end end end diff --git a/lib/sisu/v0/db_remove.rb b/lib/sisu/v0/db_remove.rb index fef4e797..a869bd24 100644 --- a/lib/sisu/v0/db_remove.rb +++ b/lib/sisu/v0/db_remove.rb @@ -67,22 +67,35 @@ module SiSU_DB_remove @db=SiSU_Env::Info_db.new end def remove - del=@conn.select_one(%{ SELECT tid FROM metadata WHERE filename LIKE '#{@opt.fns}'; }) - if del - del_id=del.join - #@conn.execute("BEGIN") - sql_entry=<