summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2008-12-24 05:34:50 +0000
committerRalph Amissah <ralph@amissah.com>2008-12-24 05:34:50 +0000
commit0c679c4085b7e026c2dc0faa843ed483c4a5590d (patch)
treeff9a43334f4da5b0aac0289d43d683075ef7bfe4
parentMerge branch 'upstream' into debian/sid (diff)
parentsqlite3 fix, populate do using rb sqlite3 driver directly (rb dbi problematic (diff)
downloadsisu-0c679c4085b7e026c2dc0faa843ed483c4a5590d.zip
sisu-0c679c4085b7e026c2dc0faa843ed483c4a5590d.tar.xz
Merge branch 'upstream' into debian/sid
-rw-r--r--CHANGELOG27
-rw-r--r--lib/sisu/v0/cgi_sqlite.rb2
-rw-r--r--lib/sisu/v0/concordance.rb4
-rw-r--r--lib/sisu/v0/css.rb12
-rw-r--r--lib/sisu/v0/dal_idx.rb2
-rw-r--r--lib/sisu/v0/db_dbi.rb20
-rw-r--r--lib/sisu/v0/db_drop.rb64
-rw-r--r--lib/sisu/v0/db_import.rb36
-rw-r--r--lib/sisu/v0/db_load_tuple.rb10
-rw-r--r--lib/sisu/v0/db_remove.rb54
-rw-r--r--lib/sisu/v0/db_select.rb16
-rw-r--r--lib/sisu/v0/dbi.rb27
-rw-r--r--lib/sisu/v0/harvest_authors.rb4
-rw-r--r--lib/sisu/v0/harvest_topics.rb4
-rw-r--r--lib/sisu/v0/sysenv.rb14
-rw-r--r--lib/sisu/v0/urls.rb4
16 files changed, 200 insertions, 100 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 0ef1ada..3c79970 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,11 +9,32 @@ Reverse Chronological:
%% STABLE MANIFEST
+%% sisu_0.70.3.orig.tar.gz (2008-12-24:51/3)
+http://www.jus.uio.no/sisu/pkg/src/sisu_0.70.3.orig.tar.gz
+ sisu_0.70.3.orig.tar.gz
+ sisu_0.70.3-1.dsc
+ sisu_0.70.3-1.diff.gz
+
+ * html and css, cosmetic changes (and the closing of a tag)
+
+ * db/sql
+ * 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
+ * postgresql, much shared code, however, operation should be unchanged
+
%% sisu_0.70.2.orig.tar.gz (2008-12-16:50/2)
http://www.jus.uio.no/sisu/pkg/src/sisu_0.70.2.orig.tar.gz
- sisu_0.70.2.orig.tar.gz
- sisu_0.70.2-1.dsc
- sisu_0.70.2-1.diff.gz
+ c4ec17c3f50b629a33afcb3d343e111172bf56b656fa892d82936f86dfde281a 1545482 sisu_0.70.2.orig.tar.gz
+ 14575b369a85da01d09fd8fe52d0d9054e21f0c3fd732f6f5b6c316a73bb9db3 1159 sisu_0.70.2-1.dsc
+ b915ffecd148fdc115deab0d1ea2f50a598d00f589866f5645783dc12c71ee91 147123 sisu_0.70.2-1.diff.gz
* harvest_authors, sort authors works
diff --git a/lib/sisu/v0/cgi_sqlite.rb b/lib/sisu/v0/cgi_sqlite.rb
index 08897f5..56bcecf 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/concordance.rb b/lib/sisu/v0/concordance.rb
index aea5e55..45cc27b 100644
--- a/lib/sisu/v0/concordance.rb
+++ b/lib/sisu/v0/concordance.rb
@@ -319,14 +319,14 @@ WOK
alph.each {|x| @file_concordance << %{<a href="##{x}">#{x}</a>,&nbsp;}}
@file_concordance << '</p>'
letter=alph.shift
- @file_concordance << %{\n<hr />\n<p class="book_index_lev1"><a name="A">A</a></p>}
+ @file_concordance << %{\n<p class="letter"><a name="A">A</a></p>}
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<hr />\n<p class="book_index_lev1"><a name="#{letter}">#{letter}</a></p>}
+ @file_concordance << %{\n<p class="letter"><a name="#{letter}">#{letter}</a></p>}
else break
end
end
diff --git a/lib/sisu/v0/css.rb b/lib/sisu/v0/css.rb
index 927a253..22e26d6 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 8633579..0e23106 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<hr />\n<p class="book_index_lev1"><a name="#{letter}">#{letter}</a><p class="book_index_lev1"><a name="#{letter.downcase}"> </a></p>}
+ @idx[:html] << %{\n<p class="letter"><a name="#{letter}">#{letter}</a></p><p class="book_index_lev1"><a name="#{letter.downcase}"> </a></p>}
else break
end
end
diff --git a/lib/sisu/v0/db_dbi.rb b/lib/sisu/v0/db_dbi.rb
index 3a54fd4..4256efb 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 <SiSU_DB_create::Create #<SiSU_DB::Column_size
+ class Create <SiSU_DB_create::Create #<SiSU_DB::Column_size #% db_create.rb
end
- class Case <SiSU_DB_select::Case
+ class Case <SiSU_DB_select::Case #% db_select.rb
end
- class Index <SiSU_DB_index::Index # create documents Indexes def initialize(opt,conn='',sql_type='')
+ class Index <SiSU_DB_index::Index #% db_indexes.rb
end
- class Drop <SiSU_DB_drop::Drop
+ class Drop <SiSU_DB_drop::Drop #% db_drop.rb
end
- class Remove <SiSU_DB_remove::Remove
+ class Remove <SiSU_DB_remove::Remove #% db_remove.rb
end
- class Load_documents <SiSU_DB_tuple::Load_documents #% main database populate/update
+ class Load_documents <SiSU_DB_tuple::Load_documents #% db_load_tuple.rb
end
- class Load_metadata <SiSU_DB_tuple::Load_metadata #% update metadata
+ class Load_metadata <SiSU_DB_tuple::Load_metadata #% db_load_tuple.rb
end
- class Load_urls <SiSU_DB_tuple::Load_urls #% update urls
+ class Load_urls <SiSU_DB_tuple::Load_urls #% db_update urls
end
- class Import <SiSU_DB_import::Import #<SiSU_DB::Column_size #% main
+ class Import <SiSU_DB_import::Import #<SiSU_DB::Column_size #% db_import.rb
end
end
__END__
diff --git a/lib/sisu/v0/db_drop.rb b/lib/sisu/v0/db_drop.rb
index f41325b..93b27e6 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 1e1e25d..03f7206 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,6 +124,7 @@ module SiSU_DB_import
tell.print_grey if @opt.cmd =~/v/
case @sql_type
when /sqlite/ #fix logic for sqlite !
+ #sqlite watch
#pf_db_import_transaction_open if @opt =~/M/
db_import_metadata
db_import_documents(@dal_array)
@@ -120,7 +133,10 @@ module SiSU_DB_import
#@conn.commit
#@conn.close
#@conn.disconnect
-#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
@@ -129,6 +145,10 @@ module SiSU_DB_import
db_import_documents(@dal_array)
db_import_urls(@dal_array,@fnm) #import OID on/off
@conn.execute('COMMIT')
+ if @opt.cmd =~/[MV]/
+ puts "\n" + @conn.inspect
+ puts "\nat #{__FILE__} #{__LINE__}"
+ end
else
@db=SiSU_Env::Info_db.new
puts "\n#{@cX.grey}file #{@cX.off} #{@cX.blue}#{@opt.fns}#{@cX.off} #{@cX.grey}already exists in database#{@cX.off} #{@cX.blue}#{@db.psql.db}#{@cX.off} #{@cX.brown}update instead?#{@cX.off}"
@@ -171,9 +191,13 @@ module SiSU_DB_import
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 aefa10c..c5169b4 100644
--- a/lib/sisu/v0/db_load_tuple.rb
+++ b/lib/sisu/v0/db_load_tuple.rb
@@ -85,6 +85,10 @@ module SiSU_DB_tuple
"INSERT INTO documents (lid, metadata_tid, lev, clean, body, ocn, ocnd, ocns, seg, lev1, lev2, lev3, lev4, lev5, lev6, digest_clean, digest_all) VALUES (#{@col[:lid]}, #{@col[:tid]}, #{@col[:lev]}, '#{@col[:plaintext]}', '#{@col[:body]}', '#{@col[:ocn]}', '#{@col[:ocnd]}', '#{@col[:ocns]}', '#{@col[:seg]}', '#{@col[:lv1]}', '#{@col[:lv2]}', '#{@col[:lv3]}', '#{@col[:lv4]}', '#{@col[:lv5]}', '#{@col[:lv6]}', '#{@col[:digest_clean]}', '#{@col[:digest_all]}');"
end
if @opt.cmd =~/M/
+ if @opt.cmd =~/V/
+ puts @file.inspect
+ puts sql_entry
+ end
@file.puts sql_entry
else @conn.execute(sql_entry)
end
@@ -117,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
@@ -129,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
@@ -141,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 93680f2..a869bd2 100644
--- a/lib/sisu/v0/db_remove.rb
+++ b/lib/sisu/v0/db_remove.rb
@@ -67,21 +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=<<SQL
-DELETE FROM endnotes WHERE metadata_tid = '#{del_id}';
-DELETE FROM endnotes_asterisk WHERE metadata_tid = '#{del_id}';
-DELETE FROM endnotes_plus WHERE metadata_tid = '#{del_id}';
-DELETE FROM documents WHERE metadata_tid = '#{del_id}';
-DELETE FROM urls WHERE metadata_tid = '#{del_id}';
-DELETE FROM metadata WHERE tid = '#{del_id}';
-SQL
+ driver_sqlite3 = true if @conn.inspect.match(/^(.{10})/)[1] == @db.sqlite.conn_sqlite3.inspect.match(/^(.{10})/)[1]
+ del_id=if driver_sqlite3
+ @conn.get_first_value(%{ SELECT tid FROM metadata WHERE filename LIKE '#{@opt.fns}'; }).to_i
+ else
+ x=@conn.select_one(%{ SELECT tid FROM metadata WHERE filename LIKE '#{@opt.fns}'; })
+ del=if x; x.join.to_i else nil
+ end
+ end
+ if del_id
+ sql_entry=[
+ "DELETE FROM endnotes WHERE metadata_tid = '#{del_id}';",
+ "DELETE FROM endnotes_asterisk WHERE metadata_tid = '#{del_id}';",
+ "DELETE FROM endnotes_plus WHERE metadata_tid = '#{del_id}';",
+ "DELETE FROM documents WHERE metadata_tid = '#{del_id}';",
+ "DELETE FROM urls WHERE metadata_tid = '#{del_id}';",
+ "DELETE FROM metadata WHERE tid = '#{del_id}';",
+ ]
+ if driver_sqlite3
+ @conn.transaction
+ sql_entry.each do |s|
+ @conn.execute(s)
+ end
+ @conn.commit if driver_sqlite3
+ else
+ s=sql_entry.join(' ')
+ @conn.execute(s)
+ end
if @opt.cmd =~/M/
@file.puts sql_entry if @opt.cmd =~/M/
- else @conn.execute(%{#{sql_entry}})
end
else
tell=SiSU_Screen::Ansi.new(@opt.cmd,"no such file in database #{@db.psql.db}::#{@opt.fns}")
@@ -91,17 +105,3 @@ SQL
end
end
__END__
-DELETE FROM endnotes WHERE metadata_tid = '#{del_id}';
-DELETE FROM endnotes_asterisk WHERE metadata_tid = '#{del_id}';
-DELETE FROM endnotes_plus WHERE metadata_tid = '#{del_id}';
-DELETE FROM documents WHERE metadata_tid = '#{del_id}';
-DELETE FROM urls WHERE metadata_tid = '#{del_id}';
-DELETE FROM metadata WHERE tid = '#{del_id}';
-/*
-DELETE FROM documents WHERE documents.metadata_tid = '#{del_id}';
-DELETE FROM endnotes WHERE endnotes.metadata_tid = '#{del_id}';
-DELETE FROM endnotes_asterisk WHERE endnotes_asterisk.metadata_tid = '#{del_id}';
-DELETE FROM endnotes_plus WHERE endnotes_plus.metadata_tid = '#{del_id}';
-DELETE FROM urls WHERE urls.metadata_tid = '#{del_id}';
-DELETE FROM metadata WHERE metadata.tid = '#{del_id}';
-*/
diff --git a/lib/sisu/v0/db_select.rb b/lib/sisu/v0/db_select.rb
index a596d4e..87a3a5a 100644
--- a/lib/sisu/v0/db_select.rb
+++ b/lib/sisu/v0/db_select.rb
@@ -65,18 +65,18 @@ module SiSU_DB_select
#@conn.execute("BEGIN;")
#@sdb=Create.new(@conn)
@file=sql_maintenance_file
- @sdb=SiSU_DB_DBI::Create.new(@opt,@conn,@file,@sql_type)
- @sdb_index=SiSU_DB_DBI::Index.new(@opt,@conn,@file,@sql_type)
- @sdb_no=SiSU_DB_DBI::Drop.new(@opt,@conn,@file,@sql_type)
+ @db=SiSU_Env::Info_db.new
+ @sdb=SiSU_DB_DBI::Create.new(@opt,@conn,@file,@sql_type) # db_dbi.rb
+ @sdb_index=SiSU_DB_DBI::Index.new(@opt,@conn,@file,@sql_type) # db_dbi.rb
+ @sdb_no=SiSU_DB_DBI::Drop.new(@opt,@conn,@db,@sql_type) # db_dbi.rb
@sdb_import=SiSU_DB_DBI::Import.new(@opt,@conn,@file,@sql_type) if @opt.mod.inspect =~/update|import/
@sdb_remove_doc=SiSU_DB_DBI::Remove.new(@opt,@conn,@file) if @opt.mod.inspect =~/update|remove/
- @db=SiSU_Env::Info_db.new
end
def sql_maintenance_file
file=if @opt.inspect =~/M/
x=if @opt.fns and not @opt.fns.empty?
@env=SiSU_Env::Info_env.new(@opt.fns) if @opt.fns
- puts "\n#{@env.path.sqlite}/#{@opt.fns}.sql"
+ puts "\n#{@env.path.sqlite}/#{@opt.fns}.sql" if @sql_type =~/sqlite/ and @opt.cmd =~/M/
@db=SiSU_Env::Info_db.new
@job="sqlite3 #{@db.sqlite.db} < #{@env.path.sqlite}/#{@opt.fns}.sql"
File.new("#{@env.path.sqlite}/#{@opt.fns}.sql",'w+')
@@ -155,13 +155,13 @@ module SiSU_DB_select
else '???'
end
tell.puts_grey if @opt.cmd =~/v/
- when /^--remove$/
- @sdb_remove_doc.remove
when /^--update$/
@sdb_remove_doc.remove
@sdb_import.marshal_load
tell=SiSU_Screen::Ansi.new(@opt.cmd,"pgaccess or psql #{@db.psql.db} database?")
tell.puts_grey if @opt.cmd =~/v/
+ when /^--remove$/
+ @sdb_remove_doc.remove
when /^--index$/
@sdb_index.create_indexes
when /^droptable(s)?$/
@@ -185,7 +185,7 @@ module SiSU_DB_select
end
end
begin
- @conn.commit if @sql_type =~/sqlite/
+ #@conn.commit if @sql_type =~/sqlite/
rescue; @sdb.output_dir?
end
end
diff --git a/lib/sisu/v0/dbi.rb b/lib/sisu/v0/dbi.rb
index 1f16172..14b3e05 100644
--- a/lib/sisu/v0/dbi.rb
+++ b/lib/sisu/v0/dbi.rb
@@ -64,7 +64,7 @@ module SiSU_DBI
include SiSU_Screen
require "#{SiSU_lib}/param"
include SiSU_Param
- require "#{SiSU_lib}/db_dbi"
+ require "#{SiSU_lib}/db_dbi" # db_dbi.rb
include SiSU_DB_DBI
require "#{SiSU_lib}/shared_html_lite"
include SiSU_Format_Shared
@@ -74,27 +74,38 @@ module SiSU_DBI
@opt=opt
@db=SiSU_Env::Info_db.new
if @opt.cmd =~/d/i \
- or @opt.mod.inspect =~/--pg(?:sql)?|(?:sq)?lite/
+ or @opt.mod.inspect =~/--(pg(?:sql)?|(?:sq)?lite)/
@sql_type=if @opt.cmd=~/D/ \
or @opt.mod.inspect =~/--pg(?:sql)?/
+ maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
'pg'
elsif @opt.cmd =~/d/ \
and @opt.mod.inspect =~/--(?:db[=-])?pg(?:sql)?/
+ maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
'pg'
- elsif @opt.mod.inspect =~/--(?:sq)?lite/
+ elsif @opt.cmd=~/d/ \
+ or @opt.mod.inspect =~/--(?:sq)?lite/
+ maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
'sqlite'
elsif @opt.cmd =~/d/ \
and @opt.mod.inspect =~/--(?:db[=-])?(?:sq)?lite/
+ maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
'sqlite'
#elsif @opt.cmd =~/d/ and @opt.mod.select =~/--my(?:sql)?/; 'mysql'
- else 'sqlite'
+ else
+ maintenance_check(@opt,__FILE__,__LINE__) if @opt.cmd.inspect =~/M/
+ 'sqlite'
end
end
end
+ def maintenance_check(opt,file,line)
+ p opt.mod
+ p opt.cmd
+ p "at #{file} #{line}"
+ end
def read_psql
begin
- db,user,dbi,pass=@db.psql.db,@db.psql.user,@db.psql.dbi,@db.psql.password
- @conn=DBI.connect(dbi,user,pass)
+ @conn=@db.psql.conn_dbi
rescue
if @opt.mod.inspect=~/--(createall|create)/
puts %{manually create the database: "#{db}" if it does not yet exist}
@@ -108,8 +119,8 @@ module SiSU_DBI
def read_sqlite
begin
sql_type='sqlite'
- dbi=@db.sqlite.dbi
- @conn=DBI.connect(dbi)
+ @conn=@db.sqlite.conn_sqlite3
+ #@conn=@db.sqlite.conn_dbi #issue with dbi sqlite api, when fixed revert to using, KEEP
rescue
ensure
end
diff --git a/lib/sisu/v0/harvest_authors.rb b/lib/sisu/v0/harvest_authors.rb
index a9a2be0..8d4d3e1 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<p class="letter"><a name="#{@letter}">#{@letter}</a><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>}
+ @output[:html_mnt] << %{\n<p class="letter"><a name="#{@letter}"></p>#{@letter}</a><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>}
end
- @output[:html] << %{\n<p class="letter"><a name="#{@letter}">#{@letter}</a><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>}
+ @output[:html] << %{\n<p class="letter"><a name="#{@letter}">#{@letter}</a></p><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>}
else break
end
end
diff --git a/lib/sisu/v0/harvest_topics.rb b/lib/sisu/v0/harvest_topics.rb
index 51f55b2..918c289 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<p class="letter"><a name="#{@letter}">#{@letter}</a><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>}
+ @output[:html_mnt] << %{\n<p class="letter"><a name="#{@letter}">#{@letter}</a></p><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>}
end
- @output[:html] << %{\n<p class="letter"><a name="#{@letter}">#{@letter}</a><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>}
+ @output[:html] << %{\n<p class="letter"><a name="#{@letter}">#{@letter}</a></p><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>}
else break
end
end
diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb
index ded1495..8356e5e 100644
--- a/lib/sisu/v0/sysenv.rb
+++ b/lib/sisu/v0/sysenv.rb
@@ -2759,7 +2759,10 @@ WOK
else "DBI:Pg:database=#{psql.db};port=#{psql.port}"
end
end
- self
+ def conn_dbi
+ DBI.connect(psql.dbi,psql.user,psql.db)
+ end
+ self
end
def mysql
def db
@@ -2780,6 +2783,15 @@ WOK
def dbi
"DBI:SQLite3:#{sqlite.db}" #sqlite3 ?
end
+ def sqlite3
+ sqlite.db #sqlite3 ?
+ end
+ def conn_dbi
+ DBI.connect(sqlite.dbi)
+ end
+ def conn_sqlite3
+ SQLite3::Database.new(sqlite.sqlite3)
+ end
self
end
end
diff --git a/lib/sisu/v0/urls.rb b/lib/sisu/v0/urls.rb
index 05ffd96..6d78d4f 100644
--- a/lib/sisu/v0/urls.rb
+++ b/lib/sisu/v0/urls.rb
@@ -109,7 +109,7 @@ module SiSU_urls
'b (XHTML)'=>@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