twitter gem and a partial added to embed tweets about a conference and new layout added for conference info screen

This commit is contained in:
AnithaPal 2016-07-20 15:11:50 -04:00
parent febd3451ad
commit f29a15b8e4
11 changed files with 216 additions and 28 deletions

View file

@ -183,9 +183,10 @@ gem 'dotenv-rails'
gem 'faker'
# for seeds
gem 'factory_girl_rails'
# for integrating Stripe payment gateway
gem 'stripe'
#For embedding tweets
gem 'twitter'
# Use guard and spring for testing in development
group :development do

View file

@ -82,6 +82,7 @@ GEM
bootstrap3-datetimepicker-rails (3.0.3)
momentjs-rails (>= 2.8.1)
browser (0.6.0)
buftok (0.2.0)
builder (3.2.2)
byebug (3.1.2)
columnize (~> 0.8)
@ -167,6 +168,7 @@ GEM
dotenv-rails (2.1.1)
dotenv (= 2.1.1)
railties (>= 4.0, < 5.1)
equalizer (0.0.10)
erubis (2.7.0)
execjs (2.6.0)
factory_girl (4.5.0)
@ -214,8 +216,15 @@ GEM
activesupport
builder
htmlentities (4.3.4)
http (1.0.4)
addressable (~> 2.3)
http-cookie (~> 1.0)
http-form_data (~> 1.0.1)
http_parser.rb (~> 0.6.0)
http-cookie (1.0.2)
domain_name (~> 0.5)
http-form_data (1.0.1)
http_parser.rb (0.6.0)
i18n (0.7.0)
i18n_data (0.7.0)
inversion (0.12.3)
@ -253,6 +262,8 @@ GEM
lumberjack (1.0.5)
mail (2.6.3)
mime-types (>= 1.16, < 3)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
method_source (0.8.2)
mime-types (2.99.1)
mina (0.3.8)
@ -277,6 +288,7 @@ GEM
multi_xml (0.5.5)
multipart-post (2.0.0)
mysql2 (0.4.2)
naught (1.1.0)
netrc (0.11.0)
nio4r (1.2.1)
nokogiri (1.6.8)
@ -462,6 +474,7 @@ GEM
sprockets-rails (~> 2.0)
shoulda-matchers (2.6.1)
activesupport (>= 3.0.0)
simple_oauth (0.3.1)
simplecov (0.11.2)
docile (~> 1.1.0)
json (~> 1.8)
@ -502,6 +515,17 @@ GEM
ttfunk (1.1.1)
turbolinks (2.5.3)
coffee-rails
twitter (5.16.0)
addressable (~> 2.3)
buftok (~> 0.2.0)
equalizer (= 0.0.10)
faraday (~> 0.9.0)
http (~> 1.0)
http_parser.rb (~> 0.6.0)
json (~> 1.8)
memoizable (~> 0.4.0)
naught (~> 1.0)
simple_oauth (~> 0.3.0)
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (3.0.0)
@ -630,6 +654,7 @@ DEPENDENCIES
timecop
transitions
turbolinks
twitter
uglifier (>= 1.3.0)
unobtrusive_flash (>= 3)
web-console (~> 2.0)

View file

@ -8,6 +8,7 @@
*= require osem-schedule-print
*= require osem-dashboard
*= require osem-splash
*= require osem-conference-wide-screen
*= require font-awesome
*= require osem-fonts
*= require bootstrap-markdown

View file

@ -0,0 +1,77 @@
@import "breakpoints.css.scss";
html {
position: relative;
min-height: 100%;
}
body {
/* Margin bottom by 2 times the footer height */
// margin-bottom: 60px;
/* Margin bottom by navbar height */
padding-top: 10px;
}
#main-display {
// Counter the general padding for #content
// margin-bottom: -60px;
section {
padding: 10px;
}
#main-heading {
position: absolute;
top: 0;
width: 100%;
height: 120px;
background-color: #abcdef;
}
#event-display{
position: absolute;
bottom:480px;
width: 100%;
top: 120px;
background-color: #00FF00;
}
#tweets-display {
position: absolute;
height: 150px;
bottom: 330px;
width: 100%;
background-color: #F63;
}
#sponsor-display {
position: absolute;
bottom: 0;
width: 100%;
max-height: 330px;
background-color: #FF1493;
.container {
background-color: yellow;
max-height: 310px;
}
.img-sponsor {
max-height: 50px;
margin: 2% auto;
}
.img-sponsor-1 {
max-height: 90px;
}
.img-sponsor-2 {
max-height: 70px;
}
.img-sponsor-3 {
max-height: 50px;
}
@include breakpoint(xs) {
.img-sponsor, .img-sponsor-1, .img-sponsor-3, .img-sponsor-3{
max-height: unset;
max-width: 280px;
}
}
}
}

