diff options
author | Ralph Amissah <ralph@amissah.com> | 2012-10-03 00:23:15 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2012-10-03 00:23:15 -0400 |
commit | 65033374ae05fed5dc878ae66e11dbecd0664ebe (patch) | |
tree | 207027c1761e4c76616d492f9325aec7e0fb5881 /lib/sisu/v4 | |
parent | v4: param (header make), epub, pdf, book cover images (diff) |
v4: param (header make), html, home button: text button; image/icon button
Diffstat (limited to 'lib/sisu/v4')
-rw-r--r-- | lib/sisu/v4/html_format.rb | 72 | ||||
-rw-r--r-- | lib/sisu/v4/manifest.rb | 21 | ||||
-rw-r--r-- | lib/sisu/v4/param.rb | 62 | ||||
-rw-r--r-- | lib/sisu/v4/sysenv.rb | 11 |
4 files changed, 123 insertions, 43 deletions
diff --git a/lib/sisu/v4/html_format.rb b/lib/sisu/v4/html_format.rb index 3895c8a1..cdb0b94a 100644 --- a/lib/sisu/v4/html_format.rb +++ b/lib/sisu/v4/html_format.rb @@ -154,14 +154,13 @@ module SiSU_HTML_Format end self end - def doc_types #used in toc & seg_nav_band - scroll=seg='' + def doc_types(page=:seg) #used in toc & seg_nav_band wgt=SiSU_HTML_Format::Widget.new(@md) %{ <table summary="segment navigation available documents types: toc,doc,pdf,concordance" border="0" cellpadding="3" cellspacing="0"> <tr> <td align="center" bgcolor=#{@vz.color_band2}> - #{wgt.manifest} + #{wgt.manifest(page)} #{wgt.search} </tr></table>} end @@ -177,16 +176,25 @@ module SiSU_HTML_Format %{ </font> #{@vz.table_close}} end - def buttons_home - %{<!- home and index buttons -!> - #{@vz.banner_home_and_index_buttons} -<!- home and index buttons -!>} - end - def copyat - %{#{@vz.paragraph_font_tiny}copy @ - <a href="#{@vz.url_home}"> - #{@vz.txt_home} - </a></h1>} + def button_home(page=:seg) + button=%{ <table summary="home button / home information" border="0" cellpadding="3" cellspacing="0">\n <tr><td align="left" bgcolor="#ffffff">\n} + if @md.make.home_button_image.is_a?(Hash) + image_path=if page==:manifest + @md.file.output_path.manifest.rel_image + elsif page==:scroll + @md.file.output_path.html_scroll.rel_image + else + @md.file.output_path.html_seg.rel_image + end + dir=SiSU_Env::FileOp.new(@md) + button +=%{ <p class="tiny_left"><a href="#{@md.make.home_button_image[:link]}" target="_top"><img border="0" src="#{image_path}/#{@md.make.home_button_image[:home_button]}" width="#{@md.make.home_button_image[:w]}" height="#{@md.make.home_button_image[:h]}" alt="home icon -->" /></a></p>\n} + elsif @md.home_button_links.is_a?(Array) + @md.home_button_links.each do |links| + button +=%{ <p class="tiny_left"><a href="#{links[:url]}/" target="_top">\n #{links[:say]}\n </a></p>\n} + end + end + button +=%{ </td></tr>\n </table>} + button end def html_close #moved %{</body> @@ -235,7 +243,7 @@ module SiSU_HTML_Format else '' end end - def manifest + def manifest(page=:seg) if @make.build.links_to_manifest? \ and not @o_str.dump_or_redirect? manifest_lnk=if @file.output_dir_structure.by_language_code? \ @@ -243,11 +251,21 @@ module SiSU_HTML_Format "#{Xx[:html_relative1]}manifest/#{@file.base_filename.manifest}" else @file.base_filename.manifest end - %{<td align="center" bgcolor=#{@vz.color_band2}> + if page==:manifest + manifest_lnk="#{@md.file.output_path.manifest.url}/#{@file.base_filename.manifest}" + brace_url=SiSU_Viz::Defaults.new.url_decoration + %{<td align="center" bgcolor=#{@vz.color_band2}> + <font face="#{@vz.font_fonts}" size="2"> + #{brace_url.xml_open}<a href="#{manifest_lnk}" target="_top">#{@md.file.output_path.manifest.url}/#{@file.base_filename.manifest}</a>#{brace_url.xml_close} + </font> +</td>} + else + %{<td align="center" bgcolor=#{@vz.color_band2}> <a href="#{manifest_lnk}" target="_top"> #{@vz.nav_txt_manifest} </a> </td>} + end else '' end end @@ -288,8 +306,11 @@ module SiSU_HTML_Format WOK %{<table summary="table of contents scroll navigation band" id="toc" width="100%" bgcolor=#{@vz.color_band1}> <tr><td width="20%"> - #{@vz.banner_band} -</td>#{search_and_manifest} + #{button_home(:scroll)} +</td> +<td width="75%" align="center"> + #{doc_types} +</td> <td width="20%"> #{@vz.table_close} @@ -297,13 +318,16 @@ WOK else '' end end - def concordance_navigation_band(type='') + def concordance_navigation_band if @make.build.html_top_band? %{<table summary="concordance navigation band" id="toc" width="100%" bgcolor=#{@vz.color_band1}> <tr><td width="20%"> - #{@vz.banner_band} + #{button_home} </td> -<td width="20%" align="right"> +<td width="75%" align="center"> + #{doc_types} +</td> +<td width="5%" align="right"> <a href="toc.html" target="_top" alt="->"> #{png_nav.toc} </a> @@ -312,16 +336,16 @@ WOK else '' end end - def seg_head_navigation_band(type='') + def seg_head_navigation_band(page=:seg) firstseg=%{<a href="#{@md.firstseg}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top" alt="->"> #{png_nav.nxt} </a>} if @md.firstseg =~/\S+/ %{<table summary="table of contents segment navigation band" id="toc" width="100%" bgcolor=#{@vz.color_band1}> <tr><td width="20%"> - #{@vz.banner_band} +#{button_home(page)} </td> <td width="75%" align="center"> - #{doc_types} + #{doc_types(page)} </td> <td width="5%" align="right"> #{firstseg} @@ -762,7 +786,7 @@ WOK def navigation_band(segtocband,seg_table_top_control) #change name to navigation_band_banner %{<table summary="segment navigation band with banner" bgcolor=#{@vz.color_band1} width="100%"><tr> <td width="20%" align="left"> -#{@vz.banner_band} +#{button_home} </td> <td width="75%" align="center"> #{doc_types} diff --git a/lib/sisu/v4/manifest.rb b/lib/sisu/v4/manifest.rb index 0c290204..6f751a24 100644 --- a/lib/sisu/v4/manifest.rb +++ b/lib/sisu/v4/manifest.rb @@ -775,24 +775,7 @@ WOK "<td>#{@env.widget_static.search_form}</td>" else '' end - banner_table=if vz.banner_home_button_only !~ /http:\/\/www\.jus\.uio\.no\/sisu/ \ - and vz.banner_home_button_only !~ /sisu\.home\.png/ -<<WOK -<table summary="band" border="0" cellpadding="3" cellspacing="0"> -<tr><td align="left" width="15%" bgcolor="#ffffff">#{vz.banner_band}</td> -<td width="70%"><p class="tiny">#{@brace_url.xml_open}<a href="#{@base_url}/#{file}">#{@base_url}/#{file}</a>#{@brace_url.xml_close}</p></td> -#{search_form}</tr> -</table> -WOK - else -<<WOK -<table summary="band" border="0" cellpadding="3" cellspacing="0"> -<tr><td align="left" bgcolor="#ffffff"><a href="http://www.jus.uio.no/sisu/" target="_top"><img border="0" src="#{vz.url_path_image_sys}/sisu.png" alt="SiSU -->" /></a></td> -<td><p class="tiny">#{@brace_url.xml_open}<a href="#{@base_url}/#{file}">#{@base_url}/#{file}</a>#{@brace_url.xml_close}</p></td> -#{search_form}</tr> -</table> -WOK - end + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) @manifest[:html] <<<<WOK <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> @@ -808,7 +791,7 @@ SiSU manifest: #{@md.title.full} #{@stylesheet.css_head} </head> <body bgcolor="#ffffff" text="#000000" link="#003090" lang="en" xml:lang="en"> -#{banner_table} +#{format_head_toc.seg_head_navigation_band(:manifest)} WOK if @f.build.manifest_minitoc? if @o_str.dump_or_redirect? diff --git a/lib/sisu/v4/param.rb b/lib/sisu/v4/param.rb index b75a8808..740a7598 100644 --- a/lib/sisu/v4/param.rb +++ b/lib/sisu/v4/param.rb @@ -927,6 +927,11 @@ module SiSU_Param ? :off : :na end + def home_button_image? + (omit.list.inspect =~/"home_button_image"/) \ + ? :off + : :na + end def texpdf_font def main @h['texpdf_font'] \ @@ -1008,6 +1013,36 @@ module SiSU_Param end {w: w, h: h} end + def home_button_text + s=if @h['home_button_text'] + @h['home_button_text'].split(/\s*;\s*/) + else nil + end + #l,n=Db[:home_button],'make.home_button_text' + #validate_length(s,l,n) + end + def home_button_image + s=nil + s=if @h['home_button_image'] + s=@h['home_button_image'].split(/\s*;\s*/) + s0=s[0] #if + image={} + s=if s0 =~/{(\S+\.(?:jpg|png|gif))(?:\s+(\d+x\d+))?\s*}(?:(http:\/\/\S+)|image)/ + image[:home_button]=$1 + if $2 + image[:dimentions]=$2 + image[:w],image[:h]=/(\d+)x(\d+)/m.match(image[:dimentions])[1,2] + else + d=get_image_dimentions(image[:home_button]) + image[:w],image[:h]=d[:w],d[:h] + image[:dimentions]="#{d[:w]}x#{d[:h]}" + end + image[:link]=$3 + image + end + else nil + end + end def cover_image s=nil if @h['cover_image'] @@ -1326,6 +1361,27 @@ module SiSU_Param ? @make.manpage.section : 1 end + if defined? @make.home_button_text \ + and @make.home_button_text.is_a?(Array) + a_idx=0 + @home_button_links=[] + @make.home_button_text.each do |doc_link| + if doc_link=~/\{.+?\}(?:(?:https?|file|ftp):\/|\.\.)\/\S+(?:\s|$)/ + @home_button_links[a_idx]={} + @home_button_links[a_idx][:say],@home_button_links[a_idx][:url]=/\{\s*(.+?)\s*\}((?:(?:https?|file|ftp):\/|\.\.)\/\S+)/im.match(doc_link)[1,2] + a_idx +=1 + end + end + @home_button_links + end + if defined? @make.home_button_image \ + and @make.home_button_image.is_a?(Hash) + @home_button_image=@make.home_button_image + end + if defined? @make.cover_image \ + and @make.cover_image.is_a?(Hash) + @cover_image=@make.cover_image + end end @lv1 ||=/^1~/ @lv2 ||=/^2~/ @@ -1457,6 +1513,12 @@ module SiSU_Param or @cover_image[:cover] =~/\S+?.(?:jpg|png|gif)/) @ec[:image] << @cover_image[:cover] end + if @home_button_image \ + and @home_button_image.is_a?(Hash) \ + and (@home_button_image =~@rgx_image \ + or @home_button_image =~/\S+?\.(?:jpg|png|gif)/) + @ec[:image] << @home_button_image + end if @ec[:image].length > 0 @ec[:image]=@ec[:image].flatten.uniq @ec[:image].delete_if {|x| x =~/https?:\/\// } diff --git a/lib/sisu/v4/sysenv.rb b/lib/sisu/v4/sysenv.rb index cc1b463c..d43bba91 100644 --- a/lib/sisu/v4/sysenv.rb +++ b/lib/sisu/v4/sysenv.rb @@ -5306,6 +5306,17 @@ WOK def rel set_path(ft).rel.abc end + def rel_image + if output_dir_structure.dump_or_redirect? + './image' + elsif output_dir_structure.by_language_code? + '../../_sisu/image' + elsif output_dir_structure.by_filetype? + '../../_sisu/image' + else + '../_sisu/image' + end + end def rcp set_path(ft).rcp.abc end |