From cc1c6832b79f011cc9ed1f357e963758ac4149b9 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Tue, 5 Apr 2011 22:40:23 -0400 Subject: v3: urls, reuse/share code, fix -U * share code between show selected urls and show all urls * fix -U which has not been properly updated for v3 --- data/doc/sisu/CHANGELOG_v3 | 2 + lib/sisu/v3/urls.rb | 189 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 144 insertions(+), 47 deletions(-) diff --git a/data/doc/sisu/CHANGELOG_v3 b/data/doc/sisu/CHANGELOG_v3 index 8ead5b8d..86ee14bb 100644 --- a/data/doc/sisu/CHANGELOG_v3 +++ b/data/doc/sisu/CHANGELOG_v3 @@ -20,6 +20,8 @@ http://www.jus.uio.no/sisu/pkg/src/sisu_3.0.7.orig.tar.gz sisu_3.0.7-1.dsc sisu_3.0.7-1.debian.tar.gz + * urls, share/reuse code, fix show all urls -U + %% 3.0.6.orig.tar.gz (2011-03-30:13/3) http://git.sisudoc.org/?p=code/sisu.git;a=log;h=refs/tags/debian/3.0.6-1 http://www.jus.uio.no/sisu/pkg/src/sisu_3.0.6.orig.tar.gz diff --git a/lib/sisu/v3/urls.rb b/lib/sisu/v3/urls.rb index 900d9849..08bf0dae 100644 --- a/lib/sisu/v3/urls.rb +++ b/lib/sisu/v3/urls.rb @@ -129,6 +129,100 @@ module SiSU_urls ensure end end + def show + def source + def src(x,y) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@md.file.output_path.src}/#{y}").result + end + def pod(x,y) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} #{@env.url.output_tell}/pod/#{y}").result + end + self + end + def generic(x,y) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} #{@env.url.output_tell}/#{@fnb}/#{y}").result + end + def meta(x,y) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} ~#{y}/#{@fnb}.#{y}").result + end + def text(x) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.txt}/#{@md.file.base_filename.txt}").result + end + def epub(x) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.epub_viewer} #{@md.file.output_path.epub}/#{@md.file.base_filename.epub}").result + end + def html + def scroll(x) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.html_scroll}/#{@md.file.base_filename.html_scroll}").result + end + def toc(x) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.html_seg}/#{@md.file.base_filename.html_segtoc}").result + end + def concordance(x) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.html_concordance}/#{@md.file.base_filename.html_concordance}").result + end + def manifest(x) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.manifest}/#{@md.file.base_filename.manifest}").result + end + self + end + def odt(x) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.odf_viewer} file://#{@md.file.output_path.odt}/#{@md.file.base_filename.odt}").result + end + def pdf + def portrait(x) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf}/#{@md.file.base_filename.pdf_p}pdf").result + end + def landscape(x) + SiSU_Screen::Ansi.new(@opt.cmd,"-p (LaTeX)","#{@prog.text_editor} ~work/tex_rz/#{@fnb}.tex").result #if y=~/landscape/ + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf}/#{@md.file.base_filename.pdf_l}pdf").result + end + self + end + def manpage(x) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.manpage_viewer} #{@md.file.output_path.manpage}/#{@md.file.base_filename.manpage}").result + end + def pinfo(x,y) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","cd #{@env.processing_path.texinfo}; pinfo ./#{@fnb}.#{y}; cd -").result + end + def po4a + def po(x,y) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@md.file.output_path.po}/#{y}").result + end + def pot(x,y) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@md.file.output_path.pot}/#{y}").result + end + self + end + def xhtml(x) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xhtml}/#{@md.file.base_filename.xhtml}").result + end + def xml + def sax(x) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xml_sax}/#{@md.file.base_filename.xml_sax}").result + end + def dom(x) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xml_dom}/#{@md.file.base_filename.xml_dom}").result + end + def sitemap(x) #BROKEN + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.sitemap}/#{@md.file.base_filename.sitemap}").result + end + self + end + def hash_digest(x) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.hash_digest}/#{@md.file.base_filename.hash_digest}").result + end + def db + def psql(x,y) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x} DBI psql","#{@pwd_stub}::#{@opt.fns}",y).result + end + def sqlite(x,y) + SiSU_Screen::Ansi.new(@opt.cmd,"-#{x} DBI sqlite","sqlite3 #{@env.path.output}/sisu_sqlite.db", "#{y}").result + end + self + end + self + end def urls_maintenance(opt,x,y) if x=~/^([abcehHmNoptwxXy])/ \ and opt.cmd =~/[abcehHmNoptwxXy]/ \ @@ -194,106 +288,95 @@ module SiSU_urls if @opt.cmd =~/[MVv]/ if (x=~/^a/ and @opt.cmd =~/a/) \ or (x=~/^t/ and @opt.cmd =~/t/) - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.txt}/#{@md.file.base_filename.txt}").result + show.text(x) end if x=~/^b/ \ and @opt.cmd =~/b/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xhtml}/#{@md.file.base_filename.xhtml}").result + show.xhtml(x) end -# if x=~/^[c]/ \ -# and @opt.cmd =~/[c]/ -# SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.manifest}/#{@md.file.base_filename.manifest}").result -# end if x=~/^D/ \ and @opt.cmd =~/D/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x} DBI psql","#{@pwd_stub}::#{@opt.fns}",y).result + show.db.psql(x,y) end if x=~/^d/ \ and @opt.cmd =~/d/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x} DBI sqlite","sqlite3 #{@env.path.output}/sisu_sqlite.db", "#{y}").result + show.db.sqlite(x,y) end if x=~/^e/ \ and @opt.cmd =~/e/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.epub_viewer} #{@md.file.output_path.epub}/#{@md.file.base_filename.epub}").result + show.epub(x) end if x=~/^h/ \ and @opt.cmd =~/h/ if x =~/scroll/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.html_scroll}/#{@md.file.base_filename.html_scroll}").result + show.html.scroll(x) else - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.html_seg}/#{@md.file.base_filename.html_segtoc}").result + show.html.toc(x) end end if x=~/^I/ \ and @opt.cmd =~/I/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","cd #{@env.processing_path.texinfo}; pinfo ./#{@fnb}.#{y}; cd -").result + show.pinfo(x,y) end if x=~/^i/ \ and @opt.cmd =~/i/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.manpage_viewer} #{@md.file.output_path.manpage}/#{@md.file.base_filename.manpage}").result + show.manpage(x) end if x=~/^N/ \ and @opt.cmd =~/N/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.hash_digest}/#{@md.file.base_filename.hash_digest}").result + show.hash_digest(x) end if x=~/^o/ \ and @opt.cmd =~/o/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.odf_viewer} file://#{@md.file.output_path.odt}/#{@md.file.base_filename.odt}").result + show.odt(x) end if x=~/^P/ \ and @opt.cmd =~/P/ if @opt.fns =~/\S+?~\S{2}(?:_\S{2})?\.ss[mt]/ f=y.gsub(/\.pot$/,'.po') - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@md.file.output_path.po}/#{f}").result + show.po4a.po(x,f) else - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@md.file.output_path.pot}/#{y}").result + show.po4a.pot(x,f) end - #@opt.cmd.gsub!(/P/,'') end if x=~/^p/ \ and @opt.cmd =~/p/ if x =~/portrait/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf}/#{@md.file.base_filename.pdf_p}pdf").result + show.pdf.portrait(x) else - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.pdf_viewer} #{@md.file.output_path.pdf}/#{@md.file.base_filename.pdf_l}pdf").result + show.pdf.landscape(x) end end - #if x=~/^P/ \ - #and @opt.cmd =~/P/ - # SiSU_Screen::Ansi.new(@opt.cmd,"-#{x} Profile","#{@pwd_stub}::#{@opt.fns}",y).result - # @opt.cmd.gsub!(/P/,'') - #end if x=~/^S/ \ and @opt.cmd =~/S/ zipfile=if @opt.fns =~/\.ssm\.sst$/; y.gsub(/(?:\~\S{2,3})?(\.ssm\.sst\.zip)$/,'.ssm.zip') else y.gsub(/(?:\~\S{2,3})?(\.sst\.zip)$/,'\1') end - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} #{@env.url.output_tell}/pod/#{y}").result + show.source.pod(x,y) end if x=~/^s/ \ and @opt.cmd =~/s/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} #{@md.file.output_path.src}/#{y}").result + show.source.src(x,y) end if x=~/^w/ \ and @opt.cmd =~/w/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.html_concordance}/#{@md.file.base_filename.html_concordance}").result + show.html.concordance(x) end if x=~/^X/ \ and @opt.cmd =~/X/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xml_dom}/#{@md.file.base_filename.xml_dom}").result + show.xml.dom(x) end if x=~/^x/ \ and @opt.cmd =~/x/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.xml_sax}/#{@md.file.base_filename.xml_sax}").result + show.xml.sax(x) end if x=~/^Y/ \ and @opt.cmd =~/Y/ #BROKEN - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.sitemap}/#{@md.file.base_filename.sitemap}").result + show.xml.sitemap(x) end - if x=~/^y/ \ and @opt.cmd =~/y/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.manifest}/#{@md.file.base_filename.manifest}").result + show.html.manifest(x) end end urls_maintenance(@opt,x,y) if @opt.cmd =~/[MV]/ @@ -307,26 +390,38 @@ module SiSU_urls @u.each do |x,y| tell=case x when /^m/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.text_editor} ~#{y}/#{@fnb}.#{y}") - when /^[bBcdhNopswxXy]/ - tellx=SiSU_Screen::Ansi.new(@opt.cmd,"-p (LaTeX)","#{@prog.text_editor} ~work/tex_rz/#{@fnb}.tex") if y=~/landscape/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} #{@env.url.output_tell}/#{@fnb}/#{y}") + show.meta(x,y) + when /^[BcdNsxXy]/ + show.generic(x,y) when /^[at]/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} file://#{@md.file.output_path.txt}/#{@md.file.base_filename.txt}") #.result + show.text(x) + when /^b/ + show.xhtml(x) when /^e/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.epub_viewer} #{@env.path.output}/epub/#{y}") + show.epub(x) + when /^h/ + if x =~/scroll/ + show.html.scroll(x) + else + show.html.toc(x) + end + when /^o/ + show.odt(x) + when /^p/ + if x =~/portrait/ + show.pdf.portrait(x) + else + show.pdf.landscape(x) + end + when /^w/ + show.html.concordance(x) when /^Y/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.web_browser} #{@env.url.output_tell}/sitemap/#{y}") + show.xml.sitemap(x) when /^I/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","cd #{@env.processing_path.texinfo}; pinfo ./#{@fnb}.#{y}; cd -") + show.pinfo(x,y) when /^i/ - SiSU_Screen::Ansi.new(@opt.cmd,"-#{x}","#{@prog.manpage_viewer} #{@env.processing_path.manpage}/#{@fnb}.1") - end - unless @opt.cmd =~/q/ - tellx.result if tellx - tell.result if tell + show.manpage(x) end - tellx=nil end end end -- cgit v1.2.3