diff options
author | Ralph Amissah <ralph@amissah.com> | 2014-05-18 09:39:31 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2014-05-18 09:39:31 -0400 |
commit | 808c9c74a72b95e6272c8927cce839d89626ba47 (patch) | |
tree | 8047b7cee667ca0c2b6b9bb12a4c3e33a34704fa /lib/sisu/v6/cgi_pgsql.rb | |
parent | debian/changelog (5.3.5-1) (diff) | |
parent | v5 v6: cgi, sample search forms: use ruby-pg & ruby-sqlite3; remove ruby-dbi (diff) |
Merge tag 'sisu_5.3.6' into debian/sid
SiSU 5.3.6
Diffstat (limited to 'lib/sisu/v6/cgi_pgsql.rb')
-rw-r--r-- | lib/sisu/v6/cgi_pgsql.rb | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/lib/sisu/v6/cgi_pgsql.rb b/lib/sisu/v6/cgi_pgsql.rb index a52b62e3..8372bb70 100644 --- a/lib/sisu/v6/cgi_pgsql.rb +++ b/lib/sisu/v6/cgi_pgsql.rb @@ -82,16 +82,15 @@ module SiSU_CGI_PgSQL opt.lingual.to_s else 'multi' end - if defined? @rc['search'] \ + @name_of[:db]=if defined? @rc['search'] \ and defined? @rc['search']['sisu'] \ and defined? @rc['search']['sisu']['action'] \ and @rc['search']['sisu']['action'] =~/https?:\/\/\S+?\.cgi/ \ and defined? @rc['search']['sisu']['db'] \ and @rc['search']['sisu']['db'] =~/\S+/ - @name_of[:db]=@rc['search']['sisu']['db'] + @rc['search']['sisu']['db'] else - @name_of[:db]=@env.path.stub_pwd #'sisu' #breaks if not present - false + @env.path.stub_pwd #'sisu' #breaks if not present end @name_of[:host_url_cgi]=%q{http://#{ENV['HTTP_HOST']}#{ENV['PATH_INFO']}} @name_of[:host_url_docs]=%q{http://#{ENV['HTTP_HOST']}} @@ -128,13 +127,6 @@ module SiSU_CGI_PgSQL default database name: #{@cX.green}#{Db[:name_prefix]}#{@name_of[:db]}#{@cX.off} (#{@name_of[:db]}) db user: #{@cX.green}#{@name_of[:user]}#{@cX.off} to modify use: #{@cX.brown}sisu --db-pg --db-user='#{@name_of[:user]}'#{@cX.off} - cgi & db host on: #{@cX.blue}#{@name_of[:host_url_cgi]}#{@cX.off} - to modify use: #{@cX.brown}sisu --db-pg --webserv-search='#{@name_of[:host_url_cgi]}'#{@cX.off} - sisu output on: #{@cX.blue}#{@name_of[:host_url_docs]}#{@cX.off} - to modify use: #{@cX.brown}sisu --db-pg --webserv-output='#{@name_of[:host_url_docs]}'#{@cX.off} - cgi search form link name: #{@cX.green}#{@name_of[:cgi_script]}#{@cX.off} - to modify use: #{@cX.brown}sisu --db-pg --cgi-search-form-name='#{@name_of[:cgi_script]}'#{@cX.off} - #{@cX.fuchsia}(settings priority: command line; sisurc.yml; else defaults)#{@cX.off} #{@cX.fuchsia}BASED ON ALREADY EXISTING databases#{@cX.off} (default database name: #{@db.psql.db}) NOTE it is first necessary to createdb, @@ -151,12 +143,12 @@ module SiSU_CGI_PgSQL #{@cX.brown}createdb #{@db.psql.db}#{@cX.off} [for a list of existing databases try 'psql --list']" - now you can use sisu to create the database tables and populate the database with documents + you can use sisu to create the database tables and populate the database with documents sisu --pg --dropall # removes existing postgresql db & tables sisu --pg --createall -v # creates postgresql db & tables sisu --pg --update -v *.sst *.ssm # populate the db - sisu --sample-search-form --pg # creates the postgresql search form + sisu --sample-search-form --db-pg # creates the postgresql search form # this should be done after creating the db # to be searched sisu --webrick & # starts ruby webrick web server @@ -195,9 +187,9 @@ module SiSU_CGI_PgSQL begin require 'cgi' require 'fcgi' - require 'dbi' + require 'pg' rescue LoadError - puts 'cgi, fcgi or dbi NOT FOUND (LoadError)' + puts 'cgi, fcgi or pg NOT FOUND (LoadError)' end @stub_default='#{@name_of[:db]}' @image_src="#{@image_src}" @@ -277,10 +269,10 @@ module SiSU_CGI_PgSQL %{<font color="#666666" size="2">#{sql_select_endnotes}</font>} end def contents - @conn.select_all(sql_select_body) + @conn.exec(sql_select_body) end def endnotes - @conn.select_all(sql_select_endnotes) + @conn.exec(sql_select_endnotes) end end WOK_SQL @@ -292,8 +284,7 @@ module SiSU_CGI_PgSQL end def dbi_connect <<-'WOK_SQL' - dbi="dbi:Pg:database=#{@db};port=#{@port}" - @conn=DBI.connect(dbi,@user) + @conn=PG::Connection.open(dbname: @db, port: @port, user: @user) WOK_SQL end end |