From 65477054fd798728bf186aa2938727ddddbe86a5 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 22 May 2007 02:06:46 +0100 Subject: Imported upstream version 0.52.7 --- data/sisu/README | 8 + data/sisu/conf/cgi-bin/sisu_search_pgsql.cgi | 923 ++++++++++++++++++++++++ data/sisu/conf/cgi-bin/sisu_search_sqlite.cgi | 932 ++++++++++++++++++++++++ data/sisu/conf/completion/README | 7 + data/sisu/conf/completion/_sisu | 64 ++ data/sisu/conf/convert/kdissert_to_sisu | 161 +++++ data/sisu/conf/convert/modify.rb | 250 +++++++ data/sisu/conf/convert/sisu_convert | 392 +++++++++++ data/sisu/conf/convert/wvHtml.xml | 388 ++++++++++ data/sisu/conf/convert/wvSiSU.xml | 360 ++++++++++ data/sisu/conf/lighttpd/lighttpd.cfg.sisu | 115 +++ data/sisu/conf/lighttpd/lighttpd.cfg.sisu_www | 115 +++ data/sisu/conf/ruby/irbrc | 19 + data/sisu/conf/syntax/README | 92 +++ data/sisu/conf/syntax/diakonos.conf | 979 ++++++++++++++++++++++++++ data/sisu/conf/syntax/nanorc | 220 ++++++ data/sisu/conf/syntax/sisu-mode.el | 235 +++++++ data/sisu/conf/syntax/sisu.lang | 90 +++ data/sisu/conf/syntax/sisu.xml | 157 +++++ data/sisu/conf/syntax/sisu_nedit.pats | 79 +++ data/sisu/conf/vim/addons/colors/slate.vim | 55 ++ data/sisu/conf/vim/addons/filetype.vim | 8 + data/sisu/conf/vim/addons/ftplugin/sisu.vim | 177 +++++ data/sisu/conf/vim/addons/syntax/sisu.vim | 171 +++++ data/sisu/image/DebTuxRubySiSU.png | Bin 0 -> 23032 bytes data/sisu/image/arrow_next_blue.png | Bin 0 -> 1302 bytes data/sisu/image/arrow_next_red.png | Bin 0 -> 1167 bytes data/sisu/image/arrow_prev_blue.png | Bin 0 -> 1348 bytes data/sisu/image/arrow_prev_red.png | Bin 0 -> 1182 bytes data/sisu/image/arrow_up_blue.png | Bin 0 -> 1320 bytes data/sisu/image/arrow_up_red.png | Bin 0 -> 1214 bytes data/sisu/image/b_bluebell.png | Bin 0 -> 419 bytes data/sisu/image/b_doc.png | Bin 0 -> 274 bytes data/sisu/image/b_home.png | Bin 0 -> 419 bytes data/sisu/image/b_odf.png | Bin 0 -> 907 bytes data/sisu/image/b_pdf.png | Bin 0 -> 325 bytes data/sisu/image/b_toc.png | Bin 0 -> 329 bytes data/sisu/image/bluebell.png | Bin 0 -> 410 bytes data/sisu/image/bullet_doc.png | Bin 0 -> 311 bytes data/sisu/image/bullet_red.png | Bin 0 -> 519 bytes data/sisu/image/c_Copyleft.png | Bin 0 -> 668 bytes data/sisu/image/c_Euro.png | Bin 0 -> 514 bytes data/sisu/image/dot_clear.png | Bin 0 -> 128 bytes data/sisu/image/dot_white.png | Bin 0 -> 128 bytes data/sisu/image/next.png | Bin 0 -> 722 bytes data/sisu/image/previous.png | Bin 0 -> 721 bytes data/sisu/image/rb7.ico | Bin 0 -> 3262 bytes data/sisu/image/sisu.png | Bin 0 -> 3260 bytes data/sisu/image/toctoc.png | Bin 0 -> 760 bytes data/sisu/odf/odt.zip | Bin 0 -> 5306 bytes 50 files changed, 5997 insertions(+) create mode 100644 data/sisu/README create mode 100644 data/sisu/conf/cgi-bin/sisu_search_pgsql.cgi create mode 100644 data/sisu/conf/cgi-bin/sisu_search_sqlite.cgi create mode 100644 data/sisu/conf/completion/README create mode 100644 data/sisu/conf/completion/_sisu create mode 100644 data/sisu/conf/convert/kdissert_to_sisu create mode 100644 data/sisu/conf/convert/modify.rb create mode 100644 data/sisu/conf/convert/sisu_convert create mode 100644 data/sisu/conf/convert/wvHtml.xml create mode 100644 data/sisu/conf/convert/wvSiSU.xml create mode 100644 data/sisu/conf/lighttpd/lighttpd.cfg.sisu create mode 100644 data/sisu/conf/lighttpd/lighttpd.cfg.sisu_www create mode 100644 data/sisu/conf/ruby/irbrc create mode 100644 data/sisu/conf/syntax/README create mode 100644 data/sisu/conf/syntax/diakonos.conf create mode 100644 data/sisu/conf/syntax/nanorc create mode 100644 data/sisu/conf/syntax/sisu-mode.el create mode 100644 data/sisu/conf/syntax/sisu.lang create mode 100644 data/sisu/conf/syntax/sisu.xml create mode 100644 data/sisu/conf/syntax/sisu_nedit.pats create mode 100644 data/sisu/conf/vim/addons/colors/slate.vim create mode 100644 data/sisu/conf/vim/addons/filetype.vim create mode 100644 data/sisu/conf/vim/addons/ftplugin/sisu.vim create mode 100644 data/sisu/conf/vim/addons/syntax/sisu.vim create mode 100644 data/sisu/image/DebTuxRubySiSU.png create mode 100644 data/sisu/image/arrow_next_blue.png create mode 100644 data/sisu/image/arrow_next_red.png create mode 100644 data/sisu/image/arrow_prev_blue.png create mode 100644 data/sisu/image/arrow_prev_red.png create mode 100644 data/sisu/image/arrow_up_blue.png create mode 100644 data/sisu/image/arrow_up_red.png create mode 100644 data/sisu/image/b_bluebell.png create mode 100644 data/sisu/image/b_doc.png create mode 100644 data/sisu/image/b_home.png create mode 100644 data/sisu/image/b_odf.png create mode 100644 data/sisu/image/b_pdf.png create mode 100644 data/sisu/image/b_toc.png create mode 100644 data/sisu/image/bluebell.png create mode 100644 data/sisu/image/bullet_doc.png create mode 100644 data/sisu/image/bullet_red.png create mode 100644 data/sisu/image/c_Copyleft.png create mode 100644 data/sisu/image/c_Euro.png create mode 100644 data/sisu/image/dot_clear.png create mode 100644 data/sisu/image/dot_white.png create mode 100644 data/sisu/image/next.png create mode 100644 data/sisu/image/previous.png create mode 100644 data/sisu/image/rb7.ico create mode 100644 data/sisu/image/sisu.png create mode 100644 data/sisu/image/toctoc.png create mode 100644 data/sisu/odf/odt.zip (limited to 'data/sisu') diff --git a/data/sisu/README b/data/sisu/README new file mode 100644 index 00000000..3f11295e --- /dev/null +++ b/data/sisu/README @@ -0,0 +1,8 @@ +This directory contains shared data that sisu uses +e.g. shared images, and odf file structure + +documentation is elsewhere +try: +/usr/share/doc/sisu +man sisu +sisu help diff --git a/data/sisu/conf/cgi-bin/sisu_search_pgsql.cgi b/data/sisu/conf/cgi-bin/sisu_search_pgsql.cgi new file mode 100644 index 00000000..0d2ed982 --- /dev/null +++ b/data/sisu/conf/cgi-bin/sisu_search_pgsql.cgi @@ -0,0 +1,923 @@ +#!/usr/bin/env ruby +=begin + * Name: SiSU information Structuring Universe + * Author: Ralph Amissah + * http://www.jus.uio.no/sisu + * http://www.jus.uio.no/sisu/SiSU/download + + * Description: generates naive cgi search form for search of sisu database (pgsql) + * $Id$ + + Copyright (C) 2006 Ralph Amissah + Copyright (C) 2005 Ralph Amissah (first release edition) + Copyright (C) 1997 Ralph Amissah (first edition) + + * License: GPL 2 or later + + Summary of GPL 2 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + http://www.fsf.org/licenses/gpl.html + http://www.gnu.org/copyleft/gpl.html + http://www.jus.uio.no/sisu/gpl2.fsf + + SiSU was first released to the public on January 4th 2005 + + SiSU uses: + + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + © Ralph Amissah 1997, current 2006. + All Rights Reserved. + + * Ralph Amissah ralph@amissah.com + Ralph Amissah ralph.amissah@gmail.com + +=end +require 'cgi' +require 'fcgi' +require 'dbi' +@version='sisu_search_pgsql' +@url_base="http://corundum:8081/_sisu/image" +host=%x{echo $HOSTNAME}.chomp! +@hosturl="http://#{host}" + + ':8081' +@base="#@hosturl/cgi-bin/#@version.cgi" +user='ralph' +class Form + def initialize(base,search_field,selected_db,checked_index,checked_text,checked_tip,checked_searched,checked_url,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,search_note,the_can='') + search_note='' if checked_searched !~/\S/ + the_can='' if checked_url !~/\S/ + search_field='' if checked_echo !~/\S/ + @base,@search_field,@selected_db,@checked_index,@checked_text,@checked_tip,@checked_searched,@checked_url,@checked_echo,@checked_sql,@checked_all,@checked_none,@checked_ignore,@search_note,@the_can=base,search_field,selected_db,checked_index,checked_text,checked_tip,checked_searched,checked_url,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,search_note,the_can + @tip=if checked_tip =~/\S/ + 'text:__; keywords:__; title:__; author:__; subject:__; description:__; publisher:__; contributor:__; date:__; type:__; format:__; identifier:__; source:__; language:__; relation:__; coverage:__; rights:__; comment:__; abstract:__; ' + else '' + end + end + def submission_form + search_form=<<-WOK + + + +
+ + + +
+ + +
+

