aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sisu/v3/dal_expand_insertions.rb284
1 files changed, 237 insertions, 47 deletions
diff --git a/lib/sisu/v3/dal_expand_insertions.rb b/lib/sisu/v3/dal_expand_insertions.rb
index e6b586aa..cef75432 100644
--- a/lib/sisu/v3/dal_expand_insertions.rb
+++ b/lib/sisu/v3/dal_expand_insertions.rb
@@ -61,7 +61,7 @@ module SiSU_insertions
def initialize(md,data)
@md,@data=md,data
end
- def output_filetypes_in_cmd(cmd_shortcut,source=nil) #make list of file types in shortcut command (as configured), e.g. when sisu -3 is used
+ def output_filetypes_in_cmd(cmd_shortcut,lnk=nil) #make list of file types in shortcut command (as configured), e.g. when sisu -3 is used
cf_defaults=SiSU_Env::Info_processing_flag.new
cmd_list=case cmd_shortcut.inspect
when /0/; cf_defaults.cf_0
@@ -73,80 +73,274 @@ module SiSU_insertions
end
file_type_names={}
file_type_names[:gen],file_type_names[:src]=[],[]
- file_type_names[:gen] <<= if cmd_list =~ /y/; 'sisu_manifest.html'
+ file_type_names[:gen] <<= if cmd_list =~ /y/; "~^ { document manifest }#{lnk[:manifest]}"
end
- file_type_names[:gen] <<= if cmd_list =~ /h/; ['toc.html', 'doc.html']
+ file_type_names[:gen] <<= if cmd_list =~ /h/; [" { html, segmented text }#{lnk[:html_toc]}"," { html, scroll, document in one }#{lnk[:html_doc]}"]
end
- file_type_names[:gen] <<= if cmd_list =~ /e/; ['.epub']
+ file_type_names[:gen] <<= if cmd_list =~ /e/; [" { epub }#{lnk[:epub]}"]
end
- file_type_names[:gen] <<= if cmd_list =~ /p/; ['landscape.pdf', 'portrait.pdf']
+ file_type_names[:gen] <<= if cmd_list =~ /p/; [" { pdf, landscape }#{lnk[:pdf_landscape]}"," { pdf, portrait }#{lnk[:pdf_portrait]}"]
end
- file_type_names[:gen] <<= if cmd_list =~ /o/; 'opendocument.odt'
+ file_type_names[:gen] <<= if cmd_list =~ /o/; " { odf:odt, open document text }#{lnk[:odt]}"
end
- file_type_names[:gen] <<= if cmd_list =~ /b/; 'scroll.xhtml'
+ file_type_names[:gen] <<= if cmd_list =~ /b/; " { xhtml scroll }#{lnk[:xhtml]}"
end
- file_type_names[:gen] <<= if cmd_list =~ /x/; 'sax.xml'
+ file_type_names[:gen] <<= if cmd_list =~ /x/; " { xml, sax }#{lnk[:xml_sax]}"
end
- file_type_names[:gen] <<= if cmd_list =~ /X/; 'dom.xml'
+ file_type_names[:gen] <<= if cmd_list =~ /X/; " { xml, dom }#{lnk[:xml_dom]}"
end
- file_type_names[:gen] <<= if cmd_list =~ /a/; 'plain.txt'
+ file_type_names[:gen] <<= if cmd_list =~ /a/; " { plain text utf-8 }#{lnk[:txt]}"
end
file_type_names[:gen] <<= if cmd_list =~ /g/; 'wiki.txt'
end
- file_type_names[:gen] <<= if cmd_list =~ /w/; 'concordance.html'
+ file_type_names[:gen] <<= if cmd_list =~ /w/; " { concordance }#{lnk[:html_concordance]}"
end
- file_type_names[:gen] <<= if cmd_list =~ /N/; 'digest.txt'
+ file_type_names[:gen] <<= if cmd_list =~ /N/; " { dcc, document content certificate (digests) }#{lnk[:digest]}"
end
- file_type_names[:src] <<= if source and cmd_shortcut =~ /s/; source
+ file_type_names[:src] <<= if source and cmd_shortcut =~ /s/; " { markup source text }#{lnk[:source]}"
end
- file_type_names[:src] <<= if cmd_shortcut =~ /S/; "#{source}.zip"
+ file_type_names[:src] <<= if cmd_shortcut =~ /S/; " { markup source (zipped) pod }#{lnk[:sisupod]}"
end
file_type_names[:gen]=file_type_names[:gen].flatten
file_type_names[:src]=file_type_names[:src].flatten
file_type_names
end
+ def by_language(linked_doc,lng,src=nil)
+ @linked_doc,@lng,@src=linked_doc,lng,src
+ @base_path="#{@md.file.output_path.base.url}/#{@lng}"
+ def manifest
+ "#{@base_path}/manifest/#{@linked_doc}.html"
+ end
+ def html_toc
+ "#{@base_path}/html/#{@linked_doc}.html"
+ end
+ def html_doc
+ "#{@base_path}/html/#{@linked_doc}.html"
+ end
+ def html_concordance
+ "#{@base_path}/html/#{@linked_doc}.html"
+ end
+ def epub
+ "#{@base_path}/epub/#{@linked_doc}.epub"
+ end
+ def pdf_landscape
+ "#{@base_path}/pdf/#{@linked_doc}.pdf"
+ end
+ def pdf_portrait
+ "#{@base_path}/pdf/#{@linked_doc}.pdf"
+ end
+ def odt
+ "#{@base_path}/odt/#{@linked_doc}.odt"
+ end
+ def xhtml
+ "#{@base_path}/xhtml/#{@linked_doc}.xhtml"
+ end
+ def xml_sax
+ "#{@base_path}/xml/#{@linked_doc}.xml"
+ end
+ def xml_dom
+ "#{@base_path}/xml/#{@linked_doc}.xml"
+ end
+ def txt
+ "#{@base_path}/txt/#{@linked_doc}.txt"
+ end
+ def digest
+ "#{@base_path}/digest/#{@linked_doc}.txt"
+ end
+ def source
+ "#{@base_path}/src/#{@src}"
+ end
+ def sisupod
+ "#{@base_path}/pod/#{@src}.zip"
+ end
+ self
+ end
+ def by_filetype(linked_doc,lng,src=nil)
+ @linked_doc,@lng,@src=linked_doc,lng,src
+ @base_path="#{@md.file.output_path.base.url}"
+ def manifest
+ "#{@base_path}/manifest/#{@linked_doc}.#{@lng}.html"
+ end
+ def html_toc
+ "#{@base_path}/html/#{@linked_doc}.#{@lng}.html"
+ end
+ def html_doc
+ "#{@base_path}/html/#{@linked_doc}.#{@lng}.html"
+ end
+ def html_concordance
+ "#{@base_path}/html/#{@linked_doc}.#{@lng}.html"
+ end
+ def epub
+ "#{@base_path}/epub/#{@linked_doc}.#{@lng}.epub"
+ end
+ def pdf_landscape
+ "#{@base_path}/pdf/#{@linked_doc}.#{@lng}.pdf"
+ end
+ def pdf_portrait
+ "#{@base_path}/pdf/#{@linked_doc}.#{@lng}.pdf"
+ end
+ def odt
+ "#{@base_path}/odt/#{@linked_doc}.#{@lng}.odt"
+ end
+ def xhtml
+ "#{@base_path}/xhtml/#{@linked_doc}.#{@lng}.xhtml"
+ end
+ def xml_sax
+ "#{@base_path}/xml_sax/#{@linked_doc}.#{@lng}.xml"
+ end
+ def xml_dom
+ "#{@base_path}/xml_dom/#{@linked_doc}.#{@lng}.xml"
+ end
+ def txt
+ "#{@base_path}/txt/#{@linked_doc}.#{@lng}.txt"
+ end
+ def digest
+ "#{@base_path}/digest/#{@linked_doc}.#{@lng}.txt"
+ end
+ def source
+ "#{@base_path}/src/#{@src}"
+ end
+ def sisupod
+ "#{@base_path}/pod/#{@src}.zip"
+ end
+ self
+ end
+ def by_filename(linked_doc,lng,src=nil)
+ @linked_doc,@lng,@src=linked_doc,lng,src
+ @base_path="#{@md.file.output_path.base.url}/#{@linked_doc}"
+ def manifest
+ "#{@base_path}/sisu_manifest.#{@lng}.html"
+ end
+ def html_toc
+ "#{@base_path}/toc.#{@lng}.html"
+ end
+ def html_doc
+ "#{@base_path}/scroll.#{@lng}.html"
+ end
+ def html_concordance
+ "#{@base_path}/concordance.#{@lng}.html"
+ end
+ def epub
+ "#{@base_path}/epub/#{@linked_doc}.#{@lng}.epub"
+ end
+ def pdf_landscape
+ "#{@base_path}/landscape.#{@lng}.a4.pdf"
+ end
+ def pdf_portrait
+ "#{@base_path}/portrait.#{@lng}.a4.pdf"
+ end
+ def odt
+ "#{@base_path}/opendocument.#{@lng}.odt"
+ end
+ def xhtml
+ "#{@base_path}/scroll.#{@lng}.xhtml"
+ end
+ def xml_sax
+ "#{@base_path}/scroll.#{@lng}.sax.xml"
+ end
+ def xml_dom
+ "#{@base_path}/scroll.#{@lng}.dom.xml"
+ end
+ def txt
+ "#{@base_path}/plain.#{@lng}.txt"
+ end
+ def digest
+ "#{@base_path}/digest.#{@lng}.txt"
+ end
+ def source
+ "#{@base_path}/#{@src}"
+ end
+ def sisupod
+ "#{@base_path}/#{@src}.zip"
+ end
+ self
+ end
def expand_insertions?
data=@data
tuned_file,tuned_file_tmp=[],[]
data.each do |para|
if para !~/^%+\s/ \
and para =~/\{(?:~\^\s+)?(.+?)\s\[(?:\d(?:[sS]*))\]\}(?:\.\.\/\S+?\/|\S+?\.ss[tm]\b)/
- txt,cmd,source,url_dir,note,manifest=nil,nil,nil,nil,nil,nil
+ txt,cmd,source,linked_doc,note,manifest=nil,nil,nil,nil,nil,nil
@u=SiSU_Env::Info_env.new.url
+ pre=txt=cmd=source=linked_doc=note=''
if defined? @u.remote
- if para =~/(.+?)\{(.+?)\s\[(\d[sS]*)\]\}((\S+?)\.ss[tm]\b)(.*)/m
- pre,txt,cmd,source,url_dir,note="#{$1.strip} ",$2,$3,$4,$5,$6
- elsif para =~/\{(.+?)\s\[(\d[sS]*)\]\}((\S+?)\.ss[tm]\b)(.*)/
- pre,txt,cmd,source,url_dir,note='',$1,$2,$3,$4,$5
+ if /(?<pre>.+?)\{(?<txt>.+?)\s\[(?<cmd>\d[sS]*)\]\}(?<source>(?<linked_doc>\S+?)\.ss[tm]\b)(?<note>.*)/m =~ para
+ pre.strip!
+ elsif /\{(?<txt>.+?)\s\[(?<cmd>\d[sS]*)\]\}(?<source>(?<linked_doc>\S+?)\.ss[tm]\b)(?<note>.*)/m =~ para
+ end
+ if linked_doc =~ /(\S+?)\/(\S+)/
+ linked_doc,linked_doc_lang=$1,$2
+ else
+ linked_doc,linked_doc_lang=linked_doc,@md.opt.lng_base
end
- manifest="#{pre}{#{txt} }#{@u.remote}/#{url_dir}/toc.html#{note}\n\n"
else
puts "error, does currently support relative paths (reltive paths were removed, as had problems for citation, and was not suited to all output types should possibly reconsider) #{__FILE__} #{__LINE__}"
- if para =~/\{(?:~\^\s+)?(.+?)\s\[(\d[sS]*)\]\}\.\.\/(\S+?)\/(\s+#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]})?/
- txt,cmd,url_dir,note=$1,$2,$3,$4
- manifest="{ #{txt} }../#{url_dir}/toc.html#{note}\n\n"
+ if /\{(?:~\^\s+)?(?<txt>.+?)\s\[(?<cmd>\d[sS]*)\]\}\.\.\/(?<linked_doc>\S+?)\/(?<note>\s+#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]})?/ =~ para
end
end
- tuned_file_tmp << manifest
- output_filetypes=output_filetypes_in_cmd(cmd,source)
+ lnk={}
+ case @md.opt.dir_structure_by
+ when /language/
+ lnk={
+ manifest: by_language(linked_doc,linked_doc_lang).manifest,
+ html_toc: by_language(linked_doc,linked_doc_lang).html_toc,
+ html_doc: by_language(linked_doc,linked_doc_lang).html_doc,
+ epub: by_language(linked_doc,linked_doc_lang).epub,
+ pdf_landscape: by_language(linked_doc,linked_doc_lang).pdf_landscape,
+ pdf_portrait: by_language(linked_doc,linked_doc_lang).pdf_landscape,
+ odt: by_language(linked_doc,linked_doc_lang).odt,
+ xhtml: by_language(linked_doc,linked_doc_lang).xhtml,
+ xml_sax: by_language(linked_doc,linked_doc_lang).xml_sax,
+ xml_dom: by_language(linked_doc,linked_doc_lang).xml_dom,
+ txt: by_language(linked_doc,linked_doc_lang).txt,
+ html_concordance: by_language(linked_doc,linked_doc_lang).html_concordance,
+ digest: by_language(linked_doc,linked_doc_lang).digest,
+ sisupod: by_language(linked_doc,linked_doc_lang,source).sisupod,
+ source: by_language(linked_doc,linked_doc_lang,source).source,
+ }
+ when /filetype/
+ lnk={
+ manifest: by_filetype(linked_doc,linked_doc_lang).manifest,
+ html_toc: by_filetype(linked_doc,linked_doc_lang).html_toc,
+ html_doc: by_filetype(linked_doc,linked_doc_lang).html_doc,
+ epub: by_filetype(linked_doc,linked_doc_lang).epub,
+ pdf_landscape: by_filetype(linked_doc,linked_doc_lang).pdf_landscape,
+ pdf_portrait: by_filetype(linked_doc,linked_doc_lang).pdf_landscape,
+ odt: by_filetype(linked_doc,linked_doc_lang).odt,
+ xhtml: by_filetype(linked_doc,linked_doc_lang).xhtml,
+ xml_sax: by_filetype(linked_doc,linked_doc_lang).xml_sax,
+ xml_dom: by_filetype(linked_doc,linked_doc_lang).xml_dom,
+ txt: by_filetype(linked_doc,linked_doc_lang).txt,
+ html_concordance: by_filetype(linked_doc,linked_doc_lang).html_concordance,
+ digest: by_filetype(linked_doc,linked_doc_lang).digest,
+ sisupod: by_filetype(linked_doc,linked_doc_lang,source).sisupod,
+ source: by_filetype(linked_doc,linked_doc_lang,source).source,
+ }
+ else
+ lnk={
+ manifest: by_filename(linked_doc,linked_doc_lang).manifest,
+ html_toc: by_filename(linked_doc,linked_doc_lang).html_toc,
+ html_doc: by_filename(linked_doc,linked_doc_lang).html_doc,
+ epub: by_filename(linked_doc,linked_doc_lang).epub,
+ pdf_landscape: by_filename(linked_doc,linked_doc_lang).pdf_landscape,
+ pdf_portrait: by_filename(linked_doc,linked_doc_lang).pdf_landscape,
+ odt: by_filename(linked_doc,linked_doc_lang).odt,
+ xhtml: by_filename(linked_doc,linked_doc_lang).xhtml,
+ xml_sax: by_filename(linked_doc,linked_doc_lang).xml_sax,
+ xml_dom: by_filename(linked_doc,linked_doc_lang).xml_dom,
+ txt: by_filename(linked_doc,linked_doc_lang).txt,
+ html_concordance: by_filename(linked_doc,linked_doc_lang).html_concordance,
+ digest: by_filename(linked_doc,linked_doc_lang).digest,
+ sisupod: by_filename(linked_doc,linked_doc_lang,source).sisupod,
+ source: by_filename(linked_doc,linked_doc_lang,source).source,
+ }
+ end
+ linked_title="#{pre}{#{txt} }#{lnk[:manifest]}#{note}\n\n"
+ tuned_file_tmp << linked_title
+ output_filetypes=output_filetypes_in_cmd(cmd,lnk)
output_filetypes[:gen].each do |o_f|
- describe = case o_f
- when /sisu_manifest.html/; "~^ { document manifest }#{@md.file.output_path.manifest.url}/#{@md.file.base_filename.manifest}"
- when /toc.html/; " { html, segmented text }#{@md.file.output_path.html_seg.url}/#{@md.file.base_filename.html_segtoc}"
- when /doc.html/; " { html, scroll, document in one }#{@md.file.output_path.html_scroll.url}/#{@md.file.base_filename.html_scroll}"
- when /\.epub/; " { epub }#{@md.file.output_path.epub.url}/#{@md.file.base_filename.epub}"
- when /landscape.pdf/; " { pdf, landscape }#{@md.file.output_path.pdf.url}/#{@md.file.base_filename.pdf_l_a4}" #chose a default pdf
- when /portrait.pdf/; " { pdf, portrait }#{@md.file.output_path.pdf.url}/#{@md.file.base_filename.pdf_p_a4}" #chose a default pdf
- when /opendocument.odt/; " { odf:odt, open document text }#{@md.file.output_path.odt.url}/#{@md.file.base_filename.odt}"
- when /scroll.xhtml/; " { xhtml scroll }#{@md.file.output_path.xhtml.url}/#{@md.file.base_filename.xhtml}"
- when /sax.xml/; " { xml, sax }#{@md.file.output_path.xml_sax.url}/#{@md.file.base_filename.xml_sax}"
- when /dom.xml/; " { xml, dom }#{@md.file.output_path.xml_dom.url}/#{@md.file.base_filename.xml_dom}"
- when /plain.txt/; " { plain text utf-8 }#{@md.file.output_path.txt.url}/#{@md.file.base_filename.txt}"
- #when /manpage.1/; " man, 1"
- when /concordance.html/; " { concordance }#{@md.file.output_path.html_concordance.url}/#{@md.file.base_filename.html_concordance}"
- when /digest.txt/; " { dcc, document content certificate (digests) }#{@md.file.output_path.hash_digest.url}/#{@md.file.base_filename.hash_digest}"
- else nil
- end
+ describe = o_f
if describe
tuned_file_tmp << if @u.remote #to double space <:br> at beginning of entry
"#{Mx[:nbsp]*4} #{describe} "
@@ -156,11 +350,7 @@ module SiSU_insertions
end
end
output_filetypes[:src].each do |o_f|
- describe=case o_f
- when /#{source}\.zip/; " { markup source (zipped) pod }#{@md.file.output_path.sisupod.url}/#{@md.file.base_filename.sisupod}"
- when /#{source}/; " { markup source text }#{@md.file.output_path.src.url}/#{@md.file.base_filename.src}"
- else nil
- end
+ describe = o_f
if describe
tuned_file_tmp << if @u.remote
"#{Mx[:nbsp]*4} #{describe} "