# 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: xml template ** Notes: tidy -xml index.xml >> index.tidy =end module SiSU_XML_format require "#{SiSU_lib}/param" # param.rb include SiSU_Param include SiSU_Viz class Paragraph_number def initialize(md,paranum) @md=md @paranum=(paranum ? (/(\d+)/m.match(paranum)[1]) : nil) end def display p_num_display=if @paranum @paranum.gsub(/(\d+)/, '' + '  \1') else '' end p_num_display end def name p_num_name=@paranum.gsub(/(\d+)/,'') p_num_name end def goto p_num_goto=@paranum.gsub(/(\d+)/,'') p_num_goto end end class Head_information def initialize #dc rdf @full_title=@subtitle=@author=@subject=@description=@publisher=@contributor=@date=@type=@format=@identifier=@source=@language=@relation=@coverage=@rights=@copyright=@owner=@keywords='' @md=@@md # DublinCore 1 - title @rdfurl=%{ rdf:about="http://www.jus.uio.no/lm/toc"\n} if defined? @md.title.full \ and @md.title.full # DublinCore 1 - title @rdf_title=%{ dc.title="#{seg_name}#{@md.title.full}"\n} @full_title=%{\n} end if defined? @md.creator.author \ and @md.creator.author # DublinCore 2 - creator/author (author) @rdf_author=%{ dc.author="#{@md.creator.author}"\n} @author=%{\n} end if defined? @md.classify.subject \ and @md.classify.subject=~/\S+/ # DublinCore 3 - subject (us library of congress, eric or udc, or schema???) @rdf_subject=%{ dc.subject="#{@md.classify.subject}"\n} @subject=%{\n} end if defined? @md.notes.description \ and @md.notes.description=~/\S+/ # DublinCore 4 - description @rdf_description=%{ dc.description="#{@md.notes.description}"\n} @description=%{\n} end if defined? @md.publisher \ and @md.publisher=~/\S+/ # DublinCore 5 - publisher (current copy published by) @rdf_publisher=%{ dc.publisher="#{@md.publisher}"\n} @publisher=%{\n} end if defined? @md.creator.contributor \ and @md.creator.contributor=~/\S+/ # DublinCore 6 - contributor @rdf_contributor=%{ dc.contributor="#{@md.creator.contributor}"\n} @contributor=%{\n} end if defined? @md.date.published \ and @md.date.published # DublinCore 7 - date year-mm-dd @rdf_date=%{ dc.date="#{@md.date.published}"\n} @date=%{\n} end if defined? @md.date.created \ and @md.date.created # DublinCore 7 - date.created year-mm-dd @rdf_date_created=%{ dc.date.created="#{@md.date.created}"\n} @date_created=%{\n} end if defined? @md.date.issued \ and @md.date.issued # DublinCore 7 - date.issued year-mm-dd @rdf_date_issued=%{ dc.date.issued="#{@md.date.issued}"\n} @date_issued=%{\n} end if defined? @md.date.available \ and @md.date.available # DublinCore 7 - date.available year-mm-dd @rdf_date_available=%{ dc.date.available="#{@md.date.available}"\n} @date_available=%{\n} end if defined? @md.date.valid \ and @md.date.valid # DublinCore 7 - date.valid year-mm-dd @rdf_date_valid=%{ dc.date.valid="#{@md.date.valid}"\n} @date_valid=%{\n} end if defined? @md.date.modified \ and @md.date.modified # DublinCore 7 - date.modified year-mm-dd @rdf_date_modified=%{ dc.date.modified="#{@md.date.modified}"\n} @date_modified=%{\n} end if defined? @md.type \ and @md.type # DublinCore 8 - type (genre eg. report, convention etc) @rdf_type=%{ dc.type="#{@md.type}"\n} @type=%{\n} end if defined? @md.classify.format \ and @md.classify.format=~/\S+/ # DublinCore 9 - format (use your mime type) @rdf_format=%{ dc.format="#{@md.classify.format}"\n} @format=%{\n} end if defined? @md.classify.identifier \ and @md.classify.identifier=~/\S+/ # DublinCore 10 - identifier (your identifier, could use urn which is free) @rdf_identifier=%{ dc.identifier="#{@md.classify.identifier}"\n} @identifier=%{\n} end if defined? @md.original.source \ and @md.original.source=~/\S+/ # DublinCore 11 - source (document source) @rdf_source=%{ dc.source="#{@md.original.source}"\n} @source=%{\n} end if defined? @md.original.language \ and @md.original.language=~/\S+/ # DublinCore 12 - language (English) @rdf_language=%{ dc.language="#{@md.original.title}"\n} @language=%{\n} end if defined? @md.classify.relation \ and @md.classify.relation=~/\S+/ # DublinCore 13 - relation @rdf_relation=%{ dc.relation="#{@md.classify.relation}"\n} @relation=%{\n} end if defined? @md.classify.coverage \ and @md.classify.coverage=~/\S+/ # DublinCore 14 - coverage @rdf_coverage=%{ dc.coverage="#{@md.classify.coverage}"\n} @coverage=%{\n} end if defined? @md.rights.all \ and @md.rights.all=~/\S+/ # DublinCore 15 - rights @rdf_rights=%{ dc.rights="#{@md.rights.all}"\n} @rights=%{\n} end @copyright=%{\n} if @md.rights.copyright.all # possibly redundant see dc.rights @owner=%{\n} if @md.owner @keywords=%{\n} if @md.keywords @vz=SiSU_Env::Get_init.instance.skin #margin,paragraph,table,banner,url,png,txt,color,font,nav_txt,nav_png,credits,js,php @index='index' end def toc_head_escript #embedded script in this case PHP end def table_close ' ' end def buttons_home %{\n#{@banner.home_and_index_buttons}\n} end def copyat %{copy @ #{@txt.home}} end def toc_head < #{@md.html_title} #{@full_title} #{@author} #{@subject} #{@description} #{@publisher} #{@contributor} #{@date} #{@date_created} #{@date_issued} #{@date_available} #{@date_valid} #{@date_modified} #{@type} #{@format} #{@identifier} #{@source} #{@language} #{@relation} #{@coverage} #{@rights} #{@copyright} #{@owner} #{@png.ico} #{@txt.generator} #{@js.head} \n #{@color.body} #{@font.css_table_file} #{@js.top} WOK end end class Format_text_object attr_accessor :md,:txt,:format,:paranum,:p_num,:para_id,:headname,:font def initialize(md,dob) @md,@dob=md,dob if @dob[:ocn]=~/\d+/ @paranum=/(\d+)/m.match(@dob[:ocn])[1] @headname='' @headname=%{} if defined? dob.name @p_num=SiSU_XML_format::Paragraph_number.new(@md,dob.ocn) end rgx=/^[1-6-]~{1,2}/ #watch @lnk_url=@lnk_url.gsub(rgx,'') if @lnk_url =~rgx rgx=/~\{\d+\s+(.+?)\}~/ @lnk_url=@lnk_url.gsub(rgx,'\1') if @lnk_url =~rgx @vz=SiSU_Env::Get_init.instance.skin end def scr_endnote_body "#{@txt} " end end class Format_scroll < Format_text_object def initialize(md,dob) super(md,dob) end def heading_body %{