View file

@ -179,14 +179,19 @@ module Admin
@sponsors = @conference.sponsors
@program = @conference.program
@current_events = @conference.program.events.confirmed.select{ |event| event.is_current?}
@tweets = twitter_client.search_tweets(3, @conference.contact.social_tag)
respond_to do |format|
format.html
format.js {render :action=>"conference_wide_screen.js.haml"}
format.html{render layout: "conference_wide_screen"}
format.js {render :action=> "conference_wide_screen.js.haml"}
end
end
private
# To create a twitter client
def twitter_client
@twitter_client ||= TwitterWrapper.new
end
def conference_params
params.require(:conference).permit(:title, :short_title, :description, :timezone,

View file

@ -0,0 +1,25 @@
class TwitterWrapper
attr_accessor :client
def initialize
@client = Twitter::REST::Client.new do |config|
config.consumer_key = ENV["OSEM_TWITTER_CONSUMER_KEY"]
config.consumer_secret = ENV["OSEM_TWITTER_CONSUMER_SECRET"]
config.access_token = ENV["OSEM_TWITTER_ACCESS_TOKEN"]
config.access_token_secret = ENV["OSEM_TWITTER_ACCESS_TOKEN_SECRET"]
end
end
##
#Fetches tweets from twitter api based on search_term and no_of_tweets
#
def search_tweets(no_of_tweets, search_term)
begin
@client.search(search_term, result_type: "recent").take(no_of_tweets).collect
rescue Twitter::Error::TooManyRequests => error
sleep error.rate_limit.reset_in + 1
retry
end
end
end

View file

@ -0,0 +1,8 @@
.container
.row
.col-md-12.text-center
%h2 Conference Tweets
- @tweets.each do |tweet|
%div#tweet
= tweet.user.name
= tweet.text

View file

@ -1,9 +1,13 @@
.text-center
%h2 Upcoming Events
- @current_events.each do |event|
%div
%h3
= link_to event.title, conference_program_proposal_path(@conference.short_title, event.id)
%h4
presented by
= event.speaker_names
.container
.row
.col-md-12.text-center
%h2 Current Events
- @current_events.each do |event|
%div
%h3
= event.title
%h4
presented by
= event.speaker_names
in
= event.room.name

View file

@ -0,0 +1,11 @@
.container
.row
.col-md-12.text-center
%h2 Sponsors
- @conference.sponsorship_levels.each do |sponsorship_level|
-if sponsorship_level.sponsors.any?
- sponsorship_level.sponsors.each_slice(3) do |slice|
.row.row-centered
- slice.each do |sponsor|
.col-md-4.col-sm-4.col-centered.col-top
= image_tag get_logo(sponsor), class: "img-responsive img-sponsor img-sponsor-#{sponsorship_level.position}"

View file

@ -1,15 +1,21 @@
.container
- if @conference.present?
.row
.col-md-12
- if @program.present?
%section#program#current-events
= render 'current_events'
.row
.col-md-12.text-center
%h2 Tweets About Conference
.row
.col-md-12
- if @sponsors.any?
%section#sponsors
= render 'conference/sponsors'
#main-display
- if @conference.present?
%section#main-heading
.container
.row
.col-md-12.text-center
%h1
= @conference.title
- if @conference.description.present?
%h3
= @conference.description
- if @program.present?
%section#event-display
= render 'current_events'
- if @conference.contact.social_tag.present?
%section#tweets-display
- if @tweets.present?
= render 'conference_tweets'
- if @sponsors.any?
%section#sponsor-display
= render 'sponsors'

View file

@ -0,0 +1,25 @@
%html{:xmlns => "http://www.w3.org/1999/html"}
%head
%meta{:charset => "utf-8"}
%meta{:name => "viewport", :content => "width=device-width, initial-scale=1, maximum-scale=1"}
%title= content_for?(:title) ? yield(:title) : (ENV['OSEM_NAME'] || 'OSEM')
%meta{:content => "", :name => "description"}
%meta{:content => "", :name => "author"}
= stylesheet_link_tag "application", :media => "all"
= javascript_include_tag "application"
= csrf_meta_tags
:javascript
window.liveSettings = {
api_key: "#{ENV['OSEM_TRANSIFEX_APIKEY']}",
picker: "bottom-right",
detectlang: true,
autocollect: true
};
= content_for(:script_head)
= javascript_include_tag "//cdn.transifex.com/live.js"
= yield(:head)
%body
.container
= yield