updates from Production version

This commit is contained in:
Lee Lawlor
2014-05-15 16:42:47 -04:00
parent f7b4a3fcce
commit c240b89ed0
10 changed files with 151 additions and 101 deletions

View File

@ -1,11 +1,19 @@
class ChannelsController < ApplicationController
include ChannelsHelper, ApiKeys
before_filter :require_user, :except => [ :show, :post_data, :social_show, :social_feed, :public]
before_filter :require_user, :except => [:realtime, :realtime_update, :show, :post_data, :social_show, :social_feed, :public]
before_filter :set_channels_menu
layout 'application', :except => [:social_show, :social_feed]
protect_from_forgery :except => [:post_data, :create, :destroy, :clear]
protect_from_forgery :except => [:realtime, :realtime_update, :post_data, :create, :destroy, :clear]
require 'csv'
# get list of all realtime channels
def realtime
# error if no key
respond_with_error(:error_auth_required) and return if params[:realtime_key] != REALTIME_DAEMON_KEY
channels = Channel.where("realtime_io_serial_number IS NOT NULL")
render :json => channels.to_json(:root => false, :only => [:id, :realtime_io_serial_number])
end
# view list of watched channels
def watched
@channels = current_user.watched_channels
@ -235,6 +243,33 @@ class ChannelsController < ApplicationController
end
end
# post from realtime.io daemon
def realtime_update
# exit if not authenticated
respond_with_error(:error_auth_required) and return if params[:realtime_key] != REALTIME_DAEMON_KEY
# set feed and channel
feed = Feed.new
channel = Channel.find(params[:id])
# update entry_id for channel and feed
entry_id = channel.next_entry_id
channel.last_entry_id = entry_id
feed.entry_id = entry_id
# set user agent
channel.user_agent = 'realtime.io'
# set feed details
feed.channel_id = channel.id
feed.status = params[:status]
# save channel and feed
channel.save
feed.save
render :nothing => true
end
# response is '0' if failure, 'entry_id' if success
def post_data

View File

@ -54,11 +54,11 @@ class StreamController < ApplicationController
def stream_example
# get the channel
channel = Channel.find(params[:channel_id])
#channel = Channel.find(params[:channel_id])
# stream the response
response.headers['Content-Type'] = 'text/csv'
response.headers['Content-Disposition'] = 'attachment; filename=feeds.csv'
#response.headers['Content-Type'] = 'text/csv'
#response.headers['Content-Disposition'] = 'attachment; filename=feeds.csv'
20.times {
response.stream.write "hello world\n"
sleep 1