+
+ + index + text + +

+

+
+ #@search_note +
+ #@tip +
+ + echo + searched + url + search fields available + sql statement + +
+ use selected + check all + check none +
+ +#@the_can +WOK + end +end +class Search_request #% search_for + attr_accessor :text1,:keywords,:title,:author,:subject,:description,:publisher,:contributor,:date,:type,:format,:identifier,:source,:language,:relation,:coverage,:rights,:comment,:abstract,:owner,:date_created,:date_issued,:date_modified,:date_available,:date_valid + def initialize(search_field='',q='') + @search_field,@q=search_field,q + @text1=@keywords=@title=@author=@subject=@description=@publisher=@contributor=@date=@type=@format=@identifier=@source=@language=@relation=@coverage=@rights=@comment=@abstract=@owner=@date_created=@date_issued=@date_modified=@date_available=@date_valid='' + if @search_field=~/\S/ + @text1=text_to_match('text:') + @keywords=text_to_match('key(?:words?)?:') + @title=text_to_match('title:') # DublinCore 1 - title + @author=text_to_match('(?:author|creator)s?:') # DublinCore 2 - creator/author + @subject=text_to_match('subj(?:ect)?:') # DublinCore 3 - subject + @description=text_to_match('description:') # DublinCore 4 - description + @publisher=text_to_match('pub(?:lisher)?:') # DublinCore 5 - publisher + @contributor=text_to_match('contributor:') # DublinCore 6 - contributor + @date=text_to_match('date:') # DublinCore 7 - date dd-mm-yy + @type=text_to_match('type:') # DublinCore 8 - type + @format=text_to_match('format:') # DublinCore 9 - format + @identifier=text_to_match('identifier:') # DublinCore 10 - identifier + @source=text_to_match('source:') # DublinCore 11 - source + @language=text_to_match('language:') # DublinCore 12 - language + @relation=text_to_match('relation:') # DublinCore 13 - relation + @coverage=text_to_match('coverage:') # DublinCore 14 - coverage + @rights=text_to_match('rights:') # DublinCore 15 - rights + @comment=text_to_match('comment:') + @abstract=text_to_match('abs(?:tract)?:') + @owner=text_to_match('owner:') + @date_created=text_to_match('date_created:') + @date_issued=text_to_match('date_issued:') + @date_modified=text_to_match('date_modified:') + @date_available=text_to_match('date_available:') + @date_valid=text_to_match('date_valid:') + @text1=text_to_match unless @keywords or @author or @title or @text1 or @comment or @abstract or @rights or @subject or @publisher or @date + else + @text1=q['s1'] if q['s1']=~/\S/ + @keywords=q['key'] if q['key']=~/\S/ + @title=q['ti'] if q['ti']=~/\S/ + @author=q['au'] if q['au']=~/\S/ + @subject=q['sj'] if q['sj']=~/\S/ + @description=q['dsc'] if q['dsc']=~/\S/ + @publisher=q['pb'] if q['pb']=~/\S/ + @contributor=q['cntr'] if q['cntr']=~/\S/ + @date=q['dt'] if q['dt']=~/\S/ + @type=q['ty'] if q['ty']=~/\S/ + @identifier=q['id'] if q['id']=~/\S/ + @source=q['src'] if q['src']=~/\S/ + @language=q['lang'] if q['lang']=~/\S/ + @relation=q['rel'] if q['rel']=~/\S/ + @coverage=q['cov'] if q['cov']=~/\S/ + @rights=q['cr'] if q['cr']=~/\S/ + @comment=q['co'] if q['co']=~/\S/ + @abstract=q['ab'] if q['ab']=~/\S/ + @date_created=q['dtc'] if q['dtc']=~/\S/ + @date_issued=q['dti'] if q['dti']=~/\S/ + @date_modified=q['dtm'] if q['dtm']=~/\S/ + @date_available=q['dta'] if q['dta']=~/\S/ + @date_valid=q['dtv'] if q['dtv']=~/\S/ + end + end + def text_to_match(identifier='') + m=Hash.new + m[:string]=/#{identifier}\s*(.+?)/ + m[:string]=/#{identifier}\s*(.+?)(?:;|\n|\r|$)/ + m[:word]=/#{identifier}[\s(]*(\S+)/ + search_string=if @search_field =~m[:word] + search_string=if @search_field =~m[:braces]: m[:braces].match(@search_field)[1] + elsif @search_field =~m[:string]: m[:string].match(@search_field)[1] + else + str=m[:word].match(@search_field)[1] + str.gsub!(/[()]/,'') + str + end + search_string.strip! + search_string.gsub!(/\s+/,'+') + search_string + #else + # "__" + end + end +end +class Dbi_search_string + def initialize(l,t,q) + @l,@t,@q=l,t,q + end + def string + search=Hash.new + search[:search]=Array.new + search[:flag]=false + if @t =~/\S+/ or @q =~/\S+/ + if @t =~/\S+/: unescaped_search=CGI.unescape(@t) + elsif @q =~/\S+/: unescaped_search=CGI.unescape(@q) + end + search_construct=Array.new + unescaped_search.gsub!(/\s*(AND|OR)\s*/,"' \) \\1 #@l~\( '") + unescaped_search.gsub!(/(.+)/,"#@l~\( '\\1' \)") + search_construct << unescaped_search + search_construct=search_construct.join(' ') + search[:search] << search_construct + search[:flag]=true + search + end + search + end +end +class Dbi_search_statement + attr_reader :text_search_flag,:sql_select_body_format,:sql_select_endnotes_format + def initialize(conn,search_for,q) + @conn=conn + @text_search_flag=false + search=Hash.new + search[:text],search[:endnotes]=Array.new,Array.new + st=Dbi_search_string.new('documents.clean',search_for.text1,q['s1']).string + se=Dbi_search_string.new('endnotes.clean',search_for.text1,q['s1']).string + @text_search_flag=st[:flag] + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << se[:search] + end + st=Dbi_search_string.new('metadata.keywords',search_for.keywords,q['key']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.title',search_for.title,q['ti']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.creator',search_for.author,q['au']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.subject',search_for.subject,q['sj']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.description',search_for.description,q['dsc']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.publisher',search_for.publisher,q['pb']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.contributor',search_for.contributor,q['cntr']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.date',search_for.date,q['dt']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.type',search_for.type,q['ty']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.identifier',search_for.identifier,q['id']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.source',search_for.source,q['src']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.language',search_for.language,q['lang']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.relation',search_for.relation,q['rel']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.coverage',search_for.coverage,q['cov']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.rights',search_for.rights,q['cr']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.comment',search_for.comment,q['co']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.abstract',search_for.abstract,q['ab']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + @search_text,@search_endnotes=Array.new,Array.new + #% + search[:text].each{|x| @search_text << "#{x} AND " } + search[:endnotes].each{|x| @search_endnotes << "#{x} AND " } + @search_text=@search_text.to_s.gsub!(/AND\s+$/,'') + @search_endnotes=@search_endnotes.to_s.gsub!(/AND\s+$/,'') + end + def sql_select_body + %{SELECT metadata.title, metadata.creator, metadata.filename, metadata.suffix, documents.body, documents.seg, documents.ocn, metadata.tid FROM documents, metadata WHERE (#@search_text) AND documents.metadata_tid = metadata.tid ORDER BY metadata.title, documents.ocn ;} + end + def sql_select_endnotes + %{SELECT metadata.title, metadata.creator, metadata.filename, endnotes.body, endnotes.nr, endnotes.ocn, endnotes.metadata_tid FROM metadata, endnotes WHERE (#@search_endnotes) AND metadata.tid = endnotes.metadata_tid ORDER BY metadata.title, endnotes.nr ;} + end + def sql_select_body_format + %{#{sql_select_body}} + end + def sql_select_endnotes_format + %{#{sql_select_endnotes}} + end + def contents + @conn.select_all(sql_select_body) + end + def endnotes + @conn.select_all(sql_select_endnotes) + end +end +class Tail + def tail + <<-'WOK' +


+
+ + + + +

