1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
|
# 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 <http://www.gnu.org/licenses/>.
If you have Internet connection, the latest version of the GPL should be
available at these locations:
<http://www.fsf.org/licensing/licenses/gpl.html>
<http://www.gnu.org/licenses/gpl.html>
<http://www.jus.uio.no/sisu/gpl.fsf/toc.html>
<http://www.jus.uio.no/sisu/gpl.fsf/doc.html>
<http://www.jus.uio.no/sisu/gpl.fsf/plain.txt>
* SiSU uses:
* Standard SiSU markup syntax,
* Standard SiSU meta-markup syntax, and the
* Standard SiSU object citation numbering and system
* Hompages:
<http://www.jus.uio.no/sisu>
<http://www.sisudoc.org>
* Download:
<http://www.jus.uio.no/sisu/SiSU/download.html>
* Ralph Amissah
<ralph@amissah.com>
<ralph.amissah@gmail.com>
** Description: xml template
** Notes: tidy -xml index.xml >> index.tidy
=end
module SiSU_XML_format
require "#{SiSU_lib}/param"
include SiSU_Param
include SiSU_Viz
class Paragraph_number
def initialize(md,paranum)
@md=md
@paranum=/(\d+)/m.match(paranum)[1]
end
def display
p_num_display=@paranum.gsub(/(\d+)/,
'<font size="1" color="#777777">' +
' \1</font>')
p_num_display
end
def name
p_num_name=@paranum.gsub(/(\d+)/,'<a name="\1"></a>')
p_num_name
end
def goto
p_num_goto=@paranum.gsub(/(\d+)/,'<a href="#\1">')
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 @md.full_title
@full_title=%{<meta name="dc.title" content="#{seg_name}#{@md.full_title}" />\n}
#if @md.subtitle
# #@rdf_title=%{ dc.title="#{seg_name}#{@md.title} - #{@md.subtitle}"\n}
# @full_title=%{<meta name="dc.title" content="#{seg_name}#{@md.title} - #{@md.subtitle}" />\n}
#else
# #@rdf_title=%{ dc.title="#{seg_name}#{@md.title}"\n}
# @full_title=%{<meta name="dc.title" content="#{seg_name}#{@md.title}" />\n}
#end
end
if @md.author # DublinCore 2 - author/creator (author)
@rdf_author=%{ dc.author="#{@md.author}"\n}
@author=%{<meta name="dc.author" content="#{@md.author}" />\n}
end
if @md.subject # DublinCore 3 - subject (us library of congress, eric or udc, or schema???)
@rdf_subject=%{ dc.subject="#{@md.subject}"\n}
@subject=%{<meta name="dc.subject" content="#{@md.subject}" />\n}
end
if @md.description # DublinCore 4 - description
@rdf_description=%{ dc.description="#{@md.description}"\n}
@description=%{<meta name="dc.description" content="#{@md.description}" />\n}
end
if @md.publisher # DublinCore 5 - publisher (current copy published by)
@rdf_publisher=%{ dc.publisher="#{@md.publisher}"\n}
@publisher=%{<meta name="dc.publisher" content="#{@md.publisher}" />\n}
end
if @md.contributor # DublinCore 6 - contributor
@rdf_contributor=%{ dc.contributor="#{@md.contributor}"\n}
@contributor=%{<meta name="dc.contributor" content="#{@md.contributor}" />\n}
end
if @md.date # DublinCore 7 - date year-mm-dd
@rdf_date=%{ dc.date="#{@md.date}"\n}
@date=%{<meta name="dc.date" content="#{@md.date}" #{@md.date_scheme} />\n}
end
if @md.date_created # DublinCore 7 - date.created year-mm-dd
@rdf_date_created=%{ dc.date.created="#{@md.date_created}"\n}
@date_created=%{<meta name="dc.date.created" content="#{@md.date_created}" #{@md.date_created_scheme} />\n}
end
if @md.date_issued # DublinCore 7 - date.issued year-mm-dd
@rdf_date_issued=%{ dc.date.issued="#{@md.date_issued}"\n}
@date_issued=%{<meta name="dc.date.issued" content="#{@md.date_issued}" #{@md.date_issued_scheme} />\n}
end
if @md.date_available # DublinCore 7 - date.available year-mm-dd
@rdf_date_available=%{ dc.date.available="#{@md.date_available}"\n}
@date_available=%{<meta name="dc.date.available" content="#{@md.date_available}" #{@md.date_available_scheme} />\n}
end
if @md.date_valid # DublinCore 7 - date.valid year-mm-dd
@rdf_date_valid=%{ dc.date.valid="#{@md.date_valid}"\n}
@date_valid=%{<meta name="dc.date.valid" content="#{@md.date_valid}" #{@md.date_valid_scheme} />\n}
end
if @md.date_modified # DublinCore 7 - date.modified year-mm-dd
@rdf_date_modified=%{ dc.date.modified="#{@md.date_modified}"\n}
@date_modified=%{<meta name="dc.date.modified" content="#{@md.date_modified}" #{@md.date_modified_scheme} />\n}
end
if @md.type # DublinCore 8 - type (genre eg. report, convention etc)
@rdf_type=%{ dc.type="#{@md.type}"\n}
@type=%{<meta name="dc.type" content="#{@md.type}" />\n}
end
if @md.format # DublinCore 9 - format (use your mime type)
@rdf_format=%{ dc.format="#{@md.format}"\n}
@format=%{<meta name="dc.format" content="#{@md.format}" />\n}
end
if @md.identifier # DublinCore 10 - identifier (your identifier, could use urn which is free)
@rdf_identifier=%{ dc.identifier="#{@md.identifier}"\n}
@identifier=%{<meta name="dc.identifier" content="#{@md.identifier}" />\n}
end
if @md.source # DublinCore 11 - source (document source)
@rdf_source=%{ dc.source="#{@md.source}"\n}
@source=%{<meta name="dc.source" content="#{@md.source}" />\n}
end
if @md.language[:name] # DublinCore 12 - language (English)
@rdf_language=%{ dc.language="#{@md.language[:name]}"\n}
@language=%{<meta name="dc.language" content="#{@md.language[:name]}" />\n}
end
if @md.language_original[:name] # DublinCore 12 - language (English)
@rdf_language_original=%{ dc.language="#{@md.language_original[:name]}"\n}
@language_original=%{<meta name="dc.language" content="#{@md.language_original[:name]}" />\n}
end
if @md.relation # DublinCore 13 - relation
@rdf_relation=%{ dc.relation="#{@md.relation}"\n}
@relation=%{<meta name="dc.relation" content="#{@md.relation}" />\n}
end
if @md.coverage # DublinCore 14 - coverage
@rdf_coverage=%{ dc.coverage="#{@md.coverage}"\n}
@coverage=%{<meta name="dc.coverage" content="#{@md.coverage}" />\n}
end
if @md.rights # DublinCore 15 - rights
@rdf_rights=%{ dc.rights="#{@md.rights}"\n}
@rights=%{<meta name="dc.rights" content="#{@md.rights}" />\n}
end
@copyright=%{<meta name="copyright" content="#{@md.rights}" />\n} if @md.rights # possibly redundant see dc.rights
@owner=%{<meta name="owner" content="#{@md.owner}" />\n} if @md.owner
@keywords=%{<meta name="keywords" content="#{@md.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=case @md.file_type
when /php/; 'index' # @index="index.php"
else 'index'
end
end
def toc_head_escript #embedded script in this case PHP
# %{<p>PHP or other embedded script for object persistence may go HERE</p>}
end
#def seg_head_escript #embedded script in this case PHP
# # %{<p>PHP or other embedded script for object persistence may go HERE</p>}
#end
def table_close
'</font> </td></tr></table>'
end
def buttons_home
%{\n#{@banner.home_and_index_buttons}\n}
end
def copyat
%{copy @ <a href="#{@url.home}" #{@js.home}>#{@txt.home}</a>}
end
def toc_head
#<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
# xmlns:dc="http://purl.org/dc/elements/1.1/">
# <rdf:Description rdf:about="http://www.jus.uio.no/lm/doc"
# dc:author="Author"
# dc:title="Title"
# dc:description="Description if any"
# dc:date="Publication Date"
# />
#</rdf:RDF>
#Dublin Core
<<WOK
<html>
<head>
<title>#{@md.html_title}</title>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<rdf:Description
#@rdfurl
#@rdf_title
#@rdf_subtitle
#@rdf_author
#@rdf_subject
#@rdf_description
#@rdf_publisher
#@rdf_contributor
#@rdf_date
#@rdf_date_created
#@rdf_date_issued
#@rdf_date_available
#@rdf_date_valid
#@rdf_date_modified
#@rdf_type
#@rdf_format
#@rdf_identifier
#@rdf_source
#@rdf_language
#@rdf_relation
#@rdf_coverage
#@rdf_rights
/>
</rdf:RDF>
#@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</head>
#{@color.body}
#{@font.css_table_file}
<a name="top"></a>
<a name="up"></a>
<a name="start"></a>
#{@js.top}
WOK
end
end
class Format_text_object
@@dp=nil
attr_accessor :md,:txt,:format,:paranum,:p_num,:para_id,:headname,:font
def initialize(md,t_o)
@md,@t_o=md,t_o
if t_o.class == Hash
@txt =t_o[:txt] || nil
@format =t_o[:format] || nil
@lnk_url =t_o[:lnk_url] || nil
@lnk_txt =t_o[:lnk_txt] || nil
@ocn =t_o[:ocn] || nil
#@h_name =t_o[:h_name] || nil
#elsif t_o.class == Array
# @txt =txt[0]
#elsif t_o.class == String
# @txt =txt
else
p t_o.class
p caller
end
if @t_o[:ocn]=~/\d+/
@paranum=/(\d+)/m.match(@t_o[:ocn])[1]
@headname=''
#if txt[2]=~/\d+/
m=/#{Mx[:lv_o]}\d:(\S+?)#{Mx[:lv_c]}/m.match(@format)
headname=m[1] if m
@headname=%{<a name="h#{headname}"></a>} unless headname.nil?
@p_num=SiSU_XML_format::Paragraph_number.new(@md,@paranum)
end
rgx=/^[1-6-]~{1,2}/ #watch
@lnk_url=@lnk_url.gsub(rgx,'') if @lnk_url =~rgx
@dp=@@dp ||=SiSU_Env::Info_env.new.digest.pattern
rgx=/~\{\d+\s+(.+?)#{Mx[:id_o]}#@dp#{Mx[:id_c]}\}~/
@lnk_url=@lnk_url.gsub(rgx,'\1') if @lnk_url =~rgx
@vz=SiSU_Env::Get_init.instance.skin
end
def scr_endnote_body
"<endnote>#{@txt}</endnote> "
end
end
class Format_scroll < Format_text_object
def initialize(md,t_o)
super(md,t_o)
end
def heading_body
%{<p class="norm">#{@p_num.name}#{@headname}#{@txt} </p>} +
%{<p class="paranum">#{@p_num.display} </p>\n}
end
def heading_body1
%{<h1 class="norm">#{@p_num.name}#{@headname}#{@txt} </h1>} +
%{<p class="paranum">#{@p_num.display} </p>\n}
end
def heading_body2
%{<h2 class="norm">#{@p_num.name}#{@headname}#{@txt} </h2>} +
%{<p class="paranum">#{@p_num.display} </p>\n}
end
def heading_body3
%{<h3 class="norm">#{@p_num.name}#{@headname}#{@txt} </h3>} +
%{<p class="paranum">#{@p_num.display} </p>\n}
end
def heading_body4
%{<h4 class="norm">#{@p_num.name}#{@headname}#{@txt}</h4>} +
%{<p class="paranum">#{@p_num.display} </p>\n}
end
def heading_body5
%{<h5 class="norm">#{@p_num.name}#{@headname}#{@txt} </h5>} +
%{<p class="paranum">#{@p_num.display} </p>\n}
end
def heading_body6
%{<h6 class="norm">#{@p_num.name}#{@headname}#{@txt} </h6>} +
%{<p class="paranum">#{@p_num.display} </p>\n}
end
end
class XML
end
end
__END__
|