This commit is contained in:
Anitha Palanisamy 2017-01-31 13:57:04 +00:00 committed by GitHub
commit f1e37df5a0
21 changed files with 264 additions and 3 deletions

View file

@ -45,6 +45,7 @@
//= require osem-commercials
//= require unobtrusive_flash
//= require unobtrusive_flash_bootstrap
//= require refresh_current_events
$(document).ready(function() {
$('a[disabled=disabled]').click(function(event){

View file

@ -0,0 +1,32 @@
$(document).ready(function() {
// will call refreshCurrentEvents every 15 minutes
setInterval(refreshCurrentEvents,900000);
// Only show the first child of tweet and sponsor containers on page load
$('#tweet-container').children().hide();
$('#tweet-container').children().eq(0).show();
$('#sponsor-container').children().hide();
$('#sponsor-container').children().eq(0).show();
setInterval(function(){ cycleVisibleElement($('#tweet-container'))}, 5000)
setInterval(function(){ cycleVisibleElement($('#sponsor-container'))}, 10000)
});
// Makes an ajax call for fresh data
function refreshCurrentEvents(){
$.ajax({
url: "conference_info.js"
});
};
// Cycle through children in a container and toggles visibility
function cycleVisibleElement(container){
var childrens = $(container).children();
for(var i = 0; i < childrens.length; i++ ){
if(childrens.eq(i).is(":visible")){
childrens.eq(i).hide();
childrens.eq(++i % childrens.length).show();
return
}
}
};

View file

@ -90,3 +90,20 @@ p.comment-body {
.changeset{
display: none;
}
#conference-header{
margin: auto;
width: 304px;
.conference-heading{
float: left;
width: 150px;
}
.conference-logo{
float: left;
width: 150px;
img{
width: 100px;
height: 100px;
}
}
}

View file

@ -173,8 +173,25 @@ module Admin
end
end
def conference_info
# To display sponsors in the conference wide information page
@sponsors = @conference.sponsors
@tweets = twitter_client.search_tweets(15, @conference.contact.social_tag)
@current_event_schedules = @program.selected_schedule.event_schedules.current.group_by{|es| es.event.track.name}
respond_to do |format|
format.html{render layout: 'conference_info'}
format.js {render action: 'conference_info.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,
:start_date, :end_date, :rooms_attributes, :tracks_attributes,

View file

@ -14,6 +14,7 @@ class EventSchedule < ActiveRecord::Base
scope :confirmed, -> { joins(:event).where('state = ?', 'confirmed') }
scope :canceled, -> { joins(:event).where('state = ?', 'canceled') }
scope :withdrawn, -> { joins(:event).where('state = ?', 'withdrawn') }
scope :current, -> { where('start_time <= ?', Time.current).select{ |es| es.end_time >= Time.current }}
delegate :guid, to: :room, prefix: true

View file

@ -0,0 +1,21 @@
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)
@client.search(search_term, result_type: 'recent').take(no_of_tweets).collect
rescue
nil
end
end

View file

@ -0,0 +1,13 @@
.container
.row
.col-md-12.text-center
%h2
= "##{@conference.contact.social_tag} Tweets"
%div#tweet-container
- @tweets.each do |tweet|
%div#tweet
%blockquote.twitter-tweet
%p{:lang => "en"}
= tweet.text
= link_to "— @" + tweet.user.name, "http://www.twitter.com/#{tweet.user.name}", target: "_blank"
= link_to tweet.url, tweet.url.to_s

View file

@ -0,0 +1,14 @@
.container
.row.row-centered
- @current_event_schedules.each do |track, event_schedules|
.col-md-4.col-sm-4.col-centered
%h2.text-center
= track
- event_schedules.each do |event_schedule|
%h3.text-center
= event_schedule.event.title
%h4.text-center
presented by
= event_schedule.event.speaker_names
in
= event_schedule.event.room.name

View file

@ -0,0 +1,12 @@
.container
.row
.col-md-12.text-center
%h2 Sponsors
%div#sponsor-container
- @conference.sponsorship_levels.each do |sponsorship_level|
-if sponsorship_level.sponsors.any?
- sponsorship_level.sponsors.each_slice(3) do |slice|
.row.row-centered#sponsor
- 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

@ -0,0 +1,23 @@
.container
- if @conference.present?
.row
.col-md-12.text-center
%div#conference-header
%div.conference-logo
= image_tag(@conference.picture_url, class: 'img-responsive') if @conference.picture?
%div.conference-heading
%h1
= @conference.title
%span
= @conference.short_title
- if @conference.description.present?
%h3
= @conference.description
- if @current_event_schedules.present?
.row#current-events
= render 'current_events'
- if @conference.contact.social_tag.present? && @tweets.any?
.row#conference-tweets
= render 'conference_tweets'
- if @sponsors.any?
= render 'sponsors'

View file

@ -0,0 +1,4 @@
$('#current-events').html("#{escape_javascript(render 'current_events', data: @current_events)}");
$('#conference-tweets').html("#{escape_javascript(render 'conference_tweets', data: @tweets)}");
$('#tweet-container').children().hide();
$('#tweet-container').children().eq(0).show();

View file

@ -139,3 +139,9 @@
= link_to(admin_conference_roles_path(@conference.short_title)) do
%span.fa.fa-group
Roles
- if can? :show, @conference
%li{:class=> active_nav_li(conference_info_admin_conference_path(@conference.short_title))}
= link_to(conference_info_admin_conference_path(@conference.short_title)) do
%span.fa.fa-expand
Conference Info

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