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,394 @@
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_programs.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_Sys_Call
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
+ class SystemCall
65
+ @@locale_flag=false
66
+ def initialize(input='',output='',opt_or_cmd='')
67
+ @input,@output=input,output
68
+ (opt_or_cmd.is_a?(SiSU_Commandline::Options)) \
69
+ ? (@cmd,@opt=opt_or_cmd.cmd,opt_or_cmd)
70
+ : (@cmd,@opt=opt_or_cmd,nil) #cmd.is_a?(String)
71
+ @prog=SiSU_Env::InfoProgram.new
72
+ @sys=SiSU_Info_Sys::InfoSystem.instance
73
+ end
74
+ def program_found?(program)
75
+ found=`which #{program} 2>&1` #`whereis #{program}`
76
+ (found =~/bin\/#{program}\b/) ? true : false
77
+ end
78
+ def locale #locales utf8 or other
79
+ unless @@locale_flag
80
+ @@locale_flag=true
81
+ end
82
+ @sys.locale
83
+ end
84
+ def file_encoding(filename,act='') #file encoding
85
+ program='file'
86
+ fnsp=SiSU_Env::InfoEnv.new(filename).source_file_with_path
87
+ if program_found?(program)
88
+ encoding=%x{file -L #{fnsp}}.strip
89
+ encoding=encoding.gsub(/#{fnsp}:(\s+|$)/,'')
90
+ encoding=if encoding \
91
+ and not encoding.empty?
92
+ encoding
93
+ else 'UTF-8 assumed, encoding undetermined'
94
+ end
95
+ if act[:verbose_plus][:set] ==:on \
96
+ or act[:maintenance][:set] ==:on
97
+ puts encoding
98
+ end
99
+ encoding
100
+ else
101
+ 'UTF-8 assumed, file encoding check program unavailable'
102
+ end
103
+ end
104
+ def wc #word count
105
+ program='wc'
106
+ if program_found?(program) \
107
+ and locale !~/utf-?8/i
108
+ true
109
+ else
110
+ program_ref="(not available)" \
111
+ unless program_found?(program)
112
+ program_ref="(UTF-8)" \
113
+ if locale =~/utf-?8/i
114
+ false
115
+ end
116
+ end
117
+ def rcs #rcs for document markup data
118
+ program='rcs'
119
+ program_ref="\n\t\tdocument version information requested"
120
+ if program_found?(program); true
121
+ else
122
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
123
+ warn("#{program} is not installed #{program_ref}")
124
+ false
125
+ end
126
+ end
127
+ def cvs #cvs for document markup data
128
+ program='cvs'
129
+ program_ref="\n\t\tdocument version information requested"
130
+ if program_found?(program); true
131
+ else
132
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
133
+ warn("#{program} is not installed #{program_ref}")
134
+ false
135
+ end
136
+ end
137
+ def po4a #po4a
138
+ program='po4a'
139
+ program_ref="\n\t\tpo4a"
140
+ if program_found?(program); true
141
+ else
142
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
143
+ warn("#{program} is not installed #{program_ref}")
144
+ false
145
+ end
146
+ end
147
+ def zip #zip
148
+ program='zip'
149
+ program_ref="\n\t\tused to in the making of number of file formats, odf, epub"
150
+ if program_found?(program); true
151
+ else
152
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
153
+ mark("*WARN* #{program} is not installed #{program_ref}")
154
+ false
155
+ end
156
+ end
157
+ def openssl #openssl for digests
158
+ program='openssl'
159
+ program_ref="\n\t\tused to generate requested source document identification digest"
160
+ if program_found?(program); true
161
+ else
162
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
163
+ warn("#{program} is not installed #{program_ref}")
164
+ false
165
+ end
166
+ end
167
+ def md5(filename) #md5 dgst
168
+ program='openssl'
169
+ program_ref="\n\t\tmd5 digest requested"
170
+ if program_found?(program)
171
+ pwd=Dir.pwd
172
+ Dir.chdir(File.dirname(filename))
173
+ dgst=%x{openssl dgst -md5 #{File.basename(filename)}}.strip #use file name without file path
174
+ Dir.chdir(pwd)
175
+ dgst.scan(/\S+/)
176
+ else
177
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
178
+ warn("#{program} is not installed #{program_ref}")
179
+ false
180
+ end
181
+ end
182
+ def sha256(filename) #sha dgst
183
+ program='openssl'
184
+ program_ref="\n\t\tsha digest requested"
185
+ if program_found?(program)
186
+ pwd=Dir.pwd
187
+ Dir.chdir(File.dirname(filename))
188
+ dgst=%x{openssl dgst -sha256 #{File.basename(filename)}}.strip #use file name without file path
189
+ Dir.chdir(pwd)
190
+ dgst.scan(/\S+/)
191
+ else
192
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
193
+ warn("#{program} is not installed #{program_ref}")
194
+ false
195
+ end
196
+ end
197
+ def sha512(filename) #sha dgst
198
+ program='openssl'
199
+ program_ref="\n\t\tsha digest requested"
200
+ if program_found?(program)
201
+ pwd=Dir.pwd
202
+ Dir.chdir(File.dirname(filename))
203
+ dgst=%x{openssl dgst -sha512 #{File.basename(filename)}}.strip #use file name without file path
204
+ Dir.chdir(pwd)
205
+ dgst.scan(/\S+/)
206
+ else
207
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
208
+ warn("#{program} is not installed #{program_ref}")
209
+ false
210
+ end
211
+ end
212
+ def psql #psql
213
+ program='psql'
214
+ program_ref="\n\t\tpsql requested"
215
+ if program_found?(program); true
216
+ else
217
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
218
+ warn("#{program} is not installed #{program_ref}")
219
+ false
220
+ end
221
+ end
222
+ def create_pg_db(dbname_stub=nil) #createdb
223
+ unless dbname_stub
224
+ @pwd ||=Dir.pwd
225
+ m=/.+\/(?:src\/)?(\S+)/im # m=/.+?\/(?:src\/)?([^\/]+)$/im # m=/.+\/(\S+)/m
226
+ dbname_stub=@pwd[m,1]
227
+ end
228
+ program='createdb'
229
+ db_name="#{Db[:name_prefix]}#{dbname_stub}"
230
+ program_ref="\n\t\tcreatedb dbname #{db_name} #for postgresql database creation"
231
+ (program_found?(program)) \
232
+ ? system("#{program} #{dbname_name}")
233
+ : (STDERR.puts "\t*WARN* #{program} is not available #{program_ref}")
234
+ end
235
+ def relaxng(cmd='') #trang - convert between different schema languages for XML
236
+ program='trang'
237
+ program_ref="\n\t\tsee <http://www.thaiopensource.com/relaxng/trang.html>"
238
+ (program_found?(program)) \
239
+ ? system("#{program} #{@input} #{@output}")
240
+ : (STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" if cmd =~/V/)
241
+ end
242
+ def qrencode #qrcode - for generating QR code
243
+ program='qrencode'
244
+ program_ref="\n\t\tsee <http://megaui.net/fukuchi/works/qrencode/index.en.html>"
245
+ found=(program_found?(program)) ? true : false
246
+ found \
247
+ ? (system(%{
248
+ echo "#{@input}" | #{program} -s 3 -o #{@output}
249
+ }))
250
+ : (STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" if @cmd =~/V/)
251
+ #found
252
+ end
253
+ def imagemagick #imagemagick is a image manipulation program
254
+ program='identify'
255
+ #program_ref="\n\t\tsee <http://www.imagemagick.org/>"
256
+ found=(program_found?(program)) ? true : false
257
+ #STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" unless found
258
+ found
259
+ end
260
+ def graphicsmagick #graphicsmagick is a image manipulation program
261
+ program='gm'
262
+ #program_ref="\n\t\tsee <http://www.graphicsmagick.org/>"
263
+ found=(program_found?(program)) ? true : false
264
+ #STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}" unless found
265
+ found
266
+ end
267
+ def well_formed? #tidy - check for well formed xml xhtml etc.
268
+ program=@prog.tidy
269
+ program_ref="\n\t\tsee <http://tidy.sourceforge.net/>"
270
+ (program_found?(program)) \
271
+ ? system("#{@prog.tidy} -xml #{@input} > #{@output}")
272
+ : (STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}")
273
+ end
274
+ def tex2pdf_engine
275
+ progs=['xetex','xelatex','pdflatex','pdfetex','pdftex']
276
+ @pdfetex_flag=false
277
+ @cmd ||=''
278
+ @texpdf=nil
279
+ progs.each do |program|
280
+ if program_found?(program)
281
+ @texpdf=program if program =~/xetex|xelatex|pdftex|pdflatex/
282
+ @pdfetex_flag=true
283
+ break
284
+ end
285
+ end
286
+ if @pdfetex_flag==false
287
+ @texpdf=progs.join(', ')
288
+ end
289
+ @texpdf
290
+ end
291
+ def latex2pdf(md,papersize='a4') #convert from latex to pdf
292
+ tell=if @cmd =~/[MV]/
293
+ ''
294
+ elsif @cmd =~/[v]/
295
+ %q{2>&1 | grep -v ' WARNING '}
296
+ else %q{2>&1 | grep -v '$'}
297
+ end
298
+ mode='batchmode' #mode='nonstopmode'
299
+ texpdf=tex2pdf_engine
300
+ if @pdfetex_flag
301
+ texpdf_cmd=case texpdf
302
+ when /xetex/
303
+ %{#{texpdf} -interaction=#{mode} -fmt=xelatex -papersize="#{papersize}" #{@input} #{tell}\n}
304
+ when /xelatex/
305
+ %{#{texpdf} -interaction=#{mode} -papersize="#{papersize}" #{@input} #{tell}\n}
306
+ when /pdftex/
307
+ "#{texpdf} -interaction=#{mode} -fmt=pdflatex #{@input} #{tell}\n"
308
+ when /pdflatex/
309
+ "#{texpdf} -interaction=#{mode} #{@input} #{tell}\n"
310
+ end
311
+ system(texpdf_cmd)
312
+ else STDERR.puts "\t*WARN* none of the following programs are installed: #{@texpdf}"
313
+ end
314
+ end
315
+ def makeinfo #texinfo
316
+ program='makeinfo'
317
+ options='' #'--force' #''
318
+ program_ref="\n\t\tsee http://www.gnu.org/software/texinfo/"
319
+ (program_found?(program)) \
320
+ ? system("#{program} #{options} #{@input}\n")
321
+ : (STDERR.puts "\t*WARN* #{program} is not installed #{program_ref}")
322
+ end
323
+ def scp
324
+ puts "scp -Cr #{@input} #{@output}" if @cmd =~/[vVM]/
325
+ puts "scp disabled"
326
+ end
327
+ def rsync(action='',chdir=nil)
328
+ program='rsync'
329
+ if program_found?(program)
330
+ vb=if @cmd =~/q/; 'q'
331
+ elsif @cmd =~/v/; 'v'
332
+ else ''
333
+ end
334
+ cX=SiSU_Screen::Ansi.new(@cmd).cX
335
+ msg=(@cmd =~/q/) ? '' : %{ && echo " #{cX.grey}OK: #{@input} -> #{@output}#{cX.off}"}
336
+ amp=(@opt \
337
+ && @opt.files.length > 1) \
338
+ ? ''
339
+ : ((@cmd =~/[vVM]/) ? '' : '&')
340
+ rsync_cmd="rsync -az#{vb} #{action} #{@input} #{@output}"
341
+ puts rsync_cmd if @cmd =~/[vVM]/
342
+ dir_change=dir_return=nil
343
+ if not chdir.nil? \
344
+ && chdir != Dir.pwd
345
+ dir_change=Dir.chdir(chdir)
346
+ dir_return=Dir.pwd
347
+ end
348
+ dir_change if dir_change
349
+ system("
350
+ #{rsync_cmd} #{msg} #{amp}
351
+ ")
352
+ dir_return if dir_return
353
+ else STDERR.puts "\t*WARN* #{program} not found"
354
+ end
355
+ end
356
+ def rm
357
+ if @cmd =~/^-Z[mMvVq]*$/; FileUtils::rm_rf(@input)
358
+ elsif @cmd =~/V/; FileUtils::rm(@input)
359
+ elsif @cmd !~/q/; FileUtils::rm(@input)
360
+ elsif @cmd =~/q/; FileUtils::rm(@input)
361
+ else STDERR.puts "\t*WARN* operation ignored"
362
+ end
363
+ end
364
+ end
365
+ end
366
+ module SiSU_Info_Program
367
+ require_relative 'constants' # constants.rb
368
+ require_relative 'utils' # utils.rb
369
+ require_relative 'se_info_env' # se_info_env.rb
370
+ class InfoProgram < SiSU_Info_Env::InfoEnv # se_info_env.rb
371
+ attr_accessor :editor,:wc,:tidy,:rexml,:pdflatex,:postgresql,:sqlite
372
+ def initialize
373
+ prog=SiSU_Env::InfoEnv.new.program
374
+ @editor, @wc, @tidy, @rexml, @pdflatex, @postgresql, @sqlite=
375
+ prog.text_editor,prog.wc,prog.tidy,prog.rexml,prog.pdflatex,prog.postgresql,prog.sqlite
376
+ end
377
+ end
378
+ end
379
+ module SiSU_Info_Set
380
+ require_relative 'se_info_env' # se_info_env.rb
381
+ class InfoSettings < SiSU_Info_Env::InfoEnv # se_info_env.rb
382
+ def permission?(prog) # program defaults
383
+ (defined? @rc['permission_set'][prog]) \
384
+ ? @rc['permission_set'][prog]
385
+ : false
386
+ end
387
+ def program?(prog) # program defaults
388
+ (defined? @rc['program_set'][prog]) \
389
+ ? @rc['program_set'][prog]
390
+ : false
391
+ end
392
+ end
393
+ end
394
+ __END__
@@ -0,0 +1,553 @@
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_remotes.rb;hb=HEAD>
55
+
56
+ =end
57
+ module SiSU_Info_Remote_Host
58
+ require_relative 'constants' # constants.rb
59
+ require_relative 'utils' # utils.rb
60
+ class InfoRemoteHost
61
+ def initialize
62
+ @rc=SiSU_Env::GetInit.new.sisu_yaml.rc
63
+ end
64
+ def remote_host #see InfoRemote remote_host_base_general
65
+ r=[]
66
+ r=if (defined? @rc['remote'] \
67
+ and @rc['remote'].is_a?(Array))
68
+ r_array=@rc['remote']
69
+ r_array.each_with_index do |renv,i|
70
+ r[i]={}
71
+ if defined? renv['user'] \
72
+ and defined? renv['host']
73
+ end
74
+ r[i][:user]=renv['user']
75
+ r[i][:host]=renv['host']
76
+ r[i][:path]=if defined? renv['path']
77
+ renv['path']
78
+ else ''
79
+ end
80
+ r[i][:name]="#{r[i][:user]}@#{r[i][:host]}:#{r[i][:path]}"
81
+ end
82
+ r
83
+ elsif (defined? @rc['remote'] \
84
+ and @rc['remote'].is_a?(Hash) \
85
+ and defined? @rc['remote']['user'] \
86
+ and defined? @rc['remote']['host'])
87
+ r[0]={}
88
+ r[0][:user]=@rc['remote']['user']
89
+ r[0][:host]=@rc['remote']['host']
90
+ r[0][:path]=if defined? @rc['remote']['path']
91
+ @rc['remote']['path']
92
+ else ''
93
+ end
94
+ r[0][:name]="#{r[0][:user]}@#{r[0][:host]}:#{r[0][:path]}"
95
+ r
96
+ else
97
+ r[0]={}
98
+ r[0][:name]='.'
99
+ r[0][:user]=''
100
+ r[0][:host]=''
101
+ r[0][:path]=''
102
+ #puts "no remote host or user"
103
+ r
104
+ end
105
+ end
106
+ def rhost
107
+ def r1
108
+ (defined? SiSU_Env::InfoRemoteHost.new.remote_host[0][:name]) \
109
+ ? (SiSU_Env::InfoRemoteHost.new.remote_host[0][:name])
110
+ : nil
111
+ end
112
+ def r2
113
+ (defined? SiSU_Env::InfoRemoteHost.new.remote_host[1][:name]) \
114
+ ? (SiSU_Env::InfoRemoteHost.new.remote_host[1][:name])
115
+ : nil
116
+ end
117
+ def r3
118
+ (defined? SiSU_Env::InfoRemoteHost.new.remote_host[2][:name]) \
119
+ ? (SiSU_Env::InfoRemoteHost.new.remote_host[2][:name])
120
+ : nil
121
+ end
122
+ def r4
123
+ (defined? SiSU_Env::InfoRemoteHost.new.remote_host[3][:name]) \
124
+ ? (SiSU_Env::InfoRemoteHost.new.remote_host[3][:name])
125
+ : nil
126
+ end
127
+ def r5
128
+ (defined? SiSU_Env::InfoRemoteHost.new.remote_host[4][:name]) \
129
+ ? (SiSU_Env::InfoRemoteHost.new.remote_host[4][:name])
130
+ : nil
131
+ end
132
+ def r6
133
+ (defined? SiSU_Env::InfoRemoteHost.new.remote_host[5][:name]) \
134
+ ? (@ls + SiSU_Env::InfoRemoteHost.new.remote_host[5][:name])
135
+ : nil
136
+ end
137
+ self
138
+ end
139
+ end
140
+ end
141
+ module SiSU_Info_Remote
142
+ require_relative 'constants' # constants.rb
143
+ require_relative 'utils' # utils.rb
144
+ require_relative 'se_filemap' # se_filemap.rb
145
+ begin
146
+ require 'fileutils'
147
+ include FileUtils::Verbose
148
+ rescue LoadError
149
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
150
+ error('fileutils NOT FOUND (LoadError)')
151
+ end
152
+ class InfoRemote < SiSU_File_Map::FileMap # se_filemap.rb
153
+ @@flag_remote=false
154
+ begin
155
+ require 'socket'
156
+ rescue LoadError
157
+ SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
158
+ error('socket NOT FOUND (LoadError)')
159
+ end
160
+ def initialize(opt)
161
+ super(opt) #
162
+ @opt=opt
163
+ @rc=GetInit.new.sisu_yaml.rc
164
+ end
165
+ def remote_host_base_general
166
+ SiSU_Env::InfoRemoteHost.new.remote_host
167
+ end
168
+ def remote_host_base
169
+ remote_host_base_general.each do |remote_conn|
170
+ @@flag_remote=true if remote_conn[:name] =~/\S+?@\S+/
171
+ end
172
+ remote_host_base_general
173
+ end
174
+ def scp #sort out later using ruby libraries #not ideal, first time each file is sent, -r must be called separately for subdir to be built
175
+ def document
176
+ self.remote_host_base.each do |remote_conn|
177
+ local_gen=@source_path
178
+ remote_gen=case @opt.cmd
179
+ when /u/
180
+ remote_conn[:name] + '/' \
181
+ + @env.path.base_markup_dir_stub + '/.' #creates remote directory tree, this is not the usual function of u
182
+ when /[abhHNopwxXy]/
183
+ remote_conn[:name] + '/' \
184
+ + @env.path.base_markup_dir_stub + '/' \
185
+ + @fnb + '/.'
186
+ else
187
+ remote_conn[:name] + '/' \
188
+ + @env.path.base_markup_dir_stub \
189
+ + '/.'
190
+ end
191
+ local_epub=@source_path_epub
192
+ local_src=@source_path_src
193
+ local_pod=@source_path_pod
194
+ remote_epub=
195
+ remote_conn[:name] + '/' + @env.path.stub_epub + '/.'
196
+ remote_src=
197
+ remote_conn[:name] + '/' + @env.path.stub_src + '/.'
198
+ remote_pod=
199
+ remote_conn[:name] + '/' + @env.path.stub_pod + '/.'
200
+ src_txt=@opt.fnc
201
+ src_pod=@opt.fncb.gsub(/(\.ss[mt])(?:\.sst)?$/,'\1.txz')
202
+ if (local_gen =~/\S/ \
203
+ and local_gen !~/\/\//) \
204
+ and (remote_gen =~/\S/ \
205
+ and remote_gen !~/\/\//) \
206
+ and @@flag_remote==true \
207
+ and @opt.cmd !~/U/
208
+ SiSU_Env::SystemCall.new(local_gen,remote_gen).scp
209
+ if FileTest.file?("#{local_src}/#{src_txt}")
210
+ SiSU_Env::SystemCall.new("#{local_src}/#{src_txt}",remote_src).scp
211
+ end
212
+ if FileTest.file?("#{local_pod}/#{src_pod}")
213
+ SiSU_Env::SystemCall.new("#{local_src}/#{src_pod}",remote_pod).scp
214
+ end
215
+ if FileTest.file?("#{local_epub}/#{@opt.fnb}.epub")
216
+ SiSU_Env::SystemCall.new(
217
+ "#{local_epub}/#{@opt.fnb}.epub",
218
+ remote_epub,@opt.cmd
219
+ ).scp
220
+ end
221
+ elsif @opt.cmd =~/U/
222
+ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
223
+ puts "#{local_gen} -> #{remote_gen}"
224
+ if FileTest.file?("#{local_src}/#{src_doc}")
225
+ puts "#{local_src}/#{src_doc}* -> #{remote_src}"
226
+ end
227
+ if FileTest.file?("#{local_pod}/#{src_doc}.txz")
228
+ puts "#{local_pod}/#{src_doc}* -> #{remote_pod}"
229
+ end
230
+ else
231
+ puts 'suspect scp request, ignored'
232
+ puts "#{local_gen} -> #{remote_gen} remote flag: #{@@flag_remote}"
233
+ puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
234
+ end
235
+ end
236
+ end
237
+ def site_base #base site
238
+ self.remote_host_base.each do |remote_conn|
239
+ local=@source_path
240
+ remote="#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/."
241
+ if defined? @rc['permission_set']['remote_base_site'] \
242
+ and @rc['permission_set']['remote_base_site'] \
243
+ and @@flag_remote==true \
244
+ and @opt.cmd !~/U/
245
+ puts "begin scp_base: #{local} -> #{remote}"
246
+ SiSU_Env::SystemCall.new("#{local}/#{@env.path.style}/",remote).scp
247
+ elsif @opt.cmd =~/U/
248
+ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
249
+ puts "begin scp_base: #{local} -> #{remote}"
250
+ puts "#{local}/#{@env.path.style}/ -> #{remote}"
251
+ else puts "permission not granted #{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
252
+ end
253
+ end
254
+ end
255
+ def site_base_all #base site
256
+ self.remote_host_base.each do |remote_conn|
257
+ local=@source_path
258
+ remote=
259
+ remote_conn[:name] + '/' \
260
+ + @env.path.base_markup_dir_stub + '/.'
261
+ if defined? @rc['permission_set']['remote_base_site'] \
262
+ and @rc['permission_set']['remote_base_site'] \
263
+ and @@flag_remote==true \
264
+ and @opt.cmd !~/U/
265
+ puts "begin scp_base_all: #{local} -> #{remote}"
266
+ SiSU_Env::SystemCall.new("#{local}/_sisu/image_sys/",remote).scp
267
+ SiSU_Env::SystemCall.new("#{local}/_sisu/image/",remote).scp
268
+ SiSU_Env::SystemCall.new("#{local}/#{@env.path.style}/",remote).scp
269
+ elsif @opt.cmd =~/U/
270
+ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
271
+ puts "scp_base_all: #{local} -> #{remote}"
272
+ puts "#{local}/_sisu/image_sys/ -> #{remote}"
273
+ puts "#{local}/_sisu/image/ -> #{remote}"
274
+ puts "#{local}/#{@env.path.style}/ -> #{remote}"
275
+ else
276
+ puts "permission not granted #{__FILE__} #{__LINE__}" \
277
+ if @opt.cmd =~/M/
278
+ end
279
+ end
280
+ end
281
+ self
282
+ end
283
+ def rsync
284
+ def document
285
+ f=(@opt.act[:ao][:set]==:on) \
286
+ ? SiSU_Env::FileOp.new(@md)
287
+ : nil
288
+ if f
289
+ self.remote_host_base.each do |remote_conn|
290
+ local_gen=@source_path
291
+ #local_gen_image="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/image"
292
+ #local_gen_image_external="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}/_sisu/image_external"
293
+ remote_gen=
294
+ remote_conn[:name] + '/' \
295
+ + @env.path.base_markup_dir_stub + '/.'
296
+ remote_rel=
297
+ remote_conn[:name] + '/' \
298
+ + f.output_path.stub.rcp
299
+ @opt.fnc
300
+ if (local_gen =~/\S/ \
301
+ and local_gen !~/\/\//) \
302
+ and (remote_gen =~/\S/ \
303
+ and remote_gen !~/\/\//) \
304
+ and @@flag_remote==true \
305
+ and @opt.cmd !~/U/
306
+ # SiSU_Env::SystemCall.new("#{local_src}/#{src_txt}",remote_src,@opt.cmd).rsync
307
+ #delete_extra_files='--delete' # '--delete-after'
308
+ inp=[]
309
+ if (@opt.act[:html][:set]==:on \
310
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
311
+ && FileTest.file?(f.place_file.html_scroll.dir)
312
+ inp \
313
+ << f.output_path.html_seg.rel \
314
+ << f.place_file.html_scroll.rel
315
+ end
316
+ if (@opt.act[:concordance][:set]==:on \
317
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
318
+ && FileTest.file?(f.place_file.html_concordance.dir)
319
+ inp << f.place_file.html_concordance.rel
320
+ end
321
+ if (@opt.act[:epub][:set]==:on \
322
+ || @opt.cmd =~/^-R[mqvVM]*$/) \
323
+ && FileTest.file?(f.place_file.epub.dir)
324
+ inp << f.place_file.epub.rel
325
+ end
326
+ if (@opt.act[:odt][:set]==:on \
327
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
328
+ && FileTest.file?(f.place_file.odt.dir)
329
+ inp << f.place_file.odt.rel
330
+ end
331
+ if (@opt.act[:xhtml][:set]==:on \
332
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
333
+ && FileTest.file?(f.place_file.xhtml.dir)
334
+ inp << f.place_file.xhtml.rel
335
+ end
336
+ if (@opt.act[:xml_sax][:set]==:on \
337
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
338
+ && FileTest.file?(f.place_file.xml_sax.dir)
339
+ inp << f.place_file.xml_sax.rel
340
+ end
341
+ if (@opt.act[:xml_dom][:set]==:on \
342
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
343
+ && FileTest.file?(f.place_file.xml_dom.dir)
344
+ inp << f.place_file.xml_dom.rel
345
+ end
346
+ if (@opt.act[:xml_scaffold_structure_sisu][:set]==:on \
347
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
348
+ && FileTest.file?(f.place_file.xml_scaffold_structure_sisu.dir)
349
+ inp << f.place_file.xml_scaffold_structure_sisu.rel
350
+ end
351
+ if (@opt.act[:xml_scaffold_structure_collapse][:set]==:on \
352
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
353
+ && FileTest.file?(f.place_file.xml_scaffold_structure_collapse.dir)
354
+ inp << f.place_file.xml_scaffold_structure_collapse.rel
355
+ end
356
+ if (@opt.act[:txt][:set]==:on \
357
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
358
+ && FileTest.file?(f.place_file.txt.dir)
359
+ inp << f.place_file.txt.rel
360
+ end
361
+ if (@opt.act[:manpage][:set]==:on \
362
+ || @opt.cmd =~/^-[mqvVM]*i[mqvVM]*$/) \
363
+ && FileTest.file?(f.place_file.manpage.dir)
364
+ inp << f.place_file.manpage.rel
365
+ end
366
+ if (@opt.act[:texinfo][:set]==:on \
367
+ || @opt.cmd =~/^-[mqvVM]*I[mqvVM]*$/) \
368
+ && FileTest.file?(f.place_file.info.dir)
369
+ inp << f.place_file.info.rel
370
+ end
371
+ if (@opt.act[:hash_digests][:set]==:on \
372
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
373
+ && FileTest.file?(f.place_file.hash_digest.dir)
374
+ inp << f.place_file.hash_digest.rel
375
+ end
376
+ if (@opt.act[:share_source][:set]==:on \
377
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
378
+ && FileTest.file?(f.place_file.src.dir)
379
+ inp << f.place_file.src.rel
380
+ end
381
+ if (@opt.act[:sisupod][:set]==:on \
382
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
383
+ && FileTest.file?(f.place_file.sisupod.dir)
384
+ inp << f.place_file.sisupod.rel
385
+ end
386
+ if (@opt.act[:pdf][:set]==:on \
387
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/)
388
+ inp <<=(@opt.dir_structure_by == :filename) \
389
+ ? (f.output_path.pdf.rel + '/*.pdf')
390
+ : (f.output_path.pdf.rel + '/' + @opt.fnb + '*.pdf')
391
+ end
392
+ if (@opt.act[:sqlite_discrete][:set]==:on \
393
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
394
+ && FileTest.file?(f.place_file.sqlite_discrete.dir)
395
+ inp << f.place_file.sqlite_discrete.rel
396
+ end
397
+ if (@opt.act[:qrcode][:set]==:on \
398
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
399
+ && FileTest.file?(f.place_file.qrcode_md.dir)
400
+ inp \
401
+ << f.place_file.qrcode_md.rel \
402
+ << f.place_file.qrcode_title.rel
403
+ end
404
+ if (@opt.act[:manifest][:set]==:on \
405
+ || @opt.cmd =~/^-[mqvVM]*R[mqvVM]*$/) \
406
+ && FileTest.file?(f.place_file.manifest.dir)
407
+ inp << f.place_file.manifest.rel
408
+ end
409
+ local_gen=if inp.length > 0
410
+ inp.join(' ')
411
+ else ''
412
+ end
413
+ local_css,images,images_system='','',''
414
+ images=images_skin=images_system=local_css=''
415
+ if @opt.cmd =~/[hwbxX]/ \
416
+ && (defined? @md.ec[:image]) \
417
+ && (@md.ec[:image].length > 0)
418
+ images=
419
+ f.place_file.images.rel + '/' \
420
+ + @md.ec[:image].join(" #{f.output_path.images.rel}/")
421
+ end
422
+ if @opt.cmd =~/[yhwbxX]/ \
423
+ && (defined? @md.ec[:image]) \
424
+ && (@md.ec[:image].length > 0)
425
+ local_css=f.output_path.css.rel
426
+ images_system='_sisu/image_sys'
427
+ end
428
+ begin
429
+ ##create file structure without copying files?:
430
+ ##rsync -av -f"+ */" -f"- *" f.output_path.base.dir remote:./path/.
431
+ #local_dirs=%{-f"+ */" -f"- *" #{f.output_path.base.dir}/*}
432
+ #SiSU_Env::SystemCall.new(local_dirs,remote_gen,@opt.cmd).rsync
433
+ local=local_gen + ' ' + images + ' ' + images_skin + ' ' + images_system + ' ' + local_css
434
+ SiSU_Env::SystemCall.new(local,remote_rel,@opt.cmd).
435
+ rsync('--relative',f.output_path.base.dir)
436
+ rescue
437
+ p __LINE__.to_s + ':' + __FILE__
438
+ local_dirs=%{--include='*/' --exclude='*' #{f.output_path.base.dir}}
439
+ SiSU_Env::SystemCall.new(local_dirs,remote_gen,@opt.cmd).rsync
440
+ end
441
+ elsif @opt.cmd =~/U/
442
+ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
443
+ puts "#{local_gen} -> #{remote_gen}"
444
+ if FileTest.file?("#{local_src}/#{src_doc}") \
445
+ or FileTest.file?("#{local_src}/#{src_doc}.txz")
446
+ puts "#{local_src}/#{src_doc}* -> #{remote_src}"
447
+ end
448
+ else
449
+ puts 'suspect rsync request, ignored'
450
+ puts "#{local_gen} -> #{remote_gen} remote flag: #{@@flag_remote}"
451
+ puts "permission not granted #{__FILE__} #{__LINE__}" \
452
+ if @opt.cmd =~/M/
453
+ end
454
+ end
455
+ end
456
+ end
457
+ def site_harvest
458
+ self.remote_host_base.each do |remote_conn|
459
+ local=@source_path_harvest
460
+ l_rel="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}"
461
+ lng='en'
462
+ if @env.output_dir_structure.by? == :language
463
+ ldest=lng + '/manifest'
464
+ files=
465
+ ldest + '/authors.html' + ' ' \
466
+ + ldest + '/topics.html'
467
+ elsif @env.output_dir_structure.by? == :filetype
468
+ ldest="manifest"
469
+ files=
470
+ ldest + '/authors.' + lng + '.html' + ' ' \
471
+ + ldest + '/topics.' + lng + '.html'
472
+ elsif @env.output_dir_structure.by? == :filename
473
+ files=
474
+ l_rel + '/authors.' + lng + '.html' + ' ' \
475
+ + l_rel + '/topics.' + lng + '.html'
476
+ end
477
+ remote="#{remote_conn[:name]}/#{@opt.base_stub}"
478
+ if @opt.act[:harvest][:set] \
479
+ && @opt.act[:rsync][:set]
480
+ (@env.output_dir_structure.by? == :filename) \
481
+ ? (SiSU_Env::SystemCall.new(files,remote).rsync)
482
+ : (SiSU_Env::SystemCall.new(ldest,remote).
483
+ rsync('--relative',l_rel))
484
+ elsif @opt.cmd =~/U/
485
+ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
486
+ puts "rsync_harvest: #{local} -> #{remote}"
487
+ else
488
+ puts "permission not granted #{__FILE__} #{__LINE__}" \
489
+ if @opt.cmd =~/M/
490
+ end
491
+ end
492
+ end
493
+ def site_base #base site
494
+ ldest='_sisu/*'
495
+ l_rel="#{@env.path.webserv}/#{@env.path.base_markup_dir_stub}"
496
+ image_sys="#{@env.path.webserv}/_sisu/image_sys"
497
+ self.remote_host_base.each do |remote_conn|
498
+ remote="#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}"
499
+ remote_conf="#{remote_conn[:name]}/_sisu"
500
+ SiSU_Env::SystemCall.new(image_sys,remote_conf).rsync
501
+ SiSU_Env::SystemCall.new(ldest,remote).rsync('--relative',l_rel)
502
+ end
503
+ end
504
+ def site_base_sync
505
+ self.remote_host_base.each do |remote_conn|
506
+ local=@source_path
507
+ remote="#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/."
508
+ if defined? @rc['permission_set']['remote_base_site'] \
509
+ and @rc['permission_set']['remote_base_site'] \
510
+ and @@flag_remote==true \
511
+ and @opt.cmd !~/U/
512
+ delete_extra_files='--delete' # '--delete-after'
513
+ puts "begin rsync_base_sync: #{local} -> #{remote}"
514
+ SiSU_Env::SystemCall.new("#{local}/_sisu/image_sys/",remote).
515
+ rsync(delete_extra_files)
516
+ SiSU_Env::SystemCall.new("#{local}/_sisu/image/",remote).
517
+ rsync(delete_extra_files)
518
+ SiSU_Env::SystemCall.new("#{local}/#{@env.path.style}/",remote).
519
+ rsync(delete_extra_files)
520
+ elsif @opt.cmd =~/U/
521
+ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
522
+ puts "rsync_base_sync: #{local} -> #{remote}"
523
+ puts "#{local}/_sisu/image_sys/ -> #{remote}"
524
+ puts "#{local}/_sisu/image/ -> #{remote}"
525
+ puts "#{local}/#{@env.path.style}/ -> #{remote}"
526
+ else
527
+ puts "permission not granted #{__FILE__} #{__LINE__}" \
528
+ if @opt.cmd =~/M/
529
+ end
530
+ end
531
+ end
532
+ self
533
+ end
534
+ def rsync_sitemaps #sitemap directory
535
+ self.remote_host_base.each do |remote_conn|
536
+ local=
537
+ @source_path + '/sitemapindex.xml'
538
+ remote="#{remote_conn[:name]}/#{@env.path.base_markup_dir_stub}/."
539
+ if @@flag_remote
540
+ delete_extra_files='--delete' # '--delete-after'
541
+ SiSU_Env::SystemCall.new(local,remote).rsync(delete_extra_files)
542
+ elsif @opt.cmd =~/U/
543
+ puts "#{__FILE__} #{__LINE__}" if @opt.cmd =~/M/
544
+ puts "rsync_sitemaps: #{local} -> #{remote}"
545
+ else
546
+ puts "permission not granted #{__FILE__} #{__LINE__}" \
547
+ if @opt.cmd =~/M/
548
+ end
549
+ end
550
+ end
551
+ end
552
+ end
553
+ __END__