aboutsummaryrefslogtreecommitdiffhomepage
path: root/lib/sisu/v3/manifest.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sisu/v3/manifest.rb')
-rw-r--r--lib/sisu/v3/manifest.rb135
1 files changed, 86 insertions, 49 deletions
diff --git a/lib/sisu/v3/manifest.rb b/lib/sisu/v3/manifest.rb
index 694ba943..0eb580b3 100644
--- a/lib/sisu/v3/manifest.rb
+++ b/lib/sisu/v3/manifest.rb
@@ -72,15 +72,15 @@ module SiSU_Manifest
class Source
def initialize(opt)
@opt=opt
- @particulars=SiSU_Particulars::Combined_singleton.instance.get_all(opt)
- l=SiSU_Env::Standardise_language.new(@opt.lng).language
+ @particulars=SiSU_Particulars::CombinedSingleton.instance.get_all(opt)
+ l=SiSU_Env::StandardiseLanguage.new(@opt.lng).language
@doc_language=l[:n]
end
def read
begin
- @env=SiSU_Env::Info_env.new(@opt.fns)
+ @env=SiSU_Env::InfoEnv.new(@opt.fns)
@md=SiSU_Param::Parameters.new(@opt).get
- SiSU_Env::Info_skin.new(@md).select
+ SiSU_Env::InfoSkin.new(@md).select
xbrowser=@env.program.web_browser
browser=@env.program.console_web_browser
# webserv_url=@env.path.url.output_tell #fix in sysenv
@@ -91,51 +91,68 @@ module SiSU_Manifest
: SiSU_Screen::Ansi.new(@opt.cmd,'Manifest',"[#{@opt.f_pth[:lng_is]}] #{@opt.fns}").green_title_hi
SiSU_Screen::Ansi.new(@opt.cmd,"#{browser} #{url_html}").grey_tab if @opt.cmd =~/v/i
end
- data=SiSU_HTML::Source::Html_environment.new(@particulars).tuned_file_instructions
- Output_Info.new(@md).check_output(data)
- rescue; SiSU_Errors::Info_error.new($!,$@,@opt.cmd,@opt.fns).error
+ data=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions
+ SiSU_Manifest::Source::Output.new(@md).check_output(data)
+ rescue; SiSU_Errors::InfoError.new($!,$@,@opt.cmd,@opt.fns).error
ensure
end
end
private
- class Output_Info <Source
+ class Output <Source
def initialize(md)
@manifest={ txt: [], html: [] }
@md,@fns=md,md.fns
- @env=SiSU_Env::Info_env.new(@md.fns)
+ @env=SiSU_Env::InfoEnv.new(@md.fns)
+ @make=SiSU_Env::ProcessingSettings.new(@md)
@fnb=@md.fnb
@base_url="#{@env.url.root}/#{@fnb}"
- @f=SiSU_Env::SiSU_file.new(@md)
+ @f=SiSU_Env::FileOp.new(@md)
+ @o_str=SiSU_Env::ProcessingSettings.new(md).output_dir_structure
+ @image_path=if @o_str.dump_or_redirect?
+ %{./image}
+ else
+ %{#{@f.path_rel_links.html_scroll_2}_sisu/image_sys}
+ end
@base_path=@f.output_path.manifest.dir
- @@dg ||=SiSU_Env::Info_env.new.digest.type
+ @@dg ||=SiSU_Env::InfoEnv.new.digest.type
@dg=@@dg
- l=SiSU_Env::Standardise_language.new(@md.opt.lng).language
+ l=SiSU_Env::StandardiseLanguage.new(@md.opt.lng).language
@language=l[:n]
@translate=SiSU_Translate::Source.new(@md,@language)
@brace_url=SiSU_Viz::Skin.new.url_decoration
+ @stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet
end
def output
manifest=@f.write_file.manifest
@manifest[:html].each do |x|
- x.gsub!(Xx[:html_relative2],@f.path_rel_links.html_scroll_2)
- x.gsub!(Xx[:html_relative1],@f.path_rel_links.html_scroll_1)
+ x=x.gsub(Xx[:html_relative2],@f.path_rel_links.html_scroll_2).
+ gsub(Xx[:html_relative1],@f.path_rel_links.html_scroll_1)
manifest << x
end
end
+ def url_make(url,file,src=nil)
+ if @o_str.dump_or_redirect?
+ ''
+ elsif :src
+ %{<br />#{@brace_url.xml_open}<a href="#{url}/#{file}">#{url}/#{file}</a>#{@brace_url.xml_close}}
+ else
+ %{<p class="tiny">#{@brace_url.xml_open}<a href="#{url}/#{file}">#{url}/#{file}</a>#{@brace_url.xml_close}</p>}
+ end
+ end
def summarize(id,file,pth='',rel='',url='',img='● ')
size=(File.size("#{pth}/#{file}")/1024.00).to_s
kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1]
@manifest[:txt] << "#{file} #{id} #{kb}\n"
- @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{img}#{id}</a></p></th><td><p class="small"><a href="#{rel}/#{file}">#{file}</a></p><p class="tiny">#{@brace_url.xml_open}<a href="#{url}/#{file}">#{url}/#{file}</a>#{@brace_url.xml_close}</p></td><td class="right"><p class="right">#{kb}</p></td></tr>\n}
+ @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{img}#{id}</a></p></th><td><p class="small"><a href="#{rel}/#{file}">#{file}</a></p>#{url_make(url,file)}</td><td class="right"><p class="right">#{kb}</p></td></tr>\n}
end
def summarize_html_seg(id,file,pth='',rel='',url='',img='● ')
size=(File.size("#{pth}/#{file}")/1024.00).to_s
kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1]
@manifest[:txt] << "#{file} #{id} #{kb}\n"
- @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{img}#{id}</a></p></th><td><p class="small"><a href="#{rel}/#{file}">#{file}</a></p><p class="tiny">#{@brace_url.xml_open}<a href="#{url}/#{file}">#{url}/#{file}</a>#{@brace_url.xml_close}</p></td><td class="right"><p class="right">#{kb}</p></td></tr>\n}
+ @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{img}#{id}</a></p></th><td><p class="small"><a href="#{rel}/#{file}">#{file}</a></p>#{url_make(url,file)}</td><td class="right"><p class="right">#{kb}</p></td></tr>\n}
end
def summarize_sources(id,file,pth,rel,url)
- sys=SiSU_Env::System_call.new
+ sys=SiSU_Env::SystemCall.new
dgst =if @dg =~/^sha(?:2|256)$/; sys.sha256("#{pth}/#{file}")
else sys.md5("#{pth}/#{file}")
end
@@ -143,17 +160,23 @@ module SiSU_Manifest
size=(File.size("#{pth}/#{file}")/1024.00).to_s
kb=/([0-9]+\.[0-9]{0,1})/m.match(size)[1]
@manifest[:txt] << "#{file} #{id} #{kb}\n"
- @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{id}</a></p></th><td class="right"><p class="tiny"><a href="#{rel}/#{file}">#{file}</a> &nbsp;&nbsp;#{dgst[1]}<br />#{@brace_url.xml_open}<a href="#{url}/#{file}">#{url}/#{file}</a>#{@brace_url.xml_close}</p></td><td class="right"><p class="right">#{kb}</p></td></tr>\n} if kb and kb =~/\d+/
+ @manifest[:html] << %{<tr><th class="left"><p class="norm"><a href="#{rel}/#{file}">#{id}</a></p></th><td class="right"><p class="tiny"><a href="#{rel}/#{file}">#{file}</a> &nbsp;&nbsp;#{dgst[1]}#{url_make(url,file,:src)}</p></td><td class="right"><p class="right">#{kb}</p></td></tr>\n} if kb and kb =~/\d+/
end
def published_manifests?
- @f=SiSU_Env::SiSU_file.new(@md) #.base_filename
+ @f=SiSU_Env::FileOp.new(@md) #.base_filename
@m=[]
url=@f.output_path.base.url
manifests={}
mp,mn,mt,mr=nil,nil,nil,nil
ln=SiSU_i18n::Languages.new.language.list
Px[:lng_lst].each do |lc|
- if @env.output_dir_structure.by_language_code?
+ 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 @env.output_dir_structure.by_language_code?
mp="#{@f.output_path.base.dir}/#{lc}/manifest"
mn="#{@md.fnb}.html"
mt="#{mp}/#{mn}"
@@ -180,8 +203,7 @@ module SiSU_Manifest
end
end
manifests
- @m.uniq!
- @m
+ @m=@m.uniq
end
def languages(id,file)
flv=published_manifests?
@@ -201,7 +223,7 @@ module SiSU_Manifest
end
end
def metadata(id,info)
- info.to_s.gsub!(/#{Mx[:br_line]}/,'<br />')
+ info=info.to_s.gsub(/#{Mx[:br_line]}/,'<br />')
@manifest[:html] << %{<tr><th class="left"><p class="bold_left">#{id}:</p></th><td><p class="left">#{info}</p></td></tr>\n}
end
def links(url,lnk,target)
@@ -213,7 +235,7 @@ module SiSU_Manifest
end
def output_tests
if FileTest.file?(@f.place_file.html_segtoc.dir)==true
- img=%{<img border="0" height="18" width="15" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_toc.png" alt="TOC linked" /> }
+ img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_toc.png" alt="TOC linked" /> }
pth=@f.output_path.html_seg.dir
rel=@f.output_path.html_seg.rel_sm
url=@f.output_path.html_seg.url
@@ -221,7 +243,7 @@ module SiSU_Manifest
summarize_html_seg(id,file,pth,rel,url,img)
end
if FileTest.file?(@f.place_file.html_scroll.dir)==true
- img=%{<img border="0" height="15" width="15" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_doc.png" alt="Full Text" /> }
+ img=%{<img border="0" height="15" width="15" src="#{@image_path}/b_doc.png" alt="Full Text" /> }
pth=@f.output_path.html_scroll.dir
rel=@f.output_path.html_scroll.rel_sm
url=@f.output_path.html_scroll.url
@@ -243,7 +265,7 @@ module SiSU_Manifest
summarize(id,file,pth,rel,url)
end
if FileTest.file?(@f.place_file.epub.dir)==true
- img=%{<img border="0" height="18" width="18" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_epub.png" alt="EPUB" /> }
+ img=%{<img border="0" height="18" width="18" src="#{@image_path}/b_epub.png" alt="EPUB" /> }
id,file='EPUB (Electronic Publication, e-book standard)',@f.base_filename.epub
pth=@f.output_path.epub.dir
rel=@f.output_path.epub.rel_sm
@@ -251,7 +273,7 @@ module SiSU_Manifest
summarize(id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_letter}")==true
- img=%{<img border="0" height="18" width="15" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF portrait" /> }
+ img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
@@ -259,7 +281,7 @@ module SiSU_Manifest
summarize(id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_letter}")==true
- img=%{<img border="0" height="15" width="18" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF landscape" /> }
+ img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
@@ -267,7 +289,7 @@ module SiSU_Manifest
summarize(id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_a4}")==true
- img=%{<img border="0" height="18" width="15" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF portrait" /> }
+ img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
@@ -275,7 +297,7 @@ module SiSU_Manifest
summarize(id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_a4}")==true
- img=%{<img border="0" height="15" width="18" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF landscape" /> }
+ img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
@@ -283,7 +305,7 @@ module SiSU_Manifest
summarize(id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_a5}")==true
- img=%{<img border="0" height="18" width="15" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF portrait" /> }
+ img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
@@ -291,7 +313,7 @@ module SiSU_Manifest
summarize(id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_a5}")==true
- img=%{<img border="0" height="15" width="18" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF landscape" /> }
+ img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
@@ -299,7 +321,7 @@ module SiSU_Manifest
summarize(id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_b5}")==true
- img=%{<img border="0" height="18" width="15" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF portrait" /> }
+ img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
@@ -307,7 +329,7 @@ module SiSU_Manifest
summarize(id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_b5}")==true
- img=%{<img border="0" height="15" width="18" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF landscape" /> }
+ img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
@@ -315,7 +337,7 @@ module SiSU_Manifest
summarize(id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_p_legal}")==true
- img=%{<img border="0" height="18" width="15" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF portrait" /> }
+ img=%{<img border="0" height="18" width="15" src="#{@image_path}/b_pdf.png" alt="PDF portrait" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
@@ -323,7 +345,7 @@ module SiSU_Manifest
summarize(id,file,pth,rel,url,img)
end
if FileTest.file?("#{@f.output_path.pdf.dir}/#{@f.base_filename.pdf_l_legal}")==true
- img=%{<img border="0" height="15" width="18" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_pdf.png" alt="PDF landscape" /> }
+ img=%{<img border="0" height="15" width="18" src="#{@image_path}/b_pdf.png" alt="PDF landscape" /> }
pth=@f.output_path.pdf.dir
rel=@f.output_path.pdf.rel_sm
url=@f.output_path.pdf.url
@@ -331,7 +353,7 @@ module SiSU_Manifest
summarize(id,file,pth,rel,url,img)
end
if FileTest.file?(@f.place_file.odt.dir)==true
- img=%{<img border="0" height="18" width="18" src="#{@f.path_rel_links.html_scroll_2}_sisu/image_sys/b_odf.png" alt="ODF/ODT" /> }
+ img=%{<img border="0" height="18" width="18" src="#{@image_path}/b_odf.png" alt="ODF/ODT" /> }
pth=@f.output_path.odt.dir
rel=@f.output_path.odt.rel_sm
url=@f.output_path.odt.url
@@ -374,6 +396,13 @@ module SiSU_Manifest
id,file='Manpage',@f.base_filename.manpage
summarize(id,file,pth,rel,url)
end
+ if FileTest.file?(@f.place_file.sqlite_discreet.dir)==true
+ id,file='SQLite3 file',@f.base_filename.sqlite_discreet
+ pth=@f.output_path.sqlite_discreet.dir
+ rel=@f.output_path.sqlite_discreet.rel_sm
+ url=@f.output_path.sqlite_discreet.url
+ summarize(id,file,pth,rel,url)
+ end
if FileTest.file?(@f.place_file.txt.dir)==true
if @md.opt.cmd =~/a/; id='Plaintext (Unix (UTF-8) with footnotes)'
elsif @md.opt.cmd =~/e/; id='Plaintext (Unix (UTF-8) with endnotes)'
@@ -417,8 +446,11 @@ module SiSU_Manifest
end
def qrc_image
fn=@md.fnb
- img_md="qrcode/#{fn}.md.png"
- img_title="qrcode/#{fn}.title.png"
+ pth=(@o_str.dump_or_redirect?) \
+ ? '.'
+ : 'qrcode'
+ img_md="#{pth}/#{fn}.md.png"
+ img_title="#{pth}/#{fn}.title.png"
if FileTest.file?(@f.place_file.qrcode_md.dir)==true
@manifest[:html] <<<<WOK
<tr><td class="left">
@@ -731,16 +763,20 @@ WOK
end
def check_output(data)
begin
- minitoc=SiSU_HTML_minitoc::Toc_mini.new(@md,data).songsheet.join("\n")
+ minitoc=SiSU_HTML_MiniToc::TocMini.new(@md,data).songsheet.join("\n")
id,file='',''
- vz=SiSU_Env::Get_init.instance.skin
+ vz=SiSU_Env::GetInit.instance.skin
+ search_form=if @make.build.search_form?
+ "<td>#{@env.widget_static.search_form}</td>"
+ else ''
+ end
banner_table=if vz.banner_home_button_only !~ /http:\/\/www\.jus\.uio\.no\/sisu/ \
and vz.banner_home_button_only !~ /sisu\.home\.png/
<<WOK
<table summary="band" border="0" cellpadding="3" cellspacing="0">
<tr><td align="left" width="15%" bgcolor="#ffffff">#{vz.banner_band}</td>
<td width="70%"><p class="tiny">#{@brace_url.xml_open}<a href="#{@base_url}/#{file}">#{@base_url}/#{file}</a>#{@brace_url.xml_close}</p></td>
-<td>#{@env.widget_static.search_form}</td></tr>
+#{search_form}</tr>
</table>
WOK
else
@@ -748,7 +784,7 @@ WOK
<table summary="band" border="0" cellpadding="3" cellspacing="0">
<tr><td align="left" bgcolor="#ffffff"><a href="http://www.jus.uio.no/sisu/" target="_top"><img border="0" src="#{vz.url_path_image_sys}/sisu.png" alt="SiSU --&gt;" /></a></td>
<td><p class="tiny">#{@brace_url.xml_open}<a href="#{@base_url}/#{file}">#{@base_url}/#{file}</a>#{@brace_url.xml_close}</p></td>
-<td>#{@env.widget_static.search_form}</td></tr>
+#{search_form}</tr>
</table>
WOK
end
@@ -764,16 +800,17 @@ SiSU manifest: #{@md.title.full}
<meta name="sourcefile" content="#{@md.fns}" />
<link rel="generator" href="http://www.jus.uio.no/sisu" />
<link rel="shortcut icon" href="#{@f.path_rel_links.html_scroll_css}_sisu/image_sys/rb7.ico" />
-<link rel="stylesheet" href="#{@f.path_rel_links.html_scroll_css}_sisu/css/html.css" type="text/css" />
+#{@stylesheet.css_head}
</head>
<body bgcolor="#ffffff" text="#000000" link="#003090" lang="en" xml:lang="en">
#{banner_table}
WOK
- if @env.manifest_minitoc?
- if @env.output_dir_structure.by_language_code? \
+ if @make.build.manifest_minitoc?
+ if @o_str.dump_or_redirect?
+ elsif @env.output_dir_structure.by_language_code? \
or @env.output_dir_structure.by_filetype?
- minitoc.gsub!(/<a href="(\S+?)"/m,%{<a href="../html/#{@md.fnb}/\\1"})
- minitoc.gsub!(/<a href="\.\.\/html\/#{@md.fnb}\/(?:sisu_manifest\.html|#{@f.base_filename.manifest})"/m,
+ minitoc=minitoc.gsub(/<a href="(\S+?)"/m,%{<a href="../html/#{@md.fnb}/\\1"}).
+ gsub(/<a href="\.\.\/html\/#{@md.fnb}\/(?:sisu_manifest\.html|#{@f.base_filename.manifest})"/m,
%{<a href="#{@f.base_filename.manifest}"})
end
@manifest[:html] <<<<WOK
@@ -853,7 +890,7 @@ WOK
</html>
WOK
output
- rescue; SiSU_Errors::Info_error.new($!,$@,@md.opt.cmd,@md.fns).error
+ rescue; SiSU_Errors::InfoError.new($!,$@,@md.opt.cmd,@md.fns).error
ensure
end
end