sisu 7.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,234 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** particulars, composite information about document being processed
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/se_hub_particulars.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_Particulars
58
+ begin
59
+ require 'singleton'
60
+ rescue LoadError
61
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
62
+ error('singleton NOT FOUND (LoadError)')
63
+ end
64
+ require_relative 'se' # se.rb
65
+ include SiSU_Env
66
+ require_relative 'dp' # dp.rb
67
+ include SiSU_Param
68
+ require_relative 'ao' # ao.rb
69
+ class CombinedSingleton
70
+ include Singleton
71
+ def get_all(opt)
72
+ set_env(opt)
73
+ set_file(opt)
74
+ set_md(opt)
75
+ set_ao(opt) #needs @md
76
+ end
77
+ def get_env(opt)
78
+ set_env(opt)
79
+ end
80
+ def get_file(opt)
81
+ set_file(opt)
82
+ end
83
+ def get_md(opt)
84
+ set_md(opt)
85
+ end
86
+ def get_ao_array(opt)
87
+ set_ao(opt) #needs @md
88
+ end
89
+ def get_env_md(opt)
90
+ set_env(opt)
91
+ set_md(opt)
92
+ end
93
+ def get_idx_sst(opt)
94
+ set_sst_idx(opt)
95
+ end
96
+ def get_idx_raw(opt)
97
+ set_raw_idx(opt)
98
+ end
99
+ def get_idx_html(opt)
100
+ set_html_idx(opt)
101
+ end
102
+ def get_idx_xhtml(opt)
103
+ set_xhtml_idx(opt)
104
+ end
105
+ def get_name_tags(opt)
106
+ set_name_tags(opt)
107
+ end
108
+ def get_maps(opt)
109
+ set_nametags_map(opt)
110
+ set_ocn_htmlseg_map(opt)
111
+ end
112
+ def get_map_nametags(opt)
113
+ set_nametags_map(opt)
114
+ end
115
+ def get_map_ocn_htmlseg(opt)
116
+ set_ocn_htmlseg_map(opt)
117
+ end
118
+ attr_accessor :opt,:md,:sst_idx,:raw_idx,:html_idx,:xhtml_idx
119
+ def set_md(opt)
120
+ begin
121
+ @md=SiSU_Param::Parameters.new(opt).get
122
+ self
123
+ rescue
124
+ SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do
125
+ __LINE__.to_s + ':' + __FILE__
126
+ end
127
+ end
128
+ end
129
+ attr_accessor :opt,:env,:file
130
+ def set_env(opt)
131
+ begin
132
+ @env=SiSU_Env::InfoEnv.new(opt.fns)
133
+ self
134
+ rescue
135
+ SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do
136
+ __LINE__.to_s + ':' + __FILE__
137
+ end
138
+ end
139
+ end
140
+ def set_file(opt)
141
+ begin
142
+ set_md(opt) unless @md
143
+ @file=SiSU_Env::FileOp.new(@md)
144
+ self
145
+ rescue
146
+ SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do
147
+ __LINE__.to_s + ':' + __FILE__
148
+ end
149
+ end
150
+ end
151
+ attr_accessor :opt,:ao_array
152
+ def set_ao(opt)
153
+ begin
154
+ @ao_array=SiSU_AO::Source.new(opt).get
155
+ self
156
+ rescue
157
+ SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do
158
+ __LINE__.to_s + ':' + __FILE__
159
+ end
160
+ end
161
+ end
162
+ def set_sst_idx(opt)
163
+ begin
164
+ @sst_idx=SiSU_AO::Source.new(opt).get_idx_sst
165
+ self
166
+ rescue
167
+ SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do
168
+ __LINE__.to_s + ':' + __FILE__
169
+ end
170
+ end
171
+ end
172
+ def set_raw_idx(opt)
173
+ begin
174
+ @raw_idx=SiSU_AO::Source.new(opt).get_idx_raw
175
+ self
176
+ rescue
177
+ SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do
178
+ __LINE__.to_s + ':' + __FILE__
179
+ end
180
+ end
181
+ end
182
+ def set_html_idx(opt)
183
+ begin
184
+ @html_idx=SiSU_AO::Source.new(opt).get_idx_html
185
+ self
186
+ rescue
187
+ SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do
188
+ __LINE__.to_s + ':' + __FILE__
189
+ end
190
+ end
191
+ end
192
+ def set_xhtml_idx(opt)
193
+ begin
194
+ @xhtml_idx=SiSU_AO::Source.new(opt).get_idx_xhtml
195
+ self
196
+ rescue
197
+ SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do
198
+ __LINE__.to_s + ':' + __FILE__
199
+ end
200
+ end
201
+ end
202
+ attr_accessor :nametags_map
203
+ def set_nametags_map(opt)
204
+ begin
205
+ opt=@md ? @md : opt
206
+ @nametags_map=SiSU_AO::Source.new(opt).get_map_nametags
207
+ self
208
+ rescue
209
+ if @md
210
+ SiSU_Errors::Rescued.new($!,$@,@md.opt.selections.str,@md.opt.fnl).location do
211
+ __LINE__.to_s + ':' + __FILE__
212
+ end
213
+ else
214
+ SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do
215
+ __LINE__.to_s + ':' + __FILE__
216
+ end
217
+ end
218
+ end
219
+ end
220
+ attr_accessor :ocn_htmlseg_map
221
+ def set_ocn_htmlseg_map(opt)
222
+ begin
223
+ @ocn_htmlseg_map=SiSU_AO::Source.new(@md).get_map_ocn_htmlseg
224
+ self
225
+ rescue
226
+ SiSU_Errors::Rescued.new($!,$@,opt.selections.str,opt.fnl).location do
227
+ __LINE__.to_s + ':' + __FILE__
228
+ end
229
+ end
230
+ end
231
+ end
232
+ end
233
+ __END__
234
+ consider running as separate objects
@@ -0,0 +1,2179 @@
1
+ # encoding: utf-8
2
+ =begin
3
+
4
+ * Name: SiSU
5
+
6
+ ** Description: documents, structuring, processing, publishing, search
7
+ *** system environment, resource control and configuration details
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/se_info_env.rb;hb=HEAD>
55
+
56
+ =end
57
+ @@current_document=Dir.pwd #nil #''
58
+ module SiSU_Info_Env
59
+ require_relative 'se_envcall' # se_envcall.rb
60
+ require_relative 'html_parts' # html_parts.rb
61
+ begin
62
+ require 'singleton'
63
+ require 'fileutils'
64
+ include FileUtils::Verbose
65
+ rescue LoadError
66
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
67
+ error('singleton or fileutils NOT FOUND (LoadError)')
68
+ end
69
+ class InfoEnv < SiSU_Env_Call::EnvCall # se_envcall.rb
70
+ begin
71
+ require 'pathname'
72
+ require 'fileutils'
73
+ include FileUtils
74
+ rescue LoadError
75
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
76
+ error('pathname or fileutils NOT FOUND (LoadError)')
77
+ end
78
+ attr_accessor :filename,:sys,:home,:hostname,:user,:env,:rc,:www,:fnb,:fnn,:fnt,:flv,:webserv_path,:stub_pwd,:base_markup_dir_stub,:stub_src,:webserv_host_cgi,:webserv_port_cgi,:processing,:processing_git,:etc,:yamlrc_dir
79
+ @@image_flag,@@local_image=true,true #warning on @@image_flag
80
+ @@fb,@@man_path=nil,nil
81
+ def initialize(fns='',md=nil)
82
+ super() #you may not want to re-execute this static info so frequently!
83
+ @init=SiSU_Env::GetInit.new #SiSU_Get_Init::GetInit
84
+ @fns,@md=fns,md
85
+ @env=SiSU_Env::EnvCall.new(fns) if fns #SiSU_Env_Call::EnvCall
86
+ fnb=if @md \
87
+ and defined? @md.fnb
88
+ @md.fnb
89
+ elsif defined? @env.fnb \
90
+ and @env.fnb
91
+ @env.fnb
92
+ elsif @fns.is_a?(String) \
93
+ and not @fns.empty?
94
+ m=/(.+)?\.(?:(?:-|ssm\.)?sst|ssm)$/m
95
+ @fns[m,1] if not @fns.empty?
96
+ end
97
+ if fnb; @@fb ||=fnb
98
+ end
99
+ @sys=SiSU_Info_Sys::InfoSystem.instance
100
+ @fnb ||=@@fb #clean up this... used primarily for zap which is not passed normal parameters
101
+ @fixed_websev_root='' # @home
102
+ @pwd=@@pwd=Dir.pwd
103
+ @base_markup_dir_stub=SiSU_Utils::Path.new.base_markup_stub
104
+ @stub_src= @base_markup_dir_stub + '/src'
105
+ @stub_pod= @base_markup_dir_stub + '/pod'
106
+ @stub_epub= @base_markup_dir_stub + '/epub'
107
+ m=/.+\/(?:src\/)?(\S+)/m # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m
108
+ @stub_pwd=@@pwd[m,1] || '' #; p __LINE__; #p @pwd; #p m; #p @stub_pwd
109
+ pt=Pathname.new(Dir.pwd)
110
+ stub=if output_dir_structure.by_language_code?
111
+ r=Px[:lng_lst_rgx]
112
+ stub=if Dir.pwd =~/.+?\/([^\/]+)(?:\/(#{r})$)/
113
+ lng=pt.split[-1].to_s
114
+ lng_part='/' + lng
115
+ base=pt.split[0].split[-1].to_s
116
+ else
117
+ lng_part='/' + language_default_set
118
+ base=pt.split[-1].to_s
119
+ end
120
+ base + lng_part
121
+ elsif output_dir_structure.by_filetype?
122
+ pt.split[-1].to_s
123
+ elsif output_dir_structure.by_filename?
124
+ ''
125
+ else
126
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
127
+ warn('set output type, by: language, filetype or filename')
128
+ end
129
+ @stub_set_manifest=stub + '/manifest'
130
+ end
131
+ def user
132
+ @sys.user
133
+ end
134
+ def hostname
135
+ @sys.hostname
136
+ end
137
+ def host
138
+ @sys.host
139
+ end
140
+ def arch
141
+ @sys.arch
142
+ end
143
+ def rbver
144
+ @sys.rbver
145
+ end
146
+ def locale
147
+ @sys.locale
148
+ end
149
+ def concord_max
150
+ ((defined? @rc['processing']['concord_max']) \
151
+ && @rc['processing']['concord_max']) \
152
+ ? @rc['processing']['concord_max']
153
+ : (defaults[:concord_max])
154
+ end
155
+ def language_default_set #set directory (default) language
156
+ ((defined? @rc['default']['language']) \
157
+ && @rc['default']['language'] =~/\S+/) \
158
+ ? @rc['default']['language']
159
+ : 'en'
160
+ end
161
+ def markup_emphasis
162
+ if defined? @rc['default']['emphasis'] \
163
+ and @rc['default']['emphasis'] \
164
+ and @rc['default']['emphasis']=~/bold/
165
+ 'bold'
166
+ elsif defined? @rc['default']['emphasis'] \
167
+ and @rc['default']['emphasis'] \
168
+ and @rc['default']['emphasis']=~/italic/
169
+ 'italics'
170
+ elsif defined? @rc['default']['emphasis'] \
171
+ and @rc['default']['emphasis'] \
172
+ and @rc['default']['emphasis']=~/underscore/
173
+ 'underscore'
174
+ else 'bold'
175
+ end
176
+ end
177
+ def plaintext_wrap
178
+ ((defined? @rc['default']['text_wrap']) \
179
+ && (@rc['default']['text_wrap']) \
180
+ && (@rc['default']['text_wrap'].to_s=~/\d\d+/) \
181
+ && (@rc['default']['text_wrap'].to_i > 19) \
182
+ && (@rc['default']['text_wrap'].to_i < 201)) \
183
+ ? @rc['default']['text_wrap'].to_i
184
+ : 78
185
+ end
186
+ def current_document
187
+ @@current_document||=Dir.pwd
188
+ @@current_document
189
+ end
190
+ def stub_pwd #200412
191
+ @stub_pwd
192
+ end
193
+ def base_markup_dir_stub
194
+ @base_markup_dir_stub
195
+ end
196
+ def stub_md_harvest #watch
197
+ @stub_set_manifest
198
+ end
199
+ def stub_src
200
+ @stub_src
201
+ end
202
+ def stub_pod
203
+ @stub_pod
204
+ end
205
+ def sisupod_v4(opt)
206
+ #processing_path.processing
207
+ # sisupod
208
+ # doc/
209
+ # manifest.txt
210
+ # en/content.sst [file content]
211
+ # fr/content.sst
212
+ # _sisu
213
+ # sisu_document_make
214
+ # image@ (ln -s ../../image)
215
+ # audio@ (ln -s ../../audio)
216
+ # video@ (ln -s ../../video)
217
+ # image/ [all images for specific document gathered here]
218
+ # audio/
219
+ # video/
220
+ spp="#{processing_path.processing}/#{Gt[:sisupod]}"
221
+ sppc="#{spp}/doc/_sisu"
222
+ lng_dirs=[]
223
+ if FileTest.directory?(spp) \
224
+ or FileTest.file?(spp)
225
+ FileUtils::rm_rf(spp)
226
+ end
227
+ paths=[]
228
+ flv=SiSU_Env::EnvCall.new(opt.fns).
229
+ document_language_versions_found
230
+ flv[:f].each {|l| lng_dirs << l[:l] }
231
+ lng_dirs.uniq.each do |lng|
232
+ paths << "#{spp}/doc/#{lng}"
233
+ end
234
+ paths \
235
+ << "#{spp}/image"
236
+ #<< "#{spp}/audio" \
237
+ #<< "#{spp}/video" \
238
+ paths.each do |x|
239
+ unless FileTest.directory?(x)
240
+ FileUtils::mkdir_p(x)
241
+ end
242
+ end
243
+ if FileTest.directory?(sppc)
244
+ pwd=Dir.pwd
245
+ Dir.chdir(sppc)
246
+ FileUtils::ln_s('../../image', 'image')
247
+ #FileUtils::ln_s('../../audio', 'audio')
248
+ #FileUtils::ln_s('../../video', 'video')
249
+ Dir.chdir(pwd)
250
+ end
251
+ end
252
+ def sisupod_v3(opt)
253
+ #processing_path.processing
254
+ # sisupod
255
+ # doc/
256
+ # manifest.txt
257
+ # en/content.sst [file content]
258
+ # fr/content.sst
259
+ # _sisu
260
+ # skin/
261
+ # doc [relevant skin if any other than default]
262
+ # image@ (ln -s ../../image)
263
+ # audio@ (ln -s ../../audio)
264
+ # video@ (ln -s ../../video)
265
+ # image/ [all images for specific document gathered here]
266
+ # audio/
267
+ # video/
268
+ spp="#{processing_path.processing}/#{Gt[:sisupod]}"
269
+ sppc="#{spp}/doc/_sisu"
270
+ lng_dirs=[]
271
+ if FileTest.directory?(spp) \
272
+ or FileTest.file?(spp)
273
+ FileUtils::rm_rf(spp)
274
+ end
275
+ paths=[]
276
+ flv=SiSU_Env::EnvCall.new(opt.fns).
277
+ document_language_versions_found
278
+ flv[:f].each {|l| lng_dirs << l[:l] }
279
+ lng_dirs.uniq.each do |lng|
280
+ paths << "#{spp}/doc/#{lng}"
281
+ end
282
+ paths \
283
+ << "#{spp}/image" \
284
+ << "#{sppc}/skin/doc" \
285
+ << "#{sppc}/skin/dir" \
286
+ << "#{sppc}/skin/site"
287
+ #<< "#{spp}/audio" \
288
+ #<< "#{spp}/video" \
289
+ paths.each do |x|
290
+ unless FileTest.directory?(x)
291
+ FileUtils::mkdir_p(x)
292
+ end
293
+ end
294
+ if FileTest.directory?(sppc)
295
+ pwd=Dir.pwd
296
+ Dir.chdir(sppc)
297
+ FileUtils::ln_s('../../image', 'image')
298
+ #FileUtils::ln_s('../../audio', 'audio')
299
+ #FileUtils::ln_s('../../video', 'video')
300
+ Dir.chdir(pwd)
301
+ end
302
+ end
303
+ def sisupod_v2
304
+ #processing_path.processing
305
+ # sisupod
306
+ # content.sst [file content]
307
+ # filename.sst [link to content.sst]
308
+ # _sisu
309
+ # skin/
310
+ # doc [relevant skin if any other than default]
311
+ # image [all images for specific document gathered here]
312
+ sisupod_processing_path="#{processing_path.processing}/#{Gt[:sisupod]}"
313
+ if FileTest.directory?(sisupod_processing_path) \
314
+ or FileTest.file?(sisupod_processing_path)
315
+ FileUtils::rm_rf(sisupod_processing_path)
316
+ end
317
+ paths=[]
318
+ paths=[
319
+ "#{processing_path.processing}/#{Gt[:sisupod]}/_sisu/skin/doc",
320
+ "#{processing_path.processing}/#{Gt[:sisupod]}/_sisu/skin/dir",
321
+ "#{processing_path.processing}/#{Gt[:sisupod]}/_sisu/skin/site",
322
+ "#{processing_path.processing}/#{Gt[:sisupod]}/_sisu/image"
323
+ ]
324
+ paths.each {|x| FileUtils::mkdir_p(x) unless FileTest.directory?(x) }
325
+ end
326
+ def defaults #multiple default directories
327
+ @default_dir ||=@sys.default_dir #DEFAULT_DIR
328
+ end
329
+ def html_seg_title_banner?
330
+ ((defined? @rc['html']['seg_title_banner']) \
331
+ && @rc['html']['seg_title_banner']==true) \
332
+ ? @rc['html']['seg_title_banner']
333
+ : false
334
+ end
335
+ def html_quick_ref?
336
+ ((defined? @rc['html']['quick_ref']) \
337
+ && @rc['html']['quick_ref']==true) \
338
+ ? @rc['html']['quick_ref']
339
+ : false
340
+ end
341
+ def html_minitoc?
342
+ if defined? @rc['html']['minitoc'] \
343
+ and @rc['html']['minitoc'].is_a?(String)
344
+ @rc['html']['minitoc']
345
+ else false
346
+ end
347
+ end
348
+ def manifest_minitoc?
349
+ if defined? @rc['manifest']['minitoc'] \
350
+ and @rc['manifest']['minitoc'].is_a?(String)
351
+ @rc['manifest']['minitoc']
352
+ else false
353
+ end
354
+ end
355
+ def build
356
+ def omit_list
357
+ @off_list ||=if defined? @rc['omit_list'] \
358
+ and @rc['omit_list'].is_a?(String)
359
+ @rc['omit_list']
360
+ elsif defined? @rc['omit']['list'] \
361
+ and @rc['omit']['list'].is_a?(String)
362
+ @rc['omit']['list']
363
+ else
364
+ nil
365
+ end
366
+ end
367
+ def listed?(test) #fix
368
+ listed=if omit_list
369
+ x=(omit_list.scan(/\b#{test}\b/)).join
370
+ test==x \
371
+ ? true
372
+ : false
373
+ else
374
+ false
375
+ end
376
+ listed
377
+ end
378
+ def ocn?
379
+ if (defined? @rc['omit']['ocn'] \
380
+ and not @rc['omit']['ocn'].nil?) \
381
+ or listed?('ocn')
382
+ :off
383
+ else
384
+ :na
385
+ end
386
+ end
387
+ def toc?
388
+ if (defined? @rc['omit']['toc'] \
389
+ and not @rc['omit']['toc'].nil?) \
390
+ or listed?('toc')
391
+ :off
392
+ else
393
+ :na
394
+ end
395
+ end
396
+ def manifest?
397
+ if (defined? @rc['omit']['manifest'] \
398
+ and not @rc['omit']['manifest'].nil?) \
399
+ or listed?('manifest')
400
+ :off
401
+ else
402
+ :na
403
+ end
404
+ end
405
+ def links_to_manifest?
406
+ if (defined? @rc['omit']['links_to_manifest'] \
407
+ and not @rc['omit']['links_to_manifest'].nil?) \
408
+ or (listed?('links_to_manifest') \
409
+ || listed?('manifest_links'))
410
+ :off
411
+ else
412
+ :na
413
+ end
414
+ end
415
+ def metadata?
416
+ if (defined? @rc['omit']['metadata'] \
417
+ and not @rc['omit']['metadata'].nil?) \
418
+ or listed?('metadata')
419
+ :off
420
+ else
421
+ :na
422
+ end
423
+ end
424
+ def minitoc?
425
+ if (defined? @rc['omit']['minitoc'] \
426
+ and not @rc['omit']['minitoc'].nil?) \
427
+ or (listed?('minitoc'))
428
+ :off
429
+ else
430
+ :na
431
+ end
432
+ end
433
+ def manifest_minitoc?
434
+ if (defined? @rc['omit']['manifest_minitoc'] \
435
+ and not @rc['omit']['manifest_minitoc'].nil?) \
436
+ or listed?('manifest_minitoc')
437
+ :off
438
+ else
439
+ :na
440
+ end
441
+ end
442
+ def html_minitoc?
443
+ if (defined? @rc['omit']['html_minitoc'] \
444
+ and not @rc['omit']['html_minitoc'].nil?) \
445
+ or (listed?('html_minitoc') \
446
+ || listed?('minitoc'))
447
+ :off
448
+ else
449
+ :na
450
+ end
451
+ end
452
+ def html_navigation?
453
+ if (defined? @rc['omit']['html_navigation'] \
454
+ and not @rc['omit']['html_navigation'].nil?) \
455
+ or listed?('html_navigation')
456
+ :off
457
+ else
458
+ :na
459
+ end
460
+ end
461
+ def html_navigation_bar?
462
+ if (defined? @rc['omit']['html_navigation_bar'] \
463
+ and not @rc['omit']['html_navigation_bar'].nil?) \
464
+ or listed?('html_navigation_bar')
465
+ :off
466
+ else
467
+ :na
468
+ end
469
+ end
470
+ def segsubtoc?
471
+ if (defined? @rc['omit']['segsubtoc'] \
472
+ and not @rc['omit']['segsubtoc'].nil?) \
473
+ or listed?('segsubtoc')
474
+ :off
475
+ else
476
+ :na
477
+ end
478
+ end
479
+ def html_right_pane?
480
+ if (defined? @rc['omit']['html_right_pane'] \
481
+ and not @rc['omit']['html_right_pane'].nil?) \
482
+ or listed?('html_right_pane')
483
+ :off
484
+ else
485
+ :na
486
+ end
487
+ end
488
+ def html_top_band?
489
+ if (defined? @rc['omit']['html_top_band'] \
490
+ and not @rc['omit']['html_top_band'].nil?) \
491
+ or listed?('html_top_band')
492
+ :off
493
+ else
494
+ :na
495
+ end
496
+ end
497
+ def search_form? #decide later, as is configured here (in sisurc) and can be turned off on command line
498
+ if (defined? @rc['omit']['search_form'] \
499
+ and not @rc['omit']['search_form'].nil?) \
500
+ or listed?('search_form')
501
+ :off
502
+ else
503
+ :na
504
+ end
505
+ end
506
+ def html_search_form? #decide later, as is configured here (in sisurc) and can be turned off on command line
507
+ if (defined? @rc['omit']['html_search_form'] \
508
+ and not @rc['omit']['html_search_form'].nil?) \
509
+ or listed?('html_search_form')
510
+ :off
511
+ else
512
+ :na
513
+ end
514
+ end
515
+ self
516
+ end
517
+ def odt_ocn?
518
+ ((defined? @rc['odt']['ocn']) \
519
+ && @rc['odt']['ocn']==false) \
520
+ ? @rc['odt']['ocn']
521
+ : true
522
+ end
523
+ def xml_docbook_ocn?
524
+ ((defined? @rc['xml_docbook']['ocn']) \
525
+ && @rc['xml_docbook']['ocn']==false) \
526
+ ? @rc['xml_docbook']['ocn']
527
+ : true
528
+ end
529
+ def xml_fictionbook_ocn?
530
+ ((defined? @rc['xml_fictionbook']['ocn']) \
531
+ && @rc['xml_fictionbook']['ocn']==false) \
532
+ ? @rc['xml_fictionbook']['ocn']
533
+ : true
534
+ end
535
+ def xml_scaffold_ocn?
536
+ ((defined? @rc['xml_scaffold']['ocn']) \
537
+ && @rc['xml_scaffold']['ocn']==false) \
538
+ ? @rc['xml_scaffold']['ocn']
539
+ : true
540
+ end
541
+ def plaintext_ocn?
542
+ ((defined? @rc['plaintext']['ocn']) \
543
+ && @rc['plaintext']['ocn']==false) \
544
+ ? @rc['plaintext']['ocn']
545
+ : true
546
+ end
547
+ def textile_ocn?
548
+ ((defined? @rc['textile']['ocn']) \
549
+ && @rc['textile']['ocn']==true) \
550
+ ? @rc['textile']['ocn']
551
+ : false
552
+ end
553
+ def asciidoc_ocn?
554
+ ((defined? @rc['asciidoc']['ocn']) \
555
+ && @rc['asciidoc']['ocn']==true) \
556
+ ? @rc['asciidoc']['ocn']
557
+ : false
558
+ end
559
+ def markdown_ocn?
560
+ ((defined? @rc['markdown']['ocn']) \
561
+ && @rc['markdown']['ocn']==true) \
562
+ ? @rc['markdown']['ocn']
563
+ : false
564
+ end
565
+ def rst_ocn?
566
+ ((defined? @rc['rst']['ocn']) \
567
+ && @rc['rst']['ocn']==true) \
568
+ ? @rc['rst']['ocn']
569
+ : false
570
+ end
571
+ def orgmode_ocn?
572
+ ((defined? @rc['orgmode']['ocn']) \
573
+ && @rc['orgmode']['ocn']==true) \
574
+ ? @rc['orgmode']['ocn']
575
+ : false
576
+ end
577
+ def widget #needs (md) #move
578
+ @rc=SiSU_Env::GetInit.new.sisu_yaml.rc
579
+ @ad=SiSU_Env::GetInit.new.ads
580
+ @html_bits=SiSU_Proj_HTML::Bits.new
581
+ @flag={
582
+ ad: false,
583
+ md: false,
584
+ sk: false,
585
+ rc: false
586
+ }
587
+ def promo?
588
+ @flag[:ad]=if @md.flag_promo \
589
+ && @ad[:flag_promo]
590
+ @flag[:md]=true
591
+ true
592
+ elsif defined? @html_bits.widget_promo \
593
+ and not @html_bits.widget_promo.nil? \
594
+ and @html_bits.widget_promo.is_a?(Array) \
595
+ and @html_bits.widget_promo.length > 0
596
+ @flag[:sk]=true
597
+ true
598
+ elsif defined? @rc['html']['promo'] \
599
+ and not @rc['html']['promo'].nil? \
600
+ and @rc['html']['promo'].length > 0
601
+ @flag[:rc]=true
602
+ true
603
+ else false
604
+ end
605
+ @flag
606
+ end
607
+ def search?
608
+ searches=['sisu']
609
+ flag=false
610
+ if defined? @rc['search']
611
+ searches.each do |type|
612
+ flag=if defined? @rc['search'][type] \
613
+ and defined? @rc['search'][type]['action'] \
614
+ and @rc['search'][type]['flag']==true \
615
+ and @rc['search'][type]['action'] =~/https?:\/\//
616
+ flag=if promo?[:ad]
617
+ false
618
+ elsif defined? @html_bits.widget_search \
619
+ and @html_bits.widget_search==true
620
+ true
621
+ elsif defined? @rc['search'][type]['flag'] \
622
+ and @rc['search'][type]['flag']==true
623
+ true
624
+ else false
625
+ end
626
+ else false
627
+ end
628
+ end
629
+ else false
630
+ end
631
+ flag
632
+ end
633
+ def search_fixed?
634
+ searches=['sisu','hyperestraier']
635
+ flag=if defined? @rc['search']
636
+ searches.each do |type|
637
+ if defined? @rc['search'][type] \
638
+ and defined? @rc['search'][type]['action'] \
639
+ and @rc['search'][type]['action'] =~/https?:\/\// \
640
+ and defined? @rc['search'][type]['db'] \
641
+ and @rc['search'][type]['db'] =~/\S+/
642
+ flag=if promo?[:ad]
643
+ false
644
+ elsif defined? @html_bits.widget_search \
645
+ and @html_bits.widget_search==true
646
+ true
647
+ elsif defined? @rc['search'][type]['flag'] \
648
+ and @rc['search'][type]['flag']==true
649
+ true
650
+ else false
651
+ end
652
+ else false
653
+ end
654
+ end
655
+ else false
656
+ end
657
+ end
658
+ def search_form(type='sisusearch',action=nil,db=nil,table=false)
659
+ rc=SiSU_Env::GetInit.new.sisu_yaml.rc
660
+ create_form_sisu=if action \
661
+ and db \
662
+ and action =~/https?:\/\// \
663
+ and db =~/\S+/
664
+ true
665
+ elsif widget.search?
666
+ db=if rc['search']['sisu']['flag']==true \
667
+ and rc['search']['sisu']['db']=~/\S+/
668
+ (rc['search']['sisu']['db']=~/^#{Db[:name_prefix]}\S+/) \
669
+ ? rc['search']['sisu']['db']
670
+ : "#{Db[:name_prefix]}#{rc['search']['sisu']['db']}"
671
+ else nil
672
+ end
673
+ action=rc['search']['sisu']['action']
674
+ true
675
+ elsif defined? rc['search']['sisu']['flag'] \
676
+ and defined? rc['search']['sisu']['action'] \
677
+ and rc['search']['sisu']['flag']==true \
678
+ and rc['search']['sisu']['action'] =~/https?:\/\//
679
+ true
680
+ else false
681
+ end
682
+ if table
683
+ table_open='<td align="center" bgcolor="#ffffff">'
684
+ table_close='</td>'
685
+ else
686
+ table_open=''
687
+ table_close='<br />'
688
+ end
689
+ form=if create_form_sisu \
690
+ and type=~/sisusearch/ \
691
+ and defined? rc['search']['sisu'] \
692
+ and defined? rc['search']['sisu']['action']
693
+ <<WOK
694
+ <!-- SiSU Search -->
695
+ #{table_open}
696
+ <a name="search"></a>
697
+ <form method="get" action="#{rc['search']['sisu']['action']}" target="_top">
698
+ <font size="2">
699
+ <input type="text" name="s1" size="24" maxlength="255" />
700
+ <input type="hidden" name="db" value="#{db}" />
701
+ <input type="hidden" name="ltd" value="1000" />
702
+ <input type="hidden" name="off" value="0" />
703
+ <input type="hidden" name="doc" value="#{@md.fnb}" /><br />
704
+ <input type="submit" name="search" value="search doc" />
705
+ <input type="submit" name="search" value="search db" />
706
+ </font></form>
707
+ #{table_close}
708
+ <!-- SiSU Search -->
709
+ WOK
710
+ else ''
711
+ end
712
+ form
713
+ end
714
+ def search_form_static(action=nil,db=nil)
715
+ rc=SiSU_Env::GetInit.new.sisu_yaml.rc
716
+ create_form=if rc['search']['sisu']['flag']==true \
717
+ and action \
718
+ and db \
719
+ and action =~/https?:\/\// \
720
+ and db =~/\S+/
721
+ true
722
+ elsif widget.search_fixed?
723
+ db=if rc['search']['sisu']['flag']==true \
724
+ and rc['search']['sisu']['db']=~/\S+/
725
+ (rc['search']['sisu']['db']=~/^#{Db[:name_prefix]}\S+/) \
726
+ ? rc['search']['sisu']['db']
727
+ : "#{Db[:name_prefix]}#{rc['search']['sisu']['db']}"
728
+ else nil
729
+ end
730
+ action=rc['search']['sisu']['action']
731
+ true
732
+ else false
733
+ end
734
+ if create_form
735
+ %{<td align="center" bgcolor="#ffffff">
736
+ <!-- SiSU Search -->
737
+ <a name="search"></a>
738
+ <form method="get" action="#{rc['search']['sisu']['action']}" target="_top">
739
+ <font size="2">
740
+ <input type="text" name="s1" size="24" maxlength="255" />
741
+ <br />
742
+ <input type="hidden" name="db" value="#{db}" />
743
+ <input type="hidden" name="ltd" value="1000" />
744
+ <input type="hidden" name="off" value="0" />
745
+ <input type="hidden" name="doc" value="#{@md.fnb}" />
746
+ <input type="submit" name="search" value="search doc" />
747
+ <input type="submit" name="search" value="search db" />
748
+ </font>
749
+ </form>
750
+ <!-- SiSU Search -->
751
+ </td> }
752
+ else ''
753
+ end
754
+ end
755
+ def search_action #check
756
+ if search?
757
+ else ''
758
+ end
759
+ end
760
+ self
761
+ end
762
+ def widget_static
763
+ @rc=SiSU_Env::GetInit.new.sisu_yaml.rc
764
+ @html_bits=SiSU_Proj_HTML::Bits.new
765
+ @flag={ ad: false, md: false, sk: false, rc: false }
766
+ def search?
767
+ flag=if defined? @rc['search'] \
768
+ and defined? @rc['search']['sisu'] \
769
+ and defined? @rc['search']['sisu']['action'] \
770
+ and @rc['search']['sisu']['action'] =~/https?:\/\// \
771
+ and defined? @rc['search']['sisu']['db'] \
772
+ and @rc['search']['sisu']['db'] =~/\S+/
773
+ flag=if defined? @html_bits.widget_search \
774
+ and @html_bits.widget_search==true
775
+ true
776
+ elsif defined? @rc['search']['sisu']['flag'] \
777
+ and @rc['search']['sisu']['flag']==true
778
+ true
779
+ else
780
+ false
781
+ end
782
+ else
783
+ false
784
+ end
785
+ end
786
+ def search_fixed?
787
+ flag=if defined? @rc['search'] \
788
+ and defined? @rc['search']['sisu'] \
789
+ and defined? @rc['search']['sisu']['action'] \
790
+ and @rc['search']['sisu']['action'] =~/https?:\/\// \
791
+ and defined? @rc['search']['sisu']['db'] \
792
+ and @rc['search']['sisu']['db'] =~/\S+/ \
793
+ and defined? @rc['search']['sisu']['db'] \
794
+ and @rc['search']['sisu']['db'] =~/\S+/
795
+ flag=if defined? @html_bits.widget_search \
796
+ and @html_bits.widget_search==true
797
+ true
798
+ elsif defined? @rc['search']['sisu']['flag'] \
799
+ and @rc['search']['sisu']['flag']==true
800
+ true
801
+ else
802
+ false
803
+ end
804
+ else
805
+ false
806
+ end
807
+ end
808
+ def search_form(action=nil,db=nil)
809
+ rc=SiSU_Env::GetInit.new.sisu_yaml.rc
810
+ create_form=if defined? rc['search']['sisu']['flag'] \
811
+ and rc['search']['sisu']['flag']==true \
812
+ and action \
813
+ and db \
814
+ and action =~/https?:\/\// \
815
+ and db =~/\S+/
816
+ true
817
+ elsif widget_static.search? \
818
+ and rc['search']['sisu']['flag']==true
819
+ db=if rc['search']['sisu']['db']=~/\S+/
820
+ (rc['search']['sisu']['db']=~/^#{Db[:name_prefix]}\S+/) \
821
+ ? rc['search']['sisu']['db']
822
+ : "#{Db[:name_prefix]}#{rc['search']['sisu']['db']}"
823
+ else nil
824
+ end
825
+ action=rc['search']['sisu']['action']
826
+ true
827
+ else false
828
+ end
829
+ if create_form \
830
+ and @fnb \
831
+ and @fnb=~/\S+/
832
+ %{<!-- SiSU Search -->
833
+ <a name="search"></a>
834
+ <form method="get" action="#{rc['search']['sisu']['action']}" target="_top">
835
+ <font size="2">
836
+ <input type="text" name="s1" size="24" maxlength="255" />
837
+ <br />
838
+ <input type="hidden" name="db" value="#{db}" />
839
+ <input type="hidden" name="doc" value="#{@fnb}" />
840
+ <input type="submit" name="search" value="search doc" />
841
+ <input type="submit" name="search" value="search db" />
842
+ </font>
843
+ </form>
844
+ <!-- SiSU Search --> }
845
+ elsif create_form
846
+ %{<!-- SiSU Search -->
847
+ <a name="search"></a>
848
+ <form method="get" action="#{rc['search']['sisu']['action']}" target="_top">
849
+ <font size="2">
850
+ <input type="text" name="s1" size="24" maxlength="255" />
851
+ <br />
852
+ <input type="hidden" name="db" value="#{db}" />
853
+ <input type="submit" name="search" value="search db" />
854
+ </font>
855
+ </form>
856
+ <!-- SiSU Search --> }
857
+ else ''
858
+ end
859
+ end
860
+ def search_action #check
861
+ if search?
862
+ else ''
863
+ end
864
+ end
865
+ self
866
+ end
867
+ def source_file_path
868
+ file=@fns.gsub(/\.ssm(?:\.sst)?/,'.ssm.sst')
869
+ unless file =~/\.ssm\.sst$/; "#{Dir.pwd}"
870
+ else "#{processing_path.composite_file}"
871
+ end
872
+ end
873
+ def source_file_with_path
874
+ file=@fns.gsub(/\.ssm(?:\.sst)?/,'.ssm.sst')
875
+ "#{source_file_path}/#{file}"
876
+ end
877
+ def texpdf_hyperlinks(cli)
878
+ @cli=cli
879
+ @hyplnks=if cli != :na
880
+ cli
881
+ elsif (defined? @rc['default']['pdf_hyperlinks']) \
882
+ && (@rc['default']['pdf_hyperlinks']=~/color/)
883
+ :color
884
+ elsif (defined? @rc['default']['pdf_hyperlinks']) \
885
+ && (@rc['default']['pdf_hyperlinks'] \
886
+ =~/(?:no-color|color-off|mono(?:chrome)?)/)
887
+ :mono
888
+ else :na
889
+ end
890
+ def landscape
891
+ if @cli != :na
892
+ @cli
893
+ elsif (defined? @rc['default']['pdf_hyperlinks_landscape']) \
894
+ && (@rc['default']['pdf_hyperlinks_landscape']=~/color/)
895
+ :color
896
+ elsif (defined? @rc['default']['pdf_hyperlinks_landscape']) \
897
+ && (@rc['default']['pdf_hyperlinks_landscape'] \
898
+ =~/(?:no-color|color-off|mono(?:chrome)?)/)
899
+ :mono
900
+ elsif @hyplnks != :na
901
+ @hyplnks
902
+ else :na
903
+ end
904
+ end
905
+ def portrait
906
+ if @cli != :na
907
+ @cli
908
+ elsif (defined? @rc['default']['pdf_hyperlinks_portrait']) \
909
+ && (@rc['default']['pdf_hyperlinks_portrait']=~/color/)
910
+ :color
911
+ elsif (defined? @rc['default']['pdf_hyperlinks_portrait']) \
912
+ && (@rc['default']['pdf_hyperlinks_portrait'] \
913
+ =~/(?:no-color|color-off|mono(?:chrome)?)/)
914
+ :mono
915
+ elsif @hyplnks != :na
916
+ @hyprlnks
917
+ else :na
918
+ end
919
+ end
920
+ self
921
+ end
922
+ def font
923
+ def size(pt=nil)
924
+ if pt && pt != :na
925
+ pt
926
+ elsif defined? @rc['default']['fontsize'] \
927
+ && @rc['default']['fontsize']=~/\d{1,2}/
928
+ @rc['default']['fontsize']
929
+ else :na
930
+ end
931
+ end
932
+ def texpdf
933
+ # you may wish to check selected font against available fonts:
934
+ # fc-list :outline -f "%{family}\n"
935
+ # fc-list :lang=ja
936
+ def main
937
+ (defined? @rc['default']['texpdf_fontface']) \
938
+ && (@rc['default']['texpdf_fontface']=~/\S{3,}/) \
939
+ ? @rc['default']['texpdf_fontface']
940
+ : 'Liberation Sans'
941
+ end
942
+ def sans # not used
943
+ (defined? @rc['default']['texpdf_fontface_sans']) \
944
+ && (@rc['default']['texpdf_fontface_sans']=~/\S{3,}/) \
945
+ ? @rc['default']['texpdf_fontface_sans']
946
+ : 'Liberation Sans'
947
+ end
948
+ def serif # not used
949
+ (defined? @rc['default']['texpdf_fontface_serif']) \
950
+ && (@rc['default']['texpdf_font_serif']=~/\S{3,}/) \
951
+ ? @rc['default']['texpdf_fontface_serif']
952
+ : 'Liberation Serif'
953
+ end
954
+ def mono
955
+ (defined? @rc['default']['texpdf_fontface_mono']) \
956
+ && (@rc['default']['texpdf_fontface_mono']=~/\S{3,}/) \
957
+ ? @rc['default']['texpdf_fontface_mono']
958
+ : 'Liberation Mono'
959
+ end
960
+ def cjk
961
+ (defined? @rc['default']['texpdf_fontface_cjk']) \
962
+ && (@rc['default']['texpdf_fontface_cjk']=~/\S{3,}/) \
963
+ ? @rc['default']['texpdf_fontface_cjk']
964
+ : 'IPAGothic' # 'IPAGothic' # 'IPAMincho' # 'TakaoMincho' # 'VL Gothic'
965
+ end
966
+ def cjk_zh
967
+ (defined? @rc['default']['texpdf_fontface_cjk_zh']) \
968
+ && (@rc['default']['texpdf_fontface_cjk_zh']=~/\S{3,}/) \
969
+ ? @rc['default']['texpdf_fontface_cjk_zh']
970
+ : 'IPAGothic'
971
+ end
972
+ def cjk_ja
973
+ (defined? @rc['default']['texpdf_fontface_cjk_ja']) \
974
+ && (@rc['default']['texpdf_fontface_cjk_ja']=~/\S{3,}/) \
975
+ ? @rc['default']['texpdf_fontface_cjk_ja']
976
+ : 'IPAGothic'
977
+ end
978
+ def cjk_ko
979
+ (defined? @rc['default']['texpdf_fontface_cjk_ko']) \
980
+ && (@rc['default']['texpdf_fontface_cjk_ko']=~/\S{3,}/) \
981
+ ? @rc['default']['texpdf_fontface_cjk_ko']
982
+ : 'IPAGothic'
983
+ end
984
+ def size(pt=nil)
985
+ if pt && pt != :na
986
+ pt
987
+ elsif (defined? @rc['default']['texpdf_fontsize']) \
988
+ && (@rc['default']['texpdf_fontsize']=~/\d{1,2}/)
989
+ @rc['default']['texpdf_fontsize']
990
+ elsif (defined? @rc['default']['fontsize']) \
991
+ && (@rc['default']['fontsize']=~/\d{1,2}/)
992
+ @rc['default']['fontsize']
993
+ else
994
+ :na
995
+ end
996
+ end
997
+ self
998
+ end
999
+ self
1000
+ end
1001
+ def path_rel_links
1002
+ def html_scroll_2
1003
+ if @env.output_dir_structure.by_language_code?
1004
+ '../../'
1005
+ elsif @env.output_dir_structure.by_filetype?
1006
+ '../'
1007
+ else
1008
+ '../'
1009
+ end
1010
+ end
1011
+ def html_seg_2
1012
+ if @env.output_dir_structure.by_language_code?
1013
+ '../../../'
1014
+ elsif @env.output_dir_structure.by_filetype?
1015
+ '../../'
1016
+ else
1017
+ '../'
1018
+ end
1019
+ end
1020
+ def html_scroll_1
1021
+ if @env.output_dir_structure.by_language_code?
1022
+ '../'
1023
+ elsif @env.output_dir_structure.by_filetype?
1024
+ '../'
1025
+ else
1026
+ './'
1027
+ end
1028
+ end
1029
+ def html_seg_1
1030
+ if @env.output_dir_structure.by_language_code?
1031
+ '../../'
1032
+ elsif @env.output_dir_structure.by_filetype?
1033
+ '../../'
1034
+ else
1035
+ './'
1036
+ end
1037
+ end
1038
+ self
1039
+ end
1040
+ def read_source_file_array(fns)
1041
+ (fns !~/\.ssm.sst$/) \
1042
+ ? (IO.readlines(fns, mode: 'r:utf-8', cr_newline: true))
1043
+ : (IO.readlines(
1044
+ "#{processing_path.composite_file}/#{fns}",
1045
+ mode: 'r:utf-8',
1046
+ cr_newline: true
1047
+ ))
1048
+ end
1049
+ def read_source_file(fns)
1050
+ read_source_file_array(fns)
1051
+ end
1052
+ def read_source_file_string(fns)
1053
+ (fns !~/\.ssm.sst$/) \
1054
+ ? (IO.read(fns, mode: 'r:utf-8', cr_newline: true))
1055
+ : (IO.read(
1056
+ "#{processing_path.composite_file}/#{fns}",
1057
+ mode: 'r:utf-8',
1058
+ cr_newline: true
1059
+ ))
1060
+ end
1061
+ def source_file_processing_array(fns)
1062
+ read_source_file_string(fns).split(/\s*\n\s*\n/m)
1063
+ end
1064
+ def path #dir
1065
+ def home
1066
+ @sys.home
1067
+ end
1068
+ def sisurc_path
1069
+ SiSU_Get_Init::GetInit.new.sisu_yaml.rc_path
1070
+ end
1071
+ def pwd
1072
+ @sys.pwd
1073
+ end
1074
+ def stub_pwd
1075
+ @stub_pwd
1076
+ end
1077
+ def base_markup_dir_stub
1078
+ @base_markup_dir_stub
1079
+ end
1080
+ def stub_epub
1081
+ @stub_epub
1082
+ end
1083
+ def stub_src
1084
+ @stub_src
1085
+ end
1086
+ def stub_pod
1087
+ @stub_pod
1088
+ end
1089
+ def etc
1090
+ defaults[:sisu_etc] #live/dynamic
1091
+ end
1092
+ def arch
1093
+ @sys.dir_arch
1094
+ end
1095
+ def sitearch
1096
+ @sys.dir_sitearch
1097
+ end
1098
+ def bin
1099
+ @sys.dir_bin
1100
+ end
1101
+ def share #shared data repository source directory
1102
+ #SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).
1103
+ # mark(defaults[:sisu_share])
1104
+ defaults[:sisu_share]
1105
+ end
1106
+ def style
1107
+ if @md \
1108
+ && ((@md.opt.opt_act[:dump][:bool] \
1109
+ && @md.opt.opt_act[:dump][:inst]) \
1110
+ || (@md.opt.opt_act[:redirect][:bool] \
1111
+ && @md.opt.opt_act[:redirect][:inst]))
1112
+ 'css'
1113
+ else
1114
+ defaults[:stylesheet_stub]
1115
+ end
1116
+ end
1117
+ def sample_data #sample data repository source directory
1118
+ defaults[:sample_data_path]
1119
+ end
1120
+ def rc
1121
+ @init.rc_path
1122
+ end
1123
+ def yamlrc
1124
+ GetInit.new.sisu_yaml.rc_path
1125
+ end
1126
+ def man #check use
1127
+ (defined? @rc['webserv']['man']) \
1128
+ ? "#{webserv}/#{@rc['webserv']['man']}"
1129
+ : defaults[:webserv_man]
1130
+ end
1131
+ def webserv_path #testing, check need, remove
1132
+ webserv
1133
+ end
1134
+ def webserv #separation required for webrick which cannot use path.output (different requirements as no file is passed)
1135
+ man_path=if @@man_path.nil?
1136
+ man_path=if defined? @rc['webserv']['path'] \
1137
+ and @rc['webserv']['path'] =~/\S\S+/
1138
+ pwd=Dir.pwd
1139
+ Dir.chdir(SiSU_Utils::Path.new.base_markup)
1140
+ man_path=@@man_path=File.expand_path(@rc['webserv']['path'])
1141
+ Dir.chdir(pwd)
1142
+ man_path
1143
+ else defaults[:webserv_path]
1144
+ end
1145
+ else @@man_path
1146
+ end
1147
+ man_path_head=man_path.gsub(/(\S+)\/[^\/\s]+$/,'\1')
1148
+ unless FileTest.directory?(man_path)
1149
+ FileUtils::mkdir_p(man_path) if File.writable?("#{man_path_head}/.")
1150
+ end
1151
+ @webserv_path=if defined? man_path \
1152
+ and File.writable?("#{man_path}/.")
1153
+ man_path #web server path as configured in rc file
1154
+ elsif FileTest.directory?(defaults[:webserv_path]) \
1155
+ and File.writable?("#{defaults[:webserv_path]}/.") #web server path default
1156
+ defaults[:webserv_path]
1157
+ else #create default directory under home and place output there
1158
+ unless FileTest.directory?(defaults[:output_local])
1159
+ FileUtils::mkdir_p(defaults[:output_local])
1160
+ end
1161
+ defaults[:output_local]
1162
+ end
1163
+ end
1164
+ def webserv_stub_ensure
1165
+ FileUtils::mkdir_p(path.webserv) unless FileTest.directory?(path.webserv)
1166
+ FileUtils::mkdir_p("#{path.webserv}/#{@base_markup_dir_stub}") \
1167
+ unless FileTest.directory?("#{path.webserv}/#{@base_markup_dir_stub}")
1168
+ end
1169
+ def webserv_map_pwd #dir
1170
+ "#{path.webserv}/#{base_markup_dir_stub}"
1171
+ end
1172
+ def webserv_dir #fixed/hard path to /www web/presentation directory, on Debian /var/www subdirectories are created within it, depending on markup directory stub-name (last segment of markup directory name)
1173
+ defaults[:webserv_dir]
1174
+ end
1175
+ def webserv_image #web/presentation directory, subdirectories are created within it, depending on markup directory stub-name (last segment of markup directory name)
1176
+ images=if defined? @rc['webserv']['images']
1177
+ @rc['webserv']['images']
1178
+ else defaults[:images]
1179
+ end
1180
+ "#{path.webserv}/#{images}"
1181
+ end
1182
+ def output #web/webserv output directory... subdirectory into which further subdirectories are made based on file names
1183
+ r=Px[:lng_lst_rgx]
1184
+ u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/
1185
+ base_stub=@sys.pwd.gsub(u,'\1')
1186
+ if Dir.pwd =~/\/#{Gt[:sisupod]}\/[^\/]+\/#{Gt[:pod]}\/#{Gt[:doc]}/
1187
+ "#{path.webserv}/#{Gt[:doc]}"
1188
+ else
1189
+ "#{path.webserv}/#{base_stub}"
1190
+ end
1191
+ end
1192
+ def feed
1193
+ (defined? @rc['webserv']['feed']) \
1194
+ ? ("#{public_output}/#{@rc['webserv']['feed']}")
1195
+ : (defaults[:webserv_feed])
1196
+ end
1197
+ def feed_home
1198
+ "#{public_output}/#{@rc['webserv']['feed_home']}"
1199
+ end
1200
+ def scripts #used previously only to include tla version info
1201
+ if defined? @rc['project']['path']
1202
+ "#{home}/#{@rc['project']['path']}"
1203
+ end
1204
+ end
1205
+ def cgi
1206
+ (defined? @rc['webserv']['cgi']) \
1207
+ ? "#{@rc['webserv']['cgi']}"
1208
+ : (defaults[:webserv_cgi])
1209
+ end
1210
+ def php
1211
+ (defined? @rc['webserv']['php']) \
1212
+ ? "#{public_output}/#{@rc['webserv']['php']}"
1213
+ : (defaults[:webserv_php])
1214
+ end
1215
+ #% programs
1216
+ def output_tell
1217
+ url.webserv_map_pwd
1218
+ end
1219
+ def image_source_sisu_includes(md=nil)
1220
+ if md \
1221
+ and (md.opt.sisu_install_type? == \
1222
+ :full_path_to_sisu_bin_in_sisu_dir_tree) \
1223
+ and FileTest.directory?(
1224
+ "#{md.opt.sisu_data_dir?}/image"
1225
+ )==true
1226
+ "#{md.opt.sisu_data_dir?}/image"
1227
+ else
1228
+ "#{share}/image"
1229
+ end
1230
+ end
1231
+ def image_source(md=nil) #image repository source directory
1232
+ if defined? @rc['image']['path'] \
1233
+ and defined? @rc['image']['public']
1234
+ pth="#{@rc['image']['path']}"
1235
+ "#{pth}/#{@rc['image']['public']}"
1236
+ else
1237
+ image_source_sisu_includes(md)
1238
+ end
1239
+ end
1240
+ def image_source_include(md=nil) #image repository source directory
1241
+ if defined? @rc['image']['path'] \
1242
+ and defined? @rc['image']['public'] \
1243
+ and FileTest.directory?(
1244
+ "#{@rc['image']['path']}/#{@rc['image']['public']}"
1245
+ )==true
1246
+ "#{@rc['image']['path']}/#{@rc['image']['public']}"
1247
+ elsif FileTest.directory?("#{@@pwd}/#{defaults[:image_stub]}")==true
1248
+ "#{@@pwd}/#{defaults[:image_stub]}"
1249
+ elsif FileTest.directory?(
1250
+ "#{SiSU_Utils::Path.new.base_markup}/#{defaults[:image_stub]}"
1251
+ )==true
1252
+ "#{SiSU_Utils::Path.new.base_markup}/#{defaults[:image_stub]}"
1253
+ else
1254
+ image_source_sisu_includes(md)
1255
+ end
1256
+ end
1257
+ def image_external
1258
+ "#{processing}/external_document/image"
1259
+ end
1260
+ def image_source_include_local
1261
+ if FileTest.directory?(defaults[:image_local])
1262
+ defaults[:image_local]
1263
+ end
1264
+ end
1265
+ def image_source_include_remote
1266
+ if FileTest.directory?(image_external)
1267
+ image_external
1268
+ end
1269
+ end
1270
+ self
1271
+ end
1272
+ def processing_path
1273
+ def encoding
1274
+ pth="#{processing}/#{defaults[:processing_encoding]}"
1275
+ FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1276
+ pth
1277
+ end
1278
+ def processing_base_tmp
1279
+ defaults[:processing_path_tmp_base]
1280
+ end
1281
+ def tmp_root_dir
1282
+ defaults[:processing_dir_tmp_root]
1283
+ end
1284
+ def root_dir
1285
+ proposed_path_base=if defined? @rc['processing']['path'] \
1286
+ and not @rc['processing']['path'].nil? \
1287
+ and not @rc['processing']['path'].empty?
1288
+ x=if @rc['processing']['path'] =~/^(?:~|home)$/
1289
+ home #fix
1290
+ else @rc['processing']['path']
1291
+ end
1292
+ else nil
1293
+ end
1294
+ proposed_dir=if defined? @rc['processing']['dir'] \
1295
+ and not @rc['processing']['dir'].nil? \
1296
+ and not @rc['processing']['dir'].empty?
1297
+ @rc['processing']['dir']
1298
+ else defaults[:processing_dir]
1299
+ end
1300
+ v=SiSU_Env::InfoVersion.instance.get_version
1301
+ v_dev=(DEVELOPER[:maintenance]==:true) \
1302
+ ? "_#{v.version}"
1303
+ : ''
1304
+ path=if proposed_path_base \
1305
+ and FileTest.directory?(proposed_path_base) \
1306
+ and File.writable?("#{proposed_path_base}/.")
1307
+ x=proposed_dir \
1308
+ ? "#{proposed_path_base}/#{proposed_dir}"
1309
+ : "#{proposed_path_base}/#{defaults[:processing_dir]}"
1310
+ else defaults[:processing_dir_tmp_root]
1311
+ end
1312
+ path = path + v_dev
1313
+ end
1314
+ def usr_dir?
1315
+ case root_dir
1316
+ when /^\/home/ then false
1317
+ else true
1318
+ end
1319
+ end
1320
+ def stub_dir
1321
+ (usr_dir?) \
1322
+ ? ("#{root_dir}/#{user}/#{stub_pwd}")
1323
+ : ("#{root_dir}/#{stub_pwd}") # see defaults[:processing_path]
1324
+ end
1325
+ def stub_dir_orig # ends up with lang, if lang dir
1326
+ (usr_dir?) \
1327
+ ? ("#{root_dir}/#{user}/#{stub_pwd}")
1328
+ : ("#{root_dir}/#{stub_pwd}") # see defaults[:processing_path]
1329
+ end
1330
+ def processing_sisupod(opt=nil) #processing directory, used/needed for sisu work files, has sub-directories (ao,tex etc)
1331
+ @opt=opt
1332
+ def paths
1333
+ processing_path_usr="#{root_dir}/#{user}"
1334
+ processing_path_fnb=processing_path_usr \
1335
+ + '/' + Gt[:pods] \
1336
+ + '/' + @opt.fng
1337
+ processing_path_sisupod=processing_path_fnb \
1338
+ + '/' + Gt[:sisupod]
1339
+ {
1340
+ fnb: processing_path_fnb,
1341
+ sisupod: processing_path_sisupod,
1342
+ }
1343
+ end
1344
+ def make
1345
+ unless FileTest.directory?(root_dir)
1346
+ FileUtils::mkdir_p(root_dir)
1347
+ File.chmod(0777,root_dir)
1348
+ end
1349
+ if usr_dir?
1350
+ processing_path_usr="#{root_dir}/#{user}"
1351
+ FileUtils::mkdir_p(processing_path_usr) \
1352
+ unless FileTest.directory?(processing_path_usr)
1353
+ File.chmod(0700,processing_path_usr)
1354
+ end
1355
+ sisupod_processing_path=paths[:sisupod]
1356
+ FileUtils::mkdir_p(sisupod_processing_path) \
1357
+ unless FileTest.directory?(sisupod_processing_path)
1358
+ sisupod_processing_path_lng=if defined? @opt.lng
1359
+ sisupod_processing_path \
1360
+ + '/' + Gt[:doc] \
1361
+ + '/' + @opt.lng
1362
+ else
1363
+ sisupod_processing_path \
1364
+ + '/' + Gt[:doc]
1365
+ end
1366
+ unless FileTest.directory?(sisupod_processing_path_lng)
1367
+ #puts "a processing directory (#{sisupod_processing_path_lng}) is being created for use by sisu"
1368
+ FileUtils::mkdir_p(sisupod_processing_path_lng)
1369
+ File.chmod(0700,sisupod_processing_path_lng)
1370
+ end
1371
+ sisupod_processing_path
1372
+ end
1373
+ self
1374
+ end
1375
+ def processing #processing directory, used/needed for sisu work files, has sub-directories (ao,tex etc)
1376
+ unless FileTest.directory?(root_dir)
1377
+ FileUtils::mkdir_p(root_dir)
1378
+ File.chmod(0777,root_dir)
1379
+ end
1380
+ if usr_dir?
1381
+ processing_path_usr="#{root_dir}/#{user}"
1382
+ FileUtils::mkdir_p(processing_path_usr) \
1383
+ unless FileTest.directory?(processing_path_usr)
1384
+ File.chmod(0700,processing_path_usr)
1385
+ end
1386
+ FileUtils::mkdir_p(stub_dir) \
1387
+ unless FileTest.directory?(stub_dir)
1388
+ File.chmod(0700,stub_dir)
1389
+ path_processing=[
1390
+ stub_dir,
1391
+ defaults[:processing_path],
1392
+ defaults[:processing_path_home]
1393
+ ]
1394
+ processing=nil
1395
+ path_processing.each do |v| #
1396
+ processing=v
1397
+ unless FileTest.directory?(processing)
1398
+ FileUtils::mkdir_p(processing)
1399
+ File.chmod(0700,processing)
1400
+ end
1401
+ break
1402
+ end
1403
+ processing
1404
+ end
1405
+ def ao
1406
+ pth=if defined? @rc['processing']['dal'] \
1407
+ and @rc['processing']['dal'].is_a?(String)
1408
+ "#{processing}/#{@rc['processing']['dal']}"
1409
+ else "#{processing}/#{defaults[:processing_ao]}"
1410
+ end
1411
+ FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1412
+ pth
1413
+ end
1414
+ def tune
1415
+ pth=if defined? @rc['processing']['tune'] \
1416
+ and @rc['processing']['tune'].is_a?(String)
1417
+ "#{processing}/#{@rc['processing']['tune']}"
1418
+ else "#{processing}/#{defaults[:processing_tune]}"
1419
+ end
1420
+ FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1421
+ pth
1422
+ end
1423
+ def composite_file
1424
+ pth=processing_path.ao #"#{processing}/composite"
1425
+ FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1426
+ pth
1427
+ end
1428
+ def git
1429
+ pth=if defined? @rc['git']['dir'] \
1430
+ and @rc['git']['dir'].is_a?(String)
1431
+ (@rc['git']['dir'] =~/^(?:~|home)$/) \
1432
+ ? home + '/' + Gt[:git]
1433
+ : @rc['git']['dir'] + '/' + Gt[:git]
1434
+ else defaults[:processing_git]
1435
+ end
1436
+ unless FileTest.directory?(pth)
1437
+ FileUtils::mkdir_p(pth)
1438
+ File.chmod(0700,pth)
1439
+ end
1440
+ pth
1441
+ end
1442
+ def odf_pth
1443
+ pth="#{processing}/odf/#{@fns}"
1444
+ pth
1445
+ end
1446
+ def odf
1447
+ odt
1448
+ end
1449
+ def odt
1450
+ pth=odf_pth + '/odt'
1451
+ FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1452
+ pth
1453
+ end
1454
+ def odf
1455
+ pth="#{processing}/odf"
1456
+ FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1457
+ pth
1458
+ end
1459
+ def odt_bld
1460
+ FileUtils::rm_rf(processing_path.odt)
1461
+ FileUtils::mkdir_p(processing_path.odt) \
1462
+ unless FileTest.directory?(processing_path.odt)
1463
+ FileUtils::mkdir_p("#{processing_path.odt}/Configurations2") \
1464
+ unless FileTest.directory?("#{processing_path.odt}/Configurations2")
1465
+ FileUtils::mkdir_p("#{processing_path.odt}/META-INF") \
1466
+ unless FileTest.directory?("#{processing_path.odt}/META-INF")
1467
+ FileUtils::mkdir_p("#{processing_path.odt}/Pictures") \
1468
+ unless FileTest.directory?("#{processing_path.odt}/Pictures")
1469
+ FileUtils::mkdir_p("#{processing_path.odt}/Thumbnails") \
1470
+ unless FileTest.directory?("#{processing_path.odt}/Thumbnails")
1471
+ processing_path.odt
1472
+ end
1473
+ def epub
1474
+ "#{processing}/epub/#{@fnb}"
1475
+ end
1476
+ def epub_bld #(md)
1477
+ FileUtils::rm_rf(processing_path.epub) \
1478
+ if FileTest.directory?(processing_path.epub)
1479
+ FileUtils::mkdir_p(processing_path.epub) \
1480
+ unless FileTest.directory?(processing_path.epub)
1481
+ FileUtils::mkdir_p("#{processing_path.epub}/META-INF") \
1482
+ unless FileTest.directory?("#{processing_path.epub}/META-INF")
1483
+ FileUtils::mkdir_p("#{processing_path.epub}/#{Ep[:d_oebps]}/image") \
1484
+ unless FileTest.directory?("#{processing_path.epub}/#{Ep[:d_oebps]}/image")
1485
+ FileUtils::mkdir_p("#{processing_path.epub}/#{Ep[:d_oebps]}/css") \
1486
+ unless FileTest.directory?("#{processing_path.epub}/#{Ep[:d_oebps]}/css")
1487
+ processing_path.epub
1488
+ end
1489
+ def epub_cp_images(md)
1490
+ pth="#{processing_path.epub}/#{Ep[:d_oebps]}/image"
1491
+ FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1492
+ src=(md.opt.sisu_install_type? == :full_path_to_sisu_bin_in_sisu_dir_tree) \
1493
+ ? "#{md.opt.sisu_data_dir?}/image"
1494
+ : "#{md.opt.sisu_data_dir?}/sisu/image"
1495
+ images=%W[bullet_09.png arrow_next_red.png arrow_prev_red.png arrow_up_red.png]
1496
+ images.each do |i| #move to avoid repeated tests
1497
+ if FileTest.file?("#{src}/#{i}")
1498
+ FileUtils::cp("#{src}/#{i}","#{pth}/#{i}") \
1499
+ unless FileTest.file?("#{pth}/#{i}")
1500
+ else STDERR.puts %{\t*WARN* did not find image - "#{i}" [#{__FILE__}:#{__LINE__}]}
1501
+ end
1502
+ end
1503
+ pth
1504
+ end
1505
+ def tex
1506
+ pth=if defined? @rc['processing']['latex'] \
1507
+ and @rc['processing']['latex'].is_a?(String)
1508
+ "#{processing}/#{@rc['processing']['latex']}"
1509
+ else "#{processing}/#{defaults[:processing_latex]}"
1510
+ end
1511
+ FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1512
+ pth
1513
+ end
1514
+ def texi
1515
+ pth=if defined? @rc['processing']['texinfo'] \
1516
+ and @rc['processing']['texinfo'].is_a?(String)
1517
+ "#{processing}/#{@rc['processing']['texinfo']}"
1518
+ else "#{processing}/#{defaults[:processing_texinfo]}"
1519
+ end
1520
+ FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1521
+ pth
1522
+ end
1523
+ def texinfo #texinfo webserv, check
1524
+ "#{processing}/#{defaults[:processing_texinfo]}"
1525
+ end
1526
+ def manpage
1527
+ "#{path.output}/man"
1528
+ end
1529
+ def lout
1530
+ pth=if defined? @rc['processing']['lout'] \
1531
+ and @rc['processing']['lout'].is_a?(String)
1532
+ "#{processing}/#{@rc['processing']['lout']}"
1533
+ else "#{processing}/#{defaults[:processing_lout]}"
1534
+ end
1535
+ FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1536
+ pth
1537
+ end
1538
+ def sql
1539
+ pth="#{processing}/sql"
1540
+ FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1541
+ pth
1542
+ end
1543
+ def sqlite
1544
+ pth=if defined? @rc['processing']['sqlite'] \
1545
+ and @rc['processing']['sqlite'].is_a?(String)
1546
+ "#{processing}/#{@rc['processing']['sqlite']}"
1547
+ else "#{processing}/#{defaults[:processing_sqlite]}"
1548
+ end
1549
+ FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1550
+ pth
1551
+ end
1552
+ def postgresql
1553
+ pth=if defined? @rc['processing']['postgresql'] \
1554
+ and @rc['processing']['postgresql'].is_a?(String)
1555
+ "#{processing}/#{@rc['processing']['postgresql']}"
1556
+ else "#{processing}/#{defaults[:processing_postgresql]}"
1557
+ end
1558
+ FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1559
+ pth
1560
+ end
1561
+ self
1562
+ end
1563
+ def url
1564
+ def hostname
1565
+ "http://#{@sys.hostname}"
1566
+ end
1567
+ def dir_url
1568
+ "file://#{path.webserv}/#{stub_pwd}"
1569
+ end
1570
+ def localhost
1571
+ "http://localhost/#{stub_pwd}"
1572
+ end
1573
+ def local
1574
+ "http://#{hostname}/#{@stub_pwd}"
1575
+ end
1576
+ def root
1577
+ if defined? @rc['webserv']['url_root'] \
1578
+ and @rc['webserv']['url_root'] =~/https?:\/\//
1579
+ "#{@rc['webserv']['url_root']}/#{@stub_pwd}"
1580
+ elsif defined? @rc['webserv']['url_root'] \
1581
+ and @rc['webserv']['url_root'] =~/localhost/
1582
+ "http://localhost/#{@stub_pwd}"
1583
+ else "file://#{path.output}"
1584
+ end
1585
+ end
1586
+ def remote
1587
+ root
1588
+ end
1589
+ def txt
1590
+ "#{root}/txt"
1591
+ end
1592
+ def html
1593
+ "#{root}/html"
1594
+ end
1595
+ def epub
1596
+ "#{root}/epub"
1597
+ end
1598
+ def odt
1599
+ "#{root}/odt"
1600
+ end
1601
+ def pdf
1602
+ "#{root}/pdf"
1603
+ end
1604
+ def src_txt
1605
+ "#{root}/src"
1606
+ end
1607
+ def src_pod
1608
+ "#{root}/pod"
1609
+ end
1610
+ def pot
1611
+ "#{root}/po4a/pot"
1612
+ end
1613
+ def po
1614
+ "#{root}/po4a/po"
1615
+ end
1616
+ def webserv_host_base(opt=nil)
1617
+ if defined? @rc['webserv']['host']
1618
+ case @rc['webserv']['host']
1619
+ when /https?:\/\// then @rc['webserv']['host']
1620
+ when /\S+/ then "http://#{@rc['webserv']['host']}"
1621
+ else defaults[:webserv_host_cgi]
1622
+ end
1623
+ else defaults[:webserv_host_cgi]
1624
+ end
1625
+ end
1626
+ def webserv_cgi(opt=nil) #web url for local webserv (localhost, or hostname)
1627
+ http=if defined? @rc['webserv_cgi']['host'] \
1628
+ and @rc['webserv_cgi']['host'].is_a?(String)
1629
+ http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://') #check https? missing
1630
+ if port.webserv_port_cgi
1631
+ http + @rc['webserv_cgi']['host'] + ':' \
1632
+ + port.webserv_port_cgi + '/' \
1633
+ + @stub_pwd
1634
+ else
1635
+ http + @rc['webserv_cgi']['host'] + '/' \
1636
+ + @stub_pwd
1637
+ end
1638
+ else
1639
+ http=((webserv_host_base=~/https?:\/\//) ? '' : 'http://')
1640
+ if port.webserv_port_cgi(opt)
1641
+ http + webserv_host_base + ':' \
1642
+ + port.webserv_port_cgi(opt) + '/'\
1643
+ + @stub_pwd
1644
+ else
1645
+ http + webserv_host_base + '/' \
1646
+ + @stub_pwd
1647
+ end
1648
+ end
1649
+ http=http.strip
1650
+ end
1651
+ def webserv_base_cgi(opt=nil) #web url for local webserv (localhost, or hostname)
1652
+ http_cgi=if opt.selections.str =~/--webserv-(?:cgi|db|search)[=-]["']?(\S+)["']+/
1653
+ m=$1
1654
+ (m=~/http\/\/:/) ? m : %{http://#{m}}
1655
+ elsif defined? @rc['webserv_cgi']['host'] \
1656
+ and @rc['webserv_cgi']['host'].is_a?(String)
1657
+ http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://')
1658
+ if port.webserv_port_cgi(opt)
1659
+ http + @rc['webserv_cgi']['host'] + ':' \
1660
+ + port.webserv_port_cgi(opt).to_s
1661
+ else
1662
+ http + @rc['webserv_cgi']['host']
1663
+ end
1664
+ else
1665
+ http=((webserv_host_base=~/https?:\/\//) ? '' : 'http://')
1666
+ if port.webserv_port_cgi(opt)
1667
+ http + webserv_host_base + ':' \
1668
+ + port.webserv_port_cgi(opt).to_s
1669
+ else http + webserv_host_base
1670
+ end
1671
+ end
1672
+ http_cgi=http_cgi.strip
1673
+ #%q{http://#{ENV['HTTP_HOST']}}
1674
+ end
1675
+ def webrick #must have a port #REMOVE
1676
+ if defined? @rc['webserv_cgi']['host'] \
1677
+ and @rc['webserv_cgi']['host'].is_a?(String)
1678
+ http=if @rc['webserv_cgi']['host'] =~/http:\/\//
1679
+ 'http://'
1680
+ elsif @rc['webserv_cgi']['host'] =~/https:\/\//
1681
+ 'https://'
1682
+ else defaults
1683
+ end
1684
+ http + @rc['webserv_cgi']['host']
1685
+ elsif webserv_host_base \
1686
+ and webserv_host_base.is_a?(String)
1687
+ webserv_host_base
1688
+ else
1689
+ #http + 'localhost'
1690
+ 'localhost'
1691
+ end
1692
+ end
1693
+ def webserv #web url for local webserv (localhost, or hostname)
1694
+ if defined? @rc['webserv']['url_root'] \
1695
+ and @rc['webserv']['url_root'] =~/http/
1696
+ # needed for alternative output dir structures, fixes manifest url links, check may cause problems elsewhere
1697
+ @rc['webserv']['url_root']
1698
+ elsif path.webserv_dir \
1699
+ and path.webserv =~ /#{path.webserv_dir}/ #revisit
1700
+ path.webserv + '/' \
1701
+ + @base_markup_dir_stub.
1702
+ gsub(/#{path.webserv_dir}/,
1703
+ "#{url.hostname}/#{@stub_pwd}")
1704
+ elsif defined? @rc['webserv']['webrick_url'] \
1705
+ and @rc['webserv']['webrick_url']==false
1706
+ 'file://' + path.webserv
1707
+ elsif port.webserv_port_cgi =~/\S+/
1708
+ url.hostname + ':' + port.webserv_port_cgi
1709
+ else
1710
+ url.hostname
1711
+ end
1712
+ end
1713
+ def webserv_base #web url for local webserv (localhost, or hostname)
1714
+ if path.webserv_dir \
1715
+ and path.webserv =~ /#{path.webserv_dir}/ #revisit
1716
+ path.webserv + '/' \
1717
+ + @stub_pwd.
1718
+ gsub(/#{path.webserv_dir}/,
1719
+ "#{url.hostname}")
1720
+ elsif defined? @rc['webserv']['webrick_url'] \
1721
+ and @rc['webserv']['webrick_url']==false
1722
+ "file://#{path.webserv}"
1723
+ else "#{url.webrick_base}"
1724
+ end
1725
+ end
1726
+ def webserv_files_from_db(opt=nil) #sort this out, messy
1727
+ if opt.selections.str =~/--webserv-output[=-]["']?(\S+)["']+/
1728
+ m=$1
1729
+ (m=~/(?:http|file\/)\/\/:/) ? m : %{http://#{m}}
1730
+ else
1731
+ show_output_on=if defined? @rc['webserv_cgi']['show_output_on']
1732
+ @rc['webserv_cgi']['show_output_on']
1733
+ elsif defined? @rc['webserv_cgi']['file_links']
1734
+ @rc['webserv_cgi']['file_links']
1735
+ else ''
1736
+ end
1737
+ m=case show_output_on
1738
+ when /webserv_cgi/ then url.webserv_base_cgi(opt)
1739
+ when /webserv/ then @rc['webserv']['url_root']
1740
+ when /https?:\/\// then @rc['webserv_cgi']['file_links']
1741
+ when /\S+/ then 'http://' + @rc['webserv_cgi']['file_links']
1742
+ else webserv_base_cgi(opt)
1743
+ end
1744
+ end
1745
+ #%q{http://#{ENV['HTTP_HOST']}/cgi-bin}
1746
+ end
1747
+ def cgi_sample_search_form_name(opt=nil)
1748
+ if opt.selections.str \
1749
+ =~/--(?:cgi-)?search-form-name[=-]["']?(\S+?\.cgi)/
1750
+ $1
1751
+ elsif not opt.selections.str =~/--db[=-]["']?sqlite/ \
1752
+ and defined? @rc['search'] \
1753
+ and defined? @rc['search']['sisu'] \
1754
+ and defined? @rc['search']['sisu']['action'] \
1755
+ and @rc['search']['sisu']['action'] =~/https?:\/\/\S+?\.cgi/
1756
+ /(?:https?:\/\/\S+?)\/([^\/]+?\.cgi)$/.
1757
+ match(@rc['search']['sisu']['action'])[1]
1758
+ else
1759
+ (opt.selections.str =~/--db[=-]["']?sqlite/) \
1760
+ ? "#{Db[:name_prefix_db]}sqlite.cgi" \
1761
+ : "#{Db[:name_prefix_db]}pg.cgi"
1762
+ end
1763
+ end
1764
+ def sample_search_form_title(organised_by=:language)
1765
+ title=if defined? @rc['search']['sisu']['title'] \
1766
+ and @rc['search']['sisu']['title'] =~/\S+/
1767
+ @rc['search']['sisu']['title']
1768
+ else %{SiSU (generated sample) search form}
1769
+ end
1770
+ title=title + " (content organised by #{organised_by})"
1771
+ end
1772
+ def output_tell #BROKEN Revisit 2011-02
1773
+ output_type=if defined? @rc['show_output_on'] \
1774
+ and @rc['show_output_on'] \
1775
+ =~/^(?:filesystem|webserv|(?:local|remote)(?:_webserv)?|webrick)/
1776
+ @rc['show_output_on']
1777
+ else 'filesystem'
1778
+ end
1779
+ case output_type
1780
+ when /^filesystem(?:_url)?/ then url.dir_url
1781
+ when /^remote(?:_webserv)?/ then url.remote
1782
+ when /^(?:webserv|local_webserv)/ then url.local
1783
+ when /^local(:\d+)/ then url.hostname + $1 + '/' + stub_pwd
1784
+ when /^localhost(:\d+)/ then url.localhost + $1 + '/' + stub_pwd
1785
+ when /^localhost/ then url.localhost
1786
+ when /^webrick/ then url.webrick
1787
+ when /^path/ then url.webserv_map_pwd
1788
+ else url.webserv_map_pwd
1789
+ end
1790
+ end
1791
+ def images
1792
+ "#{Xx[:html_relative2]}/_sisu/image"
1793
+ end
1794
+ #def images
1795
+ # '../_sisu/image'
1796
+ #end
1797
+ def images_local
1798
+ if FileTest.directory?(path.image_source_include)
1799
+ path.image_source_include
1800
+ else
1801
+ if @@local_image==true
1802
+ cmd=@md.opt.selections.str ? @md.opt.selections.str : ''
1803
+ SiSU_Screen::Ansi.new(
1804
+ cmd,
1805
+ "WARNING - no local image directory or images:",
1806
+ defaults[:image_local]
1807
+ ).warn unless @md.opt.act[:quiet][:set]==:on
1808
+ @@local_image=false
1809
+ end
1810
+ url.images
1811
+ end
1812
+ end
1813
+ def images_external
1814
+ if FileTest.directory?(image_external)
1815
+ if @@image_flag
1816
+ images=Dir.glob("#{image_external}/*.{png,jpg,gif}")
1817
+ pth=path.webserv + '/' \
1818
+ + @stub_pwd
1819
+ FileUtils::mkdir_p("#{pth}/_sisu/image_external") \
1820
+ unless FileTest.directory?("#{pth}/_sisu/image_external")
1821
+ images.each { |i| File.install(i,"#{pth}/#{i}") } \
1822
+ unless images.length > 0
1823
+ @@image_flag=false
1824
+ end
1825
+ "#{Xx[:html_relative2]}/_sisu/image_external"
1826
+ else
1827
+ if @@local_image==true
1828
+ SiSU_Screen::Ansi.new(
1829
+ @cmd,
1830
+ 'WARNING - image directory for external images or no such images:',
1831
+ :image_external
1832
+ ).warn unless @md.opt.act[:quiet][:set]==:on
1833
+ @@local_image=false
1834
+ end
1835
+ url.images_external
1836
+ end
1837
+ end
1838
+ def images_epub
1839
+ './image'
1840
+ end
1841
+ self
1842
+ end
1843
+ def port
1844
+ def webrick_port
1845
+ if @md \
1846
+ and @md.opt.act[:sample_search_form][:set]==:on \
1847
+ and @md.opt.selections.str=~/port=(\d+)/
1848
+ $1
1849
+ else
1850
+ if defined? @rc['webserv_cgi']['port']
1851
+ if @rc['webserv_cgi']['port'].nil? \
1852
+ and (defined? @md.opt.selections \
1853
+ and @md.opt.selections.str=~/webrick/)
1854
+ defaults[:webserv_port_cgi]
1855
+ elsif not @rc['webserv_cgi']['port'].nil?
1856
+ @rc['webserv_cgi']['port']
1857
+ else defaults[:webserv_port_cgi]
1858
+ end
1859
+ else defaults[:webserv_port_cgi]
1860
+ end
1861
+ end
1862
+ end
1863
+ def webserv_port_cgi(opt=nil)
1864
+ port=if opt \
1865
+ and opt.act[:sample_search_form][:set]==:on \
1866
+ and opt.selections.str=~/port[=-](\d+)/
1867
+ $1
1868
+ else
1869
+ port=if defined? @rc['webserv_cgi']['port']
1870
+ if @rc['webserv_cgi']['port'].nil? \
1871
+ and (defined? opt.selections \
1872
+ and opt.selections.str=~/webrick/)
1873
+ defaults[:webserv_port_cgi]
1874
+ elsif not @rc['webserv_cgi']['port'].nil?
1875
+ @rc['webserv_cgi']['port']
1876
+ else nil
1877
+ end
1878
+ else
1879
+ if (defined? opt.selections \
1880
+ and opt.selections.str=~/webrick/)
1881
+ defaults[:webserv_port_cgi]
1882
+ else nil
1883
+ end
1884
+ end
1885
+ end
1886
+ port.to_s
1887
+ end
1888
+ self
1889
+ end
1890
+ def digest_conf?
1891
+ if defined? @rc['default']['digest'] \
1892
+ and @rc['default']['digest'] != nil
1893
+ case @rc['default']['digest']
1894
+ when /^sha(?:5|512)?$/ then :sha512
1895
+ when /^sha(?:2|256)?$/ then :sha256
1896
+ when /^md5$/ then :md5
1897
+ else :sha256
1898
+ end
1899
+ else :sha256
1900
+ end
1901
+ end
1902
+ def digest(opt=nil)
1903
+ @opt=opt
1904
+ def type
1905
+ if @opt
1906
+ case @opt.act[:hash_digest_algo]
1907
+ when :sha512 then :sha512
1908
+ when :sha256 then :sha256
1909
+ when :md5 then :md5
1910
+ else digest_conf?
1911
+ end
1912
+ else digest_conf?
1913
+ end
1914
+ end
1915
+ def length
1916
+ case digest(@opt).type
1917
+ when :sha512 then 128
1918
+ when :sha256 then 64
1919
+ when :md5 then 32
1920
+ else 64
1921
+ end
1922
+ end
1923
+ def pattern
1924
+ "[0-9a-f]{#{digest(@opt).length}}" #/[0-9a-f]{#{digest.length}}/
1925
+ end
1926
+ self
1927
+ end
1928
+ def program
1929
+ def text_editor
1930
+ if defined? @rc['program_select']['editor'] \
1931
+ and @rc['program_select']['editor'] =~/\S\S+/
1932
+ @rc['program_select']['editor']
1933
+ elsif defined? @rc['program_select']['text_editor'] \
1934
+ and @rc['program_select']['text_editor'] =~/\S\S+/
1935
+ @rc['program_select']['text_editor']
1936
+ else 'editor' #'gvim -c :R -c :S'
1937
+ end
1938
+ end
1939
+ def pdf_viewer
1940
+ ((defined? @rc['program_select']['pdf_viewer']) \
1941
+ && @rc['program_select']['pdf_viewer'] =~/\S\S+/) \
1942
+ ? @rc['program_select']['pdf_viewer']
1943
+ : 'pdf-viewer' #'evince'
1944
+ end
1945
+ def web_browser
1946
+ if defined? @rc['program_select']['www_browser'] \
1947
+ and @rc['program_select']['www_browser'] =~/\S\S+/
1948
+ @rc['program_select']['www_browser']
1949
+ elsif defined? @rc['program_select']['web_browser'] \
1950
+ and @rc['program_select']['web_browser'] =~/\S\S+/
1951
+ @rc['program_select']['web_browser']
1952
+ else 'x-www-browser' #'firefox' 'iceweasel' 'kazehakase' 'galeon'
1953
+ end
1954
+ end
1955
+ def www_browser
1956
+ web_browser
1957
+ end
1958
+ def console_web_browser
1959
+ if defined? @rc['program_select']['console_www_browser'] \
1960
+ and @rc['program_select']['console_www_browser'] =~/\S\S+/
1961
+ @rc['program_select']['console_www_browser']
1962
+ elsif defined? @rc['program_select']['console_web_browser'] \
1963
+ and @rc['program_select']['console_web_browser'] =~/\S\S+/
1964
+ @rc['program_select']['console_web_browser']
1965
+ else 'console-www-browser' #'lynx' 'links' 'links2' 'elinks' 'w3m'
1966
+ end
1967
+ end
1968
+ def console_www_browser
1969
+ web_browser
1970
+ end
1971
+ def epub_viewer
1972
+ ((defined? @rc['program_select']['epub_viewer']) \
1973
+ && @rc['program_select']['epub_viewer'] =~/\S\S+/) \
1974
+ ? @rc['program_select']['epub_viewer']
1975
+ : 'ebook-viewer' #'calibre' 'fbreader'
1976
+ end
1977
+ def xml_viewer
1978
+ ((defined? @rc['program_select']['xml_viewer']) \
1979
+ && @rc['program_select']['xml_viewer'] =~/\S\S+/) \
1980
+ ? @rc['program_select']['xml_viewer']
1981
+ : text_editor
1982
+ end
1983
+ def docbook_viewer
1984
+ ((defined? @rc['program_select']['xml_viewer']) \
1985
+ && @rc['program_select']['xml_viewer'] =~/\S\S+/) \
1986
+ ? @rc['program_select']['xml_viewer']
1987
+ : text_editor
1988
+ end
1989
+ def fictionbook_viewer
1990
+ ((defined? @rc['program_select']['xml_viewer']) \
1991
+ && @rc['program_select']['xml_viewer'] =~/\S\S+/) \
1992
+ ? @rc['program_select']['xml_viewer']
1993
+ : text_editor
1994
+ end
1995
+ def xml_editor
1996
+ xml_viewer
1997
+ end
1998
+ def odf_viewer
1999
+ ((defined? @rc['program_select']['odf_viewer']) \
2000
+ && @rc['program_select']['odf_viewer'] =~/\S\S+/) \
2001
+ ? @rc['program_select']['odf_viewer']
2002
+ : 'lowriter' #'odf-viewer','oowriter'
2003
+ end
2004
+ def manpage_viewer
2005
+ 'man'
2006
+ end
2007
+ def manpage_generator
2008
+ ((defined? @rc['program_select']['man']) \
2009
+ && @rc['program_select']['man'] =~/\S\S+/) \
2010
+ ? @rc['program_select']['man']
2011
+ : 'nroff -man' #'nroff -man' #'groff -man -Tascii'
2012
+ end
2013
+ def texinfo
2014
+ ((defined? @rc['program_select']['info_viewer']) \
2015
+ && @rc['program_select']['info_viewer'] =~/\S\S+/) \
2016
+ ? @rc['program_select']['info_viewer']
2017
+ : 'pinfo -f' #'pinfo -f' 'info' 'tkinfo'
2018
+ end
2019
+ def file_encoding
2020
+ is=(defined? @rc['program_set']['file_encoding']) \
2021
+ ? @rc['program_set']['encoding'] : ''
2022
+ (is.nil? || is==true) ? 'encoding' : is
2023
+ end
2024
+ def wc #wordcount
2025
+ is=(defined? @rc['program_set']['wc']) \
2026
+ ? @rc['program_set']['wc'] : ''
2027
+ (is.nil? || is==true) ? 'wc' : is
2028
+ end
2029
+ def tidy
2030
+ is=(defined? @rc['program_set']['tidy']) \
2031
+ ? @rc['program_set']['tidy'] : nil
2032
+ (is.nil? || is==true) ? 'tidy' : is
2033
+ end
2034
+ def rmagick
2035
+ is=(defined? @rc['program_set']['rmagick']) \
2036
+ ? @rc['program_set']['rmagick'] : nil
2037
+ (is.nil? || is==true) ? 'rmagick' : is
2038
+ end
2039
+ def rexml #should be part of ruby 1.8 but apparently not always
2040
+ is=(defined? @rc['program_set']['rexml']) ? \
2041
+ @rc['program_set']['rexml'] : ''
2042
+ (is.nil? || is==true) ? 'rexml' : is
2043
+ end
2044
+ def pdflatex
2045
+ is=(defined? @rc['program_set']['pdflatex']) ? \
2046
+ @rc['program_set']['pdflatex'] : ''
2047
+ (is.nil? || is==true) ? 'pdflatex' : is
2048
+ end
2049
+ def postgresql
2050
+ is=(defined? @rc['program_set']['postgresql']) ? \
2051
+ @rc['program_set']['postgresql'] : ''
2052
+ (is.nil? || is==true) ? 'postgresql' : is
2053
+ end
2054
+ def sqlite
2055
+ is=(defined? @rc['program_set']['sqlite']) ? \
2056
+ @rc['program_set']['sqlite'] : ''
2057
+ (is.nil? || is==true) ? 'sqlite' : is
2058
+ end
2059
+ self
2060
+ end
2061
+ def i18n
2062
+ def language # language settings
2063
+ m=/.+\/\S+?\~(\S+)/
2064
+ pwd=Dir.pwd
2065
+ conf=(defined? @rc['default']['language']) \
2066
+ ? @rc['default']['language'] : nil
2067
+ l=if pwd=~ m then pwd[m,1] #2 directory: by visible directory name
2068
+ elsif conf then @rc['default']['language'] #3 config: from sisurc.yaml
2069
+ else defaults[:language] #4 sisu: program default
2070
+ end #1 document: param gets
2071
+ SiSU_Env::StandardiseLanguage.new(l)
2072
+ end
2073
+ #def multilingual
2074
+ # x=(defined? @rc['output_structure']['multilingual'] \
2075
+ # && @rc['output_structure']['multilingual'] ==true) \
2076
+ # ? true : false
2077
+ #end
2078
+ #def bundle
2079
+ # x=(defined? @rc['output_structure']['bundle'] \
2080
+ # && @rc['output_structure']['bundle'] ==true) \
2081
+ # ? true : false
2082
+ #end
2083
+ def lang_filename(l)
2084
+ @lang={}
2085
+ x=if output_dir_structure.by_language_code?
2086
+ (( defined? @rc['default']['language_file']) \
2087
+ && @rc['default']['language_file'] != nil) \
2088
+ ? @rc['default']['language_file']
2089
+ : 1
2090
+ else 0
2091
+ end
2092
+ if (l != defaults[:language_code]) \
2093
+ or (language.code != defaults[:language_code]) #watch
2094
+ if x==1 then @lang[:pre],@lang[:mid],@lang[:post]="#{l}.",'',''
2095
+ elsif x==2 then @lang[:pre],@lang[:mid],@lang[:post]='',".#{l}",''
2096
+ elsif x==3 then @lang[:pre],@lang[:mid],@lang[:post]='','',".#{l}"
2097
+ else @lang[:pre],@lang[:mid],@lang[:post]='','',''
2098
+ end
2099
+ else @lang[:pre],@lang[:mid],@lang[:post]='','',''
2100
+ end
2101
+ @lang
2102
+ end
2103
+ self
2104
+ end
2105
+ def file_encoding
2106
+ is=''
2107
+ if defined? @rc['program_set']['file_encoding']
2108
+ is=@rc['program_set']['encoding']
2109
+ end
2110
+ if is.nil? \
2111
+ or is==true
2112
+ is='encoding'
2113
+ end
2114
+ is
2115
+ end
2116
+ def papersize # paper settings, default overidden in param if set within document
2117
+ (defined? @rc['default']['papersize']) \
2118
+ ? @rc['default']['papersize'].downcase
2119
+ : (defaults[:papersize].downcase)
2120
+ end
2121
+ def sisupod_gen(fns_pod)
2122
+ sisupod_gen_v3(fns_pod)
2123
+ end
2124
+ def sisupod_gen_v3(fns_pod)
2125
+ pwd=Dir.pwd
2126
+ sisupod_processing_path=
2127
+ processing_path.processing + '/' + Gt[:sisupod]
2128
+ if FileTest.directory?(sisupod_processing_path) \
2129
+ or FileTest.file?(sisupod_processing_path)
2130
+ FileUtils::rm_rf(sisupod_processing_path)
2131
+ end
2132
+ unless FileTest.directory?(sisupod_processing_path)
2133
+ FileUtils::mkdir_p(sisupod_processing_path)
2134
+ end
2135
+ f_pod=if FileTest.file?("#{Dir.pwd}/#{fns_pod}")
2136
+ "#{Dir.pwd}/#{fns_pod}"
2137
+ elsif FileTest.file?(fns_pod)
2138
+ fns_pod
2139
+ end
2140
+ if f_pod \
2141
+ && FileTest.file?(f_pod)
2142
+ (SiSU_Env::SystemCall.new.program_found?('tree')) \
2143
+ ? 'tree ' + processing_path.processing + '/' + Gt[:sisupod]
2144
+ : ''
2145
+ if FileTest.directory?(processing_path.processing)
2146
+ Dir.chdir(processing_path.processing)
2147
+ system(%{tar xJf #{f_pod}})
2148
+ Dir.chdir(pwd)
2149
+ end
2150
+ #system(tree) #enable if (/[vVM]/)
2151
+ else
2152
+ SiSU_Screen::Ansi.new(
2153
+ '',
2154
+ '*WARN* file not found: ' + fns_pod
2155
+ ).warn unless @md.opt.act[:quiet][:set]==:on
2156
+ end
2157
+ sisupod_processing_path
2158
+ end
2159
+ def sisupod_gen_v2(fns_pod)
2160
+ sisupod_processing_path=
2161
+ processing_path.processing + '/' + Gt[:sisupod]
2162
+ if FileTest.directory?(sisupod_processing_path) \
2163
+ or FileTest.file?(sisupod_processing_path)
2164
+ FileUtils::rm_rf(sisupod_processing_path)
2165
+ end
2166
+ unless FileTest.directory?(sisupod_processing_path)
2167
+ FileUtils::mkdir_p(sisupod_processing_path)
2168
+ end
2169
+ (FileTest.file?(fns_pod)) \
2170
+ ? system("unzip -q #{fns_pod} -d #{processing_path.processing}")
2171
+ : (SiSU_Screen::Ansi.new(
2172
+ '',
2173
+ "*WARN* file not found: #{fns_pod}"
2174
+ ).warn unless @md.opt.act[:quiet][:set]==:on)
2175
+ sisupod_processing_path
2176
+ end
2177
+ end
2178
+ end
2179
+ __END__