diff options
author | luca-marie <ml.kochsiek@fu-berlin.de> | 2016-08-25 20:50:12 +0200 |
---|---|---|
committer | thea <ta.kupler@gmail.com> | 2016-09-01 12:09:37 +0200 |
commit | fecc0e9e1985be2d3767664453d4776ac20897c0 (patch) | |
tree | b43ea9e5e1044a30b1da7a5fd7a5be5a8a8f7bd3 | |
parent | 4054060a68c119c509228db34ec139f0a0e0c00a (diff) |
Twitter controller now as helper, some more styling in CSS, bug fix
-rw-r--r-- | app/assets/stylesheets/twitter.scss | 21 | ||||
-rw-r--r-- | app/controllers/home_controller.rb | 17 | ||||
-rw-r--r-- | app/helpers/twitter_helper.rb | 22 | ||||
-rw-r--r-- | app/views/home/_content.html.haml | 13 | ||||
-rw-r--r-- | app/views/twitter/_index.html.erb | 38 | ||||
-rw-r--r-- | config/routes.rb | 2 |
6 files changed, 60 insertions, 53 deletions
diff --git a/app/assets/stylesheets/twitter.scss b/app/assets/stylesheets/twitter.scss index 1d54785..6b74cf7 100644 --- a/app/assets/stylesheets/twitter.scss +++ b/app/assets/stylesheets/twitter.scss @@ -1,5 +1,5 @@ .twitter { - // position: fixed; + position: relative; // top: 0; // right: 10px; // bottom: 0; @@ -11,13 +11,18 @@ height: 30px; font-size: 20px ; text-align: center; + margin-bottom: 20px; +} + +.twitter_list { + position: relative; } -.tweets:hover { +.tweet:hover { background-color: #ccf2ff; } -.tweets { +.tweet { border-bottom-style: solid; border-color: #bfbfbf; // display: inline; @@ -27,7 +32,7 @@ // text-align: center; } -.tweets_pic { +.tweet_pic { display: block; float: left; width: 28px; @@ -37,7 +42,7 @@ // background: hsl(0, 0%, 30%); } -.tweets_name { +.tweet_name { padding-left: 45px; padding-top: 16px; // border-bottom-style: solid; @@ -49,7 +54,7 @@ padding-top: 15px; } -.text_date { +.tweet_text_date { text-align: right; padding-top: 4px; font-size: 12px ; @@ -58,14 +63,14 @@ padding-top: 8px; } -.twitter-image-frame { +.twitter_image_frame { width: 40px; height: 40px; overflow: hidden; position: relative; } -.twitter-image-frame > img { +.twitter_image_frame > img { display: block; position: absolute; top: 0; diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 49471ff..86c36e9 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -4,25 +4,8 @@ class HomeController < ApplicationController respond_to :html def index - unless Rails.application.secrets.twitter['enabled'] == false - twitter_handle = Rails.application.secrets.twitter['twitter_handle'] - @twitter_screen_name = twitter_handle - @twitter_name = twitter_client.user(twitter_handle).name - @tweets = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false} - @tweet_time = "tweeted on" - end - if logged_in? redirect_to current_user end end - - 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 - end 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 diff --git a/app/views/home/_content.html.haml b/app/views/home/_content.html.haml index 725c391..6efd2d0 100644 --- a/app/views/home/_content.html.haml +++ b/app/views/home/_content.html.haml @@ -1,14 +1,15 @@ -.left.column +.row %h1= t(:welcome, :provider => APP_CONFIG[:domain]) .p=t(:welcome_message_html) - = home_page_buttons - -.right.column - = render :partial => 'twitter/index' +.row + .col-md-9 + = home_page_buttons + .col-md-3 + = render 'twitter/index' - if Rails.env == 'development' .row %hr %p - = link_to "make donation", new_payment_path if APP_CONFIG[:payment].present? += link_to "make donation", new_payment_path if APP_CONFIG[:payment].present? diff --git a/app/views/twitter/_index.html.erb b/app/views/twitter/_index.html.erb index 9825afa..3dab567 100644 --- a/app/views/twitter/_index.html.erb +++ b/app/views/twitter/_index.html.erb @@ -1,26 +1,24 @@ -<% unless Rails.application.secrets.twitter['enabled'] == false %> - <div class=twitter> + <div class="twitter"> <div class="twitter_header"> - Tweets by <%= @twitter_name %></p> + Tweets by <%= twitter_name %></p> </div> - <!-- <p><a href="/followers"> You have <%= @num_followers %> followers.</a></p> --> - <% @tweets.each do |e| %> - <div class=tweets> - <div class="tweets_pic twitter-image-frame"><%= image_tag("team-loadtocode-Loading_icon.gif") %></div> - <!-- <img class="tweets_pic"></img> --> - <div class=tweets_name> - @<%= @twitter_screen_name %> - </div> - <div class=tweet_text> - <%= " #{e.text}" %> - </div> - <div class=text_date> - <%= @tweet_time %> <% t = e.created_at%> <%="#{t.strftime("%m/%d/%Y")}"%> - </div> + <div class="twitter_list"> + <% tweets.each do |e| %> + <div class="tweet"> + <div class="tweet_pic twitter_image_frame"><%= image_tag("team-loadtocode-Loading_icon.gif") %></div> + <div class="tweet_name"> + @<%= twitter_handle %> + </div> + <div class="tweet_text"> + <%= " #{e.text}" %> + </div> + <div class="tweet_text_date"> + tweeted on <% t = e.created_at%> <%= t.strftime("%m/%d/%y").to_s %> + </div> + </div> + <% end %> </div> - <% end %> <div class="twitter_footer"> - To prevent leakage no links are displayed. For more information visit @<%= @twitter_name %> on twitter.com.</p> + To prevent leakage no links are displayed. For more information visit @<%= twitter_name %> on twitter.com.</p> </div> </div> - <% end %> diff --git a/config/routes.rb b/config/routes.rb index cb39dc6..b152c9c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,4 @@ LeapWeb::Application.routes.draw do - get 'twitter/index' - # # Please do not use root_path or root_url. Use home_path and home_url instead, # so that the path will be correctly prefixed with the locale. |