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