c&d: some cruft
[software/sisu] / lib / sisu / current / se_file_op.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_file_op.rb;hb=HEAD>
55
56 =end
57 module SiSU_Info_File
58 require_relative 'utils' # utils.rb
59 require_relative 'se_info_env' # se_info_env.rb
60 begin
61 require 'fileutils'
62 include FileUtils::Verbose
63 rescue LoadError
64 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
65 error('fileutils NOT FOUND (LoadError)')
66 end
67 class InfoFile < SiSU_Info_Env::InfoEnv # se_info_env.rb
68 #todo unify with FileOp
69 def initialize(fns)
70 begin
71 super(fns)
72 @fns=fns
73 @env=SiSU_Env::InfoEnv.new(@fns)
74 m=/((.+?)(?:\~\w\w(?:_\w\w)?)?)\.((?:-|ssm\.)?sst|ssm)$/
75 @fnn,@fnb,@fnt=@fns[m,1],@fns[m,2],@fns[m,3]
76 rescue
77 SiSU_Screen::Ansi.new('',$!,$@).rescue do
78 __LINE__.to_s + ':' + __FILE__
79 end
80 ensure
81 end
82 end
83 def basefilename #Remove if possible
84 m=/(.+?)\.(?:(?:-|ssm\.)?sst|ssm)$/m
85 @fns[m,1]
86 end
87 def make_file(path,filename)
88 (File.writable?("#{path}/.")) \
89 ? File.new("#{path}/#{filename}",'w+')
90 : (SiSU_Screen::Ansi.new(
91 '',
92 "*WARN* is the file or directory writable?, could not create #{filename}"
93 ).warn)
94 end
95 def touch_file(path,filename)
96 if File.writable?("#{path}/.");
97 FileUtils::touch("#{path}/#{filename}")
98 else
99 SiSU_Screen::Ansi.new(
100 '',
101 "*WARN* is the file or directory writable?, could not create #{filename}"
102 ).warn
103 end
104 end
105 def make_path(path)
106 FileUtils::mkdir_p(path) unless FileTest.directory?(path)
107 end
108 def marshal
109 def ao_content
110 @env.processing_path.ao + '/' \
111 + @fns + '.content.rbm'
112 end
113 def ao_idx_sst_rel_html_seg
114 @env.processing_path.ao + '/' \
115 + @fns + '.idx_sst.rbm'
116 end
117 def ao_idx_sst_rel #used by tex & odf
118 @env.processing_path.ao + '/' \
119 + @fns + '.idx_raw.rbm'
120 end
121 def ao_idx_html
122 @env.processing_path.ao + '/' \
123 + @fns + '.idx_html.rbm'
124 end
125 def ao_idx_xhtml
126 @env.processing_path.ao + '/' \
127 + @fns + '.idx_xhtml.rbm'
128 end
129 def ao_metadata
130 @env.processing_path.ao + '/' \
131 + @fns + '.metadata.rbm'
132 end
133 def ao_map_nametags
134 @env.processing_path.ao + '/' \
135 + @fns + '.map_name_tags.rbm'
136 end
137 def ao_map_ocn_htmlseg
138 @env.processing_path.ao + '/' \
139 + @fns + '.map_ocn_htmlseg.rbm'
140 end
141 def html_tune
142 @env.processing_path.tune + '/' \
143 + @fns + '.marshal_tune'
144 end
145 def xhtml_tune
146 @env.processing_path.tune + '/' \
147 + @fns + '.marshal_tune'
148 end
149 self
150 end
151 def write_file_processing
152 def html_tune
153 File.new("#{@env.processing_path.tune}/#{@fns}.tune",'w+')
154 end
155 self
156 end
157 def mkdir #check moved from FileOp, existing mkdir
158 def processing
159 def ao
160 FileUtils::mkdir_p(@env.processing_path.ao) \
161 unless FileTest.directory?(@env.processing_path.ao)
162 end
163 def tune
164 FileUtils::mkdir_p(@env.processing_path.tune) \
165 unless FileTest.directory?(@env.processing_path.tune)
166 end
167 self
168 end
169 end
170 end
171 end
172 module SiSU_File_Op
173 require_relative 'constants' # constants.rb
174 require_relative 'utils' # utils.rb
175 begin
176 require 'fileutils'
177 include FileUtils::Verbose
178 rescue LoadError
179 SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
180 error('fileutils NOT FOUND (LoadError)')
181 end
182 class FileOp < SiSU_Info_File::InfoFile
183 #todo unify with CreateFile
184 def initialize(md,fno='')
185 begin
186 @md,@fno=md,fno
187 @env=SiSU_Env::InfoEnv.new(@md.fns)
188 rescue
189 SiSU_Screen::Ansi.new(md.opt.selections.str,$!,$@).rescue do
190 __LINE__.to_s + ':' + __FILE__
191 end
192 ensure
193 end
194 end
195 def output_dir_structure
196 SiSU_Env::ProcessingSettings.new(@md).output_dir_structure
197 end
198 def mkdir_initialize # not used but consider using
199 FileUtils::mkdir_p(output_path.base.dir) \
200 unless FileTest.directory?(output_path.base.dir)
201 FileUtils::mkdir_p("#{output_path.base.dir}/#{@md.fnb}") \
202 unless FileTest.directory?("#{output_path.base.dir}/#{@md.fnb}")
203 FileUtils::mkdir_p("#{output_path.base.dir}/#{@env.path.style}") \
204 unless FileTest.directory?("#{output_path.base.dir}/#{@env.path.style}")
205 FileUtils::mkdir_p(@env.processing_path.ao) \
206 unless FileTest.directory?(@env.processing_path.ao)
207 FileUtils::mkdir_p(@env.processing_path.tune) \
208 unless FileTest.directory?(@env.processing_path.tune)
209 end
210 def path_rel_links
211 def html_scroll_2
212 if output_dir_structure.by_language_code?
213 '../../'
214 elsif output_dir_structure.by_filetype?
215 '../'
216 else
217 '../'
218 end
219 end
220 def html_seg_2
221 if output_dir_structure.by_language_code?
222 '../../../'
223 elsif output_dir_structure.by_filetype?
224 '../../'
225 else
226 '../'
227 end
228 end
229 def html_scroll_1
230 if output_dir_structure.by_language_code?
231 '../'
232 elsif output_dir_structure.by_filetype?
233 '../'
234 else
235 './'
236 end
237 end
238 def html_seg_1
239 if output_dir_structure.by_language_code?
240 '../../'
241 elsif output_dir_structure.by_filetype?
242 '../../'
243 else
244 './'
245 end
246 end
247 def default_output_css
248 if (@md.opt.opt_act[:dump][:bool] \
249 && @md.opt.opt_act[:dump][:inst]) \
250 || (@md.opt.opt_act[:redirect][:bool] \
251 && @md.opt.opt_act[:redirect][:inst])
252 './'
253 elsif output_dir_structure.by_language_code?
254 '../../'
255 elsif output_dir_structure.by_filetype?
256 '../'
257 else
258 '../'
259 end
260 end
261 def html_scroll_css
262 default_output_css
263 end
264 def xhtml_css
265 default_output_css
266 end
267 def xml_css
268 default_output_css
269 end
270 def html_seg_css
271 if output_dir_structure.by_language_code?
272 '../../../'
273 elsif output_dir_structure.by_filetype?
274 '../../'
275 else
276 '../'
277 end
278 end
279 def manifest_css
280 if output_dir_structure.by_language_code?
281 '../../_sisu/css'
282 elsif output_dir_structure.by_filetype?
283 ''
284 else
285 '../'
286 end
287 end
288 self
289 end
290 def mkdir
291 def output
292 def base
293 FileUtils::mkdir_p(output_path.base.dir) \
294 unless FileTest.directory?(output_path.base.dir)
295 end
296 def css
297 FileUtils::mkdir_p("#{output_path.base.dir}/#{@env.path.style}") \
298 unless FileTest.directory?("#{output_path.base.dir}/#{@env.path.style}")
299 end
300 def epub
301 path=output_path.epub.dir
302 make_path(path)
303 end
304 self
305 end
306 self
307 end
308 def mkfile #consider using more
309 path="#{output_path.base.dir}/#{@md.fnb}"
310 make_path(path)
311 filename=@fno
312 make_file(path,filename)
313 end
314 def mkfile_pwd
315 path=Dir.pwd
316 filename=@fno
317 make_file(path,filename)
318 end
319 def write_file
320 def txt
321 path=output_path.txt.dir
322 make_path(path)
323 fn=base_filename.txt
324 make_file(path,fn)
325 end
326 def textile
327 path=output_path.textile.dir
328 make_path(path)
329 fn=base_filename.textile
330 make_file(path,fn)
331 end
332 def asciidoc
333 path=output_path.asciidoc.dir
334 make_path(path)
335 fn=base_filename.asciidoc
336 make_file(path,fn)
337 end
338 def markdown
339 path=output_path.markdown.dir
340 make_path(path)
341 fn=base_filename.markdown
342 make_file(path,fn)
343 end
344 def rst
345 path=output_path.rst.dir
346 make_path(path)
347 fn=base_filename.rst
348 make_file(path,fn)
349 end
350 def html_scroll
351 pth=output_path.html.dir
352 make_path(pth)
353 p_fn=place_file.html_scroll.dir
354 File.new(p_fn,'w+')
355 end
356 def html_seg_index
357 pth=((output_dir_structure.by_filename?) \
358 || (output_dir_structure.dump?)) \
359 ? "#{output_path.html.dir}"
360 : "#{output_path.html.dir}/#{@md.fnb}"
361 make_path(pth)
362 p_fn=place_file.html_seg_index.dir
363 File.new(p_fn,'w+')
364 end
365 def html_segtoc
366 pth=((output_dir_structure.by_filename?) \
367 || (output_dir_structure.dump?) \
368 || (output_dir_structure.redirect?)) \
369 ? "#{output_path.html.dir}"
370 : "#{output_path.html.dir}/#{@md.fnb}"
371 make_path(pth)
372 p_fn=place_file.html_segtoc.dir
373 File.new(p_fn,'w+')
374 end
375 def xhtml
376 path=output_path.xhtml.dir
377 make_path(path)
378 fn=base_filename.xhtml
379 make_file(path,fn)
380 end
381 def xml_sax
382 path=output_path.xml.dir
383 make_path(path)
384 fn=base_filename.xml_sax
385 make_file(path,fn)
386 end
387 def xml_dom
388 path=output_path.xml.dir
389 make_path(path)
390 fn=base_filename.xml_dom
391 make_file(path,fn)
392 end
393 def xml_docbook_book
394 path=output_path.xml_docbook_book.dir
395 make_path(path)
396 fn=base_filename.xml_docbook_book
397 make_file(path,fn)
398 end
399 def xml_fictionbook
400 path=output_path.xml_fictionbook.dir
401 make_path(path)
402 fn=base_filename.xml_fictionbook
403 make_file(path,fn)
404 end
405 def xml_scaffold_structure_sisu
406 path=output_path.xml_scaffold_structure_sisu.dir
407 make_path(path)
408 fn=base_filename.xml_scaffold_structure_sisu
409 make_file(path,fn)
410 end
411 def xml_scaffold_structure_collapse
412 path=output_path.xml_scaffold_structure_collapse.dir
413 make_path(path)
414 fn=base_filename.xml_scaffold_structure_collapse
415 make_file(path,fn)
416 end
417 def manpage
418 path=output_path.manpage.dir
419 make_path(path)
420 fn=base_filename.manpage
421 make_file(path,fn)
422 end
423 def texinfo
424 path=output_path.texinfo.dir
425 make_path(path)
426 fn=base_filename.texinfo
427 make_file(path,fn)
428 end
429 def info
430 path=output_path.texinfo.dir
431 make_path(path)
432 fn=base_filename.info
433 make_file(path,fn)
434 end
435 def hash_digest
436 path=output_path.hash_digest.dir
437 make_path(path)
438 fn=base_filename.hash_digest
439 make_file(path,fn)
440 end
441 def qrcode
442 path=output_path.qrcode.dir
443 make_path(path)
444 fn=base_filename.qrcode
445 make_file(path,fn)
446 end
447 def manifest
448 path=output_path.manifest.dir
449 make_path(path)
450 fn=base_filename.manifest
451 make_file(path,fn)
452 end
453 def manifest_txt
454 path=output_path.manifest.dir
455 make_path(path)
456 fn=base_filename.manifest_txt
457 make_file(path,fn)
458 end
459 def pot
460 path=output_path.pot.dir
461 make_path(path)
462 fn=base_filename.pot
463 make_file(path,fn)
464 end
465 def po
466 path=output_path.po.dir
467 make_path(path)
468 fn=base_filename.po
469 make_file(path,fn)
470 end
471 self
472 end
473 def place_file
474 def txt
475 def dir
476 output_path.txt.dir + '/' \
477 + base_filename.txt
478 end
479 def rel
480 output_path.txt.rel + '/' \
481 + base_filename.txt
482 end
483 self
484 end
485 def textile
486 def dir
487 output_path.textile.dir + '/' \
488 + base_filename.textile
489 end
490 def rel
491 output_path.textile.rel + '/' \
492 + base_filename.textile
493 end
494 self
495 end
496 def asciidoc
497 def dir
498 output_path.asciidoc.dir + '/' \
499 + base_filename.asciidoc
500 end
501 def rel
502 output_path.asciidoc.rel + '/' \
503 + base_filename.asciidoc
504 end
505 self
506 end
507 def markdown
508 def dir
509 output_path.markdown.dir + '/' \
510 + base_filename.markdown
511 end
512 def rel
513 output_path.markdown.rel + '/' \
514 + base_filename.markdown
515 end
516 self
517 end
518 def rst
519 def dir
520 output_path.rst.dir + '/' \
521 + base_filename.rst
522 end
523 def rel
524 output_path.rst.rel + '/' \
525 + base_filename.rst
526 end
527 self
528 end
529 def html_scroll
530 def dir
531 output_path.html_scroll.dir + '/' \
532 + base_filename.html_scroll
533 end
534 def rel
535 output_path.html_scroll.rel + '/' \
536 + base_filename.html_scroll
537 end
538 self
539 end
540 def html_seg_index
541 def dir
542 output_path.html_seg.dir + '/' \
543 + base_filename.html_seg_index
544 end
545 def rel
546 output_path.html_seg.rel + '/' \
547 + base_filename.html_seg_index
548 end
549 self
550 end
551 def html_segtoc
552 def dir
553 output_path.html_seg.dir + '/' \
554 + base_filename.html_segtoc
555 end
556 def rel
557 output_path.html_seg.rel + '/' \
558 + base_filename.html_segtoc
559 end
560 self
561 end
562 def html_book_index
563 def dir
564 output_path.html_seg.dir + '/' \
565 + base_filename.html_book_index
566 end
567 def rel
568 output_path.html_seg.rel + '/' \
569 + base_filename.html_book_index
570 end
571 self
572 end
573 def html_concordance
574 def dir
575 output_path.html_seg.dir + '/' \
576 + base_filename.html_concordance
577 end
578 def rel
579 output_path.html_seg.rel + '/' \
580 + base_filename.html_concordance
581 end
582 self
583 end
584 def odt
585 def dir
586 output_path.odt.dir + '/' \
587 + base_filename.odt
588 end
589 def rel
590 output_path.odt.rel + '/' \
591 + base_filename.odt
592 end
593 self
594 end
595 def epub
596 def dir
597 output_path.epub.dir + '/' \
598 + base_filename.epub
599 end
600 def rel
601 output_path.epub.rel + '/' \
602 + base_filename.epub
603 end
604 self
605 end
606 def pdf_p
607 STDERR.puts 'ERROR not available due to multiple page format sizes'
608 end
609 def pdf_l
610 STDERR.puts 'ERROR not available due to multiple page format sizes'
611 end
612 def xhtml
613 def dir
614 output_path.xhtml.dir + '/' \
615 + base_filename.xhtml
616 end
617 def rel
618 output_path.xhtml.rel + '/' \
619 + base_filename.xhtml
620 end
621 self
622 end
623 def xml_sax
624 def dir
625 output_path.xml.dir + '/' \
626 + base_filename.xml_sax
627 end
628 def rel
629 output_path.xml.rel + '/' \
630 + base_filename.xml_sax
631 end
632 self
633 end
634 def xml_dom
635 def dir
636 output_path.xml.dir + '/' \
637 + base_filename.xml_dom
638 end
639 def rel
640 output_path.xml.rel + '/' \
641 + base_filename.xml_dom
642 end
643 self
644 end
645 def xml_docbook_book
646 def dir
647 output_path.xml_docbook.dir + '/' \
648 + base_filename.xml_docbook_book
649 end
650 def rel
651 output_path.xml_docbook.rel + '/' \
652 + base_filename.xml_docbook_book
653 end
654 self
655 end
656 def xml_fictionbook
657 def dir
658 output_path.xml_fictionbook.dir + '/' \
659 + base_filename.xml_fictionbook
660 end
661 def rel
662 output_path.xml_fictionbook.rel + '/' \
663 + base_filename.xml_fictionbook
664 end
665 self
666 end
667 def xml_scaffold_structure_sisu
668 def dir
669 output_path.xml.dir + '/' \
670 + base_filename.xml_scaffold_structure_sisu
671 end
672 def rel
673 output_path.xml.rel + '/' \
674 + base_filename.xml_scaffold_structure_sisu
675 end
676 self
677 end
678 def xml_scaffold_structure_collapse
679 def dir
680 output_path.xml.dir + '/' \
681 + base_filename.xml_scaffold_structure_collapse
682 end
683 def rel
684 output_path.xml.rel + '/' \
685 + base_filename.xml_scaffold_structure_collapse
686 end
687 self
688 end
689 def sqlite_discrete
690 def dir
691 output_path.sqlite_discrete.dir + '/' \
692 + base_filename.sqlite_discrete
693 end
694 def rel
695 output_path.sqlite_discrete.rel + '/' \
696 + base_filename.sqlite_discrete
697 end
698 self
699 end
700 def hash_digest
701 def dir
702 output_path.hash_digest.dir + '/' \
703 + base_filename.hash_digest
704 end
705 def rel
706 output_path.hash_digest.rel + '/' \
707 + base_filename.hash_digest
708 end
709 self
710 end
711 def src
712 def dir
713 output_path.src.dir + '/' \
714 + base_filename.src
715 end
716 def rel
717 output_path.src.rel + '/' \
718 + base_filename.src
719 end
720 self
721 end
722 def sisupod
723 def dir
724 output_path.sisupod.dir + '/' \
725 + base_filename.sisupod
726 end
727 def rel
728 output_path.sisupod.rel + '/' \
729 + base_filename.sisupod
730 end
731 self
732 end
733 def po
734 def dir
735 output_path.po.dir + '/' \
736 + base_filename.po
737 end
738 def rel
739 output_path.po.rel + '/' \
740 + base_filename.po
741 end
742 self
743 end
744 def pot
745 def dir
746 output_path.pot.dir + '/' \
747 + base_filename.pot
748 end
749 def rel
750 output_path.pot.rel + '/' \
751 + base_filename.pot
752 end
753 self
754 end
755 def po_git
756 def dir
757 output_path.po_git + '/' \
758 + base_filename.po
759 end
760 def rel
761 #output_path.po_git + '/' + base_filename.po
762 end
763 self
764 end
765 def pot_git
766 def dir
767 output_path.pot_git + '/' \
768 + base_filename.pot
769 end
770 def rel
771 #output_path.pot_git + '/' + base_filename.pot
772 end
773 self
774 end
775 def manpage
776 def dir
777 output_path.manpage.dir + '/' \
778 + base_filename.manpage
779 end
780 def rel
781 output_path.manpage.rel + '/' \
782 + base_filename.manpage
783 end
784 self
785 end
786 def texinfo
787 def dir
788 output_path.texinfo.dir + '/' \
789 + base_filename.texinfo
790 end
791 def rel
792 output_path.texinfo.rel + '/' \
793 + base_filename.texinfo
794 end
795 self
796 end
797 def info
798 def dir
799 output_path.texinfo.dir + '/' \
800 + base_filename.info
801 end
802 def rel
803 output_path.texinfo.rel + '/' \
804 + base_filename.info
805 end
806 self
807 end
808 def qrcode_title
809 def dir
810 output_path.qrcode.dir + '/' \
811 + base_filename.qrcode_title
812 end
813 def rel
814 output_path.qrcode.rel + '/' \
815 + base_filename.qrcode_title
816 end
817 self
818 end
819 def qrcode_md
820 def dir
821 output_path.qrcode.dir + '/' \
822 + base_filename.qrcode_md
823 end
824 def rel
825 output_path.qrcode.rel + '/' \
826 + base_filename.qrcode_md
827 end
828 self
829 end
830 def manifest
831 def dir
832 output_path.manifest.dir + '/' \
833 + base_filename.manifest
834 end
835 def rel
836 output_path.manifest.rel + '/' \
837 + base_filename.manifest
838 end
839 self
840 end
841 self
842 end
843 def base_filename
844 def i18n(f)
845 f=default_hash.merge(f)
846 f[:lng] ||=@md.lang_code_insert
847 f[:fn] + f[:lng] + f[:ft]
848 end
849 def default_hash
850 {
851 fn: @md.fnb,
852 lng: @md.lang_code_insert,
853 }
854 end
855 def default_hash_build(fh,sfx)
856 if fh.is_a?(Hash)
857 fh[:fn] ||=@md.fnb
858 fh[:lng] ||= @md.lang_code_insert
859 fh[:ft]=sfx
860 fh
861 else
862 {
863 fn: @md.fnb,
864 lng: @md.lang_code_insert,
865 ft: sfx,
866 }
867 end
868 end
869 def lang_code?(lng)
870 (output_dir_structure.by_language_code?) \
871 ? ''
872 : (lng ||=@md.lang_code_insert)
873 end
874 def txt(fh=nil)
875 fh=default_hash_build(fh,Sfx[:txt])
876 fh[:lng]=lang_code?(fh[:lng])
877 fnh=if output_dir_structure.by_filename?
878 {
879 fn: 'plain',
880 ft: fh[:ft],
881 lng: fh[:lng],
882 }
883 else
884 {
885 fn: fh[:fn],
886 ft: fh[:ft],
887 lng: fh[:lng],
888 }
889 end
890 i18n(fnh)
891 end
892 def textile(fh=nil)
893 fh=default_hash_build(fh,Sfx[:txt_textile])
894 fh[:lng]=lang_code?(fh[:lng])
895 fnh=if output_dir_structure.by_filename?
896 {
897 fn: 'plain',
898 ft: fh[:ft],
899 lng: fh[:lng],
900 }
901 else
902 {
903 fn: fh[:fn],
904 ft: fh[:ft],
905 lng: fh[:lng],
906 }
907 end
908 i18n(fnh)
909 end
910 def asciidoc(fh=nil)
911 fh=default_hash_build(fh,Sfx[:txt_asciidoc])
912 fh[:lng]=lang_code?(fh[:lng])
913 fnh=if output_dir_structure.by_filename?
914 {
915 fn: 'plain',
916 ft: fh[:ft],
917 lng: fh[:lng],
918 }
919 else
920 {
921 fn: fh[:fn],
922 ft: fh[:ft],
923 lng: fh[:lng],
924 }
925 end
926 i18n(fnh)
927 end
928 def markdown(fh=nil)
929 fh=default_hash_build(fh,Sfx[:txt_markdown])
930 fh[:lng]=lang_code?(fh[:lng])
931 fnh=if output_dir_structure.by_filename?
932 {
933 fn: 'plain',
934 ft: fh[:ft],
935 lng: fh[:lng],
936 }
937 else
938 {
939 fn: fh[:fn],
940 ft: fh[:ft],
941 lng: fh[:lng],
942 }
943 end
944 i18n(fnh)
945 end
946 def rst(fh=nil)
947 fh=default_hash_build(fh,Sfx[:txt_rst])
948 fh[:lng]=lang_code?(fh[:lng])
949 fnh=if output_dir_structure.by_filename?
950 {
951 fn: 'plain',
952 ft: fh[:ft],
953 lng: fh[:lng],
954 }
955 else
956 {
957 fn: fh[:fn],
958 ft: fh[:ft],
959 lng: fh[:lng],
960 }
961 end
962 i18n(fnh)
963 end
964 def html_scroll(fh=nil)
965 fh=default_hash_build(fh,Sfx[:html])
966 fh[:lng]=lang_code?(fh[:lng])
967 fnh=if output_dir_structure.by_filename?
968 {
969 fn: 'scroll',
970 ft: fh[:ft],
971 lng: fh[:lng],
972 }
973 else
974 {
975 fn: fh[:fn],
976 ft: fh[:ft],
977 lng: fh[:lng],
978 }
979 end
980 i18n(fnh)
981 end
982 def html_seg_index(fh=nil)
983 fh=default_hash_build(fh,Sfx[:html])
984 fh[:lng]=lang_code?(fh[:lng])
985 fnh={
986 fn: 'index',
987 ft: fh[:ft],
988 lng: fh[:lng],
989 }
990 i18n(fnh)
991 end
992 def html_segtoc(fh=nil)
993 fh=default_hash_build(fh,Sfx[:html])
994 fnh=if output_dir_structure.dump_or_redirect?
995 {
996 fn: fh[:fn] + '.toc',
997 ft: fh[:ft],
998 }
999 else
1000 {
1001 fn: 'toc',
1002 ft: fh[:ft],
1003 lng: lang_code?(fh[:lng]),
1004 }
1005 end
1006 i18n(fnh)
1007 end
1008 def html_seg(fh)
1009 fh=default_hash_build(fh,Sfx[:html])
1010 fh[:lng]=lang_code?(fh[:lng])
1011 fnh={
1012 fn: fh[:fn],
1013 ft: fh[:ft],
1014 lng: fh[:lng],
1015 }
1016 i18n(fnh)
1017 end
1018 def html_book_index(fh=nil)
1019 fh=default_hash_build(fh,Sfx[:html])
1020 fh[:lng]=lang_code?(fh[:lng])
1021 fnh={
1022 fn: 'book_index',
1023 ft: fh[:ft],
1024 lng: fh[:lng],
1025 }
1026 i18n(fnh)
1027 end
1028 def html_concordance(fh=nil)
1029 fh=default_hash_build(fh,Sfx[:html])
1030 fh[:lng]=lang_code?(fh[:lng])
1031 fnh=if output_dir_structure.dump_or_redirect?
1032 {
1033 fn: 'concordance',
1034 ft: fh[:ft],
1035 }
1036 else
1037 {
1038 fn: 'concordance',
1039 ft: fh[:ft],
1040 lng: fh[:lng],
1041 }
1042 end
1043 i18n(fnh)
1044 end
1045 def xhtml(fh=nil)
1046 fh=default_hash_build(fh,Sfx[:xhtml])
1047 fh[:lng]=lang_code?(fh[:lng])
1048 fnh=if output_dir_structure.by_filename?
1049 {
1050 fn: 'scroll',
1051 ft: fh[:ft],
1052 lng: fh[:lng],
1053 }
1054 else
1055 {
1056 fn: fh[:fn],
1057 ft: fh[:ft],
1058 lng: fh[:lng],
1059 }
1060 end
1061 i18n(fnh)
1062 end
1063 def epub(fh=nil)
1064 fh=default_hash_build(fh,Sfx[:epub])
1065 fh[:lng]=lang_code?(fh[:lng])
1066 fnh={
1067 fn: fh[:fn],
1068 ft: fh[:ft],
1069 lng: fh[:lng],
1070 }
1071 i18n(fnh)
1072 end
1073 def odt(fh=nil)
1074 fh=default_hash_build(fh,Sfx[:odt])
1075 fh[:lng]=lang_code?(fh[:lng])
1076 fnh=if output_dir_structure.by_filename?
1077 {
1078 fn: 'opendocument',
1079 ft: fh[:ft],
1080 lng: fh[:lng],
1081 }
1082 else
1083 {
1084 fn: fh[:fn],
1085 ft: fh[:ft],
1086 lng: fh[:lng],
1087 }
1088 end
1089 i18n(fnh)
1090 end
1091 def xml_sax(fh=nil)
1092 fh=default_hash_build(fh,Sfx[:xml_sax])
1093 fh[:lng]=lang_code?(fh[:lng])
1094 fnh=if output_dir_structure.by_filename?
1095 {
1096 fn: 'scroll',
1097 ft: fh[:ft],
1098 lng: fh[:lng],
1099 }
1100 else
1101 {
1102 fn: fh[:fn],
1103 ft: fh[:ft],
1104 lng: fh[:lng],
1105 }
1106 end
1107 i18n(fnh)
1108 end
1109 def xml_dom(fh=nil)
1110 fh=default_hash_build(fh,Sfx[:xml_dom])
1111 fh[:lng]=lang_code?(fh[:lng])
1112 fnh=if output_dir_structure.by_filename?
1113 {
1114 fn: 'scroll',
1115 ft: fh[:ft],
1116 lng: fh[:lng],
1117 }
1118 else
1119 {
1120 fn: fh[:fn],
1121 ft: fh[:ft],
1122 lng: fh[:lng],
1123 }
1124 end
1125 i18n(fnh)
1126 end
1127 def xml_docbook_book(fh=nil)
1128 fh=default_hash_build(fh,Sfx[:xml_docbook_book])
1129 fh[:lng]=lang_code?(fh[:lng])
1130 fnh=if output_dir_structure.by_filename?
1131 {
1132 fn: 'scroll',
1133 ft: fh[:ft],
1134 lng: fh[:lng],
1135 }
1136 else
1137 {
1138 fn: fh[:fn],
1139 ft: fh[:ft],
1140 lng: fh[:lng],
1141 }
1142 end
1143 i18n(fnh)
1144 end
1145 def xml_fictionbook(fh=nil)
1146 fh=default_hash_build(fh,Sfx[:xml_fictionbook])
1147 fh[:lng]=lang_code?(fh[:lng])
1148 fnh=if output_dir_structure.by_filename?
1149 {
1150 fn: 'scroll',
1151 ft: fh[:ft],
1152 lng: fh[:lng],
1153 }
1154 else
1155 {
1156 fn: fh[:fn],
1157 ft: fh[:ft],
1158 lng: fh[:lng],
1159 }
1160 end
1161 i18n(fnh)
1162 end
1163 def xml_scaffold_structure_sisu(fh=nil)
1164 fh=default_hash_build(fh,Sfx[:xml_scaffold_structure_sisu])
1165 fh[:lng]=lang_code?(fh[:lng])
1166 fnh=if output_dir_structure.by_filename?
1167 {
1168 fn: 'scroll',
1169 ft: fh[:ft],
1170 lng: fh[:lng],
1171 }
1172 else
1173 {
1174 fn: fh[:fn],
1175 ft: fh[:ft],
1176 lng: fh[:lng],
1177 }
1178 end
1179 i18n(fnh)
1180 end
1181 def xml_scaffold_structure_collapse(fh=nil)
1182 fh=default_hash_build(fh,Sfx[:xml_scaffold_structure_collapse])
1183 fh[:lng]=lang_code?(fh[:lng])
1184 fnh=if output_dir_structure.by_filename?
1185 {
1186 fn: 'scroll',
1187 ft: fh[:ft],
1188 lng: fh[:lng],
1189 }
1190 else
1191 {
1192 fn: fh[:fn],
1193 ft: fh[:ft],
1194 lng: fh[:lng],
1195 }
1196 end
1197 i18n(fnh)
1198 end
1199 def pdf_p(fh=nil)
1200 fh=default_hash_build(fh,Sfx[:pdf])
1201 fh[:lng]=lang_code?(fh[:lng])
1202 if output_dir_structure.by_filename?
1203 'portrait' + fh[:lng] + '.'
1204 else
1205 fh[:fn] + '.portrait' + fh[:lng] + '.'
1206 end
1207 end
1208 def pdf_l(fh=nil)
1209 fh=default_hash_build(fh,Sfx[:pdf])
1210 fh[:lng]=lang_code?(fh[:lng])
1211 if output_dir_structure.by_filename?
1212 'landscape' + fh[:lng] + '.'
1213 else
1214 fh[:fn] + '.landscape' + fh[:lng] + '.'
1215 end
1216 end
1217 def pdf_p_a4(fh=nil)
1218 pdf_p(fh) + @md.fn[:pdf_p_a4]
1219 end
1220 def pdf_p_a5(fh=nil)
1221 pdf_p(fh) + @md.fn[:pdf_p_a5]
1222 end
1223 def pdf_p_b5(fh=nil)
1224 pdf_p(fh) + @md.fn[:pdf_p_b5]
1225 end
1226 def pdf_p_letter(fh=nil)
1227 pdf_p(fh) + @md.fn[:pdf_p_letter]
1228 end
1229 def pdf_p_legal(fh=nil)
1230 pdf_p(fh) + @md.fn[:pdf_p_legal]
1231 end
1232 def pdf_l_a4(fh=nil)
1233 pdf_l(fh) + @md.fn[:pdf_l_a4]
1234 end
1235 def pdf_l_a5(fh=nil)
1236 pdf_l(fh) + @md.fn[:pdf_l_a5]
1237 end
1238 def pdf_l_b5(fh=nil)
1239 pdf_l(fh) + @md.fn[:pdf_l_b5]
1240 end
1241 def pdf_l_letter(fh=nil)
1242 pdf_l(fh) + @md.fn[:pdf_l_letter]
1243 end
1244 def pdf_l_legal(fh=nil)
1245 pdf_l(fh) + @md.fn[:pdf_l_legal]
1246 end
1247 def manpage(fh=nil)
1248 fh=default_hash_build(fh,Sfx[:manpage])
1249 fh[:lng]=lang_code?(fh[:lng])
1250 fnh={
1251 fn: fh[:fn],
1252 ft: fh[:ft],
1253 lng: fh[:lng],
1254 }
1255 i18n(fnh)
1256 end
1257 def info(fh=nil)
1258 fh=default_hash_build(fh,Sfx[:info])
1259 fh[:lng]=lang_code?(fh[:lng])
1260 fnh={
1261 fn: fh[:fn],
1262 ft: fh[:ft],
1263 lng: fh[:lng],
1264 }
1265 i18n(fnh)
1266 end
1267 def texinfo(fh=nil)
1268 fh=default_hash_build(fh,Sfx[:texinfo])
1269 fh[:lng]=lang_code?(fh[:lng])
1270 fnh={
1271 fn: fh[:fn],
1272 ft: fh[:ft],
1273 lng: fh[:lng],
1274 }
1275 i18n(fnh)
1276 end
1277 def sqlite_discrete(fh=nil)
1278 fh=default_hash_build(fh,Sfx[:sql])
1279 fh[:lng]=lang_code?(fh[:lng])
1280 fnh={
1281 fn: fh[:fn],
1282 ft: fh[:ft],
1283 lng: fh[:lng],
1284 }
1285 i18n(fnh)
1286 end
1287 def hash_digest(fh=nil)
1288 fh=default_hash_build(fh,Sfx[:txt])
1289 fh[:lng]=lang_code?(fh[:lng])
1290 fnh=if output_dir_structure.by_language_code?
1291 {
1292 fn: fh[:fn] + '.hash_digest',
1293 ft: fh[:ft],
1294 }
1295 elsif output_dir_structure.by_filetype?
1296 {
1297 fn: fh[:fn],
1298 ft: fh[:ft],
1299 lng: fh[:lng],
1300 }
1301 else
1302 {
1303 fn: 'digest',
1304 ft: fh[:ft],
1305 lng: fh[:lng],
1306 }
1307 end
1308 i18n(fnh)
1309 end
1310 def sitemap(fh=nil)
1311 fh=default_hash_build(fh,Sfx[:xml])
1312 fh[:lng]=lang_code?(fh[:lng])
1313 fnh=if output_dir_structure.by_language_code?
1314 {
1315 fn: fh[:fn] + '.sitemap',
1316 ft: fh[:ft],
1317 }
1318 elsif output_dir_structure.by_filetype?
1319 {
1320 fn: fh[:fn],
1321 ft: fh[:ft],
1322 lng: fh[:lng],
1323 }
1324 else
1325 {
1326 fn: 'sitemap',
1327 ft: fh[:ft],
1328 lng: fh[:lng],
1329 }
1330 end
1331 i18n(fnh)
1332 end
1333 def qrcode_title(fh=nil)
1334 fh=default_hash_build(fh,'.title.png')
1335 fh[:lng]=lang_code?(fh[:lng])
1336 fnh=if output_dir_structure.by_filename?
1337 {
1338 fn: 'sisu_manifest',
1339 ft: fh[:ft],
1340 lng: fh[:lng],
1341 }
1342 else
1343 {
1344 fn: fh[:fn],
1345 ft: fh[:ft],
1346 lng: fh[:lng],
1347 }
1348 end
1349 i18n(fnh)
1350 end
1351 def qrcode_md #check name below
1352 fh=default_hash_build(fh,'.md.png')
1353 fh[:lng]=lang_code?(fh[:lng])
1354 fnh=if output_dir_structure.by_filename?
1355 {
1356 fn: 'sisu_manifest',
1357 ft: fh[:ft],
1358 lng: fh[:lng],
1359 }
1360 else
1361 {
1362 fn: fh[:fn],
1363 ft: fh[:ft],
1364 lng: fh[:lng],
1365 }
1366 end
1367 i18n(fnh)
1368 end
1369 def manifest_txt(fh=nil)
1370 fh=default_hash_build(fh,Sfx[:txt])
1371 fh[:lng]=lang_code?(fh[:lng])
1372 fnh=if output_dir_structure.by_filename?
1373 {
1374 fn: 'sisu_manifest',
1375 ft: fh[:ft],
1376 lng: fh[:lng],
1377 }
1378 else
1379 {
1380 fn: fh[:fn],
1381 ft: fh[:ft],
1382 lng: fh[:lng],
1383 }
1384 end
1385 i18n(fnh)
1386 end
1387 def manifest(fh=nil)
1388 fh=default_hash_build(fh,Sfx[:html])
1389 fh[:lng]=lang_code?(fh[:lng])
1390 fnh=if output_dir_structure.dump_or_redirect?
1391 {
1392 fn: fh[:fn] + '.manifest',
1393 ft: fh[:ft],
1394 lng: fh[:lng],
1395 }
1396 elsif output_dir_structure.by_filename?
1397 {
1398 fn: 'sisu_manifest',
1399 ft: fh[:ft],
1400 lng: fh[:lng],
1401 }
1402 else
1403 {
1404 fn: fh[:fn],
1405 ft: fh[:ft],
1406 lng: fh[:lng],
1407 }
1408 end
1409 i18n(fnh)
1410 end
1411 def src
1412 @md.fno
1413 end
1414 def po #check
1415 (@fno.empty?) \
1416 ? (@md.fn[:po])
1417 : (@fno + '.po')
1418 end
1419 def pot
1420 (@fno.empty?) \
1421 ? (@md.fn[:pot])
1422 : (@fno + '.pot')
1423 end
1424 def sisupod
1425 (@md.fns =~/\.ssm\.sst$/) \
1426 ? @md.fns.gsub(/(?:\~\S{2,3})?\.ssm\.sst$/,'.ssm.txz')
1427 : @md.fns.gsub(/(?:\~\S{2,3})?(\.sst)$/,'\1.txz')
1428 end
1429 self
1430 end
1431 def set_path(ft)
1432 @ft=ft
1433 def dir
1434 def abc
1435 if output_dir_structure.redirect?
1436 @md.opt.opt_act[:redirect][:inst] + '/' + @md.fnb
1437 elsif output_dir_structure.dump?
1438 @md.opt.opt_act[:dump][:inst]
1439 elsif output_dir_structure.by_language_code?
1440 output_path.base.dir + '/' + @md.opt.lng + '/' + @ft
1441 elsif output_dir_structure.by_filetype?
1442 output_path.base.dir + '/' + @ft
1443 else
1444 output_path.base.dir + '/' + @md.fnb
1445 end
1446 end
1447 def ab
1448 if output_dir_structure.redirect?
1449 @md.opt.opt_act[:redirect][:inst] + '/' + @md.fnb
1450 elsif output_dir_structure.dump?
1451 @md.opt.opt_act[:dump][:inst]
1452 elsif output_dir_structure.by_language_code?
1453 output_path.base.dir + '/' + @md.opt.lng + '/' + @ft
1454 else
1455 output_path.base.dir + '/' + @ft
1456 end
1457 end
1458 def ab_src
1459 if output_dir_structure.redirect?
1460 @md.opt.opt_act[:redirect][:inst] + '/' + @md.fnb
1461 elsif output_dir_structure.dump?
1462 @md.opt.opt_act[:dump][:inst]
1463 else
1464 output_path.base.dir + '/' \
1465 + @ft + '/' \
1466 + @md.opt.fng + '/' \
1467 + Gt[:sisupod] + '/' \
1468 + Gt[:doc] + '/' \
1469 + @md.opt.lng
1470 end
1471 end
1472 def ab_pod
1473 if output_dir_structure.redirect?
1474 @md.opt.opt_act[:redirect][:inst] + '/' + @md.fnb
1475 elsif output_dir_structure.dump?
1476 @md.opt.opt_act[:dump][:inst]
1477 else
1478 output_path.base.dir + '/' + @ft
1479 end
1480 end
1481 self
1482 end
1483 def url
1484 def abc
1485 if output_dir_structure.by_language_code?
1486 output_path.base.url + '/' + @md.opt.lng + '/' + @ft
1487 elsif output_dir_structure.by_filetype?
1488 output_path.base.url + '/' + @ft
1489 else
1490 output_path.base.url + '/' + @md.fnb
1491 end
1492 end
1493 def ab
1494 if output_dir_structure.by_language_code?
1495 output_path.base.url + '/' + @md.opt.lng + '/' + @ft
1496 else
1497 output_path.base.url + '/' + @ft
1498 end
1499 end
1500 def ab_src
1501 output_path.base.url + '/' \
1502 + @ft + '/' \
1503 + @md.opt.fng + '/' \
1504 + Gt[:sisupod] + '/' \
1505 + Gt[:doc] + '/' \
1506 + @md.opt.lng
1507 end
1508 def ab_pod
1509 output_path.base.url + '/' + @ft
1510 end
1511 self
1512 end
1513 def rel
1514 def abc
1515 if output_dir_structure.by_language_code?
1516 @md.opt.lng + '/' + @ft
1517 elsif output_dir_structure.by_filetype?
1518 @ft
1519 else
1520 @md.fnb
1521 end
1522 end
1523 def ab
1524 if output_dir_structure.by_language_code?
1525 @md.opt.lng + '/' + @ft
1526 else
1527 @ft
1528 end
1529 end
1530 def ab_src
1531 @ft
1532 end
1533 def ab_pod
1534 @ft
1535 end
1536 self
1537 end
1538 def rel_sm
1539 def abc
1540 if output_dir_structure.by_language_code?
1541 @md.opt.lng + '/' + @ft
1542 elsif output_dir_structure.by_filetype?
1543 @ft
1544 else
1545 @md.fnb
1546 end
1547 end
1548 def ab
1549 if output_dir_structure.dump_or_redirect?
1550 '.'
1551 elsif output_dir_structure.by_language_code? \
1552 or output_dir_structure.by_filetype?
1553 '../' + @ft
1554 else '.'
1555 end
1556 end
1557 def ab_src
1558 locate="#{@ft}/#{@md.opt.fng}/#{Gt[:sisupod]}/#{Gt[:doc]}/#{@md.opt.lng}"
1559 if output_dir_structure.dump_or_redirect?
1560 '.'
1561 elsif output_dir_structure.by_language_code?
1562 '../../' + locate
1563 else
1564 '../' + locate
1565 end
1566 end
1567 def ab_pod
1568 if output_dir_structure.dump_or_redirect?
1569 '.'
1570 elsif output_dir_structure.by_language_code?
1571 '../../' + @ft
1572 else
1573 '../' + @ft
1574 end
1575 end
1576 self
1577 end
1578 def rcp
1579 def abc
1580 if output_dir_structure.by_language_code?
1581 output_path.stub.rcp + '/' + @md.opt.lng + '/' + @ft
1582 elsif output_dir_structure.by_filetype?
1583 output_path.stub.rcp + '/' + @ft
1584 else
1585 output_path.stub.rcp + '/' + @md.fnb
1586 end
1587 end
1588 def ab
1589 if output_dir_structure.by_language_code?
1590 output_path.stub.rcp + '/' + @md.opt.lng + '/' + @ft
1591 else
1592 output_path.stub.rcp + '/' + @ft
1593 end
1594 end
1595 self
1596 end
1597 self
1598 end
1599 def output_path
1600 def web_base
1601 def dir
1602 @env.path.webserv
1603 end
1604 def url
1605 #"#{@env.url.root}"
1606 end
1607 def rel
1608 '.'
1609 end
1610 def rcp
1611 '.'
1612 end
1613 self
1614 end
1615 def stub
1616 def dir
1617 @md.opt.f_pth[:pth_stub]
1618 end
1619 #def url
1620 # "#{@env.url.root}"
1621 #end
1622 def rel
1623 './' + @md.opt.f_pth[:pth_stub]
1624 end
1625 def rcp
1626 @md.opt.f_pth[:pth_stub]
1627 end
1628 self
1629 end
1630 def webserver_path
1631 if output_dir_structure.dump?
1632 @md.opt.opt_act[:dump][:inst]
1633 elsif output_dir_structure.redirect?
1634 @md.opt.opt_act[:redirect][:inst]
1635 else
1636 @env.path.webserv
1637 end
1638 end
1639 def base
1640 def dir
1641 webserver_path + '/' + @md.opt.f_pth[:pth_stub]
1642 end
1643 def url
1644 @env.url.webserv + '/' + @md.opt.f_pth[:pth_stub]
1645 end
1646 def rel
1647 './' + @md.opt.f_pth[:pth_stub]
1648 end
1649 def rcp
1650 './' + @md.opt.f_pth[:pth_stub]
1651 end
1652 self
1653 end
1654 def sisugit
1655 def dir
1656 output_path.base.dir + '/git'
1657 end
1658 def url
1659 output_path.base.url + '/git'
1660 end
1661 def rel
1662 output_path.base.rel + '/git'
1663 end
1664 def rcp
1665 output_path.base.rcp + '/git'
1666 end
1667 self
1668 end
1669 #def pod
1670 # ft='pod'
1671 # path=set_path(ft).dir.ab
1672 #end
1673 def src
1674 def ft
1675 Gt[:src]
1676 end
1677 def dir
1678 set_path(ft).dir.ab_src
1679 end
1680 def url
1681 set_path(ft).url.ab_src
1682 end
1683 def rel
1684 set_path(ft).rel.ab_src
1685 end
1686 def rcp
1687 set_path(ft).rcp.ab_src
1688 end
1689 def rel_sm
1690 set_path(ft).rel_sm.ab_src
1691 end
1692 self
1693 end
1694 def sisupod
1695 def ft
1696 Gt[:src]
1697 end
1698 def dir
1699 set_path(ft).dir.ab_pod
1700 end
1701 def url
1702 set_path(ft).url.ab_pod
1703 end
1704 def rel
1705 set_path(ft).rel.ab_pod
1706 end
1707 def rcp
1708 set_path(ft).rcp.ab_pod
1709 end
1710 def rel_sm
1711 set_path(ft).rel_sm.ab_pod
1712 end
1713 self
1714 end
1715 def po
1716 def dir
1717 output_path.base.dir + '/' \
1718 + Gt[:src] + '/' \
1719 + @md.opt.fng + '/po4a/po/' \
1720 + @md.opt.lng
1721 end
1722 def url
1723 output_path.base.url + '/po4a/' \
1724 + @md.fnb + '/po/' \
1725 + @md.opt.lng
1726 end
1727 self
1728 end
1729 def pot
1730 def dir
1731 output_path.base.dir + '/' \
1732 + Gt[:src] + '/' \
1733 + @md.opt.fng + '/po4a/pot'
1734 end
1735 def url
1736 output_path.base.url + '/po4a/' \
1737 + @md.fnb + '/pot'
1738 end
1739 def rcp
1740 #p "#{output_path.base.dir}/po4a/#{@md.fnb}/pot"
1741 end
1742 self
1743 end
1744 def po_git # consider !!!
1745 def ft
1746 Gt[:po]
1747 end
1748 def dir
1749 pth=@env.processing_path.git + '/' \
1750 + @md.fnb + '/' \
1751 + ft + '/' \
1752 + @md.opt.lng
1753 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1754 pth
1755 end
1756 self
1757 end
1758 def pot_git # consider !!!
1759 def ft
1760 Gt[:pot]
1761 end
1762 def dir
1763 @env.processing_path.git + '/' \
1764 + @md.fnb + '/' \
1765 + ft
1766 end
1767 self
1768 end
1769 def md_harvest
1770 manifest
1771 self
1772 end
1773 def txt
1774 def ft
1775 'txt'
1776 end
1777 def dir
1778 set_path(ft).dir.abc
1779 end
1780 def url
1781 set_path(ft).url.abc
1782 end
1783 def rel
1784 set_path(ft).rel.abc
1785 end
1786 def rcp
1787 set_path(ft).rcp.abc
1788 end
1789 def rel_sm
1790 set_path(ft).rel_sm.ab
1791 end
1792 self
1793 end
1794 def textile
1795 def ft
1796 'textile' \
1797 + DEVELOPER[:under_construction]
1798 end
1799 def dir
1800 set_path(ft).dir.abc
1801 end
1802 def url
1803 set_path(ft).url.abc
1804 end
1805 def rel
1806 set_path(ft).rel.abc
1807 end
1808 def rcp
1809 set_path(ft).rcp.abc
1810 end
1811 def rel_sm
1812 set_path(ft).rel_sm.ab
1813 end
1814 self
1815 end
1816 def asciidoc
1817 def ft
1818 'asciidoc' \
1819 + DEVELOPER[:under_construction]
1820 end
1821 def dir
1822 set_path(ft).dir.abc
1823 end
1824 def url
1825 set_path(ft).url.abc
1826 end
1827 def rel
1828 set_path(ft).rel.abc
1829 end
1830 def rcp
1831 set_path(ft).rcp.abc
1832 end
1833 def rel_sm
1834 set_path(ft).rel_sm.ab
1835 end
1836 self
1837 end
1838 def markdown
1839 def ft
1840 'markdown' \
1841 + DEVELOPER[:under_construction]
1842 end
1843 def dir
1844 set_path(ft).dir.abc
1845 end
1846 def url
1847 set_path(ft).url.abc
1848 end
1849 def rel
1850 set_path(ft).rel.abc
1851 end
1852 def rcp
1853 set_path(ft).rcp.abc
1854 end
1855 def rel_sm
1856 set_path(ft).rel_sm.ab
1857 end
1858 self
1859 end
1860 def rst
1861 def ft
1862 'rst' \
1863 + DEVELOPER[:under_construction]
1864 end
1865 def dir
1866 set_path(ft).dir.abc
1867 end
1868 def url
1869 set_path(ft).url.abc
1870 end
1871 def rel
1872 set_path(ft).rel.abc
1873 end
1874 def rcp
1875 set_path(ft).rcp.abc
1876 end
1877 def rel_sm
1878 set_path(ft).rel_sm.ab
1879 end
1880 self
1881 end
1882 def html_scroll
1883 def ft
1884 'html'
1885 end
1886 def dir
1887 set_path(ft).dir.abc
1888 end
1889 def url
1890 set_path(ft).url.abc
1891 end
1892 def rel
1893 set_path(ft).rel.abc
1894 end
1895 def rcp
1896 set_path(ft).rcp.abc
1897 end
1898 def rel_sm
1899 set_path(ft).rel_sm.ab
1900 end
1901 def rel_image
1902 if output_dir_structure.dump_or_redirect?
1903 './image'
1904 elsif output_dir_structure.by_language_code?
1905 '../../_sisu/image'
1906 elsif output_dir_structure.by_filetype?
1907 '../_sisu/image'
1908 else
1909 '../_sisu/image'
1910 end
1911 end
1912 self
1913 end
1914 def html_seg
1915 def ft
1916 'html/' + @md.fnb
1917 end
1918 def dir
1919 set_path(ft).dir.abc
1920 end
1921 def url
1922 set_path(ft).url.abc
1923 end
1924 def rel
1925 set_path(ft).rel.abc
1926 end
1927 def rcp
1928 set_path(ft).rcp.abc
1929 end
1930 def rel_sm
1931 set_path(ft).rel_sm.ab
1932 end
1933 def rel_image
1934 if output_dir_structure.dump_or_redirect?
1935 './image'
1936 elsif output_dir_structure.by_language_code?
1937 '../../../_sisu/image'
1938 elsif output_dir_structure.by_filetype?
1939 '../../_sisu/image'
1940 else
1941 '../_sisu/image'
1942 end
1943 end
1944 self
1945 end
1946 def html_concordance
1947 html_seg
1948 self
1949 end
1950 def html
1951 def ft
1952 'html'
1953 end
1954 def dir
1955 set_path(ft).dir.abc
1956 end
1957 def url
1958 set_path(ft).url.abc
1959 end
1960 def rel
1961 set_path(ft).url.abc
1962 end
1963 def rcp
1964 set_path(ft).rcp.abc
1965 end
1966 def rel_sm
1967 set_path(ft).rel_sm.ab
1968 end
1969 def rel_image
1970 if output_dir_structure.by_language_code?
1971 '../../_sisu/image'
1972 elsif output_dir_structure.by_filetype?
1973 '../_sisu/image'
1974 else
1975 '../_sisu/image'
1976 end
1977 end
1978 self
1979 end
1980 def xhtml
1981 def ft
1982 'xhtml'
1983 end
1984 def dir
1985 set_path(ft).dir.abc
1986 end
1987 def url
1988 set_path(ft).url.abc
1989 end
1990 def rel
1991 set_path(ft).rel.abc
1992 end
1993 def rcp
1994 set_path(ft).rcp.abc
1995 end
1996 def rel_sm
1997 set_path(ft).rel_sm.ab
1998 end
1999 def rel_image
2000 '../../_sisu/image'
2001 end
2002 self
2003 end
2004 def epub
2005 def ft
2006 'epub'
2007 end
2008 def dir
2009 set_path(ft).dir.ab
2010 end
2011 def url
2012 set_path(ft).url.ab
2013 end
2014 def rel
2015 set_path(ft).rel.ab
2016 end
2017 def rcp
2018 set_path(ft).rcp.ab
2019 end
2020 def rel_sm
2021 set_path(ft).rel_sm.ab
2022 end
2023 def rel_image
2024 './image'
2025 end
2026 self
2027 end
2028 def odt
2029 def ft
2030 'odt'
2031 end
2032 def dir
2033 set_path(ft).dir.abc
2034 end
2035 def url
2036 set_path(ft).url.abc
2037 end
2038 def rel
2039 set_path(ft).rel.abc
2040 end
2041 def rcp
2042 set_path(ft).rcp.abc
2043 end
2044 def rel_sm
2045 set_path(ft).rel_sm.ab
2046 end
2047 self
2048 end
2049 def xml
2050 def ft
2051 'xml'
2052 end
2053 def dir
2054 set_path(ft).dir.abc
2055 end
2056 def url
2057 set_path(ft).url.abc
2058 end
2059 def rel
2060 set_path(ft).rel.abc
2061 end
2062 def rcp
2063 set_path(ft).rcp.abc
2064 end
2065 def rel_sm
2066 set_path(ft).rel_sm.ab
2067 end
2068 def rel_image
2069 '../../_sisu/image'
2070 end
2071 self
2072 end
2073 def xml_sax
2074 xml
2075 self
2076 end
2077 def xml_dom
2078 xml
2079 self
2080 end
2081 def xml_docbook
2082 def ft
2083 'docbook'
2084 end
2085 def dir
2086 set_path(ft).dir.abc
2087 end
2088 def url
2089 set_path(ft).url.abc
2090 end
2091 def rel
2092 set_path(ft).rel.abc
2093 end
2094 def rcp
2095 set_path(ft).rcp.abc
2096 end
2097 def rel_sm
2098 set_path(ft).rel_sm.ab
2099 end
2100 def rel_image
2101 '../../_sisu/image'
2102 end
2103 self
2104 end
2105 def xml_docbook_article
2106 def ft
2107 'docbook' \
2108 + DEVELOPER[:under_construction]
2109 end
2110 def dir
2111 set_path(ft).dir.abc
2112 end
2113 def url
2114 set_path(ft).url.abc
2115 end
2116 def rel
2117 set_path(ft).rel.abc
2118 end
2119 def rcp
2120 set_path(ft).rcp.abc
2121 end
2122 def rel_sm
2123 set_path(ft).rel_sm.ab
2124 end
2125 def rel_image
2126 '../../_sisu/image'
2127 end
2128 self
2129 end
2130 def xml_docbook_book
2131 def ft
2132 'docbook'
2133 end
2134 def dir
2135 set_path(ft).dir.abc
2136 end
2137 def url
2138 set_path(ft).url.abc
2139 end
2140 def rel
2141 set_path(ft).rel.abc
2142 end
2143 def rcp
2144 set_path(ft).rcp.abc
2145 end
2146 def rel_sm
2147 set_path(ft).rel_sm.ab
2148 end
2149 def rel_image
2150 '../../_sisu/image'
2151 end
2152 self
2153 end
2154 def xml_fictionbook
2155 def ft
2156 'fictionbook' \
2157 + DEVELOPER[:under_construction]
2158 end
2159 def dir
2160 set_path(ft).dir.abc
2161 end
2162 def url
2163 set_path(ft).url.abc
2164 end
2165 def rel
2166 set_path(ft).rel.abc
2167 end
2168 def rcp
2169 set_path(ft).rcp.abc
2170 end
2171 def rel_sm
2172 set_path(ft).rel_sm.ab
2173 end
2174 def rel_image
2175 '../../_sisu/image'
2176 end
2177 self
2178 end
2179 def xml_scaffold_structure_sisu
2180 def ft
2181 'sisu.scaffold.xml'
2182 #'xml'
2183 end
2184 def dir
2185 set_path(ft).dir.abc
2186 end
2187 def url
2188 set_path(ft).url.abc
2189 end
2190 def rel
2191 set_path(ft).rel.abc
2192 end
2193 def rcp
2194 set_path(ft).rcp.abc
2195 end
2196 def rel_sm
2197 set_path(ft).rel_sm.ab
2198 end
2199 def rel_image
2200 '../../_sisu/image'
2201 end
2202 self
2203 end
2204 def xml_scaffold_structure_collapse
2205 def ft
2206 'collapsed.scaffold.xml'
2207 #'xml'
2208 end
2209 def dir
2210 set_path(ft).dir.abc
2211 end
2212 def url
2213 set_path(ft).url.abc
2214 end
2215 def rel
2216 set_path(ft).rel.abc
2217 end
2218 def rcp
2219 set_path(ft).rcp.abc
2220 end
2221 def rel_sm
2222 set_path(ft).rel_sm.ab
2223 end
2224 def rel_image
2225 '../../_sisu/image'
2226 end
2227 self
2228 end
2229 def pdf
2230 def ft
2231 'pdf'
2232 end
2233 def dir
2234 set_path(ft).dir.abc
2235 end
2236 def url
2237 set_path(ft).url.abc
2238 end
2239 def rel
2240 set_path(ft).rel.abc
2241 end
2242 def rcp
2243 set_path(ft).rcp.abc
2244 end
2245 def rel_sm
2246 set_path(ft).rel_sm.ab
2247 end
2248 self
2249 end
2250 def sqlite_discrete
2251 def ft
2252 'sql'
2253 end
2254 def dir
2255 set_path(ft).dir.ab
2256 end
2257 def url
2258 set_path(ft).url.ab
2259 end
2260 def rel
2261 set_path(ft).rel.ab
2262 end
2263 def rcp
2264 set_path(ft).rcp.ab
2265 end
2266 def rel_sm
2267 set_path(ft).rel_sm.ab
2268 end
2269 self
2270 end
2271 def hash_digest
2272 def ft
2273 'hashes'
2274 end
2275 def dir
2276 set_path(ft).dir.abc
2277 end
2278 def url
2279 set_path(ft).url.abc
2280 end
2281 def rel
2282 set_path(ft).rel.abc
2283 end
2284 def rcp
2285 set_path(ft).rcp.abc
2286 end
2287 def rel_sm
2288 set_path(ft).rel_sm.ab
2289 end
2290 self
2291 end
2292 def manifest
2293 def ft
2294 'manifest'
2295 end
2296 def dir
2297 set_path(ft).dir.abc
2298 end
2299 def url
2300 set_path(ft).url.abc
2301 end
2302 def rel
2303 set_path(ft).rel.abc
2304 end
2305 def rel_image
2306 if output_dir_structure.dump_or_redirect?
2307 './image'
2308 elsif output_dir_structure.by_language_code?
2309 '../../_sisu/image'
2310 elsif output_dir_structure.by_filetype?
2311 '../_sisu/image'
2312 else
2313 '../_sisu/image'
2314 end
2315 end
2316 def rcp
2317 set_path(ft).rcp.abc
2318 end
2319 self
2320 end
2321 def qrcode
2322 def ft
2323 'manifest/qrcode'
2324 end
2325 def dir
2326 set_path(ft).dir.abc
2327 end
2328 def url
2329 set_path(ft).url.abc
2330 end
2331 def rel
2332 set_path(ft).rel.abc
2333 end
2334 def rcp
2335 set_path(ft).rcp.abc
2336 end
2337 def rel_sm
2338 set_path(ft).rel_sm.ab
2339 end
2340 self
2341 end
2342 def harvest
2343 def ft
2344 'site_metadata'
2345 end
2346 def dir
2347 set_path(ft).dir.ab
2348 end
2349 def url
2350 set_path(ft).url.ab
2351 end
2352 def rel
2353 set_path(ft).rel.ab
2354 end
2355 def rcp
2356 set_path(ft).rcp.ab
2357 end
2358 def rel_sm
2359 if output_dir_structure.by_language_code?
2360 ''
2361 elsif output_dir_structure.by_filetype?
2362 ''
2363 else
2364 ''
2365 end
2366 end
2367 self
2368 end
2369 def manpage
2370 def ft
2371 'man'
2372 end
2373 def dir
2374 set_path(ft).dir.ab
2375 end
2376 def url
2377 set_path(ft).url.ab
2378 end
2379 def rel
2380 set_path(ft).rel.ab
2381 end
2382 def rcp
2383 set_path(ft).rcp.ab
2384 end
2385 def rel_sm
2386 set_path(ft).rel_sm.ab
2387 end
2388 self
2389 end
2390 def texinfo
2391 def ft
2392 'texinfo'
2393 end
2394 def dir
2395 set_path(ft).dir.ab
2396 end
2397 def url
2398 set_path(ft).url.ab
2399 end
2400 def rel
2401 set_path(ft).rel.ab
2402 end
2403 def rcp
2404 set_path(ft).rcp.ab
2405 end
2406 def rel_sm
2407 set_path(ft).rel_sm.ab
2408 end
2409 self
2410 end
2411 def sitemaps
2412 def ft
2413 'sitemaps'
2414 end
2415 def dir
2416 set_path(ft).dir.ab
2417 end
2418 def url
2419 set_path(ft).url.ab
2420 end
2421 def rel
2422 set_path(ft).rel.ab
2423 end
2424 def rcp
2425 set_path(ft).rcp.ab
2426 end
2427 self
2428 end
2429 def sqlite #check url
2430 def dir
2431 output_path.base.dir
2432 end
2433 def url
2434 output_path.base.url
2435 end
2436 def rel
2437 output_path.base.rel
2438 end
2439 def rcp
2440 output_path.base.rcp
2441 end
2442 self
2443 end
2444 #def cgi
2445 #end
2446 def css
2447 @d='_sisu/css'
2448 def dir
2449 output_path.base.dir + '/' + @d
2450 end
2451 def url
2452 output_path.base.url + '/' + @d
2453 end
2454 def rel
2455 @d
2456 #output_path.base.rel + '/' + @d
2457 end
2458 def rcp
2459 output_path.stub.rcp + '/' + @d
2460 end
2461 self
2462 end
2463 def images
2464 @d='_sisu/image'
2465 def dir
2466 output_path.base.dir + '/' + @d
2467 end
2468 def url
2469 output_path.base.url + '/' + @d
2470 end
2471 def rel
2472 @d
2473 #output_path.base.rel + '/' + @d
2474 end
2475 def rcp
2476 output_path.stub.rcp + '/' + @d
2477 end
2478 self
2479 end
2480 def images_external
2481 @d='_sisu/image_external'
2482 def dir
2483 output_path.base.dir + '/' + @d
2484 end
2485 def url
2486 output_path.base.url + '/' + @d
2487 end
2488 def rel
2489 output_path.base.rel + '/' + @d
2490 end
2491 def rcp
2492 output_path.base.rcp + '/' + @d
2493 end
2494 self
2495 end
2496 #def css
2497 # #"#{@env.path.output}/#{@env.path.style}"
2498 #end
2499 self
2500 end
2501 end
2502 end
2503 module SiSU_Create_File
2504 require_relative 'constants' # constants.rb
2505 require_relative 'utils' # utils.rb
2506 require_relative 'se_info_env' # se_info_env.rb
2507 class CreateFile < SiSU_Info_Env::InfoEnv # se_info_env.rb
2508 #todo unify with FileOp
2509 def initialize(fns)
2510 begin
2511 super(fns)
2512 @env=SiSU_Env::InfoEnv.new(fns)
2513 rescue
2514 SiSU_Screen::Ansi.new('',$!,$@).rescue do
2515 __LINE__.to_s + ':' + __FILE__
2516 end
2517 ensure
2518 end
2519 end
2520 def html_root
2521 #@env.path.output
2522 end
2523 def mkdir_pdf
2524 Dir.mkdir(@env.processing_path.tex) \
2525 unless FileTest.directory?(@env.processing_path.tex)
2526 end
2527 def file_generic(output_file='')
2528 fn=@env.path.output + '/' \
2529 + @fnb + '/' \
2530 + output_file
2531 File.new(fn,'w+')
2532 end
2533 def file_error
2534 fn='/tmp/errorlog.sisu'
2535 File.new(fn,'w+')
2536 end
2537 def file_txt
2538 fn=@env.processing_path.ao + '/' \
2539 + @fns + '.txt'
2540 File.new(fn,'w+')
2541 end
2542 def file_debug
2543 fn=@env.processing_path.ao + '/' \
2544 + @fns + '.debug.txt'
2545 File.new(fn,'w+')
2546 end
2547 def metaverse
2548 def file_meta
2549 fn=@env.processing_path.ao + '/' \
2550 + @fns + '.meta'
2551 File.new(fn,'w+')
2552 end
2553 def file_meta_idx_html
2554 fn=@env.processing_path.ao + '/' \
2555 + @fns + '.idx.html'
2556 File.new(fn,'w+')
2557 end
2558 self
2559 end
2560 def file_note
2561 fn=Dir.pwd + '/' \
2562 + @fns + '.fn'
2563 File.new(fn,'w+')
2564 end
2565 def meta
2566 @env.processing_path.ao + '/' \
2567 + @fns + '.meta'
2568 end
2569 def file_semantic
2570 fn='./semantic.yaml'
2571 File.new(fn,'w+')
2572 end
2573 def file_rss
2574 fn='./semantic.xml'
2575 File.new(fn,'w+')
2576 end
2577 def epub
2578 @pth=@env.processing_path.epub
2579 def xhtml_index
2580 fn=@pth + '/' \
2581 + Ep[:d_oebps] + '/index.xhtml'
2582 File.new(fn,'w+')
2583 end
2584 def xhtml_cover_image
2585 fn=@pth + '/' \
2586 + Ep[:d_oebps] + '/cover_image.xhtml'
2587 File.new(fn,'w+')
2588 end
2589 def xhtml_segtoc
2590 fn=@pth + '/' \
2591 + Ep[:d_oebps] + '/toc.xhtml'
2592 File.new(fn,'w+')
2593 end
2594 def mimetype #fixed application/epub+zip ~/grotto/theatre/dbld/builds/epub_sample/mimetype
2595 File.new("#{@pth}/mimetype",'w')
2596 end
2597 def metadata #variable matadata ~/grotto/theatre/dbld/builds/epub_sample/metadata.opf
2598 fn=@pth + '/' \
2599 + Ep[:d_oebps] + '/' \
2600 + Ep[:f_opf]
2601 File.new(fn,'w')
2602 end
2603 def toc_ncx #variable toc ~/grotto/theatre/dbld/builds/epub_sample/toc.ncx
2604 fn=@pth + '/' \
2605 + Ep[:d_oebps] + '/' \
2606 + Ep[:f_ncx]
2607 File.new(fn,'w')
2608 end
2609 def metainf_cont #variable content ~/grotto/theatre/dbld/builds/epub_sample/META-INF/container.xml
2610 fn=@pth + '/META-INF/container.xml'
2611 File.new(fn,'w')
2612 end
2613 def xhtml_css #fixed epub xhtml css
2614 fn=@pth + '/' \
2615 + Ep[:d_oebps] + '/css/xhtml.css'
2616 File.new(fn,'w')
2617 end
2618 self
2619 end
2620 def file_texinfo
2621 fn=@env.processing_path.texinfo + '/' \
2622 + @fnb + '.texinfo'
2623 File.new(fn,'w+')
2624 end
2625 end
2626 end
2627 module SiSU_Filename_Lang
2628 require_relative 'constants' # constants.rb
2629 require_relative 'utils' # utils.rb
2630 class FilenameLanguageCodeInsert
2631 def initialize(opt,lng=nil)
2632 @opt=opt
2633 @lng=lng ||=opt.lng
2634 end
2635 def language_code_insert
2636 if @opt.dir_structure_by ==:language \
2637 or ((@opt.dir_structure_by ==:filetype \
2638 || @opt.dir_structure_by ==:filename) \
2639 and (@opt.lingual ==:mono \
2640 && @lng == @opt.act[:default_language][:code]))
2641 ''
2642 elsif (@opt.dir_structure_by ==:filetype \
2643 || @opt.dir_structure_by ==:filename) \
2644 and not @opt.lingual ==:mono
2645 '.' + @lng
2646 else
2647 '.' + @lng
2648 end
2649 end
2650 end
2651 end
2652 __END__