+ presentations' look and feel
+ generated by
+ SiSU on Debian/Gnu/Linux or a FreeBSD & Ruby - better ways, well actually, Way Better!
+ SiSU
+ version 0.36
2006w07/6 (20060218)
+ + + © Ralph Amissah
+ 1993, current 2006
+ GPL 2
+ w3 since October 3 1993
+ ralph@amissah.com
+

+
+ +

Developed
using Ruby
on Debian/Gnu/Linux software infrastructure,
with the usual GPL (or OSS) suspects.
Better - "performance, reliability, scalability, security
& total cost of ownership"
[not to mention flexibility & choice]

<<Way Better!>>

+ + + +

+ If you have problems viewing pages on this site please update your browser: +

+
+ + + +
+

+ +If you have problems viewing pages on this site please update your browser: + +

+
+ + + + + + + + + + + + + + + + + + + +
+

+ + +Epiphany + Epiphany + +® | + +

+
+

+ + +Galeon + Galeon + +® | + +

+
+

+ + +MS I-Explorer +I-Explorer + +® | + +

+
+

+ + +Kazehakase +® |

+
+

+ + +Konqueror +Konqueror +® |

+
+

+ + +Mozilla +Mozilla + + +Firefox +Firefox + +® | + +

+
+

+ + +Netscape +Netscape + +® | + +

+
+

+ + +Opera +Opera + +® | + +

+
+

+ + +Safari +Safari + +® + +

+
+ + + + + + + + + + + + + + + + + +
+

+ +for console/text viewing: + +

+
+

+ + +elinks + | + +

+
+

+ + +links2 + | + +

+
+

+ + +w3m + + +

+
+

+ +for lightweight gui (X) viewing try: + +

+
+

+ + +Dillo + |

+
+

+ + +Epiphany + Epiphany + +® | + +

+
+

+ + +Galeon + Galeon + | + +

+
+

+ + +links2 -g + + +

+
+
+ + + + +
+

+ +& for + +pdf + +viewings of this site we recommend stand alone viewers +
+(rather than web browser plugins): +
+

+
+ + + + + + + + + +
+

+ + +Adobe Acrobat Reader +Acrobat Reader + +® + | + +

+
+

+ + +Evince +Evince + +® + +

+
+

+ + GhostView® , + +GV® + +& + +GSview® + + | + +

+
+

+ + +Xpdf + Xpdf + +® + +

+
+ +
+ +WOK + end +end +@counter_txt_doc,@counter_txt_ocn,@counter_endn_doc,@counter_endn_ocn=0,0,0,0 +@counters_txt,@counters_endn,@sql_select_body,@sql_select_endnotes='','','','' +FCGI.each_cgi do |cgi| + begin # all code goes in begin section + @search=Hash.new + @search[:text],@search[:endnotes]=Array.new,Array.new + q=CGI.new + @db=if cgi['db'] =~/\S+/: + @stub=/SiSU_(\S+)/.match(cgi['db'])[1] + cgi['db'] + else + @stub='sisu' + 'SiSU_sisu' + end + checked_url,checked_searched,checked_tip,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,selected_db='','','','','','','','' + if cgi['view']=~/text/: checked_index,checked_text='','checked' + else checked_index,checked_text='checked','' + end + checked_url='checked' if cgi['url'] =~/\S/ or cgi['u'].to_i==1 + checked_searched='checked' if cgi['searched'] =~/\S/ + checked_tip='checked' if cgi['tip'] =~/\S/ + checked_echo='checked' if cgi['echo'] =~/\S/ + checked_sql='checked' if cgi['sql'] =~/\S/ + if cgi['checks'] =~/check_all/ or cgi['check_all'] =~/\S/ or cgi['a'].to_i==1 + checked_all=checked_url=checked_searched=checked_tip=checked_echo=checked_sql='checked' + checked_none='' + elsif cgi['checks'] =~/check_none/ #or cgi['a'].to_i==0 + checked_none='checked' + checked_all=checked_url=checked_searched=checked_tip=checked_echo=checked_sql='' + else checked_ignore='checked' + end + selected_db=case cgi['db'] + when /SiSU_document_samples_sisu_markup/: '' + when /SiSU_sisu/: '' + end + dbi="dbi:Pg:database=#{@db};port=5432" + @conn=DBI.connect(dbi,user) + search_field=cgi['find'] if cgi['find'] # =~/\S+/ + @search_for=Search_request.new(search_field,q) #.analyze #% search_for + #% searches + #Canned_search.new(@base,@search_for.text1,cgi) + if @search_for.text1=~/\S+/ or @search_for.author=~/\S+/ #and search_field =~/\S/ + s1='s1=' + CGI.escape(@search_for.text1) if @search_for.text1=~/\S/ + key='key=' + CGI.escape(@search_for.keywords) if @search_for.keywords=~/\S/ + ti='&ti=' + CGI.escape(@search_for.title) if @search_for.title=~/\S/ + au='&au=' + CGI.escape(@search_for.author) if @search_for.author=~/\S/ + sj='&sj=' + CGI.escape(@search_for.subject) if @search_for.subject=~/\S/ + dsc='&dsc=' + CGI.escape(@search_for.description) if @search_for.description=~/\S/ + pb='&pb=' + CGI.escape(@search_for.publisher) if @search_for.publisher=~/\S/ + cntr='&cntr=' + CGI.escape(@search_for.contributor) if @search_for.contributor=~/\S/ + dt='&dt=' + CGI.escape(@search_for.date) if @search_for.date=~/\S/ + ty='&ty=' + CGI.escape(@search_for.type) if @search_for.type=~/\S/ + id='&id=' + CGI.escape(@search_for.identifier) if @search_for.identifier=~/\S/ + src='&src=' + CGI.escape(@search_for.source) if @search_for.source=~/\S/ + lang='&lang=' + CGI.escape(@search_for.language) if @search_for.language=~/\S/ + rel='&rel=' + CGI.escape(@search_for.relation) if @search_for.relation=~/\S/ + cov='&cov=' + CGI.escape(@search_for.coverage) if @search_for.coverage=~/\S/ + cr='&cr=' + CGI.escape(@search_for.rights) if @search_for.rights=~/\S/ + co='&co=' + CGI.escape(@search_for.comment) if @search_for.comment=~/\S/ + ab='&ab=' + CGI.escape(@search_for.abstract) if @search_for.abstract=~/\S/ + dtc='&dtc=' + CGI.escape(@search_for.date_created) if @search_for.date_created=~/\S/ + dti='&dti=' + CGI.escape(@search_for.date_issued) if @search_for.date_issued=~/\S/ + dtm='&dtm=' + CGI.escape(@search_for.date_modified) if @search_for.date_modified=~/\S/ + dta='&dta=' + CGI.escape(@search_for.date_available) if @search_for.date_available=~/\S/ + dtv='&dtv=' + CGI.escape(@search_for.date_valid) if @search_for.date_valid=~/\S/ + canned_search_url=if checked_all =~/checked/ + "#@base?#{s1}#{key}#{ti}#{au}#{sj}#{dsc}#{pb}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}&db=#{cgi['db']}&view=#{cgi['view']}&a=1" + else "#@base?#{s1}#{key}#{ti}#{au}#{sj}#{dsc}#{pb}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}&db=#{cgi['db']}&view=#{cgi['view']}&u=1&e=1" + end + @search[:text][1]=%{documents.clean~'#{@search_for.text1}'} #s1 + @search[:endnotes][1]=%{endnotes.clean~'#{@search_for.text1}'} #s1 + canned_note='previous search url:' + else + canned_search_url="#@base?s1=United+Nations&db=documents&view=index" + canned_note='search url example:' + end + if search_field =~/\S+/ + analyze_format=search_field.gsub(/\s*\n/,'; ') + elsif checked_all =~/checked/ or checked_url =~/checked/ + canned_search=canned_search_url.scan(/(?:s1|au|ti)=[^&]+/) + af=canned_search.join('; ') + af.gsub!(/s1=/,'text: ') + af.gsub!(/au=/,'author: ') + af.gsub!(/ti=/,'title: ') + af.gsub!(/%2B/,' ') + analyze_format=af + st=af.split(/\s*;\s*/) + search_field=st.join("\n") + end + green=%{} + the_can=%{#{canned_note}
#{canned_search_url}

} + p_text=p_keywords=p_title=p_author=p_subject=p_description=p_publisher=p_contributor=p_date=p_type=p_format=p_identifier=p_source=p_language=p_relation=p_coverage=p_rights=p_comment=p_abstract=p_subject='' + p_text=%{text: #{green}#{@search_for.text1}

} if @search_for.text1 =~/\S+/ + p_keywords=%{keywords: #{green}#{@search_for.keywords}

} if @search_for.keywords =~/\S+/ + p_title=%{title: #{green}#{@search_for.title}
} if @search_for.title =~/\S+/ + p_author=%{author: #{green}#{@search_for.author}
} if @search_for.author =~/\S+/ + p_subject=%{subject: #{green}#{@search_for.subject}
} if @search_for.subject =~/\S+/ + p_description=%{description: #{green}#{@search_for.description}
} if @search_for.description =~/\S+/ + p_publisher=%{publisher: #{green}#{@search_for.publisher}
} if @search_for.publisher =~/\S+/ + p_contributor=%{contributor: #{green}#{@search_for.contributor}
} if @search_for.contributor =~/\S+/ + p_date=%{date: #{green}#{@search_for.date}
} if @search_for.date =~/\S+/ + p_type=%{type: #{green}#{@search_for.type}
} if @search_for.type =~/\S+/ + p_format=%{format: #{green}#{@search_for.format}
} if @search_for.format =~/\S+/ + p_identifier=%{identifier: #{green}#{@search_for.identifier}
} if @search_for.identifier =~/\S+/ + p_source=%{source: #{green}#{@search_for.source}
} if @search_for.source =~/\S+/ + p_language=%{language: #{green}#{@search_for.language}
} if @search_for.language =~/\S+/ + p_relation=%{relation: #{green}#{@search_for.relation}
} if @search_for.relation =~/\S+/ + p_coverage=%{coverage: #{green}#{@search_for.coverage}
} if @search_for.coverage =~/\S+/ + p_rights=%{rights: #{green}#{@search_for.rights}
} if @search_for.rights =~/\S+/ + p_comment=%{comment: #{green}#{@search_for.comment}
} if @search_for.comment =~/\S+/ + p_abstract=%{abstract: #{green}#{@search_for.abstract}
} if @search_for.abstract =~/\S+/ + search_note=<<-WOK + +
previous selection:
+database: #{green}#@db
; selected view: #{green}#{cgi['view']}
+search string: "#{green}#{analyze_format}"
+#{p_text} #{p_keywords} #{p_title} #{p_author} #{p_subject} #{p_description} #{p_publisher} #{p_contributor} #{p_date} #{p_type} #{p_format} #{p_identifier} #{p_source} #{p_language} #{p_relation} #{p_coverage} #{p_rights} #{p_comment} #{p_abstract} + +WOK + #eg = %{canned search e.g.:
#{url}
find: #{analyze}
database: #{database}} + #dbi_canning + @header=Form.new(@base,search_field,selected_db,checked_index,checked_text,checked_tip,checked_searched,checked_url,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,search_note,the_can).submission_form #% form + @tail=Tail.new.tail + unless q['s1'] =~/\S/ or q['au'] =~/\S/ or @search[:text][1] =~/\S/ + print "Content-type: text/html\n\n" + puts (@header+@tail) + else #% searches + s1=if @search_for.text1 =~/\S/ + @search_for.text1 + else 'Unavailable' + end + @search[:text]<<%{documents.clean~'#{CGI.unescape(s1)}'} + @search[:endnotes]<<%{endnotes.clean~'#{CGI.unescape(s1)}'} + #dbi_request + dbi_statement=Dbi_search_statement.new(@conn,@search_for,q) + @text_search_flag=false + @text_search_flag=dbi_statement.text_search_flag + s_contents=dbi_statement.contents + s_endnotes=dbi_statement.endnotes + @body_main=Array.new + @endnotes=Array.new + oldtid=0 + if @text_search_flag + if checked_sql =~/\S/ + sql_select_body=dbi_statement.sql_select_body_format + sql_select_endnotes=dbi_statement.sql_select_endnotes_format + else sql_select_body,sql_select_endnotes='','' + end + @body_main << "



