From d2fa6daa3f2ecbafd2dda8d6da895ef69575e3b3 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Thu, 14 Feb 2013 18:39:16 -0500 Subject: v4 (v3): cosmetic, minor code shuffle, & remove trailing white-spaces --- lib/sisu/v3/epub_format.rb | 6 +++--- lib/sisu/v4/constants.rb | 1 + lib/sisu/v4/epub_format.rb | 3 +-- lib/sisu/v4/html.rb | 12 ++++++------ lib/sisu/v4/html_format.rb | 8 +++----- lib/sisu/v4/hub.rb | 2 +- lib/sisu/v4/manifest.rb | 14 +++++++------- lib/sisu/v4/urls.rb | 4 ++-- 8 files changed, 24 insertions(+), 26 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/epub_format.rb b/lib/sisu/v3/epub_format.rb index 61accf22..228c2df4 100644 --- a/lib/sisu/v3/epub_format.rb +++ b/lib/sisu/v3/epub_format.rb @@ -1402,7 +1402,7 @@ output_epub_cont_seg.close end def navpoint(dob,no,name=nil) name=name ? name : dob.name - cont_name=(name =~/#{Sfx[:epub_xhtml]}/) ? name : (name + Sfx[:epub_xhtml]) + cont_name=(name =~/#{Sfx[:epub_xhtml]}/) ? name : (name + Sfx[:epub_xhtml]) id_u=DISABLE[:epub][:ncx_navpoint_unique_id] \ ? '' : "-#{no}" @@ -1597,7 +1597,7 @@ output_epub_cont_seg.close end def manifest_content(dob,name=nil) name=name ? name : dob.name - href_name=(name =~/#{Sfx[:epub_xhtml]}/) ? name : (name + Sfx[:epub_xhtml]) + href_name=(name =~/#{Sfx[:epub_xhtml]}/) ? name : (name + Sfx[:epub_xhtml]) <<-WOK WOK @@ -1654,7 +1654,7 @@ output_epub_cont_seg.close end def guide(dob,name=nil) name=name ? name : dob.name - guide_name=(name =~/#{Sfx[:epub_xhtml]}/) ? name : (name + Sfx[:epub_xhtml]) + guide_name=(name =~/#{Sfx[:epub_xhtml]}/) ? name : (name + Sfx[:epub_xhtml]) <<-WOK WOK diff --git a/lib/sisu/v4/constants.rb b/lib/sisu/v4/constants.rb index 7ad3516b..505fdc02 100644 --- a/lib/sisu/v4/constants.rb +++ b/lib/sisu/v4/constants.rb @@ -295,6 +295,7 @@ DEVELOPER={ __END__ puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:red).set puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:green) +puts SiSU_Utils::CodeMarker.new(__LINE__,__FILE__).set(:fuchsia) puts ANSI_C[:red] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__ puts "#{ANSI_C[:red]} #{__LINE__.to_s} #{ANSI_C[:off]} #{__FILE__}" puts ANSI_C[:fuchsia] + __LINE__.to_s + ANSI_C[:off] + ' ' + __FILE__.gsub(/([^\/]+$)/,"#{ANSI_C[:fuchsia]}\\1#{ANSI_C[:off]}") diff --git a/lib/sisu/v4/epub_format.rb b/lib/sisu/v4/epub_format.rb index 48408162..a56ea394 100644 --- a/lib/sisu/v4/epub_format.rb +++ b/lib/sisu/v4/epub_format.rb @@ -65,7 +65,6 @@ module SiSU_EPUB_Format def initialize(md,ocn) @md,@ocn=md,ocn.to_s @ocn ||='' - vz=SiSU_Viz::Defaults.new end def ocn_display make=SiSU_Env::ProcessingSettings.new(@md) @@ -1687,7 +1686,7 @@ output_epub_cont_seg.close fn=fn_base + Sfx[:epub_xhtml] name=hashtag ? fn + hashtag : fn name=name ? name : dob.name - guide_name=(name =~/#{Sfx[:epub_xhtml]}/) ? name : (name + Sfx[:epub_xhtml]) + guide_name=(name =~/#{Sfx[:epub_xhtml]}/) ? name : (name + Sfx[:epub_xhtml]) <<-WOK WOK diff --git a/lib/sisu/v4/html.rb b/lib/sisu/v4/html.rb index 94b20afe..9b73823b 100644 --- a/lib/sisu/v4/html.rb +++ b/lib/sisu/v4/html.rb @@ -108,18 +108,18 @@ module SiSU_HTML data=nil tuned_file_array=SiSU_HTML::Source::HTML_Environment.new(@particulars).tuned_file_instructions data=tuned_file_array - if @opt.act[:html_scroll][:set]==:on + if @opt.act[:html_scroll][:set]==:on scr_endnotes=SiSU_HTML::Source::Endnotes.new(data,@md).scroll end toc=SiSU_HTML::Source::Toc.new(@md,data).songsheet links_guide=SiSU_HTML::Source::LinksGuide.new(data,@md).toc data=tuned_file_array scr_toc=SiSU_HTML::Source::ScrollHeadAndSegToc.new(@md,toc,links_guide).in_common #watch - if @opt.act[:html_seg][:set]==:on + if @opt.act[:html_seg][:set]==:on SiSU_HTML::Source::Seg.new(@md,data).songsheet end data=tuned_file_array - if @opt.act[:html_scroll][:set]==:on + if @opt.act[:html_scroll][:set]==:on scr=SiSU_HTML::Source::Scroll.new(@md,data,scr_endnotes).songsheet scroll=SiSU_HTML::Source::ScrollOutput.new(scr_toc,scr[:body],scr[:metadata],scr[:owner_details],scr[:tails],@md).publish SiSU_HTML::Source::Output.new(scroll,@md).scroll @@ -602,7 +602,7 @@ WOK ads=SiSU_HTML_Promo::Ad.new(@md) @segtoc << format_head_toc.seg_navigation_tail << ads.div.close << ads.display << format_head_toc.html_close @segtoc=@segtoc.flatten.compact #watch - if @md.opt.act[:html_seg][:set]==:on + if @md.opt.act[:html_seg][:set]==:on SiSU_HTML::Source::Output.new(@segtoc,@md).segtoc end @segtoc=[] @@ -633,7 +633,7 @@ WOK @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure end def scroll - if @md.opt.act[:html_scroll][:set]==:on + if @md.opt.act[:html_scroll][:set]==:on begin @filename_html_scroll=@file.write_file.html_scroll @data.each do |para| @@ -657,7 +657,7 @@ WOK end end def segtoc - if @md.opt.act[:html_seg][:set]==:on + if @md.opt.act[:html_seg][:set]==:on begin @filename_html_segtoc=@file.write_file.html_segtoc @data.each do |para| diff --git a/lib/sisu/v4/html_format.rb b/lib/sisu/v4/html_format.rb index 7fcf89a0..25a8dbee 100644 --- a/lib/sisu/v4/html_format.rb +++ b/lib/sisu/v4/html_format.rb @@ -67,8 +67,8 @@ module SiSU_HTML_Format @ocn ||='' end def ocn_display - @make=SiSU_Env::ProcessingSettings.new(@md) - if @make.build.ocn? + make=SiSU_Env::ProcessingSettings.new(@md) + if make.build.ocn? ocn_class='ocn' if @ocn.to_i==0 @ocn.gsub(/^(\d+|)$/, @@ -104,11 +104,10 @@ module SiSU_HTML_Format @vz=SiSU_Viz::Defaults.new @seg_name_html=(SiSU_HTML::Source::Seg.new.seg_name_html || []) @seg_name_html_tracker=(SiSU_HTML::Source::Seg.new.seg_name_html_tracker || []) - @metalink='#metadata' @tocband_scroll,@tocband_segtoc=nil,nil @stylesheet=SiSU_Style::CSS_HeadInfo.new(md).stylesheet @o_str ||=SiSU_Env::ProcessingSettings.new(md).output_dir_structure - @index='index' + @index,@metalink='index','#metadata' @toc="#{@md.file.output_path.html_seg.dir}/#{@md.file.base_filename.html_segtoc}" end def url_path_image_sys @@ -1235,7 +1234,6 @@ WOK def clean(txt) txt=txt.gsub(/#{Mx[:en_a_o]}.+?#{Mx[:en_a_c]}/,''). gsub(/#{Mx[:en_b_o]}.+?#{Mx[:en_b_c]}/,'') - txt end def subtoc_lev(tag,attrib) @txt=clean(@txt) diff --git a/lib/sisu/v4/hub.rb b/lib/sisu/v4/hub.rb index d55a5f17..e02fa940 100644 --- a/lib/sisu/v4/hub.rb +++ b/lib/sisu/v4/hub.rb @@ -673,7 +673,7 @@ p "#{__LINE__}:#{__FILE__}" if @opt.act[:maintenance][:set] ==:on or @opt.act[:scp][:set]==:on \ or @opt.act[:webrick][:set]==:on \ or @opt.act[:zap][:set]==:on \ - or ( + or ( @opt.cmd =~/^-/ \ and @opt.cmd =~/([abCcDdeFGgHhIjikLMmNnoPpQqRrSsTtUuVvWwXxYyZ_0-9])/ \ and @opt.mod.inspect !~/--(?:sitemaps|query|identify)/ \ diff --git a/lib/sisu/v4/manifest.rb b/lib/sisu/v4/manifest.rb index c5a841a1..d7c4d33a 100644 --- a/lib/sisu/v4/manifest.rb +++ b/lib/sisu/v4/manifest.rb @@ -511,14 +511,14 @@ WOK end end def metadata_tests - if defined? @md.title #% + if defined? @md.title #% if defined? @md.title.full \ and @md.title.full=~/\S+/ id,info=@translate.full_title,@md.title.full metadata(id,info) end end - if defined? @md.creator #% + if defined? @md.creator #% if defined? @md.creator.author \ and @md.creator.author=~/\S+/ id,info=@translate.author,@md.creator.author @@ -562,7 +562,7 @@ WOK metadata(id,info) end end - if defined? @md.date #% + if defined? @md.date #% if defined? @md.date.published \ and @md.date.published=~/\S+/ #dc id,info=@translate.date,@md.date.published @@ -599,7 +599,7 @@ WOK id,info=@translate.publisher,@md.publisher metadata(id,info) end - if defined? @md.notes #% + if defined? @md.notes #% if defined? @md.notes.description \ and @md.notes.description=~/\S+/ id,info=@translate.description,@md.notes.description @@ -626,7 +626,7 @@ WOK metadata(id,info) end end - if defined? @md.title #% + if defined? @md.title #% if defined? @md.title.language \ and @md.title.language=~/\S+/ id,info=@translate.language,@md.title.language @@ -638,7 +638,7 @@ WOK metadata(id,info) end end - if defined? @md.classify #% + if defined? @md.classify #% if defined? @md.topic_register_array \ and @md.topic_register_array.length > 0 @manifest[:html] << %{

#{@translate.topic_register}:

\n} @@ -701,7 +701,7 @@ WOK metadata(id,info) end end - if defined? @md.identifier #% + if defined? @md.identifier #% if defined? @md.identifier.oclc \ and @md.identifier.oclc=~/\S+/ id,info=@translate.cls_oclc,@md.identifier.oclc diff --git a/lib/sisu/v4/urls.rb b/lib/sisu/v4/urls.rb index ad7ab480..e5341581 100644 --- a/lib/sisu/v4/urls.rb +++ b/lib/sisu/v4/urls.rb @@ -324,11 +324,11 @@ module SiSU_Urls or @opt.act[:html_scroll][:set]==:on \ or @opt.act[:html_seg][:set]==:on) if x =~/scroll/ - if @opt.act[:html_scroll][:set]==:on + if @opt.act[:html_scroll][:set]==:on show.html.scroll(x) end else - if @opt.act[:html_seg][:set]==:on + if @opt.act[:html_seg][:set]==:on show.html.toc(x) end end -- cgit v1.2.3 From 9b67ec9247d8322ede2bb47405862fd0ce6de375 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 20 Feb 2013 19:18:56 -0500 Subject: v4 (v3): epub, tinkering with headers & cleaning of angle brackets '<' & '>' --- lib/sisu/v3/epub_tune.rb | 8 +++++--- lib/sisu/v4/epub_format.rb | 22 ++++++++++++---------- lib/sisu/v4/epub_tune.rb | 9 ++++++--- 3 files changed, 23 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/epub_tune.rb b/lib/sisu/v3/epub_tune.rb index a6b23a0d..664f143e 100644 --- a/lib/sisu/v3/epub_tune.rb +++ b/lib/sisu/v3/epub_tune.rb @@ -123,7 +123,7 @@ module SiSU_EPUB_Tune begin @cX=SiSU_Screen::Ansi.new(@md.opt.cmd).cX SiSU_Screen::Ansi.new(@md.opt.cmd,'Tune').txt_grey if @md.opt.cmd =~/[MVv]/ - data=SiSU_EPUB_Tune::Tune.new(@data,@md).amp_html + data=SiSU_EPUB_Tune::Tune.new(@data,@md).amp_angle_brackets data=SiSU_EPUB_Tune::Tune.new(data,@md).endnotes_html data=SiSU_EPUB_Tune::Tune.new(data,@md).url_markup data=SiSU_EPUB_Tune::Tune.new(data,@md).markup @@ -274,10 +274,12 @@ module SiSU_EPUB_Tune @tuned_file << dob end end - def amp_html + def amp_angle_brackets data,data_new=@data,[] data.each do |dob| - dob.obj=dob.obj.gsub(/&/u,'&') + dob.obj=dob.obj. + gsub(/&/u,'&'). + gsub(//u,'>') data_new << dob end data_new diff --git a/lib/sisu/v4/epub_format.rb b/lib/sisu/v4/epub_format.rb index a56ea394..98f4d7e4 100644 --- a/lib/sisu/v4/epub_format.rb +++ b/lib/sisu/v4/epub_format.rb @@ -71,23 +71,21 @@ module SiSU_EPUB_Format if make.build.ocn? ocn_class='ocn' if @ocn.to_i==0 - @ocn.gsub(/^(\d+|)$/, - %{}) + @ocn.gsub(/^(\d+|)$/,'') else @ocn.gsub(/^(\d+|)$/, %{}) end else ocn_class='ocn_off' - @ocn.gsub(/^(\d+|)$/, - %{}) + @ocn.gsub(/^(\d+|)$/,'') end end def name %{} end def id #w3c? "tidy" complains about numbers as identifiers ! annoying - %{id="o#{@ocn}"} + (@ocn.empty?) ? '' : %{id="o#{@ocn}"} end def goto %{} @@ -1225,7 +1223,8 @@ module SiSU_EPUB_Format if x.is_a?(String) x=x.gsub(/ /,' ') if Ep[:alt]==:on x.gsub(/&/,'&'). - gsub(//,'>'). + gsub(//,">"). + gsub(/#{Dx[:url_o]}/,Dx[:url_o_xml]).gsub(/#{Dx[:url_c]}/,Dx[:url_o_xml]). #gsub(//,'>'). gsub(/\\\\/,'
'). gsub(/<br(?: \/)?>/,'
') @@ -1243,9 +1242,8 @@ module SiSU_EPUB_Format @css=SiSU_Env::CSS_Stylesheet.new(md) @seg_name_xhtml=(SiSU_EPUB::Source::Seg.new.seg_name_xhtml || []) @seg_name_xhtml_tracker=(SiSU_EPUB::Source::Seg.new.seg_name_xhtml_tracker || []) - @index='index' - @metalink='#metadata' @tocband_scroll,@tocband_segtoc=nil,nil + @index,@metalink='index','#metadata' end def doc_type_xhtml <<-WOK @@ -1572,17 +1570,21 @@ output_epub_cont_seg.close rights=if defined? @md.rights.all \ and @md.rights.all =~/\S+/ rights=SanitizeXML.xml(@md.rights.all) + rights=rights.gsub(//,' ') %{\n #{rights}} else '' end f=SiSU_Env::FileOp.new(@md) <<-WOK - <#{$ep[:o]}metadata xmlns:dc="http://purl.org/dc/elements/1.1/" + <#{$ep[:o]}metadata + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:opf="http://www.idpf.org/2007/opf" + xmlns:dcterms="http://purl.org/dc/terms/" + xmlns:dc="http://purl.org/dc/elements/1.1/" unique-identifier="urn:uuid:#{@md.dgst[1]}" version="2.0"> #{@md.title.full} #{cover_image}#{author}#{editor}#{translator}#{illustrator}#{language}#{date_published}#{subject}#{rights} - #{f.output_path.epub.url}/#{f.base_filename.epub} + #{f.output_path.epub.url.gsub(/http:\/\//,'')}/#{f.base_filename.epub} urn:uuid:#{@md.dgst[1]} diff --git a/lib/sisu/v4/epub_tune.rb b/lib/sisu/v4/epub_tune.rb index bce4aed7..fbb42bc4 100644 --- a/lib/sisu/v4/epub_tune.rb +++ b/lib/sisu/v4/epub_tune.rb @@ -123,7 +123,7 @@ module SiSU_EPUB_Tune begin @cX=SiSU_Screen::Ansi.new(@md.opt.cmd).cX SiSU_Screen::Ansi.new(@md.opt.cmd,'Tune').txt_grey if @md.opt.cmd =~/[MVv]/ - data=SiSU_EPUB_Tune::Tune.new(@data,@md).amp_html + data=SiSU_EPUB_Tune::Tune.new(@data,@md).amp_angle_brackets data=SiSU_EPUB_Tune::Tune.new(data,@md).endnotes_html data=SiSU_EPUB_Tune::Tune.new(data,@md).url_markup data=SiSU_EPUB_Tune::Tune.new(data,@md).markup @@ -156,6 +156,7 @@ module SiSU_EPUB_Tune gsub(/#{Mx[:fa_monospace_o]}(.+?)#{Mx[:fa_monospace_c]}/,'\1'). # tt, kbd gsub(/#{Mx[:mk_o]}:name#(\S+?)#{Mx[:mk_c]}/,''). gsub(/#{Mx[:gl_bullet]}/m,"●#{$ep[:hsp]*2}"). + gsub(/#{Dx[:url_o]}/,Dx[:url_o_xml]).gsub(/#{Dx[:url_c]}/,Dx[:url_o_xml]). gsub(/#{Mx[:nbsp]}/,$ep[:hsp]). gsub(/<(p|br)>/,'<\1 />') dob.obj=SiSU_EPUB_Tune::CleanXHTML.new(dob.obj).clean @@ -274,10 +275,12 @@ module SiSU_EPUB_Tune @tuned_file << dob end end - def amp_html + def amp_angle_brackets data,data_new=@data,[] data.each do |dob| - dob.obj=dob.obj.gsub(/&/u,'&') + dob.obj=dob.obj. + gsub(/&/u,'&'). + gsub(//u,'>') data_new << dob end data_new -- cgit v1.2.3 From 32a0e39ad09dab218a5bc225e165ad92611b2c38 Mon Sep 17 00:00:00 2001 From: Ralph Amissah Date: Wed, 20 Feb 2013 22:01:42 -0500 Subject: v4 (v3): html, modification to markup of angle brackets [<>] & ampersand [&] --- lib/sisu/v3/html_tune.rb | 9 ++++++--- lib/sisu/v4/html_tune.rb | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/sisu/v3/html_tune.rb b/lib/sisu/v3/html_tune.rb index 32426076..23fa586e 100644 --- a/lib/sisu/v3/html_tune.rb +++ b/lib/sisu/v3/html_tune.rb @@ -144,7 +144,7 @@ module SiSU_HTML_Tune data_tuned=[] #@tuned_file=[] data.each do |dob| - dob=angle_brackets(dob) + dob=amp_angle_brackets(dob) dob=endnotes_html(dob) dob=url_markup(dob) dob=markup(dob) @@ -241,8 +241,11 @@ module SiSU_HTML_Tune end dob end - def angle_brackets(dob) - dob.obj=dob.obj.gsub(/<([a-z:\/]+)>/,"#{Dx[:lt_xml]}\\1#{Dx[:gt_xml]}") + def amp_angle_brackets(dob) + dob.obj=dob.obj. + gsub(/&/u,'&'). + gsub(/<([a-z:\/]+)>/,"#{Dx[:lt_xml]}\\1#{Dx[:gt_xml]}"). + gsub(//u,'>') dob end def endnotes_html(dob) diff --git a/lib/sisu/v4/html_tune.rb b/lib/sisu/v4/html_tune.rb index 2661ee52..41845007 100644 --- a/lib/sisu/v4/html_tune.rb +++ b/lib/sisu/v4/html_tune.rb @@ -144,7 +144,7 @@ module SiSU_HTML_Tune data_tuned=[] #@tuned_file=[] data.each do |dob| - dob=angle_brackets(dob) + dob=amp_angle_brackets(dob) dob=endnotes_html(dob) dob=url_markup(dob) dob=markup(dob) @@ -241,8 +241,11 @@ module SiSU_HTML_Tune end dob end - def angle_brackets(dob) - dob.obj=dob.obj.gsub(/<([a-z:\/]+)>/,"#{Dx[:lt_xml]}\\1#{Dx[:gt_xml]}") + def amp_angle_brackets(dob) + dob.obj=dob.obj. + gsub(/&/u,'&'). + gsub(/<([a-z:\/]+)>/,"#{Dx[:lt_xml]}\\1#{Dx[:gt_xml]}"). + gsub(//u,'>') dob end def endnotes_html(dob) -- cgit v1.2.3