diff options
| author | Ralph Amissah <ralph@amissah.com> | 2013-07-30 21:30:36 -0400 | 
|---|---|---|
| committer | Ralph Amissah <ralph@amissah.com> | 2013-07-30 21:30:39 -0400 | 
| commit | 3e58296fa7761edaa59f807d4f8e87987ea8e921 (patch) | |
| tree | d93286de4e7cba8462a71fa013d223cf84413e88 | |
| parent | v5: output structure by, add monolingual alt for :filetype & :filename, step 1 (diff) | |
v5: output structure by, monolingual alternative for :filetype or :filename
* filename without language code, if document is in default language
* set a default language, 'en' or as specified
* set in rc file or from command line instruction
  * command line e.g.
    sisu -hv --monolingual --by-filename sisu_markup.sst
    sisu -3v --monolingual --by-filetype sisu_manual.ssm
  * sisurc.yml lingual: 'mono' | 'multi'
    lingual: 'mono'
* note: output by :filetype is roughly equivalent to what monolingual output
  by :language would be
* allow command line setting of default language using language code
  --default-language='en' --default-lang-en if used together with
  --monolingual and --by-filetype or --by-filename the selected default
  language document will not have a language code in the output filename
| -rw-r--r-- | data/doc/sisu/CHANGELOG_v5 | 14 | ||||
| -rw-r--r-- | lib/sisu/v5/concordance.rb | 27 | ||||
| -rw-r--r-- | lib/sisu/v5/constants.rb | 17 | ||||
| -rw-r--r-- | lib/sisu/v5/dal_expand_insertions.rb | 141 | ||||
| -rw-r--r-- | lib/sisu/v5/harvest_authors.rb | 5 | ||||
| -rw-r--r-- | lib/sisu/v5/harvest_topics.rb | 5 | ||||
| -rw-r--r-- | lib/sisu/v5/html.rb | 31 | ||||
| -rw-r--r-- | lib/sisu/v5/html_minitoc.rb | 31 | ||||
| -rw-r--r-- | lib/sisu/v5/html_segments.rb | 14 | ||||
| -rw-r--r-- | lib/sisu/v5/sysenv.rb | 680 | 
10 files changed, 705 insertions, 260 deletions
| diff --git a/data/doc/sisu/CHANGELOG_v5 b/data/doc/sisu/CHANGELOG_v5 index 56307de2..f34a4537 100644 --- a/data/doc/sisu/CHANGELOG_v5 +++ b/data/doc/sisu/CHANGELOG_v5 @@ -31,6 +31,20 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_5.0.8.orig.tar.xz    sisu_5.0.8-1.dsc  * output structure by, add monolingual alternative for :filetype or :filename +  * filename without language code, if document is in default language +  * set a default language, 'en' or as specified +  * set in rc file or from command line instruction +    * command line e.g. +      sisu -hv --monolingual --by-filename sisu_markup.sst +      sisu -3v --monolingual --by-filetype sisu_manual.ssm +    * sisurc.yml lingual: 'mono' | 'multi' +      lingual: 'mono' +  * note: output by :filetype is roughly equivalent to what monolingual output +    by :language would be +  * allow command line setting of default language using language code +    --default-language='en' --default-lang-en if used together with +    --monolingual and --by-filetype or --by-filename the selected default +    language document will not have a language code in the output filename  %% 5.0.7.orig.tar.xz (2013-06-25:25/2)  http://sources.sisudoc.org/gitweb/?p=code/sisu.git;a=shortlog;h=refs/tags/sisu_5.0.7 diff --git a/lib/sisu/v5/concordance.rb b/lib/sisu/v5/concordance.rb index f2143bb8..48ac1aac 100644 --- a/lib/sisu/v5/concordance.rb +++ b/lib/sisu/v5/concordance.rb @@ -239,15 +239,26 @@ WOK          %{<a href="doc#{@md.lang_code_insert}#{Sfx[:html]}\##{wordlocation}">#{wordlocation}</a>;  }        end        def location_seg(wordlocation,show) ##fix -        @word_location_seg=wordlocation.gsub(/(.+?)\#(\d+)/,"\\1#{@md.lang_code_insert}#{Sfx[:html]}#\\2") unless wordlocation.nil?          case wordlocation -        when @rxp_t1 -          %{[<a href="doc#{@md.lang_code_insert}#{Sfx[:html]}##{show}">H</a>]#{show},  } -        when @rxp_t2 -          %{[<a href="doc#{@md.lang_code_insert}#{Sfx[:html]}##{show}">H</a>]#{show},  } -        when @rxp_t3 -          %{[<a href="doc#{@md.lang_code_insert}#{Sfx[:html]}##{show}">H</a>]#{show},  } -        else %{<a href="#{@word_location_seg}">#{show}</a>,  } +        when /@rxp_t1|@rxp_t2|@rxp_t3/ +          fnh={ +            fn: 'doc', +            lng: @md.lang_code_insert +          } +          fn=@md.file.base_filename.html_seg(fnh) +          %{[<a href="#{fn}##{show}">H</a>]#{show},  } +        else +          if not wordlocation.nil? \ +          and wordlocation =~ /(.+?)\#(\d+)/ +            seg,loc=/(.+?)\#(\d+)/.match(wordlocation)[1,2] +            fnh={ +              fn: seg, +              lng: @md.lang_code_insert +            } +            fn=@md.file.base_filename.html_seg(fnh) +            word_location_seg=%{#{fn}##{loc}} +            %{<a href="#{word_location_seg}">#{show}</a>,  } +          end          end        end        def map_para diff --git a/lib/sisu/v5/constants.rb b/lib/sisu/v5/constants.rb index d72049e9..6f9d4580 100644 --- a/lib/sisu/v5/constants.rb +++ b/lib/sisu/v5/constants.rb @@ -62,7 +62,22 @@  =end  #Ax,Xx,Mx,Rx,Hx,Dx,Px,Ep,Db,Gt,Tex=Array.new(11){{}}  YEAR='2013' -Sfx={ txt: '.txt', html: '.html', xhtml: '.xhtml', xml: '.xml', epub: '.epub', epub_xhtml: '.xhtml', odt: '.odt', pdf: '.pdf'} +Sfx={ +  txt: '.txt', +  html: '.html', +  xhtml: '.xhtml', +  xml: '.xml', +  xml_sax: '.sax.xml', +  xml_dom: '.dom.xml', +  epub: '.epub', +  epub_xhtml: '.xhtml', +  odt: '.odt', +  pdf: '.pdf', +  manpage: '.1', +  info: '.info', +  texinfo: '.texinfo', +  sql: '.sql.db', +}  Ax={    tab:                       "\t",  } diff --git a/lib/sisu/v5/dal_expand_insertions.rb b/lib/sisu/v5/dal_expand_insertions.rb index 77e4934c..d0595482 100644 --- a/lib/sisu/v5/dal_expand_insertions.rb +++ b/lib/sisu/v5/dal_expand_insertions.rb @@ -111,44 +111,66 @@ module SiSU_DAL_Insertions      def by_language(linked_doc,lng,src=nil)        @linked_doc,@lng,@src=linked_doc,lng,src        @base_path="#{@md.file.output_path.base.url}/#{@lng}" +      def fnh(ft) +        { +          fn: @linked_doc, +          ft: ft, +        } +      end +      def path_and_file(fn,pth) +        "#{@base_path}/#{pth}/#{fn}" +      end        def manifest -        "#{@base_path}/manifest/#{@linked_doc}.html" +        fn=@md.file.base_filename.manifest(fnh(Sfx[:html])) +        path_and_file(fn,'manifest')        end        def html_toc -        "#{@base_path}/html/#{@linked_doc}.html" +        fn=@md.file.base_filename.html_segtoc(fnh(Sfx[:html])) +        "#{@base_path}/html/#{@linked_doc}/#{fn}"        end        def html_doc -        "#{@base_path}/html/#{@linked_doc}.html" +        fn=@md.file.base_filename.html_scroll(fnh(Sfx[:html])) +        path_and_file(fn,'html')        end        def html_concordance -        "#{@base_path}/html/#{@linked_doc}.html" +        fn=@md.file.base_filename.html_concordance +        "#{@base_path}/html/#{@linked_doc}/#{fn}"        end        def epub -        "#{@base_path}/epub/#{@linked_doc}.epub" +        fn=@md.file.base_filename.epub(fnh(Sfx[:epub])) +        path_and_file(fn,'epub')        end        def pdf_landscape -        "#{@base_path}/pdf/#{@linked_doc}.pdf" +        fn=@md.file.base_filename.pdf_l_a4(fnh(Sfx[:pdf])) +        path_and_file(fn,'pdf')        end        def pdf_portrait -        "#{@base_path}/pdf/#{@linked_doc}.pdf" +        fn=@md.file.base_filename.pdf_p_a4(fnh(Sfx[:pdf])) +        path_and_file(fn,'pdf')        end        def odt -        "#{@base_path}/odt/#{@linked_doc}.odt" +        fn=@md.file.base_filename.odt(fnh(Sfx[:odt])) +        path_and_file(fn,'odt')        end        def xhtml -        "#{@base_path}/xhtml/#{@linked_doc}.xhtml" +        fn=@md.file.base_filename.xhtml(fnh(Sfx[:xhtml])) +        path_and_file(fn,'xhtml')        end        def xml_sax -        "#{@base_path}/xml/#{@linked_doc}.xml" +        fn=@md.file.base_filename.xml_sax(fnh(Sfx[:xml_sax])) +        path_and_file(fn,'xml_sax')        end        def xml_dom -        "#{@base_path}/xml/#{@linked_doc}.xml" +        fn=@md.file.base_filename.xml_dom(fnh(Sfx[:xml_dom])) +        path_and_file(fn,'xml_dom')        end        def txt -        "#{@base_path}/txt/#{@linked_doc}.txt" +        fn=@md.file.base_filename.txt(fnh(Sfx[:txt])) +        path_and_file(fn,'txt')        end        def digest -        "#{@base_path}/digest/#{@linked_doc}.txt" +        fn=@md.file.base_filename.hash_digest(fnh(Sfx[:txt])) +        path_and_file(fn,'digest')        end        def source          "#{@base_path}/src/#{@src}" @@ -161,44 +183,66 @@ module SiSU_DAL_Insertions      def by_filetype(linked_doc,lng,src=nil)        @linked_doc,@lng,@src=linked_doc,lng,src        @base_path="#{@md.file.output_path.base.url}" +      def fnh +        { +          fn: @linked_doc, +          lng: ".#{@lng}" +        } +      end +      def path_and_file(fn,pth) +        "#{@base_path}/#{pth}/#{fn}" +      end        def manifest -        "#{@base_path}/manifest/#{@linked_doc}.#{@lng}.html" +        fn=@md.file.base_filename.manifest(fnh) +        path_and_file(fn,'manifest')        end        def html_toc -        "#{@base_path}/html/#{@linked_doc}.#{@lng}.html" +        fn=@md.file.base_filename.html_segtoc(fnh) +        path_and_file(fn,'html')        end        def html_doc -        "#{@base_path}/html/#{@linked_doc}.#{@lng}.html" +        fn=@md.file.base_filename.html_scroll(fnh) +        path_and_file(fn,'html')        end        def html_concordance -        "#{@base_path}/html/#{@linked_doc}.#{@lng}.html" +        fn=@md.file.base_filename.html_concordance +        path_and_file(fn,'html')        end        def epub -        "#{@base_path}/epub/#{@linked_doc}.#{@lng}.epub" +        fn=@md.file.base_filename.epub(fnh) +        path_and_file(fn,'epub')        end        def pdf_landscape -        "#{@base_path}/pdf/#{@linked_doc}.#{@lng}.pdf" +        fn=@md.file.base_filename.pdf_l_a4(fnh) +        path_and_file(fn,'pdf')        end        def pdf_portrait -        "#{@base_path}/pdf/#{@linked_doc}.#{@lng}.pdf" +        fn=@md.file.base_filename.pdf_p_a4(fnh) +        path_and_file(fn,'pdf')        end        def odt -        "#{@base_path}/odt/#{@linked_doc}.#{@lng}.odt" +        fn=@md.file.base_filename.odt(fnh) +        path_and_file(fn,'odt')        end        def xhtml -        "#{@base_path}/xhtml/#{@linked_doc}.#{@lng}.xhtml" +        fn=@md.file.base_filename.xhtml(fnh) +        path_and_file(fn,'xhtml')        end        def xml_sax -        "#{@base_path}/xml_sax/#{@linked_doc}.#{@lng}.xml" +        fn=@md.file.base_filename.xml_sax(fnh) +        path_and_file(fn,'xml_sax')        end        def xml_dom -        "#{@base_path}/xml_dom/#{@linked_doc}.#{@lng}.xml" +        fn=@md.file.base_filename.xml_dom(fnh) +        path_and_file(fn,'xml_dom')        end        def txt -        "#{@base_path}/txt/#{@linked_doc}.#{@lng}.txt" +        fn=@md.file.base_filename.txt(fnh) +        path_and_file(fn,'txt')        end        def digest -        "#{@base_path}/digest/#{@linked_doc}.#{@lng}.txt" +        fn=@md.file.base_filename.hash_digest(fnh) +        path_and_file(fn,'digest')        end        def source          "#{@base_path}/src/#{@src}" @@ -211,44 +255,65 @@ module SiSU_DAL_Insertions      def by_filename(linked_doc,lng,src=nil)        @linked_doc,@lng,@src=linked_doc,lng,src        @base_path="#{@md.file.output_path.base.url}/#{@linked_doc}" +      def fnh +        { +          fn: @linked_doc, +          lng: ".#{@lng}" +        } +      end +      def path_and_file(fn) +        "#{@base_path}/#{fn}" +      end        def manifest -        "#{@base_path}/sisu_manifest.#{@lng}.html" +        fn=@md.file.base_filename.manifest(fnh) +        path_and_file(fn)        end        def html_toc -        "#{@base_path}/toc.#{@lng}.html" +        fn=@md.file.base_filename.html_segtoc(fnh) +        path_and_file(fn)        end        def html_doc -        "#{@base_path}/scroll.#{@lng}.html" +        fn=@md.file.base_filename.html_scroll(fnh) +        path_and_file(fn)        end        def html_concordance -        "#{@base_path}/concordance.#{@lng}.html" +        fn=@md.file.base_filename.html_concordance +        path_and_file(fn)        end        def epub          "#{@base_path}/epub/#{@linked_doc}.#{@lng}.epub"        end        def pdf_landscape -        "#{@base_path}/landscape.#{@lng}.a4.pdf" +        fn=@md.file.base_filename.pdf_l_a4(fnh) +        path_and_file(fn)        end        def pdf_portrait -        "#{@base_path}/portrait.#{@lng}.a4.pdf" +        fn=@md.file.base_filename.pdf_p_a4(fnh) +        path_and_file(fn)        end        def odt -        "#{@base_path}/opendocument.#{@lng}.odt" +        fn=@md.file.base_filename.odt(fnh) +        path_and_file(fn)        end        def xhtml -        "#{@base_path}/scroll.#{@lng}.xhtml" +        fn=@md.file.base_filename.xhtml(fnh) +        path_and_file(fn)        end        def xml_sax -        "#{@base_path}/scroll.#{@lng}.sax.xml" +        fn=@md.file.base_filename.xml_sax(fnh) +        path_and_file(fn)        end        def xml_dom -        "#{@base_path}/scroll.#{@lng}.dom.xml" +        fn=@md.file.base_filename.xml_dom(fnh) +        path_and_file(fn)        end        def txt -        "#{@base_path}/plain.#{@lng}.txt" +        fn=@md.file.base_filename.txt(fnh) +        path_and_file(fn)        end        def digest -        "#{@base_path}/digest.#{@lng}.txt" +        fn=@md.file.base_filename.hash_digest(fnh) +        path_and_file(fn)        end        def source          "#{@base_path}/#{@src}" diff --git a/lib/sisu/v5/harvest_authors.rb b/lib/sisu/v5/harvest_authors.rb index c20558df..c78971e4 100644 --- a/lib/sisu/v5/harvest_authors.rb +++ b/lib/sisu/v5/harvest_authors.rb @@ -364,12 +364,13 @@ WOK                @output[lng][:html_mnt] << x              end              @output[lng][:html] << x +            lang_code_insert=SiSU_Env::FilenameLanguageCodeInsert.new(@opt,lng).language_code_insert              works=[]              a[1][:md].each do |i|                manifest_at=if @env.output_dir_structure.by? == :language -                i[:file] + '.html' +                i[:file] + Sfx[:html]                elsif @env.output_dir_structure.by? == :filetype -                i[:file] + '.' + lng +  '.html' +                i[:file] + '.' + lang_code_insert + Sfx[:html]                elsif @env.output_dir_structure.by? == :filename                  "./#{i[:file]}/#{i[:page]}"                else '' #error diff --git a/lib/sisu/v5/harvest_topics.rb b/lib/sisu/v5/harvest_topics.rb index d3189639..eef5a2e2 100644 --- a/lib/sisu/v5/harvest_topics.rb +++ b/lib/sisu/v5/harvest_topics.rb @@ -737,10 +737,11 @@ WOK          end        end        def do_hash_md(lng,attrib,hash) +        lang_code_insert=SiSU_Env::FilenameLanguageCodeInsert.new(@opt,lng).language_code_insert          manifest_at=if @env.output_dir_structure.by? == :language -          hash[:file] + '.html' +          hash[:file] + Sfx[:html]          elsif @env.output_dir_structure.by? == :filetype -          hash[:file] + '.' + lng +  '.html' +          hash[:file] + lang_code_insert +  Sfx[:html]          elsif @env.output_dir_structure.by? == :filename            "./#{hash[:file]}/#{hash[:page]}"          else '' #error diff --git a/lib/sisu/v5/html.rb b/lib/sisu/v5/html.rb index ff4d149d..f7e2b813 100644 --- a/lib/sisu/v5/html.rb +++ b/lib/sisu/v5/html.rb @@ -418,14 +418,23 @@ WOK          linkname,ocn=dob.obj.strip,dob.ocn          p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) if ocn          if dob.ln ==4 -          seg_link=%{  <a href="#{dob.name}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top"> +          fnh={ +            fn: dob.name, +            lng: @md.lang_code_insert +          } +          f=@md.file.base_filename.html_seg(fnh) +          seg_link=%{  <a href="#{f}" target="_top">      #{dob.obj}    </a> }            @@seg_url=dob.name          elsif dob.obj =~/\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+/ -          seg_link=dob.obj.gsub(/^(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/, -            %{<a href="\\1#{@md.lang_code_insert}#{Sfx[:html]}" } + -            %{target="_top">\\1 \\2</a> }) +          fn,hd=/^(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/.match(dob.obj)[1,2] +          fnh={ +            fn: fn, +            lng: @md.lang_code_insert +          } +          f=@md.file.base_filename.html_seg(fnh) +          seg_link=%{<a href="#{f}" target="_top">#{fn} #{hd}</a> }          end          p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) if ocn          @file=SiSU_Env::FileOp.new(@md) if @md @@ -459,8 +468,13 @@ WOK          toc={}          if ocn \          and ocn !~/#/ +          fnh={ +            fn: @@seg_url, +            lng: @md.lang_code_insert +          } +          f=@md.file.base_filename.html_seg(fnh)            p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) -          lnk_n_txt=%{  <a href="#{@@seg_url}#{@md.lang_code_insert}#{Sfx[:html]}##{ocn}"> +          lnk_n_txt=%{  <a href="#{f}##{ocn}">      #{linkname}    </a>}            txt_obj={ txt: lnk_n_txt } @@ -480,8 +494,13 @@ WOK          toc={}          if ocn \          and ocn !~/#/ +          fnh={ +            fn: @@seg_url, +            lng: @md.lang_code_insert +          } +          f=@md.file.base_filename.html_seg(fnh)            p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) -          lnk_n_txt=%{  <a href="#{@@seg_url}#{@md.lang_code_insert}#{Sfx[:html]}##{ocn}"> +          lnk_n_txt=%{  <a href="#{f}##{ocn}">    #{linkname}  </a>}            txt_obj={ txt: lnk_n_txt } diff --git a/lib/sisu/v5/html_minitoc.rb b/lib/sisu/v5/html_minitoc.rb index 99f11d87..fcbffc73 100644 --- a/lib/sisu/v5/html_minitoc.rb +++ b/lib/sisu/v5/html_minitoc.rb @@ -153,14 +153,23 @@          txt=@data          unless txt =~/~metadata/            if txt.ln ==4 -            seg_link=%{  <a href="#{txt.name}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top"> +            fnh={ +              fn: txt.name, +              lng: @md.lang_code_insert +            } +            f=@md.file.base_filename.html_seg(fnh) +            seg_link=%{  <a href="#{f}" target="_top">      #{txt.obj}    </a> }              @@seg_url=txt.name            elsif txt.obj =~/\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+/ -            seg_link=txt.obj.gsub(/^(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/, -              %{<a href="\\2#{@md.lang_code_insert}#{Sfx[:html]}" } + -              %{target="_top">\\1 \\2</a> }) +            fn,hd=/^(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/.match(dob.obj)[1,2] +            fnh={ +              fn: fn, +              lng: @md.lang_code_insert +            } +            f=@md.file.base_filename.html_seg(fnh) +            seg_link=%{<a href="#{f}" target="_top">#{fn} #{hd}</a> }            end            txt_obj={ txt: seg_link }            format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj) @@ -175,7 +184,12 @@          && txt.ocn !=0            txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1')          end -        lnk_n_txt=%{  <a href="#{@@seg_url}#{@md.lang_code_insert}#{Sfx[:html]}##{txt.ocn}"> +        fnh={ +          fn: @@seg_url, +          lng: @md.lang_code_insert +        } +        f=@md.file.base_filename.html_seg(fnh) +        lnk_n_txt=%{  <a href="#{f}##{txt.ocn}">      #{txt.obj}    </a>}            txt_obj={ txt: lnk_n_txt } @@ -190,7 +204,12 @@          && txt.ocn !=0            txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1')          end -        lnk_n_txt=%{  <a href="#{@@seg_url}#{@md.lang_code_insert}#{Sfx[:html]}##{txt.ocn}"> +        fnh={ +          fn: @@seg_url, +          lng: @md.lang_code_insert +        } +        f=@md.file.base_filename.html_seg(fnh) +        lnk_n_txt=%{  <a href="#{f}##{txt.ocn}">      #{txt.obj}    </a>}            txt_obj={ txt: lnk_n_txt } diff --git a/lib/sisu/v5/html_segments.rb b/lib/sisu/v5/html_segments.rb index 54292175..ec604327 100644 --- a/lib/sisu/v5/html_segments.rb +++ b/lib/sisu/v5/html_segments.rb @@ -273,7 +273,12 @@ module SiSU_HTML_Seg                    FileUtils::mkdir_p(@file.output_path.html_seg.dir) if File.writable?("#{@file.output_path.base.dir}/.")                  end                  SiSU_HTML_Seg::Seg.new(@md).tail -                segfilename="#{@file.output_path.html_seg.dir}/#{@@seg_name_html[tracking-1]}#{@md.lang_code_insert}#{Sfx[:html]}" +                fnh={ +                  fn: @@seg_name_html[tracking-1], +                  lng: @md.lang_code_insert +                } +                fn=@md.file.base_filename.html_seg(fnh) +                segfilename="#{@file.output_path.html_seg.dir}/#{fn}"                  output_seg_file=File.new(segfilename,'w') if @@seg_name_html[tracking-1]                  minitoc=(@make.build.html_minitoc?) \                  ? @minitoc @@ -298,7 +303,12 @@ module SiSU_HTML_Seg                  head(dob)                 #keep use for last segment, eg if metadata is last segment                 if @@seg_name_html[tracking] =='metadata' # this is for metadata -                 segfilename="#{@file.output_path.html_seg.dir}/#{@@seg_name_html[tracking]}#{@md.lang_code_insert}#{Sfx[:html]}" +                 fnh={ +                   fn: @@seg_name_html[tracking], +                   lng: @md.lang_code_insert +                 } +                 fn=@md.file.base_filename.html_seg(fnh) +                 segfilename="#{@file.output_path.html_seg.dir}/#{fn}"                   output_seg_file=File.new(segfilename,'w')                   SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'metadata').output                   Seg.new.reinitialise diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb index dcf0a671..63981be3 100644 --- a/lib/sisu/v5/sysenv.rb +++ b/lib/sisu/v5/sysenv.rb @@ -470,27 +470,31 @@ module SiSU_Env      def output_dir_structure        def by?          output_structure=:filename #set default output structure -        output_structure=if defined? @rc['output_dir_structure_by'] -          output_structure=if (@rc['output_dir_structure_by'] =~/dump/) \ -          or ((defined? @rc['output_structure']['dump']) \ -          && @rc['output_structure']['dump'] ==true) -            :dump -          elsif (@rc['output_dir_structure_by'] =~/redirect/) \ -          or ((defined? @rc['output_structure']['redirect']) \ -          && @rc['output_structure']['redirect'] ==true) -            :redirect -          elsif (@rc['output_dir_structure_by'] =~/language/) \ -          or ((defined? @rc['output_structure']['by_language']) \ -          && @rc['output_structure']['by_language'] ==true) -            :language -          elsif (@rc['output_dir_structure_by'] =~/filetype/) \ -          or ((defined? @rc['output_structure']['by_filetype']) \ -          && @rc['output_structure']['by_filetype'] ==true) -            :filetype -          elsif (@rc['output_dir_structure_by'] =~/filename/) \ -          or ((defined? @rc['output_structure']['by_filename']) \ -          && @rc['output_structure']['by_filename'] ==true) -            :filename +        if @rc +          output_structure=if defined? @rc['output_dir_structure_by'] +            output_structure=if (@rc['output_dir_structure_by'] =~/dump/) \ +            or ((defined? @rc['output_structure']['dump']) \ +            && @rc['output_structure']['dump'] ==true) +              :dump +            elsif (@rc['output_dir_structure_by'] =~/redirect/) \ +            or ((defined? @rc['output_structure']['redirect']) \ +            && @rc['output_structure']['redirect'] ==true) +              :redirect +            elsif (@rc['output_dir_structure_by'] =~/language/) \ +            or ((defined? @rc['output_structure']['by_language']) \ +            && @rc['output_structure']['by_language'] ==true) +              :language +            elsif (@rc['output_dir_structure_by'] =~/filetype/) \ +            or ((defined? @rc['output_structure']['by_filetype']) \ +            && @rc['output_structure']['by_filetype'] ==true) +              :filetype +            elsif (@rc['output_dir_structure_by'] =~/filename/) \ +            or ((defined? @rc['output_structure']['by_filename']) \ +            && @rc['output_structure']['by_filename'] ==true) +              :filename +            else #set default +              :language +            end            else #set default              :language            end @@ -4657,245 +4661,531 @@ WOK        self      end      def base_filename -      def txt -        ft='.txt' -        if output_dir_structure.by_language_code? -          @md.fnb + ft -        elsif output_dir_structure.by_filetype? -          @md.fnb + @md.lang_code_insert + ft +      def i18n(f) +        f=default_hash.merge(f) +        (@md.opt.act[:i18n][:set]==:mono \ +        || ((mono_multi_lingual? ==:mono)) \ +        && (@md.opt.lng == default_language?)) \ +        || f[:lng]==nil \ +        ? f[:fn] + f[:ft] +        : f[:fn] + f[:lng] + f[:ft] +      end +      def default_hash +        { +          fn: @md.fnb, +          lng: @md.lang_code_insert, +        } +      end +      def default_hash_build(fh,sfx) +        if fh.is_a?(Hash) +          fh[:fn] ||=@md.fnb +          fh[:lng] ||= @md.lang_code_insert +          fh[:ft]=sfx +          fh          else -          'plain' + @md.lang_code_insert + ft -        end -      end -      def html_scroll -        ft='.html' -        if output_dir_structure.by_language_code? -          @md.fnb + ft +          { +            fn: @md.fnb, +            lng: @md.lang_code_insert, +            ft: sfx, +          } +        end +      end +      def txt(fh=nil) +        fh=default_hash_build(fh,Sfx[:txt]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn], +            ft: fh[:ft], +           } +         elsif output_dir_structure.by_filetype? +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng], +          } +        else +          { +            fn: 'plain', +            ft: fh[:ft], +            lng: fh[:lng], +          } +        end +        i18n(fnh) +      end +      def html_scroll(fh=nil) +        fh=default_hash_build(fh,Sfx[:html]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn], +            ft: fh[:ft], +          }          elsif output_dir_structure.by_filetype? -          @md.fnb + @md.lang_code_insert + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng], +          }          else -          'scroll' + @md.lang_code_insert + ft -        end -      end -      def html_seg_index -        ft='.html' -        if output_dir_structure.by_language_code? -          'index' + ft +          { +            fn: 'scroll', +            ft: fh[:ft], +            lng: fh[:lng], +          } +        end +        i18n(fnh) +      end +      def html_seg_index(fh=nil) +        fh=default_hash_build(fh,Sfx[:html]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: 'index', +            ft: fh[:ft], +          }          else -          'index' + @md.lang_code_insert + ft -        end -      end -      def html_segtoc -        ft='.html' -        if output_dir_structure.dump_or_redirect? -          @md.fnb + '.toc' + ft +          { +            fn: 'index', +            ft: fh[:ft], +            lng: fh[:lng], +          } +        end +        i18n(fnh) +      end +      def html_segtoc(fh=nil) +        fh=default_hash_build(fh,Sfx[:html]) +        fnh=if output_dir_structure.dump_or_redirect? +          { +            fn: fh[:fn] + '.toc', +            ft: fh[:ft], +          }          elsif output_dir_structure.by_language_code? -          'toc' + ft +          { +            fn: 'toc', +            ft: fh[:ft], +          }          else -          'toc' + @md.lang_code_insert + ft +          { +            fn: 'toc', +            ft: fh[:ft], +            lng: fh[:lng], +          } +        end +        i18n(fnh) +      end +      def html_seg(fh) +        fh=default_hash_build(fh,Sfx[:html]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn], +            ft: fh[:ft] +          } +        elsif output_dir_structure.by_filetype? +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng] +          } +        else +          { +            fn: 'scroll', +            ft: fh[:ft], +            lng: fh[:lng] +          }          end +        i18n(fnh)        end        def html_book_index -        ft='.html' -        if output_dir_structure.by_language_code? -          'book_index' + ft +        ft=Sfx[:html] +        fnh=if output_dir_structure.by_language_code? +          { +            fn: 'book_index', +            ft: ft, +          }          else -          'book_index' + @md.lang_code_insert + ft +          { +            fn: 'book_index', +            ft: ft, +            lng: @md.lang_code_insert +          }          end +        i18n(fnh)        end        def html_concordance -        ft='.html' -        if output_dir_structure.dump_or_redirect? +        ft=Sfx[:html] +        fnh=if output_dir_structure.dump_or_redirect?            @md.fnb + '.concordance' + ft          elsif output_dir_structure.by_language_code? -          'concordance' + ft +          { +            fn: 'concordance', +            ft: ft, +          }          else -          'concordance' + @md.lang_code_insert + ft -        end -      end -      def xhtml -        ft= '.xhtml' -        if output_dir_structure.by_language_code? -          @md.fnb + ft +          { +            fn: 'concordance', +            ft: ft, +            lng: @md.lang_code_insert +          } +        end +        i18n(fnh) +      end +      def xhtml(fh=nil) +        fh=default_hash_build(fh,Sfx[:xhtml]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn], +            ft: fh[:ft], +          }          elsif output_dir_structure.by_filetype? -          @md.fnb + @md.lang_code_insert + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng] +          }          else -          'scroll' + @md.lang_code_insert + ft -        end -      end -      def epub -        ft='.epub' -        if output_dir_structure.by_language_code? -          @md.fnb + ft +          { +            fn: 'scroll', +            ft: fh[:ft], +            lng: fh[:lng] +          } +        end +        i18n(fnh) +      end +      def epub(fh=nil) +        fh=default_hash_build(fh,Sfx[:epub]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn], +            ft: fh[:ft], +          }          else -          @md.fnb + @md.lang_code_insert + ft -        end -      end -      def odt -        ft='.odt' -        if output_dir_structure.by_language_code? -          @md.fnb + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng], +          } +        end +        i18n(fnh) +      end +      def odt(fh=nil) +        fh=default_hash_build(fh,Sfx[:odt]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn], +            ft: fh[:ft], +          }          elsif output_dir_structure.by_filetype? -          @md.fnb + @md.lang_code_insert + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng], +          }          else -          'opendocument' + @md.lang_code_insert + ft -        end -      end -      def xml_sax -        ft='.sax.xml' -        if output_dir_structure.by_language_code? -          @md.fnb + ft +          { +            fn: 'opendocument', +            ft: fh[:ft], +            lng: fh[:lng], +          } +        end +        i18n(fnh) +      end +      def xml_sax(fh=nil) +        fh=default_hash_build(fh,Sfx[:xml_sax]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn], +            ft: fh[:ft], +          }          elsif output_dir_structure.by_filetype? -          @md.fnb + @md.lang_code_insert + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng], +          }          else -          'scroll' + @md.lang_code_insert + ft -        end -      end -      def xml_dom -        ft='.dom.xml' -        if output_dir_structure.by_language_code? -          @md.fnb + ft +          { +            fn: 'scroll', +            ft: fh[:ft], +            lng: fh[:lng], +          } +        end +        i18n(fnh) +      end +      def xml_dom(fh=nil) +        fh=default_hash_build(fh,Sfx[:xml_dom]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn], +            ft: fh[:ft], +          }          elsif output_dir_structure.by_filetype? -          @md.fnb + @md.lang_code_insert + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng], +          }          else -          'scroll' + @md.lang_code_insert + ft +          { +            fn: 'scroll', +            ft: fh[:ft], +            lng: fh[:lng], +          }          end +        i18n(fnh)        end -      def pdf_p +      def pdf_p(fh=nil) +        fh=default_hash_build(fh,Sfx[:pdf])          if output_dir_structure.by_language_code? -          @md.fnb + '.portrait.' -        else 'portrait' + @md.lang_code_insert + '.' +          fh[:fn] + '.portrait.' +        else +          (@md.opt.lingual==:mono \ +          && (@md.opt.lng == default_language?)) \ +          ? ('portrait' + '.') +          : ('portrait' + fh[:lng] + '.')          end        end -      def pdf_l +      def pdf_l(fh=nil) +        fh=default_hash_build(fh,Sfx[:pdf])          if output_dir_structure.by_language_code? -          @md.fnb + '.landscape.' -        else 'landscape' + @md.lang_code_insert + '.' +          fh[:fn] + '.landscape.' +        else +          (@md.opt.lingual==:mono \ +          && (@md.opt.lng == default_language?)) \ +          ? ('landscape' + '.') +          : ('landscape' + fh[:lng] + '.') +          #'landscape' + @md.lang_code_insert + '.'          end        end -      def pdf_p_a4 -        pdf_p + @md.fn[:pdf_p_a4] +      def pdf_p_a4(fh=nil) +        pdf_p(fh) + @md.fn[:pdf_p_a4]        end -      def pdf_p_a5 -        pdf_p + @md.fn[:pdf_p_a5] +      def pdf_p_a5(fh=nil) +        pdf_p(fh) + @md.fn[:pdf_p_a5]        end -      def pdf_p_b5 -        pdf_p + @md.fn[:pdf_p_b5] +      def pdf_p_b5(fh=nil) +        pdf_p(fh) + @md.fn[:pdf_p_b5]        end -      def pdf_p_letter -        pdf_p + @md.fn[:pdf_p_letter] +      def pdf_p_letter(fh=nil) +        pdf_p(fh) + @md.fn[:pdf_p_letter]        end -      def pdf_p_legal -        pdf_p + @md.fn[:pdf_p_legal] +      def pdf_p_legal(fh=nil) +        pdf_p(fh) + @md.fn[:pdf_p_legal]        end -      def pdf_l_a4 -        pdf_l + @md.fn[:pdf_l_a4] +      def pdf_l_a4(fh=nil) +        pdf_l(fh) + @md.fn[:pdf_l_a4]        end -      def pdf_l_a5 -        pdf_l + @md.fn[:pdf_l_a5] +      def pdf_l_a5(fh=nil) +        pdf_l(fh) + @md.fn[:pdf_l_a5]        end -      def pdf_l_b5 -        pdf_l + @md.fn[:pdf_l_b5] +      def pdf_l_b5(fh=nil) +        pdf_l(fh) + @md.fn[:pdf_l_b5]        end -      def pdf_l_letter -        pdf_l + @md.fn[:pdf_l_letter] +      def pdf_l_letter(fh=nil) +        pdf_l(fh) + @md.fn[:pdf_l_letter]        end -      def pdf_l_legal -        pdf_l + @md.fn[:pdf_l_legal] +      def pdf_l_legal(fh=nil) +        pdf_l(fh) + @md.fn[:pdf_l_legal]        end -      def manpage -        ft='1' -        if output_dir_structure.by_language_code? -          @md.fnb + '.' + ft +      def manpage(fh=nil) +        fh=default_hash_build(fh,Sfx[:manpage]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn], +            ft: fh[:ft], +          }          else -          @md.fnb + '.' + @md.opt.f_pth[:lng_is] + '.' + ft -        end -      end -      def info -        ft='info' -        if output_dir_structure.by_language_code? -          @md.fnb + '.' + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng], +          } +        end +        i18n(fnh) +      end +      def info(fh=nil) +        fh=default_hash_build(fh,Sfx[:info]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn], +            ft: fh[:ft], +          }          else -          @md.fnb + '.' + @md.opt.f_pth[:lng_is] + '.' + ft -        end -      end -      def texinfo -        ft='texinfo' -        if output_dir_structure.by_language_code? -          @md.fnb + '.' + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng], +          } +        end +        i18n(fnh) +      end +      def texinfo(fh=nil) +        fh=default_hash_build(fh,Sfx[:texinfo]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn], +            ft: fh[:ft], +          }          else -          @md.fnb + '.' + @md.opt.f_pth[:lng_is] + '.' + ft -        end -      end -      def sqlite_discrete -        ft='.sql.db' -        if output_dir_structure.by_language_code? -          @md.fnb + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng], +          } +        end +        i18n(fnh) +      end +      def sqlite_discrete(fh=nil) +        fh=default_hash_build(fh,Sfx[:sql]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn], +            ft: fh[:ft], +          }          else -          @md.fnb + @md.lang_code_insert + ft -        end -      end -      def hash_digest -        ft='.txt' -        if output_dir_structure.by_language_code? -          @md.fnb + '.hash_digest' + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng], +          } +        end +        i18n(fnh) +      end +      def hash_digest(fh=nil) +        fh=default_hash_build(fh,Sfx[:txt]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn] + '.hash_digest', +            ft: fh[:ft], +          }          elsif output_dir_structure.by_filetype? -          @md.fnb + @md.lang_code_insert + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng], +          }          else -          'digest' + @md.lang_code_insert + ft -        end -      end -      def sitemap -        ft='.xml' -        if output_dir_structure.by_language_code? -          @md.fnb + '.sitemap' + ft +          { +            fn: 'digest', +            ft: fh[:ft], +            lng: fh[:lng], +          } +        end +        i18n(fnh) +      end +      def sitemap(fh=nil) +        fh=default_hash_build(fh,Sfx[:xml]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn] + '.sitemap', +            ft: fh[:ft], +          }          elsif output_dir_structure.by_filetype? -          @md.fnb + @md.lang_code_insert + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng], +          }          else -          'sitemap' + @md.lang_code_insert + ft +          { +            fn: 'sitemap', +            ft: fh[:ft], +            lng: fh[:lng], +          }          end +        i18n(fnh)        end        def qrcode_title +        fn=@md.fnb          ft='.title.png' -        if output_dir_structure.by_language_code? -          @md.fnb + ft +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fn, +            ft: ft, +          }          elsif output_dir_structure.by_filetype? -          @md.fnb + @md.lang_code_insert + ft -        else #fix -          'sisu_manifest' + @md.lang_code_insert + ft +          { +            fn: fn, +            ft: ft, +            lng: @md.lang_code_insert +          } +        else +          { +            fn: 'sisu_manifest', +            ft: ft, +            lng: @md.lang_code_insert +          }          end +        i18n(fnh)        end        def qrcode_md +        fn=@md.fnb          ft='.md.png' -        if output_dir_structure.by_language_code? -          @md.fnb + ft +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fn, +            ft: ft, +          }          elsif output_dir_structure.by_filetype? -          @md.fnb + @md.lang_code_insert + ft -        else #fix -          'sisu_manifest' + @md.lang_code_insert + ft -        end -      end -      def manifest_txt -        ft='.txt' -        if output_dir_structure.by_language_code? -          @md.fnb + ft +          { +            fn: fn, +            ft: ft, +            lng: @md.lang_code_insert +          } +        else +          { +            fn: 'sisu_manifest', +            ft: ft, +            lng: @md.lang_code_insert +          } +        end +        i18n(fnh) +      end +      def manifest_txt(fh=nil) +        fh=default_hash_build(fh,Sfx[:txt]) +        fnh=if output_dir_structure.by_language_code? +          { +            fn: fh[:fn], +            ft: fh[:ft], +          }          elsif output_dir_structure.by_filetype? -          @md.fnb + @md.lang_code_insert + ft -        else #fix -          'sisu_manifest' + @md.lang_code_insert + ft -        end -      end -      def manifest -        ft='.html' -        if output_dir_structure.dump_or_redirect? -          @md.fnb + '.manifest' + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng], +          } +        else +          { +            fn: 'sisu_manifest', +            ft: fh[:ft], +            lng: fh[:lng], +          } +        end +        i18n(fnh) +      end +      def manifest(fh=nil) +        fh=default_hash_build(fh,Sfx[:html]) +        fnh=if output_dir_structure.dump_or_redirect? +          { +            fn: fh[:fn] + '.manifest', +            ft: fh[:ft], +          }          elsif output_dir_structure.by_language_code? -          @md.fnb + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +          }          elsif output_dir_structure.by_filetype? -          @md.fnb + @md.lang_code_insert + ft -        else #fix -          'sisu_manifest' + @md.lang_code_insert + ft +          { +            fn: fh[:fn], +            ft: fh[:ft], +            lng: fh[:lng], +          } +        else +          { +            fn: 'sisu_manifest', +            ft: fh[:ft], +            lng: fh[:lng], +          }          end +        i18n(fnh)        end        def src          @md.fno | 
