sisu 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (207) hide show
  1. checksums.yaml +7 -0
  2. data/bin/sisu +367 -0
  3. data/bin/sisugem +367 -0
  4. data/data/sisu/image/arrow_next_red.png +0 -0
  5. data/data/sisu/image/arrow_prev_red.png +0 -0
  6. data/data/sisu/image/arrow_up_red.png +0 -0
  7. data/data/sisu/image/b_bluebell.png +0 -0
  8. data/data/sisu/image/b_doc.png +0 -0
  9. data/data/sisu/image/b_epub.png +0 -0
  10. data/data/sisu/image/b_home.png +0 -0
  11. data/data/sisu/image/b_info.png +0 -0
  12. data/data/sisu/image/b_odf.png +0 -0
  13. data/data/sisu/image/b_pdf.png +0 -0
  14. data/data/sisu/image/b_search.png +0 -0
  15. data/data/sisu/image/b_toc.png +0 -0
  16. data/data/sisu/image/bullet_08.png +0 -0
  17. data/data/sisu/image/bullet_09.png +0 -0
  18. data/data/sisu/image/bullet_10.png +0 -0
  19. data/data/sisu/image/bullet_11.png +0 -0
  20. data/data/sisu/image/bullet_12.png +0 -0
  21. data/data/sisu/image/bullet_doc.png +0 -0
  22. data/data/sisu/image/bullet_red.png +0 -0
  23. data/data/sisu/image/dot_clear.png +0 -0
  24. data/data/sisu/image/dot_white.png +0 -0
  25. data/data/sisu/image/gplv3.png +0 -0
  26. data/data/sisu/image/gplv3_free_software.png +0 -0
  27. data/data/sisu/image/next.png +0 -0
  28. data/data/sisu/image/previous.png +0 -0
  29. data/data/sisu/image/rb7.ico +0 -0
  30. data/data/sisu/image/sisu.png +0 -0
  31. data/data/sisu/image/toctoc.png +0 -0
  32. data/data/sisu/version.yml +5 -0
  33. data/lib/sisu.rb +94 -0
  34. data/lib/sisu/air.rb +80 -0
  35. data/lib/sisu/ao.rb +590 -0
  36. data/lib/sisu/ao_character_check.rb +102 -0
  37. data/lib/sisu/ao_composite.rb +286 -0
  38. data/lib/sisu/ao_doc_objects.rb +565 -0
  39. data/lib/sisu/ao_doc_str.rb +2269 -0
  40. data/lib/sisu/ao_endnotes.rb +136 -0
  41. data/lib/sisu/ao_expand_insertions.rb +514 -0
  42. data/lib/sisu/ao_hash_digest.rb +174 -0
  43. data/lib/sisu/ao_idx.rb +422 -0
  44. data/lib/sisu/ao_images.rb +187 -0
  45. data/lib/sisu/ao_metadata.rb +86 -0
  46. data/lib/sisu/ao_misc_arrange.rb +207 -0
  47. data/lib/sisu/ao_numbering.rb +720 -0
  48. data/lib/sisu/ao_persist.rb +194 -0
  49. data/lib/sisu/ao_references.rb +502 -0
  50. data/lib/sisu/ao_syntax.rb +640 -0
  51. data/lib/sisu/cgi.rb +84 -0
  52. data/lib/sisu/cgi_pgsql.rb +270 -0
  53. data/lib/sisu/cgi_sql_common.rb +986 -0
  54. data/lib/sisu/cgi_sqlite.rb +244 -0
  55. data/lib/sisu/conf.rb +287 -0
  56. data/lib/sisu/constants.rb +388 -0
  57. data/lib/sisu/css.rb +3484 -0
  58. data/lib/sisu/db_columns.rb +1997 -0
  59. data/lib/sisu/db_create.rb +689 -0
  60. data/lib/sisu/db_dbi.rb +90 -0
  61. data/lib/sisu/db_drop.rb +207 -0
  62. data/lib/sisu/db_import.rb +877 -0
  63. data/lib/sisu/db_indexes.rb +146 -0
  64. data/lib/sisu/db_load_tuple.rb +323 -0
  65. data/lib/sisu/db_remove.rb +182 -0
  66. data/lib/sisu/db_select.rb +230 -0
  67. data/lib/sisu/db_sqltxt.rb +173 -0
  68. data/lib/sisu/db_tests.rb +114 -0
  69. data/lib/sisu/dbi.rb +166 -0
  70. data/lib/sisu/dbi_discrete.rb +206 -0
  71. data/lib/sisu/digests.rb +306 -0
  72. data/lib/sisu/dp.rb +1606 -0
  73. data/lib/sisu/dp_identify_markup.rb +161 -0
  74. data/lib/sisu/dp_make.rb +668 -0
  75. data/lib/sisu/embedded.rb +149 -0
  76. data/lib/sisu/errors.rb +84 -0
  77. data/lib/sisu/generic_parts.rb +131 -0
  78. data/lib/sisu/git.rb +277 -0
  79. data/lib/sisu/html.rb +775 -0
  80. data/lib/sisu/html_concordance.rb +391 -0
  81. data/lib/sisu/html_format.rb +1348 -0
  82. data/lib/sisu/html_harvest.rb +109 -0
  83. data/lib/sisu/html_harvest_author_format.rb +111 -0
  84. data/lib/sisu/html_harvest_authors.rb +466 -0
  85. data/lib/sisu/html_harvest_topics.rb +893 -0
  86. data/lib/sisu/html_lite_shared.rb +324 -0
  87. data/lib/sisu/html_manifest.rb +1032 -0
  88. data/lib/sisu/html_minitoc.rb +230 -0
  89. data/lib/sisu/html_parts.rb +437 -0
  90. data/lib/sisu/html_persist.rb +237 -0
  91. data/lib/sisu/html_promo.rb +440 -0
  92. data/lib/sisu/html_scroll.rb +235 -0
  93. data/lib/sisu/html_segments.rb +716 -0
  94. data/lib/sisu/html_shared.rb +62 -0
  95. data/lib/sisu/html_table.rb +64 -0
  96. data/lib/sisu/html_tune.rb +301 -0
  97. data/lib/sisu/hub.rb +277 -0
  98. data/lib/sisu/hub_actions.rb +1122 -0
  99. data/lib/sisu/hub_loop_markup_files.rb +170 -0
  100. data/lib/sisu/hub_options.rb +1695 -0
  101. data/lib/sisu/i18n.rb +702 -0
  102. data/lib/sisu/manpage.rb +377 -0
  103. data/lib/sisu/manpage_format.rb +85 -0
  104. data/lib/sisu/object_munge.rb +307 -0
  105. data/lib/sisu/prog_text_translation.rb +1702 -0
  106. data/lib/sisu/qrcode.rb +754 -0
  107. data/lib/sisu/relaxng.rb +1153 -0
  108. data/lib/sisu/remote.rb +246 -0
  109. data/lib/sisu/rexml.rb +148 -0
  110. data/lib/sisu/se.rb +158 -0
  111. data/lib/sisu/se_cleanoutput.rb +145 -0
  112. data/lib/sisu/se_clear.rb +105 -0
  113. data/lib/sisu/se_createsite.rb +273 -0
  114. data/lib/sisu/se_css.rb +221 -0
  115. data/lib/sisu/se_date.rb +92 -0
  116. data/lib/sisu/se_db.rb +214 -0
  117. data/lib/sisu/se_envcall.rb +326 -0
  118. data/lib/sisu/se_file_op.rb +2758 -0
  119. data/lib/sisu/se_filemap.rb +247 -0
  120. data/lib/sisu/se_get_init.rb +238 -0
  121. data/lib/sisu/se_hub_particulars.rb +234 -0
  122. data/lib/sisu/se_info_env.rb +2179 -0
  123. data/lib/sisu/se_info_port.rb +70 -0
  124. data/lib/sisu/se_info_system.rb +202 -0
  125. data/lib/sisu/se_load.rb +108 -0
  126. data/lib/sisu/se_processing.rb +659 -0
  127. data/lib/sisu/se_programs.rb +394 -0
  128. data/lib/sisu/se_remotes.rb +553 -0
  129. data/lib/sisu/se_standardise_lang.rb +176 -0
  130. data/lib/sisu/se_version.rb +174 -0
  131. data/lib/sisu/shared_images.rb +137 -0
  132. data/lib/sisu/shared_markup_alt.rb +336 -0
  133. data/lib/sisu/shared_metadata.rb +1361 -0
  134. data/lib/sisu/shared_sem.rb +156 -0
  135. data/lib/sisu/sisu_thor_lib.rb +407 -0
  136. data/lib/sisu/sitemaps.rb +224 -0
  137. data/lib/sisu/src_kdissert_share.rb +102 -0
  138. data/lib/sisu/src_po4a_share.rb +309 -0
  139. data/lib/sisu/src_po4a_shelf.rb +1217 -0
  140. data/lib/sisu/src_po4a_shelf_set.rb +297 -0
  141. data/lib/sisu/src_po4a_sst_ao_sst.rb +893 -0
  142. data/lib/sisu/src_po4a_sst_ao_sst_set.rb +284 -0
  143. data/lib/sisu/src_po4a_sstm.rb +135 -0
  144. data/lib/sisu/src_shared.rb +347 -0
  145. data/lib/sisu/src_sisupod_make.rb +171 -0
  146. data/lib/sisu/src_sisupod_sstm.rb +109 -0
  147. data/lib/sisu/sst_convert_markup.rb +323 -0
  148. data/lib/sisu/sst_do_inline_footnotes.rb +440 -0
  149. data/lib/sisu/sst_from_xml.rb +178 -0
  150. data/lib/sisu/sst_identify_markup.rb +482 -0
  151. data/lib/sisu/sst_to_s_xml_sax.rb +471 -0
  152. data/lib/sisu/termsheet.rb +163 -0
  153. data/lib/sisu/texinfo.rb +430 -0
  154. data/lib/sisu/texinfo_format.rb +541 -0
  155. data/lib/sisu/texpdf.rb +1162 -0
  156. data/lib/sisu/texpdf_format.rb +1689 -0
  157. data/lib/sisu/texpdf_parts.rb +235 -0
  158. data/lib/sisu/txt_asciidoc.rb +354 -0
  159. data/lib/sisu/txt_asciidoc_decorate.rb +207 -0
  160. data/lib/sisu/txt_markdown.rb +389 -0
  161. data/lib/sisu/txt_markdown_decorate.rb +207 -0
  162. data/lib/sisu/txt_orgmode.rb +376 -0
  163. data/lib/sisu/txt_orgmode_decorate.rb +186 -0
  164. data/lib/sisu/txt_output.rb +86 -0
  165. data/lib/sisu/txt_plain.rb +410 -0
  166. data/lib/sisu/txt_plain_decorate.rb +189 -0
  167. data/lib/sisu/txt_read.rb +109 -0
  168. data/lib/sisu/txt_rst.rb +371 -0
  169. data/lib/sisu/txt_rst_decorate.rb +186 -0
  170. data/lib/sisu/txt_shared.rb +241 -0
  171. data/lib/sisu/txt_textile.rb +367 -0
  172. data/lib/sisu/txt_textile_decorate.rb +186 -0
  173. data/lib/sisu/update.rb +141 -0
  174. data/lib/sisu/urls.rb +696 -0
  175. data/lib/sisu/utils.rb +232 -0
  176. data/lib/sisu/utils_composite.rb +115 -0
  177. data/lib/sisu/utils_response.rb +114 -0
  178. data/lib/sisu/utils_screen_text_color.rb +472 -0
  179. data/lib/sisu/utils_spell.rb +99 -0
  180. data/lib/sisu/webrick.rb +191 -0
  181. data/lib/sisu/wikispeak.rb +375 -0
  182. data/lib/sisu/xhtml.rb +472 -0
  183. data/lib/sisu/xhtml_epub2.rb +890 -0
  184. data/lib/sisu/xhtml_epub2_concordance.rb +322 -0
  185. data/lib/sisu/xhtml_epub2_format.rb +2272 -0
  186. data/lib/sisu/xhtml_epub2_persist.rb +278 -0
  187. data/lib/sisu/xhtml_epub2_segments.rb +599 -0
  188. data/lib/sisu/xhtml_epub2_tune.rb +330 -0
  189. data/lib/sisu/xhtml_parts.rb +183 -0
  190. data/lib/sisu/xhtml_shared.rb +62 -0
  191. data/lib/sisu/xhtml_table.rb +97 -0
  192. data/lib/sisu/xml_docbook5.rb +376 -0
  193. data/lib/sisu/xml_dom.rb +624 -0
  194. data/lib/sisu/xml_fictionbook2.rb +389 -0
  195. data/lib/sisu/xml_format.rb +865 -0
  196. data/lib/sisu/xml_md_oai_pmh_dc.rb +229 -0
  197. data/lib/sisu/xml_odf_odt.rb +887 -0
  198. data/lib/sisu/xml_odf_odt_format.rb +674 -0
  199. data/lib/sisu/xml_parts.rb +191 -0
  200. data/lib/sisu/xml_persist.rb +126 -0
  201. data/lib/sisu/xml_sax.rb +521 -0
  202. data/lib/sisu/xml_scaffold_structure_collapsed.rb +198 -0
  203. data/lib/sisu/xml_scaffold_structure_sisu.rb +201 -0
  204. data/lib/sisu/xml_shared.rb +665 -0
  205. data/lib/sisu/xml_tables.rb +261 -0
  206. data/lib/sisu/zap.rb +90 -0
  207. metadata +251 -0
