Commit a6c0d0ad734794754679b4ff57744e55d3b05c79

Fix bug where even when we were viewing identica status updates, we sometimes saw twitter urls.
  
3030 @@config = YAML.load_file ENV['HOME'] + "/.coefficient.yml"
3131end
3232
33def make_user_link(data)
34 origin = data['origin']
35 name = data['user']['screen_name']
36 string = %Q(<b><a href="#{@@sites[origin]['url']}#{name}">#{name}</a></b>)
33def make_user_link(origin, name)
34# origin = data['origin']
35# name = data['user']['screen_name']
36 string = %Q(<a href="#{@@sites[origin]['url']}#{name}">#{name}</a>)
3737 return string
3838end
3939
4141 if origin == "identica"
4242 return identicaify linkify html text
4343 else
44 return linkify html text
44 return twitterify linkify html text
4545 end
4646end
4747
5757 gsub("\"", "&quot;")
5858end
5959
60def twitterify(text)
61 new = text.dup
62 new.gsub!(/@([0-9a-zA-Z_]+)/, '@<a href="http://twitter.com/\1">\1</a>')
63 return new
64end
65
6066def linkify(text)
6167 new = text.dup
6268 # XXX this shouldn't work if . is the last character in the or
7272
7373 # maybe laconica-0.7.3/lib/util.php:common_replace_urls_callback() ?
7474 new.gsub!(/(https?:\/\/([a-zA-Z0-9_%\-+?#\/,=]|&(?!quot;)|\.(?!\z|\s))+)/, '<a href="\1">\1</a>')
75 new.gsub!(/@([0-9a-zA-Z_]+)/, '@<a href="http://twitter.com/\1">\1</a>')
7675 return new
7776end
7877
8989 # hashtag regexp in laconica is /(?:^|\s)#([A-Za-z0-9_\-\.]{1,64})/
9090 # #YouTwitFace." breaks it.
9191 # text is: Conan's #Tonight_Show: "In the year 3000 #Facebook, #Twitter, and #YouTube merge to form the largest time-wasting site ever: #YouTwitFace."
92
93 new.gsub!(/@([0-9a-zA-Z_]+)/, '@<a href="http://identi.ca/\1">\1</a>')
9294
9395 new.gsub!(/(^|\s)#(?:(?!39;)([A-Za-z0-9_\-]+|\.(?!\z|\s)))/, '\1#<a href="http://identi.ca/tag/\2">\2</a>')
9496
  
9898 end
9999
100100 should "correctly make links to twitter" do
101 assert_equal %q(<b><a href="http://twitter.com/paulv">paulv</a></b>),
102 make_user_link(@twitter)
101 assert_equal %q(<a href="http://twitter.com/paulv">paulv</a>),
102 make_user_link(@twitter['origin'], @twitter['user']['screen_name'])
103103 end
104104
105105 should "correctly make links to identica" do
106 assert_equal %q(<b><a href="http://identi.ca/paulv">paulv</a></b>),
107 make_user_link(@identica)
106 assert_equal %q(<a href="http://identi.ca/paulv">paulv</a>),
107 make_user_link(@identica['origin'], @identica['user']['screen_name'])
108108 end
109109 end
110110
  
7474 </div> <!-- image -->
7575
7676 <div> <!-- text -->
77 <%= make_user_link(d) %>
77 <b><%= make_user_link(d['origin'], d['user']['screen_name']) %></b>
7878 <%= parse_text(d['origin'], d['text']) %>
7979 </div> <!-- text -->
8080
8282
8383 <div class="footer footer_<%= d['origin'] %>">
8484 <% if d['in_reply_to_status_id'] %>
85 In <a href="/status/<%= d['origin'] %>/<%= d['in_reply_to_status_id'] %>" class="domw_reply_to">reply to</a> <a href="http://twitter.com/<%= d['in_reply_to_screen_name'] %>"><%= d['in_reply_to_screen_name'] %></a>
85 In <a href="/status/<%= d['origin'] %>/<%= d['in_reply_to_status_id'] %>" class="domw_reply_to">reply to</a> <%= make_user_link(d['origin'], d['in_reply_to_screen_name']) %>
8686 <% end %>
8787 Via <%= escape_amp d['source'] %> to <%= d['origin'] %> on
8888 <span class="entry_time_text"><%= convert_time_to_est(d['created_at']) %></span> <a href="#" onclick="reply('<%= d['origin'] %>', '<%= d['user']['screen_name'] %>', '<%= d['id'] %>')">r</a>