diff options
| -rw-r--r-- | data/doc/sisu/CHANGELOG_v2 | 5 | ||||
| -rw-r--r-- | data/doc/sisu/CHANGELOG_v3 | 53 | ||||
| -rw-r--r-- | data/sisu/v2/v/version.yml | 6 | ||||
| -rw-r--r-- | data/sisu/v3/v/version.yml | 6 | ||||
| -rw-r--r-- | lib/sisu/v2/help.rb | 2 | ||||
| -rw-r--r-- | lib/sisu/v3/cgi.rb | 6 | ||||
| -rw-r--r-- | lib/sisu/v3/cgi_pgsql.rb | 2 | ||||
| -rw-r--r-- | lib/sisu/v3/cgi_sql_common.rb | 53 | ||||
| -rw-r--r-- | lib/sisu/v3/cgi_sqlite.rb | 3 | ||||
| -rw-r--r-- | lib/sisu/v3/embedded.rb | 4 | ||||
| -rw-r--r-- | lib/sisu/v3/harvest.rb | 80 | ||||
| -rw-r--r-- | lib/sisu/v3/harvest_authors.rb | 233 | ||||
| -rw-r--r-- | lib/sisu/v3/harvest_topics.rb | 458 | ||||
| -rw-r--r-- | lib/sisu/v3/help.rb | 24 | ||||
| -rw-r--r-- | lib/sisu/v3/html.rb | 9 | ||||
| -rw-r--r-- | lib/sisu/v3/hub.rb | 2 | ||||
| -rw-r--r-- | lib/sisu/v3/manifest.rb | 2 | ||||
| -rw-r--r-- | lib/sisu/v3/options.rb | 111 | ||||
| -rw-r--r-- | lib/sisu/v3/param.rb | 2 | ||||
| -rw-r--r-- | lib/sisu/v3/sysenv.rb | 5 | ||||
| -rw-r--r-- | lib/sisu/v3/texpdf.rb | 4 | 
21 files changed, 649 insertions, 421 deletions
| diff --git a/data/doc/sisu/CHANGELOG_v2 b/data/doc/sisu/CHANGELOG_v2 index d204e9a2..f621f7be 100644 --- a/data/doc/sisu/CHANGELOG_v2 +++ b/data/doc/sisu/CHANGELOG_v2 @@ -12,6 +12,11 @@ Reverse Chronological:  %% STABLE Branch +%% 2.9.6.orig.tar.gz (2011-06-07:23/2) [see 3.0.12] +http://git.sisudoc.org/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/3.0.12-1 + +  * help, s/Bul garian/Bulgarian/ (Closes: #619068) +  %% 2.9.5.orig.tar.gz (2011-05-17:20/2) [see 3.0.10]  http://git.sisudoc.org/?p=code/sisu.git;a=shortlog;h=refs/tags/debian/3.0.10-1 diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 1385aeb5..5af32fc2 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -13,12 +13,56 @@ Reverse Chronological:  %% Development branch UNSTABLE  v3 branch once stable will supersede & replace current stable v2 branch +%% 3.0.12.orig.tar.gz (2011-06-09:23/4) +http://git.sisudoc.org/?p=code/sisu.git;a=log;h=refs/tags/debian/3.0.12-1 +http://www.jus.uio.no/sisu/pkg/src/sisu_3.0.12.orig.tar.gz +  sisu_3.0.12.orig.tar.gz +  sisu_3.0.12-1.dsc +  sisu_3.0.12-1.debian.tar.gz + +  * harvest +    * correct paths to document manifests etc. for the possible output dir +      structures +    * produce authors and topics lists for the documents that are available, +      according to availability in each language + +  * cgi generated sample search form +    * use ruby 1.9.2 shebang/header (sisu-pgsql, sisu-sqlite) recent upload +      of libdbi-ruby1.9.1 fixes bug reported as #596103 (against +      libdbd-pg-ruby1.9.1), search forms (pgsql & sqlite) can now use ruby +      1.9.2, so cgi headers changed back to #!/usr/bin/env ruby [however must +      use ruby >=1.9.2] (from #!/usr/bin/ruby1.8) [see sisu-3.0.8 NOTE & +      "sample search form" solution, (now superseded)] +    * force utf-8 character encoding to avoid issues, fix +      (incompatible character encodings: UTF-8 and US-ASCII) +    * correction of a variable name, fix + +  * options +    * restrict glob rule checks to when --glob (-G) or --find (-f) requested +    * carry information on document language (from filename and or directory +    * (additional test) + +  * sysenv, limit/prevent the creation of spurious output directories (based on +    language subdirectories), revisit + +  * manifest, fix a full name + +  * html, index.html syslink, remove and remake syslink +  * texpdf, index.html syslink, made similar + +  * param, remove unused class variable '@@symlnk' + +  * help +    * --help language, provides list of available languages (ISO 639-1 code (as +      varied by po4a) & name) +    * s/Bul garian/Bulgarian/ (Closes: #619068) +  %% 3.0.11.orig.tar.gz (2011-05-29:21/7)  http://git.sisudoc.org/?p=code/sisu.git;a=log;h=refs/tags/debian/3.0.11-1  http://www.jus.uio.no/sisu/pkg/src/sisu_3.0.11.orig.tar.gz -  sisu_3.0.11.orig.tar.gz -  sisu_3.0.11-1.dsc -  sisu_3.0.11-1.debian.tar.gz +  b3ff82d967565a35f9693ad95812adcb850ac4f58f60f4cf9e5a9d613d886fcc 1940955 sisu_3.0.11.orig.tar.gz +  69d15d75fbf3670b8609dd8d9ee65a10b2eddfbcddd9ee206cbc48cfde6eb899 1223 sisu_3.0.11-1.dsc +  2a11d94922d6810b5a786d51a148cc955d8c676932b9341b8a30bf114cab4cee 288354 sisu_3.0.11-1.debian.tar.gz    * sysenv, url webserver link (manifest) fix @@ -150,7 +194,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.0.8.orig.tar.gz      * title, src_filename and language_document_char fields mandatory        (title, title_main, src_filename, language_document_char) -  * NOTE: cgi sample search form caught by Ruby/DBI libdbi-ruby1.9.1 reported +  * NOTE: [libdbi-ruby1.9.1 fixed in unstable 2011-06-06, & for sisu-3.0.12] +    cgi sample search form caught by Ruby/DBI libdbi-ruby1.9.1 reported      reported as libdbd-pg-ruby1.9.1 bug #596103, where "select_all fails". The      cgi sample search scripts for postgresql and sqlite3 are almost identical,      both work in ruby 1.8.7, both have the same error in ruby 1.9.2... a very diff --git a/data/sisu/v2/v/version.yml b/data/sisu/v2/v/version.yml index 85cdd471..562ae361 100644 --- a/data/sisu/v2/v/version.yml +++ b/data/sisu/v2/v/version.yml @@ -1,5 +1,5 @@  --- -:version: 2.9.4 -:date_stamp: 2011w19/7 -:date: "2011-05-15" +:version: 2.9.6 +:date_stamp: 2011w23/2 +:date: "2011-06-07"  :project: SiSU diff --git a/data/sisu/v3/v/version.yml b/data/sisu/v3/v/version.yml index 1e3c4e22..a997c557 100644 --- a/data/sisu/v3/v/version.yml +++ b/data/sisu/v3/v/version.yml @@ -1,5 +1,5 @@  --- -:version: 3.0.11-beta-rb1.9.2p180 -:date_stamp: 2011w29/7 -:date: "2011-05-29" +:version: 3.0.12-beta-rb1.9.2p180 +:date_stamp: 2011w23/4 +:date: "2011-06-09"  :project: SiSU diff --git a/lib/sisu/v2/help.rb b/lib/sisu/v2/help.rb index 85bb898c..8413aff1 100644 --- a/lib/sisu/v2/help.rb +++ b/lib/sisu/v2/help.rb @@ -637,7 +637,7 @@ This is a sample header (#{@cX.fuschia}Dublin Core in fuschia,#{@cX.off} #{@cX.c  #{@cX.fuschia}@source:#{@cX.off} -#{@cX.fuschia}@language:#{@cX.off} [or @language.document:] [country code for language if available, or language, English, en is the default setting] (en - English, fr - French, de - German, it - Italian, es - Spanish, pt - Portuguese, sv - Swedish, da - Danish, fi - Finnish, no - Norwegian, is - Icelandic, nl - Dutch, et - Estonian, hu - Hungarian, pl - Polish, ro - Romanian, ru - Russian, el - Greek, uk - Ukranian, tr - Turkish, sk - Slovak, sl - Slovenian, hr - Croatian, cs - Czech, bg - Bul garian ) [however, encodings are not available for all of the languages listed.] +#{@cX.fuschia}@language:#{@cX.off} [or @language.document:] [country code for language if available, or language, English, en is the default setting] (en - English, fr - French, de - German, it - Italian, es - Spanish, pt - Portuguese, sv - Swedish, da - Danish, fi - Finnish, no - Norwegian, is - Icelandic, nl - Dutch, et - Estonian, hu - Hungarian, pl - Polish, ro - Romanian, ru - Russian, el - Greek, uk - Ukranian, tr - Turkish, sk - Slovak, sl - Slovenian, hr - Croatian, cs - Czech, bg - Bulgarian ) [however, encodings are not available for all of the languages listed.]  #{@cX.fuschia}@language.original:#{@cX.off}  original language in which the work was published diff --git a/lib/sisu/v3/cgi.rb b/lib/sisu/v3/cgi.rb index f1d628d2..bdecb6ed 100644 --- a/lib/sisu/v3/cgi.rb +++ b/lib/sisu/v3/cgi.rb @@ -64,14 +64,14 @@ module  SiSU_CGI    class SiSU_search      def initialize(opt)        @opt=opt -      @webserv=@opt.files[0].to_s.strip #verify @opt.files[0].class +      @webserv=@opt.files[0].to_s.strip      end      def search_info       a=%{            For help on sisu search, type:              sisu --help search -    } -        SiSU_Screen::Ansi.new(@opt.cmd,a).print_grey +      } +      SiSU_Screen::Ansi.new(@opt.cmd,a).print_grey      end      def read        SiSU_CGI_sqlite::SiSU_search_sqlite.new(@opt,@webserv).sqlite diff --git a/lib/sisu/v3/cgi_pgsql.rb b/lib/sisu/v3/cgi_pgsql.rb index aa4a02e8..41be70d4 100644 --- a/lib/sisu/v3/cgi_pgsql.rb +++ b/lib/sisu/v3/cgi_pgsql.rb @@ -120,7 +120,7 @@ module  SiSU_CGI_pgsql      end      def header0        <<-WOK_SQL -#!/usr/bin/ruby1.8 +#!/usr/bin/env ruby  =begin  #{about}   * Description: generates naive cgi search form for search of sisu database (pgsql) diff --git a/lib/sisu/v3/cgi_sql_common.rb b/lib/sisu/v3/cgi_sql_common.rb index c782d48f..8dce0743 100644 --- a/lib/sisu/v3/cgi_sql_common.rb +++ b/lib/sisu/v3/cgi_sql_common.rb @@ -842,6 +842,15 @@ module SiSU_CGI_sql            def path_html_seg(fn,ln=nil)              "#{@hostpath}/#{ln}/html/#{fn}"            end +          def path_toc(fn,ln=nil) +            "#{path_html_seg(fn,ln)}/toc.html" +          end +          def path_filename(fn,seg,ln=nil) +            "#{path_html_seg(fn,ln)}/#{seg}.html" +          end +          def path_endnotes(fn,ln=nil) +            "#{path_html_seg(fn,ln)}/endnotes.html" +          end            def path_html_doc(fn,ln=nil)              "#{@hostpath}/#{ln}/html/#{fn}.html"            end @@ -849,25 +858,43 @@ module SiSU_CGI_sql        when /filetype/          <<-'WOK_SQL'            def path_manifest(fn,ln=nil) -            "#{@hostpath}/manifest/#{fn}.html" +            "#{@hostpath}/manifest/#{fn}.#{ln}.html"            end            def path_html_seg(fn,ln=nil)              "#{@hostpath}/html/#{fn}"            end +          def path_toc(fn,ln=nil) +            "#{path_html_seg(fn,ln)}/toc.#{ln}.html" +          end +          def path_filename(fn,seg,ln=nil) +            "#{path_html_seg(fn,ln)}/#{seg}.#{ln}.html" +          end +          def path_endnotes(fn,ln=nil) +            "#{path_html_seg(fn,ln)}/endnotes.#{ln}.html" +          end            def path_html_doc(fn,ln=nil) -            "#{@hostpath}/html/#{fn}.html" +            "#{@hostpath}/html/#{fn}.#{ln}.html"            end          WOK_SQL        else          <<-'WOK_SQL'            def path_manifest(fn,ln=nil) -            "#{@hostpath}/#{fn}/manifest.html" +            "#{@hostpath}/#{fn}/sisu_manifest.#{ln}.html"            end            def path_html_seg(fn,ln=nil)              "#{@hostpath}/#{fn}"            end +          def path_toc(fn,ln=nil) +            "#{path_html_seg(fn,ln)}/toc.#{ln}.html" +          end +          def path_filename(fn,seg,ln=nil) +            "#{path_html_seg(fn,ln)}/#{seg}.#{ln}.html" +          end +          def path_endnotes(fn,ln=nil) +            "#{path_html_seg(fn,ln)}/endnotes.#{ln}.html" +          end            def path_html_doc(fn,ln=nil) -            "#{@hostpath}/#{fn}/doc.html" +            "#{path_html_seg(fn,ln)}/scroll.#{ln}.html"            end          WOK_SQL        end @@ -890,7 +917,7 @@ module SiSU_CGI_sql                can_txt_srch=(cgi['view']=~/index/) \                ? %{<a href="#{@canned_base_url}&fns=#{c['src_filename']}&lang=#{c['language_document_char']}&view=text"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a> } \                : %{<a href="#{@canned_base_url}&fns=#{c['src_filename']}&lang=#{c['language_document_char']}&view=index"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a> } -              title=%{<span style="background-color: #{@color_heading}"><a href="#{path_html_seg(location,c['language_document_char'])}/toc.html"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"> #{ti}</a></span> [#{c['language_document_char']}] by #{c['creator_author']} #{can_txt_srch}<a href="#{path_html_seg(location,c['language_document_char'])}/toc.html"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"></a> <a href="#{path_manifest(location,c['language_document_char'])}"><img border="0" width="15" height="15" src="#{@image_src}/b_info.png" alt="manifest"></a><br />}  if file_suffix=~/s/ #hmm watch file_suffix +              title=%{<span style="background-color: #{@color_heading}"><a href="#{path_toc(location,c['language_document_char'])}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"> #{ti}</a></span> [#{c['language_document_char']}] by #{c['creator_author']} #{can_txt_srch}<a href="#{path_toc(location,c['language_document_char'])}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"></a> <a href="#{path_manifest(location,c['language_document_char'])}"><img border="0" width="15" height="15" src="#{@image_src}/b_info.png" alt="manifest"></a><br />}  if file_suffix=~/s/ #hmm watch file_suffix                title=@text_search_flag \                ? '<br /><hr>'+title \                : '<br />'+title @@ -927,7 +954,7 @@ module SiSU_CGI_sql                    matched_para=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \                    ? (c['body'].gsub(/(<a\s+href="https?:\/\/[^><\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{<span style="background-color: #{@color_match}">\\1</span>})) \                    : c['body'] -                  %{<hr><p><font size="2">ocn <b><a href="#{path_html_seg(location,@ln)}/#{c['seg']}#{lang}.html##{c['ocn']}">#{c['ocn']}</a></b>:</font></p>#{matched_para}} +                  %{<hr><p><font size="2">ocn <b><a href="#{path_filename(location,c['seg'],@ln)}##{c['ocn']}">#{c['ocn']}</a></b>:</font></p>#{matched_para}}                  elsif c['suffix'] =~/1/ #doc                    %{#{title}<hr><p><font size="2">ocn #{c['ocn']}:#{c['body']}}                  end @@ -935,7 +962,7 @@ module SiSU_CGI_sql                  output=title+text                else #elsif cgi['view']=~/index/                                #% idx body                  if c['suffix'] !~/1/ #seg -                  index=%{<a href="#{path_html_seg(location,@ln)}/#{c['seg']}#{lang}.html##{c['ocn']}">#{c['ocn']}</a>, } if @text_search_flag +                  index=%{<a href="#{path_filename(location,c['seg'],@ln)}##{c['ocn']}">#{c['ocn']}</a>, } if @text_search_flag                  elsif c['suffix'] =~/1/ #doc #FIX                    index=%{<a href="#{path_html_doc(location,@ln)}##{c['ocn']}">#{c['ocn']}</a>, }                  end @@ -981,9 +1008,9 @@ module SiSU_CGI_sql                if e['metadata_tid'].to_i != oldtid.to_i                  ti=e['title']                  can_txt_srch=(cgi['view']=~/index/) \ -                ? %{<a href="#{@canned_base_url}&fns=#{e['src_filename']}&lang=#{c['language_document_char']}&view=text"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a> } \ -                : %{<a href="#{@canned_base_url}&fns=#{e['src_filename']}&lang=#{c['language_document_char']}&view=index"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a> } -                title=%{<br /><hr><span style="background-color: #{@color_heading}"><a href="#{path_html_seg(location,@ln)}/toc.html"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"> #{ti}</a></span> [#{c['language_document_char']}] by #{e['creator_author']} #{can_txt_srch}<a href="#{path_html_seg(location,@ln)}/toc.html"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"></a> <a href="#{path_manifest(location,@ln)}"><img border="0" width="15" height="15" src="#{@image_src}/b_info.png" alt="manifest"></a><br />}  if file_suffix=~/s/ +                ? %{<a href="#{@canned_base_url}&fns=#{e['src_filename']}&lang=#{e['language_document_char']}&view=text"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a> } \ +                : %{<a href="#{@canned_base_url}&fns=#{e['src_filename']}&lang=#{e['language_document_char']}&view=index"><img border="0" width="24" height="16" src="#{@image_src}/b_search.png" alt="search"></a> } +                title=%{<br /><hr><span style="background-color: #{@color_heading}"><a href="#{path_toc(location,@ln)}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"> #{ti}</a></span> [#{e['language_document_char']}] by #{e['creator_author']} #{can_txt_srch}<a href="#{path_toc(location,@ln)}"><img border="0" width="15" height="18" src="#{@image_src}/b_toc.png" alt="toc html"></a> <a href="#{path_manifest(location,@ln)}"><img border="0" width="15" height="15" src="#{@image_src}/b_info.png" alt="manifest"></a><br />}  if file_suffix=~/s/                  @counter_endn_doc+=1                  oldtid=e['metadata_tid'].to_i                else title = '' @@ -994,10 +1021,10 @@ module SiSU_CGI_sql                  matched_endnote=(@search_regx.to_s.class==String && @search_regx.to_s=~/\S\S+/) \                  ? matched=e['body'].gsub(/(<a\s+href="https?:\/\/[^><\s]+#{@search_regx}[^>]+?>|#{@search_regx})/mi,%{<span style="background-color: #{@color_match}">\\1</span>}) \                  : e['body'] -                output=%{#{title}<hr><font size="2">note <b><a href="#{path_html_seg(location,@ln)}/endnotes.html#_#{e['nr']}">#{e['nr']}</a></b> referred to from ocn <a href="#{path_html_doc(location,@ln)}##{e['ocn']}">#{e['ocn']}</a>:</font> #{matched_endnote}} +                output=%{#{title}<hr><font size="2">note <b><a href="#{path_endnotes(location,@ln)}#_#{e['nr']}">#{e['nr']}</a></b> referred to from ocn <a href="#{path_html_doc(location,@ln)}##{e['ocn']}">#{e['ocn']}</a>:</font> #{matched_endnote}}                else #elsif cgi['view']=~/index/      #doc #FIX                           #% idx endnotes                  @counter_endn_ocn+=1 -                output=%{#{title}<a href="#{path_html_seg(location,@ln)}/endnotes.html#_#{e['nr']}">#{e['nr']}</a> [§ <a href="#{path_html_doc(location,@ln)}##{e['ocn']}">#{e['ocn']}</a>], } +                output=%{#{title}<a href="#{path_endnotes(location,@ln)}#_#{e['nr']}">#{e['nr']}</a> [§ <a href="#{path_html_doc(location,@ln)}##{e['ocn']}">#{e['ocn']}</a>], }                end                @counters_endn=if @counter_endn_doc > 0                  if checked_stats =~/\S/ @@ -1021,7 +1048,7 @@ module SiSU_CGI_sql            ? dbi_statement.pre_next(true,@image_src).to_s \            : dbi_statement.pre_next(false,@image_src).to_s            limit=dbi_statement.sql_match_limit.to_s -          cgi.out{@header + @counters_txt + @counters_endn + canned + @body_main + @endnotes + canned + @tail} #% print cgi_output_header+counters+body+endnotes +          cgi.out{@header.force_encoding("UTF-8") + @counters_txt.force_encoding("UTF-8") + @counters_endn.force_encoding("UTF-8") + canned.force_encoding("UTF-8") + @body_main.force_encoding("UTF-8") + @endnotes.force_encoding("UTF-8") + canned.force_encoding("UTF-8") + @tail.force_encoding("UTF-8")} #% print cgi_output_header+counters+body+endnotes          end          rescue Exception => e            s='<pre>' + CGI::escapeHTML(e.backtrace.reverse.join("\n")) diff --git a/lib/sisu/v3/cgi_sqlite.rb b/lib/sisu/v3/cgi_sqlite.rb index c0ecaeb5..64124cc8 100644 --- a/lib/sisu/v3/cgi_sqlite.rb +++ b/lib/sisu/v3/cgi_sqlite.rb @@ -88,7 +88,6 @@ module  SiSU_CGI_sqlite          f2 << %{           when /#{Db[:name_prefix]}#{x}/; '<option value="#{Db[:name_prefix]}#{x}">#{x}</option>'\n}        end        f2 << "          end\n" -      #f3        f3 << %{          db_name='sisu_sqlite.db'\n}        f3 << %{          db_sqlite=case cgi['db']\n}        serve.each do |x| @@ -120,7 +119,7 @@ module  SiSU_CGI_sqlite      end      def header0        <<-WOK_SQL -#!/usr/bin/ruby1.8 +#!/usr/bin/env ruby  =begin  #{about}   * Description: generates naive cgi search form for search of sisu database (sqlite) diff --git a/lib/sisu/v3/embedded.rb b/lib/sisu/v3/embedded.rb index fad1fb29..fb2245c9 100644 --- a/lib/sisu/v3/embedded.rb +++ b/lib/sisu/v3/embedded.rb @@ -87,8 +87,8 @@ module SiSU_Embedded      def images        src="#{@base_src_dir}/_sisu/image"        src_img='_sisu/image' -      ldest="#{@env.path.webserv}/#{@env.path.stub_pwd}" -      img_dir="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image" +      ldest=@env.path.output +      img_dir="#{@env.path.output}/_sisu/image"        @rhost.each do |remote_conn|          rdest="#{remote_conn[:name]}/#{@env.path.stub_pwd}/_sisu/image"          remote_rel=remote_conn[:name] + '/' + @f.output_path.stub.rcp diff --git a/lib/sisu/v3/harvest.rb b/lib/sisu/v3/harvest.rb index aaec9046..47380c2e 100644 --- a/lib/sisu/v3/harvest.rb +++ b/lib/sisu/v3/harvest.rb @@ -58,45 +58,51 @@   ** Description: system environment, resource control and configuration details  =end -def help -  puts <<WOK -  harvest --harvest   extracts document index metadata - +module SiSU_Harvest +  @@the_idx_topics,@@the_idx_authors={},{} +  class Source +    require_relative 'options'                              # options.rb +    require_relative 'harvest_topics'                       # harvest_topics.rb +    require_relative 'harvest_authors'                      # harvest_authors.rb +    require_relative 'sysenv'                               # sysenv.rb +      include SiSU_Env +    def initialize(opt) +      @opt=opt +      @env=SiSU_Env::Info_env.new +    end +    def read +      harvest_pth="#{@env.path.webserv}/#{@opt.base_stub}" +      mkdir_p(harvest_pth) unless FileTest.directory?(harvest_pth) +      cases(@opt,@env) +    end +    def help +      puts <<WOK +      harvest --harvest   extracts document index metadata +      WOK -end -def css(opt) -  require_relative 'css'                                # css.rb -  css=SiSU_Style::CSS.new -  fn_css=SiSU_Env::CSS_default.new -  style=File.new("#{@env.path.pwd}/#{fn_css.harvest}",'w') -  style << css.harvest -  style.close -end -def cases(opt) -  case opt.mod.inspect -  when/--harvest/i -    css(opt) if opt.cmd.inspect =~/M/ -    HARVEST_authors::Songsheet.new(opt).songsheet -    HARVEST_topics::Songsheet.new(opt).songsheet -    if opt.cmd.inspect =~/R/ -      require_relative 'remote'                         # remote.rb -      SiSU_Remote::Put.new(opt).rsync_harvest      end -  else -    help +    def css(opt) +      require_relative 'css'                                # css.rb +      css=SiSU_Style::CSS.new +      fn_css=SiSU_Env::CSS_default.new +      style=File.new("#{@env.path.pwd}/#{fn_css.harvest}",'w') +      style << css.harvest +      style.close +    end +    def cases(opt,env) +      case opt.mod.inspect +      when/--harvest/i +        css(opt) if opt.cmd.inspect =~/M/ +        HARVEST_authors::Songsheet.new(opt,env).songsheet +        HARVEST_topics::Songsheet.new(opt,env).songsheet +        if opt.cmd.inspect =~/R/ +          require_relative 'remote'                         # remote.rb +          SiSU_Remote::Put.new(opt).rsync_harvest +        end +      else +        help +      end +    end    end  end -require_relative 'options'                              # options.rb -require_relative 'harvest_topics'                       # harvest_topics.rb -require_relative 'harvest_authors'                      # harvest_authors.rb -require_relative 'sysenv'                               # sysenv.rb -  include SiSU_Env -@env=SiSU_Env::Info_env.new -@@the_idx_topics,@@the_idx_authors={},{} -argv=$* -opt=SiSU_commandline::Options.new(argv) -argv.shift -harvest_pth="#{@env.path.webserv}/#{@env.stub_md_harvest}" -mkdir_p(harvest_pth) unless FileTest.directory?(harvest_pth) -cases(opt)  __END__ diff --git a/lib/sisu/v3/harvest_authors.rb b/lib/sisu/v3/harvest_authors.rb index 75d2a810..c59a9111 100644 --- a/lib/sisu/v3/harvest_authors.rb +++ b/lib/sisu/v3/harvest_authors.rb @@ -59,47 +59,45 @@  =end  module HARVEST_authors    require_relative 'author_format'                      # author_format.rb -  @@the_idx_authors=[]    class Songsheet -    def initialize(opt) -      @opt=opt +    @@the_idx_authors={} +    def initialize(opt,env) +      @opt,@env=opt,env        @file_list=opt.files -      @env=SiSU_Env::Info_env.new      end      def songsheet -      files,idx_array=[],[] -      @file_list.each do  |f| -        (f =~/.+?\.ss[tm]$/) \ -        ? (files << f[/(.+?\.ss[tm])$/,1]) \ -        : (print "not .sst or .ssm ? << #{f} >> ") -      end -      files.each do |filename| -        file_array=[] +      puts 'authors:' +      idx_array={} +      @opt.f_pths.each do |y| +        lang_hash_file_array={} +        name=y[:f]  +        filename=y[:pth] + '/' + y[:f]           File.open(filename,'r') do |file|            file.each_line("\n\n") do |line|              if line =~/^@(?:title|creator|date):(?:\s|$)/m -              file_array << line +              lang_hash_file_array[y[:lng_is]] ||= [] +              lang_hash_file_array[y[:lng_is]] << line              elsif line =~/^@\S+?:(?:\s|$)/m \              or line =~/^(?:\s*\n|%+ )/              else break              end            end          end -        idx_array=HARVEST_authors::Harvest.new(file_array,filename,idx_array).extract_harvest +        lang_hash_file_array.each_pair do |lang,a| +          idx_array[lang] ||= [] +          idx_array=HARVEST_authors::Harvest.new(@opt,@env,a,filename,name,idx_array,lang).extract_harvest +        end        end        the_idx=HARVEST_authors::Index.new(idx_array,@@the_idx_authors).construct_book_author_index        HARVEST_authors::Output_index.new(@opt,the_idx).html_print.html_songsheet -      harvest_pth="#{@env.path.webserv}/#{@env.stub_md_harvest}" -      puts "file://#{harvest_pth}/harvest_authors.html" -      puts "file://#{@env.path.pwd}/harvest_authors.html" if @opt.cmd.inspect =~/M/      end    end    class Harvest -    def initialize(data,filename,idx_array) -      @data,@filename,@idx_array=data,filename,idx_array +    def initialize(opt,env,data,filename,name,idx_array,lang) +      @opt,@env,@data,@filename,@name,@idx_array,@lang=opt,env,data,filename,name,idx_array,lang      end      def extract_harvest -      data,filename,idx_array=@data,@filename,@idx_array +      data,filename,name,idx_array,lang=@data,@filename,@name,@idx_array,@lang        @title,@subtitle,@fulltitle,@author,@author_format,@date=nil,nil,nil,nil,nil,nil        @authors=[]        rgx={} @@ -123,22 +121,25 @@ module HARVEST_authors          break if @title and @subtitle and @author and @date        end        @fulltitle=@subtitle ? (@title + ' - ' + @subtitle) : @title -      if @title and @author_format +      if @title \ +      and @author_format          creator=FORMAT::Author.new(@author_format.strip).author_details          @authors,@authorship=creator[:authors],creator[:authorship] -        file=if filename=~/~[a-z]{2,3}\.ss[mt]$/ -          lang='.' + /~([a-z]{2,3})\.ss[mt]$/.match(filename)[1] -          filename.sub(/~[a-z]{2,3}\.ss[mt]$/,'') +        file=if name=~/~[a-z]{2,3}\.ss[mt]$/ +          name.sub(/~[a-z]{2,3}\.ss[mt]$/,'')          else -          lang='' -          filename.sub(/\.ss[mt]$/,'') +          name.sub(/\.ss[mt]$/,'')          end -        page="sisu_manifest#{lang}.html" -        idx_array <<= { filename: filename, file: file, date: @date, title: @fulltitle, author: creator, page: page } +        page=if @env.output_dir_structure.by_language_code? +          "#{lang}/sisu_manifest.html" +        else +          "sisu_manifest.#{lang}.html" +        end +        idx_array[lang] <<= { filename: filename, file: file, date: @date, title: @fulltitle, author: creator, page: page, lang: lang }        else          #p "missing author field: #{@filename} title: #{@title}; author: #{@author_format}"        end -      idx_array.flatten! +      idx_array[lang].flatten!        idx_array      end    end @@ -152,38 +153,55 @@ module HARVEST_authors      end      def construct_book_author_index        idx_array=@idx_array -      idx_array.each do |idx| -        idx[:author][:last_first_format_a].each do |author| -          author.strip! -          if @@the_idx_authors[author].class==NilClass -            @@the_idx_authors[author]={ md: [] } +      idx_array.each_pair do |lang,idx_array| +        @@the_idx_authors[lang] ||= {} +        idx_array.each do |idx| +          idx[:author][:last_first_format_a].each do |author| +            author.strip! +            if @@the_idx_authors[lang][author].class==NilClass +              @@the_idx_authors[lang][author]={ md: [] } +            end +            @@the_idx_authors[lang][author][:md] << { filename: idx[:filename], file: idx[:file], author: idx[:author], title: idx[:title], date: idx[:date], page: idx[:page], lang: idx[:lang] }            end -          @@the_idx_authors[author][:md] << { filename: idx[:filename], file: idx[:file], author: idx[:author], title: idx[:title], date: idx[:date], page: idx[:page] }          end        end        @the_idx=@@the_idx_authors      end    end    class Output_index +    require_relative 'i18n'                               # i18n.rb +    require 'fileutils' +      include FileUtils      def initialize(opt,the_idx)        @opt,@the_idx=opt,the_idx        @env=SiSU_Env::Info_env.new -      @rc=Get_init.instance.sisu_yaml.rc +      @rc=SiSU_Env::Get_init.instance.sisu_yaml.rc        @alph=%W[9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]        @letter=@alph.shift        @vz=SiSU_Env::Get_init.instance.skin      end      def html_file_open -      @output={} -      harvest_pth="#{@env.path.webserv}/#{@env.stub_md_harvest}" -      @output[:html]=File.new("#{harvest_pth}/harvest_authors.html",'w') -      @output[:html_mnt]=(@opt.cmd.inspect =~/M/) \ -      ? File.new("#{@env.path.pwd}/harvest_authors.html",'w') \ -      : nil +      @the_idx.keys.each do |lng| +        @output ||={} +        @output[lng] ||={} +        harvest_pth,file='','' +        if @env.output_dir_structure.by_language_code? +          harvest_pth="#{@env.path.webserv}/#{@opt.base_stub}/#{lng}/manifest" +          file="#{harvest_pth}/authors.html" +        else +          harvest_pth="#{@env.path.webserv}/#{@opt.base_stub}/manifest" +          file="#{harvest_pth}/authors.#{lng}.html" +        end +        mkdir_p(harvest_pth) unless FileTest.directory?(harvest_pth) +        puts "file://#{file}" +        @output[lng][:html]=File.new(file,'w') +      end      end      def html_file_close -      @output[:html].close -      @output[:html_mnt].close if @output[:html_mnt].class==File +      @the_idx.keys.each do |lng| +        @output[lng][:html].close +        @output[lng][:html_mnt].close if @output[lng][:html_mnt].class==File +      end      end      def html_print        def html_songsheet @@ -194,19 +212,36 @@ module HARVEST_authors          html_tail          html_file_close        end -      def html_head_adjust(type='') -        css_path=if @env.output_dir_structure.by_language_code? +      def html_head_adjust(lng,type='') +        css_path,topics='','' +        if @env.output_dir_structure.by_language_code?            css_path=(type !~/maintenance/) \            ? '../../_sisu/css/harvest.css' \            : 'harvest.css' +          topics='topics.html'          elsif @env.output_dir_structure.by_filetype?            css_path=(type !~/maintenance/) \            ? '../_sisu/css/harvest.css' \            : 'harvest.css' +          topics="topics.#{lng}.html"          elsif @env.output_dir_structure.by_filename?            css_path=(type !~/maintenance/) \            ? '../_sisu/css/harvest.css' \            : 'harvest.css' +          topics="topics.#{lng}.html" +        end +        ln=SiSU_i18n::Languages.new.language.list +        harvest_languages='' +        @the_idx.keys.each do |lng| +          if @env.output_dir_structure.by_language_code? +            harvest_pth="../../#{lng}/manifest" +            file="#{harvest_pth}/authors.html" +          else @env.output_dir_structure.by_filetype? +            harvest_pth='.' +            file="#{harvest_pth}/authors.#{lng}.html" +          end +          l=ln[lng][:t] +          harvest_languages += %{<a href="#{file}">#{l}</a>   }          end          sv=SiSU_Env::Info_version.instance.get_version          <<WOK @@ -228,27 +263,35 @@ module HARVEST_authors  <a name="up" id="up"></a>  <a name="start" id="start"></a>  <h1>SiSU Metadata Harvest - Authors</h1> -<p>[<a href="../index.html"> HOME </a>] also see <a href="harvest_topics.html">SiSU Metadata Harvest - Topics</a></p> +<p>[<a href="../index.html"> HOME </a>] also see <a href="#{topics}">SiSU Metadata Harvest - Topics</a></p>  <p>#{@env.widget_static.search_form}</p>  <hr /> +<p class="tiny">#{harvest_languages}</p> +<hr />  WOK        end        def html_head -        @output[:html_mnt] << html_head_adjust('maintenance') if @opt.cmd.inspect =~/M/ -        @output[:html] << html_head_adjust +        @the_idx.keys.each do |lng| +          @output[lng][:html_mnt] << html_head_adjust(lng,'maintenance') if @opt.cmd.inspect =~/M/ +          @output[lng][:html] << html_head_adjust(lng) +        end        end        def html_alph          a=[]          a << '<p>'          @alph.each do |x| -          a << ((x =~/[0-9]/) ? '' : %{<a href="##{x}">#{x}</a>, }) +          a << ((x =~/[0-9]/) \ +          ? '' \ +          : %{<a href="##{x}">#{x}</a>, }) +        end +        a=a.join +        @the_idx.keys.each do |lng| +          @output[lng][:html_mnt] << a if @opt.cmd.inspect =~/M/ +          @output[lng][:html] << a          end -        @output[:html_mnt] << a.join if @output[:html_mnt].class==File -        @output[:html] << a.join        end        def html_tail -        a=[] -        a <<<<WOK +        a =<<WOK  <hr />  <a name="bottom" id="bottom"></a>  <a name="down" id="down"></a> @@ -260,27 +303,25 @@ WOK  </body>  </html>  WOK -        @output[:html_mnt] << a if @output[:html_mnt].class==File -        @output[:html] << a -      end -      def do_html(html) -        @output[:html_mnt] << html if @output[:html_mnt].class==File -        @output[:html] << html +        @the_idx.keys.each do |lng| +          @output[lng][:html_mnt] << a if @output[lng][:html_mnt].class==File +          @output[lng][:html] << a +        end        end -      def do_string(attrib,string) -        html=%{<p class="#{attrib}">#{string}</p>} -        do_html(html) +      def do_html(lng,html) +        @output[lng][:html_mnt] << html if @output[lng][:html_mnt].class==File +        @output[lng][:html] << html        end -      def do_string_name(attrib,string) +      def do_string_name(lng,attrib,string)          f=/^(\S)/.match(string[0])[1]          if @letter < f            while @letter < f              if @alph.length > 0                @letter=@alph.shift -              if @output[:html_mnt].class==File -                @output[:html_mnt] << %{\n<p class="letter"><a name="#{@letter}"></p>#{@letter}</a><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>} +              if @output[lng][:html_mnt].class==File +                @output[lng][:html_mnt] << %{\n<p class="letter"><a name="#{@letter}"></p>#{@letter}</a><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>}                end -              @output[:html] << %{\n<p class="letter"><a name="#{@letter}">#{@letter}</a></p><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>} +              @output[lng][:html] << %{\n<p class="letter"><a name="#{@letter}">#{@letter}</a></p><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>}              else break              end            end @@ -288,37 +329,35 @@ WOK        end        def html_body          the_idx=@the_idx -        the_idx.sort.each do |a| -          do_string_name('',a) -          name=a[0].sub(/(.+?)(?:,.+|$)/,'\1').gsub(/\s+/,'_') -          x = %{<p class="author"><a name="#{name}">#{a[0]}</a></p>} -          if @output[:html_mnt].class==File -            @output[:html_mnt] << x -          end -          @output[:html] << x -          works=[] -          a[1][:md].each do |x| -            if @env.output_dir_structure.by_language_code? -              manifest_pth="#{@env.path.output}/#{x[:file]}" -              manifest_at_local=@env.path.output + '/' + 'en' + '/' + 'manifest/'  +  x[:file] + '.manifest.html' -              manifest_at=x[:file] + '.manifest.html' -            elsif @env.output_dir_structure.by_filetype? -              #manifest_pth_2="#{@env.path.output}/#{x[:file]}" -              manifest_name=x[:file] -              manifest_at_local=manifest_name + 'manifest.html' -              manifest_at=x[:file] + '.manifest.html' -            elsif @env.output_dir_structure.by_filename? -              manifest_at_local="#{@env.path.output}/#{x[:file]}/#{x[:page]}" -              manifest_at="../#{x[:file]}/#{x[:page]}" +        the_idx.each_pair do |lng,lng_array| +          lng_array.sort.each do |a| +            do_string_name(lng,'',a) +            name=a[0].sub(/(.+?)(?:,.+|$)/,'\1').gsub(/\s+/,'_') +            x = %{<p class="author"><a name="#{name}">#{a[0]}</a></p>} +            if @output[lng][:html_mnt].class==File +              @output[lng][:html_mnt] << x +            end +            @output[lng][:html] << x +            works=[] +            a[1][:md].each do |x| +              if @env.output_dir_structure.by_language_code? +                manifest_pth="#{@env.path.output}/#{x[:file]}" +                manifest_at=x[:file] + '.html' +              elsif @env.output_dir_structure.by_filetype? +                manifest_name=x[:file] +                manifest_at=x[:file] + '.' + lng +  '.html' +              elsif @env.output_dir_structure.by_filename? +                manifest_at="../#{x[:file]}/#{x[:page]}" +              end +              work=[ "#{x[:date]} #{x[:title]}", %{<p class="publication">#{x[:date]} <a href="#{manifest_at}">#{x[:title]}</a>, #{x[:author][:authors_s]}</p>} ] +              works<<=(@output[lng][:html_mnt].class==File) \ +              ? (work.concat([%{<p class="publication">[<a href="#{x[:file]}.sst">src</a>]  #{x[:date]} <a href="file://#{manifest_at}">#{x[:title]}</a>, #{x[:author][:authors_s]} -- [<a href="#{x[:file]}.sst">#{x[:file]}.sst</a>]</p>}])) \ +              : work +            end +            works.sort_by {|x| x[0]}.each do |x| +              @output[lng][:html] << x[1] +              @output[lng][:html_mnt] << x[2] if @output[lng][:html_mnt].class==File              end -            work=[ "#{x[:date]} #{x[:title]}", %{<p class="publication">#{x[:date]} <a href="#{manifest_at}">#{x[:title]}</a>, #{x[:author][:authors_s]}</p>} ] -            works<<=(@output[:html_mnt].class==File) \ -            ? (work.concat([%{<p class="publication">[<a href="#{x[:file]}.sst">src</a>]  #{x[:date]} <a href="file://#{manifest_at_local}">#{x[:title]}</a>, #{x[:author][:authors_s]} -- [<a href="#{x[:file]}.sst">#{x[:file]}.sst</a>]</p>}])) \ -            : work -          end -          works.sort_by {|x| x[0]}.each do |x| -            @output[:html] << x[1] -            @output[:html_mnt] << x[2] if @output[:html_mnt].class==File            end          end        end diff --git a/lib/sisu/v3/harvest_topics.rb b/lib/sisu/v3/harvest_topics.rb index 3ca72326..c3204de9 100644 --- a/lib/sisu/v3/harvest_topics.rb +++ b/lib/sisu/v3/harvest_topics.rb @@ -60,47 +60,46 @@  =end  module HARVEST_topics    require_relative 'author_format'                      # author_format.rb +  include SiSU_Viz    class Songsheet -    def initialize(opt) -      @opt=opt +    @@the_idx_topics={} +    def initialize(opt,env) +      @opt,@env=opt,env        @file_list=opt.files -      @env=SiSU_Env::Info_env.new      end      def songsheet -      files,idx_array=[],[] -      @file_list.each do  |f| -        (f =~/.+?\.ss[tm]$/) \ -        ? (files << f[/(.+?\.ss[tm])$/,1]) \ -        : (print "not .sst or .ssm ? << #{f} >> ") -      end -      files.each do |filename| -        file_array=[] +      puts 'topics:' +      idx_array={} +      @opt.f_pths.each do |y| +        lang_hash_file_array={} +        name=y[:f]  +        filename=y[:pth] + '/' + y[:f]           File.open(filename,'r') do |file|            file.each_line("\n\n") do |line|              if line =~/^@(?:title|creator|classify):(?:\s|$)/m -              file_array << line +              lang_hash_file_array[y[:lng_is]] ||= [] +              lang_hash_file_array[y[:lng_is]] << line              elsif line =~/^@\S+?:(?:\s|$)/m \              or line =~/^(?:\s*\n|%+ )/              else break              end            end          end -        idx_array=HARVEST_topics::Harvest.new(@opt,file_array,filename,idx_array).extract_harvest +        lang_hash_file_array.each_pair do |lang,a| +          idx_array[lang] ||= [] +          idx_array=HARVEST_topics::Harvest.new(@opt,@env,a,filename,name,idx_array,lang).extract_harvest +        end        end -      the_idx=HARVEST_topics::Index.new(idx_array,@@the_idx_topics).construct_book_topic_index -      #HARVEST_topics::Output_index.new('',the_idx).screen_print.cycle if @opt.cmd.inspect =~/[VM]/ +      the_idx=HARVEST_topics::Index.new(@opt,@env,idx_array,@@the_idx_topics).construct_book_topic_index        HARVEST_topics::Output_index.new(@opt,the_idx).html_print.html_songsheet -      harvest_pth="#{@env.path.webserv}/#{@env.stub_md_harvest}" -      puts "file://#{harvest_pth}/harvest_topics.html" -      puts "file://#{@env.path.pwd}/harvest_topics.html" if @opt.cmd.inspect =~/M/      end    end    class Harvest -    def initialize(opt,data,filename,idx_array) -      @opt,@data,@filename,@idx_array=opt,data,filename,idx_array +    def initialize(opt,env,data,filename,name,idx_array,lang) +      @opt,@env,@data,@filename,@name,@idx_array,@lang=opt,env,data,filename,name,idx_array,lang      end      def extract_harvest -      data,filename,idx_array=@data,@filename,@idx_array +      data,filename,name,idx_array,lang=@data,@filename,@name,@idx_array,@lang        @idx_lst,@title,@subtitle,@fulltitle,@author,@author_format=nil,nil,nil,nil,nil,nil        rgx={}        rgx[:author]=/^@creator:(?:[ ]+|.+?:author:[ ]+)(.+?)(?:\||\n)/m @@ -128,118 +127,130 @@ module HARVEST_topics        and @idx_list          creator=FORMAT::Author.new(@author_format.strip).author_details          @authors,@authorship=creator[:authors],creator[:authorship] -        file=if filename=~/~[a-z]{2,3}\.ss[mt]$/ -          lang='.' + /~([a-z]{2,3})\.ss[mt]$/.match(filename)[1] -          filename.sub(/~[a-z]{2,3}\.ss[mt]$/,'') +        file=if name=~/~[a-z]{2,3}\.ss[mt]$/ +          name.sub(/~[a-z]{2,3}\.ss[mt]$/,'') +        else +          name.sub(/\.ss[mt]$/,'') +        end +        page=if @env.output_dir_structure.by_language_code? +          #fix +        end +        page=if @env.output_dir_structure.by_language_code? +          "#{lang}/sisu_manifest.html"          else -          lang='' -          filename.sub(/\.ss[mt]$/,'') +          "sisu_manifest.#{lang}.html"          end -        page="sisu_manifest#{lang}.html" -        idx_array <<=if @idx_list =~/;/ +        idx_array[lang] <<=if @idx_list =~/;/            g=@idx_list.scan(/[^;]+/)            idxl=[]            g.each do |i|              i.strip! -            idxl << { filename: filename, file: file, rough_idx: i, title: @fulltitle, author: creator, page: page } +            idxl << { filename: filename, file: file, rough_idx: i, title: @fulltitle, author: creator, page: page, lang: lang  }            end            idxl -        else { filename: filename, file: file, rough_idx: @idx_list, title: @fulltitle, author: creator, page: page } +        else { filename: filename, file: file, rough_idx: @idx_list, title: @fulltitle, author: creator, page: page, lang: lang  }          end        else          p "missing required field in #{@filename} - [title]: <<#{@title}>>; [author]: <<#{@author_format}>>; [idx]: <<#{@idx_list}>>" if @opt.cmd.inspect =~/[VM]/        end -      idx_array.flatten! +      idx_array[lang].flatten!        idx_array      end    end    class Index -    def initialize(idx_array,the_idx) -      @idx_array,@the_idx=idx_array,the_idx +    def initialize(opt,env,idx_array,the_idx) +      @opt,@env,@idx_array,@the_idx=opt,env,idx_array,the_idx        @@the_idx_topics=@the_idx      end      def capital(txt)        txt[0].chr.capitalize + txt[1,txt.length]      end -    def contents(hash,idx) +    def contents(lang,hash,idx)        names=''        idx[:author][:last_first_format_a].each do |n|          s=n.sub(/(.+?)(?:,.+|$)/,'\1').gsub(/\s+/,'_') -        names += %{<a href="harvest_authors.html##{s}">#{n}</a>, } +        names=if @env.output_dir_structure.by_language_code? +          names += %{<a href="authors.html##{s}">#{n}</a>, } +        else +          names += %{<a href="authors.#{lang}.html##{s}">#{n}</a>, } +        end        end        hash << { filename: idx[:filename], file: idx[:file], author: names, title: idx[:title], page: idx[:page] }      end      def construct_book_topic_index        idx_array=@idx_array -      idx_array.each do |idx| -        @lv0,@lv1,@lv2,@lv3,@lv4={},{},{},{},{} -        if idx[:rough_idx] -          idx_lst=idx[:rough_idx].scan(/[^:]+/) -        else -          puts "no topic register in: << #{idx[:filename]} >>" -          next -        end -        idx_lst_alt=[] -        idx_lst.each {|lev| idx_lst_alt << lev.scan(/[^|]+/)} -        depth = idx_lst_alt.length - 1 -        range = 0..depth -        range.each do |t| -          if idx_lst_alt[t] -            case t -            when 0 -              lev0=idx_lst_alt[t] -              lev0.each do |lv0| -                lv0=capital(lv0) -                if @@the_idx_topics[lv0].class==NilClass -                  @@the_idx_topics[lv0]={ md: [] } +      idx_array.each_pair do |lang,idx_array| +        @@the_idx_topics[lang] ||= {} +        idx_array.each do |idx| +          @lv0,@lv1,@lv2,@lv3,@lv4={},{},{},{},{} +          if idx[:rough_idx] +            idx_lst=idx[:rough_idx].scan(/[^:]+/) +          else +            puts "no topic register in: << #{idx[:filename]} >>" +            next +          end +          idx_lst_alt=[] +          idx_lst.each {|lev| idx_lst_alt << lev.scan(/[^|]+/)} +          depth = idx_lst_alt.length - 1 +          range = 0..depth +          range.each do |t| +            if idx_lst_alt[t] +              case t +              when 0 +                lev0=idx_lst_alt[t] +                lev0.each do |lv0| +                  lv0=capital(lv0) +                  if @@the_idx_topics[lang][lv0].class==NilClass +                    @@the_idx_topics[lang][lv0]={ md: [] } +                  end +                  @lv0=lv0 if lev0.length==1 +                  j=@@the_idx_topics[lang][lv0][:md] +                  contents(lang,j,idx) if idx_lst_alt.length - 1 == t                  end -                @lv0=lv0 if lev0.length==1 -                j=@@the_idx_topics[lv0][:md] -                contents(j,idx) if idx_lst_alt.length - 1 == t -              end -            when 1 -              lev1=idx_lst_alt[t] -              lev1.each do |lv1| -                lv1=capital(lv1) -                if @@the_idx_topics[@lv0][lv1].class==NilClass -                  @@the_idx_topics[@lv0][lv1]={ md: [] } +              when 1 +                lev1=idx_lst_alt[t] +                lev1.each do |lv1| +                  lv1=capital(lv1) +                  if @@the_idx_topics[lang][@lv0][lv1].class==NilClass +                    @@the_idx_topics[lang][@lv0][lv1]={ md: [] } +                  end +                  @lv1=lv1 if lev1.length==1 +                  j=@@the_idx_topics[lang][@lv0][lv1][:md] +                  contents(lang,j,idx) if idx_lst_alt.length - 1 == t                  end -                @lv1=lv1 if lev1.length==1 -                j=@@the_idx_topics[@lv0][lv1][:md] -                contents(j,idx) if idx_lst_alt.length - 1 == t -              end -            when 2 -              lev2=idx_lst_alt[t] -              lev2.each do |lv2| -                lv2=capital(lv2) -                if @@the_idx_topics[@lv0][@lv1][lv2].class==NilClass -                  @@the_idx_topics[@lv0][@lv1][lv2]={ md: [] } +              when 2 +                lev2=idx_lst_alt[t] +                lev2.each do |lv2| +                  lv2=capital(lv2) +                  if @@the_idx_topics[lang][@lv0][@lv1][lv2].class==NilClass +                    @@the_idx_topics[lang][@lv0][@lv1][lv2]={ md: [] } +                  end +                  @lv2=lv2 if lev2.length==1 +                  j=@@the_idx_topics[lang][@lv0][@lv1][lv2][:md] +                  contents(lang,j,idx) if idx_lst_alt.length - 1 == t                  end -                @lv2=lv2 if lev2.length==1 -                j=@@the_idx_topics[@lv0][@lv1][lv2][:md] -                contents(j,idx) if idx_lst_alt.length - 1 == t -              end -            when 3 -              lev3=idx_lst_alt[t] -              lev3.each do |lv3| -                lv3=capital(lv3) -                if @@the_idx_topics[@lv0][@lv1][@lv2][lv3].class==NilClass -                  @@the_idx_topics[@lv0][@lv1][@lv2][lv3]={ md: [] } +              when 3 +                lev3=idx_lst_alt[t] +                lev3.each do |lv3| +                  lv3=capital(lv3) +                  if @@the_idx_topics[lang][@lv0][@lv1][@lv2][lv3].class==NilClass +                    @@the_idx_topics[lang][@lv0][@lv1][@lv2][lv3]={ md: [] } +                  end +                  @lv3=lv3 if lev3.length==1 +                  j=@@the_idx_topics[lang][@lv0][@lv1][@lv2][lv3][:md] +                  contents(lang,j,idx) if idx_lst_alt.length - 1 == t                  end -                @lv3=lv3 if lev3.length==1 -                j=@@the_idx_topics[@lv0][@lv1][@lv2][lv3][:md] -                contents(j,idx) if idx_lst_alt.length - 1 == t -              end -            when 4 -              lev4=idx_lst_alt[t] -              lev4.each do |lv4| -                lv4=capital(lv4) -                if @@the_idx_topics[@lv0][@lv1][@lv2][@lv3][lv4].class==NilClass -                  @@the_idx_topics[@lv0][@lv1][@lv2][@lv3][lv4]={ md: [] } +              when 4 +                lev4=idx_lst_alt[t] +                lev4.each do |lv4| +                  lv4=capital(lv4) +                  if @@the_idx_topics[lang][@lv0][@lv1][@lv2][@lv3][lv4].class==NilClass +                    @@the_idx_topics[lang][@lv0][@lv1][@lv2][@lv3][lv4]={ md: [] } +                  end +                  @lv4=lv4 if lev4.length==1 +                  j=@@the_idx_topics[lang][@lv0][@lv1][@lv2][@lv3][lv4][:md] +                  contents(lang,j,idx) if idx_lst_alt.length - 1 == t                  end -                @lv4=lv4 if lev4.length==1 -                j=@@the_idx_topics[@lv0][@lv1][@lv2][@lv3][lv4][:md] -                contents(j,idx) if idx_lst_alt.length - 1 == t                end              end            end @@ -249,25 +260,42 @@ module HARVEST_topics      end    end    class Output_index +    require_relative 'i18n'                               # i18n.rb +    require 'fileutils' +      include FileUtils      def initialize(opt,the_idx)        @opt,@the_idx=opt,the_idx        @env=SiSU_Env::Info_env.new -      @rc=Get_init.instance.sisu_yaml.rc +      @rc=SiSU_Env::Get_init.instance.sisu_yaml.rc        @alph=%W[9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z]        @letter=@alph.shift        @vz=SiSU_Env::Get_init.instance.skin      end      def html_file_open -      @output={} -      harvest_pth="#{@env.path.webserv}/#{@env.stub_md_harvest}" -      @output[:html]=File.new("#{harvest_pth}/harvest_topics.html",'w') -      if @opt.cmd.inspect =~/-M/ -        @output[:html_mnt]=File.new("#{@env.path.pwd}/harvest_topics.html",'w') +      @the_idx.keys.each do |lng| +        @output ||={} +        @output[lng] ||={} +        harvest_pth,file='','' +        if @env.output_dir_structure.by_language_code? +          harvest_pth="#{@env.path.webserv}/#{@opt.base_stub}/#{lng}/manifest" +          file="#{harvest_pth}/topics.html" +        else @env.output_dir_structure.by_filetype? +          harvest_pth="#{@env.path.webserv}/#{@opt.base_stub}/manifest" +          file="#{harvest_pth}/topics.#{lng}.html" +        end +        mkdir_p(harvest_pth) unless FileTest.directory?(harvest_pth) +        puts "file://#{file}" +        @output[lng][:html]=File.new(file,'w') +        if @opt.cmd.inspect =~/-M/ +          @output[lng][:html_mnt]=File.new("#{@env.path.pwd}/topics.html",'w') +        end        end      end      def html_file_close -      @output[:html].close -      @output[:html_mnt].close if @output[:html_mnt].class==File +      @the_idx.keys.each do |lng| +        @output[lng][:html].close +        @output[lng][:html_mnt].close if @output[lng][:html_mnt].class==File +      end      end      def html_print        def html_songsheet @@ -278,19 +306,36 @@ module HARVEST_topics          html_tail          html_file_close        end -      def html_head_adjust(type='') -        css_path=if @env.output_dir_structure.by_language_code? +      def html_head_adjust(lng,type='') +        css_path,authors='','' +        if @env.output_dir_structure.by_language_code?            css_path=(type !~/maintenance/) \            ? '../../_sisu/css/harvest.css' \            : 'harvest.css' +          authors='authors.html'          elsif @env.output_dir_structure.by_filetype?            css_path=(type !~/maintenance/) \            ? '../_sisu/css/harvest.css' \            : 'harvest.css' +          authors="authors.#{lng}.html"          elsif @env.output_dir_structure.by_filename?            css_path=(type !~/maintenance/) \            ? '../_sisu/css/harvest.css' \            : 'harvest.css' +          authors="authors.#{lng}.html" +        end +        ln=SiSU_i18n::Languages.new.language.list +        harvest_languages='' +        @the_idx.keys.each do |lng| +          if @env.output_dir_structure.by_language_code? +            harvest_pth="../../#{lng}/manifest" +            file="#{harvest_pth}/topics.html" +          else @env.output_dir_structure.by_filetype? +            harvest_pth='.' +            file="#{harvest_pth}/topics.#{lng}.html" +          end +          l=ln[lng][:t] +          harvest_languages += %{<a href="#{file}">#{l}</a>   }          end          sv=SiSU_Env::Info_version.instance.get_version          <<WOK @@ -312,29 +357,35 @@ module HARVEST_topics  <a name="up" id="up"></a>  <a name="start" id="start"></a>  <h1>SiSU Metadata Harvest - Topics</h1> -<p>[<a href="../index.html"> HOME </a>] also see <a href="harvest_authors.html">SiSU Metadata Harvest - Authors</a></p> +<p>[<a href="../index.html"> HOME </a>] also see <a href="#{authors}">SiSU Metadata Harvest - Authors</a></p>  <p>#{@env.widget_static.search_form}</p>  <hr /> +<p class="tiny">#{harvest_languages}</p> +<hr />  WOK        end        def html_head -        @output[:html_mnt] << html_head_adjust('maintenance') if @opt.cmd.inspect =~/M/ -        @output[:html] << html_head_adjust +        @the_idx.keys.each do |lng| +          @output[lng][:html_mnt] << html_head_adjust(lng,'maintenance') if @opt.cmd.inspect =~/M/ +          @output[lng][:html] << html_head_adjust(lng) +        end        end        def html_alph          a=[]          a << '<p>'          @alph.each do |x| -          a << (x =~/[0-9]/) \ +          a << ((x =~/[0-9]/) \            ? '' \ -          : %{<a href="##{x}">#{x}</a>, } +          : %{<a href="##{x}">#{x}</a>, }) +        end +        a=a.join +        @the_idx.keys.each do |lng| +          @output[lng][:html_mnt] << a if @opt.cmd.inspect =~/M/ +          @output[lng][:html] << a          end -        @output[:html_mnt] << a if @opt.cmd.inspect =~/M/ -        @output[:html] << a.join        end        def html_tail -        a=[] -        a <<<<WOK +        a =<<WOK  <hr />  <a name="bottom" id="bottom"></a>  <a name="down" id="down"></a> @@ -346,107 +397,116 @@ WOK  </body>  </html>  WOK -        @output[:html_mnt] << a if @output[:html_mnt].class==File -        @output[:html] << a +        @the_idx.keys.each do |lng| +          @output[lng][:html_mnt] << a if @output[lng][:html_mnt].class==File +          @output[lng][:html] << a +        end        end -      def do_html(html) -        @output[:html] << html +      def do_html(lng,html) +        @output[lng][:html] << html        end -      def do_html_maintenance(html) -        @output[:html_mnt] << html if @output[:html_mnt].class==File +      def do_html_maintenance(lng,html) +        @output[lng][:html_mnt] << html if @output[lng][:html_mnt].class==File        end -      def do_string(attrib,string) +      def do_string(lng,attrib,string)          html=%{<p class="#{attrib}">#{string}</p>} -        do_html(html) -        do_html_maintenance(html) if @output[:html_mnt].class==File +        do_html(lng,html) +        do_html_maintenance(lng,html) if @output[lng][:html_mnt].class==File        end -      def do_string_default(attrib,string) +      def do_string_default(lng,attrib,string)          html=%{<p class="#{attrib}">#{string}</p>} -        do_html(html) +        do_html(lng,html)        end -      def do_string_maintenance(attrib,string) +      def do_string_maintenance(lng,attrib,string)          html=%{<p class="#{attrib}">#{string}</p>} -        do_html_maintenance(html) if @output[:html_mnt].class==File +        do_html_maintenance(lng,html) if @output[lng][:html_mnt].class==File        end -      def do_string_name(attrib,string) +      def do_string_name(lng,attrib,string)          f=/^(\S)/.match(string)[1]          if @letter < f            while @letter < f              if @alph.length > 0                @letter=@alph.shift -              if @output[:html_mnt].class==File -                @output[:html_mnt] << %{\n<p class="letter"><a name="#{@letter}">#{@letter}</a></p><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>} +              if @output[lng][:html_mnt].class==File +                @output[lng][:html_mnt] << %{\n<p class="letter"><a name="#{@letter}">#{@letter}</a></p><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>}                end -              @output[:html] << %{\n<p class="letter"><a name="#{@letter}">#{@letter}</a></p><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>} +              @output[lng][:html] << %{\n<p class="letter"><a name="#{@letter}">#{@letter}</a></p><p class="book_index_lev1"><a name="#{@letter.downcase}"></a></p>}              else break              end            end          end          name=string.strip.gsub(/\s+/,'_')          html=%{<p class="#{attrib}"><a name="#{name}">#{string}</a></p>} -        do_html(html) -        do_html_maintenance(html) if @output[:html_mnt].class==File +        do_html(lng,html) +        do_html_maintenance(lng,html) if @output[lng][:html_mnt].class==File        end -      def do_array(lv,array) +      def do_array(lng,lv,array)          lv+=1          array.each do |b| -          do_case(lv,b) +          do_case(lng,lv,b)          end        end -      def do_hash_md(attrib,hash) +      def do_hash_md(lng,attrib,hash)          if @env.output_dir_structure.by_language_code? -          manifest_at=hash[:file] + '.manifest.html' +          manifest_at=hash[:file] + '.html'          elsif @env.output_dir_structure.by_filetype? -          manifest_at=hash[:file] + '.manifest.html' +          manifest_at=hash[:file] + '.' + lng +  '.html'          elsif @env.output_dir_structure.by_filename?            manifest_at="../#{hash[:file]}/#{hash[:page]}"          end          html=%{<a href="#{manifest_at}">#{hash[:title]}</a> - #{hash[:author]}} -        do_string_default(attrib,html) +        do_string_default(lng,attrib,html)        end -      def do_hash_md_maintenance(attrib,hash) -        if @output[:html_mnt].class==File #should not be run for presentation output +      def do_hash_md_maintenance(lng,attrib,hash) +        if @output[lng][:html_mnt].class==File #should not be run for presentation output            html=%{[<a href="#{hash[:file]}.sst">src</a>]  <a href="file://#{@env.path.output}/#{hash[:file]}/#{hash[:page]}">#{hash[:title]}</a> - #{hash[:author]}} -          do_string_maintenance(attrib,html) +          do_string_maintenance(lng,attrib,html)          end        end -      def do_hash(lv,hash) +      def do_hash(lng,lv,hash)          lv+=1          key=[]          hash.each_key do |m|            if m == :md -            do_case(lv,hash[m]) -          elsif m != :title and m != :author and m != :filename and m != :file and m != :rough_idx and m != :page +            do_case(lng,lv,hash[m]) +          elsif m != :title \ +          and m != :author \ +          and m != :filename \ +          and m != :file \ +          and m != :rough_idx \ +          and m != :page              key << m            elsif m == :title -            do_hash_md('work',hash) -            do_hash_md_maintenance('work',hash) +            do_hash_md(lng,'work',hash) +            do_hash_md_maintenance(lng,'work',hash)            end          end          if key.length > 0            key.sort.each do |m|              attrib="lev#{lv}" -            lv==0 ? do_string_name(attrib,m) : do_string(attrib,m) -            do_case(lv,hash[m]) +            lv==0 ? do_string_name(lng,attrib,m) : do_string(lng,attrib,m) +            do_case(lng,lv,hash[m])            end          end        end -      def do_case(lv,a) +      def do_case(lng,lv,a)          y = a.class          case          when y==String            attrib="lev#{lv}" -          lv==0 ? do_string_name(attrib,a) : do_string(attrib,a) +          lv==0 ? do_string_name(lng,attrib,a) : do_string(lng,attrib,a)          when y==Array -          do_array(lv,a) +          do_array(lng,lv,a)          when y==Hash -          do_hash(lv,a) +          do_hash(lng,lv,a)          end        end        def html_body          the_idx=@the_idx -        the_idx.sort.each do |a| -          do_case(-1,a) +        the_idx.each_pair do |lng,lng_array| +          lng_array.sort.each do |a| +            do_case(lng,-1,a) +          end          end        end        self @@ -456,102 +516,116 @@ WOK          s=' '*4          puts s*lv + string        end -      def do_array(lv,array) +      def do_array(lng,lv,array)          lv+=1          array.each do |b| -          do_case(lv,b) +          do_case(lng,lv,b)          end        end -      def do_hash_md(lv,hash) +      def do_hash_md(lng,lv,hash)          string=hash[:title] + ' - ' + hash[:author] -        do_string(lv,string) +        do_string(lng,lv,string)        end -      def do_hash(lv,hash) +      def do_hash(lng,lv,hash)          lv+=1          key=[]          hash.each_key do |m|            if m == :md -            do_case(lv,hash[m]) -          elsif m != :title and m != :author and m != :filename and m != :file and m != :rough_idx and m != :page +            do_case(lng,lv,hash[m]) +          elsif m != :title \ +          and m != :author \ +          and m != :filename \ +          and m != :file \ +          and m != :rough_idx \ +          and m != :page              key << m            elsif m == :title -            do_hash_md(lv,hash) +            do_hash_md(lng,lv,hash)            end          end          if key.length > 0            key.sort.each do |m| -            do_string(lv,m) -            do_case(lv,hash[m]) +            do_string(lng,lv,m) +            do_case(lng,lv,hash[m])            end          end        end -      def do_case(lv,a) +      def do_case(lng,lv,a)          s=' '*4          y = a.class          case          when y==String -          do_string(lv,a) +          do_string(lng,lv,a)          when y==Array -          do_array(lv,a) +          do_array(lng,lv,a)          when y==Hash -          do_hash(lv,a) +          do_hash(lng,lv,a)          end        end        def cycle          the_idx=@the_idx -        the_idx.each do |a| -          do_case(-1,a) +        the_idx.keys.each do |lng| +          the_idx[lng].each do |a| +            do_case(lng,-1,a) +          end          end        end        self      end      def screen_print_unsorted -      def do_string(lv,string) +      def do_string(lng,lv,string)          s=' '*4          puts s*lv + string        end -      def do_array(lv,array) +      def do_array(lng,lv,array)          lv+=1          array.each do |b| -          do_case(lv,b) +          do_case(lng,lv,b)          end        end -      def do_hash_md(lv,hash) +      def do_hash_md(lng,lv,hash)          string=hash[:title] + ' - ' + hash[:author] -        do_string(lv,string) +        do_string(lng,lv,string)        end -      def do_hash(lv,hash) +      def do_hash(lng,lv,hash)          lv+=1          hash.each_key do |m|            if m == :md -            do_case(lv,hash[m]) +            do_case(lng,lv,hash[m])            else -            if m != :title and m != :author and m != :filename and m != :file and m != :rough_idx and m != :page -              do_string(lv,m) -              do_case(lv,hash[m]) +            if m != :title \ +            and m != :author \ +            and m != :filename \ +            and m != :file \ +            and m != :rough_idx \ +            and m != :page +              do_string(lng,lv,m) +              do_case(lng,lv,hash[m])              elsif m == :title -              do_hash_md(lv,hash) +              do_hash_md(lng,lv,hash)              else              end            end          end        end -      def do_case(lv,a) +      def do_case(lng,lv,a)          s=' '*4          y = a.class          case          when y==String -          do_string(lv,a) +          do_string(lng,lv,a)          when y==Array -          do_array(lv,a) +          do_array(lng,lv,a)          when y==Hash -          do_hash(lv,a) +          do_hash(lng,lv,a)          end        end        def cycle          the_idx=@the_idx -        the_idx.each do |a| -          do_case(-1,a) +        the_idx.keys.each do |lng| +          the_idx[lng].each do |a| +            do_case(lng,-1,a) +          end          end        end        self diff --git a/lib/sisu/v3/help.rb b/lib/sisu/v3/help.rb index 477e93e9..27822e20 100644 --- a/lib/sisu/v3/help.rb +++ b/lib/sisu/v3/help.rb @@ -61,6 +61,7 @@ module SiSU_Help      include SiSU_Screen    require_relative 'param'                              # param.rb    class Help +     require_relative 'i18n'                             # i18n.rb      def initialize(request='',color='')        @request,@color=request,color        if color =~/color_off/; @cX=SiSU_Screen::Ansi.new('k').cX @@ -637,7 +638,7 @@ This is a sample header (#{@cX.fuschia}Dublin Core in fuschia,#{@cX.off} #{@cX.c  #{@cX.fuschia}@source:#{@cX.off} -#{@cX.fuschia}@language:#{@cX.off} [or @language.document:] [country code for language if available, or language, English, en is the default setting] (en - English, fr - French, de - German, it - Italian, es - Spanish, pt - Portuguese, sv - Swedish, da - Danish, fi - Finnish, no - Norwegian, is - Icelandic, nl - Dutch, et - Estonian, hu - Hungarian, pl - Polish, ro - Romanian, ru - Russian, el - Greek, uk - Ukranian, tr - Turkish, sk - Slovak, sl - Slovenian, hr - Croatian, cs - Czech, bg - Bul garian ) [however, encodings are not available for all of the languages listed.] +#{@cX.fuschia}@language:#{@cX.off} [or @language.document:] [country code for language if available, or language, English, en is the default setting] (en - English, fr - French, de - German, it - Italian, es - Spanish, pt - Portuguese, sv - Swedish, da - Danish, fi - Finnish, no - Norwegian, is - Icelandic, nl - Dutch, et - Estonian, hu - Hungarian, pl - Polish, ro - Romanian, ru - Russian, el - Greek, uk - Ukranian, tr - Turkish, sk - Slovak, sl - Slovenian, hr - Croatian, cs - Czech, bg - Bulgarian ) [however, encodings are not available for all of the languages listed.]  #{@cX.fuschia}@language.original:#{@cX.off}  original language in which the work was published @@ -1163,12 +1164,27 @@ on the positive side: (a) the A,B,C,1,2,3 alternative makes explicit an aspect o  WOK      end      def languages -    puts <<WOK +      lang=SiSU_i18n::Languages.new.language.table +      lang.each_value do |lng| +        if lng[:t] == lng[:n] +          puts "#{lng[:c]}:  #{lng[:t]}" +        else +          puts "#{lng[:c]}:  #{lng[:t]} (#{lng[:n]})" +        end +      end +      puts <<WOK + + Multi-language Document File Naming and Directory Mapping + + A list of language codes and languages that may be available for most output formats. These are for the most part ISO 639/1 and where there is a departure it follows those made by po4a, and the languages supported will be limited (at this time) to those supported by polyglossia. (SiSU markup text is stored in Unicode so some output formats are served by this, for example, html and sql had no problem with Chinese, pdfs would be a problem as this is not (yet?) suported by xetex and polyglossia. SiSU parses left to right and would have problems with right to left languages.) -    Multi-language Document File Naming and Directory Mapping + If the same document exists in different language versions, a directory structure, or a filenaming convention may be followed. Using Spannish as the sample language code (es) [filename]~[language code].sst -    If the same document exists in different language versions, and it is desired that the published language versions should reside in the same output directory, the following filenaming convention should be observed, using Spannish as the sample language code (es) [it is very likley the use of country codes as language codes will be changed or extended in future] [filename]~[language code].sst + The simplest now is to place each document in a sub-directory which has the language code as a name, if this convention is used it is preferable that all files are placed by language in the appropriate language sub-directory ... e.g. +   ./en/filename.sst +   ./es/filename.sst + Alternatively files may all be placed in the same directory with the language and named using a tilde and the language code as shown:    filename~es.sst    within sisurc.yml under the heading diff --git a/lib/sisu/v3/html.rb b/lib/sisu/v3/html.rb index d586c25d..d77d3df6 100644 --- a/lib/sisu/v3/html.rb +++ b/lib/sisu/v3/html.rb @@ -652,10 +652,13 @@ WOK            ## only works properly for directory_structure_by language, fix            unless FileTest.file?("#{@file.output_path.html.dir}/index.html")              pwd_set=Dir.pwd +            idx_lnk=@file.base_filename.html_segtoc +            mlnk='index.html'              Dir.chdir(@file.output_path.html.dir) -              system(" -                ln -s #{@file.base_filename.html_segtoc} index.html -              ") +            system(" +              rm #{mlnk} +              ln -s #{idx_lnk} #{mlnk} +            ")              Dir.chdir(pwd_set)            end          end diff --git a/lib/sisu/v3/hub.rb b/lib/sisu/v3/hub.rb index 5eac0b03..7b847d4f 100644 --- a/lib/sisu/v3/hub.rb +++ b/lib/sisu/v3/hub.rb @@ -290,13 +290,13 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/        end        if @opt.act[:harvest]          require_relative 'harvest'                      # harvest.rb +        SiSU_Harvest::Source.new(@opt).read             # -h -H  html.rb        elsif @opt.mod.inspect =~/--convert|--to|--from/          require_relative 'sst_convert_markup'           # sst_convert_markup.rb        elsif @opt.cmd =~/([AabCcDdeFfGgHhIiJjkLMmNnOoPpQqRrSsTtUuVvwWXxYyZ_0-9])/ \        and @opt.cmd =~/^-/ \        and @opt.mod.inspect !~/--(?:sitemaps|query|identify)/ \        or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ -        @@tell=SiSU_Screen::Ansi.new(@opt.cmd)          @cX=SiSU_Screen::Ansi.new(@opt.cmd).cX          flag=SiSU_Env::Info_processing_flag.new          if @opt.cmd =~/[vVM]/                              #% version information diff --git a/lib/sisu/v3/manifest.rb b/lib/sisu/v3/manifest.rb index 0c6d5460..a21b31f9 100644 --- a/lib/sisu/v3/manifest.rb +++ b/lib/sisu/v3/manifest.rb @@ -152,7 +152,7 @@ module SiSU_Manifest          url=@f.output_path.base.url          manifests={}          mp,mn,mt,mr=nil,nil,nil,nil -        ln=SiSU_i18n::Languages.new.list +        ln=SiSU_i18n::Languages.new.language.list          Px[:lng_lst].each do |lc|            if @env.output_dir_structure.by_language_code?              mp="#{@f.output_path.base.dir}/#{lc}/manifest" diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb index 96ec3c4a..81d12db8 100644 --- a/lib/sisu/v3/options.rb +++ b/lib/sisu/v3/options.rb @@ -62,14 +62,17 @@ module SiSU_commandline    require_relative 'sysenv'                             # sysenv.rb    @@base_path=nil    class Options -    attr_accessor :cmd,:mod,:act,:dir_structure_by,:f_pths,:files,:base_path,:paths,:lngs,:f_pth,:pth,:fns,:fnb,:fnc,:fncb,:lng,:what +    attr_accessor :cmd,:mod,:act,:dir_structure_by,:f_pths,:files,:base_path,:base_stub,:paths,:lngs,:f_pth,:pth,:fns,:fnb,:fnc,:fncb,:lng,:what      def initialize(a) -      @cmd,@f_pth,@pth,@fns,@fnb,@fnc,@fncb,@what,@lng,@base_path='','','','','','','','','','','' +      @cmd,@f_pth,@pth,@fns,@fnb,@fnc,@fncb,@what,@lng,@base_path,@base_stub='','','','','','','','','','','',''        @f_pths,@files,@paths,@mod,@act=Array.new(5){[]}        @env=SiSU_Env::Info_env.new        @dir_structure_by=SiSU_Env::Env_call.new.output_dir_structure.by?        @@base_path ||=Dir.pwd        @base_path=@@base_path +      r=Px[:lng_lst].join('|') +      u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/ +      @base_stub=@base_path.gsub(u,'\1')        @a=sisu_glob_rules(a)        @a.freeze        init @@ -97,7 +100,6 @@ module SiSU_commandline              else                Dir.glob("*#{g}*.ss[tm]")              end -              Px[:lng_lst].each do |d|                if FileTest.directory?(d)                  x <<=if g =~/.ss[tm]/ @@ -113,40 +115,40 @@ module SiSU_commandline       end      end      def sisu_glob_rules(a) -      b=[] -      f=[] -      find_flag=false -      a.each do |y| -        if y =~ /^-/ \ -        or y =~ /\.ss[tm]$/ -          if y =~/^-/ \ -          && y =~/[fG]|--find|--glob/ -            find_flag=true +      a=if a.inspect =~/"-\S*[fG]/ \ +      or a.inspect =~/"--find"|"--glob"/ +        b,f=[],[] +        find_flag=false +        a.each do |y| +          if y =~ /^-/ +            if y =~/^-/ \ +            && y =~/[fG]|--find|--glob/ +              find_flag=true +            end +            b << y +          end +          if find_flag \ +          && y !~ /^-/ \ +          && y =~ /\S+/ +            f << y            end -          b << y -        end -        if find_flag \ -        && y !~ /^-/ \ -        && y =~ /\S+/ -          f << y -        elsif y =~ /^-/ -          b << y          end -      end -      r=Px[:lng_lst].join('|') -      r.gsub!(/\|en\|/,'|') -      @lang_regx=%r{(?:#{r})} -      z=if find_flag -        if f.length > 0 -          b + find_select(find_flag,f) -        else -          find_all(find_flag,b) +        r=Px[:lng_lst].join('|') +        r.gsub!(/\|en\|/,'|') +        @lang_regx=%r{(?:#{r})} +        z=if find_flag +          if f.length > 0 +            b + find_select(find_flag,f) +          else +            find_all(find_flag,b) +          end +        elsif a.inspect =~/"(?:-\S+?|--\S+?)"/ \ +        && a.inspect =~/"#{@lang_regx}\/?"/ \ +        && a.inspect =~/"en\/\S+?\.ss[tm]"/ +          init_selected_lang_dirs(a) +        else b          end -      elsif a.inspect =~/"(?:-\S+?|--\S+?)"/ \ -      && a.inspect =~/"#{@lang_regx}\/?"/ \ -      && a.inspect =~/"en\/\S+?\.ss[tm]"/ -        init_selected_lang_dirs(a) -      else b +      else a        end      end      def init_selected_lang_dirs(a) @@ -164,20 +166,22 @@ module SiSU_commandline      end      def init        a=@a -      s=expand_numeric_shortcuts(a) -      q=set_files_and_paths_and_general_extract(s) -      @cmd,@mod=opt_cmd_and_mod_adjust(q[:cmd],q[:mod]) -      @what=q[:what] unless q[:what].empty? -      @paths = q[:paths] -      @files = q[:files] -      @f_pths = q[:f_pths] -      @lngs = q[:lngs] -      if @files.length > 0 \ -      and @cmd.empty? \ -      and @mod.length==0 #% if no other action called on filename given, default is sisu -0 [filename(s)] configured as flag default -        @cmd=shortcut.cf_0 -      end -      SiSU_Screen::Ansi.new(@cmd,"\tsisu " + @cmd +  ' ' + @mod.join(' ') + ' ' + @files.join(' ') + "\n").print_brown if @cmd =~/[vVM]/ +      if a.length > 0 +        s=expand_numeric_shortcuts(a) +        q=set_files_and_paths_and_general_extract(s) +        @cmd,@mod=opt_cmd_and_mod_adjust(q[:cmd],q[:mod]) +        @what=q[:what] unless q[:what].empty? +        @paths = q[:paths] +        @files = q[:files] +        @f_pths = q[:f_pths] +        @lngs = q[:lngs] +        if @files.length > 0 \ +        and @cmd.empty? \ +        and @mod.length==0 #% if no other action called on filename given, default is sisu -0 [filename(s)] configured as flag default +          @cmd=shortcut.cf_0 +        end +        SiSU_Screen::Ansi.new(@cmd,"\tsisu " + @cmd +  ' ' + @mod.join(' ') + ' ' + @files.join(' ') + "\n").print_brown if @cmd =~/[vVM]/ +      end  #     @files.uniq!        @act=opt_act        @files @@ -187,7 +191,7 @@ module SiSU_commandline        c,w='',''        m,f,pth,z,lng,lngs=[],[],[],[],[],[]        a=s.split(/\s+/) -      a.each do |x| +      a.uniq.each do |x|          if x =~/^-[a-z0-5]+/i \          or x =~/^--\S+/            if x =~/^-([a-z0-5]+)/i; c << $1 @@ -215,13 +219,20 @@ module SiSU_commandline                $1              else 'en'              end +            lng_is =if l_p +              l_p +            elsif x =~/~(#{r})\.ss[tm]/ +              $1 +            else 'en' +            end              f_pths << {                pth: pt.split[0].realpath.to_s,                f: pt.split[1].to_s,                pth_stub: pt.split[0].realpath.to_s[u,1],                lng: (pt.split[0].realpath.to_s[t,1]) \                  ? pt.split[0].realpath.to_s[t,1] \ -                : nil +                : nil, +              lng_is: lng_is              }  #           Dir.chdir(pt.split[0].realpath)            else  puts "file not found: #{x}" diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index 5d35bf3d..22b711df 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -65,7 +65,6 @@ module SiSU_Param    require_relative 'help'                               # help.rb      include SiSU_Help    @@date=SiSU_Env::Info_date.new -  @@symlnk=Create_system_link.new    @@proc=@@filename_txt=@@filename_texinfo=@@filename_lout_portrait=@@filename_lout_landscape=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=nil    @doc={ initialise: nil, markup: '', lnks: '', stmp: '', req: {} }    @@yaml=@@yamladdr=nil @@ -1459,7 +1458,6 @@ module SiSU_Param    class Instantiate      def param_instantiate        @@date=SiSU_Env::Info_date.new -      @@symlnk=SiSU_Env::Create_system_link.new        @@proc=@@filename_txt=@@filename_texinfo=@@filename_lout_portrait=@@filename_lout_landscape=@@filename_html_scroll=@@filename_html_index=@@filename_html_segtoc=@@filename_semantic=@@filename_rss=@@newfile=@@drr=nil        @doc={         initialise: nil, diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 944df010..d0c88deb 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -1642,7 +1642,10 @@ WOK          "#{path.webserv}/#{images}"        end        def output                                                               #web/webserv output directory... subdirectory into which further subdirectories are made based on file names -        "#{path.webserv}/#{@stub_pwd}" +        r=Px[:lng_lst].join('|') +        u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/ +        base_stub=@sys.pwd.gsub(u,'\1') +        "#{path.webserv}/#{base_stub}"        end        def feed          (defined? @rc['webserv']['feed']) \ diff --git a/lib/sisu/v3/texpdf.rb b/lib/sisu/v3/texpdf.rb index eff07f19..918e00a2 100644 --- a/lib/sisu/v3/texpdf.rb +++ b/lib/sisu/v3/texpdf.rb @@ -249,11 +249,13 @@ module SiSU_TeX                  "#{@md.fnb}.landscape.pdf"                else 'landscape.pdf'                end +              pwd_set=Dir.pwd +              Dir.chdir(@md.file.output_path.pdf.dir)                system(" -                cd #{@md.file.output_path.pdf.dir}                  rm #{mklnk}                  ln -s #{pdf_l} #{mklnk}                ") +              Dir.chdir(pwd_set)              end            else              SiSU_Screen::Ansi.new(@md.opt.cmd,"FILE NOT FOUND: << #{@md.fns} >> - requested latex system processing skipped").warn | 
