class SiSU_HTML_Promo::Ad
Public Class Methods
new(md)
click to toggle source
# File lib/sisu/html_promo.rb, line 59 def initialize(md) @md=md @env=SiSU_Env::InfoEnv.new(@md.fns,@md) @rc=SiSU_Env::GetInit.new.sisu_yaml.rc @ad=SiSU_Env::GetInit.new.ads @flag=@env.widget.promo? @make=SiSU_Env::ProcessingSettings.new(@md) end
Public Instance Methods
adsense()
click to toggle source
# File lib/sisu/html_promo.rb, line 251 def adsense #draw content from a configuration file def column_right if defined? @ad[:promo]['ad']['adsense']['column_right'] @ad[:promo]['ad']['adsense']['column_right'].join("\n") else '' end end def line_single if defined? @ad[:promo]['ad']['adsense']['line_single'] @ad[:promo]['ad']['adsense']['line_single'].join("\n") else '' end end self end
advert_extract_all()
click to toggle source
# File lib/sisu/html_promo.rb, line 416 def advert_extract_all #extracts all products from list (which is broken down into categories) adverts=[] @ad[:promo_list].keys.each do |category| adverts << advert_extract_subject(category) end adverts.flatten end
advert_extract_subject(category)
click to toggle source
# File lib/sisu/html_promo.rb, line 387 def advert_extract_subject(category) #extracts products from category/subject list adverts=[] if defined? @ad[:promo_list][category] \ and @ad[:promo_list][category] @ad[:promo_list][category].keys.each do |type| @ad[:promo_list][category][type].each do |i| if i id=((i.inspect =~/^\d/) ? "id_#{i.to_s.strip}" : i.to_s.strip) #watch remove .to_s ? if defined? @ad[:promo][type][id] \ and not @ad[:promo][type][id].nil? adverts << output_form_select(type,id) else if defined? @ad[:promo][category][type][id] \ and @ad[:promo][category][type][id].is_a?(Array) \ and @ad[:promo][category][type][id].length > 0 adverts << @ad[:promo][category][type][id].join("\n") end end end end end else SiSU_Screen::Ansi.new( @md.opt.act[:color_state][:set], "*WARN* category not found: #{category}" ).warn unless @md.opt.act[:quiet][:set]==:on end adverts.join end
adverts(ads)
click to toggle source
# File lib/sisu/html_promo.rb, line 423 def adverts(ads) <<WOK #{div.minor} #{ads} #{div.close} WOK end
blurb()
click to toggle source
# File lib/sisu/html_promo.rb, line 148 def blurb @prod['blurb'] ? %{<p class="pane_blurb">#{@prod['blurb']}</p>} : '' end
cell(prod,id)
click to toggle source
# File lib/sisu/html_promo.rb, line 110 def cell(prod,id) @prod,@id=prod,id def title @prod['title'] ? %{<b>#{@prod['title']}</b>} : '' end def subtitle @prod['subtitle'] ? %{ - #{@prod['subtitle']}} : '' end def author @prod['author'] ? %{<p class="pane">#{@prod['author']}</p>} : '' end def editor @prod['editor'] ? %{<p class="pane">#{@prod['editor']}</p>} : '' end def year @prod['year'] ? %{<p class="pane">#{@prod['year']}</p>} : '' end def date @prod['date'] ? %{<p class="pane">On: #{@prod['date']}</p>} : '' end def location @prod['at'] ? %{<p class="pane">At: #{@prod['at']}</p>} : '' end def pages @prod['pages'] ? %{<p class="pane">Pages: #{@prod['pages']} pages</p>} : '' end def form @prod['form'] ? %{<p class="pane">#{@prod['form']}</p>} : '' end def nick @prod['nick'] ? %{(#{@prod['nick']})<br>} : '' end def update @prod['update'] ? %{<p class="pane">Updated: #{@prod['update']}</p>} : '' end def issn @prod['issn'] ? %{<p class="pane">issn: #{@prod['issn']}</p>} : '' end def blurb @prod['blurb'] ? %{<p class="pane_blurb">#{@prod['blurb']}</p>} : '' end def search_form_sisu(table=true) db=if @prod['db']=~/\S+/ (@prod['db']=~/^#{Db[:name_prefix]}\S+/) ? @prod['db'] : "#{Db[:name_prefix]}#{@prod['db']}" elsif defined? @rc['search']['sisu']['db'] \ and @rc['search']['sisu']['db'] =~/\S+/ (@rc['search']['sisu']['db']=~/^#{Db[:name_prefix]}\S+/) \ ? @prod['search']['sisu']['db'] : "#{Db[:name_prefix]}#{@prod['db']}" else nil end action=if @prod['action']=~/^https?:\/\// @prod['action'] elsif defined? @rc['search']['sisu']['action'] \ and @rc['search']['sisu']['action'] =~/^https?:\/\// @rc['search']['sisu']['action'] else nil end if action \ and db @env.widget.search_form('sisusearch',action,db,table) else '' end end def search_form_hyperestraier(table=true) action=if defined? @rc['search']['hyperestraier']['action'] \ and @rc['search']['hyperestraier']['action'] =~/^https?:\/\// @rc['search']['hyperestraier']['action'] else nil end form=if action '<br>' + @env.widget.search_form('hyperestraier',action,'',table) else '' end form end def links if @prod['links'] #and @prod['links']==Array links_a=[] @prod['links'].each do |x| if x \ and x['url'] \ and x['title'] subtitle=x['subtitle'] ? %{ - #{x['subtitle']}} : '' url_=(x['url'] =~/https?:/) ? x['url'] : "../#{x['url']}" links_a << %{<p class="pane_link"><a href="#{url_}">#{x['title']}#{subtitle}</a></p>\n} end end links_a.join else '' end end def image @prod['image'] ? %{<img border="0" src="../_sisu/image/#{@prod['image']}" /><br>} : '' end def url_link @url_=if @prod['url'] =~/https?:/ "#{@prod['url']}" else "../#{@prod['url']}" # "#{@env.url.root}/#{@prod['url']}" end def show @prod['url'] ? %{<p class="pane_link"><a href="#{@url_}">#{@url_}</a></p>} : '' end def url @prod['url'] ? %{<a href="#{@url_}">} : '' end def url_relative @prod['url'] ? %{<a href="../#{@prod['url']}/toc.html">} : '' end self end def flyer if @prod['flyer'] %{<p class="pane"><a href="../man/pdf/#{@id}.pdf"><img border="0" height="18" width="15" src="../_sisu/image/b_pdf.png"> PDF flyer</a></p>} else '' end end def price def gbp if defined? @prod['price']['gbp'] \ and @prod['price']['gbp'] " £ #{@prod['price']['gbp']} (GBP) " else '' end end def euro if defined? @prod['price']['euro'] \ and @prod['price']['euro'] " € #{@prod['price']['euro']} (Euro) " else '' end end def usd if defined? @prod['price']['usd'] \ and @prod['price']['usd'] " $ #{@prod['price']['usd']} (USD) " else '' end end %{<p class="pane">Price:#{gbp}#{euro}#{usd}</p>} end def adsense #draw content from a configuration file def column_right if defined? @ad[:promo]['ad']['adsense']['column_right'] @ad[:promo]['ad']['adsense']['column_right'].join("\n") else '' end end def line_single if defined? @ad[:promo]['ad']['adsense']['line_single'] @ad[:promo]['ad']['adsense']['line_single'].join("\n") else '' end end self end def site_link #Work area if url_link.url <<-WOK <p class="pane"> #{url_link.url} #{image} #{title} #{subtitle} </a>#{nick}</p> WOK else <<-WOK <p class="pane"> #{image} #{title} #{subtitle} </p> WOK end end self end
close()
click to toggle source
# File lib/sisu/html_promo.rb, line 80 def close (@make.build.html_right_pane? \ && @flag[:ad]) \ ? '</div>' : '' end
column_right()
click to toggle source
# File lib/sisu/html_promo.rb, line 252 def column_right if defined? @ad[:promo]['ad']['adsense']['column_right'] @ad[:promo]['ad']['adsense']['column_right'].join("\n") else '' end end
date()
click to toggle source
# File lib/sisu/html_promo.rb, line 127 def date @prod['date'] ? %{<p class="pane">On: #{@prod['date']}</p>} : '' end
display()
click to toggle source
# File lib/sisu/html_promo.rb, line 88 def display ads_array,promo_array=[],[] if @make.build.html_right_pane? \ && @flag[:ad] ads=if @md.promo && @md.promo.length > 0 #promo set in document promo_array=@md.promo elsif @flag[:rc] #promo set in rc file promo_array=if @rc['html']['promo'].is_a?(String) @rc['html']['promo'].split(/[,;]\s*/) else @rc['html']['promo'] end else advert_extract_all end ads=if promo_array.length > 0 promo_array.each do |x| ads_array << advert_extract_subject(x) end ads_array end adverts(ads.join) end end
div()
click to toggle source
# File lib/sisu/html_promo.rb, line 67 def div def major (@make.build.html_right_pane? \ && @flag[:ad]) \ ? '<div id="pane_major">' : '' end def minor (@make.build.html_right_pane? \ && @flag[:ad]) \ ? '<div id="pane_minor">' : '' end def close (@make.build.html_right_pane? \ && @flag[:ad]) \ ? '</div>' : '' end self end
editor()
click to toggle source
# File lib/sisu/html_promo.rb, line 121 def editor @prod['editor'] ? %{<p class="pane">#{@prod['editor']}</p>} : '' end
euro()
click to toggle source
# File lib/sisu/html_promo.rb, line 235 def euro if defined? @prod['price']['euro'] \ and @prod['price']['euro'] " € #{@prod['price']['euro']} (Euro) " else '' end end
flyer()
click to toggle source
# File lib/sisu/html_promo.rb, line 221 def flyer if @prod['flyer'] %{<p class="pane"><a href="../man/pdf/#{@id}.pdf"><img border="0" height="18" width="15" src="../_sisu/image/b_pdf.png"> PDF flyer</a></p>} else '' end end
form()
click to toggle source
# File lib/sisu/html_promo.rb, line 136 def form @prod['form'] ? %{<p class="pane">#{@prod['form']}</p>} : '' end
gbp()
click to toggle source
# File lib/sisu/html_promo.rb, line 228 def gbp if defined? @prod['price']['gbp'] \ and @prod['price']['gbp'] " £ #{@prod['price']['gbp']} (GBP) " else '' end end
image()
click to toggle source
# File lib/sisu/html_promo.rb, line 202 def image @prod['image'] ? %{<img border="0" src="../_sisu/image/#{@prod['image']}" /><br>} : '' end
issn()
click to toggle source
# File lib/sisu/html_promo.rb, line 145 def issn @prod['issn'] ? %{<p class="pane">issn: #{@prod['issn']}</p>} : '' end
line_single()
click to toggle source
# File lib/sisu/html_promo.rb, line 258 def line_single if defined? @ad[:promo]['ad']['adsense']['line_single'] @ad[:promo]['ad']['adsense']['line_single'].join("\n") else '' end end
links()
click to toggle source
# File lib/sisu/html_promo.rb, line 186 def links if @prod['links'] #and @prod['links']==Array links_a=[] @prod['links'].each do |x| if x \ and x['url'] \ and x['title'] subtitle=x['subtitle'] ? %{ - #{x['subtitle']}} : '' url_=(x['url'] =~/https?:/) ? x['url'] : "../#{x['url']}" links_a << %{<p class="pane_link"><a href="#{url_}">#{x['title']}#{subtitle}</a></p>\n} end end links_a.join else '' end end
location()
click to toggle source
# File lib/sisu/html_promo.rb, line 130 def location @prod['at'] ? %{<p class="pane">At: #{@prod['at']}</p>} : '' end
major()
click to toggle source
# File lib/sisu/html_promo.rb, line 68 def major (@make.build.html_right_pane? \ && @flag[:ad]) \ ? '<div id="pane_major">' : '' end
minor()
click to toggle source
# File lib/sisu/html_promo.rb, line 74 def minor (@make.build.html_right_pane? \ && @flag[:ad]) \ ? '<div id="pane_minor">' : '' end
nick()
click to toggle source
# File lib/sisu/html_promo.rb, line 139 def nick @prod['nick'] ? %{(#{@prod['nick']})<br>} : '' end
no_adverts()
click to toggle source
# File lib/sisu/html_promo.rb, line 430 def no_adverts <<WOK #{div.minor} #{div.close} WOK end
output_form_book(type,id)
click to toggle source
# File lib/sisu/html_promo.rb, line 319 def output_form_book(type,id) prod_id=id.gsub(/id_/,'') cell=cell(@ad[:promo][type][id],prod_id) prod_type=((id=~/id_(?:[0-9x]){10,13}/i) ? 'isbn' : 'id') id_detail=%{<p class="pane">#{prod_type}: #{prod_id}</p>} <<WOK <br> #{cell.site_link} #{cell.author} #{cell.year} #{id_detail} #{cell.pages}#{cell.form} #{cell.price} #{cell.flyer} #{cell.blurb} #{cell.links} WOK end
output_form_conference(type,id)
click to toggle source
# File lib/sisu/html_promo.rb, line 353 def output_form_conference(type,id) prod_id=id.gsub(/id_/,'') cell=cell(@ad[:promo][type][id],prod_id) #translate date (dd month yyyy) from 2007-03-04 and ruby conversion <<WOK <br> #{cell.site_link} #{cell.date} #{cell.location} #{cell.price} #{cell.flyer} #{cell.blurb} #{cell.links} WOK end
output_form_journal(type,id)
click to toggle source
# File lib/sisu/html_promo.rb, line 337 def output_form_journal(type,id) prod_id=id.gsub(/id_/,'') cell=cell(@ad[:promo][type][id],prod_id) <<WOK <br> #{cell.site_link} #{cell.editor} #{cell.issn} #{cell.update} #{cell.form} #{cell.price.gsub(/Price:/,'Subscription:')} #{cell.flyer} #{cell.blurb} #{cell.links} WOK end
output_form_link(type,id)
click to toggle source
# File lib/sisu/html_promo.rb, line 297 def output_form_link(type,id) prod_id=id.gsub(/id_/,'') cell=cell(@ad[:promo][type][id],prod_id) <<WOK <br> #{cell.site_link} #{cell.author} #{cell.year} #{cell.blurb} #{cell.links} WOK end
output_form_search_hyperestraier(type,id)
click to toggle source
# File lib/sisu/html_promo.rb, line 314 def output_form_search_hyperestraier(type,id) prod_id=id.gsub(/id_/,'') cell=cell(@ad[:promo][type][id],prod_id) cell.search_form_hyperestraier(false) end
output_form_search_sisu(type,id)
click to toggle source
# File lib/sisu/html_promo.rb, line 309 def output_form_search_sisu(type,id) prod_id=id.gsub(/id_/,'') cell=cell(@ad[:promo][type][id],prod_id) cell.search_form_sisu(false) end
output_form_select(type,id)
click to toggle source
# File lib/sisu/html_promo.rb, line 368 def output_form_select(type,id) case type when /site/ output_form_link(type,id) when /sponsor/ output_form_sponsor(type,id) when /search/ if id=~/hyperestraier/ output_form_search_hyperestraier(type,id) else output_form_search_sisu(type,id) end when /book/ output_form_book(type,id) when /journal/ output_form_journal(type,id) when /conference/ output_form_conference(type,id) end end
output_form_sponsor(type,id)
click to toggle source
# File lib/sisu/html_promo.rb, line 288 def output_form_sponsor(type,id) cell=cell(@ad[:promo][type][id],prod_id) <<-WOK <br> #{cell.site_link} #{cell.blurb} #{cell.links} WOK end
pages()
click to toggle source
# File lib/sisu/html_promo.rb, line 133 def pages @prod['pages'] ? %{<p class="pane">Pages: #{@prod['pages']} pages</p>} : '' end
price()
click to toggle source
# File lib/sisu/html_promo.rb, line 227 def price def gbp if defined? @prod['price']['gbp'] \ and @prod['price']['gbp'] " £ #{@prod['price']['gbp']} (GBP) " else '' end end def euro if defined? @prod['price']['euro'] \ and @prod['price']['euro'] " € #{@prod['price']['euro']} (Euro) " else '' end end def usd if defined? @prod['price']['usd'] \ and @prod['price']['usd'] " $ #{@prod['price']['usd']} (USD) " else '' end end %{<p class="pane">Price:#{gbp}#{euro}#{usd}</p>} end
search_form_hyperestraier(table=true)
click to toggle source
# File lib/sisu/html_promo.rb, line 174 def search_form_hyperestraier(table=true) action=if defined? @rc['search']['hyperestraier']['action'] \ and @rc['search']['hyperestraier']['action'] =~/^https?:\/\// @rc['search']['hyperestraier']['action'] else nil end form=if action '<br>' + @env.widget.search_form('hyperestraier',action,'',table) else '' end form end
search_form_sisu(table=true)
click to toggle source
# File lib/sisu/html_promo.rb, line 151 def search_form_sisu(table=true) db=if @prod['db']=~/\S+/ (@prod['db']=~/^#{Db[:name_prefix]}\S+/) ? @prod['db'] : "#{Db[:name_prefix]}#{@prod['db']}" elsif defined? @rc['search']['sisu']['db'] \ and @rc['search']['sisu']['db'] =~/\S+/ (@rc['search']['sisu']['db']=~/^#{Db[:name_prefix]}\S+/) \ ? @prod['search']['sisu']['db'] : "#{Db[:name_prefix]}#{@prod['db']}" else nil end action=if @prod['action']=~/^https?:\/\// @prod['action'] elsif defined? @rc['search']['sisu']['action'] \ and @rc['search']['sisu']['action'] =~/^https?:\/\// @rc['search']['sisu']['action'] else nil end if action \ and db @env.widget.search_form('sisusearch',action,db,table) else '' end end
show()
click to toggle source
# File lib/sisu/html_promo.rb, line 210 def show @prod['url'] ? %{<p class="pane_link"><a href="#{@url_}">#{@url_}</a></p>} : '' end
site_link()
click to toggle source
# File lib/sisu/html_promo.rb, line 266 def site_link #Work area if url_link.url <<-WOK <p class="pane"> #{url_link.url} #{image} #{title} #{subtitle} </a>#{nick}</p> WOK else <<-WOK <p class="pane"> #{image} #{title} #{subtitle} </p> WOK end end
subtitle()
click to toggle source
# File lib/sisu/html_promo.rb, line 115 def subtitle @prod['subtitle'] ? %{ - #{@prod['subtitle']}} : '' end
title()
click to toggle source
# File lib/sisu/html_promo.rb, line 112 def title @prod['title'] ? %{<b>#{@prod['title']}</b>} : '' end
update()
click to toggle source
# File lib/sisu/html_promo.rb, line 142 def update @prod['update'] ? %{<p class="pane">Updated: #{@prod['update']}</p>} : '' end
url()
click to toggle source
# File lib/sisu/html_promo.rb, line 213 def url @prod['url'] ? %{<a href="#{@url_}">} : '' end
url_link()
click to toggle source
# File lib/sisu/html_promo.rb, line 205 def url_link @url_=if @prod['url'] =~/https?:/ "#{@prod['url']}" else "../#{@prod['url']}" # "#{@env.url.root}/#{@prod['url']}" end def show @prod['url'] ? %{<p class="pane_link"><a href="#{@url_}">#{@url_}</a></p>} : '' end def url @prod['url'] ? %{<a href="#{@url_}">} : '' end def url_relative @prod['url'] ? %{<a href="../#{@prod['url']}/toc.html">} : '' end self end
url_relative()
click to toggle source
# File lib/sisu/html_promo.rb, line 216 def url_relative @prod['url'] ? %{<a href="../#{@prod['url']}/toc.html">} : '' end
usd()
click to toggle source
# File lib/sisu/html_promo.rb, line 242 def usd if defined? @prod['price']['usd'] \ and @prod['price']['usd'] " $ #{@prod['price']['usd']} (USD) " else '' end end
year()
click to toggle source
# File lib/sisu/html_promo.rb, line 124 def year @prod['year'] ? %{<p class="pane">#{@prod['year']}</p>} : '' end