c&d: some cruft
[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 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 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 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(lng=@md.opt.lng)
472 path=output_path.po(lng).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(lng=@md.opt.lng)
1751 @lng=lng
1752 def dir
1753 output_path.base.dir + '/' \
1754 + Gt[:src] + '/' \
1755 + @md.opt.fng + '/po4a/po/' \
1756 + @lng
1757 end
1758 def url
1759 output_path.base.url + '/po4a/' \
1760 + @md.fnb + '/po/' \
1761 + @lng
1762 end
1763 self
1764 end
1765 def pot
1766 def dir
1767 output_path.base.dir + '/' \
1768 + Gt[:src] + '/' \
1769 + @md.opt.fng + '/po4a/pot'
1770 end
1771 def url
1772 output_path.base.url + '/po4a/' \
1773 + @md.fnb + '/pot'
1774 end
1775 def rcp
1776 #p "#{output_path.base.dir}/po4a/#{@md.fnb}/pot"
1777 end
1778 self
1779 end
1780 def po_git # consider !!!
1781 def ft
1782 Gt[:po]
1783 end
1784 def dir
1785 pth=@env.processing_path.git + '/' \
1786 + @md.fnb + '/' \
1787 + ft + '/' \
1788 + @md.opt.lng
1789 FileUtils::mkdir_p(pth) unless FileTest.directory?(pth)
1790 pth
1791 end
1792 self
1793 end
1794 def pot_git # consider !!!
1795 def ft
1796 Gt[:pot]
1797 end
1798 def dir
1799 @env.processing_path.git + '/' \
1800 + @md.fnb + '/' \
1801 + ft
1802 end
1803 self
1804 end
1805 def md_harvest
1806 manifest
1807 self
1808 end
1809 def txt
1810 def ft
1811 'txt'
1812 end
1813 def dir
1814 set_path(ft).dir.abc
1815 end
1816 def url
1817 set_path(ft).url.abc
1818 end
1819 def rel
1820 set_path(ft).rel.abc
1821 end
1822 def rcp
1823 set_path(ft).rcp.abc
1824 end
1825 def rel_sm
1826 set_path(ft).rel_sm.ab
1827 end
1828 self
1829 end
1830 def textile
1831 def ft
1832 'textile' \
1833 + DEVELOPER[:under_construction]
1834 end
1835 def dir
1836 set_path(ft).dir.abc
1837 end
1838 def url
1839 set_path(ft).url.abc
1840 end
1841 def rel
1842 set_path(ft).rel.abc
1843 end
1844 def rcp
1845 set_path(ft).rcp.abc
1846 end
1847 def rel_sm
1848 set_path(ft).rel_sm.ab
1849 end
1850 self
1851 end
1852 def asciidoc
1853 def ft
1854 'asciidoc' \
1855 + DEVELOPER[:under_construction]
1856 end
1857 def dir
1858 set_path(ft).dir.abc
1859 end
1860 def url
1861 set_path(ft).url.abc
1862 end
1863 def rel
1864 set_path(ft).rel.abc
1865 end
1866 def rcp
1867 set_path(ft).rcp.abc
1868 end
1869 def rel_sm
1870 set_path(ft).rel_sm.ab
1871 end
1872 self
1873 end
1874 def markdown
1875 def ft
1876 'markdown' \
1877 + DEVELOPER[:under_construction]
1878 end
1879 def dir
1880 set_path(ft).dir.abc
1881 end
1882 def url
1883 set_path(ft).url.abc
1884 end
1885 def rel
1886 set_path(ft).rel.abc
1887 end
1888 def rcp
1889 set_path(ft).rcp.abc
1890 end
1891 def rel_sm
1892 set_path(ft).rel_sm.ab
1893 end
1894 self
1895 end
1896 def rst
1897 def ft
1898 'rst' \
1899 + DEVELOPER[:under_construction]
1900 end
1901 def dir
1902 set_path(ft).dir.abc
1903 end
1904 def url
1905 set_path(ft).url.abc
1906 end
1907 def rel
1908 set_path(ft).rel.abc
1909 end
1910 def rcp
1911 set_path(ft).rcp.abc
1912 end
1913 def rel_sm
1914 set_path(ft).rel_sm.ab
1915 end
1916 self
1917 end
1918 def orgmode
1919 def ft
1920 'orgmode' \
1921 + DEVELOPER[:under_construction]
1922 end
1923 def dir
1924 set_path(ft).dir.abc
1925 end
1926 def url
1927 set_path(ft).url.abc
1928 end
1929 def rel
1930 set_path(ft).rel.abc
1931 end
1932 def rcp
1933 set_path(ft).rcp.abc
1934 end
1935 def rel_sm
1936 set_path(ft).rel_sm.ab
1937 end
1938 self
1939 end
1940 def html_scroll
1941 def ft
1942 'html'
1943 end
1944 def dir
1945 set_path(ft).dir.abc
1946 end
1947 def url
1948 set_path(ft).url.abc
1949 end
1950 def rel
1951 set_path(ft).rel.abc
1952 end
1953 def rcp
1954 set_path(ft).rcp.abc
1955 end
1956 def rel_sm
1957 set_path(ft).rel_sm.ab
1958 end
1959 def rel_image
1960 if output_dir_structure.dump_or_redirect?
1961 './image'
1962 elsif output_dir_structure.by_language_code?
1963 '../../_sisu/image'
1964 elsif output_dir_structure.by_filetype?
1965 '../_sisu/image'
1966 else
1967 '../_sisu/image'
1968 end
1969 end
1970 self
1971 end
1972 def html_seg
1973 def ft
1974 'html/' + @md.fnb
1975 end
1976 def dir
1977 set_path(ft).dir.abc
1978 end
1979 def url
1980 set_path(ft).url.abc
1981 end
1982 def rel
1983 set_path(ft).rel.abc
1984 end
1985 def rcp
1986 set_path(ft).rcp.abc
1987 end
1988 def rel_sm
1989 set_path(ft).rel_sm.ab
1990 end
1991 def rel_image
1992 if output_dir_structure.dump_or_redirect?
1993 './image'
1994 elsif output_dir_structure.by_language_code?
1995 '../../../_sisu/image'
1996 elsif output_dir_structure.by_filetype?
1997 '../../_sisu/image'
1998 else
1999 '../_sisu/image'
2000 end
2001 end
2002 self
2003 end
2004 def html_concordance
2005 html_seg
2006 self
2007 end
2008 def html
2009 def ft
2010 'html'
2011 end
2012 def dir
2013 set_path(ft).dir.abc
2014 end
2015 def url
2016 set_path(ft).url.abc
2017 end
2018 def rel
2019 set_path(ft).url.abc
2020 end
2021 def rcp
2022 set_path(ft).rcp.abc
2023 end
2024 def rel_sm
2025 set_path(ft).rel_sm.ab
2026 end
2027 def rel_image
2028 if output_dir_structure.by_language_code?
2029 '../../_sisu/image'
2030 elsif output_dir_structure.by_filetype?
2031 '../_sisu/image'
2032 else
2033 '../_sisu/image'
2034 end
2035 end
2036 self
2037 end
2038 def xhtml
2039 def ft
2040 'xhtml'
2041 end
2042 def dir
2043 set_path(ft).dir.abc
2044 end
2045 def url
2046 set_path(ft).url.abc
2047 end
2048 def rel
2049 set_path(ft).rel.abc
2050 end
2051 def rcp
2052 set_path(ft).rcp.abc
2053 end
2054 def rel_sm
2055 set_path(ft).rel_sm.ab
2056 end
2057 def rel_image
2058 '../../_sisu/image'
2059 end
2060 self
2061 end
2062 def epub
2063 def ft
2064 'epub'
2065 end
2066 def dir
2067 set_path(ft).dir.ab
2068 end
2069 def url
2070 set_path(ft).url.ab
2071 end
2072 def rel
2073 set_path(ft).rel.ab
2074 end
2075 def rcp
2076 set_path(ft).rcp.ab
2077 end
2078 def rel_sm
2079 set_path(ft).rel_sm.ab
2080 end
2081 def rel_image
2082 './image'
2083 end
2084 self
2085 end
2086 def odt
2087 def ft
2088 'odt'
2089 end
2090 def dir
2091 set_path(ft).dir.abc
2092 end
2093 def url
2094 set_path(ft).url.abc
2095 end
2096 def rel
2097 set_path(ft).rel.abc
2098 end
2099 def rcp
2100 set_path(ft).rcp.abc
2101 end
2102 def rel_sm
2103 set_path(ft).rel_sm.ab
2104 end
2105 self
2106 end
2107 def xml
2108 def ft
2109 'xml'
2110 end
2111 def dir
2112 set_path(ft).dir.abc
2113 end
2114 def url
2115 set_path(ft).url.abc
2116 end
2117 def rel
2118 set_path(ft).rel.abc
2119 end
2120 def rcp
2121 set_path(ft).rcp.abc
2122 end
2123 def rel_sm
2124 set_path(ft).rel_sm.ab
2125 end
2126 def rel_image
2127 '../../_sisu/image'
2128 end
2129 self
2130 end
2131 def xml_sax
2132 xml
2133 self
2134 end
2135 def xml_dom
2136 xml
2137 self
2138 end
2139 def xml_docbook
2140 def ft
2141 'docbook'
2142 end
2143 def dir
2144 set_path(ft).dir.abc
2145 end
2146 def url
2147 set_path(ft).url.abc
2148 end
2149 def rel
2150 set_path(ft).rel.abc
2151 end
2152 def rcp
2153 set_path(ft).rcp.abc
2154 end
2155 def rel_sm
2156 set_path(ft).rel_sm.ab
2157 end
2158 def rel_image
2159 '../../_sisu/image'
2160 end
2161 self
2162 end
2163 def xml_docbook_article
2164 def ft
2165 'docbook' \
2166 + DEVELOPER[:under_construction]
2167 end
2168 def dir
2169 set_path(ft).dir.abc
2170 end
2171 def url
2172 set_path(ft).url.abc
2173 end
2174 def rel
2175 set_path(ft).rel.abc
2176 end
2177 def rcp
2178 set_path(ft).rcp.abc
2179 end
2180 def rel_sm
2181 set_path(ft).rel_sm.ab
2182 end
2183 def rel_image
2184 '../../_sisu/image'
2185 end
2186 self
2187 end
2188 def xml_docbook_book
2189 def ft
2190 'docbook'
2191 end
2192 def dir
2193 set_path(ft).dir.abc
2194 end
2195 def url
2196 set_path(ft).url.abc
2197 end
2198 def rel
2199 set_path(ft).rel.abc
2200 end
2201 def rcp
2202 set_path(ft).rcp.abc
2203 end
2204 def rel_sm
2205 set_path(ft).rel_sm.ab
2206 end
2207 def rel_image
2208 '../../_sisu/image'
2209 end
2210 self
2211 end
2212 def xml_fictionbook
2213 def ft
2214 'fictionbook' \
2215 + DEVELOPER[:under_construction]
2216 end
2217 def dir
2218 set_path(ft).dir.abc
2219 end
2220 def url
2221 set_path(ft).url.abc
2222 end
2223 def rel
2224 set_path(ft).rel.abc
2225 end
2226 def rcp
2227 set_path(ft).rcp.abc
2228 end
2229 def rel_sm
2230 set_path(ft).rel_sm.ab
2231 end
2232 def rel_image
2233 '../../_sisu/image'
2234 end
2235 self
2236 end
2237 def xml_scaffold_structure_sisu
2238 def ft
2239 'sisu.scaffold.xml'
2240 #'xml'
2241 end
2242 def dir
2243 set_path(ft).dir.abc
2244 end
2245 def url
2246 set_path(ft).url.abc
2247 end
2248 def rel
2249 set_path(ft).rel.abc
2250 end
2251 def rcp
2252 set_path(ft).rcp.abc
2253 end
2254 def rel_sm
2255 set_path(ft).rel_sm.ab
2256 end
2257 def rel_image
2258 '../../_sisu/image'
2259 end
2260 self
2261 end
2262 def xml_scaffold_structure_collapse
2263 def ft
2264 'collapsed.scaffold.xml'
2265 #'xml'
2266 end
2267 def dir
2268 set_path(ft).dir.abc
2269 end
2270 def url
2271 set_path(ft).url.abc
2272 end
2273 def rel
2274 set_path(ft).rel.abc
2275 end
2276 def rcp
2277 set_path(ft).rcp.abc
2278 end
2279 def rel_sm
2280 set_path(ft).rel_sm.ab
2281 end
2282 def rel_image
2283 '../../_sisu/image'
2284 end
2285 self
2286 end
2287 def pdf
2288 def ft
2289 'pdf'
2290 end
2291 def dir
2292 set_path(ft).dir.abc
2293 end
2294 def url
2295 set_path(ft).url.abc
2296 end
2297 def rel
2298 set_path(ft).rel.abc
2299 end
2300 def rcp
2301 set_path(ft).rcp.abc
2302 end
2303 def rel_sm
2304 set_path(ft).rel_sm.ab
2305 end
2306 self
2307 end
2308 def sqlite_discrete
2309 def ft
2310 'sql'
2311 end
2312 def dir
2313 set_path(ft).dir.ab
2314 end
2315 def url
2316 set_path(ft).url.ab
2317 end
2318 def rel
2319 set_path(ft).rel.ab
2320 end
2321 def rcp
2322 set_path(ft).rcp.ab
2323 end
2324 def rel_sm
2325 set_path(ft).rel_sm.ab
2326 end
2327 self
2328 end
2329 def hash_digest
2330 def ft
2331 'hashes'
2332 end
2333 def dir
2334 set_path(ft).dir.abc
2335 end
2336 def url
2337 set_path(ft).url.abc
2338 end
2339 def rel
2340 set_path(ft).rel.abc
2341 end
2342 def rcp
2343 set_path(ft).rcp.abc
2344 end
2345 def rel_sm
2346 set_path(ft).rel_sm.ab
2347 end
2348 self
2349 end
2350 def manifest
2351 def ft
2352 'manifest'
2353 end
2354 def dir
2355 set_path(ft).dir.abc
2356 end
2357 def url
2358 set_path(ft).url.abc
2359 end
2360 def rel
2361 set_path(ft).rel.abc
2362 end
2363 def rel_image
2364 if output_dir_structure.dump_or_redirect?
2365 './image'
2366 elsif output_dir_structure.by_language_code?
2367 '../../_sisu/image'
2368 elsif output_dir_structure.by_filetype?
2369 '../_sisu/image'
2370 else
2371 '../_sisu/image'
2372 end
2373 end
2374 def rcp
2375 set_path(ft).rcp.abc
2376 end
2377 self
2378 end
2379 def qrcode
2380 def ft
2381 'manifest/qrcode'
2382 end
2383 def dir
2384 set_path(ft).dir.abc
2385 end
2386 def url
2387 set_path(ft).url.abc
2388 end
2389 def rel
2390 set_path(ft).rel.abc
2391 end
2392 def rcp
2393 set_path(ft).rcp.abc
2394 end
2395 def rel_sm
2396 set_path(ft).rel_sm.ab
2397 end
2398 self
2399 end
2400 def harvest
2401 def ft
2402 'site_metadata'
2403 end
2404 def dir
2405 set_path(ft).dir.ab
2406 end
2407 def url
2408 set_path(ft).url.ab
2409 end
2410 def rel
2411 set_path(ft).rel.ab
2412 end
2413 def rcp
2414 set_path(ft).rcp.ab
2415 end
2416 def rel_sm
2417 if output_dir_structure.by_language_code?
2418 ''
2419 elsif output_dir_structure.by_filetype?
2420 ''
2421 else
2422 ''
2423 end
2424 end
2425 self
2426 end
2427 def manpage
2428 def ft
2429 'man'
2430 end
2431 def dir
2432 set_path(ft).dir.ab
2433 end
2434 def url
2435 set_path(ft).url.ab
2436 end
2437 def rel
2438 set_path(ft).rel.ab
2439 end
2440 def rcp
2441 set_path(ft).rcp.ab
2442 end
2443 def rel_sm
2444 set_path(ft).rel_sm.ab
2445 end
2446 self
2447 end
2448 def texinfo
2449 def ft
2450 'texinfo'
2451 end
2452 def dir
2453 set_path(ft).dir.ab
2454 end
2455 def url
2456 set_path(ft).url.ab
2457 end
2458 def rel
2459 set_path(ft).rel.ab
2460 end
2461 def rcp
2462 set_path(ft).rcp.ab
2463 end
2464 def rel_sm
2465 set_path(ft).rel_sm.ab
2466 end
2467 self
2468 end
2469 def sitemaps
2470 def ft
2471 'sitemaps'
2472 end
2473 def dir
2474 set_path(ft).dir.ab
2475 end
2476 def url
2477 set_path(ft).url.ab
2478 end
2479 def rel
2480 set_path(ft).rel.ab
2481 end
2482 def rcp
2483 set_path(ft).rcp.ab
2484 end
2485 self
2486 end
2487 def sqlite #check url
2488 def dir
2489 output_path.base.dir
2490 end
2491 def url
2492 output_path.base.url
2493 end
2494 def rel
2495 output_path.base.rel
2496 end
2497 def rcp
2498 output_path.base.rcp
2499 end
2500 self
2501 end
2502 #def cgi
2503 #end
2504 def css
2505 @d='_sisu/css'
2506 def dir
2507 output_path.base.dir + '/' + @d
2508 end
2509 def url
2510 output_path.base.url + '/' + @d
2511 end
2512 def rel
2513 @d
2514 #output_path.base.rel + '/' + @d
2515 end
2516 def rcp
2517 output_path.stub.rcp + '/' + @d
2518 end
2519 self
2520 end
2521 def images
2522 @d='_sisu/image'
2523 def dir
2524 output_path.base.dir + '/' + @d
2525 end
2526 def url
2527 output_path.base.url + '/' + @d
2528 end
2529 def rel
2530 @d
2531 #output_path.base.rel + '/' + @d
2532 end
2533 def rcp
2534 output_path.stub.rcp + '/' + @d
2535 end
2536 self
2537 end
2538 def images_external
2539 @d='_sisu/image_external'
2540 def dir
2541 output_path.base.dir + '/' + @d
2542 end
2543 def url
2544 output_path.base.url + '/' + @d
2545 end
2546 def rel
2547 output_path.base.rel + '/' + @d
2548 end
2549 def rcp
2550 output_path.base.rcp + '/' + @d
2551 end
2552 self
2553 end
2554 #def css
2555 # #"#{@env.path.output}/#{@env.path.style}"
2556 #end
2557 self
2558 end
2559 end
2560 end
2561 module SiSU_Create_File
2562 require_relative 'constants' # constants.rb
2563 require_relative 'utils' # utils.rb
2564 require_relative 'se_info_env' # se_info_env.rb
2565 class CreateFile < SiSU_Info_Env::InfoEnv # se_info_env.rb
2566 #todo unify with FileOp
2567 def initialize(fns)
2568 begin
2569 super(fns)
2570 @env=SiSU_Env::InfoEnv.new(fns)
2571 rescue
2572 SiSU_Screen::Ansi.new('',$!,$@).rescue do
2573 __LINE__.to_s + ':' + __FILE__
2574 end
2575 ensure
2576 end
2577 end
2578 def html_root
2579 #@env.path.output
2580 end
2581 def mkdir_pdf
2582 Dir.mkdir(@env.processing_path.tex) \
2583 unless FileTest.directory?(@env.processing_path.tex)
2584 end
2585 def file_generic(output_file='')
2586 fn=@env.path.output + '/' \
2587 + @fnb + '/' \
2588 + output_file
2589 File.new(fn,'w+')
2590 end
2591 def file_error
2592 fn='/tmp/errorlog.sisu'
2593 File.new(fn,'w+')
2594 end
2595 def file_txt
2596 fn=@env.processing_path.ao + '/' \
2597 + @fns + '.txt'
2598 File.new(fn,'w+')
2599 end
2600 def file_debug
2601 fn=@env.processing_path.ao + '/' \
2602 + @fns + '.debug.txt'
2603 File.new(fn,'w+')
2604 end
2605 def metaverse
2606 def file_meta
2607 fn=@env.processing_path.ao + '/' \
2608 + @fns + '.meta'
2609 File.new(fn,'w+')
2610 end
2611 def file_meta_idx_html
2612 fn=@env.processing_path.ao + '/' \
2613 + @fns + '.idx.html'
2614 File.new(fn,'w+')
2615 end
2616 self
2617 end
2618 def file_note
2619 fn=Dir.pwd + '/' \
2620 + @fns + '.fn'
2621 File.new(fn,'w+')
2622 end
2623 def meta
2624 @env.processing_path.ao + '/' \
2625 + @fns + '.meta'
2626 end
2627 def file_semantic
2628 fn='./semantic.yaml'
2629 File.new(fn,'w+')
2630 end
2631 def file_rss
2632 fn='./semantic.xml'
2633 File.new(fn,'w+')
2634 end
2635 def epub
2636 @pth=@env.processing_path.epub
2637 def xhtml_index
2638 fn=@pth + '/' \
2639 + Ep[:d_oebps] + '/index.xhtml'
2640 File.new(fn,'w+')
2641 end
2642 def xhtml_cover_image
2643 fn=@pth + '/' \
2644 + Ep[:d_oebps] + '/cover_image.xhtml'
2645 File.new(fn,'w+')
2646 end
2647 def xhtml_segtoc
2648 fn=@pth + '/' \
2649 + Ep[:d_oebps] + '/toc.xhtml'
2650 File.new(fn,'w+')
2651 end
2652 def mimetype #fixed application/epub+zip ~/grotto/theatre/dbld/builds/epub_sample/mimetype
2653 File.new("#{@pth}/mimetype",'w')
2654 end
2655 def metadata #variable matadata ~/grotto/theatre/dbld/builds/epub_sample/metadata.opf
2656 fn=@pth + '/' \
2657 + Ep[:d_oebps] + '/' \
2658 + Ep[:f_opf]
2659 File.new(fn,'w')
2660 end
2661 def toc_ncx #variable toc ~/grotto/theatre/dbld/builds/epub_sample/toc.ncx
2662 fn=@pth + '/' \
2663 + Ep[:d_oebps] + '/' \
2664 + Ep[:f_ncx]
2665 File.new(fn,'w')
2666 end
2667 def metainf_cont #variable content ~/grotto/theatre/dbld/builds/epub_sample/META-INF/container.xml
2668 fn=@pth + '/META-INF/container.xml'
2669 File.new(fn,'w')
2670 end
2671 def xhtml_css #fixed epub xhtml css
2672 fn=@pth + '/' \
2673 + Ep[:d_oebps] + '/css/xhtml.css'
2674 File.new(fn,'w')
2675 end
2676 self
2677 end
2678 def file_texinfo
2679 fn=@env.processing_path.texinfo + '/' \
2680 + @fnb + '.texinfo'
2681 File.new(fn,'w+')
2682 end
2683 end
2684 end
2685 module SiSU_Filename_Lang
2686 require_relative 'constants' # constants.rb
2687 require_relative 'utils' # utils.rb
2688 class FilenameLanguageCodeInsert
2689 def initialize(opt,lng=nil)
2690 @opt=opt
2691 @lng=lng ||=opt.lng
2692 end
2693 def language_code_insert
2694 if @opt.dir_structure_by ==:language \
2695 or ((@opt.dir_structure_by ==:filetype \
2696 || @opt.dir_structure_by ==:filename) \
2697 and (@opt.lingual ==:mono \
2698 && @lng == @opt.act[:default_language][:code]))
2699 ''
2700 elsif (@opt.dir_structure_by ==:filetype \
2701 || @opt.dir_structure_by ==:filename) \
2702 and not @opt.lingual ==:mono
2703 '.' + @lng
2704 else
2705 '.' + @lng
2706 end
2707 end
2708 end
2709 end
2710 __END__