From 4b51bc00cda70d3c118401a74f1704df38c947a3 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 1 Feb 2011 09:48:30 -0500 Subject: v3 introduced as development branch, invoked using "sisu --v3 [instructions] --- lib/sisu/v3/html_format.rb | 1480 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1480 insertions(+) create mode 100644 lib/sisu/v3/html_format.rb (limited to 'lib/sisu/v3/html_format.rb') diff --git a/lib/sisu/v3/html_format.rb b/lib/sisu/v3/html_format.rb new file mode 100644 index 00000000..0a5e6e45 --- /dev/null +++ b/lib/sisu/v3/html_format.rb @@ -0,0 +1,1480 @@ +# coding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997 - 2010, Ralph Amissah, All Rights Reserved. + + * License: GPL 3 or later: + + SiSU, a framework for document structuring, publishing and search + + Copyright (C) Ralph Amissah + + 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 3 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, see . + + If you have Internet connection, the latest version of the GPL should be + available at these locations: + + + + + + + + * SiSU uses: + * Standard SiSU markup syntax, + * Standard SiSU meta-markup syntax, and the + * Standard SiSU object citation numbering and system + + * Hompages: + + + + * Download: + + + * Ralph Amissah + + + + ** Description: html formating, css template + +=end +module SiSU_HTML_Format + include SiSU_Viz + class Paragraph_number + def initialize(md,ocn) + @md,@ocn=md,ocn.to_s + @ocn ||='' + vz=SiSU_Env::Get_init.instance.skin + @skin_no_ocn=if defined? vz.ocn_display_off \ + and vz.ocn_display_off==true + true + else false + end + end + def ocn_display + if @md.markup.inspect =~/no_ocn/ \ + or @md.mod.inspect =~/--no-ocn/ \ + or @skin_no_ocn + ocn_class='ocn_off' + @ocn.gsub(/^(\d+|)$/, + %{}) + elsif @ocn.to_i==0 + @ocn.gsub(/^(\d+|)$/, + %{}) + else + ocn_class='ocn' + @ocn.gsub(/^(\d+|)$/, + %{}) + end + end + def name + %{} + end + def id #w3c? "tidy" complains about numbers as identifiers ! annoying + %{id="o#{@ocn}"} + end + def goto + %{} + end + end + class Head_information + require "#{SiSU_lib}/shared_xml" # shared_xml.rb + include SiSU_Viz + attr_reader :md,:rdf,:vz + def initialize(md) + @md=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 || []) + @toc,@index='toc','index' + @metalink='#metadata' + @tocband_scroll,@tocband_segtoc=nil,nil + end + def doc_types #used in toc & seg_nav_band + scroll=seg='' + wgt=Widget.new(@md) + %{ + + +
+ #{wgt.manifest} + #{wgt.search} +
} + end + def rdf + SiSU_XML_tags::RDF.new(md) + end + def doc_type + %{ +\n} + end + def table_close + %{ +#{@vz.table_close}} + end + def buttons_home + %{ + #{@vz.banner_home_and_index_buttons} +} + end + def copyat + %{#{@vz.paragraph_font_tiny}copy @ +
+ #{@vz.txt_home} + } + end + def html_close #moved + %{ +} + end + end + class Widget < Head_information + def initialize(md) + super(md) + @md=md + @cf_defaults=SiSU_Env::Info_processing_flag.new + @env=SiSU_Env::Info_env.new(@md.fns) + @file=SiSU_Env::SiSU_file.new(@md) + end + def home + %{ + + #{@vz.nav_txt_homepage} + +} + end + def scroll(text) + if @md.fns =~ /\.(?:-|ssm\.)?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('sisusearch',nil,nil,true) + end + def manifest + manifest_lnk=if @file.by_language? \ + or @file.by_filetype? + "#{Xx[:html_relative1]}manifest/#{@file.base_filename.manifest}" + else @file.base_filename.manifest + end + %{ + + #{@vz.nav_txt_manifest} + +} + end + def pdf #retired 2.7.9 + 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 txt #retired 2.7.9 + txt=if @cf_defaults.cf_0 =~/[at]/ + %{ + + + #{@vz.nav_txt_plaintext} + +} + else '' + end + end + def epub #retired 2.7.9 + epub=if @cf_defaults.cf_0 =~/e/ + %{ + + + #{@vz.nav_txt_epub} + +} + else '' + end + end + def odf #retired 2.7.9 + odf=if @cf_defaults.cf_0 =~/o/ + %{ + + + #{@vz.nav_txt_odf} + +} + else '' + end + end + def concordance(text) #retired 2.7.9 + if @md.concord_make \ + and @md.wc_words < 300000 #max word count for display of concordance here as would now be a large file + %{ + + #{text} + + } + else '' + end + end + end + class XML + end + class Head_toc < Head_information + def initialize(md) + super(md) + @md=md + 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 concordance_navigation_band(type='') + %{ + +
+ #{@vz.banner_band} + +   + #{@vz.png_nav_toc} +   +#{@vz.table_close} +

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

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

} + end + def manifest_link(text) +# @file=SiSU_Env::SiSU_file.new(@md) if @md + %{ + #{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} +
+ + #{wgt.manifest} + #{wgt.search} +
} + end + def make_scroll_seg_pdf + manifest=scroll=seg='' + wgt=Widget.new(@md) + seg=%{

+ #{@vz.nav_txt_toc_link} +
+ +
+ #{wgt.manifest} + #{wgt.search} +
} + end + def make_concordance + manifest=scroll=seg='' + wgt=Widget.new(@md) + %{ + +
+ #{wgt.manifest} + #{wgt.search} +
} + end + def head + rdf=SiSU_XML_tags::RDF.new(@md) + %{#{doc_type} + + + #{@md.html_title} + + +#{rdf.metatag_html} +#{@css.html}#{@css.html_seg} + +#{@vz.color_body} + + + +#{@vz.js_top}} + end + def concordance + if @md.concord_make + %{#{@vz.margin_css} +

+ + Concordance + +

+#{@vz.table_close}} + else + %{#{@vz.margin_css} +#{@vz.table_close}} + end + end + def links_guide_vertical_open +# @file=SiSU_Env::SiSU_file.new(@md) if @md + url=((defined? @vz.url_hp) && @vz.url_hp =~/^https?:\/\/\S+$/ ? @vz.url_hp : @vz.url_home) + %{ +