Skip to content

Instantly share code, notes, and snippets.

@arton
Created July 24, 2011 14:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arton/1102677 to your computer and use it in GitHub Desktop.
Save arton/1102677 to your computer and use it in GitHub Desktop.
disp_referrer.rb patch
arton@nomad:~/public_html/diary/misc/plugin$ diff -pu disp_referrer.rb.old disp_referrer.rb
--- disp_referrer.rb.old 2011-07-24 23:23:42.000000000 +0900
+++ disp_referrer.rb 2011-07-24 23:28:55.000000000 +0900
@@ -1015,25 +1015,28 @@ class DispRef2Refs
end
result << '<ul>'
@refs[cat_key].each do |a|
- if a[2].size == 1 then
- result << %Q[<li><a rel="nofollow" href="#{DispRef2String::escapeHTML( a[2][0][1].url )}">#{DispRef2String::escapeHTML( a[2][0][1].title )}</a> &times;#{a[0]}</li>\n]
- elsif not a[2][0][1].title_ignored then
- result << %Q[<li><a rel="nofollow" href="#{DispRef2String::escapeHTML( a[2][0][1].url )}">#{DispRef2String::escapeHTML( a[1] )}</a> &times;#{a[0]} : #{a[2][0][0]}]
- a[2][1..-1].each do |b|
+ begin
+ if a[2].size == 1 then
+ result << %Q[<li><a rel="nofollow" href="#{DispRef2String::escapeHTML( a[2][0][1].url )}">#{DispRef2String::escapeHTML( a[2][0][1].title )}</a> &times;#{a[0]}</li>\n]
+ elsif not a[2][0][1].title_ignored then
+ result << %Q[<li><a rel="nofollow" href="#{DispRef2String::escapeHTML( a[2][0][1].url )}">#{DispRef2String::escapeHTML( a[1] )}</a> &times;#{a[0]} : #{a[2][0][0]}]
+ a[2][1..-1].each do |b|
title = (b[1].title != a[1]) ? %Q[ title="#{DispRef2String::escapeHTML( b[1].title )}"] : ''
result << %Q[, <a rel="nofollow" href="#{DispRef2String::escapeHTML( b[1].url )}"#{title}>#{b[0]}</a>]
end
- result << "</li>\n"
- else
- result << %Q[<li>#{DispRef2String::escapeHTML( a[1] )} &times;#{a[0]} : ]
- comma = nil
- a[2][0..-1].each do |b|
+ result << "</li>\n"
+ else
+ result << %Q[<li>#{DispRef2String::escapeHTML( a[1] )} &times;#{a[0]} : ]
+ comma = nil
+ a[2][0..-1].each do |b|
title = (b[1].title != a[1]) ? %Q[ title="#{DispRef2String::escapeHTML( b[1].title )}"] : ''
result << comma if comma
result << %Q[<a rel="nofollow" href="#{DispRef2String::escapeHTML( b[1].url )}"#{title}>#{b[0]}</a>]
comma = ', '
end
- result << "</li>\n"
+ result << "</li>\n"
+ end
+ rescue Encoding::CompatibilityError => e
end
end
result << "</ul>\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment