From d994a4fe7871ae01fa0e28a6e430287f1bc3546a Mon Sep 17 00:00:00 2001 From: Harry Bomrah Date: Wed, 9 Aug 2017 18:35:21 +0800 Subject: [PATCH] added a epaper list --- app/controllers/e_papers_controller.rb | 20 ++++++++++++++++++++ lib/e_paper/engine.rb | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/app/controllers/e_papers_controller.rb b/app/controllers/e_papers_controller.rb index 237d589..db8767a 100644 --- a/app/controllers/e_papers_controller.rb +++ b/app/controllers/e_papers_controller.rb @@ -91,6 +91,26 @@ class EPapersController < ApplicationController {} end + def widget + tags = OrbitHelper.widget_tags + papers = Paper.filter_by_widget_categories.filter_by_tags(tags).collect do |paper| + paper_thumb = !paper.image.nil? && !paper.image.url.nil? ? paper.image.thumb.url : "http://www.placehold.it/400x400/EFEFEF/AAAAAA" + { + "title" => paper.title, + "date" => paper.period, + "description" => paper.description, + "image_thumb" => paper_thumb, + "link_to_show" => OrbitHelper.url_to_show(paper.to_param) + } + end + { + "papers" => papers, + "extras" => { + "more_url" => OrbitHelper.widget_more_url + } + } + end + def subscribeuser if Subscriber.where(:email => params[:email]).count == 0 subscriber = Subscriber.new diff --git a/lib/e_paper/engine.rb b/lib/e_paper/engine.rb index a93671a..0bf6b05 100644 --- a/lib/e_paper/engine.rb +++ b/lib/e_paper/engine.rb @@ -4,7 +4,7 @@ module EPaper OrbitApp.registration "EPaper", :type => "ModuleApp" do module_label "e_paper.e_paper" base_url File.expand_path File.dirname(__FILE__) - widget_methods ['subscriber_widget'] + widget_methods ['subscriber_widget', 'widget'] widget_settings [{"data_count"=>10}] taggable "Paper" categorizable