From 65477054fd798728bf186aa2938727ddddbe86a5 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 22 May 2007 02:06:46 +0100 Subject: Imported upstream version 0.52.7 --- lib/sisu/0.52/html_format.rb | 1056 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1056 insertions(+) create mode 100644 lib/sisu/0.52/html_format.rb (limited to 'lib/sisu/0.52/html_format.rb') diff --git a/lib/sisu/0.52/html_format.rb b/lib/sisu/0.52/html_format.rb new file mode 100644 index 00000000..780b3253 --- /dev/null +++ b/lib/sisu/0.52/html_format.rb @@ -0,0 +1,1056 @@ +=begin + * Name: SiSU information Structuring Universe - Structured information, Serialized Units + * Author: Ralph Amissah + * http://www.jus.uio.no/sisu + * http://www.jus.uio.no/sisu/SiSU/download.html + + * Description: base formatting template for html generation + + * Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Ralph Amissah + + * License: GPL 2 or later + + Summary of GPL 2 + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the Free + Software Foundation; either version 2 of the License, or (at your option) + any later version. + + This program is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + http://www.fsf.org/licenses/gpl.html + http://www.gnu.org/copyleft/gpl.html + http://www.jus.uio.no/sisu/gpl2.fsf + + SiSU was first released to the public on January 4th 2005 + + SiSU uses: + + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + © Ralph Amissah 1997, current 2007. + All Rights Reserved. + + * Ralph Amissah: ralph@amissah.com + ralph.amissah@gmail.com +=end +module SiSU_HTML_Format + require SiSU_lib + '/param' + include SiSU_Param + include SiSU_Viz + class Paragraph_number + def initialize(md,paranum) + @md=md + @paranum=paranum[/(\d+)/m,1] + @paranum ||='' + @paranum='' if @md.mod.inspect =~/--no-ocn/ + end + def ocn_display + ocn_class=if @md.mod.inspect =~/--no-ocn/; 'ocn_off' + else 'ocn' + end + @paranum.gsub(/^(\d+|)$/, + %{

+   \\1 +

}) + end + def name + %{} + end + def id #w3c? "tidy" complains about numbers as identifiers ! annoying + %{id="o#@paranum"} + end + def goto + %{} + end + end + class Paragraph_id_ocn #used by table version #work area 2003w48 + attr_accessor :paranum,:font,:p_num + def initialize(md,paranum) + @paranum,@vz,@p_num=paranum,SiSU_Env::Get_init.instance.skin,SiSU_HTML_Format::Paragraph_number.new(md,paranum) #font + end + def txt + %{

#{@p_num.name} + } + end + def txt_00 + %{

#{@p_num.name} + } + end + def font_citation + %{} + end + def endnote + %{

#{@p_num.name} + } + end + def table + %{

#{@p_num.name} + } + end + def tiny + %{

#{@p_num.name} + } + end + def small + %{

#{@p_num.name} + } # keep but not used? + end + def font_tiny + %{} + end + def font_small + %{} + end + def header_ + %{

#{@p_num.name} + } + end + end + class Head_information + include SiSU_Viz + include SiSU_HTML_Format + include SiSU_Env + attr_reader :md,:sfx,:pdf,:rdf,:vz + def initialize(md='') + @md=md + @sfx,@pdf=@md.sfx,@md.pdf + @rdf=SiSU_XML_tags::RDF.new(md) + # DublinCore 1 - title + @vz=SiSU_Env::Get_init.instance.skin + @css=SiSU_Env::CSS_stylesheet.new(md) + @seg_name_html=(SiSU_HTML::Source::Seg.new.seg_name_html || []) + @seg_name_html_tracker=(SiSU_HTML::Source::Seg.new.seg_name_html_tracker || []) + case @md.file_type + when /php/; @index='index' # @index="index.php" + else @index='index' + end + @metalink='#metadata' + @tocband_scroll,@tocband_segtoc=nil,nil + end + def doc_type + %{ +\n} + end + def toc_head_escript #embedded script in this case PHP + # %{