Main Text:
" << sql_select_body + @endnotes << "



Endnotes:
" << sql_select_endnotes + else + end + #text_objects_body + s_contents.each do |c| #% text body + location=c["filename"][/(.+?)\.ss[ftms]/, 1] + file_suffix=c["filename"][/.+?\.(ss[ftms])/, 1] + #metadata_found_body + if c["tid"].to_i != oldtid.to_i + title=%{#{c["title"]} by #{c["creator"]} pdf portraitpdf landscape
} if file_suffix=~/s/ #hmm watch file_suffix + if @text_search_flag: title='

'+title + else title='
'+title + end + @counter_txt_doc+=1 + oldtid=c["tid"].to_i + else title='' + end + if @text_search_flag + if cgi['view']=~/text/ #% txt body + text=if c["suffix"] !~/1/ #seg + if @search_for.text1 =~/\S+/ or q['s1'] =~/\S+/ #% only this branch is working !! + if @search_for.text1 =~/\S+/: unescaped_search=CGI.unescape(@search_for.text1) + elsif q['s1'] =~/\S+/: unescaped_search=CGI.unescape(q['s1']) + end + search_regex=Array.new + build=unescaped_search.scan(/\S+/).each do |g| + if g.to_s =~/(AND|OR)/ + search_regex << '|' + else search_regex << %{#{g.to_s}} + end + end + search_regex=search_regex.join(' ') + search_regex=search_regex.gsub(/\s*\|\s*/,'|') + @search_regx=search_regex.to_s + end + matched_para=c["body"].gsub(/(#@search_regx)/i,%{\\1}) + %{

ocn #{c["ocn"]}:

#{matched_para}} + elsif c["suffix"] =~/1/ #doc + %{#{title}

ocn #{c["ocn"]}:#{c["body"]}} + end + @counter_txt_ocn+=1 + output=if c["seg"] =~/\S+/: title+text + else text + end + elsif cgi['view']=~/index/ #% idx body + if c["suffix"] !~/1/ #seg + index=%{#{c["ocn"]}, } if @text_search_flag + elsif c["suffix"] =~/1/ #doc + index=%{#{c["ocn"]}, } + end + if c["seg"] =~/\S+/ + if @text_search_flag + @counter_txt_ocn+=1 + output=title+index + end + else + @counter_txt_ocn+=1 + output=unless c["suffix"] =~/1/: title+index + else %{#{title}#{c["ocn"].sort}, } + end + end + end + else output=title + end + @counters_txt=if @counter_txt_doc > 0 + %{Found in the main body of #@counter_txt_doc documents, and at #@counter_txt_ocn locations within.
} + else '' + end + @body_main << output #+ details + end + #text_objects_endnote + oldtid = 0 + s_endnotes.each do |e| #% endnotes + location=e["filename"][/(.+?)\.ss[ftms]/, 1] + file_suffix=e["filename"][/.+?\.(ss[ftms])/, 1] + #metadata_found_endnotes + if @text_search_flag + if e["metadata_tid"].to_i != oldtid.to_i + title=%{


#{e["title"]} by #{e["creator"]} pdf portraitpdf landscape
} if file_suffix=~/s/ + @counter_endn_doc+=1 + oldtid=e["metadata_tid"].to_i + else title = '' + end + if cgi['view']=~/text/ #% txt endnotes + @counter_endn_ocn+=1 + matched_endnote=e["body"].gsub(/(#@search_regx)/i,%{\\1}) + output=%{#{title}
note #{e["nr"]} referred to from ocn #{e["ocn"]}: #{matched_endnote}} + elsif cgi['view']=~/index/ #% idx endnotes + @counter_endn_ocn+=1 + output=%{#{title}#{e["nr"]}#{e["ocn"]}], } + end + @counters_endn=if @counter_endn_doc > 0 + %{Found in the endnotes of #@counter_endn_doc documents, and at #@counter_endn_ocn locations within.
} + end + @endnotes << output #+ details + else @endnotes=Array.new #does not take out yet + end + end + cgi.out{@header + @counters_txt + @counters_endn + @body_main.join + @endnotes.join + @tail} #% print cgi_output_header+counters+body+endnotes + end + rescue Exception => e + s='
' + CGI::escapeHTML(e.backtrace.reverse.join("\n"))
+    s << CGI::escapeHTML(e.message) + '
' + cgi.out{s} + next + ensure # eg. disconnect from server + @conn.disconnect if @conn + end +end diff --git a/data/sisu/conf/cgi-bin/sisu_search_sqlite.cgi b/data/sisu/conf/cgi-bin/sisu_search_sqlite.cgi new file mode 100644 index 00000000..f4c5382a --- /dev/null +++ b/data/sisu/conf/cgi-bin/sisu_search_sqlite.cgi @@ -0,0 +1,932 @@ +#!/usr/bin/env ruby +=begin + * Name: SiSU information Structuring Universe + * Author: Ralph Amissah + * http://www.jus.uio.no/sisu + * http://www.jus.uio.no/sisu/SiSU/download + + * Description: generates naive cgi search form for search of sisu database (sqlite) + * $Id$ + + Copyright (C) 2006 Ralph Amissah + Copyright (C) 2005 Ralph Amissah (first release edition) + Copyright (C) 1997 Ralph Amissah (first edition) + + * License: GPL 2 or later + + Summary of GPL 2 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + http://www.fsf.org/licenses/gpl.html + http://www.gnu.org/copyleft/gpl.html + http://www.jus.uio.no/sisu/gpl2.fsf + + SiSU was first released to the public on January 4th 2005 + + SiSU uses: + + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + © Ralph Amissah 1997, current 2006. + All Rights Reserved. + + * Ralph Amissah ralph@amissah.com + Ralph Amissah ralph.amissah@gmail.com + +=end +require 'cgi' +require 'fcgi' +require 'dbi' +@version='sisu_search_sqlite' +@url_base="http://corundum:8081/_sisu/image" +host=%x{echo $HOSTNAME}.chomp! +@hosturl="http://#{host}" + + ':8081' +@base="#@hosturl/cgi-bin/#@version.cgi" +class Form + def initialize(base,search_field,selected_db,checked_index,checked_text,checked_tip,checked_searched,checked_url,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,search_note,the_can='') + search_note='' if checked_searched !~/\S/ + the_can='' if checked_url !~/\S/ + search_field='' if checked_echo !~/\S/ + @base,@search_field,@selected_db,@checked_index,@checked_text,@checked_tip,@checked_searched,@checked_url,@checked_echo,@checked_sql,@checked_all,@checked_none,@checked_ignore,@search_note,@the_can=base,search_field,selected_db,checked_index,checked_text,checked_tip,checked_searched,checked_url,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,search_note,the_can + @tip=if checked_tip =~/\S/ + 'text:__; keywords:__; title:__; author:__; subject:__; description:__; publisher:__; contributor:__; date:__; type:__; format:__; identifier:__; source:__; language:__; relation:__; coverage:__; rights:__; comment:__; abstract:__; ' + else '' + end + end + def submission_form + search_form=<<-WOK + + + +
+ + + +
+ + +
+

