From 65033374ae05fed5dc878ae66e11dbecd0664ebe Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 3 Oct 2012 00:23:15 -0400 Subject: v4: param (header make), html, home button: text button; image/icon button --- lib/sisu/v4/html_format.rb | 72 ++++++++++++++++++++++++++++++---------------- lib/sisu/v4/manifest.rb | 21 ++------------ lib/sisu/v4/param.rb | 62 +++++++++++++++++++++++++++++++++++++++ lib/sisu/v4/sysenv.rb | 11 +++++++ 4 files changed, 123 insertions(+), 43 deletions(-) (limited to 'lib') 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) %{
- #{wgt.manifest} + #{wgt.manifest(page)} #{wgt.search}
} end @@ -177,16 +176,25 @@ module SiSU_HTML_Format %{ #{@vz.table_close}} end - def buttons_home - %{ - #{@vz.banner_home_and_index_buttons} -} - end - def copyat - %{#{@vz.paragraph_font_tiny}copy @ - - #{@vz.txt_home} - } + def button_home(page=:seg) + button=%{ \n \n
\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 +=%{

home icon -->

\n} + elsif @md.home_button_links.is_a?(Array) + @md.home_button_links.each do |links| + button +=%{

\n #{links[:say]}\n

\n} + end + end + button +=%{
} + button end def html_close #moved %{ @@ -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 - %{ + if page==:manifest + manifest_lnk="#{@md.file.output_path.manifest.url}/#{@file.base_filename.manifest}" + brace_url=SiSU_Viz::Defaults.new.url_decoration + %{ + + #{brace_url.xml_open}#{@md.file.output_path.manifest.url}/#{@file.base_filename.manifest}#{brace_url.xml_close} + +} + else + %{ #{@vz.nav_txt_manifest} } + end else '' end end @@ -288,8 +306,11 @@ module SiSU_HTML_Format WOK %{#{search_and_manifest} + #{button_home(:scroll)} + +
- #{@vz.banner_band} - + #{doc_types} +   #{@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? %{ - +
- #{@vz.banner_band} + #{button_home} + + #{doc_types} +   #{png_nav.toc}   @@ -312,16 +336,16 @@ WOK else '' end end - def seg_head_navigation_band(type='') + def seg_head_navigation_band(page=:seg) firstseg=%{ #{png_nav.nxt} } if @md.firstseg =~/\S+/ %{ - -#{search_form} -
- #{@vz.banner_band} +#{button_home(page)} - #{doc_types} + #{doc_types(page)}  #{firstseg}  @@ -762,7 +786,7 @@ WOK def navigation_band(segtocband,seg_table_top_control) #change name to navigation_band_banner %{" 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/ -< - - -#{search_form} -
-#{@vz.banner_band} +#{button_home} #{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 "#{@env.widget_static.search_form}
#{vz.banner_band}

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

-WOK - else -< -
SiSU -->

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

-WOK - end + format_head_toc=SiSU_HTML_Format::HeadToc.new(@md) @manifest[:html] <<< @@ -808,7 +791,7 @@ SiSU manifest: #{@md.title.full} #{@stylesheet.css_head} -#{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 -- cgit v1.2.3