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