1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
|
# encoding: utf-8
=begin
* Name: SiSU
* Description: a framework for document structuring, publishing and search
* Author: Ralph Amissah
* Copyright: (C) 1997 - 2012, Ralph Amissah, All Rights Reserved.
* License: GPL 3 or later:
SiSU, a framework for document structuring, publishing and search
Copyright (C) Ralph Amissah
This program is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option)
any later version.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see <http://www.gnu.org/licenses/>.
If you have Internet connection, the latest version of the GPL should be
available at these locations:
<http://www.fsf.org/licensing/licenses/gpl.html>
<http://www.gnu.org/licenses/gpl.html>
<http://www.jus.uio.no/sisu/gpl.fsf/toc.html>
<http://www.jus.uio.no/sisu/gpl.fsf/doc.html>
<http://www.jus.uio.no/sisu/gpl.fsf/plain.txt>
* SiSU uses:
* Standard SiSU markup syntax,
* Standard SiSU meta-markup syntax, and the
* Standard SiSU object citation numbering and system
* Hompages:
<http://www.jus.uio.no/sisu>
<http://www.sisudoc.org>
* Download:
<http://www.jus.uio.no/sisu/SiSU/download.html>
* Ralph Amissah
<ralph@amissah.com>
<ralph.amissah@gmail.com>
** Description: SiSU information Structuring Universe, text structuring,
processing, publishing, search
=end
module SiSU
require_relative 'constants' # constants.rb
require_relative 'sysenv' # sysenv.rb
include SiSU_Screen
@@pwd_the=Dir.pwd
class Op
@@env=SiSU_Env::InfoEnv.new
def initialize(opt,req,message)
@opt,@req,@message=opt,req,message
@n_do=0
end
def pod3_output(fns_pod)
dir_pwd=@@env.path.pwd
dir_pod=@@env.sisupod_gen_v3(fns_pod)
Dir.chdir("#{dir_pod}/doc")
#system("ls")
files=Dir['*/*.ss[tm]']
files_ssm=Dir['*/*.ssm']
files_sst=Dir['*/*.sst']
content=if files_ssm.length > 0
files_ssm.join(' ')
elsif files_sst.length > 0
files_sst.join(' ')
else
p 'no files found'
end
@opt.fns=content #check
if FileTest.directory?("#{dir_pod}/doc")
Dir.chdir("#{dir_pod}/doc")
system("
sisu3 -CC #{@opt.cmd} #{@opt.mod.join(' ')} #{content}
#sisu3 -CC #{@opt.cmd} -G #{@opt.mod.join(' ')} #{content}
")
Dir.chdir(dir_pwd)
end
@pwd=`pwd`.strip
Dir.chdir(@pwd)
end
def pod2_output(fns_pod)
dir_pwd=@@env.path.pwd
dir_pod=@@env.sisupod_gen_v2(fns_pod)
Dir.chdir(dir_pod)
system("ls")
files=Dir['*.ss[tm]']
files_ssm=Dir['*.ssm']
files_sst=Dir['*.sst']
content=if files_ssm.length > 0
files_ssm.join(' ')
elsif files_sst.length > 0
files_sst.join(' ')
else
p 'no files found'
end
@opt.fns=content
if FileTest.directory?(dir_pod)
Dir.chdir(dir_pod)
system("
sisu3 -CC #{@opt.cmd} #{@opt.mod.join(' ')} #{content}
#sisu3 -CC #{@opt.cmd} -G #{@opt.mod.join(' ')} #{content}
")
Dir.chdir(dir_pwd)
end
@pwd=`pwd`.strip
Dir.chdir(@pwd)
end
def select
require_relative @req
if @req =~/^conf$/ # -C
SiSU_Initialize::Source.new(@opt).read
end
if not @opt.files.empty?
@opt.files.each_with_index do |fns,i|
env=SiSU_Env::InfoEnv.new(fns)
if fns =~ /sisupod(?:\.txz)?|\S+?(?:\.ss[mt]\.txz|\.ssp)$/
require_relative 'remote' # remote.rb #check
pod_name=if fns =~ /http:\/\/\S+?(?:\.ss[mt]\.txz|\.ssp)$/
SiSU_Remote::RemoteDownload.new(fns).pod.name
else
re_p=/(\S+?\.ss[mt](?:\.txz)?)$/
re_p.match(fns).captures.join
end
SiSU_Screen::Ansi.new(@opt.cmd,pod_name).puts_blue unless @opt.cmd =~/q/
@opt.files.shift
pod3_output(pod_name)
break
elsif fns =~ /sisupod(?:\.zip)?|\S+?(?:\.ss[mt]\.zip|\.ssp)$/
require_relative 'remote' # remote.rb #check
pod_name=if fns =~ /http:\/\/\S+?(?:\.ss[mt]\.zip|\.ssp)$/
SiSU_Remote::RemoteDownload.new(fns).pod.name
else
re_p=/(\S+?\.ss[mt](?:\.zip)?)$/
re_p.match(fns).captures.join
end
SiSU_Screen::Ansi.new(@opt.cmd,pod_name).puts_blue unless @opt.cmd =~/q/
@opt.files.shift
pod2_output(pod_name)
break
else
put=fns.gsub(/(.+)?\.ssm\.sst$/,'\1.ssm')
if fns !~/\.-sst$/
@opt.fns=fns
@opt.pth=@opt.paths[i]
@opt.f_pth=@opt.f_pths[i]
@opt.lng=@opt.lngs[i]
@@pwd=@opt.pth
else
@opt.fns=fns
@opt.pth=Dir.pwd
@opt.f_pth=@opt.f_pths[i] #@opt.f_pth= { pth: Dir.pwd }
@opt.lng='en'
#@opt.lng=@opt.lngs[i]
@@pwd=@opt.pth
end
Dir.chdir(@opt.pth) #watch
env=SiSU_Env::InfoEnv.new(fns)
if @req !~/(?:urls|remote)$/
if @opt.cmd.inspect =~/-P/ \
and @req =~ /^po4a$/
require_relative 'composite' # composite.rb #pre-processing
SiSU_Po4a::Source.new(@opt).read # -P po4a.rb
elsif @req=~/^dal$/ \
and FileTest.file?(@opt.fns) \
and @opt.fns =~ /\.(?:(?:-|ssm\.)?sst|ssm)$/
if fns =~ /\.ssm$/
require_relative 'composite' # composite.rb #pre-processing
SiSU_Assemble::Composite.new(@opt).read
@opt.fns=fns.gsub(/\.ssm$/,'.ssm.sst')
end
SiSU_DAL::Source.new(@opt).read # -m
elsif FileTest.file?(env.source_file_with_path)
case @opt.fns
when /\.(?:(?:-|ssm\.)?sst|ssm)$/
case @req
when /^dal$/
if fns =~ /\.ssm$/
require_relative 'composite' # composite.rb #pre-processing
SiSU_Assemble::Composite.new(@opt).read
@opt.fns=fns.gsub(/\.ssm$/,'.ssm.sst')
end
SiSU_DAL::Source.new(@opt).read # -m dal.rb
when /^git$/; SiSU_Git::Source.new(@opt).read # -g git.rb
when /^concordance$/; SiSU_Concordance::Source.new(@opt).read # -w concordance.rb
when /^share_src$/; SiSU_Markup::Source.new(@opt).read # -s share_src.rb
when /^sisupod_make$/; SiSU_Doc::Source.new(@opt).read # -S sisupod_make.rb
# when /^source_kdissert$/; SiSU_KdiSource::Source.new(@opt).read # -S share_src_kdissert.rb
when /^digests$/; SiSU_DigestView::Source.new(@opt).read # -N digests.rb
when /^plaintext$/; SiSU_Plaintext::Source.new(@opt).read # -t -a plaintext.rb
when /^po4a$/; SiSU_Po4a::Source.new(@opt).read # -P po4a.rb
#when /^wikispeak$/; SiSU_Wikispeak::Source.new(@opt).read # -g
when /^epub$/; SiSU_EPUB::Source.new(@opt).read # -e epub.rb
when /^odf$/; SiSU_ODF::Source.new(@opt).read # -o odf.rb
when /^xml_md_oai_pmh_dc$/; SiSU_XML_Metadata::OAI_PMH.new(@opt).read # -O
when /^texpdf$/; SiSU_TeX::Source.new(@opt).read # -p texpdf.rb
when /^manpage$/; SiSU_Manpage::Source.new(@opt).read # -i manpage.rb
when /^texinfo$/; SiSU_TexInfo::Source.new(@opt).read # -I texinfo.rb
when /^html$/; SiSU_HTML::Source.new(@opt).read # -h -H html.rb
when /^xhtml$/; SiSU_XHTML::Source.new(@opt).read # -b xhtml.rb
when /^xml$/; SiSU_XML_SAX::Source.new(@opt).read # -x xml.rb
when /^xml_dom$/; SiSU_XML_DOM::Source.new(@opt).read # -X xml_dom.rb
when /^shared_images$/; SiSU_Images::Source.new(@opt).read # -j shared_images.rb
#when /^xml_fictionbook$/; SiSU_XML_Fictionbook::Source.new(@opt).read # -f
when /^xml_scaffold$/; SiSU_XML_Scaffold::Source.new(@opt).read # -k xml_scaffold.rb
when /^embedded$/; SiSU_Embedded::Source.new(@opt).read # -m embedded.rb (image and other content) #check
when /^manifest$/; SiSU_Manifest::Source.new(@opt).read # -y manifest.rb
when /^qrcode$/; SiSU_QRcode::Source.new(@opt).read # -Q qrcode.rb
when /^sitemaps$/; SiSU_Sitemaps::Source.new(@opt).read # -Y sitemaps.rb
when /^zap$/; SiSU_Zap::Source.new(@opt).read # -Z zap.rb
when /^dbi$/; SiSU_DBI::SQL.new(@opt).connect # -D -d dbi.rb
when /^dbi_discreet$/; SiSU_DBI_Discreet::SQL.new(@opt).build # -d dbi_discreet.rb
end
@n_do=@n_do+1
SiSU_Screen::Ansi.new(@opt.cmd,@n_do,"#{@req.upcase} processed").files_processed if @opt.cmd =~/[MVv]/
ObjectSpace.garbage_collect
else #print "not processed --> ", fns, "\n"
end
else
if @req !~/^conf$/ \
and @opt.fns !~/http:\/\//
SiSU::Operations.new(@opt).not_found
end
end
elsif FileTest.file?(put)
if @opt.mod.inspect !~/harvest/ #decide whether should permit harvest in single operation
case @req
when /^urls$/; SiSU_Urls::Source.new(@opt).read # -u -v -V -M
when /^remote$/
case @message
when /scp/; SiSU_Remote::Put.new(@opt).scp # -r
when /rsync/; SiSU_Remote::Put.new(@opt).rsync # -R
else #SiSU_Remote::Put.new(put,@opt.cmd).scp
end
end
@n_do=@n_do+1
SiSU_Screen::Ansi.new(@opt.cmd,@n_do,"#{@req.upcase} processed").files_processed if @opt.cmd =~/[MVv]/
end
else SiSU::Operations.new(@opt).not_found
end
end
end
elsif @req =~/^dbi$/; SiSU_DBI::SQL.new(@opt).connect # -D -d
elsif @req=~/^sisupod_make$/; SiSU_Doc::Source.new(@opt).read # -S
end
SiSU::Operations.new.counter
end
end
class Operations
@@n_do=0
def initialize(opt='')
@opt=opt
@cX=SiSU_Screen::Ansi.new(@opt).cX
end
def counter
@@n_do=0
end
def remote_put_base_site_rsync # -CR
p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
require_relative 'remote' # remote.rb
SiSU_Remote::Put.new(@opt).rsync_base
end
def remote_put_base_site_rsync_match # -CCRZ
p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
require_relative 'remote' # remote.rb
SiSU_Remote::Put.new(@opt).rsync_base_sync
end
def remote_put_base_site # -Cr
p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
require_relative 'remote' # remote.rb
SiSU_Remote::Put.new(@opt).scp_base
end
def remote_put_base_site_all # -CCr
p "here #{__FILE__} #{__LINE__}" if @opt =~/M/
require_relative 'remote' # remote.rb
SiSU_Remote::Put.new(@opt).scp_base_all
end
def cgi # -F
require_relative 'cgi' # cgi.rb
SiSU_CGI::SearchSQL.new(@opt).read
end
def encoding # -K build character encoding db (uses KirbyBase)
require_relative 'character_encoding' # character_encoding.rb
SiSU_CharacterEncode::Create.new.db
end
def termsheet # -t
system("sisu_termsheet #{@opt.cmd} #{@opt.fns}\n")
@@n_do=@@n_do+1
SiSU_Screen::Ansi.new(@opt.cmd,@@n_do,'Termsheet(s) processed').term_sheet_title unless @opt.cmd =~/q/
end
def webrick # -W
port=prt=@fns
prt=if prt !~/\d+/
'webrick default (sysenv)'
else "webrick port set to #{prt}"
end
puts %{#{@cX.blue}<<#{@cX.off}#{@cX.green}Start Webrick web server on port: #{prt}#{@cX.off}#{@cX.blue}>> #{@cX.off*2} }
system("sisu_webrick #{port}&\n")
end
def not_found
puts "\n#{@cX.fuschia}FILE NOT FOUND:#{@cX.off} << #{@opt.fns} >> - requested #{@opt.cmd} processing skipped\n"
end
def convert_name_message(fns,type,i,o,rune)
%{\nIn filename: "#{@cX.fuschia}#{fns}#{@cX.off}" << #{type} >> #{@cX.fuschia}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.cmd} processing skipped\n}
end
def not_recognised
case @opt.fns
when /(\.s[123])$/
type=@opt.fns.gsub(/\S+?(#{$1})/,'\1')
rune=%q{rename 's/\.s[123]$/\.sst/' *.s{1,2,3}}
puts convert_name_message(@opt.fns,type,'.s1 .s2 and .s3','.sst',rune)
when /(\.r[123])$/
type=@opt.fns.gsub(/\S+?(#{$1})/,'\1')
rune=%q{rename 's/\.r[123]$/\.ssm/' *.r{1,2,3}}
puts convert_name_message(@opt.fns,type,'.r1 .r2 and .r3','.sst',rune)
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.cmd} processing skipped\n}
when /(\.ssi)$/
puts "\n#{@cX.fuschia}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.cmd} processing skipped\n"
else
puts "\n#{@cX.fuschia}FILETYPE NOT RECOGNISED:#{@cX.off} << #{@opt.fns} >> - is not a recognized filetype,\n\trequested #{@opt.cmd} processing skipped\n"
end
end
end
class Processing
require 'fileutils'
include FileUtils
@@env=SiSU_Env::InfoEnv.new
attr_accessor :op
def initialize(opt)
@opt=opt
@msg,@msgs='',nil
@tell=lambda { SiSU_Screen::Ansi.new(@opt.cmd,@msg,"#{@msgs.inspect if @msgs}") }
end
def op(req,msg)
SiSU::Op.new(@opt,req,msg).select if req and msg
end
def actions
if @opt.cmd =~/E/ # re-assign character
require 'profile'
end
if @opt.act[:harvest][:bool]
require_relative 'harvest' # harvest.rb
SiSU_Harvest::Source.new(@opt).read # -h -H html.rb
elsif @opt.mod.inspect =~/--convert|--to|--from/
require_relative 'sst_convert_markup' # sst_convert_markup.rb
elsif @opt.cmd =~/([abCcDdeFGgHhIjikLMmNnoPpQqRrSsTtUuVvWwXxYyZ_0-9])/ \
and @opt.cmd =~/^-/ \
and @opt.mod.inspect !~/--(?:sitemaps|query|identify)/ \
or @opt.mod.inspect =~/--(?:(?:sq)?lite|pg(?:sql)?)/
@cX=SiSU_Screen::Ansi.new(@opt.cmd).cX
flag=SiSU_Env::InfoProcessingFlag.new
if @opt.cmd =~/[vVM]/ #% version information
if (@opt.cmd =~/V/) \
&& (@opt.files.empty?) #% environment
SiSU_Help::Help.new('env',@opt).environment
else SiSU_Help::Help.new('env',@opt).sisu_version
end
end
if @opt.act[:license][:bool] #% license information
SiSU_Help::Help.new('license',@opt).help_request
end
if @opt.act[:dal][:bool] \
or @opt.act[:maintenance][:bool] #% --maintenance, -m for -C
path={}
path[:css]=@@env.path.output + '/_sisu/css'
path[:xml]=@@env.path.output + '/_sisu/xml'
path[:xsd]=path[:xml] + '/xsd'
path[:xsd]=path[:xml] + '/rnc'
path[:xsd]=path[:xml] + '/rng'
re_p3=/(sisupod(?:\.txz)?|\S+?\.ss[mt]\.txz|[^\/]+?\.ssp)$/
unless @opt.files.join(',') =~ re_p3 #do not mix pods with source markup files in command line
unless ( FileTest.directory?(path[:css]) \
and FileTest.directory?(path[:xsd]) )
@opt.cmd=@opt.cmd +='C' unless @opt.cmd =~/C/ #FIX
end
if @opt.cmd =~/M/
$VERBOSE=false #debug $VERBOSE=true
end
end
re_p2=/(sisupod(?:\.zip)?|\S+?\.ss[mt]\.zip)$/
unless @opt.files.join(',') =~ re_p2 #do not mix pods with source markup files in command line
unless ( FileTest.directory?(path[:css]) \
and FileTest.directory?(path[:xsd]) )
@opt.cmd=@opt.cmd +='C' unless @opt.cmd =~/C/ #FIX
end
if @opt.cmd =~/M/
$VERBOSE=false #debug $VERBOSE=true
end
end
end
if @opt.act[:site_init][:bool] #% --init-site, -C initialize/configure
op('conf','configure site')
if @opt.cmd =~/R/
if @opt.mod.inspect =~/--init(?:ialize)?=site/ \
and @opt.cmd =~/RZ/
SiSU::Operations.new(@opt).remote_put_base_site_rsync_match
else SiSU::Operations.new(@opt).remote_put_base_site_rsync
end
elsif @opt.cmd =~/r/
if @opt.mod.inspect =~/--init(?:ialize)?=site/ \
and @opt.cmd =~/CCr/
SiSU::Operations.new(@opt).remote_put_base_site_all
else SiSU::Operations.new(@opt).remote_put_base_site
end
end
end
if @opt.act[:sample_search_form][:bool] #% --sample-search-form, -F cgi sample search form
SiSU::Operations.new(@opt).cgi
end
if @opt.act[:webrick][:bool] #% --webrick, -W webrick
SiSU::Operations.new(@opt).webrick
end
if @opt.cmd =~/Z/ #% -Z wipe previous output clean
op('zap','Zap, deletions')
end
if @opt.act[:share_source][:bool]
op('share_src','SiSU markup source')
end
if @opt.act[:dal][:bool]
@retry_count= -1
begin
path_image='./_sisu/processing/external_document/image'
path_skin='./_sisu/processing/external_document/skin/doc'
@get_s,@get_p,@get_pl=[],[],[]
re_s=/(\S+?\.-sst)$/
re_p3=/((?:https?|file):\/\/\S+?(?:\/\S+?\.ss[mt]\.txz|sisupod(?:\.txz)?|\.ssp))/
re_pl3=/^(\/\S+?\.ss[mt]\.txz)/
@opt.files.each do |fns|
if fns =~re_s
@get_s << @opt.f_pths[0][:url]
end
if fns =~re_p3
@get_p << re_p3.match(fns)[1] if re_p3
end
if fns =~re_pl3
@get_pl << re_pl3.match(fns)[1] if re_p3
end
end
#re_p2=/((?:https?|file):\/\/\S+?(?:\/\S+?\.ss[mt]\.zip|sisupod(?:\.zip)?|\.ssp))/
#re_pl2=/^(\/\S+?\.ss[mt]\.zip)/
#@opt.files.each do |fns|
# if fns =~re_p2
# @get_p << re_p2.match(fns)[1] if re_p2
# end
# if fns =~re_pl2
# @get_pl << re_pl2.match(fns)[1] if re_p2
# end
#end
if @get_s.length > 0 #% remote markup file .sst
require_relative 'remote' # remote.rb
SiSU_Remote::Get.new(@opt,@get_s).fns
SiSU::Operations.new.counter
end
if @get_p.length > 0 #% remote sisupod
require_relative 'remote' # remote.rb
SiSU_Remote::Get.new(@opt,@get_p).sisupod
end
rescue
SiSU_Errors::InfoError.new($!,$@,@opt,@fns).error #ok
@retry_count +=1
retry unless @retry_count > 1
ensure
end
@opt.files=@opt.files.collect {|x| x=x.gsub(/(?:https?|file):\/\/\S+\/(\S+)\.sst$/,'\1.-sst') }
end
if @opt.act[:dal][:bool] #%--dal, -m
op('dal','dal')
end
@opt.files=@opt.files.collect {|x| x=x.gsub(/\.ssm$/,'.ssm.sst') }
if @opt.act[:sisupod][:bool] #% --sisupod, -S make sisupod
op('sisupod_make','sisupod (txz)')
if @opt.fns=~/\.kdi._sst/
op('share_src_kdissert','kdissert (kdi)') #% -S share kdissert source
end
end
if @opt.act[:qrcode][:bool] #% --qrcode, -Q
op('qrcode','QRcode')
end
if @opt.act[:hash_digests][:bool] #% --hash-digests, -N digest tree
op('digests','digests')
end
if @opt.act[:html][:bool] #% --html, -h
op('html','html')
end
if @opt.act[:txt][:bool] #% --txt, -t -a
#-A -f -e -E plaintext -a creates ms-dos type; -A creates unix type, plaintext file
op('plaintext','plaintext')
end
if @opt.act[:epub][:bool] #% --epub, -e
op('epub','ePub')
end
if @opt.act[:odt][:bool] #% --odt, -o opendocument
op('odf','OpenDocument')
end
if @opt.act[:xml_sax][:bool] #% --xml-sax, -x xml sax type
op('xml','xml sax')
end
if @opt.act[:xml_dom][:bool] #% --xml-dom, -x xml dom type
op('xml_dom','xml dom')
end
#if @opt.act[:fictionbook] #% --fictionbook, -f fictionbook xml
# op('xml_fictionbook','xml fictionbook')
#end
if @opt.act[:xhtml][:bool] #% --xhtml, -b xhtml
op('xhtml','xhtml sax')
end
if @opt.act[:images][:bool] #% --images, -j
op('shared_images','images')
end
if @opt.act[:concordance][:bool] #% --concordance, -w
op('concordance','Concordance')
end
if @opt.cmd =~/O/ #% -O open archive initiative, metadata harvesting
op('xml_md_oai_pmh_dc','OAI PMH')
end
if @opt.act[:po4a][:bool] #% --po4a, -P
op('po4a','po4a')
end
if @opt.act[:git][:bool] #% --git, -g sisu git
op('git','SiSU Git')
end
if @opt.cmd =~/T/ #% -T termsheet/standard form
SiSU_Help::Help.new('termsheet').help_request
@opt.files.each do |fns|
if FileTest.file?(fns)
@opt.fns=fns
case @opt.fns
when /\.(termsheet.rb)$/
SiSU::Operations.new(@opt).termsheet
else #print "not processed --> ", fns, "\n"
end
else SiSU::Operations.new(@opt).not_found
end
end
SiSU::Operations.new.counter
end
if @opt.cmd =~/k/ #% -T temporary tests
op('xml_scaffold','XML scaffold')
end
if @opt.act[:pdf][:bool] #% --pdf, -p latex/ texpdf
op('texpdf','LaTeX pdf')
end
if @opt.act[:manpage][:bool] #% --manpage, -i
op('manpage','manpage')
end
if @opt.act[:texinfo][:bool] #% --texinfo, -I
op('texinfo','TeX Info')
end
if @opt.act[:psql][:bool] #% --pg, -D DB postgresql
op('dbi','postgresql')
end
if @opt.act[:sqlite_discreet][:bool] #% --sqlite, -d DB sqlite
op('dbi_discreet','sqlite')
end
if @opt.act[:sqlite][:bool] #% --sqlite, -d DB sqlite
op('dbi','sqlite')
end
if @opt.act[:dal][:bool] #% --dal, -m embedded content
op('embedded','Embedded Content')
end
if @opt.act[:manifest][:bool] #% --manifest, -y
op('manifest','Manifest')
end
if @opt.act[:sitemap][:bool] #% --sitemap, -Y
op('sitemaps','Sitemap')
end
if @opt.mod.inspect !~/--harvest/
if @opt.act[:scp][:bool] #% -r copy to remote server
op('remote','scp')
end
if @opt.act[:rsync][:bool] #% -R copy to remote server
op('remote','rsync')
end
else
end
op('urls','urls')
@msg,@msgs="\tsisu -W [to start ruby web-server on output directory]\n",nil unless @opt.cmd =~/q/
@tell.call.print_brown if @opt.cmd =~/[uUvVM]/ unless @opt.files.join.empty?
if defined? @@env.processing_path.processing \
and @@env.user \
and FileTest.directory?(@@env.processing_path.processing) \
and @@env.processing_path.processing =~/#{@@env.user}$/ #clean temporary processing directory of content as is located in public area
FileUtils::cd(@@env.processing_path.processing_base_tmp) do
FileUtils::rm_rf(@@env.user) unless @opt.cmd =~/M/
end
end
elsif @opt.mod.inspect =~/--query/
require_relative 'sst_identify_markup' # sst_identify_markup.rb
puts SiSU_Markup::MarkupHistory.new(@opt).query
elsif @opt.mod.inspect =~/--identify/
require_relative 'sst_identify_markup' # sst_identify_markup.rb
markup_version=SiSU_Markup::MarkupIdentify.new(@opt).markup_version?
elsif @opt.mod.inspect =~/--about/ #% help instructions
if @opt.mod.inspect =~/--about/ \
and not @opt.what.empty?
SiSU_Help::Help.new(@opt.what,'color_off').help_request
else SiSU_Help::Help.new('list','color_off').help_request
end
elsif @opt.mod.inspect =~/--sitemaps/ #% sitemaps
require_relative 'sitemaps' # sitemaps.rb
SiSU_Sitemaps::Source.new(@opt).read
if @opt.cmd =~/R/
require_relative 'remote' # remote.rb
SiSU_Remote::Put.new(@opt).rsync_sitemaps
end
else #% help instructions
unless @opt.mod.inspect =~/--convert|--to|--from|--harvest/
if @opt.mod.inspect =~/--help/ \
and not @opt.what.empty?
SiSU_Help::Help.new(@opt.what).help_request
elsif @opt.mod.inspect =~/--help/; SiSU_Help::Help.new('list').help_request
else SiSU_Help::Help.new('env',@opt).sisu_version
tell=SiSU_Screen::Ansi.new(''," for HELP type:\n\tsisu --help [help request]\n\tman sisu\n or see the system or online documentation on SiSU:\n #{Config::CONFIG['datadir']}/doc/sisu/\n <http://www.jus.uio.no/sisu/>\n <http://sisudoc.org/>"); tell.puts_grey
end
end
end
@opt.files.each do |fns|
if FileTest.file?(fns)
@opt.fns=fns
unless @opt.fns =~ /(?:\.(?:(?:-|ssm\.)?sst|ssm|ssp|sx[sdn]\.xml|termsheet.rb)|\S+?\.ss[mt]\.(?:txz|zip)|sisupod\.(?:txz|zip)?|\S+?\.ssp)$/
if @opt.cmd.inspect=~/-P/
elsif @opt.fns=~/\.kdi$/ \
and @opt.mod.inspect =~/--(?:convert(?:-from)?|from)[=-]kdi/
elsif @opt.fns=~/\.sx[sdn]\.xml$/ \
and @opt.mod.inspect =~/--(?:(?:convert(?:-from)?|from)[=-])?(?:xml2sst|sxml)/
elsif @opt.fns=~/\.ssi$/ \
and @opt.mod.inspect =~/--identify/
else SiSU::Operations.new(@opt).not_recognised
end
end
if @opt.fns =~/\.ssm\.sst$/ \
and @opt.cmd !~/[S_M]/ # rework necessry, revist, the _ flag is a hack, to keep ._sst files
@msg,@msgs='temporary file removed',nil
@tell.call.warn unless @opt.cmd =~/V/
File.unlink(@opt.fns) if File.exist?(@opt.fns) #CONSIDER
end
else #SiSU::Operations.new(fns,'html').not_found
end
end
end
end
begin #% select what to do
if RUBY_VERSION < '1.9'
require 'jcode'
$KCODE='UTF8'
end
require_relative 'constants' # constants.rb
require_relative 'options' # options.rb
require_relative 'sysenv' # sysenv.rb
include SiSU_Env; include SiSU_Screen
require_relative 'param' # param.rb
include SiSU_Param
require_relative 'defaults' # defaults.rb
include SiSU_Viz
require_relative 'help' # help.rb
include SiSU_Help
require 'uri'
home=ENV['HOME']
argv=$*
@opt=SiSU_Commandline::Options.new(argv)
SiSU::Processing.new(@opt).actions
rescue; STDERR.puts SiSU_Screen::Ansi.new(@opt,$!,$@,nil).rescue #fix
ensure
Dir.chdir(@@pwd_the)
end
end
__END__
|