diff options
author | Ralph Amissah <ralph@amissah.com> | 2008-08-23 12:01:59 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2008-08-23 12:01:59 -0400 |
commit | 08c69d074001507d64cd5960c8679ec91a5a8353 (patch) | |
tree | af52d5986b3108abc5edbd943ea287455c89deb3 /lib/sisu/v0/shared_html_lite.rb | |
parent | a bit of a cleanup, and change reference to null to ordinary (diff) |
pass Hash to Format classes; some match tuning in dal
Diffstat (limited to 'lib/sisu/v0/shared_html_lite.rb')
-rw-r--r-- | lib/sisu/v0/shared_html_lite.rb | 85 |
1 files changed, 49 insertions, 36 deletions
diff --git a/lib/sisu/v0/shared_html_lite.rb b/lib/sisu/v0/shared_html_lite.rb index 7be46abb..7a23be0b 100644 --- a/lib/sisu/v0/shared_html_lite.rb +++ b/lib/sisu/v0/shared_html_lite.rb @@ -65,20 +65,34 @@ module SiSU_Format_Shared class CSS_Format require "#{SiSU_lib}/defaults" @@fns=nil - def initialize(md,content=nil,col=nil,en=nil) - content.gsub!(/<:i[12]>/,'') - @md,@content=md,content - @id=@ocn=col[:id] - @ocnd,@ocns=col[:ocnd],col[:ocns] - @notenumber=en - @lv=col[:lev].to_s + def initialize(md,t_o) + @md,@t_o=md,t_o + if t_o.class == Hash + @txt =t_o[:txt] #|| nil #s/@content/@txt/ + @col =t_o[:col] #|| nil + @notenumber =t_o[:endnote_nr] || nil + #elsif t_o.class == Array + # @txt =txt[0] + #elsif t_o.class == String + # @txt =txt + else + #content.gsub!(/<:i[1-9]>/,'') + #@md,@content=md,content + p t_o.class + p caller + end + + @txt.gsub!(/#{Mx[:pa_o]}:i[1-9]#{Mx[:pa_c]}/,'') + @id=@ocn=@col[:id] + @ocnd,@ocns=@col[:ocnd],@col[:ocns] + @lv=@col[:lev].to_s @@hname=if @md.fns != @@fns @@fns=@md.fns '' end - @hname=if col[:seg] \ - and not col[:seg].to_s.empty? - @@hname=col[:seg].to_s + @hname=if @col[:seg] \ + and not @col[:seg].to_s.empty? + @@hname=@col[:seg].to_s else @@hname end @tab="\t" @@ -87,7 +101,7 @@ module SiSU_Format_Shared @@tablehead,@@tablefoot=[],[] @vz=SiSU_Env::Get_init.instance.skin @env=SiSU_Env::Info_env.new(@md.fns) - @base_url="#{@env.url.root}/#{@md.fnb}/#@hname.html" + @base_url="#{@env.url.root}/#{@md.fnb}/#{@hname}.html" end def urls(data) @words=[] @@ -147,48 +161,48 @@ module SiSU_Format_Shared para end def paragraph - %{#{@tab*1}<p class="h#@lv" id="#@ocn" type="substantive" header="#@hname">\n#{@tab*2}#@content\n#{@tab*1}</p>\n} << "\n" + %{#{@tab*1}<p class="h#{@lv}" id="#{@ocn}" type="substantive" header="#{@hname}">\n#{@tab*2}#{@txt}\n#{@tab*1}</p>\n} << "\n" end def endnote #used only by db - @content=markup(@content) + @txt=markup(@txt) <<GSUB -#{@tab*1}<p class="endnote" name="note_#@notenumber" from="#@ocn"> -#{@tab*2}<a href="#@base_url#-#@notenumber" name="_#@notenumber">#@notenumber.</a> <note>#@content</note> +#{@tab*1}<p class="endnote" name="note_#{@notenumber}" from="#{@ocn}"> +#{@tab*2}<a href="#{@base_url}#-#{@notenumber}" name="_#{@notenumber}">#{@notenumber}.</a> <note>#{@txt}</note> #{@tab*1}</p> GSUB end def lev_toc_hname - %{#{@tab*1}<p class="toc#@lv" header="#@hname"><a href="##@ocn">\n#{@tab*2}#@content\n#{@tab*1}</a></p>\n} << "\n" + %{#{@tab*1}<p class="toc#{@lv}" header="#{@hname}"><a href="##{@ocn}">\n#{@tab*2}#{@txt}\n#{@tab*1}</a></p>\n} << "\n" end def lev_toc - %{#{@tab*1}<p class="toc#@lv"><a href="##@ocn">\n#{@tab*2}#@content\n#{@tab*1}</a></p>\n} << "\n" + %{#{@tab*1}<p class="toc#{@lv}"><a href="##{@ocn}">\n#{@tab*2}#{@txt}\n#{@tab*1}</a></p>\n} << "\n" end def lev4_plus - %{#{@tab*1}<p class="h#@lv" id="#@ocn" type="substantive" header="#@hname">\n#{@tab*2}#@content\n#{@tab*1}</p>\n} << "\n" + %{#{@tab*1}<p class="h#{@lv}" id="#{@ocn}" type="substantive" header="#{@hname}">\n#{@tab*2}#{@txt}\n#{@tab*1}</p>\n} << "\n" end def lev4_minus - %{#{@tab*1}<p class="h#@lv" id="#@ocn" type="substantive">\n#{@tab*2}#@content\n#{@tab*1}</p>\n} << "\n" + %{#{@tab*1}<p class="h#{@lv}" id="#{@ocn}" type="substantive">\n#{@tab*2}#{@txt}\n#{@tab*1}</p>\n} << "\n" end def norm_comment - %{#{@tab*1}<p class="norm" id="none" type="comment">\n#{@tab*2}#@content\n#{@tab*1}</p>\n} + %{#{@tab*1}<p class="norm" id="none" type="comment">\n#{@tab*2}#{@txt}\n#{@tab*1}</p>\n} end def norm - @content=markup(@content) - %{#{@tab*1}<p class="norm" id="#@ocn" type="substantive">\n#{@tab*2}#@content\n#{@tab*1}</p>\n} + @txt=markup(@txt) + %{#{@tab*1}<p class="norm" id="#{@ocn}" type="substantive">\n#{@tab*2}#{@txt}\n#{@tab*1}</p>\n} end def indent(t) - @content=markup(@content) - %{#{@tab*1}<p class="indent#{t}" id="#@ocn" type="substantive">\n#{@tab*2}#@content\n#{@tab*1}</p>\n} + @txt=markup(@txt) + %{#{@tab*1}<p class="indent#{t}" id="#{@ocn}" type="substantive">\n#{@tab*2}#{@txt}\n#{@tab*1}</p>\n} end def para_table %{<p class="norm" align="left"><font #{@vz.font_small} #{@vz.font_color} #{@vz.font_face}>} end def ocn - %{#{@tab*1}<label class="ocn">#@ocn</label>} << "\n" + %{#{@tab*1}<label class="ocn">#{@ocn}</label>} << "\n" end def html_table # get rid of use html_table @new_content=[] - @content.split(/\n/).each do |parablock| + @txt.split(/\n/).each do |parablock| m=parablock[/<!f(.+?)!>/,1] @@tablefoot<<m if m parablock.gsub!(/<!f.+?!>/,'') @@ -233,27 +247,27 @@ GSUB @new_content.join end end - class CSS_Format_generic #does CSS_Format in one definition, needs to be told about class, despite brevity of generic, easier to see structure with CSS_Format - def initialize(css_class='',content='',id=nil,ocnd=nil,ocns=nil,lv='',hname=nil) + class CSS_Format_generic #does CSS_Format in one definition, needs to be told about attrib, despite brevity of generic, easier to see structure with CSS_Format + def initialize(attrib='',txt='',id=nil,ocnd=nil,ocns=nil,lv='',hname=nil) @tab="\t" - @class=css_class - @content=content + @attrib=attrib + @txt=txt @lv=@notenumber=lv.to_s - #@ocn=ocn.to_s + #{@ocn}=ocn.to_s @hname=hname.to_s @id=@ocn=id end def paragraph - css_class=%{class="#@class" } + attrib=%{class="#{@attrib}" } if @ocn - id=%{id="#@ocn" } + id=%{id="#{@ocn}" } type=%{type="substantive" } else id=%{id="none" } type=%{type="comment" } end - header=%{header="#@hname" } if @hname - %{#{@tab*1}<p #{css_class}#{id}#{type}#{header}>\n#{@tab*2}#@content\n#{@tab*1}</p>\n} << "\n" + header=%{header="#{@hname}" } if @hname + %{#{@tab*1}<p #{attrib}#{id}#{type}#{header}>\n#{@tab*2}#{@txt}\n#{@tab*1}</p>\n} << "\n" end def para paragraph @@ -261,4 +275,3 @@ GSUB end end __END__ - |