Skip to content

Commit

Permalink
Fixed URL regexp
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasronge committed Nov 2, 2011
1 parent f7003a4 commit 699a41b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
7 changes: 3 additions & 4 deletions app/controllers/tags_controller.rb
Expand Up @@ -94,7 +94,7 @@ def search
while curr_page < 10 && !found_old_tweet do
result.each do |item|
parsed_tweet_hash = Tweet.parse(item)
found_old_tweet = true && break if Tweet.find_by_tweet_id(parsed_tweet_hash[:tweet_id])
#found_old_tweet = true && break if Tweet.find_by_tweet_id(parsed_tweet_hash[:tweet_id])
tweet = Tweet.create!(parsed_tweet_hash)

twid = item['from_user'].downcase
Expand All @@ -113,7 +113,7 @@ def search


def parse_tweet(tweet, user)
tweet.text.gsub(/(@\w+|https?\S+|#\w+)/).each do |t|
tweet.text.gsub(/(@\w+|https?:\/\/[a-zA-Z0-9\-\.~\:\?#\[\]\!\@\$&,\(\)*+=;,\/]+|#\w+)/).each do |t|
case t
when /^@.+/
t = t[1..-1].downcase
Expand All @@ -127,8 +127,7 @@ def parse_tweet(tweet, user)
tag = Tag.find_or_create_by(:name => t)
tweet.tags << tag unless tweet.tags.include?(tag)
when /https?:.+/
url = t.gsub(/[^a-zA-Z0-9\-\.~\:\?#\[\]\!\@\$&,\(\)*+=;,]/, '')
link = Link.find_or_create_by(:url => url)
link = Link.find_or_create_by(:url => t)
tweet.links << link.redirected_link || link
end
end
Expand Down
2 changes: 0 additions & 2 deletions config/routes.rb
@@ -1,7 +1,5 @@
Kvitter::Application.routes.draw do

mount Neo::Viz::App => '/neo-viz'

resources :tweets

resources :tags do
Expand Down

0 comments on commit 699a41b

Please sign in to comment.