From bab4ecc57278acd7a0b3fdd370f0a6d73241f01c Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 8 Aug 2013 00:10:33 -0400 Subject: v5: output structure by, multilingual, monolingual filenames tweak --- lib/sisu/v5/sysenv.rb | 367 ++++++++++++++++++-------------------------------- 1 file changed, 133 insertions(+), 234 deletions(-) (limited to 'lib/sisu/v5/sysenv.rb') diff --git a/lib/sisu/v5/sysenv.rb b/lib/sisu/v5/sysenv.rb index 5ea84832..5993a333 100644 --- a/lib/sisu/v5/sysenv.rb +++ b/lib/sisu/v5/sysenv.rb @@ -447,11 +447,9 @@ module SiSU_Env if (@rc['language_default'].is_a?(String)) \ && (@rc['language_default'] =~/#{Px[:lng_lst_rgx]}/) @rc['language_default'] - else - 'en' + else 'en' end - else - 'en' + else 'en' end end def mono_multi_lingual? @@ -463,8 +461,7 @@ module SiSU_Env elsif (@rc['lingual'].is_a?(String)) \ && (@rc['lingual'] =~/multi(?:lingual)?/) :multi - else - :multi + else :multi end else :multi end @@ -4662,12 +4659,8 @@ WOK def base_filename 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] + f[:lng] ||=@md.lang_code_insert + f[:fn] + f[:lng] + f[:ft] end def default_hash { @@ -4689,44 +4682,41 @@ WOK } end end + def lang_code?(lng) + (output_dir_structure.by_language_code?) \ + ? '' + : (lng ||=@md.lang_code_insert) + end def txt(fh=nil) fh=default_hash_build(fh,Sfx[:txt]) - fnh=if output_dir_structure.by_language_code? + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? { - fn: fh[:fn], + fn: 'plain', ft: fh[:ft], + lng: fh[:lng], } - elsif output_dir_structure.by_filetype? + else { 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? + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? { - fn: fh[:fn], + fn: 'scroll', ft: fh[:ft], lng: fh[:lng], } else { - fn: 'scroll', + fn: fh[:fn], ft: fh[:ft], lng: fh[:lng], } @@ -4735,18 +4725,12 @@ WOK 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 - { - fn: 'index', - ft: fh[:ft], - lng: fh[:lng], - } - end + fh[:lng]=lang_code?(fh[:lng]) + fnh={ + fn: 'index', + ft: fh[:ft], + lng: fh[:lng], + } i18n(fnh) end def html_segtoc(fh=nil) @@ -4756,130 +4740,97 @@ WOK fn: fh[:fn] + '.toc', ft: fh[:ft], } - elsif output_dir_structure.by_language_code? - { - fn: 'toc', - ft: fh[:ft], - } else { fn: 'toc', ft: fh[:ft], - lng: fh[:lng], + lng: lang_code?(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? + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? { - fn: fh[:fn], - ft: fh[:ft] - } - elsif output_dir_structure.by_filetype? - { - fn: fh[:fn], + fn: 'scroll', ft: fh[:ft], - lng: fh[:lng] + lng: fh[:lng], } else { - fn: 'scroll', + fn: fh[:fn], ft: fh[:ft], - lng: fh[:lng] + lng: fh[:lng], } end i18n(fnh) end - def html_book_index - ft=Sfx[:html] - fnh=if output_dir_structure.by_language_code? - { - fn: 'book_index', - ft: ft, - } - else - { - fn: 'book_index', - ft: ft, - lng: @md.lang_code_insert - } - end + def html_book_index(fh=nil) + fh=default_hash_build(fh,Sfx[:html]) + fh[:lng]=lang_code?(fh[:lng]) + fnh={ + fn: 'book_index', + ft: fh[:ft], + lng: fh[:lng], + } i18n(fnh) end - def html_concordance - ft=Sfx[:html] + def html_concordance(fh=nil) + fh=default_hash_build(fh,Sfx[:html]) + fh[:lng]=lang_code?(fh[:lng]) fnh=if output_dir_structure.dump_or_redirect? @md.fnb + '.concordance' + ft - elsif output_dir_structure.by_language_code? - { - fn: 'concordance', - ft: ft, - } else { fn: 'concordance', - ft: ft, - lng: @md.lang_code_insert + ft: fh[:ft], + lng: fh[:lng], } 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? + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? { - fn: fh[:fn], + fn: 'scroll', ft: fh[:ft], - lng: fh[:lng] + lng: fh[:lng], } else { - fn: 'scroll', + fn: fh[:fn], ft: fh[:ft], - lng: fh[:lng] + 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 - { - fn: fh[:fn], - ft: fh[:ft], - lng: fh[:lng], - } - end + fh[:lng]=lang_code?(fh[:lng]) + fnh={ + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], + } 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? + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? { - fn: fh[:fn], + fn: 'opendocument', ft: fh[:ft], lng: fh[:lng], } else { - fn: 'opendocument', + fn: fh[:fn], ft: fh[:ft], lng: fh[:lng], } @@ -4888,20 +4839,16 @@ WOK 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? + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? { - fn: fh[:fn], + fn: 'scroll', ft: fh[:ft], lng: fh[:lng], } else { - fn: 'scroll', + fn: fh[:fn], ft: fh[:ft], lng: fh[:lng], } @@ -4910,20 +4857,16 @@ WOK end def xml_dom(fh=nil) fh=default_hash_build(fh,Sfx[:xml_dom]) - fnh=if output_dir_structure.by_language_code? + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? { - fn: fh[:fn], - ft: fh[:ft], - } - elsif output_dir_structure.by_filetype? - { - fn: fh[:fn], + fn: 'scroll', ft: fh[:ft], lng: fh[:lng], } else { - fn: 'scroll', + fn: fh[:fn], ft: fh[:ft], lng: fh[:lng], } @@ -4932,25 +4875,20 @@ WOK end def pdf_p(fh=nil) fh=default_hash_build(fh,Sfx[:pdf]) - if output_dir_structure.by_language_code? - fh[:fn] + '.portrait.' + fh[:lng]=lang_code?(fh[:lng]) + if output_dir_structure.by_filename? + 'portrait' + fh[:lng] + '.' else - (@md.opt.lingual==:mono \ - && (@md.opt.lng == default_language?)) \ - ? ('portrait' + '.') - : ('portrait' + fh[:lng] + '.') + fh[:fn] + '.portrait' + fh[:lng] + '.' end end def pdf_l(fh=nil) fh=default_hash_build(fh,Sfx[:pdf]) - if output_dir_structure.by_language_code? - fh[:fn] + '.landscape.' + fh[:lng]=lang_code?(fh[:lng]) + if output_dir_structure.by_filename? + 'landscape' + fh[:lng] + '.' else - (@md.opt.lingual==:mono \ - && (@md.opt.lng == default_language?)) \ - ? ('landscape' + '.') - : ('landscape' + fh[:lng] + '.') - #'landscape' + @md.lang_code_insert + '.' + fh[:fn] + '.landscape' + fh[:lng] + '.' end end def pdf_p_a4(fh=nil) @@ -4985,70 +4923,47 @@ WOK end 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 - { - fn: fh[:fn], - ft: fh[:ft], - lng: fh[:lng], - } - end + fh[:lng]=lang_code?(fh[:lng]) + fnh={ + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], + } 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 - { - fn: fh[:fn], - ft: fh[:ft], - lng: fh[:lng], - } - end + fh[:lng]=lang_code?(fh[:lng]) + fnh={ + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], + } 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 - { - fn: fh[:fn], - ft: fh[:ft], - lng: fh[:lng], - } - end + fh[:lng]=lang_code?(fh[:lng]) + fnh={ + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], + } 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 - { - fn: fh[:fn], - ft: fh[:ft], - lng: fh[:lng], - } - end + fh[:lng]=lang_code?(fh[:lng]) + fnh={ + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], + } i18n(fnh) end def hash_digest(fh=nil) fh=default_hash_build(fh,Sfx[:txt]) + fh[:lng]=lang_code?(fh[:lng]) fnh=if output_dir_structure.by_language_code? { fn: fh[:fn] + '.hash_digest', @@ -5071,6 +4986,7 @@ WOK end def sitemap(fh=nil) fh=default_hash_build(fh,Sfx[:xml]) + fh[:lng]=lang_code?(fh[:lng]) fnh=if output_dir_structure.by_language_code? { fn: fh[:fn] + '.sitemap', @@ -5091,68 +5007,54 @@ WOK end i18n(fnh) end - def qrcode_title - fn=@md.fnb - ft='.title.png' - fnh=if output_dir_structure.by_language_code? - { - fn: fn, - ft: ft, - } - elsif output_dir_structure.by_filetype? + def qrcode_title(fh=nil) + fh=default_hash_build(fh,'.title.png') + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? { - fn: fn, - ft: ft, - lng: @md.lang_code_insert + fn: 'sisu_manifest', + ft: fh[:ft], + lng: fh[:lng], } else { - fn: 'sisu_manifest', - ft: ft, - lng: @md.lang_code_insert + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], } end i18n(fnh) end - def qrcode_md - fn=@md.fnb - ft='.md.png' - fnh=if output_dir_structure.by_language_code? - { - fn: fn, - ft: ft, - } - elsif output_dir_structure.by_filetype? + def qrcode_md #check name below + fh=default_hash_build(fh,'.md.png') + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? { - fn: fn, - ft: ft, - lng: @md.lang_code_insert + fn: 'sisu_manifest', + ft: fh[:ft], + lng: fh[:lng], } else { - fn: 'sisu_manifest', - ft: ft, - lng: @md.lang_code_insert + fn: fh[:fn], + ft: fh[:ft], + lng: fh[:lng], } end i18n(fnh) end def manifest_txt(fh=nil) fh=default_hash_build(fh,Sfx[:txt]) - fnh=if output_dir_structure.by_language_code? + fh[:lng]=lang_code?(fh[:lng]) + fnh=if output_dir_structure.by_filename? { - fn: fh[:fn], - ft: fh[:ft], - } - elsif output_dir_structure.by_filetype? - { - fn: fh[:fn], + fn: 'sisu_manifest', ft: fh[:ft], lng: fh[:lng], } else { - fn: 'sisu_manifest', + fn: fh[:fn], ft: fh[:ft], lng: fh[:lng], } @@ -5161,25 +5063,22 @@ WOK end def manifest(fh=nil) fh=default_hash_build(fh,Sfx[:html]) + fh[:lng]=lang_code?(fh[:lng]) fnh=if output_dir_structure.dump_or_redirect? { fn: fh[:fn] + '.manifest', ft: fh[:ft], + lng: fh[:lng], } - elsif output_dir_structure.by_language_code? - { - fn: fh[:fn], - ft: fh[:ft], - } - elsif output_dir_structure.by_filetype? + elsif output_dir_structure.by_filename? { - fn: fh[:fn], + fn: 'sisu_manifest', ft: fh[:ft], lng: fh[:lng], } else { - fn: 'sisu_manifest', + fn: fh[:fn], ft: fh[:ft], lng: fh[:lng], } @@ -6029,7 +5928,7 @@ WOK or ((@opt.dir_structure_by ==:filetype \ || @opt.dir_structure_by ==:filename) \ and (@opt.lingual ==:mono \ - && @opt.lng == @opt.act[:default_language][:code])) + && @lng == @opt.act[:default_language][:code])) '' elsif (@opt.dir_structure_by ==:filetype \ || @opt.dir_structure_by ==:filename) \ -- cgit v1.2.3