+
+ + index + text + +

+

+
+ #@search_note +
+ #@tip +
+ + echo + searched + url + search fields available + sql statement + +
+ use selected + check all + check none +
+ +#@the_can +WOK + end +end +class Search_request #% search_for + attr_accessor :text1,:keywords,:title,:author,:subject,:description,:publisher,:contributor,:date,:type,:format,:identifier,:source,:language,:relation,:coverage,:rights,:comment,:abstract,:owner,:date_created,:date_issued,:date_modified,:date_available,:date_valid + def initialize(search_field='',q='') + @search_field,@q=search_field,q + @text1=@keywords=@title=@author=@subject=@description=@publisher=@contributor=@date=@type=@format=@identifier=@source=@language=@relation=@coverage=@rights=@comment=@abstract=@owner=@date_created=@date_issued=@date_modified=@date_available=@date_valid='' + if @search_field=~/\S/ + @text1=text_to_match('text:') + @keywords=text_to_match('key(?:words?)?:') + @title=text_to_match('title:') # DublinCore 1 - title + @author=text_to_match('(?:author|creator)s?:') # DublinCore 2 - creator/author + @subject=text_to_match('subj(?:ect)?:') # DublinCore 3 - subject + @description=text_to_match('description:') # DublinCore 4 - description + @publisher=text_to_match('pub(?:lisher)?:') # DublinCore 5 - publisher + @contributor=text_to_match('contributor:') # DublinCore 6 - contributor + @date=text_to_match('date:') # DublinCore 7 - date dd-mm-yy + @type=text_to_match('type:') # DublinCore 8 - type + @format=text_to_match('format:') # DublinCore 9 - format + @identifier=text_to_match('identifier:') # DublinCore 10 - identifier + @source=text_to_match('source:') # DublinCore 11 - source + @language=text_to_match('language:') # DublinCore 12 - language + @relation=text_to_match('relation:') # DublinCore 13 - relation + @coverage=text_to_match('coverage:') # DublinCore 14 - coverage + @rights=text_to_match('rights:') # DublinCore 15 - rights + @comment=text_to_match('comment:') + @abstract=text_to_match('abs(?:tract)?:') + @owner=text_to_match('owner:') + @date_created=text_to_match('date_created:') + @date_issued=text_to_match('date_issued:') + @date_modified=text_to_match('date_modified:') + @date_available=text_to_match('date_available:') + @date_valid=text_to_match('date_valid:') + @text1=text_to_match unless @keywords or @author or @title or @text1 or @comment or @abstract or @rights or @subject or @publisher or @date + else + @text1=q['s1'] if q['s1']=~/\S/ + @keywords=q['key'] if q['key']=~/\S/ + @title=q['ti'] if q['ti']=~/\S/ + @author=q['au'] if q['au']=~/\S/ + @subject=q['sj'] if q['sj']=~/\S/ + @description=q['dsc'] if q['dsc']=~/\S/ + @publisher=q['pb'] if q['pb']=~/\S/ + @contributor=q['cntr'] if q['cntr']=~/\S/ + @date=q['dt'] if q['dt']=~/\S/ + @type=q['ty'] if q['ty']=~/\S/ + @identifier=q['id'] if q['id']=~/\S/ + @source=q['src'] if q['src']=~/\S/ + @language=q['lang'] if q['lang']=~/\S/ + @relation=q['rel'] if q['rel']=~/\S/ + @coverage=q['cov'] if q['cov']=~/\S/ + @rights=q['cr'] if q['cr']=~/\S/ + @comment=q['co'] if q['co']=~/\S/ + @abstract=q['ab'] if q['ab']=~/\S/ + @date_created=q['dtc'] if q['dtc']=~/\S/ + @date_issued=q['dti'] if q['dti']=~/\S/ + @date_modified=q['dtm'] if q['dtm']=~/\S/ + @date_available=q['dta'] if q['dta']=~/\S/ + @date_valid=q['dtv'] if q['dtv']=~/\S/ + end + end + def text_to_match(identifier='') + m=Hash.new + m[:string]=/#{identifier}\s*(.+?)/ + m[:string]=/#{identifier}\s*(.+?)(?:;|\n|\r|$)/ + m[:word]=/#{identifier}[\s(]*(\S+)/ + search_string=if @search_field =~m[:word] + search_string=if @search_field =~m[:braces]: m[:braces].match(@search_field)[1] + elsif @search_field =~m[:string]: m[:string].match(@search_field)[1] + else + str=m[:word].match(@search_field)[1] + str.gsub!(/[()]/,'') + str + end + search_string.strip! + search_string.gsub!(/\s+/,'+') + search_string + #else + # "__" + end + end +end +class Dbi_search_string + def initialize(l,t,q) + @l,@t,@q=l,t,q + end + def string + search=Hash.new + search[:search]=Array.new + search[:flag]=false + if @t =~/\S+/ or @q =~/\S+/ + if @t =~/\S+/: unescaped_search=CGI.unescape(@t) + elsif @q =~/\S+/: unescaped_search=CGI.unescape(@q) + end + search_construct=Array.new + unescaped_search.gsub!(/\s*(AND|OR)\s*/,"%' \) \\1 #@l LIKE \( '%") + unescaped_search.gsub!(/(.+)/,"#@l LIKE \( '%\\1%' \)") + search_construct << unescaped_search + search_construct=search_construct.join(' ') + search[:search] << search_construct + search[:flag]=true + search + end + search + end +end +class Dbi_search_statement + attr_reader :text_search_flag,:sql_select_body_format,:sql_select_endnotes_format + def initialize(conn,search_for,q) + @conn=conn + @text_search_flag=false + search=Hash.new + search[:text],search[:endnotes]=Array.new,Array.new + st=Dbi_search_string.new('documents.clean',search_for.text1,q['s1']).string + se=Dbi_search_string.new('endnotes.clean',search_for.text1,q['s1']).string + @text_search_flag=st[:flag] + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << se[:search] + end + st=Dbi_search_string.new('metadata.keywords',search_for.keywords,q['key']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.title',search_for.title,q['ti']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.creator',search_for.author,q['au']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.subject',search_for.subject,q['sj']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.description',search_for.description,q['dsc']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.publisher',search_for.publisher,q['pb']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.contributor',search_for.contributor,q['cntr']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.date',search_for.date,q['dt']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.type',search_for.type,q['ty']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.identifier',search_for.identifier,q['id']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.source',search_for.source,q['src']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.language',search_for.language,q['lang']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.relation',search_for.relation,q['rel']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.coverage',search_for.coverage,q['cov']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.rights',search_for.rights,q['cr']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.comment',search_for.comment,q['co']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + st=Dbi_search_string.new('metadata.abstract',search_for.abstract,q['ab']).string + if st[:flag] + search[:text] << st[:search] + search[:endnotes] << st[:search] + end + @search_text,@search_endnotes=Array.new,Array.new + #% + search[:text].each{|x| @search_text << "#{x} AND " } + search[:endnotes].each{|x| @search_endnotes << "#{x} AND " } + @search_text=@search_text.to_s.gsub!(/AND\s+$/,'') + @search_endnotes=@search_endnotes.to_s.gsub!(/AND\s+$/,'') + end + def sql_select_body + %{SELECT metadata.title, metadata.creator, metadata.filename, metadata.suffix, documents.body, documents.seg, documents.ocn, metadata.tid FROM documents, metadata WHERE #{@search_text} AND documents.metadata_tid = metadata.tid ORDER BY metadata.title, documents.ocn ;} + end + def sql_select_endnotes + %{SELECT metadata.title, metadata.creator, metadata.filename, endnotes.body, endnotes.nr, endnotes.ocn, endnotes.metadata_tid FROM metadata, endnotes WHERE #{@search_endnotes} AND metadata.tid = endnotes.metadata_tid ORDER BY metadata.title, endnotes.nr ;} + end + def sql_select_body_format + %{#{sql_select_body}} + end + def sql_select_endnotes_format + %{#{sql_select_endnotes}} + end + def contents + @conn.select_all(sql_select_body) + end + def endnotes + @conn.select_all(sql_select_endnotes) + end +end +class Tail + def tail + <<-'WOK' +


