aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v4
diff options
context:
space:
mode:
authorRalph Amissah <ralph@amissah.com>2013-08-08 00:26:51 -0400
committerRalph Amissah <ralph@amissah.com>2013-08-08 00:26:51 -0400
commit6f88dbf16ce50d3ab246b79e16222447cb3ddfc6 (patch)
treea5b35b294f9278ce2c20179f8ceb0e8c65877640 /lib/sisu/v4
parentdebian/changelog (4.1.9-1) (diff)
parentv4: merge v5 lib (5.0.10) (diff)
Merge tag 'sisu_4.1.10' into debian/sid
SiSU 4.1.10
Diffstat (limited to 'lib/sisu/v4')
-rw-r--r--lib/sisu/v4/cgi_pgsql.rb24
-rw-r--r--lib/sisu/v4/cgi_sql_common.rb113
-rw-r--r--lib/sisu/v4/cgi_sqlite.rb24
-rw-r--r--lib/sisu/v4/concordance.rb26
-rw-r--r--lib/sisu/v4/constants.rb17
-rw-r--r--lib/sisu/v4/dal_expand_insertions.rb139
-rw-r--r--lib/sisu/v4/harvest_authors.rb5
-rw-r--r--lib/sisu/v4/harvest_topics.rb5
-rw-r--r--lib/sisu/v4/html.rb27
-rw-r--r--lib/sisu/v4/html_minitoc.rb27
-rw-r--r--lib/sisu/v4/html_segments.rb12
-rw-r--r--lib/sisu/v4/hub.rb1
-rw-r--r--lib/sisu/v4/manifest.rb22
-rw-r--r--lib/sisu/v4/options.rb26
-rw-r--r--lib/sisu/v4/param.rb11
-rw-r--r--lib/sisu/v4/sysenv.rb676
16 files changed, 764 insertions, 391 deletions
diff --git a/lib/sisu/v4/cgi_pgsql.rb b/lib/sisu/v4/cgi_pgsql.rb
index 162f20cc..3698f769 100644
--- a/lib/sisu/v4/cgi_pgsql.rb
+++ b/lib/sisu/v4/cgi_pgsql.rb
@@ -73,11 +73,14 @@ module SiSU_CGI_PgSQL
get_init=SiSU_Env::GetInit.new
@rc=get_init.sisu_yaml.rc
@name_of={}
- @name_of[:output_dir_structure]=if defined? @rc['output_dir_structure_by'] \
- and defined? @rc['output_dir_structure_by'] =~/(language|filetype|filename)/
- @rc['output_dir_structure_by']
+ @name_of[:output_dir_structure]=if @opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/
+ @opt.dir_structure_by.to_s
else 'language'
end
+ @name_of[:lingual]=if @opt.lingual.to_s =~/(?:mono|multi)/
+ @opt.lingual.to_s
+ else 'multi'
+ end
if defined? @rc['search'] \
and defined? @rc['search']['sisu'] \
and defined? @rc['search']['sisu']['action'] \
@@ -93,8 +96,7 @@ module SiSU_CGI_PgSQL
@name_of[:host_url_docs]=@env.url.webserv_files_from_db(@opt)
@name_of[:cgi_script]=@env.url.cgi_sample_search_form_name(@opt)
@name_of[:user]=@db.psql.user(@opt)
- @cgi_file_name="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by.to_s}_pgsql.cgi"
- @cgi_link_name=@name_of[:cgi_script] #sisu_pgsql.cgi,
+ @cgi_file_name=@name_of[:cgi_script]
@image_src="#{@env.url.webserv_base_cgi(@opt)}/_sisu/image_sys"
@common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env)
end
@@ -161,24 +163,19 @@ module SiSU_CGI_PgSQL
# if necessary make the directory '/usr/lib/cgi-bin'
# here we copy the postgresql search form to cgi-bin
# (copy #{@cgi_file_name} to your cgi directory)
- # set file permissions to 755, &
- # make symbolic link to #{@cgi_link_name}
+ # set file permissions to 755
WOK
a=case @webserv
when /pwd/; ''
else <<-WOK
sudo cp -vi #{Dir.pwd}/#{@cgi_file_name} /usr/lib/cgi-bin/.; \\
- cd /usr/lib/cgi-bin && \\
- sudo chmod -v 755 #{@cgi_file_name}; \\
- sudo rm -vi #{@cgi_link_name}; \\
- sudo ln -s #{@cgi_file_name} #{@cgi_link_name}; \\
- cd -
+ sudo chmod -v 755 /usr/lib/cgi-bin/#{@cgi_file_name}
WOK
end
SiSU_Screen::Ansi.new(@opt.cmd,a).warn
a=<<-WOK
- #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_link_name}
+ #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name}
WOK
SiSU_Screen::Ansi.new(@opt.cmd,a).print_blue
a="\n\t(to create and populate postgresql database see 'man sisu' and in particular the --pg option)\n\t[the database to be used for this directory (#{@db.psql.db}) will have to be created manually if it does not exist,\n\tusing postgresql tools directly: 'createdb #{@db.psql.db}' for a list of existing databases try 'psql --list']"
@@ -202,6 +199,7 @@ module SiSU_CGI_PgSQL
@hosturl_cgi='#{@name_of[:host_url_cgi]}'
@hosturl_files='#{@name_of[:host_url_docs]}'
@output_dir_structure_by='#{@name_of[:output_dir_structure]}'
+ @lingual='#{@name_of[:lingual]}'
@port='#{@db.psql.port}'
@db_name_prefix='#{Db[:name_prefix]}'
@user='#{@name_of[:user]}' # check user name for access to pg database: e.g. www-data or '#{@env.user}'
diff --git a/lib/sisu/v4/cgi_sql_common.rb b/lib/sisu/v4/cgi_sql_common.rb
index a6639fb3..2597b4a2 100644
--- a/lib/sisu/v4/cgi_sql_common.rb
+++ b/lib/sisu/v4/cgi_sql_common.rb
@@ -845,72 +845,77 @@ module SiSU_CGI_SQL
@hostpath="#{@hosturl_files}/#{@stub}"
WOK_SQL
end
- def dir_structure
- case @opt.dir_structure_by
- when :language
- <<-'WOK_SQL'
- def path_manifest(fn,ln=nil)
- "#{@hostpath}/#{ln}/manifest/#{fn}.html"
- end
- def path_html_seg(fn,ln=nil)
- "#{@hostpath}/#{ln}/html/#{fn}"
- end
- def path_toc(fn,ln=nil)
- "#{path_html_seg(fn,ln)}/toc.html"
- end
- def path_filename(fn,seg,ln=nil)
- "#{path_html_seg(fn,ln)}/#{seg}.html"
- end
- def path_endnotes(fn,ln=nil)
- "#{path_html_seg(fn,ln)}/endnotes.html"
- end
- def path_html_doc(fn,ln=nil)
- "#{@hostpath}/#{ln}/html/#{fn}.html"
- end
- WOK_SQL
- when :filetype
- <<-'WOK_SQL'
- def path_manifest(fn,ln=nil)
- "#{@hostpath}/manifest/#{fn}.#{ln}.html"
- end
- def path_html_seg(fn,ln=nil)
- "#{@hostpath}/html/#{fn}"
- end
- def path_toc(fn,ln=nil)
- "#{path_html_seg(fn,ln)}/toc.#{ln}.html"
- end
- def path_filename(fn,seg,ln=nil)
- "#{path_html_seg(fn,ln)}/#{seg}.#{ln}.html"
- end
- def path_endnotes(fn,ln=nil)
- "#{path_html_seg(fn,ln)}/endnotes.#{ln}.html"
- end
- def path_html_doc(fn,ln=nil)
- "#{@hostpath}/html/#{fn}.#{ln}.html"
- end
- WOK_SQL
- else
- <<-'WOK_SQL'
+ def dir_structure #@opt.dir_structure_by
+ <<-'WOK_SQL'
def path_manifest(fn,ln=nil)
- "#{@hostpath}/#{fn}/sisu_manifest.#{ln}.html"
+ case @output_dir_structure_by
+ when 'filename'
+ @lingual =='mono' \
+ ? "#{@hostpath}/#{fn}/sisu_manifest.html"
+ : "#{@hostpath}/#{fn}/sisu_manifest.#{ln}.html"
+ when 'filetype'
+ @lingual =='mono' \
+ ? "#{@hostpath}/manifest/#{fn}.html"
+ : "#{@hostpath}/manifest/#{fn}.#{ln}.html"
+ else
+ "#{@hostpath}/#{ln}/manifest/#{fn}.html"
+ end
end
def path_html_seg(fn,ln=nil)
- "#{@hostpath}/#{fn}"
+ case @output_dir_structure_by
+ when 'filename'
+ "#{@hostpath}/#{fn}"
+ when 'filetype'
+ "#{@hostpath}/html/#{fn}"
+ else
+ "#{@hostpath}/#{ln}/html/#{fn}"
+ end
end
def path_toc(fn,ln=nil)
- "#{path_html_seg(fn,ln)}/toc.#{ln}.html"
+ if @output_dir_structure_by =='filename' \
+ or @output_dir_structure_by =='filetype'
+ @lingual =='mono' \
+ ? "#{path_html_seg(fn,ln)}/toc.html"
+ : "#{path_html_seg(fn,ln)}/toc.#{ln}.html"
+ else
+ "#{path_html_seg(fn,ln)}/toc.html"
+ end
end
def path_filename(fn,seg,ln=nil)
- "#{path_html_seg(fn,ln)}/#{seg}.#{ln}.html"
+ if @output_dir_structure_by =='filename' \
+ or @output_dir_structure_by =='filetype'
+ @lingual =='mono' \
+ ? "#{path_html_seg(fn,ln)}/#{seg}.html"
+ : "#{path_html_seg(fn,ln)}/#{seg}.#{ln}.html"
+ else
+ "#{path_html_seg(fn,ln)}/#{seg}.html"
+ end
end
def path_endnotes(fn,ln=nil)
- "#{path_html_seg(fn,ln)}/endnotes.#{ln}.html"
+ if @output_dir_structure_by =='filename' \
+ or @output_dir_structure_by =='filetype'
+ @lingual =='mono' \
+ ? "#{path_html_seg(fn,ln)}/endnotes.html"
+ : "#{path_html_seg(fn,ln)}/endnotes.#{ln}.html"
+ else
+ "#{path_html_seg(fn,ln)}/endnotes.html"
+ end
end
def path_html_doc(fn,ln=nil)
- "#{path_html_seg(fn,ln)}/scroll.#{ln}.html"
+ case @output_dir_structure_by
+ when 'filename'
+ @lingual =='mono' \
+ ? "#{path_html_seg(fn,ln)}/scroll.html"
+ : "#{path_html_seg(fn,ln)}/scroll.#{ln}.html"
+ when 'filetype'
+ @lingual =='mono' \
+ ? "#{@hostpath}/html/#{fn}.html"
+ : "#{@hostpath}/html/#{fn}.#{ln}.html"
+ else
+ "#{@hostpath}/#{ln}/html/#{fn}.html"
+ end
end
- WOK_SQL
- end
+ WOK_SQL
end
def main3
<<-'WOK_SQL'
diff --git a/lib/sisu/v4/cgi_sqlite.rb b/lib/sisu/v4/cgi_sqlite.rb
index 93129b5c..b3b67d42 100644
--- a/lib/sisu/v4/cgi_sqlite.rb
+++ b/lib/sisu/v4/cgi_sqlite.rb
@@ -69,8 +69,17 @@ module SiSU_CGI_SQLite
@cX=SiSU_Screen::Ansi.new(opt.cmd).cX
@env=SiSU_Env::InfoEnv.new('',opt)
@image_src="#{@env.url.webserv_cgi(@opt)}/_sisu/image_sys"
+ @name_of={}
+ @name_of[:output_dir_structure]=if @opt.dir_structure_by.to_s =~/(?:language|filetype|filename)/
+ @opt.dir_structure_by.to_s
+ else 'language'
+ end
+ @name_of[:lingual]=if @opt.lingual.to_s =~/(?:mono|multi)/
+ @opt.lingual.to_s
+ else 'multi'
+ end
@common=SiSU_CGI_SQL::CGI_Common.new(@webserv,@opt,@image_src,@env)
- @cgi_file_name="#{Db[:name_prefix_db]}by_#{opt.dir_structure_by.to_s}_sqlite.cgi"
+ @cgi_file_name=@env.url.cgi_sample_search_form_name(@opt)
@name_of_sqlite_db_file='sisu_sqlite.db'
end
def sqlite
@@ -126,26 +135,21 @@ module SiSU_CGI_SQLite
# if necessary make the directory '/usr/lib/cgi-bin'
# here we copy the postgresql search form to cgi-bin
# (copy #{@cgi_file_name} to your cgi directory)
- # set file permissions to 755, &
- # make symbolic link to #{@cgi_link_name}
+ # set file permissions to 755
WOK
a=case @webserv
when /pwd/; ''
else <<-WOK
sudo cp -vi #{Dir.pwd}/#{@cgi_file_name} /usr/lib/cgi-bin/.; \\
- cd /usr/lib/cgi-bin && \\
- sudo chmod -v 755 #{@cgi_file_name}; \\
- sudo rm -vi #{@env.url.cgi_sample_search_form_name(@opt)}; \\
- sudo ln -sf #{@cgi_file_name} #{@env.url.cgi_sample_search_form_name(@opt)}; \\
- cd -
+ sudo chmod -v 755 /usr/lib/cgi-bin/#{@cgi_file_name}
WOK
end
b='(to create and populate sisu sqlite database see "man sisu" and in particular the -d flag)'
SiSU_Screen::Ansi.new(@opt.cmd,a,b).warn
a=<<-WOK
- #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_link_name}
+ #{@env.webserv_base_cgi(@opt)}/cgi-bin/#{@cgi_file_name}
WOK
SiSU_Screen::Ansi.new(@opt.cmd,a).print_blue
@@ -167,6 +171,8 @@ module SiSU_CGI_SQLite
@image_src='#{@image_src}'
@hosturl_cgi='#{@env.url.webserv_base_cgi(@opt)}/cgi-bin'
@hosturl_files='#{@env.url.webserv_files_from_db(@opt)}'
+ @output_dir_structure_by='#{@name_of[:output_dir_structure]}'
+ @lingual='#{@name_of[:lingual]}'
@db_name_prefix='#{Db[:name_prefix]}'
@base='#{@env.url.webserv_base_cgi(@opt)}/cgi-bin/#{@env.url.cgi_sample_search_form_name(@opt)}' #fix sqlite
WOK_SQL
diff --git a/lib/sisu/v4/concordance.rb b/lib/sisu/v4/concordance.rb
index cba5ae99..567b36e0 100644
--- a/lib/sisu/v4/concordance.rb
+++ b/lib/sisu/v4/concordance.rb
@@ -239,15 +239,14 @@ WOK
%{<a href="doc#{@md.lang_code_insert}#{Sfx[:html]}\##{wordlocation}">#{wordlocation}</a>; }
end
def location_seg(wordlocation,show) ##fix
- @word_location_seg=wordlocation.gsub(/(.+?)\#(\d+)/,"\\1#{@md.lang_code_insert}#{Sfx[:html]}#\\2") unless wordlocation.nil?
- case wordlocation
- when @rxp_t1
- %{[<a href="doc#{@md.lang_code_insert}#{Sfx[:html]}##{show}">H</a>]#{show}, }
- when @rxp_t2
- %{[<a href="doc#{@md.lang_code_insert}#{Sfx[:html]}##{show}">H</a>]#{show}, }
- when @rxp_t3
- %{[<a href="doc#{@md.lang_code_insert}#{Sfx[:html]}##{show}">H</a>]#{show}, }
- else %{<a href="#{@word_location_seg}">#{show}</a>, }
+ unless wordlocation.nil?
+ wl=wordlocation.gsub(/(.+?)\#(\d+)/,"\\1#{@md.lang_code_insert}#{Sfx[:html]}#\\2")
+ case wordlocation
+ when /#{@rxp_t1}|@rxp_t2}|#{@rxp_t3}/
+ %{[<a href="doc#{@md.lang_code_insert}#{Sfx[:html]}##{show}">H</a>]#{show}, }
+ when /(.+?)\#(\d+)/
+ %{<a href="#{wl}">#{show}</a>, }
+ end
end
end
def map_para
@@ -316,10 +315,11 @@ WOK
end
@freq[word] +=1
@word_map[word] ||= []
- if line !~@rxp_lv1 \
- and line !~@rxp_lv2 \
- and line !~@rxp_lv3 #fix @rxp_lv # Mx[:lv_o]
- @word_map[word] << location_seg("#{@seg}\##{ocn}",ocn)
+ if line !~ /#{@rxp_lv1}|#{@rxp_lv2}|#{@rxp_lv3}/
+ loc_=%{#{location_seg("#{@seg}\##{ocn}",ocn).to_s}}
+ unless loc_.empty?
+ @word_map[word] << loc_
+ end
else
@word_map[word] << case line
when @rxp_lv1; location_seg('T1',ocn) #fix @rxp_lv # Mx[:lv_o]
diff --git a/lib/sisu/v4/constants.rb b/lib/sisu/v4/constants.rb
index fe4e895f..fab3890f 100644
--- a/lib/sisu/v4/constants.rb
+++ b/lib/sisu/v4/constants.rb
@@ -62,7 +62,22 @@
=end
#Ax,Xx,Mx,Rx,Hx,Dx,Px,Ep,Db,Gt,Tex=Array.new(11){{}}
YEAR='2013'
-Sfx={ txt: '.txt', html: '.html', xhtml: '.xhtml', xml: '.xml', epub: '.epub', epub_xhtml: '.xhtml', odt: '.odt', pdf: '.pdf'}
+Sfx={
+ txt: '.txt',
+ html: '.html',
+ xhtml: '.xhtml',
+ xml: '.xml',
+ xml_sax: '.sax.xml',
+ xml_dom: '.dom.xml',
+ epub: '.epub',
+ epub_xhtml: '.xhtml',
+ odt: '.odt',
+ pdf: '.pdf',
+ manpage: '.1',
+ info: '.info',
+ texinfo: '.texinfo',
+ sql: '.sql.db',
+}
Ax={
tab: "\t",
}
diff --git a/lib/sisu/v4/dal_expand_insertions.rb b/lib/sisu/v4/dal_expand_insertions.rb
index 9a242b28..bfa9f7da 100644
--- a/lib/sisu/v4/dal_expand_insertions.rb
+++ b/lib/sisu/v4/dal_expand_insertions.rb
@@ -111,44 +111,66 @@ module SiSU_DAL_Insertions
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 fnh
+ {
+ fn: @linked_doc,
+ ft: ft,
+ }
+ end
+ def path_and_file(fn,pth)
+ "#{@base_path}/#{pth}/#{fn}"
+ end
def manifest
- "#{@base_path}/manifest/#{@linked_doc}.html"
+ fn=@md.file.base_filename.manifest(fnh)
+ path_and_file(fn,'manifest')
end
def html_toc
- "#{@base_path}/html/#{@linked_doc}.html"
+ fn=@md.file.base_filename.html_segtoc(fnh)
+ "#{@base_path}/html/#{@linked_doc}/#{fn}"
end
def html_doc
- "#{@base_path}/html/#{@linked_doc}.html"
+ fn=@md.file.base_filename.html_scroll(fnh)
+ path_and_file(fn,'html')
end
def html_concordance
- "#{@base_path}/html/#{@linked_doc}.html"
+ fn=@md.file.base_filename.html_concordance
+ "#{@base_path}/html/#{@linked_doc}/#{fn}"
end
def epub
- "#{@base_path}/epub/#{@linked_doc}.epub"
+ fn=@md.file.base_filename.epub(fnh)
+ path_and_file(fn,'epub')
end
def pdf_landscape
- "#{@base_path}/pdf/#{@linked_doc}.pdf"
+ fn=@md.file.base_filename.pdf_l_a4(fnh)
+ path_and_file(fn,'pdf')
end
def pdf_portrait
- "#{@base_path}/pdf/#{@linked_doc}.pdf"
+ fn=@md.file.base_filename.pdf_p_a4(fnh)
+ path_and_file(fn,'pdf')
end
def odt
- "#{@base_path}/odt/#{@linked_doc}.odt"
+ fn=@md.file.base_filename.odt(fnh)
+ path_and_file(fn,'odt')
end
def xhtml
- "#{@base_path}/xhtml/#{@linked_doc}.xhtml"
+ fn=@md.file.base_filename.xhtml(fnh)
+ path_and_file(fn,'xhtml')
end
def xml_sax
- "#{@base_path}/xml/#{@linked_doc}.xml"
+ fn=@md.file.base_filename.xml_sax(fnh)
+ path_and_file(fn,'xml_sax')
end
def xml_dom
- "#{@base_path}/xml/#{@linked_doc}.xml"
+ fn=@md.file.base_filename.xml_dom(fnh)
+ path_and_file(fn,'xml_dom')
end
def txt
- "#{@base_path}/txt/#{@linked_doc}.txt"
+ fn=@md.file.base_filename.txt(fnh)
+ path_and_file(fn,'txt')
end
def digest
- "#{@base_path}/digest/#{@linked_doc}.txt"
+ fn=@md.file.base_filename.hash_digest(fnh)
+ path_and_file(fn,'digest')
end
def source
"#{@base_path}/src/#{@src}"
@@ -161,44 +183,65 @@ module SiSU_DAL_Insertions
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 fnh
+ {
+ fn: @linked_doc,
+ }
+ end
+ def path_and_file(fn,pth)
+ "#{@base_path}/#{pth}/#{fn}"
+ end
def manifest
- "#{@base_path}/manifest/#{@linked_doc}.#{@lng}.html"
+ fn=@md.file.base_filename.manifest(fnh)
+ path_and_file(fn,'manifest')
end
def html_toc
- "#{@base_path}/html/#{@linked_doc}.#{@lng}.html"
+ fn=@md.file.base_filename.html_segtoc(fnh)
+ path_and_file(fn,'html')
end
def html_doc
- "#{@base_path}/html/#{@linked_doc}.#{@lng}.html"
+ fn=@md.file.base_filename.html_scroll(fnh)
+ path_and_file(fn,'html')
end
def html_concordance
- "#{@base_path}/html/#{@linked_doc}.#{@lng}.html"
+ fn=@md.file.base_filename.html_concordance
+ path_and_file(fn,'html')
end
def epub
- "#{@base_path}/epub/#{@linked_doc}.#{@lng}.epub"
+ fn=@md.file.base_filename.epub(fnh)
+ path_and_file(fn,'epub')
end
def pdf_landscape
- "#{@base_path}/pdf/#{@linked_doc}.#{@lng}.pdf"
+ fn=@md.file.base_filename.pdf_l_a4(fnh)
+ path_and_file(fn,'pdf')
end
def pdf_portrait
- "#{@base_path}/pdf/#{@linked_doc}.#{@lng}.pdf"
+ fn=@md.file.base_filename.pdf_p_a4(fnh)
+ path_and_file(fn,'pdf')
end
def odt
- "#{@base_path}/odt/#{@linked_doc}.#{@lng}.odt"
+ fn=@md.file.base_filename.odt(fnh)
+ path_and_file(fn,'odt')
end
def xhtml
- "#{@base_path}/xhtml/#{@linked_doc}.#{@lng}.xhtml"
+ fn=@md.file.base_filename.xhtml(fnh)
+ path_and_file(fn,'xhtml')
end
def xml_sax
- "#{@base_path}/xml_sax/#{@linked_doc}.#{@lng}.xml"
+ fn=@md.file.base_filename.xml_sax(fnh)
+ path_and_file(fn,'xml_sax')
end
def xml_dom
- "#{@base_path}/xml_dom/#{@linked_doc}.#{@lng}.xml"
+ fn=@md.file.base_filename.xml_dom(fnh)
+ path_and_file(fn,'xml_dom')
end
def txt
- "#{@base_path}/txt/#{@linked_doc}.#{@lng}.txt"
+ fn=@md.file.base_filename.txt(fnh)
+ path_and_file(fn,'txt')
end
def digest
- "#{@base_path}/digest/#{@linked_doc}.#{@lng}.txt"
+ fn=@md.file.base_filename.hash_digest(fnh)
+ path_and_file(fn,'digest')
end
def source
"#{@base_path}/src/#{@src}"
@@ -211,44 +254,64 @@ module SiSU_DAL_Insertions
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 fnh
+ {
+ fn: @linked_doc,
+ }
+ end
+ def path_and_file(fn)
+ "#{@base_path}/#{fn}"
+ end
def manifest
- "#{@base_path}/sisu_manifest.#{@lng}.html"
+ fn=@md.file.base_filename.manifest(fnh)
+ path_and_file(fn)
end
def html_toc
- "#{@base_path}/toc.#{@lng}.html"
+ fn=@md.file.base_filename.html_segtoc(fnh)
+ path_and_file(fn)
end
def html_doc
- "#{@base_path}/scroll.#{@lng}.html"
+ fn=@md.file.base_filename.html_scroll(fnh)
+ path_and_file(fn)
end
def html_concordance
- "#{@base_path}/concordance.#{@lng}.html"
+ fn=@md.file.base_filename.html_concordance
+ path_and_file(fn)
end
def epub
"#{@base_path}/epub/#{@linked_doc}.#{@lng}.epub"
end
def pdf_landscape
- "#{@base_path}/landscape.#{@lng}.a4.pdf"
+ fn=@md.file.base_filename.pdf_l_a4(fnh)
+ path_and_file(fn)
end
def pdf_portrait
- "#{@base_path}/portrait.#{@lng}.a4.pdf"
+ fn=@md.file.base_filename.pdf_p_a4(fnh)
+ path_and_file(fn)
end
def odt
- "#{@base_path}/opendocument.#{@lng}.odt"
+ fn=@md.file.base_filename.odt(fnh)
+ path_and_file(fn)
end
def xhtml
- "#{@base_path}/scroll.#{@lng}.xhtml"
+ fn=@md.file.base_filename.xhtml(fnh)
+ path_and_file(fn)
end
def xml_sax
- "#{@base_path}/scroll.#{@lng}.sax.xml"
+ fn=@md.file.base_filename.xml_sax(fnh)
+ path_and_file(fn)
end
def xml_dom
- "#{@base_path}/scroll.#{@lng}.dom.xml"
+ fn=@md.file.base_filename.xml_dom(fnh)
+ path_and_file(fn)
end
def txt
- "#{@base_path}/plain.#{@lng}.txt"
+ fn=@md.file.base_filename.txt(fnh)
+ path_and_file(fn)
end
def digest
- "#{@base_path}/digest.#{@lng}.txt"
+ fn=@md.file.base_filename.hash_digest(fnh)
+ path_and_file(fn)
end
def source
"#{@base_path}/#{@src}"
diff --git a/lib/sisu/v4/harvest_authors.rb b/lib/sisu/v4/harvest_authors.rb
index a6033f27..a5f68cc7 100644
--- a/lib/sisu/v4/harvest_authors.rb
+++ b/lib/sisu/v4/harvest_authors.rb
@@ -364,12 +364,13 @@ WOK
@output[lng][:html_mnt] << x
end
@output[lng][:html] << x
+ lang_code_insert=SiSU_Env::FilenameLanguageCodeInsert.new(@opt,lng).language_code_insert
works=[]
a[1][:md].each do |i|
manifest_at=if @env.output_dir_structure.by? == :language
- i[:file] + '.html'
+ i[:file] + Sfx[:html]
elsif @env.output_dir_structure.by? == :filetype
- i[:file] + '.' + lng + '.html'
+ i[:file] + '.' + lang_code_insert + Sfx[:html]
elsif @env.output_dir_structure.by? == :filename
"./#{i[:file]}/#{i[:page]}"
else '' #error
diff --git a/lib/sisu/v4/harvest_topics.rb b/lib/sisu/v4/harvest_topics.rb
index 616c9598..09104f30 100644
--- a/lib/sisu/v4/harvest_topics.rb
+++ b/lib/sisu/v4/harvest_topics.rb
@@ -737,10 +737,11 @@ WOK
end
end
def do_hash_md(lng,attrib,hash)
+ lang_code_insert=SiSU_Env::FilenameLanguageCodeInsert.new(@opt,lng).language_code_insert
manifest_at=if @env.output_dir_structure.by? == :language
- hash[:file] + '.html'
+ hash[:file] + Sfx[:html]
elsif @env.output_dir_structure.by? == :filetype
- hash[:file] + '.' + lng + '.html'
+ hash[:file] + lang_code_insert + Sfx[:html]
elsif @env.output_dir_structure.by? == :filename
"./#{hash[:file]}/#{hash[:page]}"
else '' #error
diff --git a/lib/sisu/v4/html.rb b/lib/sisu/v4/html.rb
index 210bc0b3..d4987c4d 100644
--- a/lib/sisu/v4/html.rb
+++ b/lib/sisu/v4/html.rb
@@ -418,14 +418,21 @@ WOK
linkname,ocn=dob.obj.strip,dob.ocn
p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) if ocn
if dob.ln ==4
- seg_link=%{ <a href="#{dob.name}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top">
+ fnh={
+ fn: dob.name,
+ }
+ f=@md.file.base_filename.html_seg(fnh)
+ seg_link=%{ <a href="#{f}" target="_top">
#{dob.obj}
</a> }
@@seg_url=dob.name
elsif dob.obj =~/\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+/
- seg_link=dob.obj.gsub(/^(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/,
- %{<a href="\\1#{@md.lang_code_insert}#{Sfx[:html]}" } +
- %{target="_top">\\1 \\2</a> })
+ fn,hd=/^(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/.match(dob.obj)[1,2]
+ fnh={
+ fn: fn,
+ }
+ f=@md.file.base_filename.html_seg(fnh)
+ seg_link=%{<a href="#{f}" target="_top">#{fn} #{hd}</a> }
end
p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn) if ocn
@file=SiSU_Env::FileOp.new(@md) if @md
@@ -459,8 +466,12 @@ WOK
toc={}
if ocn \
and ocn !~/#/
+ fnh={
+ fn: @@seg_url,
+ }
+ f=@md.file.base_filename.html_seg(fnh)
p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
- lnk_n_txt=%{ <a href="#{@@seg_url}#{@md.lang_code_insert}#{Sfx[:html]}##{ocn}">
+ lnk_n_txt=%{ <a href="#{f}##{ocn}">
#{linkname}
</a>}
txt_obj={ txt: lnk_n_txt }
@@ -480,8 +491,12 @@ WOK
toc={}
if ocn \
and ocn !~/#/
+ fnh={
+ fn: @@seg_url,
+ }
+ f=@md.file.base_filename.html_seg(fnh)
p_num=SiSU_HTML_Format::ParagraphNumber.new(@md,ocn)
- lnk_n_txt=%{ <a href="#{@@seg_url}#{@md.lang_code_insert}#{Sfx[:html]}##{ocn}">
+ lnk_n_txt=%{ <a href="#{f}##{ocn}">
#{linkname}
</a>}
txt_obj={ txt: lnk_n_txt }
diff --git a/lib/sisu/v4/html_minitoc.rb b/lib/sisu/v4/html_minitoc.rb
index d333e3fe..2733affb 100644
--- a/lib/sisu/v4/html_minitoc.rb
+++ b/lib/sisu/v4/html_minitoc.rb
@@ -153,14 +153,21 @@
txt=@data
unless txt =~/~metadata/
if txt.ln ==4
- seg_link=%{ <a href="#{txt.name}#{@md.lang_code_insert}#{Sfx[:html]}" target="_top">
+ fnh={
+ fn: txt.name,
+ }
+ f=@md.file.base_filename.html_seg(fnh)
+ seg_link=%{ <a href="#{f}" target="_top">
#{txt.obj}
</a> }
@@seg_url=txt.name
elsif txt.obj =~/\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+/
- seg_link=txt.obj.gsub(/^(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/,
- %{<a href="\\2#{@md.lang_code_insert}#{Sfx[:html]}" } +
- %{target="_top">\\1 \\2</a> })
+ fn,hd=/^(\d+.\d+.\d+.\d+|\d+.\d+.\d+|\d+.\d+|\d+)(.*)/.match(dob.obj)[1,2]
+ fnh={
+ fn: fn,
+ }
+ f=@md.file.base_filename.html_seg(fnh)
+ seg_link=%{<a href="#{f}" target="_top">#{fn} #{hd}</a> }
end
txt_obj={ txt: seg_link }
format_toc=SiSU_HTML_Format::FormatToc.new(@md,txt_obj)
@@ -175,7 +182,11 @@
&& txt.ocn !=0
txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1')
end
- lnk_n_txt=%{ <a href="#{@@seg_url}#{@md.lang_code_insert}#{Sfx[:html]}##{txt.ocn}">
+ fnh={
+ fn: @@seg_url,
+ }
+ f=@md.file.base_filename.html_seg(fnh)
+ lnk_n_txt=%{ <a href="#{f}##{txt.ocn}">
#{txt.obj}
</a>}
txt_obj={ txt: lnk_n_txt }
@@ -190,7 +201,11 @@
&& txt.ocn !=0
txt.obj=txt.obj.gsub(@pat_strip_heading_name,'\1')
end
- lnk_n_txt=%{ <a href="#{@@seg_url}#{@md.lang_code_insert}#{Sfx[:html]}##{txt.ocn}">
+ fnh={
+ fn: @@seg_url,
+ }
+ f=@md.file.base_filename.html_seg(fnh)
+ lnk_n_txt=%{ <a href="#{f}##{txt.ocn}">
#{txt.obj}
</a>}
txt_obj={ txt: lnk_n_txt }
diff --git a/lib/sisu/v4/html_segments.rb b/lib/sisu/v4/html_segments.rb
index 65034738..ac3cebac 100644
--- a/lib/sisu/v4/html_segments.rb
+++ b/lib/sisu/v4/html_segments.rb
@@ -273,7 +273,11 @@ module SiSU_HTML_Seg
FileUtils::mkdir_p(@file.output_path.html_seg.dir) if File.writable?("#{@file.output_path.base.dir}/.")
end
SiSU_HTML_Seg::Seg.new(@md).tail
- segfilename="#{@file.output_path.html_seg.dir}/#{@@seg_name_html[tracking-1]}#{@md.lang_code_insert}#{Sfx[:html]}"
+ fnh={
+ fn: @@seg_name_html[tracking-1],
+ }
+ fn=@md.file.base_filename.html_seg(fnh)
+ segfilename="#{@file.output_path.html_seg.dir}/#{fn}"
output_seg_file=File.new(segfilename,'w') if @@seg_name_html[tracking-1]
minitoc=(@make.build.html_minitoc?) \
? @minitoc
@@ -298,7 +302,11 @@ module SiSU_HTML_Seg
head(dob)
#keep use for last segment, eg if metadata is last segment
if @@seg_name_html[tracking] =='metadata' # this is for metadata
- segfilename="#{@file.output_path.html_seg.dir}/#{@@seg_name_html[tracking]}#{@md.lang_code_insert}#{Sfx[:html]}"
+ fnh={
+ fn: @@seg_name_html[tracking],
+ }
+ fn=@md.file.base_filename.html_seg(fnh)
+ segfilename="#{@file.output_path.html_seg.dir}/#{fn}"
output_seg_file=File.new(segfilename,'w')
SiSU_HTML_Seg::Output.new(@md,output_seg_file,@@seg,minitoc,'metadata').output
Seg.new.reinitialise
diff --git a/lib/sisu/v4/hub.rb b/lib/sisu/v4/hub.rb
index 84178dff..72ed5a6b 100644
--- a/lib/sisu/v4/hub.rb
+++ b/lib/sisu/v4/hub.rb
@@ -89,6 +89,7 @@ module SiSU
end
end
class OptionLoopFiles
+ attr_reader :opt
def initialize(opt)
@opt=opt
@r=Px[:lng_lst_rgx]
diff --git a/lib/sisu/v4/manifest.rb b/lib/sisu/v4/manifest.rb
index 600b33d1..ba5a0556 100644
--- a/lib/sisu/v4/manifest.rb
+++ b/lib/sisu/v4/manifest.rb
@@ -176,27 +176,29 @@ module SiSU_Manifest
mp,mn,mt,mr=nil,nil,nil,nil
ln=SiSU_i18n::Languages.new.language.list
Px[:lng_lst].each do |lc|
+ lngc=SiSU_Env::FilenameLanguageCodeInsert.new(@md.opt,lc).language_code_insert
+ fnh={
+ fn: @md.fnb,
+ lng: lngc,
+ }
+ mn=@f.base_filename.manifest(fnh)
if @o_str.dump_or_redirect? #does not work for --redirect or --dump
mp="#{@f.output_path.base.dir}"
- mn="#{@md.fnb}.html"
mt="#{mp}/#{mn}"
mr="../../#{lc}/manifest/#{mn}"
mu="#{url}/#{mn}"
elsif @f.output_dir_structure.by_language_code?
mp="#{@f.output_path.base.dir}/#{lc}/manifest"
- mn="#{@md.fnb}.html"
mt="#{mp}/#{mn}"
mr="../../#{lc}/manifest/#{mn}"
mu="#{url}/#{lc}/manifest/#{mn}"
elsif @f.output_dir_structure.by_filetype?
mp="#{@f.output_path.base.dir}/manifest"
- mn="#{@md.fnb}.#{lc}.html"
mt="#{mp}/#{mn}"
mr=mn
mu="#{url}/manifest/#{mn}"
else
mp="#{@f.output_path.base.dir}/#{@md.fnb}"
- mn="sisu_manifest.#{lc}.html"
mt="#{mp}/#{mn}"
mr=mn
mu="#{url}/#{mn}"
@@ -211,18 +213,16 @@ module SiSU_Manifest
@m=@m.uniq
end
def languages(id,file)
- flv=published_manifests?
@manifest[:html] << %{<tr><th class="left"><div id="horizontal_links"><ul id="horizontal">\n}
- flv.each do |l|
+ published_manifests?.each do |l|
SiSU_Translate::Source.new(@md,@language,l[:n]).language_list
@manifest[:txt] << "#{l[:mu]} #{l[:l]}\n"
@manifest[:html] << %{<li class="norm"><a href="#{l[:rel]}">#{l[:l]}</a>&nbsp;&nbsp;&nbsp;</li>}
end
@manifest[:html] << %{</ul></div></th></tr>\n}
end
- def published_languages(id,file)
- flv=published_manifests?
- flv.each do |l|
+ def published_languages(id)
+ published_manifests?.each do |l|
@manifest[:txt] << "#{l[:mu]} #{l[:l]}\n"
@manifest[:html] << %{<tr><th class="left"><p class="bold"><a href="#{l[:mu]}">#{l[:l]}</a></p></th><td><p class="norm">#{l[:l]}</p><p class="tiny">#{@brace_url.xml_open}<a href="#{l[:mu]}">#{l[:mu]}</a>#{@brace_url.xml_close}</p></td><td class="right"><p class="right">&nbsp;</p></td></tr>\n}
end
@@ -445,8 +445,8 @@ module SiSU_Manifest
end
def language_versions
if FileTest.file?(@f.place_file.manifest.dir)==true
- id,file='Markup (SiSU source)',@md.fns
- published_languages(id,file)
+ id='Markup (SiSU source)'
+ published_languages(id)
end
end
def qrc_image
diff --git a/lib/sisu/v4/options.rb b/lib/sisu/v4/options.rb
index 8ad92f8f..9d6821ac 100644
--- a/lib/sisu/v4/options.rb
+++ b/lib/sisu/v4/options.rb
@@ -137,7 +137,7 @@ module SiSU_Commandline
end
end
class Options
- attr_accessor :cmd,:mod,:act,:dir_structure_by,:f_pths,:files,:files_mod,:base_path,:base_stub,:sub_location,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod
+ attr_accessor :cmd,:mod,:act,:dir_structure_by,:lingual,:f_pths,:files,:files_mod,:base_path,:base_stub,:sub_location,:paths,:lngs,:f_pth,:pth,:fno,:fns,:fnb,:fnc,:fng,:fncb,:lng,:lng_base,:what,:make_instructions,:make_instructions_pod
@@act=nil
def initialize(a)
@cmd,@f_pth,@pth,@fno,@fns,@fnb,@fnc,@fng,@fncb,@what,@lng,@lng_base,@base_path,@base_stub,@sub_location='','','','','','','','','','','','','',''
@@ -145,6 +145,7 @@ module SiSU_Commandline
@env=SiSU_Env::InfoEnv.new
@lng_base=@env.language_default_set
@dir_structure_by=SiSU_Env::EnvCall.new.output_dir_structure.by?
+ @lingual=SiSU_Env::EnvCall.new.mono_multi_lingual?
@@sisu_call_origin_path ||=Dir.pwd
@base_path=@@sisu_call_origin_path
r=Px[:lng_lst_rgx]
@@ -217,7 +218,7 @@ module SiSU_Commandline
end
end
end
- r=Px[:lng_lst_rgx].gsub(/\|#{@lng_base}\|/,'|')
+ r=Px[:lng_lst_rgx].gsub(/\|#{lng_base}\|/,'|')
@lang_regx=%r{(?:#{r})}
if find_flag
(f.length > 0) \
@@ -225,7 +226,7 @@ module SiSU_Commandline
: find_all(find_flag,b)
elsif a.inspect =~/"(?:-\S+?|--\S+?)"/ \
&& a.inspect =~/"#{@lang_regx}\/?"/ \
- && a.inspect =~/"#{@lng_base}\/\S+?\.ss[tm]"/
+ && a.inspect =~/"#{lng_base}\/\S+?\.ss[tm]"/
init_selected_lang_dirs(a)
else b
end
@@ -235,7 +236,7 @@ module SiSU_Commandline
def init_selected_lang_dirs(a)
@z=[]
a.each do |y|
- if y =~/^#{@lng_base}\/(\S+?\.ss[tm])$/
+ if y =~/^#{lng_base}\/(\S+?\.ss[tm])$/
@fn=$1
@z << y
elsif y =~/^#{@lang_regx}\/?$/
@@ -670,11 +671,28 @@ module SiSU_Commandline
{ bool: false, set: :off, off: off_list}
else { bool: true, set: :na, off: [] }
end
+ act[:default_language]=if mod.inspect =~/"--(?:default-)?language[-=](\S{2})"/
+ { set: :on, code: $1 }
+ elsif lng_base
+ { set: :on, code: lng_base }
+ else { set: :na, code: 'en' }
+ end
+ act[:i18n]=if mod.inspect =~/"(?:--monolingual|--i18n-mono(?:lingual)?)"/ #if monolingual possible outputs output_by :filename & :filetype only, without language code in default language name; give warning of conflict settings if monolingual & :language selected
+ @lingual=:mono
+ { set: :mono }
+ elsif mod.inspect =~/"(?:--multilingual|--i18n-multi(?:lingual)?)"/
+ @lingual=:multi
+ { set: :multi }
+ else { set: :na }
+ end
act[:output_by]=if mod.inspect =~/"--(?:output-)?by-language"/
+ @dir_structure_by=:language
{ set: :language }
elsif mod.inspect =~/"--(?:output-)?by-filename"/
+ @dir_structure_by=:filename
{ set: :filename }
elsif mod.inspect =~/"--(?:output-)?by-filetype"/
+ @dir_structure_by=:filetype
{ set: :filetype }
else { set: :na }
end
diff --git a/lib/sisu/v4/param.rb b/lib/sisu/v4/param.rb
index fb2061a7..ed70c9c4 100644
--- a/lib/sisu/v4/param.rb
+++ b/lib/sisu/v4/param.rb
@@ -841,16 +841,7 @@ module SiSU_Param
@authors,@topic_register_array,@papersize_array=[],[],[]
@lvs=[nil,0,0,0,0,0,0]
@emphasis_set_to='bold'
- @lang_code_insert=if @opt.act[:output_by][:set]==:language
- ''
- elsif @opt.act[:output_by][:set]==:filetype \
- or @opt.act[:output_by][:set]==:filename
- ".#{@opt.lng}"
- elsif @opt.dir_structure_by ==:language
- ''
- else
- ".#{@opt.lng}"
- end
+ @lang_code_insert=SiSU_Env::FilenameLanguageCodeInsert.new(@opt).language_code_insert
@footer_links= { left: { say: '', url: '' }, center: { say: '', url: '' } }
@rgx_image=/(?:^|[^_\\])\{(?:\s*|\~\^\s+)(\S+?\.(?:png|jpg|gif)\b)/m
@rgx_audio=/\{\s*(\S+?\.(?:mp3|ogg))/
diff --git a/lib/sisu/v4/sysenv.rb b/lib/sisu/v4/sysenv.rb
index 5f764f9c..32e38ac6 100644
--- a/lib/sisu/v4/sysenv.rb
+++ b/lib/sisu/v4/sysenv.rb
@@ -441,10 +441,36 @@ module SiSU_Env
end
@fnn,@fnb,@fnt,@flv,@fnz=@@fnn,@@fnb,@@fnt,@@flv,@@fnz
end
+ def default_language?
+ if @rc \
+ && defined? @rc['language_default']
+ if (@rc['language_default'].is_a?(String)) \
+ && (@rc['language_default'] =~/#{Px[:lng_lst_rgx]}/)
+ @rc['language_default']
+ else 'en'
+ end
+ else 'en'
+ end
+ end
+ def mono_multi_lingual?
+ if @rc \
+ && defined? @rc['lingual']
+ if (@rc['lingual'].is_a?(String)) \
+ && (@rc['lingual'] =~/mono(?:lingual)?/)
+ :mono
+ elsif (@rc['lingual'].is_a?(String)) \
+ && (@rc['lingual'] =~/multi(?:lingual)?/)
+ :multi
+ else :multi
+ end
+ else :multi
+ end
+ end
def output_dir_structure
def by?
output_structure=:filename #set default output structure
- output_structure=if defined? @rc['output_dir_structure_by']
+ if @rc \
+ && defined? @rc['output_dir_structure_by']
output_structure=if (@rc['output_dir_structure_by'] =~/dump/) \
or ((defined? @rc['output_structure']['dump']) \
&& @rc['output_structure']['dump'] ==true)
@@ -2489,8 +2515,8 @@ WOK
/(?:https?:\/\/\S+?)\/([^\/]+?\.cgi)$/.match(@rc['search']['sisu']['action'])[1]
else
(opt.mod.inspect =~/--db[=-]["']?sqlite/) \
- ? 'sisu_sqlite.cgi' \
- : 'sisu_pgsql.cgi'
+ ? "#{Db[:name_prefix_db]}sqlite.cgi" \
+ : "#{Db[:name_prefix_db]}pgsql.cgi"
end
end
def sample_search_form_title(organised_by=:language)
@@ -4631,245 +4657,433 @@ WOK
self
end
def base_filename
- def txt
- ft='.txt'
- if output_dir_structure.by_language_code?
- @md.fnb + ft
- elsif output_dir_structure.by_filetype?
- @md.fnb + @md.lang_code_insert + ft
- else
- 'plain' + @md.lang_code_insert + ft
- end
- end
- def html_scroll
- ft='.html'
- if output_dir_structure.by_language_code?
- @md.fnb + ft
- elsif output_dir_structure.by_filetype?
- @md.fnb + @md.lang_code_insert + ft
+ def i18n(f)
+ f=default_hash.merge(f)
+ f[:lng] ||=@md.lang_code_insert
+ f[:fn] + f[:lng] + f[:ft]
+ end
+ def default_hash
+ {
+ fn: @md.fnb,
+ lng: @md.lang_code_insert,
+ }
+ end
+ def default_hash_build(fh,sfx)
+ if fh.is_a?(Hash)
+ fh[:fn] ||=@md.fnb
+ fh[:lng] ||= @md.lang_code_insert
+ fh[:ft]=sfx
+ fh
else
- 'scroll' + @md.lang_code_insert + ft
+ {
+ fn: @md.fnb,
+ lng: @md.lang_code_insert,
+ ft: sfx,
+ }
end
end
- def html_seg_index
- ft='.html'
- if output_dir_structure.by_language_code?
- 'index' + ft
+ def lang_code?(lng)
+ (output_dir_structure.by_language_code?) \
+ ? ''
+ : (lng ||=@md.lang_code_insert)
+ end
+ def txt(fh=nil)
+ fh=default_hash_build(fh,Sfx[:txt])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.by_filename?
+ {
+ fn: 'plain',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ else
+ {
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ end
+ i18n(fnh)
+ end
+ def html_scroll(fh=nil)
+ fh=default_hash_build(fh,Sfx[:html])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.by_filename?
+ {
+ fn: 'scroll',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
else
- 'index' + @md.lang_code_insert + ft
- end
- end
- def html_segtoc
- ft='.html'
- if output_dir_structure.dump_or_redirect?
- @md.fnb + '.toc' + ft
- elsif output_dir_structure.by_language_code?
- 'toc' + ft
+ {
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ end
+ i18n(fnh)
+ end
+ def html_seg_index(fh=nil)
+ fh=default_hash_build(fh,Sfx[:html])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh={
+ fn: 'index',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ i18n(fnh)
+ end
+ def html_segtoc(fh=nil)
+ fh=default_hash_build(fh,Sfx[:html])
+ fnh=if output_dir_structure.dump_or_redirect?
+ {
+ fn: fh[:fn] + '.toc',
+ ft: fh[:ft],
+ }
else
- 'toc' + @md.lang_code_insert + ft
- end
- end
- def html_book_index
- ft='.html'
- if output_dir_structure.by_language_code?
- 'book_index' + ft
+ {
+ fn: 'toc',
+ ft: fh[:ft],
+ lng: lang_code?(fh[:lng]),
+ }
+ end
+ i18n(fnh)
+ end
+ def html_seg(fh)
+ fh=default_hash_build(fh,Sfx[:html])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.by_filename?
+ {
+ fn: 'scroll',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
else
- 'book_index' + @md.lang_code_insert + ft
- end
- end
- def html_concordance
- ft='.html'
- if output_dir_structure.dump_or_redirect?
+ {
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ end
+ i18n(fnh)
+ end
+ def html_book_index(fh=nil)
+ fh=default_hash_build(fh,Sfx[:html])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh={
+ fn: 'book_index',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ i18n(fnh)
+ end
+ def html_concordance(fh=nil)
+ fh=default_hash_build(fh,Sfx[:html])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.dump_or_redirect?
@md.fnb + '.concordance' + ft
- elsif output_dir_structure.by_language_code?
- 'concordance' + ft
else
- 'concordance' + @md.lang_code_insert + ft
- end
- end
- def xhtml
- ft= '.xhtml'
- if output_dir_structure.by_language_code?
- @md.fnb + ft
- elsif output_dir_structure.by_filetype?
- @md.fnb + @md.lang_code_insert + ft
+ {
+ fn: 'concordance',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ end
+ i18n(fnh)
+ end
+ def xhtml(fh=nil)
+ fh=default_hash_build(fh,Sfx[:xhtml])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.by_filename?
+ {
+ fn: 'scroll',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
else
- 'scroll' + @md.lang_code_insert + ft
- end
- end
- def epub
- ft='.epub'
- if output_dir_structure.by_language_code?
- @md.fnb + ft
+ {
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ end
+ i18n(fnh)
+ end
+ def epub(fh=nil)
+ fh=default_hash_build(fh,Sfx[:epub])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh={
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ i18n(fnh)
+ end
+ def odt(fh=nil)
+ fh=default_hash_build(fh,Sfx[:odt])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.by_filename?
+ {
+ fn: 'opendocument',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
else
- @md.fnb + @md.lang_code_insert + ft
- end
- end
- def odt
- ft='.odt'
- if output_dir_structure.by_language_code?
- @md.fnb + ft
- elsif output_dir_structure.by_filetype?
- @md.fnb + @md.lang_code_insert + ft
+ {
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ end
+ i18n(fnh)
+ end
+ def xml_sax(fh=nil)
+ fh=default_hash_build(fh,Sfx[:xml_sax])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.by_filename?
+ {
+ fn: 'scroll',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
else
- 'opendocument' + @md.lang_code_insert + ft
- end
- end
- def xml_sax
- ft='.sax.xml'
- if output_dir_structure.by_language_code?
- @md.fnb + ft
- elsif output_dir_structure.by_filetype?
- @md.fnb + @md.lang_code_insert + ft
+ {
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ end
+ i18n(fnh)
+ end
+ def xml_dom(fh=nil)
+ fh=default_hash_build(fh,Sfx[:xml_dom])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.by_filename?
+ {
+ fn: 'scroll',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
else
- 'scroll' + @md.lang_code_insert + ft
- end
- end
- def xml_dom
- ft='.dom.xml'
- if output_dir_structure.by_language_code?
- @md.fnb + ft
- elsif output_dir_structure.by_filetype?
- @md.fnb + @md.lang_code_insert + ft
+ {
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ end
+ i18n(fnh)
+ end
+ def pdf_p(fh=nil)
+ fh=default_hash_build(fh,Sfx[:pdf])
+ fh[:lng]=lang_code?(fh[:lng])
+ if output_dir_structure.by_filename?
+ 'portrait' + fh[:lng] + '.'
else
- 'scroll' + @md.lang_code_insert + ft
- end
- end
- def pdf_p
- if output_dir_structure.by_language_code?
- @md.fnb + '.portrait.'
- else 'portrait' + @md.lang_code_insert + '.'
- end
- end
- def pdf_l
- if output_dir_structure.by_language_code?
- @md.fnb + '.landscape.'
- else 'landscape' + @md.lang_code_insert + '.'
+ fh[:fn] + '.portrait' + fh[:lng] + '.'
end
end
- def pdf_p_a4
- pdf_p + @md.fn[:pdf_p_a4]
- end
- def pdf_p_a5
- pdf_p + @md.fn[:pdf_p_a5]
- end
- def pdf_p_b5
- pdf_p + @md.fn[:pdf_p_b5]
- end
- def pdf_p_letter
- pdf_p + @md.fn[:pdf_p_letter]
- end
- def pdf_p_legal
- pdf_p + @md.fn[:pdf_p_legal]
- end
- def pdf_l_a4
- pdf_l + @md.fn[:pdf_l_a4]
- end
- def pdf_l_a5
- pdf_l + @md.fn[:pdf_l_a5]
- end
- def pdf_l_b5
- pdf_l + @md.fn[:pdf_l_b5]
- end
- def pdf_l_letter
- pdf_l + @md.fn[:pdf_l_letter]
- end
- def pdf_l_legal
- pdf_l + @md.fn[:pdf_l_legal]
- end
- def manpage
- ft='1'
- if output_dir_structure.by_language_code?
- @md.fnb + '.' + ft
+ def pdf_l(fh=nil)
+ fh=default_hash_build(fh,Sfx[:pdf])
+ fh[:lng]=lang_code?(fh[:lng])
+ if output_dir_structure.by_filename?
+ 'landscape' + fh[:lng] + '.'
else
- @md.fnb + '.' + @md.opt.f_pth[:lng_is] + '.' + ft
- end
- end
- def info
- ft='info'
- if output_dir_structure.by_language_code?
- @md.fnb + '.' + ft
+ fh[:fn] + '.landscape' + fh[:lng] + '.'
+ end
+ end
+ def pdf_p_a4(fh=nil)
+ pdf_p(fh) + @md.fn[:pdf_p_a4]
+ end
+ def pdf_p_a5(fh=nil)
+ pdf_p(fh) + @md.fn[:pdf_p_a5]
+ end
+ def pdf_p_b5(fh=nil)
+ pdf_p(fh) + @md.fn[:pdf_p_b5]
+ end
+ def pdf_p_letter(fh=nil)
+ pdf_p(fh) + @md.fn[:pdf_p_letter]
+ end
+ def pdf_p_legal(fh=nil)
+ pdf_p(fh) + @md.fn[:pdf_p_legal]
+ end
+ def pdf_l_a4(fh=nil)
+ pdf_l(fh) + @md.fn[:pdf_l_a4]
+ end
+ def pdf_l_a5(fh=nil)
+ pdf_l(fh) + @md.fn[:pdf_l_a5]
+ end
+ def pdf_l_b5(fh=nil)
+ pdf_l(fh) + @md.fn[:pdf_l_b5]
+ end
+ def pdf_l_letter(fh=nil)
+ pdf_l(fh) + @md.fn[:pdf_l_letter]
+ end
+ def pdf_l_legal(fh=nil)
+ pdf_l(fh) + @md.fn[:pdf_l_legal]
+ end
+ def manpage(fh=nil)
+ fh=default_hash_build(fh,Sfx[:manpage])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh={
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ i18n(fnh)
+ end
+ def info(fh=nil)
+ fh=default_hash_build(fh,Sfx[:info])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh={
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ i18n(fnh)
+ end
+ def texinfo(fh=nil)
+ fh=default_hash_build(fh,Sfx[:texinfo])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh={
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ i18n(fnh)
+ end
+ def sqlite_discrete(fh=nil)
+ fh=default_hash_build(fh,Sfx[:sql])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh={
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ i18n(fnh)
+ end
+ def hash_digest(fh=nil)
+ fh=default_hash_build(fh,Sfx[:txt])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.by_language_code?
+ {
+ fn: fh[:fn] + '.hash_digest',
+ ft: fh[:ft],
+ }
+ elsif output_dir_structure.by_filetype?
+ {
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
else
- @md.fnb + '.' + @md.opt.f_pth[:lng_is] + '.' + ft
- end
- end
- def texinfo
- ft='texinfo'
- if output_dir_structure.by_language_code?
- @md.fnb + '.' + ft
+ {
+ fn: 'digest',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ end
+ i18n(fnh)
+ end
+ def sitemap(fh=nil)
+ fh=default_hash_build(fh,Sfx[:xml])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.by_language_code?
+ {
+ fn: fh[:fn] + '.sitemap',
+ ft: fh[:ft],
+ }
+ elsif output_dir_structure.by_filetype?
+ {
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
else
- @md.fnb + '.' + @md.opt.f_pth[:lng_is] + '.' + ft
- end
- end
- def sqlite_discrete
- ft='.sql.db'
- if output_dir_structure.by_language_code?
- @md.fnb + ft
+ {
+ fn: 'sitemap',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ end
+ i18n(fnh)
+ end
+ def qrcode_title(fh=nil)
+ fh=default_hash_build(fh,'.title.png')
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.by_filename?
+ {
+ fn: 'sisu_manifest',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
else
- @md.fnb + @md.lang_code_insert + ft
- end
- end
- def hash_digest
- ft='.txt'
- if output_dir_structure.by_language_code?
- @md.fnb + '.hash_digest' + ft
- elsif output_dir_structure.by_filetype?
- @md.fnb + @md.lang_code_insert + ft
+ {
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ end
+ i18n(fnh)
+ end
+ def qrcode_md #check name below
+ fh=default_hash_build(fh,'.md.png')
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.by_filename?
+ {
+ fn: 'sisu_manifest',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
else
- 'digest' + @md.lang_code_insert + ft
- end
- end
- def sitemap
- ft='.xml'
- if output_dir_structure.by_language_code?
- @md.fnb + '.sitemap' + ft
- elsif output_dir_structure.by_filetype?
- @md.fnb + @md.lang_code_insert + ft
+ {
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ end
+ i18n(fnh)
+ end
+ def manifest_txt(fh=nil)
+ fh=default_hash_build(fh,Sfx[:txt])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.by_filename?
+ {
+ fn: 'sisu_manifest',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
else
- 'sitemap' + @md.lang_code_insert + ft
- end
- end
- def qrcode_title
- ft='.title.png'
- if output_dir_structure.by_language_code?
- @md.fnb + ft
- elsif output_dir_structure.by_filetype?
- @md.fnb + @md.lang_code_insert + ft
- else #fix
- 'sisu_manifest' + @md.lang_code_insert + ft
- end
- end
- def qrcode_md
- ft='.md.png'
- if output_dir_structure.by_language_code?
- @md.fnb + ft
- elsif output_dir_structure.by_filetype?
- @md.fnb + @md.lang_code_insert + ft
- else #fix
- 'sisu_manifest' + @md.lang_code_insert + ft
- end
- end
- def manifest_txt
- ft='.txt'
- if output_dir_structure.by_language_code?
- @md.fnb + ft
- elsif output_dir_structure.by_filetype?
- @md.fnb + @md.lang_code_insert + ft
- else #fix
- 'sisu_manifest' + @md.lang_code_insert + ft
- end
- end
- def manifest
- ft='.html'
- if output_dir_structure.dump_or_redirect?
- @md.fnb + '.manifest' + ft
- elsif output_dir_structure.by_language_code?
- @md.fnb + ft
- elsif output_dir_structure.by_filetype?
- @md.fnb + @md.lang_code_insert + ft
- else #fix
- 'sisu_manifest' + @md.lang_code_insert + ft
+ {
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ end
+ i18n(fnh)
+ end
+ def manifest(fh=nil)
+ fh=default_hash_build(fh,Sfx[:html])
+ fh[:lng]=lang_code?(fh[:lng])
+ fnh=if output_dir_structure.dump_or_redirect?
+ {
+ fn: fh[:fn] + '.manifest',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ elsif output_dir_structure.by_filename?
+ {
+ fn: 'sisu_manifest',
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
+ else
+ {
+ fn: fh[:fn],
+ ft: fh[:ft],
+ lng: fh[:lng],
+ }
end
+ i18n(fnh)
end
def src
@md.fno
@@ -5703,6 +5917,28 @@ WOK
self
end
end
+ class FilenameLanguageCodeInsert
+ def initialize(opt,lng=nil)
+ @opt,@lng=opt,lng
+ @opt=opt
+ @lng=lng ||=@opt.lng
+ end
+ def language_code_insert
+ if @opt.dir_structure_by ==:language \
+ or ((@opt.dir_structure_by ==:filetype \
+ || @opt.dir_structure_by ==:filename) \
+ and (@opt.lingual ==:mono \
+ && @lng == @opt.act[:default_language][:code]))
+ ''
+ elsif (@opt.dir_structure_by ==:filetype \
+ || @opt.dir_structure_by ==:filename) \
+ and not @opt.lingual ==:mono
+ ".#{@lng}"
+ else
+ ".#{@lng}"
+ end
+ end
+ end
class CreateFile <InfoEnv #todo unify with FileOp
def initialize(fns)
begin