From 08c69d074001507d64cd5960c8679ec91a5a8353 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sat, 23 Aug 2008 12:01:59 -0400 Subject: pass Hash to Format classes; some match tuning in dal --- lib/sisu/v0/shared_html_lite.rb | 85 ++++++++++++++++++++++++----------------- 1 file changed, 49 insertions(+), 36 deletions(-) (limited to 'lib/sisu/v0/shared_html_lite.rb') 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}

\n#{@tab*2}#@content\n#{@tab*1}

\n} << "\n" + %{#{@tab*1}

\n#{@tab*2}#{@txt}\n#{@tab*1}

\n} << "\n" end def endnote #used only by db - @content=markup(@content) + @txt=markup(@txt) < -#{@tab*2}#@notenumber. #@content +#{@tab*1}

+#{@tab*2}#{@notenumber}. #{@txt} #{@tab*1}

GSUB end def lev_toc_hname - %{#{@tab*1}

\n#{@tab*2}#@content\n#{@tab*1}

\n} << "\n" + %{#{@tab*1}

\n#{@tab*2}#{@txt}\n#{@tab*1}

\n} << "\n" end def lev_toc - %{#{@tab*1}

\n#{@tab*2}#@content\n#{@tab*1}

\n} << "\n" + %{#{@tab*1}

\n#{@tab*2}#{@txt}\n#{@tab*1}

\n} << "\n" end def lev4_plus - %{#{@tab*1}

\n#{@tab*2}#@content\n#{@tab*1}

\n} << "\n" + %{#{@tab*1}

\n#{@tab*2}#{@txt}\n#{@tab*1}

\n} << "\n" end def lev4_minus - %{#{@tab*1}

\n#{@tab*2}#@content\n#{@tab*1}

\n} << "\n" + %{#{@tab*1}

\n#{@tab*2}#{@txt}\n#{@tab*1}

\n} << "\n" end def norm_comment - %{#{@tab*1}

\n#{@tab*2}#@content\n#{@tab*1}

\n} + %{#{@tab*1}

\n#{@tab*2}#{@txt}\n#{@tab*1}

\n} end def norm - @content=markup(@content) - %{#{@tab*1}

\n#{@tab*2}#@content\n#{@tab*1}

\n} + @txt=markup(@txt) + %{#{@tab*1}

\n#{@tab*2}#{@txt}\n#{@tab*1}

\n} end def indent(t) - @content=markup(@content) - %{#{@tab*1}

\n#{@tab*2}#@content\n#{@tab*1}

\n} + @txt=markup(@txt) + %{#{@tab*1}

\n#{@tab*2}#{@txt}\n#{@tab*1}

\n} end def para_table %{

} end def ocn - %{#{@tab*1}} << "\n" + %{#{@tab*1}} << "\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[//,1] @@tablefoot</,'') @@ -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}

\n#{@tab*2}#@content\n#{@tab*1}

\n} << "\n" + header=%{header="#{@hname}" } if @hname + %{#{@tab*1}

\n#{@tab*2}#{@txt}\n#{@tab*1}

\n} << "\n" end def para paragraph @@ -261,4 +275,3 @@ GSUB end end __END__ - -- cgit v1.2.3