+
+ + + + +

+ presentations' look and feel
+ generated by
+ SiSU on Debian/Gnu/Linux or a FreeBSD & Ruby - better ways, well actually, Way Better!
+ SiSU
+ version 0.36
2006w07/6 (20060218)
+ + + © Ralph Amissah
+ 1993, current 2006
+ GPL 2
+ w3 since October 3 1993
+ ralph@amissah.com
+

+
+ +

Developed
using Ruby
on Debian/Gnu/Linux software infrastructure,
with the usual GPL (or OSS) suspects.
Better - "performance, reliability, scalability, security
& total cost of ownership"
[not to mention flexibility & choice]

<<Way Better!>>

+ + + +

+ If you have problems viewing pages on this site please update your browser: +

+
+ + + +
+

+ +If you have problems viewing pages on this site please update your browser: + +

+
+ + + + + + + + + + + + + + + + + + + +
+

+ + +Epiphany + Epiphany + +® | + +

+
+

+ + +Galeon + Galeon + +® | + +

+
+

+ + +MS I-Explorer +I-Explorer + +® | + +

+
+

+ + +Kazehakase +® |

+
+

+ + +Konqueror +Konqueror +® |

+
+

+ + +Mozilla +Mozilla + + +Firefox +Firefox + +® | + +

+
+

+ + +Netscape +Netscape + +® | + +

+
+

+ + +Opera +Opera + +® | + +

+
+

+ + +Safari +Safari + +® + +

+
+ + + + + + + + + + + + + + + + + +
+

+ +for console/text viewing: + +

+
+

+ + +elinks + | + +

+
+

+ + +links2 + | + +

+
+

+ + +w3m + + +

+
+

+ +for lightweight gui (X) viewing try: + +

+
+

+ + +Dillo + |

+
+

+ + +Epiphany + Epiphany + +® | + +

+
+

+ + +Galeon + Galeon + | + +

+
+

+ + +links2 -g + + +

+
+
+ + + + +
+

+ +& for + +pdf + +viewings of this site we recommend stand alone viewers +
+(rather than web browser plugins): +
+

+
+ + + + + + + + + +
+

+ + +Adobe Acrobat Reader +Acrobat Reader + +® + | + +

+
+

+ + +Evince +Evince + +® + +

+
+

+ + GhostView® , + +GV® + +& + +GSview® + + | + +

+
+

+ + +Xpdf + Xpdf + +® + +

+
+ +
+ +WOK + end +end +@counter_txt_doc,@counter_txt_ocn,@counter_endn_doc,@counter_endn_ocn=0,0,0,0 +@counters_txt,@counters_endn,@sql_select_body,@sql_select_endnotes='','','','' +FCGI.each_cgi do |cgi| + begin # all code goes in begin section + @search=Hash.new + @search[:text],@search[:endnotes]=Array.new,Array.new + q=CGI.new + @db=if cgi['db'] =~/\S+/: + @stub=/SiSU_(\S+)/.match(cgi['db'])[1] + cgi['db'] + else + @stub='sisu' + 'SiSU_sisu' + end + checked_url,checked_searched,checked_tip,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,selected_db='','','','','','','','' + if cgi['view']=~/text/: checked_index,checked_text='','checked' + else checked_index,checked_text='checked','' + end + checked_url='checked' if cgi['url'] =~/\S/ or cgi['u'].to_i==1 + checked_searched='checked' if cgi['searched'] =~/\S/ + checked_tip='checked' if cgi['tip'] =~/\S/ + checked_echo='checked' if cgi['echo'] =~/\S/ + checked_sql='checked' if cgi['sql'] =~/\S/ + if cgi['checks'] =~/check_all/ or cgi['check_all'] =~/\S/ or cgi['a'].to_i==1 + checked_all=checked_url=checked_searched=checked_tip=checked_echo=checked_sql='checked' + checked_none='' + elsif cgi['checks'] =~/check_none/ #or cgi['a'].to_i==0 + checked_none='checked' + checked_all=checked_url=checked_searched=checked_tip=checked_echo=checked_sql='' + else checked_ignore='checked' + end + selected_db=case cgi['db'] + when /SiSU_document_samples_sisu_markup/: '' + when /SiSU_sisu/: '' + end + db_name='sisu_sqlite.db' + db_sqlite=case cgi['db'] + when /SiSU_document_samples_sisu_markup/: "/home/ralph/sisu_www/document_samples_sisu_markup/sisu_sqlite.db" + when /SiSU_sisu/: "/home/ralph/sisu_www/sisu/sisu_sqlite.db" + end + @dbi="DBI:SQLite:#{db_sqlite}" #sqlite3 ? + @conn=DBI.connect(@dbi) + search_field=cgi['find'] if cgi['find'] # =~/\S+/ + @search_for=Search_request.new(search_field,q) #.analyze #% search_for + #% searches + #Canned_search.new(@base,@search_for.text1,cgi) + if @search_for.text1=~/\S+/ or @search_for.author=~/\S+/ #and search_field =~/\S/ + s1='s1=' + CGI.escape(@search_for.text1) if @search_for.text1=~/\S/ + key='key=' + CGI.escape(@search_for.keywords) if @search_for.keywords=~/\S/ + ti='&ti=' + CGI.escape(@search_for.title) if @search_for.title=~/\S/ + au='&au=' + CGI.escape(@search_for.author) if @search_for.author=~/\S/ + sj='&sj=' + CGI.escape(@search_for.subject) if @search_for.subject=~/\S/ + dsc='&dsc=' + CGI.escape(@search_for.description) if @search_for.description=~/\S/ + pb='&pb=' + CGI.escape(@search_for.publisher) if @search_for.publisher=~/\S/ + cntr='&cntr=' + CGI.escape(@search_for.contributor) if @search_for.contributor=~/\S/ + dt='&dt=' + CGI.escape(@search_for.date) if @search_for.date=~/\S/ + ty='&ty=' + CGI.escape(@search_for.type) if @search_for.type=~/\S/ + id='&id=' + CGI.escape(@search_for.identifier) if @search_for.identifier=~/\S/ + src='&src=' + CGI.escape(@search_for.source) if @search_for.source=~/\S/ + lang='&lang=' + CGI.escape(@search_for.language) if @search_for.language=~/\S/ + rel='&rel=' + CGI.escape(@search_for.relation) if @search_for.relation=~/\S/ + cov='&cov=' + CGI.escape(@search_for.coverage) if @search_for.coverage=~/\S/ + cr='&cr=' + CGI.escape(@search_for.rights) if @search_for.rights=~/\S/ + co='&co=' + CGI.escape(@search_for.comment) if @search_for.comment=~/\S/ + ab='&ab=' + CGI.escape(@search_for.abstract) if @search_for.abstract=~/\S/ + dtc='&dtc=' + CGI.escape(@search_for.date_created) if @search_for.date_created=~/\S/ + dti='&dti=' + CGI.escape(@search_for.date_issued) if @search_for.date_issued=~/\S/ + dtm='&dtm=' + CGI.escape(@search_for.date_modified) if @search_for.date_modified=~/\S/ + dta='&dta=' + CGI.escape(@search_for.date_available) if @search_for.date_available=~/\S/ + dtv='&dtv=' + CGI.escape(@search_for.date_valid) if @search_for.date_valid=~/\S/ + canned_search_url=if checked_all =~/checked/ + "#@base?#{s1}#{key}#{ti}#{au}#{sj}#{dsc}#{pb}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}&db=#{cgi['db']}&view=#{cgi['view']}&a=1" + else "#@base?#{s1}#{key}#{ti}#{au}#{sj}#{dsc}#{pb}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}&db=#{cgi['db']}&view=#{cgi['view']}&u=1&e=1" + end + @search[:text][1]=%{documents.clean~'#{@search_for.text1}'} #s1 + @search[:endnotes][1]=%{endnotes.clean~'#{@search_for.text1}'} #s1 + canned_note='previous search url:' + else + canned_search_url="#@base?s1=United+Nations&db=documents&view=index" + canned_note='search url example:' + end + if search_field =~/\S+/ + analyze_format=search_field.gsub(/\s*\n/,'; ') + elsif checked_all =~/checked/ or checked_url =~/checked/ + canned_search=canned_search_url.scan(/(?:s1|au|ti)=[^&]+/) + af=canned_search.join('; ') + af.gsub!(/s1=/,'text: ') + af.gsub!(/au=/,'author: ') + af.gsub!(/ti=/,'title: ') + af.gsub!(/%2B/,' ') + analyze_format=af + st=af.split(/\s*;\s*/) + search_field=st.join("\n") + end + green=%{} + the_can=%{#{canned_note}
#{canned_search_url}

} + p_text=p_keywords=p_title=p_author=p_subject=p_description=p_publisher=p_contributor=p_date=p_type=p_format=p_identifier=p_source=p_language=p_relation=p_coverage=p_rights=p_comment=p_abstract=p_subject='' + p_text=%{text: #{green}#{@search_for.text1}

} if @search_for.text1 =~/\S+/ + p_keywords=%{keywords: #{green}#{@search_for.keywords}

} if @search_for.keywords =~/\S+/ + p_title=%{title: #{green}#{@search_for.title}
} if @search_for.title =~/\S+/ + p_author=%{author: #{green}#{@search_for.author}
} if @search_for.author =~/\S+/ + p_subject=%{subject: #{green}#{@search_for.subject}
} if @search_for.subject =~/\S+/ + p_description=%{description: #{green}#{@search_for.description}
} if @search_for.description =~/\S+/ + p_publisher=%{publisher: #{green}#{@search_for.publisher}
} if @search_for.publisher =~/\S+/ + p_contributor=%{contributor: #{green}#{@search_for.contributor}
} if @search_for.contributor =~/\S+/ + p_date=%{date: #{green}#{@search_for.date}
} if @search_for.date =~/\S+/ + p_type=%{type: #{green}#{@search_for.type}
} if @search_for.type =~/\S+/ + p_format=%{format: #{green}#{@search_for.format}
} if @search_for.format =~/\S+/ + p_identifier=%{identifier: #{green}#{@search_for.identifier}
} if @search_for.identifier =~/\S+/ + p_source=%{source: #{green}#{@search_for.source}
} if @search_for.source =~/\S+/ + p_language=%{language: #{green}#{@search_for.language}
} if @search_for.language =~/\S+/ + p_relation=%{relation: #{green}#{@search_for.relation}
} if @search_for.relation =~/\S+/ + p_coverage=%{coverage: #{green}#{@search_for.coverage}
} if @search_for.coverage =~/\S+/ + p_rights=%{rights: #{green}#{@search_for.rights}
} if @search_for.rights =~/\S+/ + p_comment=%{comment: #{green}#{@search_for.comment}
} if @search_for.comment =~/\S+/ + p_abstract=%{abstract: #{green}#{@search_for.abstract}
} if @search_for.abstract =~/\S+/ + search_note=<<-WOK + +
previous selection:
+database: #{green}#@db
; selected view: #{green}#{cgi['view']}
+search string: "#{green}#{analyze_format}"
+#{p_text} #{p_keywords} #{p_title} #{p_author} #{p_subject} #{p_description} #{p_publisher} #{p_contributor} #{p_date} #{p_type} #{p_format} #{p_identifier} #{p_source} #{p_language} #{p_relation} #{p_coverage} #{p_rights} #{p_comment} #{p_abstract} + +WOK + #eg = %{canned search e.g.:
#{url}
find: #{analyze}
database: #{database}} + #dbi_canning + @header=Form.new(@base,search_field,selected_db,checked_index,checked_text,checked_tip,checked_searched,checked_url,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,search_note,the_can).submission_form #% form + @tail=Tail.new.tail + unless q['s1'] =~/\S/ or q['au'] =~/\S/ or @search[:text][1] =~/\S/ + print "Content-type: text/html\n\n" + puts (@header+@tail) + else #% searches + s1=if @search_for.text1 =~/\S/ + @search_for.text1 + else 'Unavailable' + end + @search[:text]<<%{documents.clean~'#{CGI.unescape(s1)}'} + @search[:endnotes]<<%{endnotes.clean~'#{CGI.unescape(s1)}'} + #dbi_request + dbi_statement=Dbi_search_statement.new(@conn,@search_for,q) + @text_search_flag=false + @text_search_flag=dbi_statement.text_search_flag + s_contents=dbi_statement.contents + s_endnotes=dbi_statement.endnotes + @body_main=Array.new + @endnotes=Array.new + oldtid=0 + if @text_search_flag + if checked_sql =~/\S/ + sql_select_body=dbi_statement.sql_select_body_format + sql_select_endnotes=dbi_statement.sql_select_endnotes_format + else sql_select_body,sql_select_endnotes='','' + end + @body_main << "



