diff options
author | Ralph Amissah <ralph@amissah.com> | 2011-09-13 19:20:25 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2011-09-13 19:20:25 -0400 |
commit | c2163c564756a6998fa9d82ae33c92724ab7f8fc (patch) | |
tree | 99c7f51a11db67b559e955a0a21144f3915ecd70 /lib | |
parent | v3: dal_images, disabled imagemagick configuration permission check (diff) |
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
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v3/constants.rb | 5 | ||||
-rw-r--r-- | lib/sisu/v3/html_scroll.rb | 1 | ||||
-rw-r--r-- | lib/sisu/v3/html_tune.rb | 7 | ||||
-rw-r--r-- | lib/sisu/v3/manifest.rb | 5 | ||||
-rw-r--r-- | lib/sisu/v3/qrcode.rb | 4 | ||||
-rw-r--r-- | lib/sisu/v3/shared_xml.rb | 12 | ||||
-rw-r--r-- | lib/sisu/v3/sysenv.rb | 36 |
7 files changed, 54 insertions, 16 deletions
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<a name="docinfo"></a>') 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=%{<br /><p class="caption">#{c}</p>} 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$/ %{<a href="#{u}"><img src="#{image_path}/#{png}" #{w} #{h} naturalsizeflag="0" align="bottom" border="0"></a>#{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] <<<<WOK <tr><td class="left"> 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] <<<<WOK #{@translate.manifest_description_metadata} diff --git a/lib/sisu/v3/shared_xml.rb b/lib/sisu/v3/shared_xml.rb index daf59a4c..a1a68593 100644 --- a/lib/sisu/v3/shared_xml.rb +++ b/lib/sisu/v3/shared_xml.rb @@ -378,13 +378,13 @@ module SiSU_XML_munge dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]}/, '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="#\2">\1</link>') dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\1" width="\\2" height="\\3" />[\\1] \\4}) + %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@md.file.output_path.xml.rel_image}/\\1" width="\\2" height="\\3" />[\\1] \\4}) dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, - %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\1"/>\\1}) + %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@md.file.output_path.xml.rel_image}/\\1"/>\\1}) dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))[ ]+(\d+)x(\d+)(\s+[^}]+)?#{Mx[:lnk_c]}image/, - %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\1" width="\\2" height="\\3" />[\\1] \\4}) + %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@md.file.output_path.xml.rel_image}/\\1" width="\\2" height="\\3" />[\\1] \\4}) dob.obj.gsub!(/(?:^|[^_\\])#{Mx[:lnk_o]}[ ]*(\S+?\.(?:jpg|png|gif))([ ]+[^}]+)?#{Mx[:lnk_c]}image/, - %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@dir.url.images_local}/\\1"/>\\1}) + %{<image xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="#{@md.file.output_path.xml.rel_image}/\\1"/>\\1}) dob.obj.gsub!(/#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, '<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:type="simple" xlink:href="\2">\1</link>') #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)/, - "<image.path>#{@dir.url.images_local}\/\\1</image.path>") + "<image.path>#{@md.file.output_path.xml.rel_image}\/\\1</image.path>") 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)/, - "<image.path>#{@dir.url.images_local}\/\\1</image.path>") + "<image.path>#{@md.file.output_path.xml.rel_image}\/\\1</image.path>") 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 |