diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-05-28 04:28:52 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-05-28 04:29:01 -0400 |
commit | ba278b927a8127efaa27725ca2bcb416a2c5d25d (patch) | |
tree | 29d25529260d19f3cf1b14367490daea2b917837 /lib | |
parent | v3: options, --init-site, --configure, fix (diff) |
v3: options, command line control of output directory structure
* --output-by-language; --output-by-filetype; --output-by-filename, or
--by-language; --by-filetype; --by-filename
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v3/options.rb | 11 | ||||
-rw-r--r-- | lib/sisu/v3/param.rb | 13 | ||||
-rw-r--r-- | lib/sisu/v3/sysenv.rb | 117 |
3 files changed, 91 insertions, 50 deletions
diff --git a/lib/sisu/v3/options.rb b/lib/sisu/v3/options.rb index 1452de4b..44d4e40e 100644 --- a/lib/sisu/v3/options.rb +++ b/lib/sisu/v3/options.rb @@ -507,8 +507,15 @@ module SiSU_Commandline { bool: false, set: :off, off: off_list} else { bool: true, set: :na, off: [] } end - act[:ocn]= - if mod.inspect =~/"--inc-ocn"/ + act[:output_by]=if mod.inspect =~/"--(?:output-)?by-language"/ + { set: :language } + elsif mod.inspect =~/"--(?:output-)?by-filename"/ + { set: :filename } + elsif mod.inspect =~/"--(?:output-)?by-filetype"/ + { set: :filetype } + else { set: :na } + end + act[:ocn]=if mod.inspect =~/"--inc-ocn"/ { bool: true, set: :on } elsif mod.inspect =~/"--(?:exc|no)-ocn"/ \ || act[:switch][:off].inspect =~/"ocn"/ diff --git a/lib/sisu/v3/param.rb b/lib/sisu/v3/param.rb index d8aa3e8a..77b4e8e7 100644 --- a/lib/sisu/v3/param.rb +++ b/lib/sisu/v3/param.rb @@ -1063,9 +1063,16 @@ module SiSU_Param @flv,@lang,@seg_names,@tags,@tag_array,@tag_a,@ec[:image],@ec[:audio],@ec[:multimedia]=Array.new(9){[]} @authors,@topic_register_array,@papersize_array=[],[],[] @lvs=[nil,0,0,0,0,0,0] - @lang_code_insert=(@opt.dir_structure_by ==:language) \ - ? '' - : ".#{@opt.lng}" + @lang_code_insert=if @opt.act[:output_by][:set]==:language + '' + elsif @opt.act[:output_by][:set]==:filetype \ + or @opt.act[:output_by][:set]==:filename + ".#{@opt.lng}" + elsif @opt.dir_structure_by ==:language + '' + else + ".#{@opt.lng}" + end @rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m @rgx_audio=/\{\s*(\S+?\.(?:mp3|ogg))/ @rgx_mm=/\{\s*(\S+?\.(?:ogg|mpeg))/ #expand and distinguish ogg diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index 4a91a2de..a28b4060 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -3554,14 +3554,14 @@ WOK def doc_rc #document rc, make instructions @md.make end - def cmd_rc #command-line rc - @cmd_rc=@md.opt.opt_act + def cmd_rc_act #command-line rc + @cmd_rc_act=@md.opt.opt_act end def build def ocn? - if cmd_rc[:ocn][:set]==:on + if cmd_rc_act[:ocn][:set]==:on true - elsif cmd_rc[:ocn][:set]==:off + elsif cmd_rc_act[:ocn][:set]==:off false elsif defined? @md.make.ocn? \ and @md.make.ocn? ==:off @@ -3573,9 +3573,9 @@ WOK end end def toc? - if cmd_rc[:toc][:set]==:on + if cmd_rc_act[:toc][:set]==:on true - elsif cmd_rc[:toc][:set]==:off + elsif cmd_rc_act[:toc][:set]==:off false elsif defined? @md.make.toc? \ and @md.make.toc? ==:off @@ -3587,9 +3587,9 @@ WOK end end def manifest? - if cmd_rc[:manifest][:set]==:on + if cmd_rc_act[:manifest][:set]==:on true - elsif cmd_rc[:manifest][:set]==:off + elsif cmd_rc_act[:manifest][:set]==:off false elsif defined? @md.make.manifest? \ and @md.make.manifest? ==:off @@ -3601,9 +3601,9 @@ WOK end end def links_to_manifest? - if cmd_rc[:links_to_manifest][:set]==:on + if cmd_rc_act[:links_to_manifest][:set]==:on true - elsif cmd_rc[:links_to_manifest][:set]==:off + elsif cmd_rc_act[:links_to_manifest][:set]==:off false elsif defined? @md.make.links_to_manifest? \ and @md.make.links_to_manifest? ==:off @@ -3615,9 +3615,9 @@ WOK end end def metadata? - if cmd_rc[:metadata][:set]==:on + if cmd_rc_act[:metadata][:set]==:on true - elsif cmd_rc[:metadata][:set]==:off + elsif cmd_rc_act[:metadata][:set]==:off false elsif defined? @md.make.metadata? \ and @md.make.metadata? ==:off @@ -3631,9 +3631,9 @@ WOK def minitoc? if html_top_band? == false #one form of navigation necessary true - elsif cmd_rc[:minitoc][:set]==:on + elsif cmd_rc_act[:minitoc][:set]==:on true - elsif cmd_rc[:minitoc][:set]==:off + elsif cmd_rc_act[:minitoc][:set]==:off false elsif defined? @md.make.minitoc? \ and @md.make.minitoc? ==:off @@ -3647,11 +3647,11 @@ WOK def manifest_minitoc? if html_top_band? == false #one form of navigation necessary true - elsif cmd_rc[:manifest_minitoc][:set]==:on \ - || cmd_rc[:minitoc][:set]==:on + elsif cmd_rc_act[:manifest_minitoc][:set]==:on \ + || cmd_rc_act[:minitoc][:set]==:on true - elsif cmd_rc[:manifest_minitoc][:set]==:off \ - || cmd_rc[:minitoc][:set]==:off + elsif cmd_rc_act[:manifest_minitoc][:set]==:off \ + || cmd_rc_act[:minitoc][:set]==:off false elsif defined? @md.make.manifest_minitoc? \ and (@md.make.manifest_minitoc? ==:off \ @@ -3669,11 +3669,11 @@ WOK def html_minitoc? if html_top_band? == false #one form of navigation necessary true - elsif cmd_rc[:html_minitoc][:set]==:on \ - || cmd_rc[:minitoc][:set]==:on + elsif cmd_rc_act[:html_minitoc][:set]==:on \ + || cmd_rc_act[:minitoc][:set]==:on true - elsif cmd_rc[:html_minitoc][:set]==:off \ - || cmd_rc[:minitoc][:set]==:off + elsif cmd_rc_act[:html_minitoc][:set]==:off \ + || cmd_rc_act[:minitoc][:set]==:off false elsif defined? @md.make.html_minitoc? \ and (@md.make.html_minitoc? ==:off \ @@ -3689,9 +3689,9 @@ WOK end end def html_top_band? - if cmd_rc[:html_top_band][:set]==:on + if cmd_rc_act[:html_top_band][:set]==:on true - elsif cmd_rc[:html_top_band][:set]==:off + elsif cmd_rc_act[:html_top_band][:set]==:off false elsif defined? @md.make.html_top_band? \ and @md.make.html_top_band? ==:off @@ -3703,9 +3703,9 @@ WOK end end def html_navigation? - if cmd_rc[:html_navigation][:set]==:on + if cmd_rc_act[:html_navigation][:set]==:on true - elsif cmd_rc[:html_navigation][:set]==:off + elsif cmd_rc_act[:html_navigation][:set]==:off false elsif defined? @md.make.html_navigation? \ and @md.make.html_navigation? ==:off @@ -3717,9 +3717,9 @@ WOK end end def html_navigation_bar? - if cmd_rc[:html_navigation_bar][:set]==:on + if cmd_rc_act[:html_navigation_bar][:set]==:on true - elsif cmd_rc[:html_navigation_bar][:set]==:off + elsif cmd_rc_act[:html_navigation_bar][:set]==:off false elsif defined? @md.make.html_navigation_bar? \ and @md.make.html_navigation_bar? ==:off @@ -3731,9 +3731,9 @@ WOK end end def search_form? - if cmd_rc[:search_form][:set]==:on + if cmd_rc_act[:search_form][:set]==:on true - elsif cmd_rc[:search_form][:set]==:off + elsif cmd_rc_act[:search_form][:set]==:off false elsif defined? @md.make.html_search_form? \ and @md.make.search_form? ==:off @@ -3745,11 +3745,11 @@ WOK end end def html_search_form? - if cmd_rc[:html_search_form][:set]==:on \ - || cmd_rc[:search_form][:set]==:on + if cmd_rc_act[:html_search_form][:set]==:on \ + || cmd_rc_act[:search_form][:set]==:on true - elsif cmd_rc[:html_search_form][:set]==:off \ - || cmd_rc[:search_form][:set]==:off + elsif cmd_rc_act[:html_search_form][:set]==:off \ + || cmd_rc_act[:search_form][:set]==:off false elsif defined? @md.make.html_search_form? \ and (@md.make.html_search_form? ==:off \ @@ -3765,9 +3765,9 @@ WOK end end def html_right_pane? - if cmd_rc[:html_right_pane][:set]==:on + if cmd_rc_act[:html_right_pane][:set]==:on true - elsif cmd_rc[:html_right_pane][:set]==:off + elsif cmd_rc_act[:html_right_pane][:set]==:off false elsif defined? @md.make.html_right_pane? \ and @md.make.html_right_pane? ==:off @@ -3779,9 +3779,9 @@ WOK end end def segsubtoc? - if cmd_rc[:segsubtoc][:set]==:on + if cmd_rc_act[:segsubtoc][:set]==:on true - elsif cmd_rc[:segsubtoc][:set]==:off + elsif cmd_rc_act[:segsubtoc][:set]==:off false elsif defined? @md.make.segsubtoc? \ and @md.make.segsubtoc? ==:off @@ -3796,27 +3796,54 @@ WOK end def output_dir_structure def by_language_code? - env_rc.output_dir_structure.by_language_code? + if cmd_rc_act[:output_by][:set] == :language + true + elsif cmd_rc_act[:output_by][:set] == :filetype \ + or cmd_rc_act[:output_by][:set] == :filename + false + elsif cmd_rc_act[:output_by][:set] == :language + true + else + env_rc.output_dir_structure.by_language_code? + end end def by_filetype? - env_rc.output_dir_structure.by_filetype? + if cmd_rc_act[:output_by][:set] == :filetype + true + elsif cmd_rc_act[:output_by][:set] == :language \ + or cmd_rc_act[:output_by][:set] == :filename + false + elsif cmd_rc_act[:output_by][:set] == :filetype + true + else + env_rc.output_dir_structure.by_filetype? + end end def by_filename? - env_rc.output_dir_structure.by_filename? + if cmd_rc_act[:output_by][:set] == :filename + true + elsif cmd_rc_act[:output_by][:set] == :language \ + or cmd_rc_act[:output_by][:set] == :filetype + false + elsif cmd_rc_act[:output_by][:set] == :filename + true + else + env_rc.output_dir_structure.by_filename? + end end def multilingual? by_language_code? end def dump? - ((cmd_rc[:dump][:bool] \ - && cmd_rc[:dump][:inst]) \ + ((cmd_rc_act[:dump][:bool] \ + && cmd_rc_act[:dump][:inst]) \ || (env_rc.output_dir_structure.dump?)) \ ? true : false end def redirect? - ((cmd_rc[:redirect][:bool] \ - && cmd_rc[:redirect][:inst]) \ + ((cmd_rc_act[:redirect][:bool] \ + && cmd_rc_act[:redirect][:inst]) \ || (env_rc.output_dir_structure.redirect?)) \ ? true : false |