#{@p_num.name}#{@headname}#{@dob.obj}

} + %{

  #{@dob.ocn}

\n} end def heading_body1 %{

#{@p_num.name}#{@headname}#{@dob.obj}

} + %{

  #{@dob.ocn}

\n} end def heading_body2 %{

#{@p_num.name}#{@headname}#{@dob.obj}

} + %{

  #{@dob.ocn}

\n} end def heading_body3 %{

#{@p_num.name}#{@headname}#{@dob.obj}

} + %{

  #{@dob.ocn}

\n} end def heading_body4 %{

#{@p_num.name}#{@headname}#{@dob.obj}

} + %{

  #{@dob.ocn}

\n} end def heading_body5 %{
#{@p_num.name}#{@headname}#{@dob.obj}
} + %{

  #{@dob.ocn}

\n} end def heading_body6 %{
#{@p_num.name}#{@headname}#{@dob.obj}
} + %{

  #{@dob.ocn}

\n} end end 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 not ocn true elsif 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 include SiSU_Viz attr_reader :md,:sfx,:pdf,:rdf,:vz def initialize(md) @md=md @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 || []) @index='index' @metalink='#metadata' @tocband_scroll,@tocband_segtoc=nil,nil 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 end def home %{ #{@vz.png_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 %{ #{@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 \ 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 @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 concordance_navigation_band(type='') if type=~/pdf/ @tocband_concordance=make_concordance end %{
#{@vz.banner_band} #{@tocband_concordance}   #{@vz.png_nav_toc}   #{@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 seg_head_navigation_band_bottom(type='') 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) %{ #{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 make_concordance manifest=scroll=seg='' wgt=Widget.new(@md) %{ #{wgt.seg(@vz.nav_txt_toc_link)}#{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} #{@css.html} #{@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 #??? url=(((defined? @vz.url_hp) && @vz.url_hp =~/^https?:\/\/\S+$/) ? @vz.url_hp : @vz.url_home) %{