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