@@ -0,0 +1,229 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** summary of generated outputs and metadata
8
+
9
+ ** Author: Ralph Amissah
10
+ <ralph@amissah.com>
11
+ <ralph.amissah@gmail.com>
12
+
13
+ ** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
14
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
15
+ All Rights Reserved.
16
+
17
+ ** License: GPL 3 or later:
18
+
19
+ SiSU, a framework for document structuring, publishing and search
20
+
21
+ Copyright (C) Ralph Amissah
22
+
23
+ This program is free software: you can redistribute it and/or modify it
24
+ under the terms of the GNU General Public License as published by the Free
25
+ Software Foundation, either version 3 of the License, or (at your option)
26
+ any later version.
27
+
28
+ This program is distributed in the hope that it will be useful, but WITHOUT
29
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
30
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
31
+ more details.
32
+
33
+ You should have received a copy of the GNU General Public License along with
34
+ this program. If not, see <http://www.gnu.org/licenses/>.
35
+
36
+ If you have Internet connection, the latest version of the GPL should be
37
+ available at these locations:
38
+ <http://www.fsf.org/licensing/licenses/gpl.html>
39
+ <http://www.gnu.org/licenses/gpl.html>
40
+
41
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
42
+
43
+ ** SiSU uses:
44
+ * Standard SiSU markup syntax,
45
+ * Standard SiSU meta-markup syntax, and the
46
+ * Standard SiSU object citation numbering and system
47
+
48
+ ** Hompages:
49
+ <http://www.jus.uio.no/sisu>
50
+ <http://www.sisudoc.org>
51
+
52
+ ** Git
53
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
54
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/xml_md_oai_pmh_dc.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_XML_Metadata
58
+ require_relative 'se' # se.rb
59
+ include SiSU_Env
60
+ require_relative 'dp' # dp.rb
61
+ include SiSU_Param
62
+ class OAI_PMH
63
+ def initialize(opt)
64
+ @md=SiSU_Param::Parameters.new(opt).get
65
+ @oai_pmh=[]
66
+ end
67
+ def read
68
+ output
69
+ end
70
+ def pre
71
+ <<WOK
72
+ <?xml version="1.0" encoding="UTF-8"?>
73
+ <oai_dc:dc
74
+ xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
75
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
76
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
77
+ xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/
78
+ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
79
+ WOK
80
+ end
81
+ def body
82
+ if defined? @md.title.full \
83
+ and @md.title.full=~/\S+/ # DublinCore 1 - title
84
+ @oai_pmh << %{ <dc:title xml:lang="en">#{@md.title.full}</dc:title>\n}
85
+ end
86
+ if defined? @md.creator.author \
87
+ and @md.creator.author=~/\S+/ # DublinCore 2 - creator/author (author)
88
+ txt=meta_content_clean(@md.creator.author)
89
+ @oai_pmh << %{ <dc:author>#{txt}</dc:author>\n}
90
+ end
91
+ if defined? @md.classify.subject \
92
+ and @md.classify.subject=~/\S+/ # DublinCore 3 - subject (us library of congress, eric or udc, or schema???)
93
+ txt=meta_content_clean(@md.classify.subject)
94
+ @oai_pmh << %{ <dc:subject>#{txt}</dc:subject>\n}
95
+ end
96
+ if defined? @md.classify.keywords \
97
+ and @md.classify.keywords=~/\S+/
98
+ txt=meta_content_clean(@md.classify.keywords)
99
+ @oai_pmh << %{ <dc:keywords>#{txt}</dc:keywords>\n}
100
+ end
101
+ if @md.publisher # DublinCore 5 - publisher (current copy published by)
102
+ txt=meta_content_clean(@md.publisher)
103
+ @oai_pmh << %{ <dc:publisher>#{txt}</dc:publisher>\n}
104
+ end
105
+ if defined? @md.creator.contributor \
106
+ and @md.creator.contributor=~/\S+/ # DublinCore 6 - contributor
107
+ txt=meta_content_clean(@md.creator.contributor)
108
+ @oai_pmh << %{ <dc:contributor>#{txt}</dc:contributor>\n}
109
+ end
110
+ if defined? @md.date.published \
111
+ and @md.date.published=~/\S+/ # DublinCore 7 - date year-mm-dd
112
+ @oai_pmh << %{ <dc:date>#{@md.date.published}</dc:date>\n}
113
+ end
114
+ if defined? @md.date.created \
115
+ and @md.date.created=~/\S+/ # DublinCore 7 - date.created
116
+ @oai_pmh << %{ <dc:date_created>#{@md.date.created}</dc:date_created>\n}
117
+ end
118
+ if defined? @md.date.issued \
119
+ and @md.date.issued=~/\S+/ # DublinCore 7 - date.issued
120
+ @oai_pmh << %{ <dc:date_issued>#{@md.date.issued}</dc:date_issued>\n}
121
+ end
122
+ if defined? @md.date.available \
123
+ and @md.date.available=~/\S+/ # DublinCore 7 - date.available
124
+ @oai_pmh << %{ <dc:date_available>#{@md.date.available}</dc:date_available>\n}
125
+ end
126
+ if defined? @md.date.valid \
127
+ and @md.date.valid=~/\S+/ # DublinCore 7 - date.valid
128
+ @oai_pmh << %{ <dc:date_valid>#{@md.date.valid}</dc:date_valid>\n}
129
+ end
130
+ if defined? @md.date.modified \
131
+ and @md.date.modified=~/\S+/ # DublinCore 7 - date.modified
132
+ @oai_pmh << %{ <dc:date_modified>#{@md.date.modified}</dc:date_modified>\n}
133
+ end
134
+ if defined? @md.notes.description \
135
+ and @md.notes.description=~/\S+/ # DublinCore 4 - description
136
+ txt=meta_content_clean(@md.notes.description)
137
+ @oai_pmh << %{ <dc:description>#{txt}</dc:description>\n}
138
+ end
139
+ if defined? @md.notes.coverage \
140
+ and @md.notes.coverage=~/\S+/ # DublinCore 14 - coverage
141
+ txt=meta_content_clean(@md.notes.coverage)
142
+ @oai_pmh << %{ <dc:coverage>#{txt}</dc:coverage>\n}
143
+ end
144
+ if defined? @md.notes.relation \
145
+ and @md.notes.relation=~/\S+/ # DublinCore 13 - relation
146
+ txt=meta_content_clean(@md.notes.relation)
147
+ @oai_pmh << %{ <dc:relation>#{txt}</dc:relation>\n}
148
+ end
149
+ if defined? @md.notes.type \
150
+ and @md.notes.type=~/\S+/ # DublinCore 8 - type
151
+ txt=meta_content_clean(@md.notes.type)
152
+ @oai_pmh << %{ <dc:type>#{txt}</dc:type>\n}
153
+ end
154
+ if defined? @md.notes.format \
155
+ and @md.notes.format=~/\S+/ # DublinCore 9 - format
156
+ txt=meta_content_clean(@md.notes.format)
157
+ @oai_pmh << %{ <dc:format>#{txt}</dc:format>\n}
158
+ end
159
+ #if defined? @md.identifier.sisupod \
160
+ #and @md.identifier.sisupod=~/\S+/ # DublinCore 10 - identifier
161
+ # txt=meta_content_clean(@md.identifier.sisupod)
162
+ # @oai_pmh << %{ <dc:identifier>#{txt}</dc:identifier>\n}
163
+ #end
164
+ if defined? @md.original.source \
165
+ and @md.original.source=~/\S+/ # DublinCore 11 - source
166
+ txt=meta_content_clean(@md.original.source)
167
+ @oai_pmh << %{ <dc:source>#{txt}</dc:source>\n}
168
+ end
169
+ if defined? @md.title.language \
170
+ and @md.title.language=~/\S+/ # DublinCore 12 - language (English)
171
+ @oai_pmh << %{ <dc:language>#{@md.title.language}</dc:language>\n}
172
+ end
173
+ if defined? @md.original.language \
174
+ and @md.original.language=~/\S+/
175
+ @oai_pmh << %{ <dc:language>#{@md.original.language}</dc:language>\n}
176
+ end
177
+ if defined? @md.rights.all \
178
+ and @md.rights.all=~/\S+/ # DublinCore 15 - rights
179
+ txt=meta_content_clean(@md.rights.all)
180
+ @oai_pmh << %{ <dc:rights>#{txt}</dc:rights>\n}
181
+ end
182
+ @oai_pmh
183
+ end
184
+ def meta_content_clean(content='')
185
+ unless content.nil?
186
+ content=content.tr('"',"'")
187
+ end
188
+ content
189
+ end
190
+ def post
191
+ '</oai_dc:dc>'
192
+ end
193
+ def output
194
+ SiSU_Env::FileOp.new(@md).mkdir
195
+ oai_pmh=SiSU_Env::FileOp.new(@md,@md.fn[:oai_pmh]).mkfile #implement in param
196
+ oai_pmh << pre
197
+ body.each do |x|
198
+ oai_pmh << x
199
+ end
200
+ oai_pmh << post
201
+ end
202
+ end
203
+ end
204
+ __END__
205
+ http://www.openarchives.org/pmh/
206
+ http://www.openarchives.org/OAI/2.0/openarchivesprotocol.htm#dublincore
207
+ http://es.dublincore.org/documents/usageguide/elements.shtml
208
+ http://dublincore.org/documents/dces/
209
+ see also http://dublincore.org/documents/dcmes-xml/
210
+ #http://www.openarchives.org/OAI/2.0/openarchivesprotocol.htm#dublincore
211
+ #sample implementation, e.g. 2
212
+ <?xml version="1.0" encoding="UTF-8"?>
213
+ <oai_dc:dc
214
+ xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
215
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
216
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
217
+ xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/
218
+ http://www.openarchives.org/OAI/2.0/oai_dc.xsd">
219
+ <dc:title xml:lang="en">Grassmann's space analysis</dc:title>
220
+ <dc:author>Hyde, E. W. (Edward Wyllys)</dc:author>
221
+ <dc:subject>LCSH:Ausdehnungslehre; LCCN QA205.H99</dc:subject>
222
+ <dc:publisher>J. Wiley &amp; Sons</dc:publisher>
223
+ <dc:date>Created: 1906; Available: 1991</dc:date>
224
+ <dc:type>text</dc:type>
225
+ <dc:identifier>http://resolver.library.cornell.edu/math/1796949
226
+ </dc:identifier>
227
+ <dc:language>english</dc:language>
228
+ <dc:rights xml:lang="en">Public Domain</dc:rights>
229
+ </oai_dc:dc>
@@ -0,0 +1,887 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** opendocument text generation
8
+
9
+ ** Author: Ralph Amissah
10
+ <ralph@amissah.com>
11
+ <ralph.amissah@gmail.com>
12
+
13
+ ** Copyright: (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
14
+ 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Ralph Amissah,
15
+ All Rights Reserved.
16
+
17
+ ** License: GPL 3 or later:
18
+
19
+ SiSU, a framework for document structuring, publishing and search
20
+
21
+ Copyright (C) Ralph Amissah
22
+
23
+ This program is free software: you can redistribute it and/or modify it
24
+ under the terms of the GNU General Public License as published by the Free
25
+ Software Foundation, either version 3 of the License, or (at your option)
26
+ any later version.
27
+
28
+ This program is distributed in the hope that it will be useful, but WITHOUT
29
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
30
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
31
+ more details.
32
+
33
+ You should have received a copy of the GNU General Public License along with
34
+ this program. If not, see <http://www.gnu.org/licenses/>.
35
+
36
+ If you have Internet connection, the latest version of the GPL should be
37
+ available at these locations:
38
+ <http://www.fsf.org/licensing/licenses/gpl.html>
39
+ <http://www.gnu.org/licenses/gpl.html>
40
+
41
+ <http://www.sisudoc.org/sisu/en/manifest/gpl.fsf.html>
42
+
43
+ ** SiSU uses:
44
+ * Standard SiSU markup syntax,
45
+ * Standard SiSU meta-markup syntax, and the
46
+ * Standard SiSU object citation numbering and system
47
+
48
+ ** Hompages:
49
+ <http://www.jus.uio.no/sisu>
50
+ <http://www.sisudoc.org>
51
+
52
+ ** Git
53
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=summary>
54
+ <http://git.sisudoc.org/gitweb/?p=code/sisu.git;a=blob;f=lib/sisu/odf.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_XML_ODF_ODT
58
+ require_relative 'se_hub_particulars' # se_hub_particulars.rb
59
+ include SiSU_Particulars
60
+ require_relative 'ao' # ao.rb
61
+ require_relative 'se' # se.rb
62
+ include SiSU_Env
63
+ require_relative 'xml_parts' # xml_parts.rb
64
+ require_relative 'xml_odf_odt_format' # xml_odf_odt_format.rb
65
+ include SiSU_XML_ODF_ODT_Format
66
+ require_relative 'shared_metadata' # shared_metadata.rb
67
+ require_relative 'txt_shared' # txt_shared.rb
68
+ require_relative 'xml_shared' # xml_shared.rb
69
+ include SiSU_XML_Munge
70
+ require_relative 'xml_persist' # xml_persist.rb
71
+ @@alt_id_count,@@alt_id_count=0,0
72
+ class Source
73
+ begin
74
+ require 'zlib'
75
+ require 'find'
76
+ rescue LoadError
77
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
78
+ error('zlib or find NOT FOUND (LoadError)')
79
+ end
80
+ def initialize(opt)
81
+ @opt=opt
82
+ @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
83
+ @@endnotes_para=[]
84
+ end
85
+ def read
86
+ begin
87
+ @md,@env,@ao_array=@particulars.md,@particulars.env,@particulars.ao_array
88
+ unless @opt.act[:quiet][:set]==:on
89
+ tool=(@opt.act[:verbose][:set]==:on \
90
+ || @opt.act[:verbose_plus][:set]==:on \
91
+ || @opt.act[:maintenance][:set]==:on) \
92
+ ? "#{@env.program.odf_viewer} file://#{@md.file.output_path.odt.dir}/#{@md.file.base_filename.odt}"
93
+ : "[#{@opt.f_pth[:lng_is]}] #{@opt.fno}"
94
+ (@opt.act[:verbose][:set]==:on \
95
+ || @opt.act[:verbose_plus][:set]==:on \
96
+ || @opt.act[:maintenance][:set]==:on) \
97
+ ? SiSU_Screen::Ansi.new(
98
+ @opt.act[:color_state][:set],
99
+ 'Opendocument (ODF:ODT)',
100
+ tool
101
+ ).green_hi_blue
102
+ : SiSU_Screen::Ansi.new(
103
+ @opt.act[:color_state][:set],
104
+ 'Opendocument (ODF:ODT)',
105
+ tool
106
+ ).green_title_hi
107
+ if (@opt.act[:verbose_plus][:set]==:on \
108
+ || @opt.act[:maintenance][:set]==:on)
109
+ SiSU_Screen::Ansi.new(
110
+ @opt.act[:color_state][:set],
111
+ @opt.fns,
112
+ 'file://' \
113
+ + @md.file.output_path.odt.dir + '/' \
114
+ + @md.file.base_filename.odt
115
+ ).flow
116
+ end
117
+ end
118
+ SiSU_XML_ODF_ODT::Source::Scroll.new(@particulars).songsheet
119
+ rescue
120
+ SiSU_Errors::Rescued.new($!,$@,@opt.selections.str,@opt.fns).location do
121
+ __LINE__.to_s + ':' + __FILE__
122
+ end
123
+ ensure
124
+ Dir.chdir(@opt.f_pth[:pth])
125
+ end
126
+ end
127
+ private
128
+ class Scroll <Source
129
+ require_relative 'txt_shared' # txt_shared.rb
130
+ include SiSU_Parts_XML
131
+ @@img_count=0
132
+ @@docstart=true
133
+ @@fns=nil
134
+ def initialize(particulars)
135
+ @md,@env,@ao_array=particulars.md,particulars.env,particulars.ao_array
136
+ @make=SiSU_Env::ProcessingSettings.new(@md)
137
+ @tab="\t"
138
+ @br=(@md.opt.act[:maintenance][:set]==:on) \
139
+ ? '' : ''
140
+ end
141
+ def songsheet
142
+ begin
143
+ @per=SiSU_XML_Persist::Persist.new
144
+ pre
145
+ @data=markup(@ao_array)
146
+ publish
147
+ ensure
148
+ SiSU_XML_Persist::Persist.new.persist_init
149
+ unless (@md.opt.act[:verbose_plus][:set]==:on \
150
+ || @md.opt.act[:maintenance][:set]==:on)
151
+ if @env.processing_path.odt =~/od[ft]/
152
+ #p "rm -r #{@env.processing_path.odt}" if @md.opt.selections.str =~/v/
153
+ FileUtils::rm_r(@env.processing_path.odf_pth)
154
+ #system("rm -r #{@env.processing_path.odt}")
155
+ end
156
+ end
157
+ end
158
+ end
159
+ def break_line
160
+ (@md.opt.act[:maintenance][:set]==:on) \
161
+ ? "\n" : ''
162
+ end
163
+ # Used for extraction of endnotes from paragraphs
164
+ def extract_endnotes(dob='')
165
+ notes=dob.obj.scan(/#{Mx[:en_a_o]}(\d+\s+.+?)#{Mx[:en_a_c]}/)[1] #FIX
166
+ @n=[]
167
+ notes.each do |n| #high cost to deal with <br> appropriately within odf, consider
168
+ n=n.dup.to_s
169
+ if n =~/#{Mx[:br_line]}/
170
+ fix=n.split(/#{Mx[:br_line]}/) #watch #added
171
+ fix.each do |x|
172
+ if x =~/\S+/ then @n << x
173
+ end
174
+ end
175
+ else @n << n
176
+ end
177
+ end
178
+ end
179
+ def odf_book_idx
180
+ if @md.book_idx
181
+ idx_arr=[]
182
+ idx_raw=SiSU_Particulars::CombinedSingleton.
183
+ instance.get_idx_raw(@md.opt).raw_idx
184
+ idx_raw.each do |x|
185
+ x=if x.is_a?(String)
186
+ SiSU_XML_ODF_ODT_Format::FormatBookIndex.new(x).
187
+ book_idx_bookmark
188
+ else nil
189
+ end
190
+ idx_arr << x.strip if x.is_a?(String)
191
+ end
192
+ @per.book_idx=idx_arr.join
193
+ end
194
+ end
195
+ def odf_metadata
196
+ @per.metadata=SiSU_Metadata::Summary.new(@md).
197
+ odf.metadata
198
+ end
199
+ def odf_tail
200
+ manifest="#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}"
201
+ @per.tail << %{<text:p text:style-name="P_normal">Available document outputs: <br /> &lt;<text:a xl:type="simple" xl:href="#{manifest}">#{manifest}</text:a>&gt;</text:p>}
202
+ @per.tail << %{\n<text:p text:style-name="P_normal">SiSU: &lt;<text:a xl:type="simple" xl:href="http://www.jus.uio.no/lm">www.jus.uio.no/sisu</text:a>&gt; and &lt;<text:a xl:type="simple" xl:href="http://www.sisudoc.org">www.sisudoc.org</text:a>&gt;</text:p>}
203
+ @per.tail << "\n</office:text></office:body></office:document-content>"
204
+ end
205
+ def set_bookmark_tag(dob)
206
+ SiSU_XML_ODF_ODT_Format::Tags.new.set_bookmark_tag(dob)
207
+ end
208
+ def heading(dob,p_num)
209
+ dob=footnote(dob)
210
+ m=/#{$1}/
211
+ breakpage=''
212
+ if @md.fns \
213
+ and @md.fns != '' \
214
+ and @md.fns !=@@fns
215
+ @@docstart=true
216
+ @@fns=@md.fns
217
+ end
218
+ unless @@docstart
219
+ breakpage=if (@md.pagenew || @md.pagebreak) \
220
+ and (@md.pagenew =~m or @md.pagebreak =~m)
221
+ '<text:p text:style-name="P_normal_page_new"> </text:p>'
222
+ elsif @md.pageline \
223
+ and @md.pageline =~m #fix
224
+ else ''
225
+ end
226
+ end
227
+ @@docstart=false
228
+ if dob.use_ != :dummy
229
+ dob.tmp=dob.obj
230
+ dob.obj=%{#{breakpage}<text:h text:style-name="H_#{dob.ln}" text:outline-level="#{dob.ln}">} \
231
+ + %{#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}</text:h>}
232
+ else dob.tmp,dob.obj='',''
233
+ end
234
+ dob
235
+ end
236
+ def toc(dob,p_num)
237
+ hardspace=(dob.lv =~/[A-D]/i) \
238
+ ? '<text:p text:style-name="Standard"/>'
239
+ : ''
240
+ toc_heading=dob.ocn \
241
+ ? (%{<text:bookmark-ref text:reference-format="text" text:ref-name="#{dob.ocn}">} \
242
+ + %{#{dob.tmp}</text:bookmark-ref>})
243
+ : dob.tmp
244
+ dob.obj=%{<text:h text:style-name="H_#{dob.ln}" text:outline-level="#{dob.ln}">} \
245
+ + %{#{toc_heading}</text:h>#{hardspace}}
246
+ dob
247
+ end
248
+ def image_src(i)
249
+ if @md.fns =~/\.ss[tm]$/ \
250
+ and FileTest.file?("#{@env.path.image_source_include(@md)}/#{i}") #review
251
+ @env.path.image_source_include(@md)
252
+ elsif @md.opt.f_pth[:pth] =~/\/\S+?\/sisupod\/\S+?\/sisupod\/doc/
253
+ pt=/(\/\S+?\/sisupod\/\S+?\/sisupod)\/doc/.match(@md.opt.f_pth[:pth])[1]
254
+ img_src=pt + '/image'
255
+ if FileTest.file?("#{img_src}/#{i}")
256
+ img_src
257
+ else
258
+ SiSU_Screen::Ansi.new(
259
+ @md.opt.act[:color_state][:set],
260
+ "ERROR - image:",
261
+ %{"#{i}" missing},
262
+ "search locations: #{@env.path.image_source_include_local}," \
263
+ + "#{@env.path.image_source_include_remote} and" \
264
+ + "#{@env.path.image_source_include}"
265
+ ).error2 unless @md.opt.act[:quiet][:set]==:on
266
+ nil
267
+ end
268
+ elsif @md.fns =~/\.ss[tm]$/ \
269
+ and FileTest.file?("#{@env.path.image_source_include_local}/#{i}") #review
270
+ @env.path.image_source_include_local
271
+ elsif @md.fns =~/\.ss[tm]$/ \
272
+ and FileTest.file?("#{@env.path.image_source_sisu_includes(@md)}/#{i}")
273
+ @env.path.image_source_sisu_includes(@md)
274
+ elsif @md.fns =~/\.-ss[tm]$/ \
275
+ and FileTest.file?("#{@env.path.image_source_include_remote}/#{i}")
276
+ @env.path.image_source_include_remote
277
+ else
278
+ SiSU_Screen::Ansi.new(
279
+ @md.opt.act[:color_state][:set],
280
+ "ERROR - image:",
281
+ %{"#{i}" missing},
282
+ "search locations: " \
283
+ + @env.path.image_source_include_local + ',' \
284
+ + @env.path.image_source_include_remote + 'and' \
285
+ + @env.path.image_source_include \
286
+ + @md.opt.sisu_data_dir?
287
+ ).error2 unless @md.opt.act[:quiet][:set]==:on
288
+ nil
289
+ end
290
+ end
291
+ def image_odf(img)
292
+ # copy image to od image directory (unless exists)
293
+ # divide pixel dimension by 37.79485 and retain 3 decimal places
294
+ m=img[1]
295
+ i=/^(\S+?\.(?:png|jpg|gif))/.match(m).captures.join \
296
+ if m =~/^(\S+?\.(?:png|jpg|gif))/
297
+ c=/^\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"/.match(m).captures.join \
298
+ if m =~/^\S+?\.(?:png|jpg|gif)\s+.+?"(.*?)"/
299
+ w,h=/\s(\d+)x(\d+)/.match(m).captures if m =~/\s\d+x\d+/
300
+ w=(w.to_i/37.79485).to_s
301
+ h=(h.to_i/37.79485).to_s
302
+ h=/([0-9]+\.\d{0,3})/.match(h).captures.join
303
+ w=/([0-9]+\.\d{0,3})/.match(w).captures.join
304
+ image_source=image_src(i)
305
+ if image_source
306
+ if FileTest.file?("#{image_source}/#{i}")
307
+ FileUtils::cp(
308
+ "#{image_source}/#{i}",
309
+ "#{@env.processing_path.odt}/Pictures/#{i}"
310
+ )
311
+ else STDERR.puts %{\t*WARN* did not find image - "#{image_source}/#{i}" [#{__FILE__}:#{__LINE__}]}
312
+ end
313
+ end
314
+ img=if i.to_s =~/jpg|png|gif/ \
315
+ and h.to_s =~/\d/ \
316
+ and w.to_s =~/\d/
317
+ @@img_count +=1
318
+ %{<draw:frame draw:style-name="fr1" draw:name="graphics#{@@img_count}" text:anchor-type="as-char" svg:width="#{w}cm" svg:height="#{h}cm" draw:z-index="2"><draw:image xl:href="Pictures/#{i}" xl:type="simple" xl:show="embed" xl:actuate="onLoad"/></draw:frame>#{c}} #anchor-type: as-char or paragraph or char or ...
319
+ else %{<text:p text:style-name="P_normal">[image omitted]</text:p>}
320
+ end
321
+ end
322
+ def image(dob)
323
+ m=if dob.obj =~/#{Mx[:lnk_o]}[ ]*(.+?)[ ]*#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/
324
+ dob.obj.scan(/(#{Mx[:lnk_o]}[ ]*(.+?)[ ]*#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]})/)
325
+ elsif dob.obj =~/#{Mx[:lnk_o]}[ ]*(.+?)[ ]*#{Mx[:lnk_c]}image/
326
+ dob.obj.scan(/(#{Mx[:lnk_o]}[ ]*(.+?)[ ]*#{Mx[:lnk_c]}(image))/)
327
+ else nil
328
+ end
329
+ if m then m.each do |i|
330
+ cont,url=i[1],i[2]
331
+ cont=cont.gsub(/([)(\]\[])/,"\\\\\\1").
332
+ gsub(/([+?])/,"\\\\\\1") # incorrect handling of +
333
+ url=url.gsub(/([+?])/,"\\\\\\1")
334
+ dob.obj=dob.obj.sub(/#{Mx[:lnk_o]}[ ]*#{cont}[ ]*#{Mx[:lnk_c]}image/m,image_odf(i)).
335
+ sub(/#{Mx[:lnk_o]}[ ]*#{cont}[ ]*#{Mx[:lnk_c]}#{Mx[:url_o]}#{url}#{Mx[:url_c]}/m,image_odf(i)).
336
+ sub(/\\([)(\]\[?])/,'\1') #clumsy fix
337
+ end
338
+ m=nil
339
+ end
340
+ dob
341
+ end
342
+ def text_link_odf(txt,url,trail)
343
+ txt=txt.gsub(/(\\\+)/,'+') #this is convoluted, and risky :-(
344
+ url=url.gsub(/(\\\+)/,'+') #this is convoluted, and risky :-(
345
+ map_nametags=SiSU_Particulars::CombinedSingleton.
346
+ instance.get_map_nametags(@md).nametags_map
347
+ t=case url
348
+ when /^https?:/
349
+ %{<text:a xl:type="simple" xl:href="#{url}">#{txt.strip}</text:a>#{trail}}
350
+ when /^:/ # site same document collection html link
351
+ url=url.gsub(/^:/,"#{@env.url.root}/")
352
+ %{<text:a xl:type="simple" xl:href="#{url}">#{txt.strip}</text:a>#{trail}}
353
+ when /^\.\.\// # site same document collection html link
354
+ url=url.gsub(/^\.\.\//,"#{@env.url.root}/")
355
+ %{<text:a xl:type="simple" xl:href="#{url}">#{txt.strip}</text:a>#{trail}}
356
+ else # document internal link
357
+ if map_nametags[url] \
358
+ and map_nametags[url][:segname]
359
+ else p "NOT FOUND name_tags: #{url}"
360
+ end
361
+ t=map_nametags[url] \
362
+ && map_nametags[url][:segname] \
363
+ ? (%{<text:a xl:type="simple" xl:href="#{@env.url.root}/#{@md.fnb}/#{map_nametags[url][:segname]}#{Sfx[:html]}##{url}">} \
364
+ + %{#{txt.strip}</text:a>#{trail}})
365
+ : %{#{txt.strip}#{trail}}
366
+ end
367
+ t
368
+ end
369
+ def text_link_odf_bookmark(txt,url,trail)
370
+ SiSU_Particulars::CombinedSingleton.instance.get_map_nametags(@md).nametags_map
371
+ %{<text:bookmark-ref text:reference-format="text" text:ref-name="#{url}">#{txt.strip}</text:bookmark-ref>#{trail}}
372
+ end
373
+ def text_link(dob)
374
+ m=dob.obj.scan(/(#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:url_o]}(\S+?)#{Mx[:url_c]})/) #sort
375
+ if m
376
+ m.each do |i|
377
+ txt,url,trail=i[1],i[2]
378
+ txt=txt.gsub(/([)(\]\[])/,"\\\\\\1").
379
+ gsub(/([+?*])/,"\\\\\\1") # problems with +
380
+ url=url.gsub(/([+?])/,"\\\\\\1") # problems with +
381
+ dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:url_o]}#{url}#{Mx[:url_c]}/m,
382
+ text_link_odf(txt,url,trail)). #make sure trailing ']' are not caught in url
383
+ gsub(/\\([)(\]\[?])/,'\1') #clumsy fix
384
+ end
385
+ m=nil
386
+ end
387
+ dob
388
+ end
389
+ def text_link_relative(dob)
390
+ m=dob.obj.scan(/(#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]})/) #sort
391
+ if m
392
+ m.each do |i|
393
+ txt,url,trail=i[1],i[2]
394
+ txt=txt.gsub(/([)(\]\[])/,"\\\\\\1").
395
+ gsub(/([+?*])/,"\\\\\\1") # problems with +
396
+ url=url.gsub(/([+?])/,"\\\\\\1") # problems with +
397
+ dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{url}#{Mx[:rel_c]}/m,
398
+ text_link_odf_bookmark(txt,url,trail)). #make sure trailing ']' are not caught in url
399
+ gsub(/\\([)(\]\[?])/,'\1') #clumsy fix
400
+ end
401
+ m=nil
402
+ end
403
+ dob
404
+ end
405
+ def text_link_relative_(dob)
406
+ m=dob.obj.scan(/(#{Mx[:lnk_o]}(.+?)#{Mx[:lnk_c]}#{Mx[:rel_o]}(\S+?)#{Mx[:rel_c]})/) #sort
407
+ if m
408
+ m.each do |i|
409
+ txt,url,trail=i[1],i[2]
410
+ txt=txt.gsub(/([)(\]\[])/,"\\\\\\1")
411
+ dob.obj=dob.obj.gsub(/#{Mx[:lnk_o]}[ ]*#{txt}#{Mx[:lnk_c]}#{Mx[:rel_o]}#{url}#{Mx[:rel_c]}/m,
412
+ text_link_odf(txt,url,trail)). #make sure trailing ']' are not caught in url
413
+ gsub(/\\([)(\]\[?])/,'\1') #clumsy fix
414
+ end
415
+ m=nil
416
+ end
417
+ dob
418
+ end
419
+ def normal(dob,p_num) #P1 - P3
420
+ dob=footnote(dob)
421
+ dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
422
+ '<text:a xl:type="simple" xl:href="\1">\1</text:a>'). #http ftp matches escaped, no decoration
423
+ gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
424
+ %{#{the_url_decoration.xml_open}<text:a xl:type="simple" xl:href="mailto:\\1">\\1</text:a>#{the_url_decoration.xml_close}}).
425
+ gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
426
+ %{#{the_url_decoration.xml_open}<text:a xl:type="simple" xl:href="\\1">\\1</text:a>#{the_url_decoration.xml_close}}) #http ftp matches with decoration
427
+ dob.obj= if dob.is==:para \
428
+ and dob.indent.to_s =~/[0-9]/ \
429
+ and dob.indent == dob.hang
430
+ %{<text:p text:style-name="P_indent_#{dob.indent}">#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}</text:p>}
431
+ elsif dob.is==:para \
432
+ and dob.hang.to_s =~/[0-9]/ \
433
+ and dob.indent != dob.hang
434
+ %{<text:p text:style-name="P_h#{dob.hang}_i#{dob.indent}">#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}</text:p>}
435
+ else %{<text:p text:style-name="P_normal">#{p_num[:set_ref]}#{set_bookmark_tag(dob)}#{dob.obj}#{p_num[:display]}</text:p>}
436
+ end
437
+ dob
438
+ end
439
+ def fontface(dob)
440
+ end
441
+ def footnote_urls(str)
442
+ str=str.gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
443
+ %{#{the_url_decoration.xml_open}<text:a xl:type="simple" xl:href="\\1">\\1</text:a>#{the_url_decoration.xml_close}})
444
+ str=text_link(str) if str =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/
445
+ str=text_link_relative(str) if str =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/
446
+ str
447
+ end
448
+ def footnote(t_o)
449
+ str=if defined? t_o.obj then t_o.obj
450
+ elsif t_o.is_a?(String) then t_o
451
+ end
452
+ if str
453
+ @astx||=10000
454
+ @astxs||=20000
455
+ if str =~/#{Mx[:en_a_o]}\d+\s+/
456
+ str=str.gsub(/#{Mx[:en_a_o]}(\d+)\s+(.+?)#{Mx[:en_a_c]}/,
457
+ '<text:note text:id="ftn\1" text:note-class="footnote"><text:note-citation>\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>')
458
+ end
459
+ if str =~/#{Mx[:en_a_o]}([*]+)\s+/
460
+ a=$1.gsub(/([*])/,"\\\\\\1")
461
+ str=str.gsub(/#{Mx[:en_a_o]}([*]+)\s+(.+?)#{Mx[:en_a_c]}/,
462
+ %{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>})
463
+ @astxs+=1
464
+ end
465
+ if str=~/#{Mx[:en_a_o]}[*+]+\s/
466
+ asterisk=str.scan(/#{Mx[:en_a_o]}([*+]+)\s+(.+?)#{Mx[:en_a_c]}/)
467
+ asterisk.each do |x|
468
+ a=x[0].gsub(/([*+])/,"\\\\\\1")
469
+ str=group_clean(str)
470
+ str=footnote_urls(str)
471
+ str=str.gsub(/#{Mx[:en_a_o]}(#{a})\s+(.+?)#{Mx[:en_a_c]}/,
472
+ %{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>})
473
+ @astx+=1
474
+ end
475
+ end
476
+ if str=~/#{Mx[:en_b_o]}[*+]\d+\s/
477
+ asterisk=str.scan(/#{Mx[:en_b_o]}([*+]\d+)\s+(.+?)#{Mx[:en_b_c]}/)
478
+ asterisk.each do |x|
479
+ a=x[0].gsub(/([*+])/,"\\\\\\1")
480
+ str=group_clean(str)
481
+ str=footnote_urls(str)
482
+ str=str.gsub(/#{Mx[:en_b_o]}(#{a})\s+(.+?)#{Mx[:en_b_c]}/,
483
+ %{<text:note text:id="ftn#{@astx.to_s}" text:note-class="footnote"><text:note-citation text:label="\\1">\\1</text:note-citation><text:note-body><text:p text:style-name="Footnote"> \\2</text:p><text:p text:style-name="Footnote"/></text:note-body></text:note>})
484
+ @astx+=1
485
+ end
486
+ end
487
+ end
488
+ if defined? t_o.obj then t_o.obj=str
489
+ elsif t_o.is_a?(String) then t_o=str
490
+ end
491
+ t_o
492
+ end
493
+ def group_clean(str)
494
+ str=str.gsub(/&amp;nbsp;|&nbsp;|#{Mx[:nbsp]}/,'&#160;').
495
+ gsub(/</,'&lt;').gsub(/>/,'&gt;').
496
+ gsub(/&lt;(text:span text:style-name="Span_\S+?"|\/text:span)&gt;/,'<\1>'). #works, not ideal
497
+ gsub(/#{Mx[:br_line]}/,'<br />').
498
+ gsub(/&lt;br(?:\s+\/)?&gt;/,'<br />')
499
+ end
500
+ def poem(dob,p_num) #P4 #same as group
501
+ parray=[]
502
+ dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i|
503
+ set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : ''
504
+ parablock=group_clean(parablock)
505
+ parablock=footnote(parablock)
506
+ parray << %{<text:p text:style-name="P_group">#{set_ref}#{parablock}</text:p>} if parablock =~/\S+/
507
+ end
508
+ dob.obj=parray.join \
509
+ + %{<text:p text:style-name="P_group">#{p_num[:display]}</text:p>} \
510
+ + '<text:p text:style-name="Standard"/>'
511
+ dob
512
+ end
513
+ def group(dob,p_num) #P4 #same as verse
514
+ parray=[]
515
+ dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
516
+ '<text:a xl:type="simple" xl:href="\1">\1</text:a>'). #http ftp matches escaped, no decoration
517
+ gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
518
+ %{#{the_url_decoration.xml_open}<text:a xl:type="simple" xl:href="mailto:\\1">\\1</text:a>#{the_url_decoration.xml_close}}).
519
+ gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
520
+ %{#{the_url_decoration.xml_open}<text:a xl:type="simple" xl:href="\\1">\\1</text:a>#{the_url_decoration.xml_close}}) #http ftp matches with decoration
521
+ dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i|
522
+ set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : ''
523
+ parablock=group_clean(parablock)
524
+ parablock=parablock.gsub(/&lt;text:a xl:type="simple" xl:href="(.+?)"&gt;/m,
525
+ '<text:a xl:type="simple" xl:href="\1">').
526
+ gsub(/&lt;(\/text:a)&gt;/,'<\1>').
527
+ gsub(/&lt;(text:note text:id=.+?)&gt;/,'<\1>').
528
+ gsub(/&lt;(text:p text:style-name="Footnote")&gt;/,'<\1>').
529
+ gsub(/&lt;(\/?text:(?:note-citation|note-body|note|p))&gt;/,'<\1>')
530
+ parablock=footnote(parablock)
531
+ parray << %{<text:p text:style-name="P_group">#{set_ref}#{parablock}</text:p>} if parablock =~/\S+/
532
+ end
533
+ dob.obj=parray.join \
534
+ + %{<text:p text:style-name="P_group">#{p_num[:display]}</text:p>} \
535
+ + '<text:p text:style-name="Standard"/>'
536
+ dob
537
+ end
538
+ def block(dob,p_num) #P4 #same as verse
539
+ parray=[]
540
+ dob.obj=dob.obj.gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
541
+ '<text:a xl:type="simple" xl:href="\1">\1</text:a>'). #http ftp matches escaped, no decoration
542
+ gsub(/#{Mx[:url_o]}([a-zA-Z0-9._-]+\@\S+?\.[a-zA-Z0-9._-]+)#{Mx[:url_c]}/,
543
+ %{#{the_url_decoration.xml_open}<text:a xl:type="simple" xl:href="mailto:\\1">\\1</text:a>#{the_url_decoration.xml_close}}).
544
+ gsub(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/,
545
+ %{#{the_url_decoration.xml_open}<text:a xl:type="simple" xl:href="\\1">\\1</text:a>#{the_url_decoration.xml_close}}) #http ftp matches with decoration
546
+ dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i|
547
+ set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : ''
548
+ parablock=group_clean(parablock)
549
+ parablock=parablock.gsub(/&lt;text:a xl:type="simple" xl:href="(.+?)"&gt;/m,
550
+ '<text:a xl:type="simple" xl:href="\1">').
551
+ gsub(/&lt;(\/text:a)&gt;/,'<\1>').
552
+ gsub(/&lt;(text:note text:id=.+?)&gt;/,'<\1>').
553
+ gsub(/&lt;(text:p text:style-name="Footnote")&gt;/,'<\1>').
554
+ gsub(/&lt;(\/?text:(?:note-citation|note-body|note|p))&gt;/,'<\1>')
555
+ parablock=footnote(parablock)
556
+ parray << %{<text:p text:style-name="P_group">#{set_ref}#{parablock}</text:p>} \
557
+ if parablock =~/\S+/
558
+ end
559
+ dob.obj=parray.join \
560
+ + %{<text:p text:style-name="P_group">#{p_num[:display]}</text:p>} \
561
+ + '<text:p text:style-name="Standard"/>'
562
+ dob
563
+ end
564
+ def code(dob,p_num) #P5
565
+ if dob.is==:code
566
+ dob.obj=dob.obj.gsub(/\s\s/,'&#160;&#160;')
567
+ parray=[]
568
+ dob.obj.split(/#{Mx[:br_line]}|#{Mx[:br_nl]}/).each_with_index do |parablock,i|
569
+ set_ref=(i==0) ? "#{p_num[:set_ref]}#{set_bookmark_tag(dob)}" : ''
570
+ parablock=group_clean(parablock)
571
+ parablock=parablock.gsub(/^\s*$/,'<br />').
572
+ gsub(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/,
573
+ '<text:a xl:type="simple" xl:href="\1">\1</text:a>') #http ftp matches escaped, no decoration
574
+ parray << %{<text:p text:style-name="P_code">#{set_ref}#{parablock}</text:p>} if parablock =~/\S+/
575
+ end
576
+ dob.obj=parray.join \
577
+ + %{<text:p text:style-name="P_group">#{p_num[:display]}</text:p>} \
578
+ + '<text:p text:style-name="Standard"/>'
579
+ end
580
+ dob
581
+ end
582
+ def table(dob,p_num) #
583
+ if dob.is ==:table
584
+ dob=footnote(dob) #check
585
+ table=SiSU_XML_ODF_ODT_Format::Table.new(@md,dob,p_num)
586
+ dob=table.table
587
+ end
588
+ dob
589
+ end
590
+ def obj_break(dob)
591
+ if dob.is ==:break
592
+ br=SiSU_XML_ODF_ODT_Format::FormatObjBreak.new(@md,dob)
593
+ if dob.obj==Mx[:br_page] \
594
+ or dob.obj==Mx[:br_page_new]
595
+ dob=br.br_page
596
+ elsif dob.obj==Mx[:br_page_line]
597
+ dob=br.br_page_line
598
+ elsif dob.obj==Mx[:br_obj]
599
+ dob=br.obj_sep
600
+ end
601
+ end
602
+ dob
603
+ end
604
+ def odf_structure(md,dob)
605
+ @md,@dob=md,dob
606
+ dob=if dob.is !=:code
607
+ dob=image(dob) if dob.obj =~/#{Mx[:lnk_o]}[ ]*\S+?\.(?:png|jpg|gif)\s.+?#{Mx[:lnk_c]}(?:#{Mx[:url_o]}\S+?#{Mx[:url_c]}|image)/
608
+ dob=text_link(dob) if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:url_o]}\S+?#{Mx[:url_c]}/
609
+ dob=text_link_relative(dob) if dob.obj =~/#{Mx[:lnk_o]}.+?#{Mx[:lnk_c]}#{Mx[:rel_o]}\S+?#{Mx[:rel_c]}/
610
+ dob
611
+ else dob
612
+ end
613
+ p_num={ display: '', set_ref: '' }
614
+ if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/
615
+ if @make.build.odt_ocn?
616
+ if defined? dob.ocn \
617
+ and dob.ocn.is_a?(Fixnum)
618
+ p_num=SiSU_XML_ODF_ODT_Format::ParagraphNumber.new(@make,dob.ocn).set_bookmark_and_display
619
+ end
620
+ end
621
+ end
622
+ if dob.is==:heading
623
+ @per.body << heading(dob,p_num).obj << break_line*2
624
+ if SiSU_Env::ProcessingSettings.new(md).build.toc?
625
+ if dob.lv =~/[A-D1]/i
626
+ @per.toc << toc(dob,p_num).obj
627
+ end
628
+ end
629
+ elsif dob.is ==:verse
630
+ @per.body << poem(dob,p_num).obj << break_line*2
631
+ elsif dob.is==:group
632
+ @per.body << group(dob,p_num).obj << break_line*2
633
+ elsif dob.is==:block
634
+ @per.body << block(dob,p_num).obj << break_line*2
635
+ elsif dob.is==:code
636
+ @per.body << code(dob,p_num).obj << break_line*2
637
+ elsif dob.is==:table #elsif dob.obj =~ /<!Th?¡/u
638
+ @per.body << table(dob,p_num).obj << break_line*2
639
+ elsif dob.is==:break
640
+ @per.body << obj_break(dob).obj << break_line*2
641
+ else
642
+ @per.body << normal(dob,p_num).obj << break_line*2 # main text, contents, body KEEP
643
+ end
644
+ @@endnotes_para=[]
645
+ end
646
+ def tidywords(wordlist)
647
+ wordlist
648
+ end
649
+ def markup(data) # Used for major markup instructions
650
+ #safe_characters=/[^a-zA-Z0-9}{\/?,."';:)(><\-_&!@%~#\]\[*=$| \n+`#{Mx[:tc_p]}]/u
651
+ dir=SiSU_Env::InfoEnv.new(@md.fns)
652
+ dir.path.odt_bld
653
+ @data_mod,@endnotes,@level,@cont,@copen,@odf_contents_close=Array.new(6){[]}
654
+ @rcdc=false
655
+ (0..7).each { |x| @cont[x]=@level[x]=false }
656
+ (4..7).each { |x| @odf_contents_close[x]='' }
657
+ odf_tail #($1,$2)
658
+ bullet=image_src('bullet_09.png')
659
+ if bullet
660
+ if FileTest.file?("#{bullet}/bullet_09.png")
661
+ FileUtils::cp("#{bullet}/bullet_09.png","#{@env.processing_path.odt}/Pictures/.")
662
+ else STDERR.puts %{\t*WARN* did not find image - "#{bullet}/bullet_09.png" [#{__FILE__}:#{__LINE__}]}
663
+ end
664
+ end
665
+ odf_book_idx
666
+ odf_metadata
667
+ data.each do |dob|
668
+ #p dob.obj if dob.obj =~safe_characters and @md.opt.selections.str =~/V/ #KEEP
669
+ dob.obj='' if dob.obj =~/#{Mx[:lv_o]}\d+:.*?#{Mx[:lv_c]}.+?#{Mx[:pa_non_object_dummy_heading]}/ #fix Mx[:lv_o]
670
+ para_array=[]
671
+ dob.obj=dob.obj.gsub(/</,'&lt;').gsub(/>/,'&gt;')
672
+ word=dob.obj.scan(/\S+|\n/)
673
+ if word
674
+ word.each do |w| # _ - / # | : ! ^ ~
675
+ unless dob =~/^(?:#{Rx[:meta]}|%+ )/m
676
+ w=w.gsub(/&#(?:126|152);/,'~'). #126 usual
677
+ gsub(/&nbsp;/,'&#160;')
678
+ if w !~/(?:&\S{2,7}?;)+/
679
+ w=w.gsub(/&/,'&amp;')
680
+ end
681
+ if w !~/&\S{1,7}?;(?:&\S{1,7}?;)+/ #imperfect
682
+ w=w.gsub(/(&\S{1,7};)+&/,'\1&amp;')
683
+ end
684
+ end
685
+ para_array << w
686
+ end
687
+ dob.obj=para_array.join(' ')
688
+ dob.obj=dob.obj.strip
689
+ end
690
+ if dob.is==:code #{Mx[:gr_o]}code#{Mx[:gr_c]}/ #fix #code-block: angle brackets special characters #fix
691
+ dob.obj=dob.obj.gsub(/(^|[^}])_(?:<|&lt;)/m,'\1&lt;').gsub(/(^|[^}])_(?:>|&gt;)/m,'\1&gt;').
692
+ gsub(/(^|[^}])_(?:<|&lt;)/m,'\1&lt;').gsub(/(^|[^}])_(?:>|&gt;)/m,'\1&gt;')
693
+ end
694
+ if dob.of==:block
695
+ dob.obj=dob.obj.gsub(/#{Mx[:gl_bullet]}/,'● ')
696
+ end
697
+ dob.obj=dob.obj.gsub(/#{Mx[:fa_strike_o]}(.+?)#{Mx[:fa_strike_c]}/,'<del>\1</del>').
698
+ gsub(/#{Mx[:fa_insert_o]}(.+?)#{Mx[:fa_insert_c]}/,'<ins>\1</ins>').
699
+ gsub(/#{Mx[:fa_cite_o]}(.+?)#{Mx[:fa_cite_c]}/,'<cite>\1</cite>').
700
+ gsub(/#{Mx[:tag_o]}\S+?#{Mx[:tag_c]}/,
701
+ '<text:bookmark-start text:name="\1"/><text:bookmark-end text:name="\1"/>'). #check
702
+ gsub(/#{Mx[:mk_o]}#([a-zA-Z]+)#{Mx[:mk_c]}/,'&\1;').
703
+ gsub(/#{Mx[:mk_o]}(#[0-9]+)#{Mx[:mk_c]}/,'&\1;').
704
+ gsub(/#{Mx[:mk_o]}[~-]##{Mx[:mk_c]}/,'')
705
+ if dob.is==:para \
706
+ and dob.bullet_
707
+ dob.obj='<draw:frame draw:style-name="gr1" text:anchor-type="as-char" svg:width="0.22cm" svg:height="0.22cm" draw:z-index="2"><draw:image xl:href="Pictures/bullet_09.png" xl:type="simple" xl:show="embed" xl:actuate="onLoad"/></draw:frame> ' +
708
+ dob.obj
709
+ end
710
+ dob.obj=dob.obj.gsub(/#{Mx[:br_line]}/,'<br />').
711
+ gsub(/&#169;/,'©'). #too arbitrary
712
+ gsub(/.+?<-#>/,''). # remove dummy headings (used by html) #check
713
+ gsub(/#{Mx[:fa_bold_o]}(.+?)#{Mx[:fa_bold_c]}/,
714
+ '<text:span text:style-name="Span_bold">\1</text:span>').
715
+ gsub(/#{Mx[:fa_italics_o]}(.+?)#{Mx[:fa_italics_c]}/,
716
+ '<text:span text:style-name="Span_italic">\1</text:span>').
717
+ gsub(/#{Mx[:fa_underscore_o]}(.+?)#{Mx[:fa_underscore_c]}/,
718
+ '<text:span text:style-name="Span_underscore">\1</text:span>').
719
+ gsub(/#{Mx[:fa_superscript_o]}(.+?)#{Mx[:fa_superscript_c]}/,
720
+ '<text:span text:style-name="Span_superscript">\1</text:span>').
721
+ gsub(/#{Mx[:fa_subscript_o]}(.+?)#{Mx[:fa_subscript_c]}/,
722
+ '<text:span text:style-name="Span_subscript">\1</text:span>').
723
+ gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,
724
+ '<text:span text:style-name="Span_monospace">\1</text:span>').
725
+ gsub(/­/u,'-').
726
+ gsub(/ /u, ' '). # space identify
727
+ gsub(/ /u, ' '). # space identify
728
+ gsub(/·/u,'*').
729
+ gsub(/[­–—]/u,'-'). #— – chk
730
+ gsub(/ < /i,'&#060;').
731
+ gsub(/\\copy(?:right)?\b/,'&#169;').
732
+ gsub(/\\trademark\b|\\tm\b/,'&#174;').
733
+ gsub(/\44/,'&#36;'). #$ watch
734
+ gsub(/<a href=".+?">(.+?)<\/a>/,'\1').
735
+ gsub(/#{Mx[:mk_o]}name#\S+?#{Mx[:mk_c]}/,'') # remove name links
736
+ wordlist=dob.obj.scan(/\S+/)
737
+ dob.obj=tidywords(wordlist).join(' ').strip
738
+ @rcdc=true if @rcdc==false \
739
+ and (dob.obj =~/~metadata/ \
740
+ or dob =~/#{Mx[:lv_o]}1:meta#{Mx[:lv_x]}\s*Document Information/) #fix Mx[:lv_o]
741
+ if dob.is !~/(^#{Rx[:meta]}|#{Mx[:br_eof]}|#{Mx[:br_endnotes]})/ #check
742
+ if defined? dob.ocn and dob.ocn =~/\d+/
743
+ @p_num=SiSU_XML_ODF_ODT_Format::ParagraphNumber.new(@make,dob.ocn)
744
+ end
745
+ if dob.is ==:heading \
746
+ || dob.is ==:para \
747
+ || dob.is ==:group \
748
+ || dob.is ==:verse \
749
+ || dob.is ==:code \
750
+ || dob.is ==:table \
751
+ || dob.is ==:break
752
+ odf_structure(@md,dob)
753
+ end
754
+ if dob.obj ## Clean Prepared Text
755
+ dob.obj=dob.obj.gsub(/<!.+!>/,' ').
756
+ gsub(/#{Mx[:tc_o]}.+?#{Mx[:tc_c]}/,' ').
757
+ gsub(/<:\S+>/,' ')
758
+ end
759
+ end
760
+ end
761
+ end
762
+ def pre
763
+ table=if @md.flag_tables
764
+ x=<<WOK
765
+ <style:style style:name="Table1" style:family="table"><style:table-properties style:width="16.999cm" table:align="margins"/></style:style>
766
+ <style:style style:name="Table1.A" style:family="table-column"><style:table-column-properties style:column-width="16.999cm" style:rel-column-width="65535*"/></style:style>
767
+ <style:style style:name="Table1.B" style:family="table-column"><style:table-column-properties style:column-width="8.499cm" style:rel-column-width="32767*"/></style:style>
768
+ <style:style style:name="Table1.C" style:family="table-column"><style:table-column-properties style:column-width="5.666cm" style:rel-column-width="21845*"/></style:style>
769
+ <style:style style:name="Table1.D" style:family="table-column"><style:table-column-properties style:column-width="4.349cm" style:rel-column-width="16383*"/></style:style>
770
+ <style:style style:name="Table1.E" style:family="table-column"><style:table-column-properties style:column-width="3.399cm" style:rel-column-width="13107*"/></style:style>
771
+ <style:style style:name="Table1.F" style:family="table-column"><style:table-column-properties style:column-width="2.833cm" style:rel-column-width="10922*"/></style:style>
772
+ <style:style style:name="Table1.G" style:family="table-column"><style:table-column-properties style:column-width="2.428cm" style:rel-column-width="9362*"/></style:style>
773
+ <style:style style:name="Table1.H" style:family="table-column"><style:table-column-properties style:column-width="2.124cm" style:rel-column-width="8191*"/></style:style>
774
+ <style:style style:name="Table2" style:family="table"><style:table-properties style:width="16.999cm" table:align="margins"/></style:style>
775
+ <style:style style:name="Table2.A" style:family="table-column"><style:table-column-properties style:column-width="16.999cm" style:rel-column-width="65535*"/></style:style>
776
+ <style:style style:name="Table2.B" style:family="table-column"><style:table-column-properties style:column-width="8.499cm" style:rel-column-width="32767*"/></style:style>
777
+ <style:style style:name="Table2.C" style:family="table-column"><style:table-column-properties style:column-width="5.666cm" style:rel-column-width="21845*"/></style:style>
778
+ <style:style style:name="Table2.D" style:family="table-column"><style:table-column-properties style:column-width="4.349cm" style:rel-column-width="16383*"/></style:style>
779
+ <style:style style:name="Table2.E" style:family="table-column"><style:table-column-properties style:column-width="3.999cm" style:rel-column-width="13107*"/></style:style>
780
+ <style:style style:name="Table2.F" style:family="table-column"><style:table-column-properties style:column-width="2.833cm" style:rel-column-width="10922*"/></style:style>
781
+ <style:style style:name="Table2.G" style:family="table-column"><style:table-column-properties style:column-width="2.428cm" style:rel-column-width="9362*"/></style:style>
782
+ <style:style style:name="Table2.H" style:family="table-column"><style:table-column-properties style:column-width="2.124cm" style:rel-column-width="8191*"/></style:style>
783
+ <style:style style:name="Table2.I" style:family="table-column"><style:table-column-properties style:column-width="1.8887cm" style:rel-column-width="7281*"/></style:style>
784
+ <style:style style:name="Table2.J" style:family="table-column"><style:table-column-properties style:column-width="1.6999cm" style:rel-column-width="6553*"/></style:style>
785
+ <style:style style:name="Table2.K" style:family="table-column"><style:table-column-properties style:column-width="1.5453cm" style:rel-column-width="5957*"/></style:style>
786
+ <style:style style:name="Table2.L" style:family="table-column"><style:table-column-properties style:column-width="1.416cm" style:rel-column-width="5461*"/></style:style>
787
+ <style:style style:name="Table2.M" style:family="table-column"><style:table-column-properties style:column-width="1.307" style:rel-column-width="5041*"/></style:style>
788
+ <style:style style:name="Table2.N" style:family="table-column"><style:table-column-properties style:column-width="1.214cm" style:rel-column-width="4681*"/></style:style>
789
+ WOK
790
+ x=x.strip
791
+ x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on
792
+ x
793
+ else ''
794
+ end
795
+ x=<<WOK
796
+ <?xml version="1.0" encoding="UTF-8"?>
797
+ <office:document-content xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:xl="http://www.w3.org/1999/xlink" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:ooow="http://openoffice.org/2004/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:rpt="http://openoffice.org/2005/report" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:css3t="http://www.w3.org/TR/css3-text/" office:version="1.2"><office:scripts/>
798
+ <office:font-face-decls><style:font-face style:name="DejaVu Sans Mono" svg:font-family="'DejaVu Sans Mono'" style:font-adornments="Book" style:font-family-generic="modern" style:font-pitch="fixed"/><style:font-face style:name="Inconsolata" svg:font-family="Inconsolata" style:font-adornments="Regular" style:font-pitch="fixed"/><style:font-face style:name="Liberation Mono" svg:font-family="'Liberation Mono'" style:font-adornments="Regular" style:font-family-generic="modern" style:font-pitch="fixed"/><style:font-face style:name="DejaVu Sans" svg:font-family="'DejaVu Sans'" style:font-adornments="ExtraLight" style:font-family-generic="swiss" style:font-pitch="variable"/><style:font-face style:name="Nimbus Sans L" svg:font-family="&apos;Nimbus Sans L&apos;" style:font-pitch="variable"/><style:font-face style:name="Tahoma" svg:font-family="Tahoma, Lucidasans, &apos;Lucida Sans&apos;, &apos;Arial Unicode MS&apos;" style:font-pitch="variable"/><style:font-face style:name="Nimbus Roman No9 L" svg:font-family="&apos;Nimbus Roman No9 L&apos;" style:font-family-generic="roman" style:font-pitch="variable"/><style:font-face style:name="Bitstream Vera Sans" svg:font-family="&apos;Bitstream Vera Sans&apos;" style:font-family-generic="swiss" style:font-pitch="variable"/></office:font-face-decls>
799
+ <office:automatic-styles>
800
+ #{table}
801
+ <style:style style:name="P_table_cell" style:family="paragraph" style:parent-style-name="Table_Contents"><style:paragraph-properties fo:text-align="justify" style:justify-single-word="false"/></style:style>
802
+ </office:automatic-styles>
803
+ <office:body>
804
+ <office:text text:use-soft-page-breaks="true">
805
+ <office:forms form:automatic-focus="false" form:apply-design-mode="false"/>
806
+ <text:sequence-decls><text:sequence-decl text:display-outline-level="0" text:name="Illustration"/><text:sequence-decl text:display-outline-level="0" text:name="Table"/><text:sequence-decl text:display-outline-level="0" text:name="Text"/><text:sequence-decl text:display-outline-level="0" text:name="Drawing"/></text:sequence-decls>
807
+ WOK
808
+ x=x.strip
809
+ x=x.gsub(/\n+/m,'') unless @md.opt.act[:maintenance][:set]==:on
810
+ @per.head << x
811
+ end
812
+ def publish
813
+ content=[]
814
+ br_pg='<text:p text:style-name="P_normal_page_new"> </text:p>'
815
+ content <<
816
+ @per.head <<
817
+ @per.toc <<
818
+ br_pg <<
819
+ @per.body <<
820
+ @per.book_idx <<
821
+ br_pg <<
822
+ @per.metadata <<
823
+ @per.tail
824
+ SiSU_XML_ODF_ODT::Source::Output.new(content,@md,@env).odf
825
+ @@odf={ head: [], toc: [], body: [], tail: [], book_idx: [], metadata: [] }
826
+ end
827
+ end
828
+ class Output <Source
829
+ def initialize(content,md,env)
830
+ @content,@md,@env=content,md,env
831
+ end
832
+ def odf #%odf output
833
+ env=SiSU_Env::FileOp.new(@md)
834
+ env.mkdir
835
+ header=SiSU_XML_ODF_ODT_Format::ODT_Head_1_2.new(@md)
836
+ filename="#{@env.processing_path.odt}/manifest.rdf"
837
+ od=File.new(filename,'w+')
838
+ od << header.manifest_rdf
839
+ od.close
840
+ filename="#{@env.processing_path.odt}/META-INF/manifest.xml"
841
+ od=File.new(filename,'w+')
842
+ od << header.meta_inf_manifest_xml(@md)
843
+ od.close
844
+ filename="#{@env.processing_path.odt}/meta.xml"
845
+ od=File.new(filename,'w+')
846
+ od << header.meta_xml
847
+ od.close
848
+ filename="#{@env.processing_path.odt}/settings.xml"
849
+ od=File.new(filename,'w+')
850
+ od << header.settings_xml
851
+ od.close
852
+ filename="#{@env.processing_path.odt}/styles.xml"
853
+ od=File.new(filename,'w+')
854
+ od << header.styles_xml
855
+ od.close
856
+ filename="#{@env.processing_path.odt}/mimetype"
857
+ od=File.new(filename,'w+')
858
+ od << header.mimetype
859
+ od.close
860
+ env.make_path(@env.processing_path.odt)
861
+ env.make_path(@md.file.output_path.odt.dir)
862
+ filename="#{@env.processing_path.odt}/content.xml"
863
+ od=File.new(filename,'w+')
864
+ @content.compact.each do |para| # this is a hack
865
+ od.puts para unless para =~/\A\s*\Z/
866
+ end
867
+ od.close
868
+ opendoc=@md.file.base_filename.odt #watch where output by language
869
+ FileUtils::mkdir_p(@md.file.output_path.odt.dir) \
870
+ unless FileTest.directory?(@md.file.output_path.odt.dir)
871
+ if FileTest.directory?(@env.processing_path.odt) \
872
+ and SiSU_Env::SystemCall.new.zip
873
+ pwd=Dir.pwd
874
+ Dir.chdir(@env.processing_path.odt)
875
+ system("
876
+ zip -qr #{opendoc} *
877
+ ")
878
+ FileUtils::mv(opendoc, @md.file.place_file.odt.dir)
879
+ Dir.chdir(pwd)
880
+ else
881
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).mark('*EXITED odf* zip program not found') unless SiSU_Env::SystemCall.new.zip
882
+ end
883
+ end
884
+ end
885
+ end
886
+ end
887
+ __END__