d: composite documents (.ssm), extract insert files list
[software/sisu] / lib / sisu / develop / hub_actions.rb
1 # encoding: utf-8
2 =begin
3
4 * Name: SiSU
5
6 ** Description: documents, structuring, processing, publishing, search
7 *** hub, perform selected actions
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/develop/hub_actions.rb;hb=HEAD>
55
56 =end
57 module SiSU_Hub_Actions
58 class HubActions
59 require_relative 'utils_composite' # utils_composite.rb
60 include SiSU_Composite_Doc_Utils # composite doc, .ssm, extract all related insert files, array of filenames test
61 def initialize(opt)
62 @opt=opt
63 end
64 def report
65 def version_info?
66 if @opt.act[:version_info][:set]==:on
67 SiSU_Env::InfoAbout.new(@opt).sisu_version
68 end
69 end
70 def version_dir?
71 if @opt.act[:version_info][:set]==:on \
72 || @opt.act[:verbose][:set]==:on \
73 || @opt.act[:verbose_plus][:set]==:on \
74 || @opt.act[:maintenance][:set]==:on
75 SiSU_Screen::Ansi.new(
76 @opt.act[:color_state][:set],
77 ' ' + File.dirname(__FILE__)
78 ).grey
79 end
80 end
81 self
82 end
83 def prepare
84 def site?
85 if @opt.act[:site_init][:set]==:on #% --init-site, -C initialize/configure
86 require_relative 'conf' #% --init-site, -C initialize/configure
87 SiSU_Initialize::Source.new(@opt).read
88 if @opt.act[:rsync][:set]==:on
89 if @opt.selections.str =~/--init(?:ialize)?=site/ \
90 and @opt.selections.str =~/RZ/
91 SiSU_Hub_Actions::Operations.new(@opt).remote_put_base_site_rsync_match
92 else SiSU_Hub_Actions::Operations.new(@opt).remote_put_base_site_rsync
93 end
94 elsif @opt.act[:scp][:set]==:on
95 if @opt.selections.str =~/--init(?:ialize)?=site/ \
96 and @opt.selections.str =~/CCr/
97 SiSU_Hub_Actions::Operations.new(@opt).remote_put_base_site_all
98 else SiSU_Hub_Actions::Operations.new(@opt).remote_put_base_site
99 end
100 end
101 end
102 end
103 def remote_site?
104 if @opt.act[:site_init][:set]==:on
105 if @opt.act[:site_init][:set]==:on #% --init-site, -C initialize/configure
106 #require_relative 'conf' #% --init-site, -C initialize/configure
107 #SiSU_Initialize::Source.new(@opt).read
108 #if @opt.act[:rsync][:set]==:on
109 # if @opt.selections.str =~/--init(?:ialize)?=site/ \
110 # and @opt.selection =~/RZ/
111 # SiSU_Hub_Actions::Operations.new(@opt).remote_put_base_site_rsync_match
112 # else SiSU_Hub_Actions::Operations.new(@opt).remote_put_base_site_rsync
113 # end
114 #elsif @opt.act[:scp][:set]==:on
115 # if @opt.selections.str =~/--init(?:ialize)?=site/ \
116 # and @opt.selection =~/CCr/
117 # SiSU_Hub_Actions::Operations.new(@opt).remote_put_base_site_all
118 # else SiSU_Hub_Actions::Operations.new(@opt).remote_put_base_site
119 # end
120 #end
121 end
122 end
123 end
124 def sql?
125 if @opt.act[:psql_createdb][:set]==:on \
126 or @opt.act[:psql_create][:set]==:on \
127 or @opt.act[:psql_drop][:set]==:on
128 done=:ok
129 if @opt.act[:psql][:set]==:on
130 require_relative 'dbi'
131 SiSU_DBI::SQL.new(@opt).connect
132 end
133 end
134 if @opt.act[:sqlite_createdb][:set]==:on \
135 or @opt.act[:sqlite_create][:set]==:on \
136 or @opt.act[:sqlite_drop][:set]==:on
137 done=:ok
138 if @opt.act[:sqlite][:set]==:on
139 require_relative 'dbi'
140 SiSU_DBI::SQL.new(@opt).connect
141 end
142 end
143 end
144 def search_form?
145 if @opt.act[:sample_search_form][:set]==:on #% --sample-search-form, -F cgi sample search form
146 SiSU_Hub_Actions::Operations.new(@opt).cgi
147 end
148 end
149 def webrick?
150 if @opt.act[:webrick][:set]==:on #% --webrick, -W webrick
151 SiSU_Hub_Actions::Operations.new(@opt).webrick
152 end
153 end
154 self
155 end
156 def outputs
157 def each_file
158 def abstract_objects?
159 if @opt.act[:ao][:set]==:on #% --ao --dal, -m
160 if @opt.f_pths.length > 0
161 unless @opt.act[:po4a][:set]==:on # --po4a, -P
162 if @opt.fno =~ /\.ssm$/
163 require_relative 'ao_composite' # ao_composite.rb #pre-processing
164 SiSU_Assemble::Composite.new(@opt).read
165 end
166 require_relative 'ao' # ao.rb
167 SiSU_AO::Source.new(@opt).read
168 end
169 else
170 msg='document abstraction request requires sisu markup files'
171 if (@opt.act[:verbose_plus][:set]==:on \
172 || @opt.act[:maintenance][:set]==:on)
173 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
174 mark(msg)
175 else puts msg
176 end
177 end
178 end
179 end
180 def qrcode?
181 if @opt.act[:qrcode][:set]==:on #% --qrcode, -Q
182 if @opt.f_pths.length > 0
183 require_relative 'qrcode' # qrcode.rb
184 SiSU_QRcode::Source.new(@opt).read
185 else
186 msg='qrcode request requires sisu markup files'
187 if (@opt.act[:verbose_plus][:set]==:on \
188 || @opt.act[:maintenance][:set]==:on)
189 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
190 mark(msg)
191 else puts msg
192 end
193 end
194 end
195 end
196 def hash_digests?
197 if @opt.act[:hash_digests][:set]==:on #% --hash-digests, -N digest tree
198 if @opt.f_pths.length > 0
199 require_relative 'digests' # digests.rb
200 SiSU_DigestView::Source.new(@opt).read
201 else
202 msg='hash digest request requires sisu markup files'
203 if (@opt.act[:verbose_plus][:set]==:on \
204 || @opt.act[:maintenance][:set]==:on)
205 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
206 mark(msg)
207 else puts msg
208 end
209 end
210 end
211 end
212 def text?
213 if @opt.act[:txt][:set]==:on #% --txt, -t -a
214 if @opt.f_pths.length > 0
215 require_relative 'txt_plain' # txt_plain.rb
216 SiSU_Txt_Plain::Source.new(@opt).read
217 else
218 msg='text request requires sisu markup files'
219 if (@opt.act[:verbose_plus][:set]==:on \
220 || @opt.act[:maintenance][:set]==:on)
221 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
222 mark(msg)
223 else puts msg
224 end
225 end
226 end
227 if @opt.act[:txt_textile][:set]==:on #% --textile
228 if @opt.f_pths.length > 0
229 require_relative 'txt_textile' #txt_textile.rb
230 SiSU_Txt_Textile::Source.new(@opt).read
231 else
232 msg='textile request requires sisu markup files'
233 if (@opt.act[:verbose_plus][:set]==:on \
234 || @opt.act[:maintenance][:set]==:on)
235 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
236 mark(msg)
237 else puts msg
238 end
239 end
240 end
241 if @opt.act[:txt_asciidoc][:set]==:on #% --asciidoc
242 if @opt.f_pths.length > 0
243 require_relative 'txt_asciidoc' # txt_asciidoc.rb
244 SiSU_Txt_AsciiDoc::Source.new(@opt).read
245 else
246 msg='asciidoc request requires sisu markup files'
247 if (@opt.act[:verbose_plus][:set]==:on \
248 || @opt.act[:maintenance][:set]==:on)
249 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
250 mark(msg)
251 else puts msg
252 end
253 end
254 end
255 if @opt.act[:txt_markdown][:set]==:on #% --markdown
256 if @opt.f_pths.length > 0
257 require_relative 'txt_markdown' # txt_markdown.rb
258 SiSU_Txt_Markdown::Source.new(@opt).read
259 else
260 msg='markdown request requires sisu markup files'
261 if (@opt.act[:verbose_plus][:set]==:on \
262 || @opt.act[:maintenance][:set]==:on)
263 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
264 mark(msg)
265 else puts msg
266 end
267 end
268 end
269 if @opt.act[:txt_rst][:set]==:on #% --rst, --rest
270 if @opt.f_pths.length > 0
271 require_relative 'txt_rst' # txt_rst.rb
272 SiSU_Txt_rST::Source.new(@opt).read
273 else
274 msg='rst request requires sisu markup files'
275 if (@opt.act[:verbose_plus][:set]==:on \
276 || @opt.act[:maintenance][:set]==:on)
277 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
278 mark(msg)
279 else puts msg
280 end
281 end
282 end
283 if @opt.act[:txt_orgmode][:set]==:on #% --orgmode
284 if @opt.f_pths.length > 0
285 require_relative 'txt_orgmode' # txt_orgmode.rb
286 SiSU_Txt_OrgMode::Source.new(@opt).read
287 else
288 msg='orgmode request requires sisu markup files'
289 if (@opt.act[:verbose_plus][:set]==:on \
290 || @opt.act[:maintenance][:set]==:on)
291 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
292 mark(msg)
293 else puts msg
294 end
295 end
296 end
297 end
298 def html?
299 if @opt.act[:html][:set]==:on #% --html, -h
300 if @opt.f_pths.length > 0
301 require_relative 'html' # html.rb
302 SiSU_HTML::Source.new(@opt).read
303 else
304 msg='html request requires sisu markup files'
305 if (@opt.act[:verbose_plus][:set]==:on \
306 || @opt.act[:maintenance][:set]==:on)
307 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
308 mark(msg)
309 else puts msg
310 end
311 end
312 else
313 if @opt.act[:html_seg][:set]==:on #% --html-seg
314 if @opt.f_pths.length > 0
315 require_relative 'html' # html.rb
316 SiSU_HTML::Source.new(@opt).read
317 else
318 msg='html seg request requires sisu markup files'
319 if (@opt.act[:verbose_plus][:set]==:on \
320 || @opt.act[:maintenance][:set]==:on)
321 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
322 mark(msg)
323 else puts msg
324 end
325 end
326 end
327 if @opt.act[:html_scroll][:set]==:on #% --html-scroll
328 if @opt.f_pths.length > 0
329 require_relative 'html' # html.rb
330 SiSU_HTML::Source.new(@opt).read
331 else
332 msg='html scroll request requires sisu markup files'
333 if (@opt.act[:verbose_plus][:set]==:on \
334 || @opt.act[:maintenance][:set]==:on)
335 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
336 mark(msg)
337 else puts msg
338 end
339 end
340 end
341 end
342 if @opt.act[:concordance][:set]==:on #% --concordance, -w
343 if @opt.f_pths.length > 0
344 require_relative 'html_concordance' # html_concordance.rb
345 SiSU_Concordance::Source.new(@opt).read
346 else
347 msg='concordance request requires sisu markup files'
348 if (@opt.act[:verbose_plus][:set]==:on \
349 || @opt.act[:maintenance][:set]==:on)
350 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
351 mark(msg)
352 else puts msg
353 end
354 end
355 end
356 end
357 def xhtml?
358 if @opt.act[:xhtml][:set]==:on #% --xhtml, -b
359 if @opt.f_pths.length > 0
360 require_relative 'xhtml' # xhtml.rb
361 SiSU_XHTML::Source.new(@opt).read
362 else
363 msg='xhtml request requires sisu markup files'
364 if (@opt.act[:verbose_plus][:set]==:on \
365 || @opt.act[:maintenance][:set]==:on)
366 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
367 mark(msg)
368 else puts msg
369 end
370 end
371 end
372 if @opt.act[:epub][:set]==:on #% --epub, -e
373 if @opt.f_pths.length > 0
374 require_relative 'xhtml_epub2' # xhtml_epub2.rb
375 SiSU_XHTML_EPUB2::Source.new(@opt).read
376 else
377 msg='epub request requires sisu markup files'
378 if (@opt.act[:verbose_plus][:set]==:on \
379 || @opt.act[:maintenance][:set]==:on)
380 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
381 mark(msg)
382 else puts msg
383 end
384 end
385 end
386 end
387 def xml?
388 if @opt.act[:odt][:set]==:on #% --odt, -o
389 if @opt.f_pths.length > 0
390 require_relative 'xml_odf_odt' # xml_odf_odt.rb
391 SiSU_XML_ODF_ODT::Source.new(@opt).read
392 else
393 msg='odt request requires sisu markup files'
394 if (@opt.act[:verbose_plus][:set]==:on \
395 || @opt.act[:maintenance][:set]==:on)
396 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
397 mark(msg)
398 else puts msg
399 end
400 end
401 end
402 if @opt.act[:xml_scaffold_structure_sisu][:set]==:on #% --xml-scaffold --xml-scaffold-sisu
403 if @opt.f_pths.length > 0
404 require_relative 'xml_scaffold_structure_sisu' # xml_scaffold_structure_sisu.rb
405 SiSU_XML_Scaffold_Structure_Sisu::Source.new(@opt).read
406 else
407 msg='xml scaffold request requires sisu markup files'
408 if (@opt.act[:verbose_plus][:set]==:on \
409 || @opt.act[:maintenance][:set]==:on)
410 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
411 mark(msg)
412 else puts msg
413 end
414 end
415 end
416 if @opt.act[:xml_scaffold_structure_collapse][:set]==:on #% --xml-scaffold-collapse
417 if @opt.f_pths.length > 0
418 require_relative 'xml_scaffold_structure_collapsed' # xml_scaffold_structure_collapsed.rb
419 SiSU_XML_Scaffold_Structure_Collapse::Source.new(@opt).read
420 else
421 msg='xml scaffold request requires sisu markup files'
422 if (@opt.act[:verbose_plus][:set]==:on \
423 || @opt.act[:maintenance][:set]==:on)
424 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
425 mark(msg)
426 else puts msg
427 end
428 end
429 end
430 if @opt.act[:xml_docbook_book][:set]==:on #% --xml-docbook
431 if @opt.f_pths.length > 0
432 require_relative 'xml_docbook5' # xml_docbook5.rb
433 SiSU_XML_Docbook_Book::Source.new(@opt).read
434 else
435 msg='docbook request requires sisu markup files'
436 if (@opt.act[:verbose_plus][:set]==:on \
437 || @opt.act[:maintenance][:set]==:on)
438 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
439 mark(msg)
440 else puts msg
441 end
442 end
443 end
444 if @opt.act[:xml_fictionbook][:set]==:on #% --xml-fictionbook
445 if @opt.f_pths.length > 0
446 require_relative 'xml_fictionbook2' # xml_fictionbook2.rb
447 SiSU_XML_Fictionbook::Source.new(@opt).read
448 else
449 msg='fictionbook request requires sisu markup files'
450 if (@opt.act[:verbose_plus][:set]==:on \
451 || @opt.act[:maintenance][:set]==:on)
452 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
453 mark(msg)
454 else puts msg
455 end
456 end
457 end
458 if @opt.act[:xml_sax][:set]==:on #% --xml-sax, -x
459 if @opt.f_pths.length > 0
460 require_relative 'xml_sax' # xml_sax.rb
461 SiSU_XML_SAX::Source.new(@opt).read
462 else
463 msg='xml sax request requires sisu markup files'
464 if (@opt.act[:verbose_plus][:set]==:on \
465 || @opt.act[:maintenance][:set]==:on)
466 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
467 mark(msg)
468 else puts msg
469 end
470 end
471 end
472 if @opt.act[:xml_dom][:set]==:on #% --xml-dom, -X
473 if @opt.f_pths.length > 0
474 require_relative 'xml_dom' # xml_dom.rb
475 SiSU_XML_DOM::Source.new(@opt).read
476 else
477 msg='xml dom request requires sisu markup files'
478 if (@opt.act[:verbose_plus][:set]==:on \
479 || @opt.act[:maintenance][:set]==:on)
480 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
481 mark(msg)
482 else puts msg
483 end
484 end
485 end
486 end
487 def pdf?
488 if @opt.act[:pdf][:set]==:on \
489 or @opt.act[:pdf_p][:set]==:on \
490 or @opt.act[:pdf_l][:set]==:on #% --pdf-l --pdf, -p
491 if @opt.f_pths.length > 0
492 require_relative 'texpdf' # texpdf.rb
493 SiSU_TeX::Source.new(@opt).read
494 else
495 msg='pdf request requires sisu markup files'
496 if (@opt.act[:verbose_plus][:set]==:on \
497 || @opt.act[:maintenance][:set]==:on)
498 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
499 mark(msg)
500 else puts msg
501 end
502 end
503 end
504 end
505 def man_or_info?
506 if @opt.act[:manpage][:set]==:on #% --manpage, -i
507 if @opt.f_pths.length > 0
508 require_relative 'manpage' # manpage.rb
509 SiSU_Manpage::Source.new(@opt).read
510 else
511 msg='manpage request requires sisu markup files'
512 if (@opt.act[:verbose_plus][:set]==:on \
513 || @opt.act[:maintenance][:set]==:on)
514 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
515 mark(msg)
516 else puts msg
517 end
518 end
519 end
520 if @opt.act[:texinfo][:set]==:on #% --texinfo, -I
521 if @opt.f_pths.length > 0
522 require_relative 'texinfo' # texinfo.rb
523 SiSU_TexInfo::Source.new(@opt).read
524 else
525 msg='texinfo request requires sisu markup files'
526 if (@opt.act[:verbose_plus][:set]==:on \
527 || @opt.act[:maintenance][:set]==:on)
528 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
529 mark(msg)
530 else puts msg
531 end
532 end
533 end
534 end
535 def sqlite_discrete?
536 if @opt.act[:sqlite_discrete][:set]==:on #% --sqlite, -d
537 if @opt.f_pths.length > 0
538 require_relative 'dbi_discrete' # dbi_discrete.rb
539 SiSU_DBI_Discrete::SQL.new(@opt).build
540 else
541 msg='sqlite (discrete) request requires sisu markup files'
542 if (@opt.act[:verbose_plus][:set]==:on \
543 || @opt.act[:maintenance][:set]==:on)
544 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
545 mark(msg)
546 else puts msg
547 end
548 end
549 end
550 end
551 def manifest?
552 if @opt.act[:manifest][:set]==:on #% --manifest, -y
553 if @opt.f_pths.length > 0
554 require_relative 'html_manifest' # html_manifest.rb
555 ((@opt.act[:sisupod][:set]==:on \
556 || @opt.act[:share_source][:set]==:on) \
557 && @opt.f_pths.length < 2 ) \
558 ? nil
559 : SiSU_Manifest::Source.new(@opt).read
560 else
561 msg='manifest request requires sisu markup files'
562 if (@opt.act[:verbose_plus][:set]==:on \
563 || @opt.act[:maintenance][:set]==:on)
564 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
565 mark(msg)
566 else puts msg
567 end
568 end
569 end
570 end
571 def harvest?
572 if @opt.act[:harvest][:set]==:on #% --harvest
573 if @opt.f_pths.length > 0
574 require_relative 'html_harvest' # html_harvest.rb
575 SiSU_Harvest::Source.new(@opt).read
576 else
577 msg='harvest request requires sisu markup files'
578 if (@opt.act[:verbose_plus][:set]==:on \
579 || @opt.act[:maintenance][:set]==:on)
580 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:yellow).
581 mark(msg)
582 else puts msg
583 end
584 end
585 end
586 end
587 self
588 end
589 def loop_files
590 def share_source?
591 if @opt.act[:share_source][:set]==:on \
592 or @opt.act[:sisupod][:set]==:on \
593 or @opt.act[:git][:set]==:on
594 begin
595 if @opt.f_pths.length > 0
596 require_relative 'src_shared'
597 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
598 loop_files_on_given_option do
599 SiSU_Source::SiSUpodSource.new(@opt).read
600 end
601 else
602 msg='share markup source request requires sisu markup files'
603 if (@opt.act[:verbose_plus][:set]==:on \
604 || @opt.act[:maintenance][:set]==:on)
605 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
606 mark(msg)
607 else puts msg
608 end
609 end
610 if @opt.act[:share_source][:set]==:on
611 if @opt.f_pths.length > 0
612 require_relative 'src_share' # src_share.rb
613 begin
614 ensure
615 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
616 loop_files_on_given_option_bundle do
617 SiSU_Markup::Source.new(@opt).read
618 end
619 end
620 else
621 msg='share markup source request requires sisu markup files'
622 if (@opt.act[:verbose_plus][:set]==:on \
623 || @opt.act[:maintenance][:set]==:on)
624 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
625 mark(msg)
626 else puts msg
627 end
628 end
629 end
630 if @opt.act[:sisupod][:set]==:on #% --sisupod, -S
631 if @opt.f_pths.length > 0
632 require_relative 'src_sisupod_make' # src_sisupod_make.rb
633 begin
634 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
635 loop_files_on_given_option_bundle do
636 SiSU_Doc::Source.new(@opt).sisupod_tar_xz
637 end
638 ensure
639 end
640 else
641 msg='sisupod (share markup source) request requires sisu markup files'
642 if (@opt.act[:verbose_plus][:set]==:on \
643 || @opt.act[:maintenance][:set]==:on)
644 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
645 mark(msg)
646 else puts msg
647 end
648 end
649 end
650 if @opt.act[:git][:set]==:on #% --git, -g
651 if @opt.f_pths.length > 0
652 require_relative 'git' # git.rb
653 begin
654 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
655 loop_files_on_given_option do
656 SiSU_Git::Source.new(@opt).read
657 end
658 ensure
659 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
660 loop_files_on_given_option_bundle do
661 SiSU_Git::Source.new(@opt).git_commit
662 end
663 end
664 else
665 msg='git request requires sisu markup files'
666 if (@opt.act[:verbose_plus][:set]==:on \
667 || @opt.act[:maintenance][:set]==:on)
668 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
669 mark(msg)
670 else puts msg
671 end
672 end
673 end
674 if (@opt.act[:sisupod][:set]==:on \
675 || @opt.act[:share_source][:set]==:on) \
676 and @opt.act[:manifest][:set]==:on #% --manifest, -y
677 if @opt.f_pths.length > 0
678 require_relative 'html_manifest' # html_manifest.rb
679 begin
680 ensure
681 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
682 loop_files_on_given_option_bundle do
683 SiSU_Manifest::Source.new(@opt).read
684 end
685 end
686 else
687 msg='manifest request requires sisu markup files'
688 if (@opt.act[:verbose_plus][:set]==:on \
689 || @opt.act[:maintenance][:set]==:on)
690 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
691 mark(msg)
692 else puts msg
693 end
694 end
695 end
696 ensure
697 if @opt.f_pths.length > 0
698 env=SiSU_Env::InfoEnv.new(@opt.fns)
699 path_pod=env.processing_path.processing_sisupod(@opt).paths
700 unless @opt.act[:maintenance][:set]==:on
701 FileUtils::rm_rf("#{path_pod[:sisupod]}/*") \
702 if FileTest.directory?(path_pod[:sisupod])
703 end
704 else
705 #SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
706 # mark('*** request requires sisu markup files')
707 end
708 end
709 end
710 if @opt.act[:po4a][:set]==:on #% --po4a, -P
711 if @opt.f_pths.length > 0
712 require_relative 'po4a'
713 begin
714 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
715 loop_files_on_given_option do
716 SiSU_Po4a::Source.new(@opt).read # po4a.rb
717 end
718 ensure
719 end
720 else
721 msg='po4a request requires sisu markup files'
722 if (@opt.act[:verbose_plus][:set]==:on \
723 || @opt.act[:maintenance][:set]==:on)
724 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
725 mark(msg)
726 else puts msg
727 end
728 end
729 end
730 if @opt.act[:images][:set]==:on #% --images, -j
731 if @opt.f_pths.length > 0
732 require_relative 'shared_images'
733 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
734 loop_files_on_given_option do
735 SiSU_Images::Source.new(@opt).read # shared_images.rb
736 end
737 else
738 msg='place images request requires sisu markup files'
739 if (@opt.act[:verbose_plus][:set]==:on \
740 || @opt.act[:maintenance][:set]==:on)
741 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
742 mark(msg)
743 else puts msg
744 end
745 end
746 end
747 end
748 def run_termsheet? #broken, revisit later
749 if @opt.selections.str =~/--termsheet/ #% -T termsheet/standard form #fix later
750 if @opt.f_pths.length > 0
751 @opt.files.each do |fns|
752 if FileTest.file?(fns)
753 @opt.fns=fns
754 case @opt.fns
755 when /\.(termsheet.rb)$/
756 SiSU_Hub_Actions::Operations.new(@opt).termsheet
757 else #print "not processed --> ", fns, "\n"
758 end
759 else SiSU_Hub_Actions::Operations.new(@opt).not_found
760 end
761 end
762 else
763 msg='process termsheet request requires sisu markup files'
764 if (@opt.act[:verbose_plus][:set]==:on \
765 || @opt.act[:maintenance][:set]==:on)
766 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
767 mark(msg)
768 else puts msg
769 end
770 end
771 end
772 end
773 def sql?
774 if @opt.act[:psql][:set]==:on #% --pg, -D
775 if @opt.f_pths.length > 0
776 require_relative 'dbi'
777 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
778 loop_files_on_given_option do
779 SiSU_DBI::SQL.new(@opt).connect # dbi.rb
780 end
781 else
782 msg='pgsql request requires sisu markup files'
783 if (@opt.act[:verbose_plus][:set]==:on \
784 || @opt.act[:maintenance][:set]==:on)
785 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
786 mark(msg)
787 else puts msg
788 end
789 end
790 end
791 if @opt.act[:sqlite][:set]==:on #% --sqlite, -d
792 if @opt.f_pths.length > 0
793 require_relative 'dbi'
794 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
795 loop_files_on_given_option do
796 SiSU_DBI::SQL.new(@opt).connect # dbi.rb
797 end
798 else
799 msg='sqlite request requires sisu markup files'
800 if (@opt.act[:verbose_plus][:set]==:on \
801 || @opt.act[:maintenance][:set]==:on)
802 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
803 mark(msg)
804 else puts msg
805 end
806 end
807 end
808 end
809 def manifest?
810 if @opt.act[:manifest][:set]==:on #% --manifest, -y
811 if @opt.f_pths.length > 1
812 require_relative 'html_manifest'
813 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).manifest_on_files_translated do
814 SiSU_Manifest::Source.new(@opt).read # html_manifest.rb
815 end
816 end
817 end
818 end
819 def sitemaps?
820 if @opt.act[:sitemap][:set]==:on #% --sitemap, -Y
821 if @opt.f_pths.length > 0
822 require_relative 'sitemaps'
823 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
824 loop_files_on_given_option do
825 SiSU_Sitemaps::Source.new(@opt).read # sitemaps.rb
826 end
827 end
828 end
829 end
830 def remote_placement?
831 if @opt.act[:harvest][:set] !=:on
832 if @opt.act[:scp][:set]==:on #% -r copy to remote server
833 if @opt.f_pths.length > 0
834 require_relative 'remote' # remote.rb
835 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
836 loop_files_on_given_option do
837 SiSU_Remote::Put.new(@opt).scp
838 end
839 end
840 end
841 if @opt.act[:rsync][:set]==:on #% -R copy to remote server
842 if @opt.f_pths.length > 0
843 require_relative 'remote' # remote.rb
844 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
845 loop_files_on_given_option do
846 SiSU_Remote::Put.new(@opt).rsync
847 end
848 end
849 end
850 else
851 end
852 end
853 def urls?
854 if @opt.act[:urls_selected][:set]==:on #% --urls
855 if @opt.f_pths.length > 0
856 require_relative 'urls'
857 SiSU_Hub_Loops::OptionLoopFiles.new(@opt).
858 loop_files_on_given_option do
859 SiSU_Urls::Source.new(@opt).read #% urls.rb
860 end
861 else
862 msg='urls request requires sisu markup files'
863 if (@opt.act[:verbose_plus][:set]==:on \
864 || @opt.act[:maintenance][:set]==:on)
865 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:cyan).
866 mark(msg)
867 else puts msg
868 end
869 end
870 end
871 end
872 self
873 end
874 def init?
875 SiSU_Env::InfoProcessingFlag.new
876 if @opt.act[:ao][:set]==:on \
877 or @opt.act[:maintenance][:set]==:on #% --maintenance, -M
878 env=SiSU_Env::InfoEnv.new(@opt.fns)
879 path={}
880 path[:css]=env.path.output + '/_sisu/css'
881 path[:xml]=env.path.output + '/_sisu/xml'
882 path[:xsd]=path[:xml] + '/xsd'
883 path[:xsd]=path[:xml] + '/rnc'
884 path[:xsd]=path[:xml] + '/rng'
885 re_p3=/(sisupod(?:\.txz)?|\S+?\.ss[mt]\.txz|[^\/]+?\.ssp)$/
886 unless @opt.files.join(',') =~ re_p3 #do not mix pods with source markup files in command line
887 if @opt.act[:maintenance][:set] ==:on
888 $VERBOSE=false #debug $VERBOSE=true
889 end
890 end
891 re_p2=/(sisupod(?:\.zip)?|\S+?\.ss[mt]\.zip)$/
892 unless @opt.files.join(',') =~ re_p2 #do not mix pods with source markup files in command line
893 if @opt.act[:maintenance][:set] ==:on
894 $VERBOSE=false #debug $VERBOSE=true
895 end
896 end
897 end
898 if @opt.act[:ao][:set]==:on
899 @retry_count= -1
900 begin
901 @get_s,@get_p,@get_pl=[],[],[]
902 re_s=/(\S+?\.-sst)$/
903 re_p3=/((?:https?|file):\/\/\S+?(?:\/\S+?\.ss[mt]\.txz|sisupod(?:\.txz)?|\.ssp))/
904 re_pl3=/^(\/\S+?\.ss[mt]\.txz)/
905 @opt.files.each do |fns|
906 if fns =~re_s
907 @get_s << @opt.f_pths[0][:url]
908 end
909 if fns =~re_p3
910 @get_p << re_p3.match(fns)[1] if re_p3
911 end
912 if fns =~re_pl3
913 @get_pl << re_pl3.match(fns)[1] if re_p3
914 end
915 end
916 if @get_s.length > 0 #% remote markup file .sst
917 require_relative 'remote' # remote.rb
918 SiSU_Remote::Get.new(@opt,@get_s).fns
919 SiSU_Hub_Actions::Operations.new.counter
920 end
921 if @get_p.length > 0 #% remote sisupod
922 require_relative 'remote' # remote.rb
923 SiSU_Remote::Get.new(@opt,@get_p).sisupod
924 end
925 rescue
926 SiSU_Errors::Rescued.new($!,$@,@opt,@fns).location do
927 __LINE__.to_s + ':' + __FILE__
928 end
929 @retry_count +=1
930 retry unless @retry_count > 1
931 ensure
932 end
933 end
934 end
935 self
936 end
937 end
938 class Operations
939 @@n_do=0
940 def initialize(opt='')
941 @opt=opt
942 @cX=SiSU_Screen::Ansi.new(@opt).cX
943 end
944 def counter
945 @@n_do=0
946 end
947 def remote_put_base_site_rsync # -CR
948 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) \
949 if @opt.act[:maintenance][:set] ==:on
950 require_relative 'remote' # remote.rb
951 SiSU_Remote::Put.new(@opt).rsync_base
952 end
953 def remote_put_base_site_rsync_match # -CCRZ
954 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) \
955 if @opt.act[:maintenance][:set] ==:on
956 require_relative 'remote' # remote.rb
957 SiSU_Remote::Put.new(@opt).rsync_base_sync
958 end
959 def remote_put_base_site # -Cr
960 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) \
961 if @opt.act[:maintenance][:set] ==:on
962 require_relative 'remote' # remote.rb
963 SiSU_Remote::Put.new(@opt).scp_base
964 end
965 def remote_put_base_site_all # -CCr
966 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).mark(:cyan) \
967 if @opt.act[:maintenance][:set] ==:on
968 require_relative 'remote' # remote.rb
969 SiSU_Remote::Put.new(@opt).scp_base_all
970 end
971 def cgi # -F
972 require_relative 'cgi' # cgi.rb
973 SiSU_CGI::SearchSQL.new(@opt).read
974 end
975 def termsheet # -t
976 system("sisu_termsheet #{@opt.selections.str} #{@opt.fns}\n")
977 @@n_do=@@n_do+1
978 SiSU_Screen::Ansi.new(
979 @opt.selections.str,@@n_do,
980 'Termsheet(s) processed'
981 ).term_sheet_title unless @opt.act[:quiet][:set] ==:on
982 end
983 def webrick # -W
984 prt=SiSU_Env::InfoEnv.new(@fns).port.webrick_port
985 puts %{#{@cX.blue}<<#{@cX.off}#{@cX.green}Start Webrick web server on port: #{prt}#{@cX.off}#{@cX.blue}>> #{@cX.off*2} }
986 require_relative 'webrick'
987 SiSU_Webserv::WebrickStart.new
988 end
989 def not_found
990 puts "\n#{@cX.fuchsia}FILE NOT FOUND:#{@cX.off} << #{@opt.fns} >> - requested #{@opt.selections.str} processing skipped\n"
991 end
992 def convert_name_message(fns,type,i,o,rune)
993 %{\nIn filename: "#{@cX.fuchsia}#{fns}#{@cX.off}" << #{type} >> #{@cX.fuchsia}is apre 0.36 markup filename.#{@cX.off} #{@cX.brown}Please rename your file.#{@cX.off}\n\tAs of sisu-0.37, SiSU markup files with #{@cX.brown}the extensions #{i} should be re-named #{o}#{@cX.off}\n\tif you have the program called 'rename' installed, the following rune should do the trick:\n\t\t#{rune}\n\talternatively try:\n\t\tsisu --convert --36to37 #{fns}\n\trequested #{@opt.selections.str} processing skipped\n}
994 end
995 def not_recognised
996 case @opt.fns
997 when /(\.s[123])$/
998 type=@opt.fns.gsub(/\S+?(#{$1})/,'\1')
999 rune=%q{rename 's/\.s[123]$/\.sst/' *.s{1,2,3}}
1000 puts convert_name_message(@opt.fns,type,'.s1 .s2 and .s3','.sst',rune)
1001 when /(\.r[123])$/
1002 type=@opt.fns.gsub(/\S+?(#{$1})/,'\1')
1003 rune=%q{rename 's/\.r[123]$/\.ssm/' *.r{1,2,3}}
1004 puts convert_name_message(@opt.fns,type,'.r1 .r2 and .r3','.sst',rune)
1005 puts %{\n\tNote also that you will need to change the names of the files called/required\n\twithin the document text to build the composite document\n\t\t.s1 .s2 .s3 should be .sst \n\t\t.si should be .ssi\n\trequested #{@opt.selections.str} processing skipped\n}
1006 when /(\.ssi)$/
1007 puts "\n#{@cX.fuchsia}component filetype:#{@cX.off} << #{@opt.fns} >> - is not a processed filetype, (it may be used as a component of a .ssm markup file)\n\trequested #{@opt.selections.str} processing skipped\n"
1008 else
1009 puts "\n#{@cX.fuchsia}FILETYPE NOT RECOGNISED:#{@cX.off} << #{@opt.fns} >> - is not a recognized filetype,\n\trequested #{@opt.selections.str} processing skipped\n"
1010 end
1011 end
1012 end
1013 end
1014 __END__