From 194557d8bd11ffcf31333c252a63318683bcccf4 Mon Sep 17 00:00:00 2001 From: thea Date: Fri, 23 Sep 2016 15:55:09 +0200 Subject: included count for tweet fetch --- app/helpers/twitter_helper.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index 719f95e..cc48084 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 - 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." -- 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/assets/stylesheets/twitter.scss | 5 +++++ app/helpers/twitter_helper.rb | 14 +++++++++++--- app/views/twitter/_index.html.erb | 9 ++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/twitter.scss b/app/assets/stylesheets/twitter.scss index a67c044..4419918 100644 --- a/app/assets/stylesheets/twitter.scss +++ b/app/assets/stylesheets/twitter.scss @@ -71,3 +71,8 @@ box-sizing: border-box; font-style: italic; font-size: 12px; } + +.more_tweets_link { + text-align: right; + font-size: 12px; +} 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 diff --git a/app/views/twitter/_index.html.erb b/app/views/twitter/_index.html.erb index cdfff4b..6e592c7 100644 --- a/app/views/twitter/_index.html.erb +++ b/app/views/twitter/_index.html.erb @@ -18,9 +18,16 @@ <% end %> - + <%if all_tweets_count > num_of_tweets then%> + + <% end %> + -- cgit v1.2.3