Main Text:
" << sql_select_body + @endnotes << "



Endnotes:
" << sql_select_endnotes + else + end + #text_objects_body + s_contents.each do |c| #% text body + location=c["filename"][/(.+?)\.ss[ftm]/, 1] + file_suffix=c["filename"][/.+?\.(ss[ftm])/, 1] + #metadata_found_body + if c["tid"].to_i != oldtid.to_i + title=%{#{c["title"]} by #{c["creator"]} pdf portraitpdf landscape
} if file_suffix=~/s/ #hmm watch file_suffix + if @text_search_flag: title='

'+title + else title='
'+title + end + @counter_txt_doc+=1 + oldtid=c["tid"].to_i + else title='' + end + if @text_search_flag + if cgi['view']=~/text/ #% txt body + text=if c["suffix"] !~/1/ #seg + if @search_for.text1 =~/\S+/ or q['s1'] =~/\S+/ #% only this branch is working !! + if @search_for.text1 =~/\S+/: unescaped_search=CGI.unescape(@search_for.text1) + elsif q['s1'] =~/\S+/: unescaped_search=CGI.unescape(q['s1']) + end + search_regex=Array.new + build=unescaped_search.scan(/\S+/).each do |g| + if g.to_s =~/(AND|OR)/ + search_regex << '|' + else search_regex << %{#{g.to_s}} + end + end + search_regex=search_regex.join(' ') + search_regex=search_regex.gsub(/\s*\|\s*/,'|') + @search_regx=search_regex.to_s + end + matched_para=c["body"].gsub(/(#@search_regx)/i,%{\\1}) + %{

ocn #{c["ocn"]}:

#{matched_para}} + elsif c["suffix"] =~/1/ #doc + %{#{title}

ocn #{c["ocn"]}:#{c["body"]}} + end + @counter_txt_ocn+=1 + output=if c["seg"] =~/\S+/: title+text + else text + end + elsif cgi['view']=~/index/ #% idx body + if c["suffix"] !~/1/ #seg + index=%{#{c["ocn"]}, } if @text_search_flag + elsif c["suffix"] =~/1/ #doc + index=%{#{c["ocn"]}, } + end + if c["seg"] =~/\S+/ + if @text_search_flag + @counter_txt_ocn+=1 + output=title+index + end + else + @counter_txt_ocn+=1 + output=unless c["suffix"] =~/1/: title+index + else %{#{title}#{c["ocn"].sort}, } + end + end + end + else output=title + end + @counters_txt=if @counter_txt_doc > 0 + %{Found in the main body of #@counter_txt_doc documents, and at #@counter_txt_ocn locations within.
} + else '' + end + @body_main << output #+ details + end + #text_objects_endnote + oldtid = 0 + s_endnotes.each do |e| #% endnotes + location=e["filename"][/(.+?)\.ss[ftm]/, 1] + file_suffix=e["filename"][/.+?\.(ss[ftm])/, 1] + #metadata_found_endnotes + if @text_search_flag + if e["metadata_tid"].to_i != oldtid.to_i + title=%{


