From 506e32633838b4daf9ab566c9da083329212f219 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Sun, 26 Jan 2014 02:22:02 -0500 Subject: v5 v6: made true, branches: v6 development; v5 stable; v4 closed --- lib/sisu/v6/html_format.rb | 1437 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1437 insertions(+) create mode 100644 lib/sisu/v6/html_format.rb (limited to 'lib/sisu/v6/html_format.rb') diff --git a/lib/sisu/v6/html_format.rb b/lib/sisu/v6/html_format.rb new file mode 100644 index 00000000..bf1703a1 --- /dev/null +++ b/lib/sisu/v6/html_format.rb @@ -0,0 +1,1437 @@ +# encoding: utf-8 +=begin + + * Name: SiSU + + * Description: a framework for document structuring, publishing and search + + * Author: Ralph Amissah + + * Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, + 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 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: + + + * Git + + + + * Ralph Amissah + + + + ** Description: html formating, css template + +=end +module SiSU_HTML_Format + include SiSU_Viz + class ParagraphNumber + def initialize(md,ocn) + @md,@ocn=md,ocn.to_s + @ocn ||='' + end + def ocn_display + make=SiSU_Env::ProcessingSettings.new(@md) + if make.build.ocn? + ocn_class='ocn' + if @ocn.to_i==0 \ + or @ocn.empty? + %{} + else + @ocn.gsub(/^(\d+|)$/, + %{}) + end + else + %{} + end + end + def name + (@ocn==nil || @ocn.empty?) ? '' : %{} + end + def id #w3c? "tidy" complains about numbers as identifiers ! annoying + (@ocn==nil || @ocn.empty?) ? '' : %{id="o#{@ocn}"} + end + def goto + (@ocn==nil || @ocn.empty?) ? '' : %{} + end + end + class HeadInformation + require_relative 'css' # css.rb + require_relative 'xml_shared' # xml_shared.rb + include SiSU_Viz + attr_reader :md,:rdf,:vz + def initialize(md) + @md=md + # DublinCore 1 - title + @vz=SiSU_Viz::Defaults.new + @seg_name_html=(SiSU_HTML::Source::Seg.new.seg_name_html || []) + @seg_name_html_tracker=(SiSU_HTML::Source::Seg.new.seg_name_html_tracker || []) + @tocband_scroll,@tocband_segtoc=nil,nil + @stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure + @index,@metalink='index','#metadata' + @toc=@md.file.base_filename.html_segtoc + end + def url_path_image_sys + (@o_str.dump_or_redirect?) \ + ? './image' + : "#{Xx[:html_relative2]}_sisu/image_sys" + end + def icon + def up + 'arrow_up_red.png' + end + def next + 'arrow_next_red.png' + end + def previous + 'arrow_prev_red.png' + end + def dot_clear + 'dot_clear.png' + end + def dot_white + 'dot_white.png' + end + def dot + dot_white + end + self + end + def png_nav + def toc + %{toc} + end + def pre + %{<< previous} + end + def nxt + %{next >>} + end + def dot_toc + %{^} + end + def dot_pre + %{<} + end + def dot_nxt + %{>} + end + self + end + def doc_types(page=:seg) #used in toc & seg_nav_band + wgt=SiSU_HTML_Format::Widget.new(@md) + %{ + + +
+ #{wgt.manifest(page)} + #{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 button_home(page=:seg) + button=%{ \n \n
\n} + if @md.make.home_button_image.is_a?(Hash) + image_path=if page==:manifest + @md.file.output_path.manifest.rel_image + elsif page==:scroll + @md.file.output_path.html_scroll.rel_image + else + @md.file.output_path.html_seg.rel_image + end + SiSU_Env::FileOp.new(@md) + button +=%{

home icon -->

\n} + elsif @md.home_button_links.is_a?(Array) + @md.home_button_links.each do |links| + button +=%{

\n #{links[:say]}\n

\n} + end + end + button +=%{
} + button + end + def html_close #moved + %{ +} + end + end + class Widget < HeadInformation + def initialize(md) + super(md) + @md=md + @cf_defaults=SiSU_Env::InfoProcessingFlag.new + @env=SiSU_Env::InfoEnv.new(md.fns) + @file=SiSU_Env::FileOp.new(md) + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure + @make=SiSU_Env::ProcessingSettings.new(@md) + end + def home + %{ +
+ #{@vz.nav_txt_homepage} + +} + end + def scroll(text) + if @md.fns =~ /\.(?:-|ssm\.)?sst$/ + %{ + + #{text} + + +} + end + end + def seg(text) + %{ + + #{text} + + +} + end + def search + if @make.build.html_search_form? + env=SiSU_Env::InfoEnv.new(@md.fns,@md) + env.widget.search_form('sisusearch',nil,nil,true) + else '' + end + end + def manifest(page=:seg) + if @make.build.links_to_manifest? \ + and not @o_str.dump_or_redirect? + manifest_lnk=if @file.output_dir_structure.by_language_code? \ + or @file.output_dir_structure.by_filetype? + "#{Xx[:html_relative1]}manifest/#{@file.base_filename.manifest}" + else @file.base_filename.manifest + end + if page==:manifest + manifest_lnk="#{@md.file.output_path.manifest.url}/#{@file.base_filename.manifest}" + brace_url=SiSU_Viz::Defaults.new.url_decoration + %{ + + #{brace_url.xml_open}#{@md.file.output_path.manifest.url}/#{@file.base_filename.manifest}#{brace_url.xml_close} + +} + else + %{ + + #{@vz.nav_txt_manifest} + +} + end + else '' + end + 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 + end + class XML + end + class HeadToc < HeadInformation + def initialize(md) + super(md) + @md=md + @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure + @make=SiSU_Env::ProcessingSettings.new(@md) + @file=SiSU_Env::FileOp.new(@md) + end + def scroll_head_navigation_band + if @make.build.html_top_band? + < + #{make_scroll_search_form_and_manifest_link} + +WOK + %{ + + +
+ #{button_home(:scroll)} + + #{doc_types} + +   +#{@vz.table_close} +

} + else '' + end + end + def concordance_navigation_band + if @make.build.html_top_band? + %{ + + + +} + %{
+ #{button_home} + + #{doc_types} + +   + #{png_nav.toc} +   +#{@vz.table_close} +

} + else '' + end + end + def seg_head_navigation_band(page=:seg) + if page==:manifest + nxt=(@file.output_dir_structure.by_language_code? \ + || @file.output_dir_structure.by_filetype?) \ + ? "../html/#{@md.fnb}/toc#{@md.lang_code_insert}#{Sfx[:html]}" + : "toc#{@md.lang_code_insert}#{Sfx[:html]}" + firstseg=%{ + #{png_nav.nxt}} + elsif @md.firstseg =~/\S+/ + firstseg=%{ + #{png_nav.nxt}} + end + %{ + + + +} + %{
+#{button_home(page)} + + #{doc_types(page)} + +  #{firstseg}  +#{@vz.table_close} +

} + end + def manifest_link(text) +# @file=SiSU_Env::FileOp.new(@md) if @md + %{ + #{text} + } + end + def concordance_link(text) + if @md.concord_make + %{ + + #{text} + + } + else '' + end + end + def make_scroll_search_form_and_manifest_link + wgt=SiSU_HTML_Format::Widget.new(@md) + %{

+ #{@vz.nav_txt_doc_link} +
+ + #{wgt.manifest} + #{wgt.search} +
} + end + def make_scroll_seg_pdf + seg='' + wgt=SiSU_HTML_Format::Widget.new(@md) + seg=%{

+ #{@vz.nav_txt_toc_link} +
+ +
+ #{wgt.manifest} + #{wgt.search} +
} + end + def make_concordance + wgt=SiSU_HTML_Format::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} +#{@stylesheet.css_head} + +#{@vz.color_body} + + +} + 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::FileOp.new(@md) if @md + url=((defined? @vz.url_hp) && @vz.url_hp =~/^https?:\/\/\S+$/ ? @vz.url_hp : @vz.url_home) + %{ +