class EPapersController < ApplicationController def index params = OrbitHelper.params page = Page.where(:page_id => params[:page_id]).first rescue nil papers = Paper.can_display.order_by(:order_position => "asc").filter_by_categories f = papers.collect do |paper| statuses = paper.statuses_with_classname.collect do |status| { "status" => status["name"], "status-class" => "status-#{status['classname']}" } end topics = paper.topics.collect do |topic| { "episode" => topic.episode, "content" => topic.content, "publish_date" => topic.created_at } end { "link_to_show" => OrbitHelper.url_to_show(paper.to_param), "title" => paper.title, "period" => paper.period, "description" => paper.description, "category" => paper.category.title, "topic" => topics } end { "papers" => f, "extras" => { "widget-title"=>"EPaper", "th_title" => t('e_paper.title'), "th_category" => t('category'), "th_period" => t('e_paper.period'), "th_description" => t('e_paper.description'), "th_history" => t('e_paper.history'), "th_intro" => t('e_paper.intro'), "th_episode" => t('e_paper.topic_name'), "date" => t('e_paper.date') }, "total_pages" => papers.total_pages } end def show params = OrbitHelper.params paper = Paper.find_by(:uid => params[:uid]) topics = paper.topics.collect do |topic| desc = ActionView::Base.full_sanitizer.sanitize(topic.content) { "link_to_show" => OrbitHelper.url_to_show(topic.to_param) + "?method=showtopic", "episode" => topic.episode, "content" => topic.content, "description" => desc[0..100], "publish_date" => topic.created_at } end { "data" => { "title" => paper.title, "period" => paper.period, "description" => paper.description, "category" => paper.category.title, "publish_date" => paper.created_at, "th_title" => t('e_paper.title'), "th_category" => t('category'), "th_period" => t('e_paper.period'), "th_description" => t('e_paper.description'), "th_history" => t('e_paper.history'), "th_intro" => t('e_paper.intro'), "th_episode" => t('e_paper.topic_name'), "date" => t('e_paper.date'), }, "topics" => topics } end def subscriber_widget {} end def subscribeuser if Subscriber.where(:email => params[:email]).count == 0 subscriber = Subscriber.new subscriber.email = params[:email] subscriber.save data = {"success" => true, "msg" => "Successfully Subscribed!!!"} else data = {"success" => false, "msg" => "Already Subscribed!!!"} end render :json => data.to_json end def unsubscribeuser subscriber = Subscriber.where(:email => params[:email]).first rescue nil if !subscriber.nil? subscriber.destroy data = {"success" => true, "msg" => "Successfully Unsubscribed!!!"} # else # data = {"success" => false, "msg" => "Already Subscribed!!!"} end render :json => data.to_json end def showtopic params = OrbitHelper.params topic = Topic.where(:uid => params[:uid]).first { "episode" => topic.episode, "content" => topic.content, "publish_date" => topic.created_at } end private def sub_params params.require(:subscriber).permit! end end