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(-) 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 3408ac694a60df0380a3bf444077165a1f30e87e Mon Sep 17 00:00:00 2001 From: luca-marie Date: Fri, 9 Sep 2016 13:19:51 +0200 Subject: Added changes in css, view and main view file, as well as default avatar is now set as twitter official logo (added 2 official twitter logo images; changed footer text. --- app/assets/images/Twitter_Logo_Blue.png | Bin 0 -> 4298 bytes app/assets/images/Twitter_Logo_White_On_Blue.png | Bin 0 -> 4861 bytes app/assets/images/rails.png | Bin 6646 -> 0 bytes app/assets/images/team-loadtocode-Loading_icon.gif | Bin 17490 -> 0 bytes app/assets/stylesheets/twitter.scss | 32 +++++++++------- app/views/home/_content.html.haml | 4 +- app/views/twitter/_index.html.erb | 41 ++++++++++++--------- 7 files changed, 45 insertions(+), 32 deletions(-) create mode 100644 app/assets/images/Twitter_Logo_Blue.png create mode 100644 app/assets/images/Twitter_Logo_White_On_Blue.png delete mode 100644 app/assets/images/rails.png delete mode 100644 app/assets/images/team-loadtocode-Loading_icon.gif diff --git a/app/assets/images/Twitter_Logo_Blue.png b/app/assets/images/Twitter_Logo_Blue.png new file mode 100644 index 0000000..b5eebc8 Binary files /dev/null and b/app/assets/images/Twitter_Logo_Blue.png differ diff --git a/app/assets/images/Twitter_Logo_White_On_Blue.png b/app/assets/images/Twitter_Logo_White_On_Blue.png new file mode 100644 index 0000000..25ba09f Binary files /dev/null and b/app/assets/images/Twitter_Logo_White_On_Blue.png differ diff --git a/app/assets/images/rails.png b/app/assets/images/rails.png deleted file mode 100644 index d5edc04..0000000 Binary files a/app/assets/images/rails.png and /dev/null differ diff --git a/app/assets/images/team-loadtocode-Loading_icon.gif b/app/assets/images/team-loadtocode-Loading_icon.gif deleted file mode 100644 index a718bd8..0000000 Binary files a/app/assets/images/team-loadtocode-Loading_icon.gif and /dev/null differ diff --git a/app/assets/stylesheets/twitter.scss b/app/assets/stylesheets/twitter.scss index 89cdecf..b2481db 100644 --- a/app/assets/stylesheets/twitter.scss +++ b/app/assets/stylesheets/twitter.scss @@ -3,9 +3,10 @@ } .twitter_header { - font-size: 20px; + font-size: 16px; text-align: left; - margin-bottom: 80px; + margin-bottom: 55px; + padding: 10px 8px; } .twitter_id { @@ -25,28 +26,29 @@ .twitter_image_frame { width: 40px; height: 40px; - overflow: hidden; + overflow: hidden } -.twitter_name { - padding-left: 65px; - line-height: 40px; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - font-size: 20px; -} - .twitter_image_frame > img { display: block; position: absolute; top: 0; bottom: 0; - left: 0; + left: 30; width: 100%; margin: auto; } +.twitter_name { + padding-left: 55px; + line-height: 20px; + white-space: nowrap; + overflow: hidden; + text-overflow: ellipsis; + font-size: 16px; +} + +// Body = displays tweets .twitter_list { box-sizing: border-box; } @@ -70,5 +72,7 @@ box-sizing: border-box; .twitter_footer { border-top-style: solid; border-color: lightgrey; - padding-top: 8px; + padding: 10px 8px; + font-style: italic; + font-size: 12px; } diff --git a/app/views/home/_content.html.haml b/app/views/home/_content.html.haml index ecd8524..5341189 100644 --- a/app/views/home/_content.html.haml +++ b/app/views/home/_content.html.haml @@ -1,4 +1,4 @@ -.col-md-9 +.col-md-8 .row %h1= t(:welcome, :provider => APP_CONFIG[:domain]) .p=t(:welcome_message_html) @@ -6,6 +6,8 @@ .row = home_page_buttons +.col-md-1 + .col-md-3 .row = render 'twitter/index' diff --git a/app/views/twitter/_index.html.erb b/app/views/twitter/_index.html.erb index 2d17aad..2cba033 100644 --- a/app/views/twitter/_index.html.erb +++ b/app/views/twitter/_index.html.erb @@ -1,30 +1,37 @@ <% if twitter_enabled == true %>