From 6d898f1eb74160fbc7d6365b3ad8d6b9417d2f19 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 14 Feb 2012 21:32:53 -0500 Subject: v3dv: control hooks * hooks to make it possible to control (via: the command line; the document markup header, or; the command line) the likes of: toc, manifest, manifest-links, metadata, html-minitoc, html-navigation, html-navigation-bar; these are switched on by default and control takes the form of making it possible to switch them off. --- data/doc/sisu/CHANGELOG_v3 | 6 ++ lib/sisu/v3dv/html_segments.rb | 3 +- lib/sisu/v3dv/options.rb | 64 +++++++++++- lib/sisu/v3dv/param.rb | 3 + lib/sisu/v3dv/sysenv.rb | 221 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 294 insertions(+), 3 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index bfbb5340..34757240 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -47,6 +47,12 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.1.14.orig.tar.xz * v3dv: dal, remove sisu_manifest from document structure & toc (metadata retained (provide link to sisu_manifest)), html & epub coding affected +* v3dv: hooks to make it possible to control (via: the command line; the + document markup header, or; the command line) the likes of: toc, manifest, + manifest-links, metadata, html-minitoc, html-navigation, html-navigation-bar; + these are switched on by default and control takes the form of making it + possible to switch them off. + * v3 v3dv: document --redirect, --dump, -j update sisu_commands.sst [documents not generated until v3.2.0 (when v3dv branch is merged into v3)] diff --git a/lib/sisu/v3dv/html_segments.rb b/lib/sisu/v3dv/html_segments.rb index 05f30cc4..b20d2271 100644 --- a/lib/sisu/v3dv/html_segments.rb +++ b/lib/sisu/v3dv/html_segments.rb @@ -138,6 +138,7 @@ module SiSU_HTML_Seg @seg_name_html=@@seg_name_html || nil @seg_name_html_tracker=@@tracker || nil @env=SiSU_Env::InfoEnv.new(@md.fns) if @md + @make=SiSU_Env::InfoSet.new(@md) if @md if @md @title_banner_=SiSU_Env::CreateSite.new(@md.opt.cmd).html_seg_title_banner? end @@ -244,7 +245,7 @@ module SiSU_HTML_Seg 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]}" output_seg_file=File.new(segfilename,'w') if @@seg_name_html[tracking-1] - minitoc=(@env.html_minitoc?) \ + minitoc=(@make.html_minitoc?) \ ? @minitoc : '' if dob.is==:heading \ diff --git a/lib/sisu/v3dv/options.rb b/lib/sisu/v3dv/options.rb index fbb3261e..b2b7ff15 100644 --- a/lib/sisu/v3dv/options.rb +++ b/lib/sisu/v3dv/options.rb @@ -486,8 +486,68 @@ module SiSU_Commandline || mod.inspect =~/"--maintenance|--keep-processing-files"/) \ ? { bool: true } : { bool: false } - act[:ocn]=if mod.inspect =~/"--no-ocn"/ - { bool: false } + act[:switch]=if mod.inspect =~/"--switch-off=/ + off_list=mod.join(';').gsub(/^.*--switch-off=['"]?(.+?)(?:['"];.+)?$/,'\1') + off_list=off_list.scan(/[^,;\s]+/) + { bool: false, off: off_list} + else { bool: true, off: [] } + end + act[:ocn]=if mod.inspect =~/"--no-ocn"/ \ + || act[:switch][:off].inspect =~/"ocn"/ + { bool: false } + else { bool: true } + end + act[:toc]=if mod.inspect =~/"--no-toc"/ \ + || act[:switch][:off].inspect =~/"toc"/ + { bool: false } + else { bool: true } + end + act[:manifest]=if mod.inspect =~/"--no-manifest"/ \ + || act[:switch][:off].inspect =~/"manifest"/ + #|| mod.inspect =~/"--(?:redirect|dump)/ + { bool: false } + else { bool: true } + end + act[:manifest_links]=if mod.inspect =~/"--no-manifest-links"/ \ + || act[:switch][:off].inspect =~/"manifest_links"/ \ + || mod.inspect =~/"--(?:redirect|dump)/ + { bool: false } + else { bool: true } + end + act[:manifest_minitoc]=if mod.inspect =~/"--no-manifest-minitoc"/ \ + || act[:switch][:off].inspect =~/"manifest_minitoc"|"minitoc"/ + #|| mod.inspect =~/"--(?:redirect|dump)/ + { bool: false } + else { bool: true } + end + act[:metadata]=if mod.inspect =~/"--no-metadata"/ \ + || act[:switch][:off].inspect =~/"metadata"/ + { bool: false } + else { bool: true } + end + act[:html_minitoc]=if mod.inspect =~/"--no-html-minitoc"/ \ + || act[:switch][:off].inspect =~/"html_minitoc"|"minitoc"/ + { bool: false } + else { bool: true } + end + act[:html_navigation]=if mod.inspect =~/"--no-html-navigation"/ \ + || act[:switch][:off].inspect =~/"html_navigation"|"nav"/ + { bool: false } + else { bool: true } + end + act[:html_navigation_bar]=if mod.inspect =~/"--no-html-navigation-bar"/ \ + || act[:switch][:off].inspect =~/"html_navigation_bar"|"navbar"/ + { bool: false } + else { bool: true } + end + act[:html_search_form]=if mod.inspect =~/"--no-html-search-form"/ \ + || act[:switch][:off].inspect =~/"html_search_form"|"search"/ + { bool: false } + else { bool: true } + end + act[:html_right_column]=if mod.inspect =~/"--no-html-right-column"/ \ + || act[:switch][:off].inspect =~/"html_right_column"|"promo"/ + { bool: false } else { bool: true } end act[:dal]=(cmd =~/m/ \ diff --git a/lib/sisu/v3dv/param.rb b/lib/sisu/v3dv/param.rb index fac9ad76..8d3379b7 100644 --- a/lib/sisu/v3dv/param.rb +++ b/lib/sisu/v3dv/param.rb @@ -811,6 +811,9 @@ module SiSU_Param else nil end end + def omit_list + m=@h['omit'] + end def texpdf_font def main @h['texpdf_font'] \ diff --git a/lib/sisu/v3dv/sysenv.rb b/lib/sisu/v3dv/sysenv.rb index b305dfb7..fcfc234b 100644 --- a/lib/sisu/v3dv/sysenv.rb +++ b/lib/sisu/v3dv/sysenv.rb @@ -1199,6 +1199,129 @@ module SiSU_Env else false end end + def manifest_minitoc? + flag=if (defined? @rc['manifest']['minitoc'] \ + and not @rc['manifest']['minitoc'].nil?) + @rc['manifest']['minitoc'] + else false + end + end + def build + def omit_list + @off_list ||=if (defined? @rc['omit_list'] \ + and not @rc['omit_list'].nil?) + @rc['omit_list'] + elsif (defined? @rc['omit']['list'] \ + and not @rc['omit']['list'].nil?) + @rc['omit']['list'] + else + nil + end + end + def listed?(test) #fix + listed=if omit_list + x=(omit_list.scan(/\b#{test}\b/)).join + test==x \ + ? true \ + : false + else + false + end + listed + end + def ocn? + flag=if (defined? @rc['omit']['ocn'] \ + and not @rc['omit']['ocn'].nil?) \ + or listed?('ocn') + false + else + true + end + end + def toc? + flag=if (defined? @rc['omit']['toc'] \ + and not @rc['omit']['toc'].nil?) \ + or listed?('toc') + false + else + true + end + end + def manifest? + flag=if (defined? @rc['omit']['manifest'] \ + and not @rc['omit']['manifest'].nil?) \ + or listed?('manifest') + false + else + true + end + end + def manifest_links? + flag=if (defined? @rc['omit']['manifest_links'] \ + and not @rc['omit']['manifest_links'].nil?) \ + or listed?('manifest_links') + false + else + true + end + end + def manifest_minitoc? + flag=if (defined? @rc['omit']['manifest_minitoc'] \ + and not @rc['omit']['manifest_minitoc'].nil?) \ + or listed?('manifest_minitoc') + false + else + true + end + end + def html_minitoc? + flag=if (defined? @rc['omit']['html_minitoc'] \ + and not @rc['omit']['html_minitoc'].nil?) \ + or (listed?('html_minitoc') \ + || listed?('minitoc')) + false + else + true + end + end + def html_navigation? + flag=if (defined? @rc['omit']['html_navigation'] \ + and not @rc['omit']['html_navigation'].nil?) \ + or listed?('html_navigation') + false + else + true + end + end + def html_navigation_bar? + flag=if (defined? @rc['omit']['html_navigation_bar'] \ + and not @rc['omit']['html_navigation_bar'].nil?) \ + or listed?('html_navigation_bar') + false + else + true + end + end + def html_search_form? + flag=if (defined? @rc['omit']['html_search_form'] \ + and not @rc['omit']['html_search_form'].nil?) \ + or listed?('html_search_form') + false + else + true + end + end + def html_right_column? + flag=if (defined? @rc['omit']['html_right_column'] \ + and not @rc['omit']['html_right_column'].nil?) \ + or listed?('html_right_column') + false + else + true + end + end + self + end def odt_ocn? ((defined? @rc['odt']['ocn']) \ && @rc['odt']['ocn']==true) \ @@ -4826,6 +4949,104 @@ WOK self end end + class InfoSet #