diff options
author | Ralph Amissah <ralph@amissah.com> | 2010-10-09 23:11:53 -0400 |
---|---|---|
committer | Ralph Amissah <ralph@amissah.com> | 2010-10-09 23:11:53 -0400 |
commit | 74c8847f7a177e934837e8bd2560336fe6712acb (patch) | |
tree | 44a6e904d65569b4628678521edef76a76859822 /lib | |
parent | debian/changelog 2.7.4-1 (diff) | |
parent | version date (diff) |
Merge branch 'upstream' into debian/sid
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sisu/v2/odf.rb | 6 | ||||
-rw-r--r-- | lib/sisu/v2/param.rb | 44 | ||||
-rw-r--r-- | lib/sisu/v2/shared_metadata.rb | 14 |
3 files changed, 48 insertions, 16 deletions
diff --git a/lib/sisu/v2/odf.rb b/lib/sisu/v2/odf.rb index 41229249..ad1f45d1 100644 --- a/lib/sisu/v2/odf.rb +++ b/lib/sisu/v2/odf.rb @@ -461,9 +461,9 @@ module SiSU_ODF word.each do |w| # _ - / # | : ! ^ ~ unless dob =~/^(?:#{Rx[:meta]}|%+ )/m w.gsub!(/&#(?:126|152);/,'~') #126 usual - if w !~/&\S{1,7};/ \ - or w =~/ / - w.gsub!(/&/,'&') #watch + w.gsub!(/ /,' ') + if w !~/&\S{2,7}?;/ + w.gsub!(/&/,'&') end w.gsub!(/(&\S{1,7};)+&/,'\1&') #could break things end diff --git a/lib/sisu/v2/param.rb b/lib/sisu/v2/param.rb index b44a5b8e..78cad7c6 100644 --- a/lib/sisu/v2/param.rb +++ b/lib/sisu/v2/param.rb @@ -427,32 +427,52 @@ module SiSU_Param l,n=Db[:col_info_note],'rights.license' validate_length(s,l,n) end + def sep(str) + (str =~/https?:\/\/\S+$/) ? ' ;' : ';' + end def all s=if @h['all']; @h['all'] else - s=copyright.text + ';' + s='' + if defined? copyright.text \ + and copyright.text \ + and not copyright.text.empty? + v=sep(copyright.text) + s +=copyright.text + v + end if defined? copyright.translation \ - and copyright.translation - s +='<br> translation ' + copyright.translation + ';' + and copyright.translation \ + and not copyright.translation.empty? + v=sep(copyright.translation) + s +='<br> translation ' + copyright.translation + v end if defined? copyright.illustrations \ - and copyright.illustrations - s +='<br> illustrations ' + copyright.illustrations + ';' + and copyright.illustrations \ + and not copyright.illustrations.empty? + v=sep(copyright.illustrations) + s +='<br> illustrations ' + copyright.illustrations + v end if defined? copyright.photographs \ - and copyright.photographs - s +='<br> photographs ' + copyright.photographs + ';' + and copyright.photographs \ + and not copyright.photographs.empty? + v=sep(copyright.photographs) + s +='<br> photographs ' + copyright.photographs + v end if defined? copyright.digitization \ - and copyright.digitization - s +='<br> digitization ' + copyright.digitization + ';' + and copyright.digitization \ + and not copyright.digitization.empty? + v=sep(copyright.digitization) + s +='<br> digitization ' + copyright.digitization + v end if defined? copyright.audio \ - and copyright.audio - s +='<br> audio ' + copyright.audio + ';' + and copyright.audio \ + and not copyright.audio.empty? + v=sep(copyright.audio) + s +='<br> audio ' + copyright.audio + v end if defined? copyright.license \ - and copyright.license + and copyright.license \ + and not copyright.license.empty? s +='<br> License: ' + copyright.license end if s.empty? diff --git a/lib/sisu/v2/shared_metadata.rb b/lib/sisu/v2/shared_metadata.rb index 69a92070..e589c598 100644 --- a/lib/sisu/v2/shared_metadata.rb +++ b/lib/sisu/v2/shared_metadata.rb @@ -476,6 +476,18 @@ WOK if @inf.class==String @inf.gsub!(/</,'<'); @inf.gsub!(/>/,'>') @inf.gsub!(/<br(?: \/)?>/,'<br />') + if @inf =~/&/ + inf_array=[] + word=@inf.scan(/\S+|\n/) + word.each do |w| # _ - / # | : ! ^ ~ + w.gsub!(/ /,' ') + if w !~/&\S{2,7}?;/ + w.gsub!(/&/,'&') + end + inf_array << w + end + @inf=inf_array.join(' ') + end @inf.gsub!(/#{Mx[:url_o]}_(\S+?)#{Mx[:url_c]}/, '<text:a xlink:type="simple" xlink:href="\1">\1</text:a>') #http ftp matches escaped, no decoration @inf.gsub!(/(#{Mx[:lnk_c]})#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, @@ -484,7 +496,7 @@ WOK @inf.gsub!(/#{Mx[:url_o]}(\S+?)#{Mx[:url_c]}/, %{#{url_brace.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{url_brace.xml_close}}) #http ftp matches with decoration else - @inf.gsub!(/(https?:\/\/\S+)/, + @inf.gsub!(/(https?:\/\/[^<>'"\s]+)/, %{#{url_brace.xml_open}<text:a xlink:type="simple" xlink:href="\\1">\\1</text:a>#{url_brace.xml_close}}) #http ftp matches with decoration end @inf.gsub!(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+)/, |