#{e["title"]} by #{e["creator"]} pdf portraitpdf landscape
} if file_suffix=~/s/ + @counter_endn_doc+=1 + oldtid=e["metadata_tid"].to_i + else title = '' + end + if cgi['view']=~/text/ #% txt endnotes + @counter_endn_ocn+=1 + matched_endnote=e["body"].gsub(/(#@search_regx)/i,%{\\1}) + output=%{#{title}
note #{e["nr"]} referred to from ocn #{e["ocn"]}: #{matched_endnote}} + elsif cgi['view']=~/index/ #% idx endnotes + @counter_endn_ocn+=1 + output=%{#{title}#{e["nr"]}#{e["ocn"]}], } + end + @counters_endn=if @counter_endn_doc > 0 + %{Found in the endnotes of #@counter_endn_doc documents, and at #@counter_endn_ocn locations within.
} + end + @endnotes << output #+ details + else @endnotes=Array.new #does not take out yet + end + end + cgi.out{@header + @counters_txt + @counters_endn + @body_main.join + @endnotes.join + @tail} #% print cgi_output_header+counters+body+endnotes + end + rescue Exception => e + s='
' + CGI::escapeHTML(e.backtrace.reverse.join("\n"))
+    s << CGI::escapeHTML(e.message) + '
' + cgi.out{s} + next + ensure # eg. disconnect from server + @conn.disconnect if @conn + end +end diff --git a/data/sisu/conf/completion/README b/data/sisu/conf/completion/README new file mode 100644 index 00000000..d723a140 --- /dev/null +++ b/data/sisu/conf/completion/README @@ -0,0 +1,7 @@ +_sisu (naive zsh completion for SiSU) + on Debian file is located at /usr/share/sisu/conf/completion + installation: works if copied somewhere within your $fpath + do it yourself on Debian copy to ~/.zfunc or + /usr/local/share/zsh/site-functions and run compinit + + note zsh is not installed by default on a Debian system diff --git a/data/sisu/conf/completion/_sisu b/data/sisu/conf/completion/_sisu new file mode 100644 index 00000000..076795cb --- /dev/null +++ b/data/sisu/conf/completion/_sisu @@ -0,0 +1,64 @@ +#compdef sisu +# Copyright (C) 2006 Ralph Amissah +# sisu, version 0.46.1 +# same license as Zsh or SiSU +local curcontext="$curcontext" state line ret=1 +typeset -A opt_args +_arguments -s -C -M 'r:|[_-]=* r:|=*' \ + '(--convert --to -C)-U[prints to screen url output map of available output possibilities]' \ + '(--convert --to -C)-u[url mapping of output files for requested processing flags]' \ + '(--convert --to -C)-V[more verbose than -v]' \ + '(--convert --to -C)-v[verbose]' \ + '--no-ocn[-\[hHp\]switches off object citation numbering]' \ + '--no-annotate[-\[mhHpoxXabN\] strips output text of additional editors endnotes]' \ + '(--convert --to -C)-A[plaintext with dos line-feeds, footnotes follow paragraphs in which they occur]' \ + '(--convert --to -C)-a[plaintext with Unix line-feeds, footnotes follow paragraphs in which they occur]' \ + '(--convert --to -C)-b[XHTML output]' \ + '(- *)-C[initialise site]' \ + '(--convert --to -C)-c[toggle screen color on or off depending on set default]' \ + '(--convert --to -C)-E[plaintext with dos line-feeds, endnotes following main text]' \ + '(--convert --to -C)-e[plaintext with Unix line-feeds, endnotes following main text]' \ + '(--convert --to -C)-F[generate sample cgi web search form \[--webserv=webrick for sisu webrick url\]]' \ + '(--convert --to -C -h)-H[HTML output, without link suffixes]' \ + '(--convert --to -C -H)-h[HTML output]' \ + '(--convert --to -C)-I[texinfo output, not maintained]' \ + '(--convert --to -C)-L[print license info]' \ + '(--convert --to -C)-M[maintenance mode, retain intermediate processing files]' \ + '(--convert --to -C)-m[create intermediate markup file, metaverse, assumed for most output instuctions]' \ + '(--convert --to -C)-N[document content certificate, output document digests]' \ + '(--convert --to -C)-n[skip intermediate markup, skip -m]' \ + '(--convert --to -C)-o[Open Document text format output]' \ + '(--convert --to -C)-p[LaTeX pdf output]' \ + '(--convert --to -C)-q[quiet mode]' \ + '(--convert --to -C)-R[post output to remote host using rsync, requires pre-configuration]' \ + '(--convert --to -C)-r[post output to remote host using scp, requires pre-configuration]' \ + '(--convert --to -C)-S[produces and shares tarred gzipped markup source document with associated images etc.]' \ + '(--convert --to -C)-s[shares markup source]' \ + '(--convert --to -C)-t[termsheet, preprocessing]' \ + '(- *)-W[starts ruby webrick server]' \ + '(--convert --to -C)-w[concordance file]' \ + '(--convert --to -C)-X[XML dom style]' \ + '(--convert --to -C)-x[XML sax style]' \ + '(--convert --to -C)-y[output summary page, manifest of existing generated output]' \ + '(--convert --to -C)-Z[Zap delete/destroy output]' \ + '--import[-\[Dd\] imports document to database]' \ + '--update[-\[Dd\] updates document in database]' \ + '--remove[-\[Dd\] removes document from database]' \ + '--dropall[-\[Dd\] drops database, tables, indexes, all!]' \ + '--create[-\[Dd\] creates new database - tables, indexes, etc.]' \ + '--recreate[-\[Dd\] drops database, killing data and creates new empty database - tables, indexes, etc.]' \ + '(--convert --to -C)-D[postgresql database instruction]' \ + '(--convert --to -C)-d[sqlite database instruction]' \ + '(- *)--help[display help information]' \ + '(--convert --to -C -2 -3 -4 -5)-1[shortcut, initial default -mNHwpy]' \ + '(--convert --to -C -1 -3 -4 -5)-2[shortcut, initial default -mNHwpaoy]' \ + '(--convert --to -C -1 -2 -4 -5)-3[shortcut, initial default -mNHwpaobxXy]' \ + '(--convert --to -C -1 -2 -3 -5)-4[shortcut, initial default -mNHwpaobxXDy --import]' \ + '(--convert --to -C -1 -2 -3 -4)-5[shortcut, initial default -mNHwpaobxXDy --update]' \ + '--to=node[XML node based input representation, experimental]' \ + '--to=sax[XML sax based input representation, experimental]' \ + '--to=dom[XML dom based input representation, experimental]' \ + '--convert=footnotes[embedded footnotes]' \ + '--to=current[current markup]' \ + '--to=xml2sst[from sisu xml to sst]' \ + '*:SiSU files:_files -g "*.(sst|ssm)(.)"' diff --git a/data/sisu/conf/convert/kdissert_to_sisu b/data/sisu/conf/convert/kdissert_to_sisu new file mode 100644 index 00000000..aa651f80 --- /dev/null +++ b/data/sisu/conf/convert/kdissert_to_sisu @@ -0,0 +1,161 @@ +#!/usr/bin/env ruby +=begin + * Name: modify.rb + * Author: Ralph Amissah + * http://www.jus.uio.no/sisu + * http://www.jus.uio.no/sisu/SiSU/download + * Description: Conversion script from kdissert .kdi to sisu markup .sst + * Copyright (C) 2004, 2006 Ralph Amissah + * Packaged with: SiSU information Structuring Universe - + Structured information, Serialized Units + * SiSU Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Ralph Amissah + + * License: GPL 2 or later + + Summary of GPL 2 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + http://www.fsf.org/licenses/gpl.html + http://www.gnu.org/copyleft/gpl.html + http://www.jus.uio.no/sisu/gpl2.fsf + + © Ralph Amissah 1997, current 2006. + All Rights Reserved. + + * Ralph Amissah: ralph@amissah.com + ralph.amissah@gmail.com +=end +require 'rexml/document' +include REXML +argv=$* +@sisu,@sisu_base=Array.new,Array.new +unless argv.empty? + argv.each do |kdi| + if kdi =~/\.kdi$/ + system("cp #{kdi} #{kdi}.tar.gz && tar xzvf #{kdi}.tar.gz && rm #{kdi}.tar.gz") + file=File.new("maindoc.xml") + #system("cp #{kdi} /tmp/. && cd /tmp && tar xzvf /tmp/#{kdi} && cd -") + #file=File.new("/tmp/maindoc.xml") + @output=File.new("#{kdi}.sst",'w') + doc=Document.new(file) + root=doc.root + @el=Array.new + root.each do |x| + end + root.each_with_index do |content,idx| + if root.elements["item[#{idx}]/summary"] + id,ma,ch=nil,nil,Array.new + if root.elements["item[#{idx}]/id"] + id=root.elements["item[#{idx}]/id"].text.to_i + end + if root.elements["item[#{idx}]/parent"] + ma=root.elements["item[#{idx}]/parent"].text.to_s + end + if root.elements["item[#{idx}]/child"] #problem only get one child, even where several + root.get_elements("item[#{idx}]/child").each do |x| + ch << x.text + end + end + if root.elements["item[#{idx}]/summary"] + sum=root.elements["item[#{idx}]/summary"].text.to_s.strip + end + if root.elements["item[#{idx}]/text"] + txt=root.elements["item[#{idx}]/text"].text.to_s.strip + end + @el[id]=Hash.new + @el[id][:id]=id + @el[id][:ma]=ma + @el[id][:ch]=ch + @el[id][:sum]=sum + @el[id][:txt]=txt + if ma == '-1' + @el[id][:lev]=':A' + @top=id + end + end + end + @doc=Array.new + @title=@el[@top][:sum] + p @el[@top][:sum] + @doc << ':A~ ' + @el[@top][:sum] + @el[@top][:ch].each do |x| + @el[x.to_i][:lev]='1' + @doc << '1~ ' + @el[x.to_i][:sum] + @doc << @el[x.to_i][:txt] + @el[x.to_i][:ch].each do |y| + @el[y.to_i][:lev]='2' + @doc << '2~ ' + @el[y.to_i][:sum] + @doc << @el[y.to_i][:txt] + @el[y.to_i][:ch].each do |z| + @el[z.to_i][:lev]='3' + @doc << '3~ ' + @el[z.to_i][:sum] + @doc << @el[z.to_i][:txt] + @el[z.to_i][:ch].each do |za| #unsupported... consder + @el[za.to_i][:lev]='4' + @doc << '!_ ' + @el[za.to_i][:sum] + @doc << @el[za.to_i][:txt] + end + end + end + end + #@el.each_with_index do |x,i| + # if x: puts "#{i}: lev: #{x[:lev]}, id: #{x[:id]}, ma: #{x[:ma]}, ch: #{x[:ch].join(',')}" + # end + #end +# regexs strip most kdissert markup, and provide minimal info for sisu markup --> + @doc.each do |c,idx| + c.gsub!(/<\/summary>/,'') + c.gsub!(/.+?\n|<\/body>|<\/html>|

/m,'') + c.gsub!(/<\/p>/,"\n") + c.gsub!(/(.+?)<\/span>/," *{ \\1 }* ") + c.gsub!(/(.+?)<\/span>/," _{ \\1 }_ ") + c.gsub!(/(.+?)<\/span>/," /{ \\1 }/ ") + c.gsub!(/