From 8138e2301b94ad697109c9e00da24710840b94c6 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 14 Feb 2012 20:33:26 -0500 Subject: v3dv: sysenv, output_dir_structure, rewritten, affected code modified --- lib/sisu/v3dv/cgi_pgsql.rb | 2 +- lib/sisu/v3dv/cgi_sql_common.rb | 4 +- lib/sisu/v3dv/cgi_sqlite.rb | 2 +- lib/sisu/v3dv/dal_expand_insertions.rb | 4 +- lib/sisu/v3dv/param.rb | 2 +- lib/sisu/v3dv/sysenv.rb | 68 ++++++++++++++-------------------- 6 files changed, 34 insertions(+), 48 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3dv/cgi_pgsql.rb b/lib/sisu/v3dv/cgi_pgsql.rb index 26a85874..8b3f0224 100644 --- a/lib/sisu/v3dv/cgi_pgsql.rb +++ b/lib/sisu/v3dv/cgi_pgsql.rb @@ -68,7 +68,7 @@ module SiSU_CGI_PgSQL @image_src="#{@env.url.webserv_cgi}/_sisu/image_sys" @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env) @db=SiSU_Env::InfoDb.new - @cgi_file_name="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by}_pgsql.cgi" + @cgi_file_name="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by.to_s}_pgsql.cgi" end def pgsql serve=[] diff --git a/lib/sisu/v3dv/cgi_sql_common.rb b/lib/sisu/v3dv/cgi_sql_common.rb index 0f17bb79..8a7c126f 100644 --- a/lib/sisu/v3dv/cgi_sql_common.rb +++ b/lib/sisu/v3dv/cgi_sql_common.rb @@ -841,7 +841,7 @@ module SiSU_CGI_SQL end def dir_structure case @opt.dir_structure_by - when /language/ + when :language <<-'WOK_SQL' def path_manifest(fn,ln=nil) "#{@hostpath}/#{ln}/manifest/#{fn}.html" @@ -862,7 +862,7 @@ module SiSU_CGI_SQL "#{@hostpath}/#{ln}/html/#{fn}.html" end WOK_SQL - when /filetype/ + when :filetype <<-'WOK_SQL' def path_manifest(fn,ln=nil) "#{@hostpath}/manifest/#{fn}.#{ln}.html" diff --git a/lib/sisu/v3dv/cgi_sqlite.rb b/lib/sisu/v3dv/cgi_sqlite.rb index 31ba44c4..9c2a6a8d 100644 --- a/lib/sisu/v3dv/cgi_sqlite.rb +++ b/lib/sisu/v3dv/cgi_sqlite.rb @@ -66,7 +66,7 @@ module SiSU_CGI_SQLite @env=SiSU_Env::InfoEnv.new('',opt) @image_src="#{@env.url.webserv_cgi}/_sisu/image_sys" @common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env) - @cgi_file_name="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by}_sqlite.cgi" + @cgi_file_name="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by.to_s}_sqlite.cgi" end def sqlite serve=[] diff --git a/lib/sisu/v3dv/dal_expand_insertions.rb b/lib/sisu/v3dv/dal_expand_insertions.rb index 8ec52065..9e675bc4 100644 --- a/lib/sisu/v3dv/dal_expand_insertions.rb +++ b/lib/sisu/v3dv/dal_expand_insertions.rb @@ -289,7 +289,7 @@ module SiSU_DAL_Insertions end lnk={} case @md.opt.dir_structure_by - when /language/ + when :language lnk={ manifest: by_language(linked_doc,linked_doc_lang).manifest, html_toc: by_language(linked_doc,linked_doc_lang).html_toc, @@ -307,7 +307,7 @@ module SiSU_DAL_Insertions sisupod: by_language(linked_doc,linked_doc_lang,source).sisupod, source: by_language(linked_doc,linked_doc_lang,source).source, } - when /filetype/ + when :filetype lnk={ manifest: by_filetype(linked_doc,linked_doc_lang).manifest, html_toc: by_filetype(linked_doc,linked_doc_lang).html_toc, diff --git a/lib/sisu/v3dv/param.rb b/lib/sisu/v3dv/param.rb index fc2ac877..f9734da3 100644 --- a/lib/sisu/v3dv/param.rb +++ b/lib/sisu/v3dv/param.rb @@ -963,7 +963,7 @@ 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/) \ + @lang_code_insert=(@opt.dir_structure_by ==:language) \ ? '' : ".#{@opt.lng}" @rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m diff --git a/lib/sisu/v3dv/sysenv.rb b/lib/sisu/v3dv/sysenv.rb index 1b1a5857..7374d88f 100644 --- a/lib/sisu/v3dv/sysenv.rb +++ b/lib/sisu/v3dv/sysenv.rb @@ -405,56 +405,42 @@ module SiSU_Env @fnn,@fnb,@fnt,@flv,@fnz=@@fnn,@@fnb,@@fnt,@@flv,@@fnz end def output_dir_structure - def by_language_code? - x=if defined? @rc['output_dir_structure_by'] \ - and @rc['output_dir_structure_by'] =~/language/ - true - elsif defined? @rc['output_structure']['by_language'] \ - and @rc['output_structure']['by_language'] ==true - true - else false + 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'] =~/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 + end end end + def by_language_code? + ((by?) ==:language) \ + ? true \ + : false + end def by_filetype? - x=if by_language_code? - false - elsif defined? @rc['output_dir_structure_by'] \ - and @rc['output_dir_structure_by'] =~/filetype/ - true - elsif defined? @rc['output_structure']['by_filetype'] \ - and @rc['output_structure']['by_filetype'] ==true - true - else false - end + ((by?) ==:filetype) \ + ? true \ + : false end def by_filename? - x=if by_language_code? - false - elsif by_filetype? - false - elsif defined? @rc['output_dir_structure_by'] \ - and @rc['output_dir_structure_by'] =~/filename/ - true - elsif defined? @rc['output_structure']['by_filename'] \ - and @rc['output_structure']['by_filename'] ==true - true - else true - end + ((by?) ==:filename) \ + ? true \ + : false end def multilingual? by_language_code? end - def by? - by=if by_language_code? - 'language' - elsif by_filetype? - 'filetype' - elsif by_filename? - 'filename' - else - 'filename' - end - end self end def document_language_versions_found #REVISIT -- cgit v1.2.3 From 2b884fb73428186df29bf22ff38d77e5d2f823cf Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 14 Feb 2012 21:10:19 -0500 Subject: v3dv: --redirect (--redirect=dir_path) & --dump (--dump=dir_path) + consequences * --dump places output in directory specified, if none specified in the current directory (pwd). * --redirect places output in subdirectory under specified directory, subdirectory uses the filename (without the suffix). If no output directory is specified places the subdirectory under the current directory (pwd). * html, css incorporated into each file (concordance & manifest included) * html, xhtml & xmls, css copied into css subdirectory (not used by html as embedded) * html xmls, images copied to output directory * no links to manifest * manifest with relative links only * longer html filenames given to avoid names clashing (e.g. for toc, manifest, concordance) * html, epub, remove manifest toc links * -j copy images associated with file (images used by html & xmls) * automatically invoked by --dump & redirect * v3 v3dv: document --redirect, --dump, -j update sisu_commands.sst [documents not generated until v3.2.0 (when v3dv branch is merged into v3)] --- lib/sisu/v3dv/concordance.rb | 4 +- lib/sisu/v3dv/css.rb | 92 ++++++++++++ lib/sisu/v3dv/defaults.rb | 2 +- lib/sisu/v3dv/html.rb | 27 ++-- lib/sisu/v3dv/html_format.rb | 116 +++++++++++---- lib/sisu/v3dv/hub.rb | 8 +- lib/sisu/v3dv/manifest.rb | 70 +++++++--- lib/sisu/v3dv/options.rb | 30 +++- lib/sisu/v3dv/param.rb | 2 - lib/sisu/v3dv/shared_images.rb | 125 +++++++++++++++++ lib/sisu/v3dv/sisupod_make.rb | 2 +- lib/sisu/v3dv/sysenv.rb | 310 ++++++++++++++++++++++++++++------------- lib/sisu/v3dv/xhtml.rb | 4 +- lib/sisu/v3dv/xml.rb | 4 +- lib/sisu/v3dv/xml_dom.rb | 4 +- lib/sisu/v3dv/xml_format.rb | 6 +- 16 files changed, 625 insertions(+), 181 deletions(-) create mode 100644 lib/sisu/v3dv/shared_images.rb (limited to 'lib') diff --git a/lib/sisu/v3dv/concordance.rb b/lib/sisu/v3dv/concordance.rb index 82c53e7a..7ec234bc 100644 --- a/lib/sisu/v3dv/concordance.rb +++ b/lib/sisu/v3dv/concordance.rb @@ -121,7 +121,7 @@ WOK def create head_banner=SiSU_HTML_Format::HeadToc.new(@md) minitoc=SiSU_HTML_MiniToc::TocMini.new(@md,@data).songsheet.join("\n") - @css=SiSU_Env::CSS_Stylesheet.new(@md) + stylesheet=SiSU_Style::CSS_HeadInfo.new(@md).stylesheet toc='
' + minitoc + '
' < @@ -136,7 +136,7 @@ WOK - #{@css.html_seg} + #{stylesheet.css_head_seg} #{@vz.js_head} diff --git a/lib/sisu/v3dv/css.rb b/lib/sisu/v3dv/css.rb index 522aae7e..cdcd16cd 100644 --- a/lib/sisu/v3dv/css.rb +++ b/lib/sisu/v3dv/css.rb @@ -59,6 +59,98 @@ module SiSU_Style require_relative 'sysenv' # sysenv.rb require_relative 'defaults' # defaults.rb + class CSS_HeadInfo + def initialize(md,ft='html') + @md,@ft=md,ft + @env=SiSU_Env::InfoEnv.new('',md) + @fn_css ||=SiSU_Env::CSS_Default.new + @o_str ||=SiSU_Env::OutputStructure.new(md).output_dir_structure + css_copy + end + def stylesheet + def css_path + SiSU_Env::CSS_Stylesheet.new(@md) + end + def css_embed_content + @css_embed_content ||=SiSU_Style::CSS.new + end + def css_embed? + if @ft=='html' \ + && @o_str.dump_or_redirect? + true + else + false + end + end + def css_embed(css) + <<-WOK + + WOK + end + def css_action + style_css=SiSU_Style::CSS.new + css=case @ft + when 'html' + css=css_embed_content.html + css_embed(css) + when 'xhtml' + css_path.xhtml + when 'xml_sax' + css_path.xml_sax + when 'xml_dom' + css_path.xml_dom + else + css_embed_content.html + end + end + def css_head + (css_embed?) \ + ? css_action\ + : "#{css_path.html}#{css_path.html_seg}" + end + def css_head_seg + (css_embed?) \ + ? css_action \ + : css_path.html_seg + end + def css_head_xml + css_action + end + self + end + def css_copy + if @o_str.dump_or_redirect? + css=SiSU_Style::CSS.new + if @o_str.dump? + css_pth="#{@md.opt.opt_act[:dump][:inst]}/#{@env.path.style}" + elsif @o_str.redirect? + css_pth="#{@md.opt.opt_act[:redirect][:inst]}/#{@md.fnb}/#{@env.path.style}" + end + FileUtils::mkdir_p(css_pth) unless FileTest.directory?(css_pth) + case @ft + when 'html' + style=File.new("#{css_pth}/#{@fn_css.html}",'w') + style << css.html + style.close + when 'xhtml' + style=File.new("#{css_pth}/#{@fn_css.xhtml}",'w') + style << css.xhtml + style.close + when 'xml_sax' + style=File.new("#{css_pth}/#{@fn_css.xml_sax}",'w') + style << css.xml_sax + style.close + when 'xml_dom' + style=File.new("#{css_pth}/#{@fn_css.xml_dom}",'w') + style << css.xml_dom + style.close + css_path.xml_dom + end + end + end + end class CSS def initialize @vz=SiSU_Env::GetInit.instance.skin diff --git a/lib/sisu/v3dv/defaults.rb b/lib/sisu/v3dv/defaults.rb index 1c9dd94f..eab42b71 100644 --- a/lib/sisu/v3dv/defaults.rb +++ b/lib/sisu/v3dv/defaults.rb @@ -1040,7 +1040,7 @@ module SiSU_Viz def png_book %{Cameron May Books} end - #% png_nav + #% png_nav #not currently used def png_nav_home end def png_nav_toc diff --git a/lib/sisu/v3dv/html.rb b/lib/sisu/v3dv/html.rb index ec7b0573..75d89382 100644 --- a/lib/sisu/v3dv/html.rb +++ b/lib/sisu/v3dv/html.rb @@ -138,14 +138,10 @@ module SiSU_HTML def link_images @symlnk.images end - def directories - title=File.basename(@md.fns,'.rb') - end def tuned_file_instructions @tell=SiSU_Screen::Ansi.new(@md.opt.cmd) @md.opt.cmd=@md.opt.cmd.gsub(/H/,'h') - @md.file_type='html' if @md.opt.cmd =~/[hon]/ - directories + @md.file_type='html' if @md.opt.cmd =~/[hw]/ newfilename=%{#{@md.file.output_path.html_scroll.dir}/#{@md.file.base_filename.html_segtoc}} if @md.file_type =~/html/ dal_array=@particulars.dal_array # dal file drawn here @tuned_file_array=SiSU_HTML_Tune::Tune.new(dal_array,@md).songsheet @@ -611,7 +607,8 @@ WOK class Output def initialize(data='',md='') @data,@md=data,md - @file=SiSU_Env::FileOp.new(@md) + @file=SiSU_Env::FileOp.new(md) + @o_str ||=SiSU_Env::OutputStructure.new(md).output_dir_structure end def scroll begin @@ -646,15 +643,17 @@ WOK rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error ensure @filename_html_segtoc.close - unless FileTest.file?("#{@file.output_path.html_seg.dir}/#{@md.file.base_filename.html_seg_index}") - pwd_set=Dir.pwd - idx_lnk=@file.base_filename.html_segtoc - mlnk=@file.base_filename.html_seg_index - Dir.chdir(@file.output_path.html_seg.dir) - FileUtils::rm_f(mlnk) - FileUtils::ln_s(idx_lnk, mlnk) - Dir.chdir(pwd_set) + pwd_set=Dir.pwd + idx_lnk=if @o_str.dump_or_redirect? + @file.base_filename.manifest + else + @file.base_filename.html_segtoc end + mlnk=@file.base_filename.html_seg_index + Dir.chdir(@file.output_path.html_seg.dir) + FileUtils::rm_f(mlnk) + FileUtils::ln_s(idx_lnk,mlnk) + Dir.chdir(pwd_set) end end end diff --git a/lib/sisu/v3dv/html_format.rb b/lib/sisu/v3dv/html_format.rb index 29d1bfcb..d8b44760 100644 --- a/lib/sisu/v3dv/html_format.rb +++ b/lib/sisu/v3dv/html_format.rb @@ -96,6 +96,7 @@ module SiSU_HTML_Format end end class HeadInformation + require_relative 'css' # css.rb require_relative 'shared_xml' # shared_xml.rb include SiSU_Viz attr_reader :md,:rdf,:vz @@ -103,12 +104,61 @@ module SiSU_HTML_Format @md=md # DublinCore 1 - title @vz=SiSU_Env::GetInit.instance.skin - @css=SiSU_Env::CSS_Stylesheet.new(md) @seg_name_html=(SiSU_HTML::Source::Seg.new.seg_name_html || []) @seg_name_html_tracker=(SiSU_HTML::Source::Seg.new.seg_name_html_tracker || []) - @toc,@index='toc','index' @metalink='#metadata' @tocband_scroll,@tocband_segtoc=nil,nil + @stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet + @o_str ||=SiSU_Env::OutputStructure.new(md).output_dir_structure + @index='index' + @toc="#{@md.file.output_path.html_seg.dir}/#{@md.file.base_filename.html_segtoc}" + end + def url_path_image_sys + (@o_str.dump_or_redirect?) \ + ? './image' + : "#{Xx[:html_relative2]}_sisu/image_sys" + end + def icon + def up + 'arrow_up_red.png' + end + def next + 'arrow_next_red.png' + end + def previous + 'arrow_prev_red.png' + end + def dot_clear + 'dot_clear.png' + end + def dot_white + 'dot_white.png' + end + def dot + dot_white + end + self + end + def png_nav + def toc + %{TOC} + end + def pre + %{<< previous} + end + def nxt + %{next >>} + end + def dot_toc + %{^} + end + def dot_pre + %{<} + end + def dot_nxt + %{>} + end + self end def doc_types #used in toc & seg_nav_band scroll=seg='' @@ -154,8 +204,9 @@ module SiSU_HTML_Format super(md) @md=md @cf_defaults=SiSU_Env::InfoProcessingFlag.new - @env=SiSU_Env::InfoEnv.new(@md.fns) - @file=SiSU_Env::FileOp.new(@md) + @env=SiSU_Env::InfoEnv.new(md.fns) + @file=SiSU_Env::FileOp.new(md) + @o_str ||=SiSU_Env::OutputStructure.new(md).output_dir_structure end def home %{ @@ -187,16 +238,19 @@ module SiSU_HTML_Format env.widget.search_form('sisusearch',nil,nil,true) end def manifest - manifest_lnk=if @file.output_dir_structure.by_language_code? \ - or @file.output_dir_structure.by_filetype? - "#{Xx[:html_relative1]}manifest/#{@file.base_filename.manifest}" - else @file.base_filename.manifest - end + if not @o_str.dump_or_redirect? + manifest_lnk=if @file.output_dir_structure.by_language_code? \ + or @file.output_dir_structure.by_filetype? + "#{Xx[:html_relative1]}manifest/#{@file.base_filename.manifest}" + else @file.base_filename.manifest + end %{ #{@vz.nav_txt_manifest} } + else '' + end end def pdf #retired 2.7.9 pdf=if @md.programs[:pdf] \ @@ -267,6 +321,7 @@ module SiSU_HTML_Format def initialize(md) super(md) @md=md + @o_str ||=SiSU_Env::OutputStructure.new(md).output_dir_structure end def scroll_head_navigation_band pdf=if @md.programs[:pdf] @@ -293,14 +348,14 @@ WOK   - #{@vz.png_nav_toc} + #{png_nav.toc}   #{@vz.table_close}

} end def seg_head_navigation_band(type='') firstseg=%{ - #{@vz.png_nav_nxt} + #{png_nav.nxt} } if @md.firstseg =~/\S+/ %{
@@ -319,7 +374,7 @@ WOK @tocband_segtoc=make_scroll_seg_pdf end firstseg=%{ - #{@vz.png_nav_nxt} + #{png_nav.nxt} } if @md.firstseg =~/\S+/ %{
@@ -394,7 +449,7 @@ WOK #{rdf.metatag_html} -#{@css.html}#{@css.html_seg} +#{@stylesheet.css_head} #{@vz.color_body} @@ -529,12 +584,15 @@ WOK #{@vz.table_close}} end def manifest #check structure - manifest=manifest_link(@vz.nav_txt_manifest) - %{#{@vz.margin_txt_3} + if not @o_str.dump_or_redirect? + manifest=manifest_link(@vz.nav_txt_manifest) + %{#{@vz.margin_txt_3} #{@vz.paragraph_font_small} #{manifest} #{@vz.table_close}} + else '' + end end def concordance #check structure concord=concordance_link(@vz.nav_txt_concordance) @@ -618,14 +676,14 @@ WOK end end class HeadSeg < HeadInformation - def initialize(md) #(md='') + def initialize(md) super(md) end def title_banner(title,subtitle,creator) end def dot_control_pre_next pre="#{@seg_name_html[@seg_name_html_tracker-1]}#{@md.lang_code_insert}#{Sfx[:html]}" - up="#{@toc}#{@md.lang_code_insert}#{Sfx[:html]}" + up=@toc nxt="#{@seg_name_html[@seg_name_html_tracker+1]}#{@md.lang_code_insert}#{Sfx[:html]}" if nxt=~/sisu_manifest\.html/ @file=SiSU_Env::FileOp.new(@md) if @md @@ -637,56 +695,56 @@ WOK %{
- #{@vz.png_nav_dot_pre} + #{png_nav.dot_pre} - #{@vz.png_nav_dot_toc} + #{png_nav.dot_toc} - #{@vz.png_nav_dot_nxt} + #{png_nav.dot_nxt} #{@vz.table_close}} end def dot_control_pre pre="#{@seg_name_html[@seg_name_html_tracker-2]}#{@md.lang_code_insert}#{Sfx[:html]}" - up="#{@toc}#{@md.lang_code_insert}#{Sfx[:html]}" + up=@toc nxt="#{@md.file.base_filename.html_segtoc}" %{} pre=%{} if f_pre==true nxt=%{} if f_nxt==true if nxt =~/sisu_manifest.html/ @@ -853,7 +911,7 @@ WOK #{rdf.metatag_html} -#{@css.html_seg} +#{@stylesheet.css_head_seg} #{@vz.color_body} diff --git a/lib/sisu/v3dv/hub.rb b/lib/sisu/v3dv/hub.rb index 4924297a..fd7909ec 100644 --- a/lib/sisu/v3dv/hub.rb +++ b/lib/sisu/v3dv/hub.rb @@ -202,7 +202,7 @@ module SiSU when /^share_src$/; SiSU_Markup::Source.new(@opt).read # -s share_src.rb when /^sisupod_make$/; SiSU_Doc::Source.new(@opt).read # -S sisupod_make.rb # when /^source_kdissert$/; SiSU_KdiSource::Source.new(@opt).read # -S share_src_kdissert.rb - when /^digests$/; SiSU_DigestView::Source.new(@opt).read # -N digests.rb + when /^digests$/; SiSU_DigestView::Source.new(@opt).read # -N digests.rb when /^plaintext$/; SiSU_Plaintext::Source.new(@opt).read # -t -a plaintext.rb when /^po4a$/; SiSU_Po4a::Source.new(@opt).read # -P po4a.rb #when /^wikispeak$/; SiSU_Wikispeak::Source.new(@opt).read # -g @@ -216,6 +216,7 @@ module SiSU when /^xhtml$/; SiSU_XHTML::Source.new(@opt).read # -b xhtml.rb when /^xml$/; SiSU_XML_SAX::Source.new(@opt).read # -x xml.rb when /^xml_dom$/; SiSU_XML_DOM::Source.new(@opt).read # -X xml_dom.rb + when /^shared_images$/; SiSU_Images::Source.new(@opt).read # -j shared_images.rb #when /^xml_fictionbook$/; SiSU_XML_Fictionbook::Source.new(@opt).read # -f when /^xml_scaffold$/; SiSU_XML_Scaffold::Source.new(@opt).read # -k xml_scaffold.rb when /^embedded$/; SiSU_Embedded::Source.new(@opt).read # -m embedded.rb (image and other content) #check @@ -357,7 +358,7 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ 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 =~/([abCcDdeFGgHhIikLMmNnoPpQqRrSsTtUuVvWwXxYyZ_0-9])/ \ + elsif @opt.cmd =~/([abCcDdeFGgHhIjikLMmNnoPpQqRrSsTtUuVvWwXxYyZ_0-9])/ \ and @opt.cmd =~/^-/ \ and @opt.mod.inspect !~/--(?:sitemaps|query|identify)/ \ or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/ @@ -518,6 +519,9 @@ p "here #{__FILE__} #{__LINE__}" if @opt =~/M/ if @opt.act[:xhtml][:bool] #% --xhtml, -b xhtml op('xhtml','xhtml sax') end + if @opt.act[:images][:bool] #% --images, -j + op('shared_images','images') + end if @opt.act[:concordance][:bool] #% --concordance, -w op('concordance','Concordance') end diff --git a/lib/sisu/v3dv/manifest.rb b/lib/sisu/v3dv/manifest.rb index 3310fa98..19fdc65c 100644 --- a/lib/sisu/v3dv/manifest.rb +++ b/lib/sisu/v3dv/manifest.rb @@ -106,6 +106,12 @@ module SiSU_Manifest @fnb=@md.fnb @base_url="#{@env.url.root}/#{@fnb}" @f=SiSU_Env::FileOp.new(@md) + @o_str=SiSU_Env::OutputStructure.new(md).output_dir_structure + @image_path=if @o_str.dump_or_redirect? + %{./image} + else + %{#{@f.path_rel_links.html_scroll_2}_sisu/image_sys} + end @base_path=@f.output_path.manifest.dir @@dg ||=SiSU_Env::InfoEnv.new.digest.type @dg=@@dg @@ -113,6 +119,7 @@ module SiSU_Manifest @language=l[:n] @translate=SiSU_Translate::Source.new(@md,@language) @brace_url=SiSU_Viz::Skin.new.url_decoration + @stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet end def output manifest=@f.write_file.manifest @@ -122,17 +129,26 @@ module SiSU_Manifest manifest << x end end + def url_make(url,file,src=nil) + if @o_str.dump_or_redirect? + '' + elsif :src + %{
#{@brace_url.xml_open}#{url}/#{file}#{@brace_url.xml_close}} + else + %{

#{@brace_url.xml_open}#{url}/#{file}#{@brace_url.xml_close}

} + end + end def summarize(id,file,pth='',rel='',url='',img='● ') size=(File.size("#{pth}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] @manifest[:txt] << "#{file} #{id} #{kb}\n" - @manifest[:html] << %{\n} + @manifest[:html] << %{\n} end def summarize_html_seg(id,file,pth='',rel='',url='',img='● ') size=(File.size("#{pth}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] @manifest[:txt] << "#{file} #{id} #{kb}\n" - @manifest[:html] << %{\n} + @manifest[:html] << %{\n} end def summarize_sources(id,file,pth,rel,url) sys=SiSU_Env::SystemCall.new @@ -143,7 +159,7 @@ module SiSU_Manifest size=(File.size("#{pth}/#{file}")/1024.00).to_s kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1] @manifest[:txt] << "#{file} #{id} #{kb}\n" - @manifest[:html] << %{\n} if kb and kb =~/\d+/ + @manifest[:html] << %{\n} if kb and kb =~/\d+/ end def published_manifests? @f=SiSU_Env::FileOp.new(@md) #.base_filename @@ -153,7 +169,13 @@ module SiSU_Manifest mp,mn,mt,mr=nil,nil,nil,nil ln=SiSU_i18n::Languages.new.language.list Px[:lng_lst].each do |lc| - if @env.output_dir_structure.by_language_code? + if @o_str.dump_or_redirect? #does not work for --redirect or --dump + mp="#{@f.output_path.base.dir}" + mn="#{@md.fnb}.html" + mt="#{mp}/#{mn}" + mr="../../#{lc}/manifest/#{mn}" + mu="#{url}/#{mn}" + elsif @env.output_dir_structure.by_language_code? mp="#{@f.output_path.base.dir}/#{lc}/manifest" mn="#{@md.fnb}.html" mt="#{mp}/#{mn}" @@ -212,7 +234,7 @@ module SiSU_Manifest end def output_tests if FileTest.file?(@f.place_file.html_segtoc.dir)==true - img=%{TOC linked } + img=%{TOC linked } pth=@f.output_path.html_seg.dir rel=@f.output_path.html_seg.rel_sm url=@f.output_path.html_seg.url @@ -220,7 +242,7 @@ module SiSU_Manifest summarize_html_seg(id,file,pth,rel,url,img) end if FileTest.file?(@f.place_file.html_scroll.dir)==true - img=%{Full Text } + img=%{Full Text } pth=@f.output_path.html_scroll.dir rel=@f.output_path.html_scroll.rel_sm url=@f.output_path.html_scroll.url @@ -242,7 +264,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url) end if FileTest.file?(@f.place_file.epub.dir)==true - img=%{EPUB } + img=%{EPUB } id,file='EPUB (Electronic Publication, e-book standard)',@f.base_filename.epub pth=@f.output_path.epub.dir rel=@f.output_path.epub.rel_sm @@ -250,7 +272,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_letter}")==true - img=%{PDF portrait } + img=%{PDF portrait } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -258,7 +280,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_letter}")==true - img=%{PDF landscape } + img=%{PDF landscape } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -266,7 +288,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_a4}")==true - img=%{PDF portrait } + img=%{PDF portrait } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -274,7 +296,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_a4}")==true - img=%{PDF landscape } + img=%{PDF landscape } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -282,7 +304,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_a5}")==true - img=%{PDF portrait } + img=%{PDF portrait } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -290,7 +312,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_a5}")==true - img=%{PDF landscape } + img=%{PDF landscape } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -298,7 +320,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_b5}")==true - img=%{PDF portrait } + img=%{PDF portrait } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -306,7 +328,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_b5}")==true - img=%{PDF landscape } + img=%{PDF landscape } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -314,7 +336,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_legal}")==true - img=%{PDF portrait } + img=%{PDF portrait } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -322,7 +344,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_legal}")==true - img=%{PDF landscape } + img=%{PDF landscape } pth=@f.output_path.pdf.dir rel=@f.output_path.pdf.rel_sm url=@f.output_path.pdf.url @@ -330,7 +352,7 @@ module SiSU_Manifest summarize(id,file,pth,rel,url,img) end if FileTest.file?(@f.place_file.odt.dir)==true - img=%{ODF/ODT } + img=%{ODF/ODT } pth=@f.output_path.odt.dir rel=@f.output_path.odt.rel_sm url=@f.output_path.odt.url @@ -416,8 +438,11 @@ module SiSU_Manifest end def qrc_image fn=@md.fnb - img_md="qrcode/#{fn}.md.png" - img_title="qrcode/#{fn}.title.png" + pth=(@o_str.dump_or_redirect?) \ + ? '.' \ + : 'qrcode' + img_md="#{pth}/#{fn}.md.png" + img_title="#{pth}/#{fn}.title.png" if FileTest.file?(@f.place_file.qrcode_md.dir)==true @manifest[:html] <<<
- #{@vz.png_nav_dot_pre} + #{png_nav.dot_pre} - #{@vz.png_nav_dot_toc} + #{png_nav.dot_toc} - #{@vz.png_nav_dot_nxt} + #{png_nav.dot_nxt} #{@vz.table_close}} end def toc_nav(f_pre=false,f_nxt=false,use=1) pre=nxt='' toc=%{ - - #{@vz.png_nav_toc} + + #{png_nav.toc} - #{@vz.png_nav_pre} + #{png_nav.pre} - #{@vz.png_nav_nxt} + #{png_nav.nxt}

#{img}#{id}

#{file}

#{@brace_url.xml_open}#{url}/#{file}#{@brace_url.xml_close}

#{kb}

#{img}#{id}

#{file}

#{url_make(url,file)}

#{kb}

#{img}#{id}

#{file}

#{@brace_url.xml_open}#{url}/#{file}#{@brace_url.xml_close}

#{kb}

#{img}#{id}

#{file}

#{url_make(url,file)}

#{kb}

#{id}

#{file}   #{dgst[1]}
#{@brace_url.xml_open}#{url}/#{file}#{@brace_url.xml_close}

#{kb}

#{id}

#{file}   #{dgst[1]}#{url_make(url,file,:src)}

#{kb}

@@ -763,13 +788,14 @@ SiSU manifest: #{@md.title.full} - +#{@stylesheet.css_head} #{banner_table} WOK if @env.manifest_minitoc? - if @env.output_dir_structure.by_language_code? \ + if @o_str.dump_or_redirect? + elsif @env.output_dir_structure.by_language_code? \ or @env.output_dir_structure.by_filetype? minitoc=minitoc.gsub(/. + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: common file for xml generation +=end +module SiSU_Images + class Source + def initialize(opt) + @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt) + end + def read + SiSU_Images::Source::Place.new(@particulars).songsheet + end + class Place + def initialize(particulars) + @particulars=particulars + @md=@particulars.md + @env=@particulars.env + @o_str ||=SiSU_Env::OutputStructure.new(@md).output_dir_structure + end + def songsheet + images_set.select_sisu_base + images_set.select_with_document + end + def images_set + @pwd=ENV['PWD'] + def copy(src_path,dest_path,images=nil) + if FileTest.directory?(src_path) + FileUtils::cd(src_path) + unless images + images=Dir.glob("*.{png,jpg,gif,ico}") + end + FileUtils::mkdir_p(dest_path) unless FileTest.directory?(dest_path) + FileUtils::chmod(0755,dest_path) + if images.length > 0 + images.each do |i| + FileUtils::cp_r(i,"#{dest_path}/#{i}") + FileUtils::chmod(0644,"#{dest_path}/#{i}") + end + end + FileUtils::cd(@pwd) + else puts "\tWARN, did not find - #{src_path}" + end + end + def dest_path(image_type) + pth=if image_type==:image_sys + pth=(@o_str.dump_or_redirect?) \ + ? "#{@md.file.output_path.html.dir}/image" \ + : "#{@env.path.webserv}/_sisu/image_sys" + elsif image_type==:image + pth=(@o_str.dump_or_redirect?) \ + ? "#{@md.file.output_path.html.dir}/image" \ + : "#{@env.path.webserv}/_sisu/image" + end + end + def select_with_document + images=@md.ec[:image] + src_path="#{@pwd}/_sisu/image" + dest=dest_path(:image) + copy(src_path,dest,images) + end + def select_sisu_base + images=%w[arrow_next_red.png arrow_prev_red.png arrow_up_red.png dot_clear.png dot_white.png b_doc.png b_epub.png b_odf.png b_pdf.png b_toc.png] + src_path="#{@env.path.share}/image" + dest=dest_path(:image_sys) + copy(src_path,dest,images) + end + self + end + end + end +end +__END__ diff --git a/lib/sisu/v3dv/sisupod_make.rb b/lib/sisu/v3dv/sisupod_make.rb index 4b1a5ef9..ac584925 100644 --- a/lib/sisu/v3dv/sisupod_make.rb +++ b/lib/sisu/v3dv/sisupod_make.rb @@ -293,7 +293,7 @@ module SiSU_Doc tar -cJf #{@zipfile}.txz sisupod #echo "#{@file.place_file.sisupod.dir}" }) - FileUtils::mv("#{@zipfile}.txz", @file.place_file.sisupod.dir) + FileUtils::mv("#{@zipfile}.txz",@file.place_file.sisupod.dir) FileUtils::rm_r(Dir.glob("sisupod/*")) Dir.chdir(@env.path.pwd) SiSU_Screen::Ansi.new('',"#{@opt.fns}.txz").blue_tab unless @opt.cmd =~/q/ diff --git a/lib/sisu/v3dv/sysenv.rb b/lib/sisu/v3dv/sysenv.rb index 7374d88f..b305dfb7 100644 --- a/lib/sisu/v3dv/sysenv.rb +++ b/lib/sisu/v3dv/sysenv.rb @@ -408,7 +408,15 @@ module SiSU_Env 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'] =~/language/) \ + 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 @@ -420,9 +428,21 @@ module SiSU_Env or ((defined? @rc['output_structure']['by_filename']) \ && @rc['output_structure']['by_filename'] ==true) :filename + else #recheck current default + :language end end end + def dump? + ((by?) ==:dump) \ + ? true \ + : false + end + def redirect? + ((by?) ==:redirect) \ + ? true \ + : false + end def by_language_code? ((by?) ==:language) \ ? true \ @@ -1568,7 +1588,12 @@ WOK end end def default_output_css - if @env.output_dir_structure.by_language_code? + if (@md.opt.opt_act[:dump][:bool] \ + && @md.opt.opt_act[:dump][:inst]) \ + || (@md.opt.opt_act[:redirect][:bool] \ + && @md.opt.opt_act[:redirect][:inst]) + './' + elsif @env.output_dir_structure.by_language_code? '../../' elsif @env.output_dir_structure.by_filetype? '../' @@ -1664,7 +1689,14 @@ WOK defaults[:sisu_share] end def style - defaults[:stylesheet_stub] + if (@md.opt.opt_act[:dump][:bool] \ + && @md.opt.opt_act[:dump][:inst]) \ + || (@md.opt.opt_act[:redirect][:bool] \ + && @md.opt.opt_act[:redirect][:inst]) + 'css' + else + defaults[:stylesheet_stub] + end end def sample_data #sample data repository source directory defaults[:sample_data_path] @@ -3312,14 +3344,10 @@ WOK end end end - class FileOp ' : '' @@xml[:open] =< WOK diff --git a/lib/sisu/v3dv/xml.rb b/lib/sisu/v3dv/xml.rb index 1187e02e..aa75e139 100644 --- a/lib/sisu/v3dv/xml.rb +++ b/lib/sisu/v3dv/xml.rb @@ -396,13 +396,13 @@ WOK rdf=SiSU_XML_Tags::RDF.new(@md) dir=SiSU_Env::InfoEnv.new @@xml[:head],@@xml[:body]=[],[] - css=SiSU_Env::CSS_Stylesheet.new(@md) + stylesheet=SiSU_Style::CSS_HeadInfo.new(@md,'xml_sax').stylesheet encoding=if @sys.locale =~/utf-?8/i; '' else '' end @@xml[:open] =< WOK diff --git a/lib/sisu/v3dv/xml_dom.rb b/lib/sisu/v3dv/xml_dom.rb index e63f7ad7..6b8c4e5c 100644 --- a/lib/sisu/v3dv/xml_dom.rb +++ b/lib/sisu/v3dv/xml_dom.rb @@ -470,13 +470,13 @@ WOK def pre rdf=SiSU_XML_Tags::RDF.new(@md) dir=SiSU_Env::InfoEnv.new - css=SiSU_Env::CSS_Stylesheet.new(@md) + stylesheet=SiSU_Style::CSS_HeadInfo.new(@md,'xml_dom').stylesheet encoding=if @sys.locale =~/utf-?8/i; '' else '' end @@xml[:open] =< WOK diff --git a/lib/sisu/v3dv/xml_format.rb b/lib/sisu/v3dv/xml_format.rb index 50a9f5ac..0b1e9eef 100644 --- a/lib/sisu/v3dv/xml_format.rb +++ b/lib/sisu/v3dv/xml_format.rb @@ -374,7 +374,7 @@ WOK @rdf=SiSU_XML_Tags::RDF.new(md) # DublinCore 1 - title @vz=SiSU_Env::GetInit.instance.skin - @css=SiSU_Env::CSS_Stylesheet.new(md) + @stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet @seg_name_html=(SiSU_HTML::Source::Seg.new.seg_name_html || []) @seg_name_html_tracker=(SiSU_HTML::Source::Seg.new.seg_name_html_tracker || []) @index='index' @@ -544,7 +544,7 @@ WOK #{@rdf.rdftoc} #{@rdf.metatag_html} -#{@css.html} +#{@stylesheet.css_head} #{@vz.color_body} @@ -938,7 +938,7 @@ WOK #{@rdf.rdfseg} #{@rdf.metatag_html} -#{@css.html} +#{@stylesheet.css_head} #{@vz.color_body} -- cgit v1.2.3 From f653df1613b8ee994842139fd080bbc75325032f Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 14 Feb 2012 21:27:01 -0500 Subject: v3dv: dal, remove sisu_manifest from document structure & toc * html & epub coding affected --- lib/sisu/v3dv/dal_doc_str.rb | 5 ----- lib/sisu/v3dv/epub_segments.rb | 4 ++-- lib/sisu/v3dv/html_segments.rb | 12 ++++++------ 3 files changed, 8 insertions(+), 13 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3dv/dal_doc_str.rb b/lib/sisu/v3dv/dal_doc_str.rb index a3c697e0..b4a98edd 100644 --- a/lib/sisu/v3dv/dal_doc_str.rb +++ b/lib/sisu/v3dv/dal_doc_str.rb @@ -502,11 +502,6 @@ module SiSU_DAL_DocumentStructureExtract tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) h={ ln: 4, obj: 'SiSU Metadata, document information', name: 'metadata', autonum_: false, ocn_: false } tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) - tuned_file << @pb - h={ ln: 2, obj: 'Manifest', autonum_: false, ocn_: false } - tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) - h={ ln: 4, obj: 'SiSU Manifest, alternative outputs etc.', name: 'sisu_manifest', autonum_: false, ocn_: false } - tuned_file << SiSU_DAL_DocumentStructure::ObjectHeading.new.heading_insert(h) tuned_file h={ obj: 'eof' } meta=SiSU_DAL_DocumentStructure::ObjectMetadata.new.metadata(@metadata) diff --git a/lib/sisu/v3dv/epub_segments.rb b/lib/sisu/v3dv/epub_segments.rb index 55c6c1f9..96abfdc0 100644 --- a/lib/sisu/v3dv/epub_segments.rb +++ b/lib/sisu/v3dv/epub_segments.rb @@ -247,10 +247,10 @@ WOK SiSU_EPUB_Seg::Seg.new.reinitialise heading_art(dob) head(dob) - if @@seg_name_xhtml[tracking]=='sisu_manifest' # this is for manifest, includes navigation bug + if @@seg_name_xhtml[tracking] =='metadata' segfilename="#{dir_epub_cont}/#{@@seg_name_xhtml[tracking]}#{Sfx[:epub_xhtml]}" output_epub_cont_seg=File.new(segfilename,'w') - SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,@minitoc,'sisu_manifest').output + SiSU_EPUB_Seg::Output.new(@md,output_epub_cont_seg,@@seg,@minitoc,'metadata').output SiSU_EPUB_Seg::Seg.new.reinitialise #BUG navigation bug with items following metadata, and occurring before manifest, this becomes a bug ... work area for book index, FIX end #@output_epub_cont_seg.close #%(((( EOF )))) --> diff --git a/lib/sisu/v3dv/html_segments.rb b/lib/sisu/v3dv/html_segments.rb index eca87b12..05f30cc4 100644 --- a/lib/sisu/v3dv/html_segments.rb +++ b/lib/sisu/v3dv/html_segments.rb @@ -266,12 +266,12 @@ module SiSU_HTML_Seg heading_art(dob) head(dob) #keep use for last segment, eg if metadata is last segment - #if @@seg_name_html[tracking] =~/metadata/ # this is for metadata - # segfilename="#{@md.dir_out}/#{@md.fnl[:pre]}#{@@seg_name_html[tracking]}#{@md.fnl[:mid]}#{Sfx[:html]}#{@md.fnl[:post]}" - # output_seg_file=File.new(segfilename,'w') - # SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'metadata').output - # Seg.new.reinitialise - #end + 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]}" + output_seg_file=File.new(segfilename,'w') + SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'metadata').output + Seg.new.reinitialise + end end if tracking==0 heading_art(dob) -- cgit v1.2.3 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. --- 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 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 288 insertions(+), 3 deletions(-) (limited to 'lib') 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 #