From e1e98d0229b8b79de2105515f0312903a23dc335 Mon Sep 17 00:00:00 2001 From: luca-marie Date: Wed, 24 Aug 2016 15:23:07 +0200 Subject: Update with Twitter --- app/helpers/twitter_helper.rb | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 app/helpers/twitter_helper.rb (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb new file mode 100644 index 0000000..bb3ed2d --- /dev/null +++ b/app/helpers/twitter_helper.rb @@ -0,0 +1,2 @@ +module TwitterHelper +end -- cgit v1.2.3 From fecc0e9e1985be2d3767664453d4776ac20897c0 Mon Sep 17 00:00:00 2001 From: luca-marie Date: Thu, 25 Aug 2016 20:50:12 +0200 Subject: Twitter controller now as helper, some more styling in CSS, bug fix --- app/helpers/twitter_helper.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index bb3ed2d..9fd4ffd 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -1,2 +1,24 @@ module TwitterHelper + + def twitter_client + Twitter::REST::Client.new do |config| + config.consumer_key = Rails.application.secrets.twitter['consumer_key'] + config.consumer_secret = Rails.application.secrets.twitter['consumer_secret'] + config.bearer_token = Rails.application.secrets.twitter['bearer_token'] + end + end + + def twitter_handle + Rails.application.secrets.twitter['twitter_handle'] + end + + def twitter_name + twitter_client.user(twitter_handle).name + end + + def tweets + twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false} + end end + +# unless Rails.application.secrets.twitter['enabled'] == false -- cgit v1.2.3 From e87d797cdbfe5ebe8dff789742adb6a82d92aae4 Mon Sep 17 00:00:00 2001 From: luca-marie Date: Fri, 26 Aug 2016 17:16:35 +0200 Subject: Small updates on method to check if twitter feed enabled --- app/helpers/twitter_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index 9fd4ffd..b01293f 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -1,4 +1,7 @@ module TwitterHelper + def twitter_enabled + Rails.application.secrets.twitter['enabled'] == true + end def twitter_client Twitter::REST::Client.new do |config| @@ -20,5 +23,3 @@ module TwitterHelper twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false} end end - -# unless Rails.application.secrets.twitter['enabled'] == false -- cgit v1.2.3 From ea3fc6ffbb8f90aff28ce56fe4432a8d3ff18caa Mon Sep 17 00:00:00 2001 From: luca-marie Date: Mon, 29 Aug 2016 17:39:46 +0200 Subject: Changes mainly on CSS 'fine tuning' and shortening the Twitter API credentials, - only bearer token is needed to access Twitter API --- app/helpers/twitter_helper.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index b01293f..d20b7da 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -5,8 +5,6 @@ module TwitterHelper def twitter_client Twitter::REST::Client.new do |config| - config.consumer_key = Rails.application.secrets.twitter['consumer_key'] - config.consumer_secret = Rails.application.secrets.twitter['consumer_secret'] config.bearer_token = Rails.application.secrets.twitter['bearer_token'] end end -- cgit v1.2.3 From 92e7b90d619111fdaaf50ab0b8538c39605fe005 Mon Sep 17 00:00:00 2001 From: luca-marie Date: Thu, 1 Sep 2016 12:17:05 +0200 Subject: Updating the view and CSS, no pic and twitter handle in each tweet; Displaying only 3 most tweets --- app/helpers/twitter_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index d20b7da..834e5c6 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -18,6 +18,6 @@ module TwitterHelper end def tweets - twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false} + twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) end end -- cgit v1.2.3 From 4a09c2df8df3db979049ee8d98b202ad9f2125a8 Mon Sep 17 00:00:00 2001 From: luca-marie Date: Thu, 8 Sep 2016 18:25:41 +0200 Subject: Helper has caching of name and tweets included now \o/ --- app/helpers/twitter_helper.rb | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index 834e5c6..fd3f82c 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -1,6 +1,8 @@ module TwitterHelper def twitter_enabled - Rails.application.secrets.twitter['enabled'] == true + if Rails.application.secrets.twitter + Rails.application.secrets.twitter['enabled'] == true + end end def twitter_client @@ -13,11 +15,32 @@ module TwitterHelper Rails.application.secrets.twitter['twitter_handle'] end + def twitter_user_info + $twitter_user_info ||= [] + end + + def update_twitter_info + twitter_user_info[0] = Time.now + twitter_user_info[1] = twitter_client.user(twitter_handle).name + twitter_user_info[2] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) + end + + def cached_info + if twitter_user_info[0] == nil + update_twitter_info + else + if Time.now > twitter_user_info[0] + 15.minutes + update_twitter_info + end + end + twitter_user_info + end + def twitter_name - twitter_client.user(twitter_handle).name + cached_info[1] end def tweets - twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) + cached_info[2] end end -- cgit v1.2.3 From 2ef8707a7539622007b6d679a7708a5979594ff3 Mon Sep 17 00:00:00 2001 From: luca-marie Date: Tue, 13 Sep 2016 12:20:12 +0200 Subject: Cleaning CSS &view code, updating twitter helper with develop --- app/helpers/twitter_helper.rb | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index fd3f82c..0b8f79c 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -16,31 +16,42 @@ module TwitterHelper end def twitter_user_info - $twitter_user_info ||= [] + $twitter_user_info ||= [] end - def update_twitter_info - twitter_user_info[0] = Time.now - twitter_user_info[1] = twitter_client.user(twitter_handle).name - twitter_user_info[2] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) - end - - def cached_info + def twitter_name if twitter_user_info[0] == nil update_twitter_info else - if Time.now > twitter_user_info[0] + 15.minutes + if Time.now > twitter_user_info[0] + 120.minutes update_twitter_info end end - twitter_user_info + twitter_user_info[1] end - def twitter_name - cached_info[1] + def update_twitter_info + twitter_user_info[0] = Time.now + twitter_user_info[1] = twitter_client.user(twitter_handle).name + end + + def twitter_tweets + $twitter_tweets ||= [] + end + + def twitter_timeline + if twitter_tweets[0] == nil + update_twitter_timeline + else + if Time.now > twitter_tweets[0] + 15.minutes + update_twitter_timeline + end + end + twitter_tweets[1] end - def tweets - cached_info[2] + def update_twitter_timeline + twitter_tweets[0] = Time.now + twitter_tweets[1] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) end end -- cgit v1.2.3 From 782be39862394c05a069eab9b7dd8f6779354917 Mon Sep 17 00:00:00 2001 From: luca-marie Date: Tue, 13 Sep 2016 17:26:51 +0200 Subject: Change in code for caching --- app/helpers/twitter_helper.rb | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index 0b8f79c..f824a03 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -19,39 +19,28 @@ module TwitterHelper $twitter_user_info ||= [] end - def twitter_name - if twitter_user_info[0] == nil - update_twitter_info - else - if Time.now > twitter_user_info[0] + 120.minutes - update_twitter_info - end - end - twitter_user_info[1] - end - def update_twitter_info twitter_user_info[0] = Time.now twitter_user_info[1] = twitter_client.user(twitter_handle).name + twitter_user_info[2] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) end - def twitter_tweets - $twitter_tweets ||= [] - end - - def twitter_timeline - if twitter_tweets[0] == nil - update_twitter_timeline + def cached_info + if twitter_user_info[0] == nil + update_twitter_info else - if Time.now > twitter_tweets[0] + 15.minutes - update_twitter_timeline + if Time.now > twitter_user_info[0] + 15.minutes + update_twitter_info end end - twitter_tweets[1] + twitter_user_info + end + + def twitter_name + cached_info[1] end - def update_twitter_timeline - twitter_tweets[0] = Time.now - twitter_tweets[1] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) + def tweets + cached_info[2] end end -- cgit v1.2.3 From 460129e5965751127bb6cb363a661afb7c7d5ab4 Mon Sep 17 00:00:00 2001 From: thea Date: Wed, 21 Sep 2016 14:08:38 +0200 Subject: included error-handling: twitter-helper includes rescue and error message for fourth value in array. there will always be an empty array that view (text and each - method) does not break. if empty array in view the error-message is shown. (its WIP) --- app/helpers/twitter_helper.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index f824a03..8503f24 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -23,6 +23,26 @@ module TwitterHelper twitter_user_info[0] = Time.now twitter_user_info[1] = twitter_client.user(twitter_handle).name twitter_user_info[2] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) + if twitter_user_info[2] == nil + error_handling + twitter_user_info[3] = "The twitter-handle does not exist or the account is private. Please change it or contact your provider-admin." + end + rescue Twitter::Error::BadRequest + error_handling + rescue Twitter::Error::Unauthorized + error_handling + rescue Twitter::Error::Forbidden + error_handling + rescue Twitter::Error::NotAcceptable + error_handling + rescue Twitter::Error::TooManyRequests + error_handling + end + + def error_handling + twitter_user_info[2] = [] + twitter_user_info[3] = "The twitter-handle does not exist or the account is private. Please change it or contact your provider-admin." + return twitter_user_info end def cached_info @@ -43,4 +63,8 @@ module TwitterHelper def tweets cached_info[2] end + + def error_message + cached_info[3] + end end -- cgit v1.2.3 From d44fc9292637ed6d1a4a7e04883e8b3b88dc3c15 Mon Sep 17 00:00:00 2001 From: theaamanda Date: Wed, 21 Sep 2016 23:34:53 +0200 Subject: finished error-handling with different error-messages for different errors. added info that the account has to be public in Twitter-Doc --- app/helpers/twitter_helper.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index 8503f24..719f95e 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -29,19 +29,23 @@ module TwitterHelper end rescue Twitter::Error::BadRequest error_handling + twitter_user_info[3] = "The request to have the tweets shown was invalid or cannot be otherwise served." rescue Twitter::Error::Unauthorized error_handling + twitter_user_info[3] = "Please change your twitter-credentials, make sure that the twitter-account you access is public or contact your provider-admin to have the tweets shown." rescue Twitter::Error::Forbidden error_handling + twitter_user_info[3] = "The request to have the tweets shown is understood, but it has been refused or access is not allowed." rescue Twitter::Error::NotAcceptable error_handling + twitter_user_info[3] = "An invalid format is specified in the request to have the tweets shown." rescue Twitter::Error::TooManyRequests error_handling + twitter_user_info[3] = "The rate-limit for accessing the tweets is reached. You should be able to see the tweets in a couple of minutes." end def error_handling twitter_user_info[2] = [] - twitter_user_info[3] = "The twitter-handle does not exist or the account is private. Please change it or contact your provider-admin." return twitter_user_info end -- cgit v1.2.3 From 306b36c045cd62638db179115ed002c6ab7c5cd8 Mon Sep 17 00:00:00 2001 From: luca-marie Date: Thu, 22 Sep 2016 14:36:10 +0200 Subject: included Theas work on error-handling \o/; changed link to twitter-account in header; fixed erb escaping characters problem without letting evil code pass; setting customized image file 'Avatar_Pic.png' in config/custo../assets to get loaded instead of default twitter-logo --- app/helpers/twitter_helper.rb | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index f824a03..719f95e 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -23,6 +23,30 @@ module TwitterHelper twitter_user_info[0] = Time.now twitter_user_info[1] = twitter_client.user(twitter_handle).name twitter_user_info[2] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) + if twitter_user_info[2] == nil + error_handling + twitter_user_info[3] = "The twitter-handle does not exist or the account is private. Please change it or contact your provider-admin." + end + rescue Twitter::Error::BadRequest + error_handling + twitter_user_info[3] = "The request to have the tweets shown was invalid or cannot be otherwise served." + rescue Twitter::Error::Unauthorized + error_handling + twitter_user_info[3] = "Please change your twitter-credentials, make sure that the twitter-account you access is public or contact your provider-admin to have the tweets shown." + rescue Twitter::Error::Forbidden + error_handling + twitter_user_info[3] = "The request to have the tweets shown is understood, but it has been refused or access is not allowed." + rescue Twitter::Error::NotAcceptable + error_handling + twitter_user_info[3] = "An invalid format is specified in the request to have the tweets shown." + rescue Twitter::Error::TooManyRequests + error_handling + twitter_user_info[3] = "The rate-limit for accessing the tweets is reached. You should be able to see the tweets in a couple of minutes." + end + + def error_handling + twitter_user_info[2] = [] + return twitter_user_info end def cached_info @@ -43,4 +67,8 @@ module TwitterHelper def tweets cached_info[2] end + + def error_message + cached_info[3] + end end -- cgit v1.2.3 From cd07bbe8d0390a8622bcde257efcb3e11038de63 Mon Sep 17 00:00:00 2001 From: luca-marie Date: Thu, 22 Sep 2016 16:05:02 +0200 Subject: Modified error messages --- app/helpers/twitter_helper.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index 719f95e..e3b468a 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -22,26 +22,26 @@ module TwitterHelper def update_twitter_info twitter_user_info[0] = Time.now twitter_user_info[1] = twitter_client.user(twitter_handle).name - twitter_user_info[2] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) + twitter_user_info[2] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(7) if twitter_user_info[2] == nil error_handling - twitter_user_info[3] = "The twitter-handle does not exist or the account is private. Please change it or contact your provider-admin." + twitter_user_info[3] = "The twitter handle does not exist or the account's tweets are protected. Please change the privacy settings accordingly." end rescue Twitter::Error::BadRequest error_handling - twitter_user_info[3] = "The request to have the tweets shown was invalid or cannot be otherwise served." + twitter_user_info[3] = "The request to display tweets is invalid or cannot be otherwise served." rescue Twitter::Error::Unauthorized error_handling - twitter_user_info[3] = "Please change your twitter-credentials, make sure that the twitter-account you access is public or contact your provider-admin to have the tweets shown." + twitter_user_info[3] = "The account's tweets are protected and cannot be displayed. Please change the privacy settings of the corresponding account." rescue Twitter::Error::Forbidden error_handling - twitter_user_info[3] = "The request to have the tweets shown is understood, but it has been refused or access is not allowed." + twitter_user_info[3] = "The request to display tweets is understood, but it has been refused or access is not allowed." rescue Twitter::Error::NotAcceptable error_handling - twitter_user_info[3] = "An invalid format is specified in the request to have the tweets shown." + twitter_user_info[3] = "An invalid format is specified in the request to display tweets." rescue Twitter::Error::TooManyRequests error_handling - twitter_user_info[3] = "The rate-limit for accessing the tweets is reached. You should be able to see the tweets in a couple of minutes." + twitter_user_info[3] = "The rate-limit for accessing the tweets is reached. You should be able to display tweets in a couple of minutes." end def error_handling -- cgit v1.2.3 From a771c63ff6a04f2f80b94c35538dd62ad1b0c310 Mon Sep 17 00:00:00 2001 From: luca-marie Date: Thu, 22 Sep 2016 16:11:12 +0200 Subject: same same but slightly different --- app/helpers/twitter_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index e3b468a..cf75a73 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -22,7 +22,7 @@ module TwitterHelper def update_twitter_info twitter_user_info[0] = Time.now twitter_user_info[1] = twitter_client.user(twitter_handle).name - twitter_user_info[2] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(7) + twitter_user_info[2] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) if twitter_user_info[2] == nil error_handling twitter_user_info[3] = "The twitter handle does not exist or the account's tweets are protected. Please change the privacy settings accordingly." -- cgit v1.2.3 From 4ffa776d2c760618b17bd76a9a023f7fe762babd Mon Sep 17 00:00:00 2001 From: luca-marie Date: Fri, 23 Sep 2016 11:52:46 +0200 Subject: Doc updated on how to customize avatar picture in twitter feature; update error response messages; added 'config/customization/images' + link in 'config/initializer/customization.rb' --- app/helpers/twitter_helper.rb | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index cf75a73..5a9d28c 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -22,26 +22,32 @@ module TwitterHelper def update_twitter_info twitter_user_info[0] = Time.now twitter_user_info[1] = twitter_client.user(twitter_handle).name - twitter_user_info[2] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) + twitter_user_info[2] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(10) if twitter_user_info[2] == nil error_handling twitter_user_info[3] = "The twitter handle does not exist or the account's tweets are protected. Please change the privacy settings accordingly." end rescue Twitter::Error::BadRequest error_handling - twitter_user_info[3] = "The request to display tweets is invalid or cannot be otherwise served." + twitter_user_info[3] = "The request for displaying tweets is invalid or cannot be otherwise served." rescue Twitter::Error::Unauthorized error_handling twitter_user_info[3] = "The account's tweets are protected and cannot be displayed. Please change the privacy settings of the corresponding account." rescue Twitter::Error::Forbidden error_handling - twitter_user_info[3] = "The request to display tweets is understood, but it has been refused or access is not allowed." + twitter_user_info[3] = "The request for displaying tweets is understood, but it has been refused or access is not allowed." rescue Twitter::Error::NotAcceptable error_handling - twitter_user_info[3] = "An invalid format is specified in the request to display tweets." + twitter_user_info[3] = "An invalid format is specified in the request for displaying tweets." rescue Twitter::Error::TooManyRequests error_handling twitter_user_info[3] = "The rate-limit for accessing the tweets is reached. You should be able to display tweets in a couple of minutes." + rescue Twitter::Error::NotFound + error_handling + twitter_user_info[3] = "The twitter hanlde does not exist." + rescue Twitter::Error + error_handling + twitter_user_info[3] = "An error occured while fetching the tweets." end def error_handling -- cgit v1.2.3 From a7ab66b0478c1845ed0fdbff7dd3c83ea804826c Mon Sep 17 00:00:00 2001 From: luca-marie Date: Fri, 23 Sep 2016 15:46:25 +0200 Subject: increase number of fetched tweets to make sure 3 most recent tweets without RTs and @ are displayed --- app/helpers/twitter_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index 5a9d28c..2312ed9 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -22,7 +22,7 @@ module TwitterHelper def update_twitter_info twitter_user_info[0] = Time.now twitter_user_info[1] = twitter_client.user(twitter_handle).name - twitter_user_info[2] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(10) + twitter_user_info[2] = twitter_client.user_timeline(twitter_handle, {:count => 200}).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) if twitter_user_info[2] == nil error_handling twitter_user_info[3] = "The twitter handle does not exist or the account's tweets are protected. Please change the privacy settings accordingly." -- cgit v1.2.3 From af32db82732060fe5a309977afdb648aa9a62212 Mon Sep 17 00:00:00 2001 From: luca-marie Date: Fri, 23 Sep 2016 16:47:01 +0200 Subject: Fixed typo in helper --- app/helpers/twitter_helper.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index 9b1d78d..f520286 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -22,7 +22,6 @@ module TwitterHelper def update_twitter_info twitter_user_info[0] = Time.now twitter_user_info[1] = twitter_client.user(twitter_handle).name -<<<<<<< HEAD twitter_user_info[2] = twitter_client.user_timeline(twitter_handle, {:count => 200}).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) if twitter_user_info[2] == nil error_handling -- cgit v1.2.3 From 8a9ef9e96193a737b8d21e1f21db43d0d69394ef Mon Sep 17 00:00:00 2001 From: thea Date: Fri, 30 Sep 2016 12:13:22 +0200 Subject: added 'show more tweets'-link when more tweets are existing than displayed, method included to set number of tweets which should be displayed --- app/helpers/twitter_helper.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index f520286..1afe50d 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -22,7 +22,7 @@ module TwitterHelper def update_twitter_info twitter_user_info[0] = Time.now twitter_user_info[1] = twitter_client.user(twitter_handle).name - twitter_user_info[2] = twitter_client.user_timeline(twitter_handle, {:count => 200}).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) + twitter_user_info[2] = twitter_client.user_timeline(twitter_handle, {:count => 200}).select{ |tweet| tweet.text.start_with?('RT','@')==false} if twitter_user_info[2] == nil error_handling twitter_user_info[3] = "The twitter handle does not exist or the account's tweets are protected. Please change the privacy settings accordingly or contact your provider-admin." @@ -52,7 +52,7 @@ module TwitterHelper def error_handling twitter_user_info[2] = [] - return twitter_user_info + twitter_user_info end def cached_info @@ -70,11 +70,19 @@ module TwitterHelper cached_info[1] end + def num_of_tweets + 2 + end + def tweets - cached_info[2] + cached_info[2].take(num_of_tweets) end def error_message cached_info[3] end + + def all_tweets_count + twitter_user_info[2].count + end end -- cgit v1.2.3 From c275ff63cd78872f27b1b83d0da27c6ad537b2c9 Mon Sep 17 00:00:00 2001 From: thea Date: Fri, 30 Sep 2016 12:25:55 +0200 Subject: changed number 2 to 3 to have three tweets shown --- app/helpers/twitter_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/helpers/twitter_helper.rb') diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index 1afe50d..7ce28be 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -71,7 +71,7 @@ module TwitterHelper end def num_of_tweets - 2 + 3 end def tweets -- cgit v1.2.3