c&d: po4a (& git) revisited, revisit
[software/sisu] / lib / sisu / current / 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/current/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 widget #needs (md) #move
572 @rc=SiSU_Env::GetInit.new.sisu_yaml.rc
573 @ad=SiSU_Env::GetInit.new.ads
574 @html_bits=SiSU_Proj_HTML::Bits.new
575 @flag={
576 ad: false,
577 md: false,
578 sk: false,
579 rc: false
580 }
581 def promo?
582 @flag[:ad]=if @md.flag_promo \
583 && @ad[:flag_promo]
584 @flag[:md]=true
585 true
586 elsif defined? @html_bits.widget_promo \
587 and not @html_bits.widget_promo.nil? \
588 and @html_bits.widget_promo.is_a?(Array) \
589 and @html_bits.widget_promo.length > 0
590 @flag[:sk]=true
591 true
592 elsif defined? @rc['html']['promo'] \
593 and not @rc['html']['promo'].nil? \
594 and @rc['html']['promo'].length > 0
595 @flag[:rc]=true
596 true
597 else false
598 end
599 @flag
600 end
601 def search?
602 searches=['sisu']
603 flag=false
604 if defined? @rc['search']
605 searches.each do |type|
606 flag=if defined? @rc['search'][type] \
607 and defined? @rc['search'][type]['action'] \
608 and @rc['search'][type]['flag']==true \
609 and @rc['search'][type]['action'] =~/https?:\/\//
610 flag=if promo?[:ad]
611 false
612 elsif defined? @html_bits.widget_search \
613 and @html_bits.widget_search==true
614 true
615 elsif defined? @rc['search'][type]['flag'] \
616 and @rc['search'][type]['flag']==true
617 true
618 else false
619 end
620 else false
621 end
622 end
623 else false
624 end
625 flag
626 end
627 def search_fixed?
628 searches=['sisu','hyperestraier']
629 flag=if defined? @rc['search']
630 searches.each do |type|
631 if defined? @rc['search'][type] \
632 and defined? @rc['search'][type]['action'] \
633 and @rc['search'][type]['action'] =~/https?:\/\// \
634 and defined? @rc['search'][type]['db'] \
635 and @rc['search'][type]['db'] =~/\S+/
636 flag=if promo?[:ad]
637 false
638 elsif defined? @html_bits.widget_search \
639 and @html_bits.widget_search==true
640 true
641 elsif defined? @rc['search'][type]['flag'] \
642 and @rc['search'][type]['flag']==true
643 true
644 else false
645 end
646 else false
647 end
648 end
649 else false
650 end
651 end
652 def search_form(type='sisusearch',action=nil,db=nil,table=false)
653 rc=SiSU_Env::GetInit.new.sisu_yaml.rc
654 create_form_sisu=if action \
655 and db \
656 and action =~/https?:\/\// \
657 and db =~/\S+/
658 true
659 elsif widget.search?
660 db=if rc['search']['sisu']['flag']==true \
661 and rc['search']['sisu']['db']=~/\S+/
662 (rc['search']['sisu']['db']=~/^#{Db[:name_prefix]}\S+/) \
663 ? rc['search']['sisu']['db']
664 : "#{Db[:name_prefix]}#{rc['search']['sisu']['db']}"
665 else nil
666 end
667 action=rc['search']['sisu']['action']
668 true
669 elsif defined? rc['search']['sisu']['flag'] \
670 and defined? rc['search']['sisu']['action'] \
671 and rc['search']['sisu']['flag']==true \
672 and rc['search']['sisu']['action'] =~/https?:\/\//
673 true
674 else false
675 end
676 if table
677 table_open='<td align="center" bgcolor="#ffffff">'
678 table_close='</td>'
679 else
680 table_open=''
681 table_close='<br />'
682 end
683 form=if create_form_sisu \
684 and type=~/sisusearch/ \
685 and defined? rc['search']['sisu'] \
686 and defined? rc['search']['sisu']['action']
687 <<WOK
688 <!-- SiSU Search -->
689 #{table_open}
690 <a name="search"></a>
691 <form method="get" action="#{rc['search']['sisu']['action']}" target="_top">
692 <font size="2">
693 <input type="text" name="s1" size="24" maxlength="255" />
694 <input type="hidden" name="db" value="#{db}" />
695 <input type="hidden" name="ltd" value="1000" />
696 <input type="hidden" name="off" value="0" />
697 <input type="hidden" name="doc" value="#{@md.fnb}" /><br />
698 <input type="submit" name="search" value="search doc" />
699 <input type="submit" name="search" value="search db" />
700 </font></form>
701 #{table_close}
702 <!-- SiSU Search -->
703 WOK
704 else ''
705 end
706 form
707 end
708 def search_form_static(action=nil,db=nil)
709 rc=SiSU_Env::GetInit.new.sisu_yaml.rc
710 create_form=if rc['search']['sisu']['flag']==true \
711 and action \
712 and db \
713 and action =~/https?:\/\// \
714 and db =~/\S+/
715 true
716 elsif widget.search_fixed?
717 db=if rc['search']['sisu']['flag']==true \
718 and rc['search']['sisu']['db']=~/\S+/
719 (rc['search']['sisu']['db']=~/^#{Db[:name_prefix]}\S+/) \
720 ? rc['search']['sisu']['db']
721 : "#{Db[:name_prefix]}#{rc['search']['sisu']['db']}"
722 else nil
723 end
724 action=rc['search']['sisu']['action']
725 true
726 else false
727 end
728 if create_form
729 %{<td align="center" bgcolor="#ffffff">
730 <!-- SiSU Search -->
731 <a name="search"></a>
732 <form method="get" action="#{rc['search']['sisu']['action']}" target="_top">
733 <font size="2">
734 <input type="text" name="s1" size="24" maxlength="255" />
735 <br />
736 <input type="hidden" name="db" value="#{db}" />
737 <input type="hidden" name="ltd" value="1000" />
738 <input type="hidden" name="off" value="0" />
739 <input type="hidden" name="doc" value="#{@md.fnb}" />
740 <input type="submit" name="search" value="search doc" />
741 <input type="submit" name="search" value="search db" />
742 </font>
743 </form>
744 <!-- SiSU Search -->
745 </td> }
746 else ''
747 end
748 end
749 def search_action #check
750 if search?
751 else ''
752 end
753 end
754 self
755 end
756 def widget_static
757 @rc=SiSU_Env::GetInit.new.sisu_yaml.rc
758 @html_bits=SiSU_Proj_HTML::Bits.new
759 @flag={ ad: false, md: false, sk: false, rc: false }
760 def search?
761 flag=if defined? @rc['search'] \
762 and defined? @rc['search']['sisu'] \
763 and defined? @rc['search']['sisu']['action'] \
764 and @rc['search']['sisu']['action'] =~/https?:\/\// \
765 and defined? @rc['search']['sisu']['db'] \
766 and @rc['search']['sisu']['db'] =~/\S+/
767 flag=if defined? @html_bits.widget_search \
768 and @html_bits.widget_search==true
769 true
770 elsif defined? @rc['search']['sisu']['flag'] \
771 and @rc['search']['sisu']['flag']==true
772 true
773 else
774 false
775 end
776 else
777 false
778 end
779 end
780 def search_fixed?
781 flag=if defined? @rc['search'] \
782 and defined? @rc['search']['sisu'] \
783 and defined? @rc['search']['sisu']['action'] \
784 and @rc['search']['sisu']['action'] =~/https?:\/\// \
785 and defined? @rc['search']['sisu']['db'] \
786 and @rc['search']['sisu']['db'] =~/\S+/ \
787 and defined? @rc['search']['sisu']['db'] \
788 and @rc['search']['sisu']['db'] =~/\S+/
789 flag=if defined? @html_bits.widget_search \
790 and @html_bits.widget_search==true
791 true
792 elsif defined? @rc['search']['sisu']['flag'] \
793 and @rc['search']['sisu']['flag']==true
794 true
795 else
796 false
797 end
798 else
799 false
800 end
801 end
802 def search_form(action=nil,db=nil)
803 rc=SiSU_Env::GetInit.new.sisu_yaml.rc
804 create_form=if defined? rc['search']['sisu']['flag'] \
805 and rc['search']['sisu']['flag']==true \
806 and action \
807 and db \
808 and action =~/https?:\/\// \
809 and db =~/\S+/
810 true
811 elsif widget_static.search? \
812 and rc['search']['sisu']['flag']==true
813 db=if rc['search']['sisu']['db']=~/\S+/
814 (rc['search']['sisu']['db']=~/^#{Db[:name_prefix]}\S+/) \
815 ? rc['search']['sisu']['db']
816 : "#{Db[:name_prefix]}#{rc['search']['sisu']['db']}"
817 else nil
818 end
819 action=rc['search']['sisu']['action']
820 true
821 else false
822 end
823 if create_form \
824 and @fnb \
825 and @fnb=~/\S+/
826 %{<!-- SiSU Search -->
827 <a name="search"></a>
828 <form method="get" action="#{rc['search']['sisu']['action']}" target="_top">
829 <font size="2">
830 <input type="text" name="s1" size="24" maxlength="255" />
831 <br />
832 <input type="hidden" name="db" value="#{db}" />
833 <input type="hidden" name="doc" value="#{@fnb}" />
834 <input type="submit" name="search" value="search doc" />
835 <input type="submit" name="search" value="search db" />
836 </font>
837 </form>
838 <!-- SiSU Search --> }
839 elsif create_form
840 %{<!-- SiSU Search -->
841 <a name="search"></a>
842 <form method="get" action="#{rc['search']['sisu']['action']}" target="_top">
843 <font size="2">
844 <input type="text" name="s1" size="24" maxlength="255" />
845 <br />
846 <input type="hidden" name="db" value="#{db}" />
847 <input type="submit" name="search" value="search db" />
848 </font>
849 </form>
850 <!-- SiSU Search --> }
851 else ''
852 end
853 end
854 def search_action #check
855 if search?
856 else ''
857 end
858 end
859 self
860 end
861 def source_file_path
862 file=@fns.gsub(/\.ssm(?:\.sst)?/,'.ssm.sst')
863 unless file =~/\.ssm\.sst$/; "#{Dir.pwd}"
864 else "#{processing_path.composite_file}"
865 end
866 end
867 def source_file_with_path
868 file=@fns.gsub(/\.ssm(?:\.sst)?/,'.ssm.sst')
869 "#{source_file_path}/#{file}"
870 end
871 def texpdf_hyperlinks(cli)
872 @cli=cli
873 @hyplnks=if cli != :na
874 cli
875 elsif (defined? @rc['default']['pdf_hyperlinks']) \
876 && (@rc['default']['pdf_hyperlinks']=~/color/)
877 :color
878 elsif (defined? @rc['default']['pdf_hyperlinks']) \
879 && (@rc['default']['pdf_hyperlinks'] \
880 =~/(?:no-color|color-off|mono(?:chrome)?)/)
881 :mono
882 else :na
883 end
884 def landscape
885 if @cli != :na
886 @cli
887 elsif (defined? @rc['default']['pdf_hyperlinks_landscape']) \
888 && (@rc['default']['pdf_hyperlinks_landscape']=~/color/)
889 :color
890 elsif (defined? @rc['default']['pdf_hyperlinks_landscape']) \
891 && (@rc['default']['pdf_hyperlinks_landscape'] \
892 =~/(?:no-color|color-off|mono(?:chrome)?)/)
893 :mono
894 elsif @hyplnks != :na
895 @hyplnks
896 else :na
897 end
898 end
899 def portrait
900 if @cli != :na
901 @cli
902 elsif (defined? @rc['default']['pdf_hyperlinks_portrait']) \
903 && (@rc['default']['pdf_hyperlinks_portrait']=~/color/)
904 :color
905 elsif (defined? @rc['default']['pdf_hyperlinks_portrait']) \
906 && (@rc['default']['pdf_hyperlinks_portrait'] \
907 =~/(?:no-color|color-off|mono(?:chrome)?)/)
908 :mono
909 elsif @hyplnks != :na
910 @hyprlnks
911 else :na
912 end
913 end
914 self
915 end
916 def font
917 def size(pt=nil)
918 if pt && pt != :na
919 pt
920 elsif defined? @rc['default']['fontsize'] \
921 && @rc['default']['fontsize']=~/\d{1,2}/
922 @rc['default']['fontsize']
923 else :na
924 end
925 end
926 def texpdf
927 # you may wish to check selected font against available fonts:
928 # fc-list :outline -f "%{family}\n"
929 # fc-list :lang=ja
930 def main
931 (defined? @rc['default']['texpdf_fontface']) \
932 && (@rc['default']['texpdf_fontface']=~/\S{3,}/) \
933 ? @rc['default']['texpdf_fontface']
934 : 'Liberation Sans'
935 end
936 def sans # not used
937 (defined? @rc['default']['texpdf_fontface_sans']) \
938 && (@rc['default']['texpdf_fontface_sans']=~/\S{3,}/) \
939 ? @rc['default']['texpdf_fontface_sans']
940 : 'Liberation Sans'
941 end
942 def serif # not used
943 (defined? @rc['default']['texpdf_fontface_serif']) \
944 && (@rc['default']['texpdf_font_serif']=~/\S{3,}/) \
945 ? @rc['default']['texpdf_fontface_serif']
946 : 'Liberation Serif'
947 end
948 def mono
949 (defined? @rc['default']['texpdf_fontface_mono']) \
950 && (@rc['default']['texpdf_fontface_mono']=~/\S{3,}/) \
951 ? @rc['default']['texpdf_fontface_mono']
952 : 'Liberation Mono'
953 end
954 def cjk
955 (defined? @rc['default']['texpdf_fontface_cjk']) \
956 && (@rc['default']['texpdf_fontface_cjk']=~/\S{3,}/) \
957 ? @rc['default']['texpdf_fontface_cjk']
958 : 'IPAGothic' # 'IPAGothic' # 'IPAMincho' # 'TakaoMincho' # 'VL Gothic'
959 end
960 def cjk_zh
961 (defined? @rc['default']['texpdf_fontface_cjk_zh']) \
962 && (@rc['default']['texpdf_fontface_cjk_zh']=~/\S{3,}/) \
963 ? @rc['default']['texpdf_fontface_cjk_zh']
964 : 'IPAGothic'
965 end
966 def cjk_ja
967 (defined? @rc['default']['texpdf_fontface_cjk_ja']) \
968 && (@rc['default']['texpdf_fontface_cjk_ja']=~/\S{3,}/) \
969 ? @rc['default']['texpdf_fontface_cjk_ja']
970 : 'IPAGothic'
971 end
972 def cjk_ko
973 (defined? @rc['default']['texpdf_fontface_cjk_ko']) \
974 && (@rc['default']['texpdf_fontface_cjk_ko']=~/\S{3,}/) \
975 ? @rc['default']['texpdf_fontface_cjk_ko']
976 : 'IPAGothic'
977 end
978 def size(pt=nil)
979 if pt && pt != :na
980 pt
981 elsif (defined? @rc['default']['texpdf_fontsize']) \
982 && (@rc['default']['texpdf_fontsize']=~/\d{1,2}/)
983 @rc['default']['texpdf_fontsize']
984 elsif (defined? @rc['default']['fontsize']) \
985 && (@rc['default']['fontsize']=~/\d{1,2}/)
986 @rc['default']['fontsize']
987 else
988 :na
989 end
990 end
991 self
992 end
993 self
994 end
995 def path_rel_links
996 def html_scroll_2
997 if @env.output_dir_structure.by_language_code?
998 '../../'
999 elsif @env.output_dir_structure.by_filetype?
1000 '../'
1001 else
1002 '../'
1003 end
1004 end
1005 def html_seg_2
1006 if @env.output_dir_structure.by_language_code?
1007 '../../../'
1008 elsif @env.output_dir_structure.by_filetype?
1009 '../../'
1010 else
1011 '../'
1012 end
1013 end
1014 def html_scroll_1
1015 if @env.output_dir_structure.by_language_code?
1016 '../'
1017 elsif @env.output_dir_structure.by_filetype?
1018 '../'
1019 else
1020 './'
1021 end
1022 end
1023 def html_seg_1
1024 if @env.output_dir_structure.by_language_code?
1025 '../../'
1026 elsif @env.output_dir_structure.by_filetype?
1027 '../../'
1028 else
1029 './'
1030 end
1031 end
1032 self
1033 end
1034 def read_source_file_array(fns)
1035 (fns !~/\.ssm.sst$/) \
1036 ? (IO.readlines(fns, mode: 'r:utf-8', cr_newline: true))
1037 : (IO.readlines(
1038 "#{processing_path.composite_file}/#{fns}",
1039 mode: 'r:utf-8',
1040 cr_newline: true
1041 ))
1042 end
1043 def read_source_file(fns)
1044 read_source_file_array(fns)
1045 end
1046 def read_source_file_string(fns)
1047 (fns !~/\.ssm.sst$/) \
1048 ? (IO.read(fns, mode: 'r:utf-8', cr_newline: true))
1049 : (IO.read(
1050 "#{processing_path.composite_file}/#{fns}",
1051 mode: 'r:utf-8',
1052 cr_newline: true
1053 ))
1054 end
1055 def source_file_processing_array(fns)
1056 read_source_file_string(fns).split(/\s*\n\s*\n/m)
1057 end
1058 def path #dir
1059 def home
1060 @sys.home
1061 end
1062 def sisurc_path
1063 SiSU_Get_Init::GetInit.new.sisu_yaml.rc_path
1064 end
1065 def pwd
1066 @sys.pwd
1067 end
1068 def stub_pwd
1069 @stub_pwd
1070 end
1071 def base_markup_dir_stub
1072 @base_markup_dir_stub
1073 end
1074 def stub_epub
1075 @stub_epub
1076 end
1077 def stub_src
1078 @stub_src
1079 end
1080 def stub_pod
1081 @stub_pod
1082 end
1083 def etc
1084 defaults[:sisu_etc] #live/dynamic
1085 end
1086 def arch
1087 @sys.dir_arch
1088 end
1089 def sitearch
1090 @sys.dir_sitearch
1091 end
1092 def bin
1093 @sys.dir_bin
1094 end
1095 def share #shared data repository source directory
1096 #SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:green).
1097 # mark(defaults[:sisu_share])
1098 defaults[:sisu_share]
1099 end
1100 def style
1101 if @md \
1102 && ((@md.opt.opt_act[:dump][:bool] \
1103 && @md.opt.opt_act[:dump][:inst]) \
1104 || (@md.opt.opt_act[:redirect][:bool] \
1105 && @md.opt.opt_act[:redirect][:inst]))
1106 'css'
1107 else
1108 defaults[:stylesheet_stub]
1109 end
1110 end
1111 def sample_data #sample data repository source directory
1112 defaults[:sample_data_path]
1113 end
1114 def rc
1115 @init.rc_path
1116 end
1117 def yamlrc
1118 GetInit.new.sisu_yaml.rc_path
1119 end
1120 def man #check use
1121 (defined? @rc['webserv']['man']) \
1122 ? "#{webserv}/#{@rc['webserv']['man']}"
1123 : defaults[:webserv_man]
1124 end
1125 def webserv_path #testing, check need, remove
1126 webserv
1127 end
1128 def webserv #separation required for webrick which cannot use path.output (different requirements as no file is passed)
1129 man_path=if @@man_path.nil?
1130 man_path=if defined? @rc['webserv']['path'] \
1131 and @rc['webserv']['path'] =~/\S\S+/
1132 pwd=Dir.pwd
1133 Dir.chdir(SiSU_Utils::Path.new.base_markup)
1134 man_path=@@man_path=File.expand_path(@rc['webserv']['path'])
1135 Dir.chdir(pwd)
1136 man_path
1137 else defaults[:webserv_path]
1138 end
1139 else @@man_path
1140 end
1141 man_path_head=man_path.gsub(/(\S+)\/[^\/\s]+$/,'\1')
1142 unless FileTest.directory?(man_path)
1143 FileUtils::mkdir_p(man_path) if File.writable?("#{man_path_head}/.")
1144 end
1145 @webserv_path=if defined? man_path \
1146 and File.writable?("#{man_path}/.")
1147 man_path #web server path as configured in rc file
1148 elsif FileTest.directory?(defaults[:webserv_path]) \
1149 and File.writable?("#{defaults[:webserv_path]}/.") #web server path default
1150 defaults[:webserv_path]
1151 else #create default directory under home and place output there
1152 unless FileTest.directory?(defaults[:output_local])
1153 FileUtils::mkdir_p(defaults[:output_local])
1154 end
1155 defaults[:output_local]
1156 end
1157 end
1158 def webserv_stub_ensure
1159 FileUtils::mkdir_p(path.webserv) unless FileTest.directory?(path.webserv)
1160 FileUtils::mkdir_p("#{path.webserv}/#{@base_markup_dir_stub}") \
1161 unless FileTest.directory?("#{path.webserv}/#{@base_markup_dir_stub}")
1162 end
1163 def webserv_map_pwd #dir
1164 "#{path.webserv}/#{base_markup_dir_stub}"
1165 end
1166 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)
1167 defaults[:webserv_dir]
1168 end
1169 def webserv_image #web/presentation directory, subdirectories are created within it, depending on markup directory stub-name (last segment of markup directory name)
1170 images=if defined? @rc['webserv']['images']
1171 @rc['webserv']['images']
1172 else defaults[:images]
1173 end
1174 "#{path.webserv}/#{images}"
1175 end
1176 def output #web/webserv output directory... subdirectory into which further subdirectories are made based on file names
1177 r=Px[:lng_lst_rgx]
1178 u=/.+?\/([^\/]+)(?:\/(?:#{r})$|$)/
1179 base_stub=@sys.pwd.gsub(u,'\1')
1180 if Dir.pwd =~/\/#{Gt[:sisupod]}\/[^\/]+\/#{Gt[:pod]}\/#{Gt[:doc]}/
1181 "#{path.webserv}/#{Gt[:doc]}"
1182 else
1183 "#{path.webserv}/#{base_stub}"
1184 end
1185 end
1186 def feed
1187 (defined? @rc['webserv']['feed']) \
1188 ? ("#{public_output}/#{@rc['webserv']['feed']}")
1189 : (defaults[:webserv_feed])
1190 end
1191 def feed_home
1192 "#{public_output}/#{@rc['webserv']['feed_home']}"
1193 end
1194 def scripts #used previously only to include tla version info
1195 if defined? @rc['project']['path']
1196 "#{home}/#{@rc['project']['path']}"
1197 end
1198 end
1199 def cgi
1200 (defined? @rc['webserv']['cgi']) \
1201 ? "#{@rc['webserv']['cgi']}"
1202 : (defaults[:webserv_cgi])
1203 end
1204 def php
1205 (defined? @rc['webserv']['php']) \
1206 ? "#{public_output}/#{@rc['webserv']['php']}"
1207 : (defaults[:webserv_php])
1208 end
1209 #% programs
1210 def output_tell
1211 url.webserv_map_pwd
1212 end
1213 def image_source #image repository source directory
1214 if defined? @rc['image']['path'] \
1215 and defined? @rc['image']['public']
1216 pth="#{@rc['image']['path']}"
1217 "#{pth}/#{@rc['image']['public']}"
1218 else
1219 "#{share}/image"
1220 end
1221 end
1222 def image_source_sisu_includes
1223 "#{share}/image"
1224 end
1225 def image_source_include #image repository source directory
1226 if defined? @rc['image']['path'] \
1227 and defined? @rc['image']['public'] \
1228 and FileTest.directory?(
1229 "#{@rc['image']['path']}/#{@rc['image']['public']}"
1230 )==true
1231 "#{@rc['image']['path']}/#{@rc['image']['public']}"
1232 elsif FileTest.directory?("#{@@pwd}/#{defaults[:image_stub]}")==true
1233 "#{@@pwd}/#{defaults[:image_stub]}"
1234 elsif FileTest.directory?(
1235 "#{SiSU_Utils::Path.new.base_markup}/#{defaults[:image_stub]}"
1236 )==true
1237 "#{SiSU_Utils::Path.new.base_markup}/#{defaults[:image_stub]}"
1238 else
1239 "#{share}/image"
1240 end
1241 end
1242 def image_external
1243 "#{processing}/external_document/image"
1244 end
1245 def image_source_include_local
1246 if FileTest.directory?(defaults[:image_local])
1247 defaults[:image_local]
1248 end
1249 end
1250 def image_source_include_remote
1251 if FileTest.directory?(image_external); image_external
1252 end
1253 end
1254 self
1255 end
1256 def processing_path
1257 def encoding
1258 pth="#{processing}/#{defaults[:processing_encoding]}"
1259 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1260 pth
1261 end
1262 def processing_base_tmp
1263 defaults[:processing_path_tmp_base]
1264 end
1265 def tmp_root_dir
1266 defaults[:processing_dir_tmp_root]
1267 end
1268 def root_dir
1269 proposed_path_base=if defined? @rc['processing']['path'] \
1270 and not @rc['processing']['path'].nil? \
1271 and not @rc['processing']['path'].empty?
1272 x=if @rc['processing']['path'] =~/^(?:~|home)$/
1273 home #fix
1274 else @rc['processing']['path']
1275 end
1276 else nil
1277 end
1278 proposed_dir=if defined? @rc['processing']['dir'] \
1279 and not @rc['processing']['dir'].nil? \
1280 and not @rc['processing']['dir'].empty?
1281 @rc['processing']['dir']
1282 else defaults[:processing_dir]
1283 end
1284 v=SiSU_Env::InfoVersion.instance.get_version
1285 v_dev=(DEVELOPER[:maintenance]==:true) \
1286 ? "_#{v[:version]}"
1287 : ''
1288 path=if proposed_path_base \
1289 and FileTest.directory?(proposed_path_base) \
1290 and File.writable?("#{proposed_path_base}/.")
1291 x=proposed_dir \
1292 ? "#{proposed_path_base}/#{proposed_dir}"
1293 : "#{proposed_path_base}/#{defaults[:processing_dir]}"
1294 else defaults[:processing_dir_tmp_root]
1295 end
1296 path = path + v_dev
1297 end
1298 def usr_dir?
1299 case root_dir
1300 when /^\/home/ then false
1301 else true
1302 end
1303 end
1304 def stub_dir
1305 (usr_dir?) \
1306 ? ("#{root_dir}/#{user}/#{stub_pwd}")
1307 : ("#{root_dir}/#{stub_pwd}") # see defaults[:processing_path]
1308 end
1309 def stub_dir_orig # ends up with lang, if lang dir
1310 (usr_dir?) \
1311 ? ("#{root_dir}/#{user}/#{stub_pwd}")
1312 : ("#{root_dir}/#{stub_pwd}") # see defaults[:processing_path]
1313 end
1314 def processing_sisupod(opt=nil) #processing directory, used/needed for sisu work files, has sub-directories (ao,tex etc)
1315 @opt=opt
1316 def paths
1317 processing_path_usr="#{root_dir}/#{user}"
1318 processing_path_fnb=processing_path_usr \
1319 + '/' + Gt[:pods] \
1320 + '/' + @opt.fng
1321 processing_path_sisupod=processing_path_fnb \
1322 + '/' + Gt[:sisupod]
1323 {
1324 fnb: processing_path_fnb,
1325 sisupod: processing_path_sisupod,
1326 }
1327 end
1328 def make
1329 unless FileTest.directory?(root_dir)
1330 FileUtils::mkdir_p(root_dir)
1331 File.chmod(0777,root_dir)
1332 end
1333 if usr_dir?
1334 processing_path_usr="#{root_dir}/#{user}"
1335 FileUtils::mkdir_p(processing_path_usr) \
1336 unless FileTest.directory?(processing_path_usr)
1337 File.chmod(0700,processing_path_usr)
1338 end
1339 sisupod_processing_path=paths[:sisupod]
1340 FileUtils::mkdir_p(sisupod_processing_path) \
1341 unless FileTest.directory?(sisupod_processing_path)
1342 sisupod_processing_path_lng=if defined? @opt.lng
1343 sisupod_processing_path \
1344 + '/' + Gt[:doc] \
1345 + '/' + @opt.lng
1346 else
1347 sisupod_processing_path \
1348 + '/' + Gt[:doc]
1349 end
1350 unless FileTest.directory?(sisupod_processing_path_lng)
1351 #puts "a processing directory (#{sisupod_processing_path_lng}) is being created for use by sisu"
1352 FileUtils::mkdir_p(sisupod_processing_path_lng)
1353 File.chmod(0700,sisupod_processing_path_lng)
1354 end
1355 sisupod_processing_path
1356 end
1357 self
1358 end
1359 def processing #processing directory, used/needed for sisu work files, has sub-directories (ao,tex etc)
1360 unless FileTest.directory?(root_dir)
1361 FileUtils::mkdir_p(root_dir)
1362 File.chmod(0777,root_dir)
1363 end
1364 if usr_dir?
1365 processing_path_usr="#{root_dir}/#{user}"
1366 FileUtils::mkdir_p(processing_path_usr) \
1367 unless FileTest.directory?(processing_path_usr)
1368 File.chmod(0700,processing_path_usr)
1369 end
1370 FileUtils::mkdir_p(stub_dir) \
1371 unless FileTest.directory?(stub_dir)
1372 File.chmod(0700,stub_dir)
1373 path_processing=[
1374 stub_dir,
1375 defaults[:processing_path],
1376 defaults[:processing_path_home]
1377 ]
1378 processing=nil
1379 path_processing.each do |v| #
1380 processing=v
1381 unless FileTest.directory?(processing)
1382 FileUtils::mkdir_p(processing)
1383 File.chmod(0700,processing)
1384 end
1385 break
1386 end
1387 processing
1388 end
1389 def ao
1390 pth=if defined? @rc['processing']['dal'] \
1391 and @rc['processing']['dal'].is_a?(String)
1392 "#{processing}/#{@rc['processing']['dal']}"
1393 else "#{processing}/#{defaults[:processing_ao]}"
1394 end
1395 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1396 pth
1397 end
1398 def tune
1399 pth=if defined? @rc['processing']['tune'] \
1400 and @rc['processing']['tune'].is_a?(String)
1401 "#{processing}/#{@rc['processing']['tune']}"
1402 else "#{processing}/#{defaults[:processing_tune]}"
1403 end
1404 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1405 pth
1406 end
1407 def composite_file
1408 pth=processing_path.ao #"#{processing}/composite"
1409 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1410 pth
1411 end
1412 def git
1413 pth=if defined? @rc['git']['dir'] \
1414 and @rc['git']['dir'].is_a?(String)
1415 (@rc['git']['dir'] =~/^(?:~|home)$/) \
1416 ? home + '/' + Gt[:git]
1417 : @rc['git']['dir'] + '/' + Gt[:git]
1418 else defaults[:processing_git]
1419 end
1420 unless FileTest.directory?(pth)
1421 FileUtils::mkdir_p(pth)
1422 File.chmod(0700,pth)
1423 end
1424 pth
1425 end
1426 def odf_pth
1427 pth="#{processing}/odf/#{@fns}"
1428 pth
1429 end
1430 def odf
1431 odt
1432 end
1433 def odt
1434 pth=odf_pth + '/odt'
1435 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1436 pth
1437 end
1438 def odf
1439 pth="#{processing}/odf"
1440 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1441 pth
1442 end
1443 def odt_bld
1444 FileUtils::rm_rf(processing_path.odt)
1445 FileUtils::mkdir_p(processing_path.odt) \
1446 unless FileTest.directory?(processing_path.odt)
1447 FileUtils::mkdir_p("#{processing_path.odt}/Configurations2") \
1448 unless FileTest.directory?("#{processing_path.odt}/Configurations2")
1449 FileUtils::mkdir_p("#{processing_path.odt}/META-INF") \
1450 unless FileTest.directory?("#{processing_path.odt}/META-INF")
1451 FileUtils::mkdir_p("#{processing_path.odt}/Pictures") \
1452 unless FileTest.directory?("#{processing_path.odt}/Pictures")
1453 FileUtils::mkdir_p("#{processing_path.odt}/Thumbnails") \
1454 unless FileTest.directory?("#{processing_path.odt}/Thumbnails")
1455 processing_path.odt
1456 end
1457 def epub
1458 "#{processing}/epub/#{@fnb}"
1459 end
1460 def epub_bld #(md)
1461 FileUtils::rm_rf(processing_path.epub) \
1462 if FileTest.directory?(processing_path.epub)
1463 FileUtils::mkdir_p(processing_path.epub) \
1464 unless FileTest.directory?(processing_path.epub)
1465 FileUtils::mkdir_p("#{processing_path.epub}/META-INF") \
1466 unless FileTest.directory?("#{processing_path.epub}/META-INF")
1467 FileUtils::mkdir_p("#{processing_path.epub}/#{Ep[:d_oebps]}/image") \
1468 unless FileTest.directory?("#{processing_path.epub}/#{Ep[:d_oebps]}/image")
1469 FileUtils::mkdir_p("#{processing_path.epub}/#{Ep[:d_oebps]}/css") \
1470 unless FileTest.directory?("#{processing_path.epub}/#{Ep[:d_oebps]}/css")
1471 processing_path.epub
1472 end
1473 def epub_cp_images(md)
1474 pth="#{processing_path.epub}/#{Ep[:d_oebps]}/image"
1475 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1476 src="#{path.share}/image"
1477 images=%W[bullet_09.png arrow_next_red.png arrow_prev_red.png arrow_up_red.png]
1478 images.each do |i| #move to avoid repeated tests
1479 if FileTest.file?("#{src}/#{i}")
1480 FileUtils::cp("#{src}/#{i}","#{pth}/#{i}") \
1481 unless FileTest.file?("#{pth}/#{i}")
1482 else STDERR.puts %{\t*WARN* did not find image - "#{i}" [#{__FILE__}:#{__LINE__}]}
1483 end
1484 end
1485 pth
1486 end
1487 def tex
1488 pth=if defined? @rc['processing']['latex'] \
1489 and @rc['processing']['latex'].is_a?(String)
1490 "#{processing}/#{@rc['processing']['latex']}"
1491 else "#{processing}/#{defaults[:processing_latex]}"
1492 end
1493 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1494 pth
1495 end
1496 def texi
1497 pth=if defined? @rc['processing']['texinfo'] \
1498 and @rc['processing']['texinfo'].is_a?(String)
1499 "#{processing}/#{@rc['processing']['texinfo']}"
1500 else "#{processing}/#{defaults[:processing_texinfo]}"
1501 end
1502 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1503 pth
1504 end
1505 def texinfo #texinfo webserv, check
1506 "#{processing}/#{defaults[:processing_texinfo]}"
1507 end
1508 def manpage
1509 "#{path.output}/man"
1510 end
1511 def lout
1512 pth=if defined? @rc['processing']['lout'] \
1513 and @rc['processing']['lout'].is_a?(String)
1514 "#{processing}/#{@rc['processing']['lout']}"
1515 else "#{processing}/#{defaults[:processing_lout]}"
1516 end
1517 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1518 pth
1519 end
1520 def sql
1521 pth="#{processing}/sql"
1522 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1523 pth
1524 end
1525 def sqlite
1526 pth=if defined? @rc['processing']['sqlite'] \
1527 and @rc['processing']['sqlite'].is_a?(String)
1528 "#{processing}/#{@rc['processing']['sqlite']}"
1529 else "#{processing}/#{defaults[:processing_sqlite]}"
1530 end
1531 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1532 pth
1533 end
1534 def postgresql
1535 pth=if defined? @rc['processing']['postgresql'] \
1536 and @rc['processing']['postgresql'].is_a?(String)
1537 "#{processing}/#{@rc['processing']['postgresql']}"
1538 else "#{processing}/#{defaults[:processing_postgresql]}"
1539 end
1540 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1541 pth
1542 end
1543 self
1544 end
1545 def url
1546 def hostname
1547 "http://#{@sys.hostname}"
1548 end
1549 def dir_url
1550 "file://#{path.webserv}/#{stub_pwd}"
1551 end
1552 def localhost
1553 "http://localhost/#{stub_pwd}"
1554 end
1555 def local
1556 "http://#{hostname}/#{@stub_pwd}"
1557 end
1558 def root
1559 if defined? @rc['webserv']['url_root'] \
1560 and @rc['webserv']['url_root'] =~/https?:\/\//
1561 "#{@rc['webserv']['url_root']}/#{@stub_pwd}"
1562 elsif defined? @rc['webserv']['url_root'] \
1563 and @rc['webserv']['url_root'] =~/localhost/
1564 "http://localhost/#{@stub_pwd}"
1565 else "file://#{path.output}"
1566 end
1567 end
1568 def remote
1569 root
1570 end
1571 def txt
1572 "#{root}/txt"
1573 end
1574 def html
1575 "#{root}/html"
1576 end
1577 def epub
1578 "#{root}/epub"
1579 end
1580 def odt
1581 "#{root}/odt"
1582 end
1583 def pdf
1584 "#{root}/pdf"
1585 end
1586 def src_txt
1587 "#{root}/src"
1588 end
1589 def src_pod
1590 "#{root}/pod"
1591 end
1592 def pot
1593 "#{root}/po4a/pot"
1594 end
1595 def po
1596 "#{root}/po4a/po"
1597 end
1598 def webserv_host_base(opt=nil)
1599 if defined? @rc['webserv']['host']
1600 case @rc['webserv']['host']
1601 when /https?:\/\// then @rc['webserv']['host']
1602 when /\S+/ then "http://#{@rc['webserv']['host']}"
1603 else defaults[:webserv_host_cgi]
1604 end
1605 else defaults[:webserv_host_cgi]
1606 end
1607 end
1608 def webserv_cgi(opt=nil) #web url for local webserv (localhost, or hostname)
1609 http=if defined? @rc['webserv_cgi']['host'] \
1610 and @rc['webserv_cgi']['host'].is_a?(String)
1611 http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://') #check https? missing
1612 if port.webserv_port_cgi
1613 http + @rc['webserv_cgi']['host'] + ':' \
1614 + port.webserv_port_cgi + '/' \
1615 + @stub_pwd
1616 else
1617 http + @rc['webserv_cgi']['host'] + '/' \
1618 + @stub_pwd
1619 end
1620 else
1621 http=((webserv_host_base=~/https?:\/\//) ? '' : 'http://')
1622 if port.webserv_port_cgi(opt)
1623 http + webserv_host_base + ':' \
1624 + port.webserv_port_cgi(opt) + '/'\
1625 + @stub_pwd
1626 else
1627 http + webserv_host_base + '/' \
1628 + @stub_pwd
1629 end
1630 end
1631 http=http.strip
1632 end
1633 def webserv_base_cgi(opt=nil) #web url for local webserv (localhost, or hostname)
1634 http_cgi=if opt.selections.str =~/--webserv-(?:cgi|db|search)[=-]["']?(\S+)["']+/
1635 m=$1
1636 (m=~/http\/\/:/) ? m : %{http://#{m}}
1637 elsif defined? @rc['webserv_cgi']['host'] \
1638 and @rc['webserv_cgi']['host'].is_a?(String)
1639 http=((@rc['webserv_cgi']['host'] =~ /https?:\/\//) ? '' : 'http://')
1640 if port.webserv_port_cgi(opt)
1641 http + @rc['webserv_cgi']['host'] + ':' \
1642 + port.webserv_port_cgi(opt).to_s
1643 else
1644 http + @rc['webserv_cgi']['host']
1645 end
1646 else
1647 http=((webserv_host_base=~/https?:\/\//) ? '' : 'http://')
1648 if port.webserv_port_cgi(opt)
1649 http + webserv_host_base + ':' \
1650 + port.webserv_port_cgi(opt).to_s
1651 else http + webserv_host_base
1652 end
1653 end
1654 http_cgi=http_cgi.strip
1655 #%q{http://#{ENV['HTTP_HOST']}}
1656 end
1657 def webrick #must have a port #REMOVE
1658 if defined? @rc['webserv_cgi']['host'] \
1659 and @rc['webserv_cgi']['host'].is_a?(String)
1660 http=if @rc['webserv_cgi']['host'] =~/http:\/\//
1661 'http://'
1662 elsif @rc['webserv_cgi']['host'] =~/https:\/\//
1663 'https://'
1664 else defaults
1665 end
1666 http + @rc['webserv_cgi']['host']
1667 elsif webserv_host_base \
1668 and webserv_host_base.is_a?(String)
1669 webserv_host_base
1670 else
1671 #http + 'localhost'
1672 'localhost'
1673 end
1674 end
1675 def webserv #web url for local webserv (localhost, or hostname)
1676 if defined? @rc['webserv']['url_root'] \
1677 and @rc['webserv']['url_root'] =~/http/
1678 # needed for alternative output dir structures, fixes manifest url links, check may cause problems elsewhere
1679 @rc['webserv']['url_root']
1680 elsif path.webserv_dir \
1681 and path.webserv =~ /#{path.webserv_dir}/ #revisit
1682 path.webserv + '/' \
1683 + @base_markup_dir_stub.
1684 gsub(/#{path.webserv_dir}/,
1685 "#{url.hostname}/#{@stub_pwd}")
1686 elsif defined? @rc['webserv']['webrick_url'] \
1687 and @rc['webserv']['webrick_url']==false
1688 'file://' + path.webserv
1689 elsif port.webserv_port_cgi =~/\S+/
1690 url.hostname + ':' + port.webserv_port_cgi
1691 else
1692 url.hostname
1693 end
1694 end
1695 def webserv_base #web url for local webserv (localhost, or hostname)
1696 if path.webserv_dir \
1697 and path.webserv =~ /#{path.webserv_dir}/ #revisit
1698 path.webserv + '/' \
1699 + @stub_pwd.
1700 gsub(/#{path.webserv_dir}/,
1701 "#{url.hostname}")
1702 elsif defined? @rc['webserv']['webrick_url'] \
1703 and @rc['webserv']['webrick_url']==false
1704 "file://#{path.webserv}"
1705 else "#{url.webrick_base}"
1706 end
1707 end
1708 def webserv_files_from_db(opt=nil) #sort this out, messy
1709 if opt.selections.str =~/--webserv-output[=-]["']?(\S+)["']+/
1710 m=$1
1711 (m=~/(?:http|file\/)\/\/:/) ? m : %{http://#{m}}
1712 else
1713 show_output_on=if defined? @rc['webserv_cgi']['show_output_on']
1714 @rc['webserv_cgi']['show_output_on']
1715 elsif defined? @rc['webserv_cgi']['file_links']
1716 @rc['webserv_cgi']['file_links']
1717 else ''
1718 end
1719 m=case show_output_on
1720 when /webserv_cgi/ then url.webserv_base_cgi(opt)
1721 when /webserv/ then @rc['webserv']['url_root']
1722 when /https?:\/\// then @rc['webserv_cgi']['file_links']
1723 when /\S+/ then 'http://' + @rc['webserv_cgi']['file_links']
1724 else webserv_base_cgi(opt)
1725 end
1726 end
1727 #%q{http://#{ENV['HTTP_HOST']}/cgi-bin}
1728 end
1729 def cgi_sample_search_form_name(opt=nil)
1730 if opt.selections.str \
1731 =~/--(?:cgi-)?search-form-name[=-]["']?(\S+?\.cgi)/
1732 $1
1733 elsif not opt.selections.str =~/--db[=-]["']?sqlite/ \
1734 and defined? @rc['search'] \
1735 and defined? @rc['search']['sisu'] \
1736 and defined? @rc['search']['sisu']['action'] \
1737 and @rc['search']['sisu']['action'] =~/https?:\/\/\S+?\.cgi/
1738 /(?:https?:\/\/\S+?)\/([^\/]+?\.cgi)$/.
1739 match(@rc['search']['sisu']['action'])[1]
1740 else
1741 (opt.selections.str =~/--db[=-]["']?sqlite/) \
1742 ? "#{Db[:name_prefix_db]}sqlite.cgi" \
1743 : "#{Db[:name_prefix_db]}pg.cgi"
1744 end
1745 end
1746 def sample_search_form_title(organised_by=:language)
1747 title=if defined? @rc['search']['sisu']['title'] \
1748 and @rc['search']['sisu']['title'] =~/\S+/
1749 @rc['search']['sisu']['title']
1750 else %{SiSU (generated sample) search form}
1751 end
1752 title=title + " (content organised by #{organised_by})"
1753 end
1754 def output_tell #BROKEN Revisit 2011-02
1755 output_type=if defined? @rc['show_output_on'] \
1756 and @rc['show_output_on'] \
1757 =~/^(?:filesystem|webserv|(?:local|remote)(?:_webserv)?|webrick)/
1758 @rc['show_output_on']
1759 else 'filesystem'
1760 end
1761 case output_type
1762 when /^filesystem(?:_url)?/ then url.dir_url
1763 when /^remote(?:_webserv)?/ then url.remote
1764 when /^(?:webserv|local_webserv)/ then url.local
1765 when /^local(:\d+)/ then url.hostname + $1 + '/' + stub_pwd
1766 when /^localhost(:\d+)/ then url.localhost + $1 + '/' + stub_pwd
1767 when /^localhost/ then url.localhost
1768 when /^webrick/ then url.webrick
1769 when /^path/ then url.webserv_map_pwd
1770 else url.webserv_map_pwd
1771 end
1772 end
1773 def images
1774 "#{Xx[:html_relative2]}/_sisu/image"
1775 end
1776 #def images
1777 # '../_sisu/image'
1778 #end
1779 def images_local
1780 if FileTest.directory?(path.image_source_include)
1781 path.image_source_include
1782 else
1783 if @@local_image==true
1784 cmd=@md.opt.selections.str ? @md.opt.selections.str : ''
1785 SiSU_Screen::Ansi.new(
1786 cmd,
1787 "WARNING - no local image directory or images:",
1788 defaults[:image_local]
1789 ).warn unless @md.opt.act[:quiet][:set]==:on
1790 @@local_image=false
1791 end
1792 url.images
1793 end
1794 end
1795 def images_external
1796 if FileTest.directory?(image_external)
1797 if @@image_flag
1798 images=Dir.glob("#{image_external}/*.{png,jpg,gif}")
1799 pth=path.webserv + '/' \
1800 + @stub_pwd
1801 FileUtils::mkdir_p("#{pth}/_sisu/image_external") \
1802 unless FileTest.directory?("#{pth}/_sisu/image_external")
1803 images.each { |i| File.install(i,"#{pth}/#{i}") } \
1804 unless images.length > 0
1805 @@image_flag=false
1806 end
1807 "#{Xx[:html_relative2]}/_sisu/image_external"
1808 else
1809 if @@local_image==true
1810 SiSU_Screen::Ansi.new(
1811 @cmd,
1812 'WARNING - image directory for external images or no such images:',
1813 :image_external
1814 ).warn unless @md.opt.act[:quiet][:set]==:on
1815 @@local_image=false
1816 end
1817 url.images_external
1818 end
1819 end
1820 def images_epub
1821 './image'
1822 end
1823 self
1824 end
1825 def port
1826 def webrick_port
1827 if @md \
1828 and @md.opt.act[:sample_search_form][:set]==:on \
1829 and @md.opt.selections.str=~/port=(\d+)/
1830 $1
1831 else
1832 if defined? @rc['webserv_cgi']['port']
1833 if @rc['webserv_cgi']['port'].nil? \
1834 and (defined? @md.opt.selections \
1835 and @md.opt.selections.str=~/webrick/)
1836 defaults[:webserv_port_cgi]
1837 elsif not @rc['webserv_cgi']['port'].nil?
1838 @rc['webserv_cgi']['port']
1839 else defaults[:webserv_port_cgi]
1840 end
1841 else defaults[:webserv_port_cgi]
1842 end
1843 end
1844 end
1845 def webserv_port_cgi(opt=nil)
1846 port=if opt \
1847 and opt.act[:sample_search_form][:set]==:on \
1848 and opt.selections.str=~/port[=-](\d+)/
1849 $1
1850 else
1851 port=if defined? @rc['webserv_cgi']['port']
1852 if @rc['webserv_cgi']['port'].nil? \
1853 and (defined? opt.selections \
1854 and opt.selections.str=~/webrick/)
1855 defaults[:webserv_port_cgi]
1856 elsif not @rc['webserv_cgi']['port'].nil?
1857 @rc['webserv_cgi']['port']
1858 else nil
1859 end
1860 else
1861 if (defined? opt.selections \
1862 and opt.selections.str=~/webrick/)
1863 defaults[:webserv_port_cgi]
1864 else nil
1865 end
1866 end
1867 end
1868 port.to_s
1869 end
1870 self
1871 end
1872 def digest_conf?
1873 if defined? @rc['default']['digest'] \
1874 and @rc['default']['digest'] != nil
1875 case @rc['default']['digest']
1876 when /^sha(?:5|512)?$/ then :sha512
1877 when /^sha(?:2|256)?$/ then :sha256
1878 when /^md5$/ then :md5
1879 else :sha256
1880 end
1881 else :sha256
1882 end
1883 end
1884 def digest(opt=nil)
1885 @opt=opt
1886 def type
1887 if @opt
1888 case @opt.act[:hash_digest_algo]
1889 when :sha512 then :sha512
1890 when :sha256 then :sha256
1891 when :md5 then :md5
1892 else digest_conf?
1893 end
1894 else digest_conf?
1895 end
1896 end
1897 def length
1898 case digest(@opt).type
1899 when :sha512 then 128
1900 when :sha256 then 64
1901 when :md5 then 32
1902 else 64
1903 end
1904 end
1905 def pattern
1906 "[0-9a-f]{#{digest(@opt).length}}" #/[0-9a-f]{#{digest.length}}/
1907 end
1908 self
1909 end
1910 def program
1911 def text_editor
1912 if defined? @rc['program_select']['editor'] \
1913 and @rc['program_select']['editor'] =~/\S\S+/
1914 @rc['program_select']['editor']
1915 elsif defined? @rc['program_select']['text_editor'] \
1916 and @rc['program_select']['text_editor'] =~/\S\S+/
1917 @rc['program_select']['text_editor']
1918 else 'editor' #'gvim -c :R -c :S'
1919 end
1920 end
1921 def pdf_viewer
1922 ((defined? @rc['program_select']['pdf_viewer']) \
1923 && @rc['program_select']['pdf_viewer'] =~/\S\S+/) \
1924 ? @rc['program_select']['pdf_viewer']
1925 : 'pdf-viewer' #'evince'
1926 end
1927 def web_browser
1928 if defined? @rc['program_select']['www_browser'] \
1929 and @rc['program_select']['www_browser'] =~/\S\S+/
1930 @rc['program_select']['www_browser']
1931 elsif defined? @rc['program_select']['web_browser'] \
1932 and @rc['program_select']['web_browser'] =~/\S\S+/
1933 @rc['program_select']['web_browser']
1934 else 'x-www-browser' #'firefox' 'iceweasel' 'kazehakase' 'galeon'
1935 end
1936 end
1937 def www_browser
1938 web_browser
1939 end
1940 def console_web_browser
1941 if defined? @rc['program_select']['console_www_browser'] \
1942 and @rc['program_select']['console_www_browser'] =~/\S\S+/
1943 @rc['program_select']['console_www_browser']
1944 elsif defined? @rc['program_select']['console_web_browser'] \
1945 and @rc['program_select']['console_web_browser'] =~/\S\S+/
1946 @rc['program_select']['console_web_browser']
1947 else 'console-www-browser' #'lynx' 'links' 'links2' 'elinks' 'w3m'
1948 end
1949 end
1950 def console_www_browser
1951 web_browser
1952 end
1953 def epub_viewer
1954 ((defined? @rc['program_select']['epub_viewer']) \
1955 && @rc['program_select']['epub_viewer'] =~/\S\S+/) \
1956 ? @rc['program_select']['epub_viewer']
1957 : 'ebook-viewer' #'calibre' 'fbreader'
1958 end
1959 def xml_viewer
1960 ((defined? @rc['program_select']['xml_viewer']) \
1961 && @rc['program_select']['xml_viewer'] =~/\S\S+/) \
1962 ? @rc['program_select']['xml_viewer']
1963 : text_editor
1964 end
1965 def docbook_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 fictionbook_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 xml_editor
1978 xml_viewer
1979 end
1980 def odf_viewer
1981 ((defined? @rc['program_select']['odf_viewer']) \
1982 && @rc['program_select']['odf_viewer'] =~/\S\S+/) \
1983 ? @rc['program_select']['odf_viewer']
1984 : 'lowriter' #'odf-viewer','oowriter'
1985 end
1986 def manpage_viewer
1987 'man'
1988 end
1989 def manpage_generator
1990 ((defined? @rc['program_select']['man']) \
1991 && @rc['program_select']['man'] =~/\S\S+/) \
1992 ? @rc['program_select']['man']
1993 : 'nroff -man' #'nroff -man' #'groff -man -Tascii'
1994 end
1995 def texinfo
1996 ((defined? @rc['program_select']['info_viewer']) \
1997 && @rc['program_select']['info_viewer'] =~/\S\S+/) \
1998 ? @rc['program_select']['info_viewer']
1999 : 'pinfo -f' #'pinfo -f' 'info' 'tkinfo'
2000 end
2001 def file_encoding
2002 is=(defined? @rc['program_set']['file_encoding']) \
2003 ? @rc['program_set']['encoding'] : ''
2004 (is.nil? || is==true) ? 'encoding' : is
2005 end
2006 def wc #wordcount
2007 is=(defined? @rc['program_set']['wc']) \
2008 ? @rc['program_set']['wc'] : ''
2009 (is.nil? || is==true) ? 'wc' : is
2010 end
2011 def tidy
2012 is=(defined? @rc['program_set']['tidy']) \
2013 ? @rc['program_set']['tidy'] : nil
2014 (is.nil? || is==true) ? 'tidy' : is
2015 end
2016 def rmagick
2017 is=(defined? @rc['program_set']['rmagick']) \
2018 ? @rc['program_set']['rmagick'] : nil
2019 (is.nil? || is==true) ? 'rmagick' : is
2020 end
2021 def rexml #should be part of ruby 1.8 but apparently not always
2022 is=(defined? @rc['program_set']['rexml']) ? \
2023 @rc['program_set']['rexml'] : ''
2024 (is.nil? || is==true) ? 'rexml' : is
2025 end
2026 def pdflatex
2027 is=(defined? @rc['program_set']['pdflatex']) ? \
2028 @rc['program_set']['pdflatex'] : ''
2029 (is.nil? || is==true) ? 'pdflatex' : is
2030 end
2031 def postgresql
2032 is=(defined? @rc['program_set']['postgresql']) ? \
2033 @rc['program_set']['postgresql'] : ''
2034 (is.nil? || is==true) ? 'postgresql' : is
2035 end
2036 def sqlite
2037 is=(defined? @rc['program_set']['sqlite']) ? \
2038 @rc['program_set']['sqlite'] : ''
2039 (is.nil? || is==true) ? 'sqlite' : is
2040 end
2041 self
2042 end
2043 def i18n
2044 def language # language settings
2045 m=/.+\/\S+?\~(\S+)/
2046 pwd=Dir.pwd
2047 conf=(defined? @rc['default']['language']) \
2048 ? @rc['default']['language'] : nil
2049 l=if pwd=~ m then pwd[m,1] #2 directory: by visible directory name
2050 elsif conf then @rc['default']['language'] #3 config: from sisurc.yaml
2051 else defaults[:language] #4 sisu: program default
2052 end #1 document: param gets
2053 SiSU_Env::StandardiseLanguage.new(l)
2054 end
2055 #def multilingual
2056 # x=(defined? @rc['output_structure']['multilingual'] \
2057 # && @rc['output_structure']['multilingual'] ==true) \
2058 # ? true : false
2059 #end
2060 #def bundle
2061 # x=(defined? @rc['output_structure']['bundle'] \
2062 # && @rc['output_structure']['bundle'] ==true) \
2063 # ? true : false
2064 #end
2065 def lang_filename(l)
2066 @lang={}
2067 x=if output_dir_structure.by_language_code?
2068 (( defined? @rc['default']['language_file']) \
2069 && @rc['default']['language_file'] != nil) \
2070 ? @rc['default']['language_file']
2071 : 1
2072 else 0
2073 end
2074 if (l != defaults[:language_code]) \
2075 or (language.code != defaults[:language_code]) #watch
2076 if x==1 then @lang[:pre],@lang[:mid],@lang[:post]="#{l}.",'',''
2077 elsif x==2 then @lang[:pre],@lang[:mid],@lang[:post]='',".#{l}",''
2078 elsif x==3 then @lang[:pre],@lang[:mid],@lang[:post]='','',".#{l}"
2079 else @lang[:pre],@lang[:mid],@lang[:post]='','',''
2080 end
2081 else @lang[:pre],@lang[:mid],@lang[:post]='','',''
2082 end
2083 @lang
2084 end
2085 self
2086 end
2087 def file_encoding
2088 is=''
2089 if defined? @rc['program_set']['file_encoding']
2090 is=@rc['program_set']['encoding']
2091 end
2092 if is.nil? \
2093 or is==true
2094 is='encoding'
2095 end
2096 is
2097 end
2098 def papersize # paper settings, default overidden in param if set within document
2099 (defined? @rc['default']['papersize']) \
2100 ? @rc['default']['papersize'].downcase
2101 : (defaults[:papersize].downcase)
2102 end
2103 def odf_structure
2104 FileUtils::rm_rf(processing_path.processing_path.odf_pth)
2105 FileUtils::mkdir_p(processing_path.processing_path.odf_pth)
2106 system(
2107 "unzip -q #{path.share}/#{SiSU_is[:branch_name]}/odf/odt.zip -d #{processing_path.odf_pth}"
2108 #"unzip -q #{path.share}/#{SiSU_is[:branch_version]}/odf/odt.zip -d #{processing_path.odf_pth}"
2109 )
2110 end
2111 def sisupod_gen(fns_pod)
2112 sisupod_gen_v3(fns_pod)
2113 end
2114 def sisupod_gen_v3(fns_pod)
2115 pwd=Dir.pwd
2116 sisupod_processing_path=
2117 processing_path.processing + '/' + Gt[:sisupod]
2118 if FileTest.directory?(sisupod_processing_path) \
2119 or FileTest.file?(sisupod_processing_path)
2120 FileUtils::rm_rf(sisupod_processing_path)
2121 end
2122 unless FileTest.directory?(sisupod_processing_path)
2123 FileUtils::mkdir_p(sisupod_processing_path)
2124 end
2125 f_pod=if FileTest.file?("#{Dir.pwd}/#{fns_pod}")
2126 "#{Dir.pwd}/#{fns_pod}"
2127 elsif FileTest.file?(fns_pod)
2128 fns_pod
2129 end
2130 if f_pod \
2131 && FileTest.file?(f_pod)
2132 (SiSU_Env::SystemCall.new.program_found?('tree')) \
2133 ? 'tree ' + processing_path.processing + '/' + Gt[:sisupod]
2134 : ''
2135 if FileTest.directory?(processing_path.processing)
2136 Dir.chdir(processing_path.processing)
2137 system(%{tar xJf #{f_pod}})
2138 Dir.chdir(pwd)
2139 end
2140 #system(tree) #enable if (/[vVM]/)
2141 else
2142 SiSU_Screen::Ansi.new(
2143 '',
2144 '*WARN* file not found: ' + fns_pod
2145 ).warn unless @md.opt.act[:quiet][:set]==:on
2146 end
2147 sisupod_processing_path
2148 end
2149 def sisupod_gen_v2(fns_pod)
2150 sisupod_processing_path=
2151 processing_path.processing + '/' + Gt[:sisupod]
2152 if FileTest.directory?(sisupod_processing_path) \
2153 or FileTest.file?(sisupod_processing_path)
2154 FileUtils::rm_rf(sisupod_processing_path)
2155 end
2156 unless FileTest.directory?(sisupod_processing_path)
2157 FileUtils::mkdir_p(sisupod_processing_path)
2158 end
2159 (FileTest.file?(fns_pod)) \
2160 ? system("unzip -q #{fns_pod} -d #{processing_path.processing}")
2161 : (SiSU_Screen::Ansi.new(
2162 '',
2163 "*WARN* file not found: #{fns_pod}"
2164 ).warn unless @md.opt.act[:quiet][:set]==:on)
2165 sisupod_processing_path
2166 end
2167 end
2168 end
2169 __END__