PHP or other embedded script for object persistence may go HERE

} + end + def seg_head_escript #embedded script in this case PHP + # %{

PHP or other embedded script for object persistence may go HERE

} + end + def table_close + %{
+#{@vz.table_close}} + end + def buttons_home + %{ + #{@vz.banner_home_and_index_buttons} +} + end + def copyat + %{#{@vz.paragraph_heading_1_center}copy @ +
+ #{@vz.txt_home} + } + end + end + class Widget < Head_information + def initialize(md) + super(md) + @md=md + @cf_defaults=SiSU_Env::Info_processing_flag.new + end + def home + %{ + + #{@vz.png_homepage} + +} + end + def scroll(text) + if @md.fns =~ /\.[_-]?sst$/ + scroll=%{ + + #{text} + + +} + end + end + def seg(text) + %{ + + #{text} + + +} + end + def search + env=SiSU_Env::Info_env.new(@md.fns,@md) + env.widget.search_form + end + def manifest + %{ + + #{@vz.nav_txt_manifest} + +} + end + def pdf + pdf=if @md.programs[:pdf] and @cf_defaults.cf_0 =~/p/ + %{ + + + #{@vz.nav_txt_pdf_portrait} + + + + + #{@vz.nav_txt_pdf_landscape} + + +} + else '' + end + end + def odf + odf=if @cf_defaults.cf_0 =~/o/ + %{ + + + #{@vz.nav_txt_odf} + +} + else '' + end + end + def concordance(text) + if @md.concord_make or @cf_defaults.cf_0 =~/w/ + %{ + + #{text} + + } + else '' + end + end + end + class Head_toc < Head_information + def initialize(md) + super(md) + @md=md + @tocband_scroll,@tocband_segtoc=make_scroll,make_seg + end + def scroll_head_navigation_band + pdf=if @md.programs[:pdf] + < + #{make_seg_scroll_pdf} + +WOK + else '' + end + %{ +#{pdf} + +} + %{
+ #{@vz.banner_band} + +   +#{@vz.table_close} +

} + end + def seg_head_navigation_band(type='') + if type=~/pdf/ + @tocband_segtoc=make_scroll_seg_pdf + end + firstseg=%{ + #{@vz.png_nav_nxt} + } if @md.firstseg =~/\S+/ + %{ + + + +} + %{
+ #{@vz.banner_band} + + #@tocband_segtoc + +  #{firstseg}  +#{@vz.table_close} +

} + end + def manifest_link(text) + %{ + #{text} + } + end + def concordance_link(text) + if @md.concord_make + %{ + + #{text} + + } + else '' + end + end + def make_seg_scroll_pdf + wgt=Widget.new(@md) + scroll=%{

+ #{@vz.nav_txt_doc_link} +
+ + #{scroll} + #{wgt.seg(@vz.nav_txt_toc_link)}#{wgt.pdf}#{wgt.odf} + #{wgt.concordance(@vz.nav_txt_concordance)} + #{wgt.manifest} + #{wgt.search} + #{wgt.home} +
} + end + def make_scroll_seg_pdf + manifest=scroll=seg='' + wgt=Widget.new(@md) + seg=%{

+ #{@vz.nav_txt_toc_link} +
+ + #{seg} + #{wgt.scroll(@vz.nav_txt_doc_link)}#{wgt.pdf}#{wgt.odf} +
+ #{wgt.concordance(@vz.nav_txt_concordance)} + #{wgt.manifest} + #{wgt.search} + #{wgt.home} +
} + end + def head + %{#{doc_type} + + + #{@md.html_title} + + + #{@rdf.rdftoc} + #{@rdf.metatag_html} + #{@vz.font_css_table_file} + +#{@vz.color_body} + + + + #{@vz.js_top}} + end + def document_versions_toc + #document_version_hold + end + def links_guide_vertical_open #??? + url=(defined? @vz.url_hp) && @vz.url_hp =~/^http:\/\/\S+$/ ? @vz.url_hp : @vz.url_home + %{