From c2163c564756a6998fa9d82ae33c92724ab7f8fc Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 13 Sep 2011 19:20:25 -0400 Subject: v3: image (relative) paths for different sisu output structures * (re: by_language, by_filetype, by_filename) * sysenv, set path * html seg, scroll, manifest (qrcodes), xmls --- lib/sisu/v3/constants.rb | 5 +++-- lib/sisu/v3/html_scroll.rb | 1 + lib/sisu/v3/html_tune.rb | 7 ++++--- lib/sisu/v3/manifest.rb | 5 ++--- lib/sisu/v3/qrcode.rb | 4 ++-- lib/sisu/v3/shared_xml.rb | 12 ++++++------ lib/sisu/v3/sysenv.rb | 36 ++++++++++++++++++++++++++++++++++++ 7 files changed, 54 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/constants.rb b/lib/sisu/v3/constants.rb index 498ee1f3..1202e47c 100644 --- a/lib/sisu/v3/constants.rb +++ b/lib/sisu/v3/constants.rb @@ -65,8 +65,9 @@ Ax={ Xx={ protect: '☞', segment: 'Ф', - html_relative2: '※※', #'※' '☼' - html_relative1: '※', #'※' '☼' + relative_path: '☼', + html_relative2: '※※', + html_relative1: '※', } Mx={ meta_o: '〔@', meta_c: '〕', diff --git a/lib/sisu/v3/html_scroll.rb b/lib/sisu/v3/html_scroll.rb index 0a37bcca..beb3700a 100644 --- a/lib/sisu/v3/html_scroll.rb +++ b/lib/sisu/v3/html_scroll.rb @@ -81,6 +81,7 @@ module SiSU_HTML_scroll @rcdc=false @scr={ body: [], metadata: [], owner_details: [] } data.each do |dob| + dob.obj.gsub!(/#{@md.file.output_path.html_seg.rel_image}/m,@md.file.output_path.html_scroll.rel_image) if defined? dob.name and dob.name =~/^meta/ \ and dob.obj =~/Document Information/ dob.obj.gsub!(/(Document Information(?: \(metadata\))?)/,'\1') diff --git a/lib/sisu/v3/html_tune.rb b/lib/sisu/v3/html_tune.rb index c97183f1..afedec54 100644 --- a/lib/sisu/v3/html_tune.rb +++ b/lib/sisu/v3/html_tune.rb @@ -257,9 +257,10 @@ module SiSU_HTML_Tune c=m[/"(.+?)"/m,1] caption=%{

#{c}

} if c png=m.scan(/\S+/)[0] - image_path=if @md.fns =~/\.-ss[tm]$/; @env.url.images_external - else @env.url.images_local - end + image_path=@md.file.output_path.html_seg.rel_image + #image_path=(@md.fns =~/\.-ss[tm]$/) \ + #? @env.url.images_external + #: @env.url.images_local ins=if u \ and u.strip !~/^image$/ %{#{caption}} diff --git a/lib/sisu/v3/manifest.rb b/lib/sisu/v3/manifest.rb index 3b34d0b2..adc048ef 100644 --- a/lib/sisu/v3/manifest.rb +++ b/lib/sisu/v3/manifest.rb @@ -418,9 +418,8 @@ module SiSU_Manifest def qrc_image pth="#{@env.path.webserv}/#{@env.path.stub_pwd}/_sisu/image" fn=@f.base_filename.manifest_txt - #fix relative path for different output structures - img_md="../../_sisu/image/qrc_md.#{fn}.png" - img_title="../../_sisu/image/qrc_title.#{fn}.png" + img_md="#{@md.file.output_path.html.rel_image}/qrc_md.#{fn}.png" + img_title="#{@md.file.output_path.html.rel_image}/qrc_title.#{fn}.png" if FileTest.file?("#{pth}/qrc_md.#{fn}.png")==true @manifest[:html] <<< diff --git a/lib/sisu/v3/qrcode.rb b/lib/sisu/v3/qrcode.rb index fe9ca432..e244231e 100644 --- a/lib/sisu/v3/qrcode.rb +++ b/lib/sisu/v3/qrcode.rb @@ -709,9 +709,9 @@ WOK @en_manifest=if @env.output_dir_structure.by_language_code? "#{url}/en/manifest/#{@md.fnb}.html" elsif @env.output_dir_structure.by_filetype? - "#{url}/manifest/#{@md.fnb}.#{lc}.html" + "#{url}/manifest/#{@md.fnb}.#{@md.opt.lng}.html" else - "#{url}/sisu_manifest.#{lc}.html" + "#{url}/sisu_manifest.#{@md.opt.lng}.html" end @manifest[:txt] <<<\1') dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{[\\1] \\4}) + %{[\\1] \\4}) dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{\\1}) + %{\\1}) dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}image/, - %{[\\1] \\4}) + %{[\\1] \\4}) dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}image/, - %{\\1}) + %{\\1}) dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, '\1') #watch, compare html_tune dob.obj.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, @@ -416,7 +416,7 @@ module SiSU_XML_munge dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& ') #sort dob.obj.gsub!(/&([^;]{1,5})/,'&\1') #sort, rough estimate, revisit #WATCH found in node not sax dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif))[ ]+.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/, - "#{@dir.url.images_local}\/\\1") + "#{@md.file.output_path.xml.rel_image}\/\\1") dob.obj.gsub!(/ |#{Mx[:nbsp]}/,' ') wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17 dob.obj=tidywords(wordlist).join(' ').strip @@ -438,7 +438,7 @@ module SiSU_XML_munge dob.obj.gsub!(/(^|#{Mx[:gl_c]}|\s)&\s+/,'\1& ') #sort dob.obj.gsub!(/&([^;]{1,5})/,'&\1') #sort, rough estimate, revisit #WATCH found in node not sax dob.obj.gsub!(/(#{Mx[:lnk_o]}(\S+?\.(?:png|jpg|gif))[ ]+.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/, - "#{@dir.url.images_local}\/\\1") + "#{@md.file.output_path.xml.rel_image}\/\\1") dob.obj.gsub!(/ |#{Mx[:nbsp]}/,' ') wordlist=dob.obj.scan(/&[#0-9a-z]+;|\S+|\n/) #\n needed for tables, check though added 2005w17 dob.obj=tidywords(wordlist).join(' ').strip diff --git a/lib/sisu/v3/sysenv.rb b/lib/sisu/v3/sysenv.rb index f052e2a5..7463cb4b 100644 --- a/lib/sisu/v3/sysenv.rb +++ b/lib/sisu/v3/sysenv.rb @@ -4175,6 +4175,15 @@ WOK def rel_sm set_path(ft).rel_sm.ab end + def rel_image + if @env.output_dir_structure.by_language_code? + '../../_sisu/image' + elsif @env.output_dir_structure.by_filetype? + '../_sisu/image' + else + '../_sisu/image' + end + end self end def html_seg @@ -4196,6 +4205,15 @@ WOK def rel_sm set_path(ft).rel_sm.ab end + def rel_image + if @env.output_dir_structure.by_language_code? + '../../../_sisu/image' + elsif @env.output_dir_structure.by_filetype? + '../../_sisu/image' + else + '../_sisu/image' + end + end self end def html_concordance @@ -4221,6 +4239,15 @@ WOK def rel_sm set_path(ft).rel_sm.ab end + def rel_image + if @env.output_dir_structure.by_language_code? + '../../_sisu/image' + elsif @env.output_dir_structure.by_filetype? + '../_sisu/image' + else + '../_sisu/image' + end + end self end def xhtml @@ -4242,6 +4269,9 @@ WOK def rel_sm set_path(ft).rel_sm.ab end + def rel_image + '../../_sisu/image' + end self end def epub @@ -4263,6 +4293,9 @@ WOK def rel_sm set_path(ft).rel_sm.ab end + def rel_image + './image' + end self end def odt @@ -4305,6 +4338,9 @@ WOK def rel_sm set_path(ft).rel_sm.ab end + def rel_image + '../../_sisu/image' + end self end def xml_sax -- cgit v1.2.3