diff options
author | Ralph Amissah <ralph@amissah.com> | 2007-07-07 09:29:14 +0100 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2007-07-07 09:29:14 +0100 |
commit | e2d508aca4c5011ce8d1eed3f855833026468880 (patch) | |
tree | b3c89a6c469796612e59e6d8cbfc88d569cbcce2 /lib | |
parent | debian directory reinstated (diff) | |
parent | cgi-sample search form; texinfo fix; xml scaffold; help, man pages etc. visit... (diff) |
Merge branch 'upstream' into debian/sid
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v0/cgi_pgsql.rb | 28 | ||||
-rw-r--r-- | lib/sisu/v0/cgi_sql_common.rb | 196 | ||||
-rw-r--r-- | lib/sisu/v0/cgi_sqlite.rb | 11 | ||||
-rw-r--r-- | lib/sisu/v0/docbook.rb | 567 | ||||
-rw-r--r-- | lib/sisu/v0/help.rb | 98 | ||||
-rw-r--r-- | lib/sisu/v0/hub.rb | 14 | ||||
-rw-r--r-- | lib/sisu/v0/sysenv.rb | 23 | ||||
-rw-r--r-- | lib/sisu/v0/texinfo.rb | 29 | ||||
-rw-r--r-- | lib/sisu/v0/texinfo_format.rb | 133 | ||||
-rw-r--r-- | lib/sisu/v0/urls.rb | 6 | ||||
-rw-r--r-- | lib/sisu/v0/xml_scaffold.rb | 203 |
11 files changed, 542 insertions, 766 deletions
diff --git a/lib/sisu/v0/cgi_pgsql.rb b/lib/sisu/v0/cgi_pgsql.rb index e5260a5f..0032a927 100644 --- a/lib/sisu/v0/cgi_pgsql.rb +++ b/lib/sisu/v0/cgi_pgsql.rb @@ -92,7 +92,7 @@ module SiSU_CGI_pgsql f2 << " end\n" if FileTest.writable?('.') output=File.open('sisu_pgsql.cgi','w') - output << header0 << header1 << header_desc << header2 << f1 << buttons1 << buttons_note << buttons2 << search_request << search_statement << search_statement_common << search_query1 << @common.pages << search_query2 << @common.tail << @common.main1 << f2 << dbi_connect << @common.main2 + output << header0 << header1 << header_desc << header2 << f1 << buttons1 << buttons2 << buttons2_pgsql << buttons3 << search_request << search_statement << search_statement_common << search_query1 << @common.pages << search_query2 << @common.tail << @common.main1 << f2 << dbi_connect << @common.main2 a=%{ generated sisu_pgsql.cgi, BASED ON ALREADY EXISTING directories that could potentially be used to populate postgresql db, (-D) } @@ -139,8 +139,8 @@ module SiSU_CGI_pgsql def search_statement <<-'WOK_SQL' class Dbi_search_string - def initialize(l,t,q) - @l,@t,@q=l,t,q + def initialize(l,t,q,cse=false) + @l,@t,@q,@c=l,t,q,cse end def string search={ :search => [],:flag => false } @@ -149,8 +149,13 @@ module SiSU_CGI_pgsql elsif @q =~/\S+/; unescaped_search=CGI.unescape(@q) end search_construct=[] - unescaped_search.gsub!(/\s*(AND|OR)\s*/,"' \) \\1 #@l~\( '") - unescaped_search.gsub!(/(.+)/,"#@l~\( '\\1' \)") + if @c + unescaped_search.gsub!(/\s*(AND|OR)\s*/,"' \) \\1 #@l~\( '") + unescaped_search.gsub!(/(.+)/,"#@l~\( '\\1' \)") + else + unescaped_search.gsub!(/\s*(AND|OR)\s*/,"' \) \\1 #@l~*\( '") + unescaped_search.gsub!(/(.+)/,"#@l~*\( '\\1' \)") + end search_construct << unescaped_search search_construct=search_construct.join(' ') search[:search] << search_construct @@ -162,9 +167,6 @@ module SiSU_CGI_pgsql end WOK_SQL end - def buttons_note - ' <font size="2" color="#666666">case sensitive</font>' - end def search_query1 <<-'WOK_SQL' @search_text,@search_endnotes=[],[] @@ -183,7 +185,7 @@ module SiSU_CGI_pgsql def sql_select_body limit ||=@@limit offset ||=@@offset - @sql_statement[: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} + @sql_statement[: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, metadata.filename, documents.ocn} @sql_statement[:range]=%{LIMIT #{limit} OFFSET #{offset} ;} select=@sql_statement[:body] + ' ' + @sql_statement[:range] select @@ -191,7 +193,7 @@ module SiSU_CGI_pgsql def sql_select_endnotes limit ||=@@limit offset ||=@@offset - @sql_statement[: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} + @sql_statement[: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, metadata.filename, endnotes.nr} @sql_statement[:range]=%{LIMIT #{limit} OFFSET #{offset} ;} select=@sql_statement[:endnotes] + ' ' + @sql_statement[:range] select @@ -211,6 +213,12 @@ module SiSU_CGI_pgsql end WOK_SQL end + def buttons2_pgsql + <<-'WOK_SQL' + <font size="2" color="#222222"> + <input type="checkbox" name="casesense" #@checked_case> case sensitive + WOK_SQL + end def dbi_connect <<-'WOK_SQL' dbi="dbi:Pg:database=#{@db};port=#{@port}" diff --git a/lib/sisu/v0/cgi_sql_common.rb b/lib/sisu/v0/cgi_sql_common.rb index 6045bf10..37ca67b8 100644 --- a/lib/sisu/v0/cgi_sql_common.rb +++ b/lib/sisu/v0/cgi_sql_common.rb @@ -131,11 +131,11 @@ module SiSU_CGI_sql @color_heading='#DDFFAA' @color_match='#ffff48' 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='') + def initialize(base,search_field,selected_db,checked_index,checked_text,checked_tip,checked_searched,checked_url,checked_case,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 + @base,@search_field,@selected_db,@checked_index,@checked_text,@checked_tip,@checked_searched,@checked_url,@checked_case,@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_case,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,search_note,the_can @tip=if checked_tip =~/\S/ '<font size="2" color="#666666">text:__; keywords:__; title:__; author:__; subject:__; description:__; publisher:__; contributor:__; date:__; type:__; format:__; identifier:__; source:__; language:__; relation:__; coverage:__; rights:__; comment:__; abstract:__; filename:__;</font>' else '' @@ -205,8 +205,13 @@ module SiSU_CGI_sql #@tip #@search_note #@the_can - </td></tr></table><table><tr><td> - <font size="2" color="#222222"> + </td></tr></table> + <table><tr><td> + WOK_SQL + end + def buttons3 + <<-'WOK_SQL' + <br /> <input type="checkbox" name="echo" #@checked_echo> echo previous search <input type="checkbox" name="searched" #@checked_searched> search result stats <input type="checkbox" name="url" #@checked_url> url for search @@ -319,106 +324,109 @@ module SiSU_CGI_sql <<-'WOK_SQL' class Dbi_search_statement attr_reader :text_search_flag,:sql_select_body_format,:sql_select_endnotes_format,:sql_offset,:sql_limit - def initialize(conn,search_for,q) + def initialize(conn,search_for,q,c) @conn=conn @text_search_flag=false @sql_statement={ :body=>'',:endnotes=>'',:range=>'' } #@offset||=@@offset #@offset+=@@limit search={ :text => [],:endnotes => [] } - 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 + cse=if c =~/\S/; true + else false + end + st=Dbi_search_string.new('documents.clean',search_for.text1,q['s1'],cse).string + se=Dbi_search_string.new('endnotes.clean',search_for.text1,q['s1'],cse).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 + st=Dbi_search_string.new('metadata.keywords',search_for.keywords,q['key'],cse).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 + st=Dbi_search_string.new('metadata.title',search_for.title,q['ti'],cse).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 + st=Dbi_search_string.new('metadata.creator',search_for.author,q['au'],cse).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 + st=Dbi_search_string.new('metadata.subject',search_for.subject,q['sj'],cse).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 + st=Dbi_search_string.new('metadata.description',search_for.description,q['dsc'],cse).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 + st=Dbi_search_string.new('metadata.publisher',search_for.publisher,q['pb'],cse).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 + st=Dbi_search_string.new('metadata.contributor',search_for.contributor,q['cntr'],cse).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 + st=Dbi_search_string.new('metadata.date',search_for.date,q['dt'],cse).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 + st=Dbi_search_string.new('metadata.type',search_for.type,q['ty'],cse).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 + st=Dbi_search_string.new('metadata.identifier',search_for.identifier,q['id'],cse).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 + st=Dbi_search_string.new('metadata.source',search_for.source,q['src'],cse).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 + st=Dbi_search_string.new('metadata.language',search_for.language,q['lang'],cse).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 + st=Dbi_search_string.new('metadata.relation',search_for.relation,q['rel'],cse).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 + st=Dbi_search_string.new('metadata.coverage',search_for.coverage,q['cov'],cse).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 + st=Dbi_search_string.new('metadata.rights',search_for.rights,q['cr'],cse).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 + st=Dbi_search_string.new('metadata.comment',search_for.comment,q['co'],cse).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 + st=Dbi_search_string.new('metadata.abstract',search_for.abstract,q['ab'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] end - st=Dbi_search_string.new('metadata.filename',search_for.filename,q['fns']).string + st=Dbi_search_string.new('metadata.filename',search_for.filename,q['fns'],cse).string if st[:flag] search[:text] << st[:search] search[:endnotes] << st[:search] @@ -479,32 +487,99 @@ module SiSU_CGI_sql WOK_SQL end def tail + v=SiSU_Env::Info_version.new.get_version <<-WOK_SQL def tail <<-'WOK' <br /><hr /><br /> - <center><table align="center"bgcolor="#ffffff"><tr><td><font color="#666666"><table summary="" bgcolor="#ffffff" cellpadding="4" border="0" align="center"> - - <tr align="center"> - <td align="center"><p class="center"><font color="#666666" size="2"> - presentations' look and feel<br /> - generated by<br /> - <a href="http://www.jus.uio.no/sisu" ><img border="0" src="#@image_src/sisu.png" alt="SiSU in Ruby with the usual GPL (or OSS) suspects - Way Better!" width="120" height="38"></a><br /> - <a href="http://www.jus.uio.no/sisu" >SiSU</a><br /> - version 0.50<br />2007w11/1 (2007-03-12)<br /> - - <table summary="SiSU rights" bgcolor="#ffffff" cellpadding="4" border="0" align="center" width="40%"> - <sup>©</sup> Ralph Amissah<br /> - 1993, current 2007<br /> - GPL 3<br /> - <i>w3 since October 3 1993</i><br /> - <a href="mailto://ralph@amissah.com" >ralph@amissah.com</a><br /> - </font></p> - </td></tr></table> - - <p><center><font color="#666666" size="2">the usual GPL (or OSS) suspects:<br />Better - "performance, reliability, scalability, security<br />& total cost of ownership"<br /><i>[not to mention flexibility & choice]</i><br /><br /><<<a href="http://www.jus.uio.no/sisu/">Way Better!</a>>></font></center></p><tr align="center"><td align="center"> - - </font></center></td></tr></table></center> <a name="bottom" id="bottom"></a><a name="down" id="down"></a><a name="end" id="end"></a><a name="finish" id="finish"></a><a name="stop" id="stop"></a><a name="credits" id="credits"></a> +<table summary="SiSU summary" bgcolor="#ffffff" cellpadding="4" border="0"> +<tr><td> + <!-- widget way better --> +<tr><td valign="top" width="10%"> + <p class="tiny_left"><font color="#666666" size="2"> + + <a href="http://www.gnu.org/licenses/gpl.html"> + <img border="0" src="#@image_src/gplv3_free_software.png" alt="GPLv3" width="127" height="51" /> + </a> + </font></p> +</td><td valign="top" width="45%"> + <p class="tiny_left"><font color="#666666" size="2"> + <b>SiSU</b> <sup>©</sup> Ralph Amissah + 1993, current 2007 + All Rights Reserved. + <br /> + <b>SiSU is released under + <a href="http://www.gnu.org/licenses/gpl.html">GPL v3</a> + or later</b> + <a href="http://www.gnu.org/licenses/gpl.html"> + http://www.gnu.org/licenses/gpl.html + </a> + </font></p> +</td><td valign="top" width="45%"> + <p class="tiny_left"><font color="#666666" size="2"> + Developed using + <a href="http://www.ruby-lang.org/en/"> + Ruby + </a> + on + <a href="http://www.debian.org/"> + Debian/Gnu/Linux + </a> + software infrastructure, + & with the usual GPL (or OSS) suspects. + <br /> + Better - "performance, reliability, scalability, security & total cost of ownership" + [not to mention flexibility & choice] + <br /> + Get With the Future + <a href="http://www.jus.uio.no/sisu/"> + Way Better! + </a> + </font></p> +</td></tr> + <!-- widget sisu --> +<tr><td valign="top" width="10%"> + <p class="tiny_left"><font color="#666666" size="2"> + <a href="http://www.jus.uio.no/sisu" > + <img border="0" src="#@image_src/sisu.png" alt="SiSU" width="120" height="39" /> + </a> + </font></p> +</td><td valign="top" width="45%"> +<!-- SiSU Rights --> + <p class="tiny_left"><font color="#666666" size="2"> + Generated by + <a href="http://www.jus.uio.no/sisu" > + SiSU + </a> + #{v[:project]} #{v[:version]} #{v[:date]} (#{v[:date_stamp]}) + <br /> + <a href="http://www.jus.uio.no/sisu" > + www.jus.uio.no/sisu + </a> + and + <a href="http://www.sisudoc.org" > + www.sisudoc.org + </a> + <br /> + <br /> + <i>w3 since October 3 1993</i> + <a href="mailto://ralph@amissah.com" > + ralph@amissah.com + </a> + </font></p> +</td><td valign="top" width="45%"> + <p class="tiny_left"><font color="#666666" size="2"> + Using: + <br />Standard SiSU markup syntax, + <br />Standard SiSU meta-markup syntax, and the + <br />Standard SiSU <u>object citation numbering</u> and system, (object/text positioning system) + <br /> + <sup>©</sup> Ralph Amissah 1997, current 2007. + All Rights Reserved. + </font></p> +</td></tr> +</table> + <a name="bottom" id="bottom"></a><a name="down" id="down"></a><a name="end" id="end"></a><a name="finish" id="finish"></a><a name="stop" id="stop"></a><a name="credits" id="credits"></a> </body></html> WOK end @@ -526,13 +601,14 @@ module SiSU_CGI_sql @stub='sisu' 'SiSU_sisu' end - checked_url,checked_searched,checked_tip,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,selected_db='','','','','','','','' + checked_url,checked_searched,checked_tip,checked_case,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_case='checked' if cgi['casesense'] =~/\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 @@ -580,8 +656,13 @@ module SiSU_CGI_sql "#@base?#{s1}#{key}#{ti}#{au}#{sj}#{dsc}#{pb}#{cntr}#{dt}#{ty}#{id}#{src}#{lang}#{rel}#{cov}#{cr}#{co}#{ab}#{dtc}#{dti}#{dtm}#{dta}#{dtv}#{fns}&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}#{fns}&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 + if checked_case=~/\S/ + @search[:text][1]=%{documents.clean~'#{@search_for.text1}'} #s1 + @search[:endnotes][1]=%{endnotes.clean~'#{@search_for.text1}'} #s1 + else + @search[:text][1]=%{documents.clean~*'#{@search_for.text1}'} #s1 + @search[:endnotes][1]=%{endnotes.clean~*'#{@search_for.text1}'} #s1 + end canned_note='previous search url:' else @@canned_search_url="#@base?s1=United+Nations&db=documents&view=index" @@ -635,7 +716,7 @@ module SiSU_CGI_sql WOK #eg = %{canned search e.g.:<br /> <a href="#{url}">#{url}</a><br />find: #{analyze}<br />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 + @header=Form.new(@base,search_field,selected_db,checked_index,checked_text,checked_tip,checked_searched,checked_url,checked_case,checked_echo,checked_sql,checked_all,checked_none,checked_ignore,search_note,the_can).submission_form #% form unless q['s1'] =~/\S/ or q['au'] =~/\S/ or @search[:text][1] =~/\S/ print "Content-type: text/html\n\n" puts (@header+@tail) @@ -644,10 +725,15 @@ module SiSU_CGI_sql @search_for.text1 else 'Unavailable' end - @search[:text]<<%{documents.clean~'#{CGI.unescape(s1)}'} - @search[:endnotes]<<%{endnotes.clean~'#{CGI.unescape(s1)}'} + if checked_case=~/\S/ + @search[:text]<<%{documents.clean~'#{CGI.unescape(s1)}'} + @search[:endnotes]<<%{endnotes.clean~'#{CGI.unescape(s1)}'} + else + @search[:text]<<%{documents.clean~*'#{CGI.unescape(s1)}'} + @search[:endnotes]<<%{endnotes.clean~*'#{CGI.unescape(s1)}'} + end #dbi_request - dbi_statement=Dbi_search_statement.new(@conn,@search_for,q) + dbi_statement=Dbi_search_statement.new(@conn,@search_for,q,checked_case) @text_search_flag=false @text_search_flag=dbi_statement.text_search_flag s_contents=dbi_statement.contents @@ -710,7 +796,7 @@ module SiSU_CGI_sql end matched_para=if (@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) matched=if c['body'] =~/<a href="https?:\/\//mi; c['body'] - else (c['body'].gsub(/(#@search_regx)/,%{<span style="background-color: #@color_match">\\1</span>})) + else (c['body'].gsub(/(#@search_regx)/,%{<span style="background-color: #@color_match">\\1</span>})) end matched else c['body'] diff --git a/lib/sisu/v0/cgi_sqlite.rb b/lib/sisu/v0/cgi_sqlite.rb index 1113403a..4565ebe2 100644 --- a/lib/sisu/v0/cgi_sqlite.rb +++ b/lib/sisu/v0/cgi_sqlite.rb @@ -92,7 +92,7 @@ module SiSU_CGI_sqlite f3 << " 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 + output << header0 << header1 << header_desc << header2 << f1 << buttons1 << buttons2 << buttons3 << search_request << search_statement << search_statement_common << search_query1 << @common.pages << search_query2 << @common.tail << @common.main1 << f2 << f3 << dbi_connect << @common.main2 a=%{ generated sisu_sqlite.cgi, BASED ON ALREADY CREATED sisu_sqlite.db OUTPUT, (-d) } @@ -134,12 +134,11 @@ module SiSU_CGI_sqlite def search_statement <<-'WOK_SQL' class Dbi_search_string - def initialize(l,t,q) + def initialize(l,t,q,cse=false) @l,@t,@q=l,t,q end def string - search={ :search => [] } - search[:flag]=false + search={ :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) @@ -176,7 +175,7 @@ module SiSU_CGI_sqlite def sql_select_body limit ||=@@limit offset ||=@@offset - @sql_statement[: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} + @sql_statement[: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, metadata.filename, documents.ocn} @sql_statement[:range]=%{LIMIT #{limit} OFFSET #{offset} ;} select=@sql_statement[:body] + ' ' + @sql_statement[:range] select @@ -184,7 +183,7 @@ module SiSU_CGI_sqlite def sql_select_endnotes limit ||=@@limit offset ||=@@offset - @sql_statement[: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} + @sql_statement[: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, metadata.filename, endnotes.nr} @sql_statement[:range]=%{LIMIT #{limit} OFFSET #{offset} ;} select=@sql_statement[:endnotes] + ' ' + @sql_statement[:range] select diff --git a/lib/sisu/v0/docbook.rb b/lib/sisu/v0/docbook.rb deleted file mode 100644 index 6324cc28..00000000 --- a/lib/sisu/v0/docbook.rb +++ /dev/null @@ -1,567 +0,0 @@ -=begin - - * Name: SiSU - - * Description: a framework for document structuring, publishing and search - - * Author: Ralph Amissah - - * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007 Ralph Amissah All Rights Reserved. - - * License: GPL 3 or later: - - SiSU, a framework for document structuring, publishing and search - - Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2007 Ralph Amissah - - 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 3 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, see <http://www.gnu.org/licenses/>. - - 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/gpl.fsf> - - * SiSU uses: - * Standard SiSU markup syntax, - * Standard SiSU meta-markup syntax, and the - * Standard SiSU object citation numbering and system - - * Hompages: - <http://www.jus.uio.no/sisu> - <http://www.sisudoc.org> - - * Download: - <http://www.jus.uio.no/sisu/SiSU/download.html> - - * Ralph Amissah - <ralph@amissah.com> - <ralph.amissah@gmail.com> - - ** Description: docbook, ... not developed - -=end -module SiSU_Docbook - require "#{SiSU_lib}/defaults" - require "#{SiSU_lib}/param" - include SiSU_Param - include SiSU_Viz - require "#{SiSU_lib}/sysenv" - include SiSU_Env - require "#{SiSU_lib}/dal" - require "#{SiSU_lib}/shared_xml" - require "#{SiSU_lib}/xml_format" - include SiSU_XML_format - include SiSU_XML_munge - require "#{SiSU_lib}/rexml" - include SiSU_Rexml - @@alt_id_count,@@tablehead,@@number_of_cols=0,0,0 - @@tablefoot='' - class Source - def initialize(opt) - @opt=opt - end - def read - begin - @md=SiSU_Param::Parameters.new(@opt).get - @env=SiSU_Env::Info_env.new(@opt.fns) - path=@env.path.output_tell - loc=@env.url.output_tell - tool=if @opt.cmd =~/[MV]/; "#{@env.program.web_browser} #{loc}/#{@md.fnb}/#{@md.fn[:docbook]}\n\t#{@env.program.xml_viewer} #{path}/#{@md.fnb}/#{@md.fn[:docbook]}" - elsif @opt.cmd =~/v/; "#{@env.program.web_browser} #{loc}/#{@md.fnb}/#{@md.fn[:docbook]}" - else '' - end - tell=SiSU_Screen::Ansi.new(@opt.cmd,'invert','XML DOM',tool) - tell.colorize unless @opt.cmd =~/q/ - tell=SiSU_Screen::Ansi.new(@opt.cmd,@opt.fns,"#{@env.path.output_tell}/#{@md.fnb}/#{@md.fn[:docbook]}") - tell.flow if @opt.cmd =~/[MV]/ - @dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here - SiSU_Docbook::Source::Songsheet.new(@dal_array,@md,@env).songsheet - rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error - ensure #file closed in songsheet - end - end - private - class Songsheet - def initialize(data,md='',dir='') - @data,@md,@env=data,md,dir - end - def songsheet - begin - SiSU_Docbook::Source::Scroll.new(@data,@md).songsheet - SiSU_Docbook::Source::Tidy.new(@md,@env).xml if @md.cmd =~/[vVM]/i # test wellformedness, comment out when not in use - SiSU_Rexml::Rexml.new(@md,@md.fn[:docbook]).xml if @md.cmd =~/M/ # test rexml parsing, comment out when not in use #debug - rescue; SiSU_Errors::Info_error.new($!,$@,@md.cmd,@md.fns).error - ensure - end - end - end - class Scroll - Heading,Heading_close,Contents=[],[],[] - Heading[0]='part' - Heading[1]='part level="1"' - Heading[2]='part level="2"' - Heading[3]='part level="3"' - Heading_close[1]=Heading[0] - Heading_close[2]=Heading[0] - Heading_close[3]=Heading[0] - #Contents[0]='preface' - Contents[1]='chapter' - Contents[2]='sect1' - Contents[3]='sect2' - @@xml={ :body=>[],:open=>[],:close=>[],:head=>[],:sc=[] } - @@dp=nil - require "#{SiSU_lib}/shared_txt" - include SiSU_text_utils - def initialize(data='',md='') - @data,@md=data,md - @vz=SiSU_Env::Get_init.instance.skin - @dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern - @regx=/^(?:(?:<:p[bn]>\s*)?\d~(?:(\S+))?\s+)?(.+?)\s*<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - @tab="\t" - @trans=SiSU_XML_munge::Trans.new(@md) - @sys=SiSU_Env::System_call.new - end - def songsheet - pre - markup - post - publish - end - protected - def xml_markup(para='') - para.gsub!(/~\{(\d+)\s+(.+?)\s*<#@dp>\}~/, - '<footnote><para>\1 \2</para></footnote> ') - end - def xml_head(meta) - txt=meta.text - txt.gsub!(/<br(?: \/)?>/,'') - txt.gsub!(/ & /,' and ') - @@xml[:head] <<=if meta.type == 'meta' - <<WOK -#{@tab}<#{meta.el}> -#{@tab*2}#{txt} -#{@tab}</#{meta.el}> -WOK - else '' - end - end - def xml_sc(md='') - sc=if @md.sc_info - <<WOK - <source_control> - <sc class="sourcefile"> - #{@md.sc_filename} - </sc> - <sc class="number"> - #{@md.sc_number} - </sc> - <sc class="date"> - #{@md.sc_date} - </sc> - </source_control> -WOK - else '' - end - @@xml[:sc]=sc - end - def xml_element(lv='',ocn='',para='',hname='',tag='',xml_element='') - lv=lv.to_i - n=lv - 1 - n1=lv - n2=lv + 1 - n3=lv + 2 - v=lv - 3 - tag='' - tag="\n#{@tab*n3}<nametag>#{hname}</nametag>\n" if hname - @@xml[:body] <<<<WOK -#{@tab*n}#{xml_element} -#{@tab*n1}<title>#{para[@regx, 2]}</title> -WOK - if lv == 4 - @copen[1]=true - @copen[2]=@copen[3]=false - elsif lv == 5 - @copen[2]=true - @copen[3]=false - elsif lv == 6 - @copen[3]=true - end - end - def xml_structure(lv='',ocn='',para='',hname='' ) - lv=lv.to_i - n=lv - 1 - n1=lv - n2=lv + 1 - n3=lv + 2 - v=lv - 3 - tag='' - tag="\n#{@tab*n3}<nametag>#{hname}</nametag>\n" if hname !=nil - #if para[@regx] - # paragraph="#{para[@regx, 2]}" - # util=SiSU_text_utils::Paragraph.new(paragraph, 70) - # wrapped=util.line_wrap - #end - case lv - when 1..3 - xml_element="<#{Heading[lv]}>" - 3.downto(lv) do |x| - y=x - 1 - @cont[1]=false if @cont[1] - @cont[2]=false if @cont[2] - @cont[3]=false if @cont[3] - ####### attempt to close contents - if @copen[3] # 6~ - [3,2,1].each do |v| - @@xml[:body] << "#{@tab*n}</#{Contents[v]}>\n" - end - @copen[1]=@copen[2]=@copen[3]=false - elsif @copen[2] # 5~ - [2,1].each do |v| - @@xml[:body] << "#{@tab*n}</#{Contents[v]}>\n" - end - @copen[1]=@copen[2]=@copen[3]=false - elsif @copen[1] # 4~ - [1].each do |v| - @@xml[:body] << "#{@tab*n}</#{Contents[v]}>\n" - end - @copen[1]=@copen[2]=@copen[3]=false - end - @@xml[:body] << "#{@tab*y}</#{Heading_close[x]}>\n" if @level[x] - @level[x]=false - end - when 4..6 - 6.downto(lv) do |x| - y=x - 1 - if @level[x] == true - u=x - 3; - @xml_contents_close[x]='' - end - end - cv=lv - 3 - if para =~/^4~\S+/ - m=/^4~(\S+)/.match(para)[1] - id=if m =~/^\d+$/; 'ch' + m - else 'ch_' + m - end - elsif para =~/^5~\S+/ - m=/^5~(\S+)/.match(para)[1] - id= 'sec_' + m - elsif para =~/^6~\S+/ - m=/^6~(\S+)/.match(para)[1] - id= 'subsec_' + m - else '' - end - xml_element=%{<#{Contents[cv]} id="#{id}">} #hmmm gsub were it possible - case lv - when 4 - if @copen[3] == true # 6~ - [3,2,1].each do |v| - @@xml[:body] << "#{@tab*n}</#{Contents[v]}>\n" - end - elsif @copen[2] == true # 5~ - [2,1].each do |v| - @@xml[:body] << "#{@tab*n}</#{Contents[v]}>\n" - end - elsif @copen[1] == true # 4~ - [1].each do |v| - @@xml[:body] << "#{@tab*n}</#{Contents[v]}>\n" - end - end - @cont[1]=true - when 5 - if @copen[3] == true #6~ - [3,2].each do |v| - @@xml[:body] << "#{@tab*n}</#{Contents[v]}>\n" - end - elsif @copen[2] == true #5~ - [2].each do |v| - @@xml[:body] << "#{@tab*n}</#{Contents[v]}>\n" - end - end - @cont[2]=true - when 6 - [3].each do |v| - @@xml[:body] << "#{@tab*n}</#{Contents[v]}>\n" if @copen[3] #watch should possibly be outside... - end - @cont[3]=true - end - end - xml_element(lv,ocn,para,hname,tag,xml_element) - @level[lv]=true - ((lv+1)..6).each { |x| @level[x]=false } - end - def group_structure(para='',ocn='') - para.gsub!(/<:group(?:-end)?>/,'') - para.strip! - @@xml[:body] << %{#{@tab*7}<para class="group">#{@tab*1}\n} - @@xml[:body] << %{#{@tab*8}#{para}#{@tab*1}\n} - @@xml[:body] << %{#{@tab*7}</para>\n} - end - def poem_structure(para='',ocn='') - para.gsub!(/<:verse(?:-end)?>/,'') - para.strip! - @@xml[:body] << %{#{@tab*7}<para class="verse">#{@tab*1}\n} - @@xml[:body] << %{#{@tab*8}#{para}#{@tab*1}\n} - @@xml[:body] << %{#{@tab*7}</para>\n} - end - def code_structure(para='',ocn='') - para.gsub!(/<:code(?:-end)?>/,'') - para.strip! - @@xml[:body] << %{#{@tab*7}<para class="code">#{@tab*1}\n} - @@xml[:body] << %{#{@tab*8}#{para}#{@tab*1}\n} - @@xml[:body] << %{#{@tab*7}</para>\n} - end - #def table_structure(table='',ocn='') #tables - # @@xml[:body] << %{#{@tab*1}#{table}\n#{@tab*1}\n} # unless lv # main text, contents, body KEEP #{ocn} - # @endnotes=[] - #end - def tidywords(wordlist) - wordlist.each do |x| - x.gsub!(/&/,'&') unless x =~/&\S+;/ - end - end - def markup - data=@data - dir=SiSU_Env::Info_env.new(@md.fns) - xml_sc(@md) - @rcdc=false - @level,@cont,@copen,@xml_contents_close=[],[],[],[] - (0..6).each { |x| @cont[x]=@level[x]=false } - (4..6).each { |x| @xml_contents_close[x]='' } - data.each do |para| - wordlist=para.scan(/\S+|\n/) #\n needed for tables, check though added 2005w17 - para=tidywords(wordlist).join(' ').strip - para.gsub!(/<[-~]#>/,'') - para.gsub!(/<0;\w\d+;[um]\d+><#@dp:#@dp>/,'') - para.gsub!(/<:pb>\s*/,'') - para.gsub!(/\{(\S+?\.(?:png|jpg|gif)) .+?\}(?:(?:https?|ftp):\/\/\S+|image)/, - %{<imagedata fileref="#{dir.url.images_local}\/\\1"/>}) - #para.gsub!(/\{(\S+?\.png) \d+x\d+ \".+?\" \}(?:http:\/\/\S+|image)/,'<image>\1</image>') - para.gsub!(/ /,' ') - @trans.char_enc.utf8(para) if @sys.locale =~/utf-?8/i #% utf8 - if para =~/^0~(\S+)\s+(.+?)\Z/m # for headers - d_meta=SiSU_text_utils::Header_scan.new(@md,para).meta - if d_meta; xml_head(d_meta) - end - end - @rcdc=true if @rcdc ==false and (para =~/^\d~metadata/ or para =~/^1~\s+Document Information/) - if para !~/(^0~|<ENDNOTES>|<EOF>)/ - if para =~/.+?<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - paranum=para[@regx, 3] - @p_num=SiSU_XML_format::Paragraph_number.new(@md,paranum) - end - @sto=SiSU_text_parts::Split_text_object.new(@md,para).lev_segname_para_ocn - ### problem in scroll, it appears tables are getting paragraph numbers - unless @rcdc - m=/<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - if para =~m - format_scroll=SiSU_XML_format::Format_scroll.new(@md,@sto.text) if @sto.format =~/i[12]|null/ - case @sto.format - when /^(1)~(?:(\S+))?/ - xml_markup(para) - xml_structure($1,@sto.ocn,para,$2) - para=@sto.lev_para_ocn.heading_body1 - when /^(2)~(?:(\S+))?/ - xml_markup(para) - xml_structure($1,@sto.ocn,para,$2) - para=@sto.lev_para_ocn.heading_body2 - when /^(3)~(?:(\S+))?/ - xml_markup(para) - xml_structure($1,@sto.ocn,para,$2) - para=@sto.lev_para_ocn.heading_body3 - when /^(4)~(\S+)/ # work on see SiSU_text_parts::Split_text_object - xml_markup(para) - xml_structure($1,@sto.ocn,para,$2) - para=@sto.lev_para_ocn.heading_body4 - when /^(5)~(?:(\S+))?/ - xml_markup(para) - xml_structure($1,@sto.ocn,para,$2) - para=@sto.lev_para_ocn.heading_body5 - when /^(6)~(?:(\S+))?/ - xml_markup(para) - xml_structure($1,@sto.ocn,para,$2) - para=@sto.lev_para_ocn.heading_body6 - #when /^(i1)$/ - # #format_scroll.gsubBody - # #para=@sto.lev_para_ocn.scrIndent1 - #when /^(i2)$/ - # format_scroll.gsubBody - # para=@sto.lev_para_ocn.scrIndent2 - #when /^(center)$/ - # para.gsub!(/(.+)/, - # %{<center>(\\1)</center>}) - # para=@sto.lev_para_ocn.scrPara - #when /^(b|bold)$/ - # para.gsub!(/(.+)/, - # %{<b>(\\1)</b>}) - # para=@sto.lev_para_ocn.scrPara - #when /null/ # see whether u can improve - # if (para !~/#{@margin.txt_0}|#{@margin.txt_1}|#{@margin.txt_2}/) - # #format_scroll.gsubBody - # #para=@sto.lev_para_ocn.scrPara - # end - else - matched=/<~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/mi.match(para) - stamp,ocn=matched[0],matched[1] - if para =~ /<:verse>/ - para.gsub!(/#{stamp}/,'') - poem_structure(para,ocn) - elsif para =~ /<:group>/ - para.gsub!(/#{stamp}/,'') - group_structure(para,ocn) - elsif para =~ /<:code>/ - para.gsub!(/#{stamp}/,'') - code_structure(para,ocn) - elsif para =~/<!Th?.+/ # tables come as single block #work area 2005w13 - table=SiSU_Tables::Table_xml.new(para,ocn) - para=table.table_split - @@xml[:body] << para - #@@xml[:body] << table_structure(para,ocn) - else #xml_structure(para, nil, nil, nil) - xml_markup(para) - @@xml[:body] << "#{@tab*7}<para>#{para[@regx, 2]}</para>\n" if para[@regx, 2] # main text, contents, body KEEP ocn = #{para[@regx, 3]} == #{ocn} - end - end - elsif para =~/(Note|Endnotes?)/ and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - #format_scroll=MonoSiSU.new('<br /><a name="notes">Note</a>') - #para=format_scroll.boldPara - elsif para =~/(MetaData)/ and para =~/<~\d+;[m]\d+;\w\d+><#@dp:#@dp>$/ #debug 2003w46 add rc info - format_scroll=Format_scroll.new(@md,'<br /><a name="metadata">MetaData</a>') - para=format_scroll.bold_para - elsif para =~/(Owner Details)/ and para !~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/ - format_scroll=Format_scroll.new(@md,'<br /><a name="owner.details">Owner Details</a>') - @@xml[:owner_details]=format_scroll.bold_para - para='' - elsif para =~/(.*)<:#>(.*)/ - one, two=$1,$2 - format_text=Format_text_object.new(one,two) - para=format_text.seg_no_paranum - end - para='' if para =~/<a name="n\d+">/ and para =~/^(-\{{2}~\d+|<!e[:_]\d+!>)/ # -endnote - if para =~/.*<:#>.*$/ - para=case para - when /<:i1>/ - format_text=Format_text_object.new(para,'') - format_text.scr_inden_ocn_e_no_paranum - when /<:i2>/ - format_text=Format_text_object.new(para,'') - format_text.scr_inden_ocn_e_no_paranum - end - end - if para =~/<:center>/ - one, two=/(.*)<:center>(.*)/.match(para)[1,2] - format_text=Format_text_object.new(one, two) - para=format_text.center - end - else - end - para.gsub!(/<:\S+?>/,'') - para.gsub!(/<!.+!>/,' ') - end - end - @content_flag=true - 6.downto(4) do |x| - y=x - 1; v=x - 3 - if @level[x] == true #2004w36 bug fix? watch/test previous logic broke on free.for.all @coontent_flag introduced - if @content_flag==true - @@xml[:body] << "\n#{@tab*y}</#{Contents[v]}>\n" - @content_flag=false - else - @@xml[:body] << "\n#{@tab*y}</#{Contents[v]}>\n" - end - end - end - 3.downto(1) do |x| - y=x - 1 - @@xml[:body] << "#{@tab*y}</#{Heading_close[x]}>\n" if @level[x] == true - end - end - def pre - rdf=SiSU_XML_tags::RDF.new(@md) - dir=SiSU_Env::Info_env.new - css=SiSU_Env::CSS_select.new(@md).docbook_xml - encoding='<?xml version="1.0"?> -<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook V5.0//EN" - "http://www.oasis-open.org/docbook/xml/5.0/docbook.dtd">' - #encoding='<?xml version="1.0" encoding="utf-8"?>' - @@xml[:open] =<<WOK -#{encoding} -<?xml-stylesheet type="text/css" href="../#{dir.path.style}/#{css}"?> -#{rdf.comment_xml} -<book> -WOK - @@xml[:head] << "<bookinfo>\n" - end - def post - @@xml[:head] << @@xml[:sc] - @@xml[:head] << "</bookinfo>\n" - @@xml[:close] = "</book>\n" - end - def publish - content=[] - data=@data - content << @@xml[:open] << @@xml[:head] << @@xml[:body] << @@xml[:metadata] - content << @@xml[:owner_details] if @md.stmp =~/\w\w/ - content << @@xml[:tail] << @@xml[:close] - Output.new(content.to_s,@md).xml - @@xml[:head],@@xml[:body],@@xml[:tail]=[],[],[] - end - end - class Output - include SiSU_Param - def initialize(data,md) - @data,@md=data,md - end - def xml - @sisu=[] - @data.each do |para| - para.gsub!(/<:\S+?>/,'') - para.gsub!(/<!.+?!>/,'') - para="#{para}\n" unless para.empty? - @sisu << para - end - new_file_data=@sisu.to_s - @sisu=new_file_data.scan(/.+/) - SiSU_Env::SiSU_file.new(@md).mkdir - filename_xml=SiSU_Env::SiSU_file.new(@md,@md.fn[:docbook]).mkfile - @sisu.each {|para| filename_xml.puts para} - filename_xml.close - end - end - class Tidy - def initialize(md,dir) - @md,@env=md,dir - @prog=SiSU_Env::Info_program.new - end - def xml - if @prog.tidy !=false - if @md.cmd =~/[VM]/ - tell=SiSU_Screen::Ansi.new(@md.cmd,'invert','Using XML Tidy','check document structure') - tell.colorize unless @md.cmd =~/q/ - tell.grey_open unless @md.cmd =~/q/ - tidyfile='/dev/null' #don't want one or screen output, check for alternative flags - tidy=SiSU_Env::System_call.new("#{@env.path.output}/#{@md.fnb}/#{@md.fn[:docbook]}",tidyfile) - tidy.well_formed? - tell.p_off unless @md.cmd =~/q/ - end - end - end - end - end -end -__END__ - diff --git a/lib/sisu/v0/help.rb b/lib/sisu/v0/help.rb index 23cccc04..9c10c27e 100644 --- a/lib/sisu/v0/help.rb +++ b/lib/sisu/v0/help.rb @@ -988,15 +988,22 @@ WOK help_env end def program_found?(program) - rc=if SiSU_Env::Info_settings.new.program?(program) - "rc: #{SiSU_Env::Info_settings.new.program?(program)} " - else '' + if program + rc=if SiSU_Env::Info_settings.new.program?(program) + SiSU_Env::Info_settings.new.program?(program) + else '' + end + if program =='rmagick'; program='identify' #rmagick is ruby lib uses imagemagick's identify + end + bin=if SiSU_Env::System_call.new.program_found?(program) + SiSU_Env::System_call.new.program_found?(program) + else 'false' + end + else bin,rc='false','false' end - bin=if SiSU_Env::System_call.new.program_found?(program) - "bin: #{SiSU_Env::System_call.new.program_found?(program)}" - else '' + if program; "#{@cX.blue}#{program}#{@cX.off} bin: #{@cX.brown}#{bin}#{@cX.off} rc: #{@cX.brown}#{rc}#{@cX.off}" + else "bin: #{@cX.brown}#{bin}#{@cX.off} rc: #{@cX.brown}#{rc}#{@cX.off}" end - "#{@cX.brown}#{rc}#{bin}#{@cX.off}" end def environment cf_defaults=SiSU_Env::Info_processing_flag.new @@ -1010,7 +1017,6 @@ WOK current directory: #{@cX.blue}#{@env.path.pwd}#{@cX.off} document output root directory set to: #{@cX.blue}#{@env.path.webserv}#{@cX.off} documents from current directory placed in: #{@cX.blue}#{@env.path.output}#{@cX.off} - sisurc.yml used: #{@cX.blue}#{@env.path.yamlrc}#{@cX.off} webrick url: #{@cX.blue}#{@env.url.webserv_base_cgi}#{@cX.off} (to start webrick server 'sisu -W') sqlite db for present directory: #{@cX.blue}sqlite #{@env.path.output}/sisu_sqlite.db#{@cX.off} @@ -1022,7 +1028,7 @@ WOK [generated postgresql cgi search form]: #{@cX.blue}#{@env.url.webserv_base_cgi}/cgi-bin/sisu_pgsql.cgi#{@cX.off} (to generate 'sisu -F' or 'sisu -F webrick') #{@cX.green}configuration files#{@cX.off} - sisurc.yml used: #{@cX.blue}#{@env.path.yamlrc}#{@cX.off} + sisurc.yml used: #{@cX.blue}#{@env.path.yamlrc}#{@cX.off} configuration information search path: #{@cX.blue}#{@env.path.rc.join(', ')}#{@cX.off} (directory also relevant for skins and images) digest (md5 or sha256): #{@cX.blue}#{@env.digest.type}#{@cX.off} @@ -1040,13 +1046,13 @@ WOK odf viewer: #{@cX.blue}#{@env.program.odf_viewer}#{@cX.off} (default selections can be changed in sisurc.yml under program_select:) #{@cX.green}programs used if available#{@cX.off} - word count: #{@cX.blue}#{@env.program.wc}#{@cX.off} #{program_found?(@env.program.wc)} - imagemagick/rmagick: #{program_found?('rmagick')} - tidy: #{@cX.blue}#{@env.program.tidy}#{@cX.off} #{program_found?(@env.program.tidy)} - rexml: #{@cX.blue}#{@env.program.rexml}#{@cX.off} #{program_found?(@env.program.rexml)} - latex to pdf: #{@cX.blue}#{@env.program.pdflatex}#{@cX.off} #{program_found?(@env.program.pdflatex)} - postgresql: #{@cX.blue}#{@env.program.postgresql}#{@cX.off} #{program_found?(@env.program.postgresql)} - sqlite: #{@cX.blue}#{@env.program.sqlite}#{@cX.off} #{program_found?(@env.program.sqlite)} + word count: #{program_found?(@env.program.wc)} + imagemagick/rmagick: #{program_found?(@env.program.rmagick)} + tidy: #{program_found?(@env.program.tidy)} + rexml: #{program_found?(@env.program.rexml)} + latex to pdf: #{program_found?(@env.program.pdflatex)} + postgresql: #{program_found?(@env.program.postgresql)} + sqlite: #{program_found?(@env.program.sqlite)} (these can be turned off if unavailable in sisurc.yaml under program_set:) #{@cX.green}processing shortcut defaults set to:#{@cX.off} color defaut set (on==true) #{@cX.blue}#{cf_defaults.color}#{@cX.off} @@ -1349,9 +1355,25 @@ WOK print <<WOK #{@cX.green}Install SiSU#{@cX.off} - SiSU does require setup, the file sisu is placed in the equivalent of #{@cX.blue}/usr/bin#{@cX.off} or #{@cX.blue}/usr/local/bin#{@cX.off} and the REWRITE files where ruby libraries are kept, on my debian system #{@cX.blue}/usr/local/lib/site_ruby/1.8#{@cX.off} + Presumably if you are reading this interactively you have a copy of SiSU already installed, nevertheless here are a few notes. - For information on download and installation, see #{@cX.blue}http://www.jus.uio.no/sisu/sisu_download/download#{@cX.off} or #{@cX.blue}http://www.jus.uio.no/sisu/SiSU/download#{@cX.off} + SiSU does require setup, the executable file #{@cX.blue}sisu#{@cX.off} is placed in #{@cX.blue}#{Config::CONFIG['bindir']}#{@cX.off} or #{@cX.blue}#{Config::CONFIG['sitelibdir']}#{@cX.off} and the library files, in #{@cX.blue}#{Config::CONFIG['rubylibdir']}/#{SiSU_lib}#{@cX.off} + or in #{@cX.blue}#{Config::CONFIG['sitelibdir']}/#{SiSU_lib}#{@cX.off} + + SiSU comes with a number of installers, including #{@cX.blue}setup.rb#{@cX.off}, #{@cX.blue}install#{@cX.off} and a #{@cX.blue}Rantfile#{@cX.off} if rant is installed on your system, you may need to be root to install sisu on your system. After unpacking the tarball, in the top directory of the tarball which contains the named files type, one of: + sudo ./sisu-install base + sudo ./sisu-install setup + if that does not work try + sudo ruby ./sisu-install setup + if rant is installed on your system you may instead run: + sudo rant base + + for further options: + ./sisu-install -T + + SiSU is pre-packaged for some GNU/Linux distributions such as Debian. + + For information on download and installation, see #{@cX.blue}http://www.jus.uio.no/sisu/SiSU/download#{@cX.off} For post installation help it is best you refer to '#{@cX.blue}man 8 sisu#{@cX.off}' @@ -1360,18 +1382,17 @@ WOK arch: #{@cX.blue}#{@env.arch}#{@cX.off} Directories for installation - bin: #{@cX.blue}[FIX]#{@cX.off} - lib (site-ruby): #{@cX.blue}#{Config::CONFIG['sitelibdir']}/#{SiSU_lib}#{@cX.off} - conf [etc]: #{@cX.blue}#{@env.path.etc}/sisu{@cX.off} - data (document samples, images, README): #{@cX.blue}#{@env.path.sample_data}/sisu#{@cX.off} and #{@cX.blue}#{@env.path.sample_data}/doc/sisu#{@cX.off} - man (manual pages): #{@cX.blue}#{@env.path.man}#{@cX.off} - processing: #{@cX.blue}#{@env.path.processing}#{@cX.off} - output www: #{@cX.blue}#{@env.path.output}#{@cX.off} + bin: #{@cX.blue}#{Config::CONFIG['bindir']}#{@cX.off} or #{@cX.blue}#{Config::CONFIG['sitelibdir']}#{@cX.off} + lib (site-ruby): #{@cX.blue}#{Config::CONFIG['rubylibdir']}/#{SiSU_lib}#{@cX.off} or #{@cX.blue}#{Config::CONFIG['sitelibdir']}/#{SiSU_lib}#{@cX.off} + conf [etc]: #{@cX.blue}#{@env.path.etc}/sisu#{@cX.off} + data (document samples, images, README): #{@cX.blue}#{@env.path.sample_data}#{@cX.off} + processing: #{@cX.blue}#{@env.path.processing}#{@cX.off} + output www: #{@cX.blue}#{@env.path.output}#{@cX.off} Output files, are currently set to be produced in: - processed document output: #{@cX.blue}#{@env.path.output}#{@cX.off} - a document in the current directory #{@cX.blue}#{Dir.pwd}#{@cX.off} - will have its output placed in: #{@cX.blue}#{@env.path.output}/#@output_stub#{@cX.off} + processed document output: #{@cX.blue}#{@env.path.output}#{@cX.off} + a document in the current directory #{@cX.blue}#{Dir.pwd}#{@cX.off} + will have its output placed in: #{@cX.blue}#{@env.path.output}/#@output_stub#{@cX.off} Install any additional programs of interest (that SiSU makes use of, that are not already on your system) @@ -1393,10 +1414,25 @@ WOK def setup print <<WOK - [provide some setup information] + #{@cX.green}configuration files#{@cX.off} + sisurc.yml used: + #{@cX.blue}#{@env.path.yamlrc}#{@cX.off} + configuration information search path: + #{@cX.blue}#{@env.path.rc.join(', ')}#{@cX.off} + (directory also relevant for skins and images) + + to initialise the mapped output directory, from within the markup document directory type: + #{@cX.blue}sisu -CC#{@cX.off} - also see http://www.jus.uio.no/sisu/SiSU + for information on your current sisu configuration settings, type: + #{@cX.blue}sisu --help env#{@cX.off} + or + #{@cX.blue}sisu -V#{@cX.off} + see also + #{@cX.blue}man 8 sisu#{@cX.off} + and + #{@cX.blue}http://www.jus.uio.no/sisu/SiSU#{@cX.off} WOK end def termsheet @@ -1587,7 +1623,7 @@ WOK def texinfo print <<WOK - sisu -i [filename] produces texinfo and info files + sisu -I [filename] produces texinfo and info files info and texinfo files are currently left in a separate work/output directory... have not decided what to do with them diff --git a/lib/sisu/v0/hub.rb b/lib/sisu/v0/hub.rb index e4ae72a2..35160d23 100644 --- a/lib/sisu/v0/hub.rb +++ b/lib/sisu/v0/hub.rb @@ -51,7 +51,8 @@ <ralph@amissah.com> <ralph.amissah@gmail.com> - ** Description: SiSU information Structuring Universe, processing + ** Description: SiSU information Structuring Universe, text structuring, + processing, publishing, search =end module SiSU @@ -145,12 +146,13 @@ module SiSU when /^sisupod_make$/; SiSU_Doc::Source.new(@opt).read # -S when /^source_kdissert$/; SiSU_Kdi_source::Source.new(@opt).read ## -S when /^digests$/; SiSU_Digest_view::Source.new(@opt).read # -N + when /^xml_scaffold$/; SiSU_XML_scaffold::Source.new(@opt).read # -T when /^plaintext$/; SiSU_Plaintext::Source.new(@opt).read # -a -A -e -E -f when /^wikispeak$/; SiSU_Wikispeak::Source.new(@opt).read # -g when /^odf$/; SiSU_ODF::Source.new(@opt).read # -o when /^texpdf$/; SiSU_TeX::Source.new(@opt).read # -p when /^texinfo$/; SiSU_TexInfo::Source.new(@opt).read # -I - when /^docbook$/; SiSU_Docbook::Source.new(@opt).read # -B + #when /^docbook$/; SiSU_Docbook::Source.new(@opt).read # -B when /^html$/; SiSU_HTML::Source.new(@opt).read # -h -H when /^xml$/; SiSU_XML_SAX::Source.new(@opt).read # -x when /^xml_dom$/; SiSU_XML_DOM::Source.new(@opt).read # -X @@ -290,7 +292,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ flag=SiSU_Env::Info_processing_flag.new extra='' if @opt.cmd !~/[mn]/ - extra+=if @opt.cmd =~/[abBeghHhINoptwXxz]/ and @opt.cmd !~/[mn]/; 'm' #% add dal + extra+=if @opt.cmd =~/[abeghHhINoptTwXxz]/ and @opt.cmd !~/[mn]/; 'm' #% add dal elsif ((@opt.cmd =~/[Dd]/ or (@opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/)) \ and @opt.mod.inspect !~/(?:remove|(?:(?:re)?create(?:all)?|dropall|drop)$)/) \ and @opt.cmd !~/[mn]/ @@ -466,8 +468,8 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ end if @opt.cmd =~/b/; op('xhtml','xhtml sax') #% -b xhtml sax type end - if @opt.cmd =~/B/; op('docbook','docbook xml') #% -B docbook xml - end + #if @opt.cmd =~/B/; op('docbook','docbook xml') #% -B docbook xml + #end if @opt.cmd =~/w/; op('concordance','Concordance') #% -w concordance end if @opt.cmd =~/t/ #% -t termsheet/standard form @@ -484,6 +486,8 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ end Operations.new.counter end + if @opt.cmd =~/T/; op('xml_scaffold','XML scaffold') #% -T temporary tests + end if @opt.cmd =~/p/; op('texpdf','LaTeX pdf') #% -p latex/ texpdf end if @opt.cmd =~/I/; op('texinfo','TeX Info') #% -I texinfo (i taken by db import) diff --git a/lib/sisu/v0/sysenv.rb b/lib/sisu/v0/sysenv.rb index f1aa19fc..c2d694f2 100644 --- a/lib/sisu/v0/sysenv.rb +++ b/lib/sisu/v0/sysenv.rb @@ -92,7 +92,7 @@ module SiSU_Env out=Config::CONFIG['localstatedir'] etc=Config::CONFIG['sysconfdir'] + '/sisu' share=Config::CONFIG['datadir'] + '/sisu' - data=Config::CONFIG['datadir'] + '/sisu-examples/sample' + data=Config::CONFIG['datadir'] + '/doc/sisu' m=/.+\/(\S+)/m @stub_pwd ||=@@pwd[m,1] prcss_dir='_sisu_processing' @@ -506,7 +506,7 @@ module SiSU_Env def rcs #rcs for document markup data program='rcs' program_ref="\n\t\tdocument version information requested" - if program_found?(rcs); true + if program_found?(program); true else puts "\tWARN: #{program} is not installed #{program_ref}" #if @cmd =~/v/ false end @@ -514,7 +514,7 @@ module SiSU_Env def cvs #cvs for document markup data program='cvs' program_ref="\n\t\tdocument version information requested" - if program_found?(cvs); true + if program_found?(program); true else puts "\tWARN: #{program} is not installed #{program_ref}" #if @cmd =~/v/ false end @@ -574,6 +574,14 @@ module SiSU_Env else puts "\tWARN: #{program} is not installed #{program_ref}" if cmd =~/V/ end end + def rmagick #rmagick is a ruby library + program='identify' + program_ref="\n\t\tsee http://www.imagemagick.org/" + if program_found?(program); true + else puts "\tWARN: #{program} is not installed #{program_ref}" #if @cmd =~/v/ + false + end + end def well_formed? #tidy - check for well formed xml xhtml etc. program=@prog.tidy program_ref="\n\t\tsee http://tidy.sourceforge.net/" @@ -610,7 +618,7 @@ module SiSU_Env def makeinfo #texinfo program='makeinfo' program_ref="\n\t\tsee http://www.gnu.org/software/texinfo/" - if program_found?(program); system("makeinfo #@input\n") + if program_found?(program); system("#{program} #@input\n") else puts "\tWARN: #{program} is not installed #{program_ref}" end end @@ -1556,6 +1564,13 @@ module SiSU_Env end is end + def rmagick + if defined? @rc['program_set']['rmagick']; is=@rc['program_set']['rmagick'] + end + if is.nil? or is==true; is='rmagick' + end + is + end def rexml #should be part of ruby 1.8 but apparently not always is=if FileTest.directory?("#{Config::CONFIG['rubylibdir']}/rexml") #Config::CONFIG['sitedir'] true diff --git a/lib/sisu/v0/texinfo.rb b/lib/sisu/v0/texinfo.rb index 29f31421..88f91d7d 100644 --- a/lib/sisu/v0/texinfo.rb +++ b/lib/sisu/v0/texinfo.rb @@ -87,7 +87,7 @@ module SiSU_TexInfo when /\.[_-]?sst$/ Dir.mkdir(@env.path.output) unless FileTest.directory?("#{@env.path.output}") Dir.mkdir(@env.path.texi) unless FileTest.directory?(@env.path.tex) - @@filename_texinfo=File.new(%{#{@env.path.texi}/#@opt.fnb.texinfo},'w+') + @@filename_texinfo=File.new(%{#{@env.path.texi}/#{@opt.fnb}.texinfo},'w+') end rescue; STDERR.puts SiSU_Screen::Ansi.new(@opt.cmd,$!,$@).rescue ensure @@ -158,13 +158,13 @@ module SiSU_TexInfo @tex_file=[] data=@data data.each do |para| - para.gsub!(/&/,'<=and>') # DEBUG 2003w16 this is a kludge, because i could not get parameters # from param, Sort out ... revert to more elegant solution if para =~ /<!Th?¡\s+c/ @@flag['tables']='y' # KLUDGE get from param end para.gsub!(/<:p[bn]>/,'') + para.gsub!(/(^|\s)\{(.+?)\}(http:\/\/\S+)/,'\1(\2 [linked to:] \3)') do_mono=TexInfoFormat::Texinfo.new(para,@md) @tex_file << do_mono.spec_char end @@ -176,8 +176,10 @@ module SiSU_TexInfo @tex_file=[] data.each do |para| # BUG bug -> have problems with endnotes in headers - if para =~ /\\~\\\{\d+\s+/ #if para =~ /<!e\s+/ # watch - para.gsub!(/\s*\\~\\\{(\d+)\s+(.+?)<#@dp>\\\}\\~/m,' @footnote{ \2} ') + if para =~ /\\~@\{\d+\s+/ #if para =~ /<!e\s+/ # watch + para.gsub!(/\s*\\~@\{(?:\d+)\s+(.+?)<#@dp>@\}\\~/m,' @footnote{ \1} ') + elsif para =~ /\\~@\{\*+\s+/ #if para =~ /<!e\s+/ # watch + para.gsub!(/\s*\\~@\{(\*+)\s+(?:.+?)<#@dp>@\}\\~/m,' @footnote{ \1} ') end @tex_file << para end @@ -226,7 +228,7 @@ module SiSU_TexInfo if @@flag['code']==1 line.gsub!(/^\s*(.+)/m, "\\noindent \\marginpar\[left-text\]{\\begin{tiny}#{@@counting}\\end{tiny}}\\1\\") @@counting+=1 if @@flag['code']==1 - else line.gsub!(/(.+)/m,'\noindent\1\') + else line.gsub!(/(.+)/m,'\noindent\1') end end end @@ -258,7 +260,7 @@ module SiSU_TexInfo toc=TexInfoFormat::Texinfo.new($1,@md) texinfo_menu << toc.menu end - if para =~ /^[4-6]\\+~\S+\s*(.+?)\s*$/ + if para =~ /^[4-6]\\+~(?:\S+)?\s+(.+?)\s*$/ toc=TexInfoFormat::Texinfo.new($1,@md) texinfo_menu << toc.menu case para @@ -270,6 +272,8 @@ module SiSU_TexInfo @subsubmenu[n_menu]=[] @submenu[n_menu] << toc.menu when /^[6]\\+~\S+\s+(.+?)\s*$/ + n_submenu+=1 + @subsubmenu[n_submenu]=[] @subsubmenu[n_submenu] << toc.menu end end @@ -279,7 +283,7 @@ module SiSU_TexInfo @tex_file << texinfo_menu @tex_file << "* Index::\n" + "@end menu\n\n" + - "@c {{{ 5\n\n" + "@c %% 5\n\n" n_menu,n_submenu=0,0 @@do_submenu,@@do_subsubmenu=1,1 data.each do |para| @@ -325,14 +329,13 @@ module SiSU_TexInfo if para !~/\S/ para=nil else - para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>/,'~[\1]') - #para.gsub!(/[1-3]\\\\\{\\\\\{\\\\\{\s+/, '') - #para.gsub!(/[1-3]\\\\\{\s+/, '') + para.gsub!(/<\\~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/,'<\1>') + #para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>/,'<\1>') + #para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>/,'<\1>') para=para end - #para.gsub!(/^\s+$/mi, "") end -#%case with endnotes + #%case with endnotes para.gsub!(/\s*[0-8]\\+(\S+)?\s+/,' ') if para @tex_file << para if para end @@ -397,7 +400,7 @@ module SiSU_TexInfo end def makeinfo if @md.fns =~/\.[_-]?sst$/ - m=/(.+?)\.[_-]?sst$/.match(@md.fns) + m=/(.+?)\.([_-]?sst)$/.match(@md.fns) fnb,sfx=m[1],m[2] pwd=Dir.pwd case sfx diff --git a/lib/sisu/v0/texinfo_format.rb b/lib/sisu/v0/texinfo_format.rb index bb60895d..3184ee80 100644 --- a/lib/sisu/v0/texinfo_format.rb +++ b/lib/sisu/v0/texinfo_format.rb @@ -90,6 +90,8 @@ module TexInfoFormat author=@md.dc_creator if @md.dc_creator author ||='' author.gsub!(/[\*]/,'') #if author + v=SiSU_Env::Info_version.new.get_version + #(version @value{VERSION} #{v[:version]}, @value{UPDATED} #{v[:date]}) head =<<WOK \\input texinfo @c -*-texinfo-*- @comment $Id$ @@ -98,10 +100,9 @@ module TexInfoFormat @settitle #{title} @value{VERSION} @syncodeindex pg cp @comment %**end of header -@c {{{ 2 +@c %% 2 @copying -SiSU in texinfo version of #{title} -(version @value{VERSION}, @value{UPDATED}) +SiSU texinfo of #{title} Copyright @copyright{} #{year} #{author}. @@ -117,7 +118,7 @@ Copyright #{author}, generated by ``SiSU'' WOK if @md.subtitle titlepage=<<WOK -@c {{{ 3 +@c %% 3 @titlepage @title #{title} #{subtitle} @author #{author} @@ -129,7 +130,7 @@ WOK WOK else titlepage=<<WOK -@c {{{ 3 +@c %% 3 @titlepage @title #{title} @value{VERSION}, @value{UPDATED} @@ -149,7 +150,7 @@ WOK @one=@one.gsub(/<(br|p|i)>|<\/\s*(br|p|i)>|<(br|p)\s*\/>/," #{@@tex_backslash*2} ") @one.gsub!(/\$/,"\\$") @one.gsub!(/[,]\s*/,' - ') - "@c {{{ 4\n" + + "@c %% 4\n" + "@ifnottex\n" + "@node Top\n" + "@top #@one\n\n" + @@ -201,7 +202,7 @@ WOK dc_coverage="Coverage: #{dc_coverage}\n\n" if dc_coverage dc_rights="Rights: #{dc_rights}\n\n" if dc_rights "@node Dublin Core\n" + - "@chapter Dublin Core\n" + + "@unnumbered Dublin Core\n" + "@cindex chapter, Dublin Core\n\n" + "#{dc_title}" + "#{dc_creator}" + @@ -225,91 +226,80 @@ WOK "\n\n" end def tail - "@c {{{ 6\n" + + "@c %% 6\n" + "@node Index\n" + "@unnumbered Index\n" + "@printindex cp\n\n" + "@bye" end + def clean(para) + para.gsub!(/<\\~(\d+);(?:\w|[0-6]:)\d+;\w\d+><#@dp:#@dp>$/,'<\1>') + para.gsub!(/\s*[,:]\s*/,' - ') + para.gsub!(/<:#>/,'') + para.strip! + para + end def menu - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,:]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - "* #@para::" + para=clean(@para) + para=para.gsub(/@footnote\{.+?\}\s+/,'') + "* #{para}::" end def level1 @para.gsub!(/[1]\\+~/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,:]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@node #@para\n@chapter #@para\n@cindex chapter, #@para\n" + para=clean(@para) + nd=para.gsub(/@footnote\{.+?\}\s+/,'') + para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" @para.gsub!(/.+/,"#{para}") end def level2 @para.gsub!(/[2]\\+~/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,:]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@node #@para\n@chapter #@para\n@cindex chapter, #@para\n" + para=clean(@para) + nd=para.gsub(/@footnote\{.+?\}\s+/,'') + para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" @para.gsub!(/.+/,"#{para}") end def level3 @para.gsub!(/[3]\\+\~/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,:]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@node #@para\n@chapter #@para\n@cindex chapter, #@para\n" + para=clean(@para) + nd=para.gsub(/@footnote\{.+?\}\s+/,'') + #para=para.gsub(/(.+?)\s*(@footnote\{.+?\})\s*(.+)$/,"\\1 \\3\n\\2") + #para=para.gsub(/(.+?)\s*(@footnote\{.+?\})\s*(.+)$/,'\1 \3 \2') + para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" @para.gsub!(/.+/,"#{para}") end def level4 @para.gsub!(/[4]\\+~\S+/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,:]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@node #@para\n@chapter #@para\n@cindex chapter, #@para\n" + para=clean(@para) + nd=para.gsub(/@footnote\{.+?\}\s+/,'') + para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" @para.gsub!(/.+/,"#{para}") end def level5 @para.gsub!(/[5]\\+~\S+/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,:]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@node #@para\n@chapter #@para\n@cindex chapter, #@para\n" + para=clean(@para) + nd=para.gsub(/@footnote\{.+?\}\s+/,'') + para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" @para.gsub!(/.+/,"#{para}") end def level6 @para.gsub!(/[6]\\+~\S+/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,:]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@node #@para\n@chapter #@para\n@cindex chapter, #@para\n" + para=clean(@para) + nd=para.gsub(/@footnote\{.+?\}\s+/,'') + para="@node #{nd}\n@unnumbered #{para}\n@cindex chapter, #{nd}\n" @para.gsub!(/.+/,"#{para}") end def submenu @para=@para.join("\n") @para.gsub!(/[5]\\+~\S+/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@menu\n#@para\n@end menu\n\n" + para=clean(@para) + para="@menu\n#{para}\n@end menu\n\n" @para.gsub!(/.+/m,"#{para}") end def subsubmenu @para=@para.join("\n") @para.gsub!(/[6]\\+~\S+/,'') - @para.gsub!(/<\\~(\d+);\w\d+;\w\d+><#@dp:#@dp>$/,'~[\1]') - @para.gsub!(/\s*[,]\s*/,' - ') - @para.gsub!(/<:#>/,'') - @para.strip! - para="@menu\n#@para\n@menu\n\n" + para=clean(@para) + para="@menu\n#{para}\n@end menu\n\n" @para.gsub!(/.+/m,"#{para}") end def indent1 @@ -320,12 +310,15 @@ WOK end def spec_char # special characters @para.gsub!(/<EOF>/i,'') - @para.gsub!(/@/i,'@@') - @para.gsub!(/&(lt|#060);/,'\< ') - @para.gsub!(/&(gt|#062);/,' \>') - @para.gsub!(/{/,'\{ ') - @para.gsub!(/}/,'\} ') - @para.gsub!(/&#(126|152);/i,'~ ') + @para.gsub!(/©/,'(c)') + @para.gsub!(/&(lt|#060);/,'<'); @para.gsub!(/&(gt|#062);/,'>') + @para.gsub!(/{/,'{'); @para.gsub!(/}/,'}') + @para.gsub!(/&#(126|152);/i,'~') + @para.gsub!(/!/,'!') + @para.gsub!(/#/,'#') + @para.gsub!(/*/,'*') + @para.gsub!(///,'/') + @para.gsub!(/_/,'_') @para.gsub!(/<sup><font face=symbol>&atild;<\/font><\/sup>/,' ') @para.gsub!(/\\/,'\\backslash ') @para.gsub!(/<:pb>/,'\\newpage') @@ -337,13 +330,6 @@ WOK if @para !~ /^\s*<:image|\}:image\s/ @para.gsub!(/_/,'\_') end - @para.gsub!(/\{/,"\\{") - @para.gsub!(/\}/,"\\}") - @para.gsub!(/ /,' ') # ~ character for hardspace - @para.gsub!(/ /,' ') # ~ character for hardspace - @para.gsub!(/&(\S+?);/,'') - @para.gsub!(/(\s+&\s+)/,' and ') - @para.gsub!(/(\&)/,"\\&") @para.gsub!(/§/i,'\S') @para.gsub!(/£/i,'\pounds') @para.gsub!(/å/i,'\aa') @@ -352,7 +338,6 @@ WOK @para.gsub!(/Å/i,'\AA') @para.gsub!(/Æ/i,'\AE') @para.gsub!(/Ø/i,'\O') - @para.gsub!(/&(.+?);/i,' ') @para.gsub!(/<a href=".+?">/i,' ') @para.gsub!(/<\/a>/i,' ') @para.gsub!(/<:ee>/i,'') @@ -360,6 +345,15 @@ WOK @para.gsub!(/<b>(.+?)<\/b>/,'\*\1\*') @para.gsub!(/<i>(.+?)<\/i>/,'\/\1\/') @para.gsub!(/<u>(.+?)<\/u>/,'\_\1\_') + @para.gsub!(/@/i,'@@') + @para.gsub!(/\{/,'@{'); @para.gsub!(/\}/,'@}') + #@para.gsub!(/(^|[\s*!\/#_-])\{/,'\1@{'); @para.gsub!(/\}([\s*!\/#_-]|$)/,'@}\1') + @para.gsub!(/ /,' ') # ~ character for hardspace + @para.gsub!(/ /,' ') # ~ character for hardspace + @para.gsub!(/&(\S+?);/,' ') + @para.gsub!(/&/,'<=and>') + @para.gsub!(/(\s+&\s+)/,' and ') + @para.gsub!(/(\&)/,"\\&") @para.gsub!(/"(.+?)"/,"`\\1'") # open & close " @para.gsub!(/\s+"/," `") # open " @para.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*"/,'\1`') # open " @@ -368,11 +362,6 @@ WOK @para.gsub!(/"(\.|,)/,"'") # close " @para.gsub!(/\s+'/," `") # open ' @para.gsub!(/^([1-6-]\\+(?:~\S+)?|<.+?>)?\s*'/,'\1`') # open ' - #if @para=~/#{@@tex_1}/ - #end - #@para.gsub!(/^([1-6-](?:#{@@tex_2}|#{@@tex_1})(?:\\~\S+)?|<.+?>)?\s*"/i,"\\1`") # open " - #@para.gsub!(/"([1-6-](?:#{@@tex_2}|#{@@tex_1})(?:\\~\S+)?|<.+?>)?\s*$/i,"'\\1") # close " - #@para.gsub!(/^([1-6-](?:#{@@tex_2}|#{@@tex_1})(?:\\~\S+)?|<.+?>)?\s*'/i,"\\1`") # open ' @para.gsub!(/(<font.*?>|<\/font>)/,'') @para.gsub!(/\s*<sup>(\S+?)<\/sup>/,'^\1') @para.gsub!(/(<sup>|<\/sup>)/,'') diff --git a/lib/sisu/v0/urls.rb b/lib/sisu/v0/urls.rb index a18cdc2f..09b15f2d 100644 --- a/lib/sisu/v0/urls.rb +++ b/lib/sisu/v0/urls.rb @@ -103,7 +103,7 @@ module SiSU_urls 'a (Plain-text (footnotes))'=>@fn[:plain], 'A (Plain-text (footnotes) dos)'=>@fn[:plain], 'b (XHTML)'=>@fn[:xhtml], - 'B (Docbook XML)'=>@fn[:docbook], + #'B (Docbook XML)'=>@fn[:docbook], 'D[iu] (DBI import/update postgresql)'=>'dbi psql', 'd[iu] (DBI import/update sqlite)'=>'dbi sqlite', 'e (Plain-text (endnotes))'=>@fn[:plain], @@ -137,7 +137,7 @@ module SiSU_urls end end def urls_maintenance(opt,x,y) - if x=~/^([aAbBceEhHmNopwxXy])/ and opt.cmd =~/[aAbBceEhHmNopwxXy]/ and x=~/^[#{opt.cmd}]/ + if x=~/^([aAbceEhHmNopwxXy])/ and opt.cmd =~/[aAbceEhHmNopwxXy]/ and x=~/^[#{opt.cmd}]/ m=$1 f=y tool=@editor @@ -180,7 +180,7 @@ module SiSU_urls @pwd_stub="#@webserv_url"[m,1] @u.each do |x,y| if @opt.fns =~ @m_regular - if x=~/^([aAbBceEhHNopsSwxXyY])/ and @opt.cmd=~/[aAbBceEhHNopsSwxXyY]/ and x=~/^[#{@opt.cmd}]/ + if x=~/^([aAbceEhHNopsSwxXyY])/ and @opt.cmd=~/[aAbceEhHNopsSwxXyY]/ and x=~/^[#{@opt.cmd}]/ m=$1 tell=SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#@browser #@webserv_url/#@fnb/#{y}") tell.result unless @opt.cmd =~/q/ diff --git a/lib/sisu/v0/xml_scaffold.rb b/lib/sisu/v0/xml_scaffold.rb new file mode 100644 index 00000000..93987840 --- /dev/null +++ b/lib/sisu/v0/xml_scaffold.rb @@ -0,0 +1,203 @@ +=begin + + * Name: SiSU + + * Description: extract and print an XML rendition of document structure to screen + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007 Ralph Amissah All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007 Ralph Amissah + + 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 3 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, see <http://www.gnu.org/licenses/>. + + 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/gpl.fsf> + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + <http://www.jus.uio.no/sisu> + <http://www.sisudoc.org> + + * Download: + <http://www.jus.uio.no/sisu/SiSU/download.html> + + * Ralph Amissah + <ralph@amissah.com> + <ralph.amissah@gmail.com> + + ** Description: SiSU information Structuring Universe, processing + +=end +module SiSU_XML_scaffold + require "#{SiSU_lib}/dal" + require "#{SiSU_lib}/sysenv" + include SiSU_Env + include SiSU_Param + pwd=Dir.pwd + class Source + def initialize(opt) + @opt=opt + @sp=' ' + end + def read + begin + @md=SiSU_Param::Parameters.new(@opt).get + @dal_array=SiSU_DAL::Source.new(@opt).get # dal file drawn here + SiSU_XML_scaffold::Source::Scroll.new(@dal_array,@md).songsheet + rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error + ensure + end + end + private + class Scroll <Source + def initialize(data='',md='') + @data,@md=data,md + end + def songsheet + @t='docbook' #@t='fictionbook' + @s=['book', #@s=['body', + 'part', # 'section', + 'subpart N/A', # 'section', + 'sub-subpart N/A', # 'section', + 'chapter', # 'section', + 'sect1', # 'section', + 'sect2' # 'section' + ] #] + structure + end + def structure_outline(ds) + puts "\ninfo outline --->\n\n" + ds.each {|x| puts "#{x[:ocn]} #{x[:lev]} #{x[:hdr]}" } + end + def structure_simple(ds) + puts "\nheading outline --->\n\n" + ds.each_with_index do |x,i| + #puts "#{x[:ocn]} #{x[:lev]} #{x[:hdr]}" + if x[:lev] =~ /^([1-6])/; puts "<#{@s[$1.to_i]}>#{x[:ocn]} #{x[:lev]} #{x[:hdr]}</#{@s[$1.to_i]}>" + end + end + end + def structure_build_tag_close(lev,h) + @sp=' ' + case h[0] + when 1 + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and h[1] + puts "</#{@s[0]}>" if (lev == 0) + when 2 + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and h[2] + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and h[1] + puts "</#{@s[0]}>" if (lev == 0) + when 3 + puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) and h[3] + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and h[2] + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and h[1] + puts "</#{@s[0]}>" if (lev == 0) + when 4 + puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) + puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) and h[3] + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and h[2] + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and h[1] + puts "</#{@s[0]}>" if (lev == 0) + when 5 + puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) + puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) + puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) and h[3] + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and h[2] + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and h[1] + puts "</#{@s[0]}>" if (lev == 0) + when 6 + puts "#{@sp*6}</#{@s[6]}>" if (lev <= 6) + puts "#{@sp*5}</#{@s[5]}>" if (lev <= 5) + puts "#{@sp*4}</#{@s[4]}>" if (lev <= 4) + puts "#{@sp*3}</#{@s[3]}>" if (lev <= 3) and h[3] + puts "#{@sp*2}</#{@s[2]}>" if (lev <= 2) and h[2] + puts "#{@sp*1}</#{@s[1]}>" if (lev <= 1) and h[1] + puts "</#{@s[0]}>" if (lev == 0) + end + end + def structure_build(ds) + puts "\nXML [#@t type] structure outline --->\n\n" + @h=[0,false,false,false] + puts "<#{@s[0]}>" + ds.each_with_index do |x,i| + case x[:lev] + when /^1/ + structure_build_tag_close(x[:lev].to_i,@h) + puts "#{@sp*1}<#{@s[1]}>\n#{@sp*1} #{x[:ocn]} #{x[:lev]} #{x[:hdr]}" + @h=[1,true,false,false] + when /^2/ + structure_build_tag_close(x[:lev].to_i,@h) + puts "#{@sp*2}<#{@s[2]}>\n#{@sp*2} #{x[:ocn]} #{x[:lev]} #{x[:hdr]}" + @h=[2,true,true,false] + when /^3/ + structure_build_tag_close(x[:lev].to_i,@h) + puts "#{@sp*3}<#{@s[3]}>\n#{@sp*3} #{x[:ocn]} #{x[:lev]} #{x[:hdr]}" + @h=[3,true,true,true] + when /^4/ + structure_build_tag_close(x[:lev].to_i,@h) + puts "#{@sp*4}<#{@s[4]}>\n#{@sp*4} #{x[:ocn]} #{x[:lev]} #{x[:hdr]}" + @h[0]=4 + when /^5/ + structure_build_tag_close(x[:lev].to_i,@h) + puts "#{@sp*5}<#{@s[5]}>\n#{@sp*5} #{x[:ocn]} #{x[:lev]} #{x[:hdr]}" + @h[0]=5 + when /^6/ + structure_build_tag_close(x[:lev].to_i,@h) + puts "#{@sp*6}<#{@s[6]}>\n#{@sp*6} #{x[:ocn]} #{x[:lev]} #{x[:hdr]}" + @h[0]=6 + end + end + structure_build_tag_close(0,@h) + end + def structure + data=@data + @ds=[] + c=0 + data.each do |para| + if para =~/<~\d+;(?:\w|[0-6]:)\d+;\w\d+>/ + x=(/<~(\d+);((?:\w|[0-6]:)\d+);(\w\d+)>/).match(para) + if x[3] =~/^[hu]\d+/ + @ds[c]={} + @ds[c][:ocn]=x[1] + @ds[c][:lev]=x[2] + @ds[c][:hdr]=x[3] + c+=1 + #puts "#{x[1]} #{x[2]} #{x[3]}" + end + end + end + structure_outline(@ds) if @md.cmd =~/V/ + structure_simple(@ds) if @md.cmd =~/V/ + structure_build(@ds) + @ds + end + end + end +end +__END__ |