Fix bug(data split in index). Add paper criteria filter for index page.
This commit is contained in:
parent
103ea0311b
commit
75bec0fe3d
|
@ -1,27 +1,85 @@
|
||||||
class EPapersController < ApplicationController
|
class EPapersController < ApplicationController
|
||||||
FrontendMethods = ["papers", "topics"]
|
FrontendMethods = ["papers", "topics"]
|
||||||
|
EmptyImg = "data:image/gif;base64,R0lGODlhAQABAAAAACwAAAAAAQABAAA="
|
||||||
|
EmptyImgUrl = "#{EmptyImg}\" style=\"display: none;"
|
||||||
|
def self.custom_widget_data
|
||||||
|
ac = ActionController::Base.new
|
||||||
|
ac.render_to_string("e_papers/custom_widget_data",:locals=>{:@custom_data_field=>@custom_data_field,:@field_name=>@field_name})
|
||||||
|
end
|
||||||
def index
|
def index
|
||||||
topics = EPaperTopic.filter_by_categories.filter_by_tags.desc(:period)
|
page_no = OrbitHelper.page_number
|
||||||
data = topics.collect do |topic|
|
data_count = OrbitHelper.page_data_count
|
||||||
|
page = (OrbitHelper.page rescue Page.where(:url=>params[:url]).first)
|
||||||
|
page_layout = page.layout
|
||||||
|
custom_data_field = page.custom_data_field
|
||||||
|
if custom_data_field
|
||||||
|
criteria_id = (custom_data_field["criteria_id"] || "all" rescue "all")
|
||||||
|
epaper_topics = nil
|
||||||
|
if criteria_id == "all"
|
||||||
|
epaper_topics = EPaperTopic.all
|
||||||
|
else
|
||||||
|
criteria = PaperCriteria.where(:id => criteria_id).first
|
||||||
|
epaper_topics = criteria.epaper_topics
|
||||||
|
end
|
||||||
|
else
|
||||||
|
epaper_topics = EPaperTopic.all
|
||||||
|
criteria = nil
|
||||||
|
end
|
||||||
|
topics = epaper_topics.filter_by_categories.filter_by_tags.desc(:period).page(page_no).per(data_count)
|
||||||
|
total_pages = topics.total_pages
|
||||||
|
page_url = page.get_url rescue page.url
|
||||||
|
if page_layout.include?("_latest")
|
||||||
|
topics_group = topics.group_by(&:category)
|
||||||
|
data = topics_group.collect do |category, topics|
|
||||||
|
category_title = (category ? category.title : "")
|
||||||
|
topics_data = topics.collect do |topic|
|
||||||
|
{
|
||||||
|
"title" => topic.title,
|
||||||
|
"criteria_title" => topic.criteria_title,
|
||||||
|
"link_to_show" => OrbitHelper.url_to_show(topic.to_param),
|
||||||
|
"description" => topic.description,
|
||||||
|
"img_url" => topic.image.url || EmptyImgUrl,
|
||||||
|
"img_url_thumb" => topic.image.thumb.url || EmptyImgUrl,
|
||||||
|
"category" => category_title,
|
||||||
|
"category_title" => category_title,
|
||||||
|
"publish_date" => topic.period
|
||||||
|
}
|
||||||
|
end
|
||||||
|
{
|
||||||
|
"category_title" => category_title,
|
||||||
|
"category_link" => "#{page_url}?method=topics&category=#{category.id.to_s}",
|
||||||
|
"topics" => topics_data
|
||||||
|
}
|
||||||
|
end
|
||||||
{
|
{
|
||||||
"title" => topic.title,
|
"categories" => data,
|
||||||
"criteria_title" => topic.criteria_title,
|
"extras" => {
|
||||||
"link_to_show" => OrbitHelper.url_to_show(topic.to_param),
|
|
||||||
"description" => topic.description,
|
},
|
||||||
"img_url" => topic.image.url,
|
"total_pages" => total_pages
|
||||||
"img_url_thumb" => topic.image.thumb.url,
|
}
|
||||||
"category" => (topic.category.title rescue ""),
|
else
|
||||||
"category_title" => (topic.category.title rescue ""),
|
data = topics.to_a.collect do |topic|
|
||||||
"publish_date" => topic.period
|
{
|
||||||
|
"title" => topic.title,
|
||||||
|
"criteria_title" => topic.criteria_title,
|
||||||
|
"link_to_show" => OrbitHelper.url_to_show(topic.to_param),
|
||||||
|
"description" => topic.description,
|
||||||
|
"img_url" => topic.image.url || EmptyImgUrl,
|
||||||
|
"img_url_thumb" => topic.image.thumb.url || EmptyImgUrl,
|
||||||
|
"category" => (topic.category.title rescue ""),
|
||||||
|
"category_title" => (topic.category.title rescue ""),
|
||||||
|
"publish_date" => topic.period
|
||||||
|
}
|
||||||
|
end
|
||||||
|
{
|
||||||
|
"topics" => data,
|
||||||
|
"extras" => {
|
||||||
|
|
||||||
|
},
|
||||||
|
"total_pages" => total_pages
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
{
|
|
||||||
"topics" => data,
|
|
||||||
"extras" => {
|
|
||||||
|
|
||||||
},
|
|
||||||
"total_pages" => (topics.count * 1.0 / OrbitHelper.page_data_count).ceil
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def papers
|
def papers
|
||||||
|
@ -58,8 +116,8 @@ class EPapersController < ApplicationController
|
||||||
"content" => epaper.content,
|
"content" => epaper.content,
|
||||||
"publish_date" => epaper.period,
|
"publish_date" => epaper.period,
|
||||||
"description" => epaper.description,
|
"description" => epaper.description,
|
||||||
"image_url" => epaper.image.url,
|
"image_url" => epaper.image.url || EmptyImgUrl,
|
||||||
"image_thumb_url" => epaper.image.thumb.url,
|
"image_thumb_url" => epaper.image.thumb.url || EmptyImgUrl,
|
||||||
"title" => epaper.title,
|
"title" => epaper.title,
|
||||||
"category_title" => epaper.category.title,
|
"category_title" => epaper.category.title,
|
||||||
"criteria_title" => epaper.criteria_title,
|
"criteria_title" => epaper.criteria_title,
|
||||||
|
@ -71,11 +129,17 @@ class EPapersController < ApplicationController
|
||||||
|
|
||||||
def topics
|
def topics
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
criteria = PaperCriteria.where(:uid => params[:uid]).first
|
if params[:uid].present?
|
||||||
if params["category"].present?
|
criteria = PaperCriteria.where(:uid => params[:uid]).first
|
||||||
papers = criteria.epaper_topics.where(:category_id => params["category"]).group_by(&:category)
|
return if criteria.nil?
|
||||||
|
epaper_topics = criteria.epaper_topics
|
||||||
else
|
else
|
||||||
papers = criteria.epaper_topics.group_by(&:category)
|
epaper_topics = EPaperTopic.all
|
||||||
|
end
|
||||||
|
if params["category"].present?
|
||||||
|
papers = epaper_topics.where(:category_id => params["category"]).group_by(&:category)
|
||||||
|
else
|
||||||
|
papers = epaper_topics.group_by(&:category)
|
||||||
end
|
end
|
||||||
data = []
|
data = []
|
||||||
papers_sorted = get_all_categories.map do |v|
|
papers_sorted = get_all_categories.map do |v|
|
||||||
|
@ -92,8 +156,8 @@ class EPapersController < ApplicationController
|
||||||
"title" => topic.title,
|
"title" => topic.title,
|
||||||
"link_to_show" => OrbitHelper.url_to_show(topic.to_param),
|
"link_to_show" => OrbitHelper.url_to_show(topic.to_param),
|
||||||
"description" => topic.description,
|
"description" => topic.description,
|
||||||
"img_url" => topic.image.url,
|
"img_url" => topic.image.url || EmptyImgUrl,
|
||||||
"img_url_thumb" => topic.image.thumb.url,
|
"img_url_thumb" => topic.image.thumb.url || EmptyImgUrl,
|
||||||
"category" => category.title
|
"category" => category.title
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -151,8 +215,8 @@ class EPapersController < ApplicationController
|
||||||
"title" => topic.title,
|
"title" => topic.title,
|
||||||
"link_to_show" => OrbitHelper.widget_item_url(topic.to_param),
|
"link_to_show" => OrbitHelper.widget_item_url(topic.to_param),
|
||||||
"description" => topic.description,
|
"description" => topic.description,
|
||||||
"img_url" => topic.image.url,
|
"img_url" => topic.image.url || EmptyImgUrl,
|
||||||
"img_url_thumb" => topic.image.thumb.url,
|
"img_url_thumb" => topic.image.thumb.url || EmptyImgUrl,
|
||||||
"category" => (topic.category.title rescue nil),
|
"category" => (topic.category.title rescue nil),
|
||||||
"link_to_show_wise" => OrbitHelper.widget_more_url + "/" + topic.to_param
|
"link_to_show_wise" => OrbitHelper.widget_more_url + "/" + topic.to_param
|
||||||
}
|
}
|
||||||
|
@ -183,8 +247,8 @@ class EPapersController < ApplicationController
|
||||||
"title" => topic.title,
|
"title" => topic.title,
|
||||||
"link_to_show" => OrbitHelper.widget_item_url(topic.to_param),
|
"link_to_show" => OrbitHelper.widget_item_url(topic.to_param),
|
||||||
"description" => topic.description,
|
"description" => topic.description,
|
||||||
"img_url" => topic.image.url,
|
"img_url" => topic.image.url || EmptyImgUrl,
|
||||||
"img_url_thumb" => topic.image.thumb.url,
|
"img_url_thumb" => topic.image.thumb.url || EmptyImgUrl,
|
||||||
"category" => (category.title rescue nil)
|
"category" => (category.title rescue nil)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -220,8 +284,8 @@ class EPapersController < ApplicationController
|
||||||
"title" => topic.title,
|
"title" => topic.title,
|
||||||
"link_to_show" => OrbitHelper.widget_item_url(topic.to_param),
|
"link_to_show" => OrbitHelper.widget_item_url(topic.to_param),
|
||||||
"description" => topic.description,
|
"description" => topic.description,
|
||||||
"img_url" => topic.image.url,
|
"img_url" => topic.image.url || EmptyImgUrl,
|
||||||
"img_url_thumb" => topic.image.thumb.url,
|
"img_url_thumb" => topic.image.thumb.url || EmptyImgUrl,
|
||||||
"category" => (category.title rescue nil)
|
"category" => (category.title rescue nil)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
<% if @field_name == "page" %>
|
||||||
|
<div id="e_papers_data">
|
||||||
|
<div class="control-group input-content">
|
||||||
|
<label class="control-label muted" for="criteria_id"><%=t("e_paper.criteria_title")%> :</label>
|
||||||
|
<div class="controls">
|
||||||
|
<%= select_tag("#{@field_name}[custom_data_field][criteria_id]", options_for_select(([[t("e_paper.all_criteria"), "all"]] + PaperCriteria.all.desc(:start_date).map{|criteria| [criteria.title, criteria.id.to_s]}), (@custom_data_field["criteria_id"] rescue nil)), :id=>"criteria_id" )%>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
|
@ -4,6 +4,7 @@ en:
|
||||||
restful_actions:
|
restful_actions:
|
||||||
batch_delete_subscribers: "Batch Delete Subscribers"
|
batch_delete_subscribers: "Batch Delete Subscribers"
|
||||||
e_paper:
|
e_paper:
|
||||||
|
all_criteria: All Issue
|
||||||
show_progress: "Show Progress"
|
show_progress: "Show Progress"
|
||||||
delete_subscribers_hint2: "Delete Subscribers below forever."
|
delete_subscribers_hint2: "Delete Subscribers below forever."
|
||||||
delete_subscribers_hint1: "Do you realy want to delete Subscribers you added forever?"
|
delete_subscribers_hint1: "Do you realy want to delete Subscribers you added forever?"
|
||||||
|
@ -32,7 +33,7 @@ en:
|
||||||
published: "Published"
|
published: "Published"
|
||||||
subscribers: Subscribers
|
subscribers: Subscribers
|
||||||
test_mail: Send Test Email
|
test_mail: Send Test Email
|
||||||
paper_criteria: ePaper Issue
|
paper_criteria: EPaper Issue
|
||||||
criteria_title: Issue Title
|
criteria_title: Issue Title
|
||||||
date_span: Article Date Range
|
date_span: Article Date Range
|
||||||
new_criteria: New Issue
|
new_criteria: New Issue
|
||||||
|
|
|
@ -4,6 +4,7 @@ zh_tw:
|
||||||
restful_actions:
|
restful_actions:
|
||||||
batch_delete_subscribers: "批次刪除訂閱者"
|
batch_delete_subscribers: "批次刪除訂閱者"
|
||||||
e_paper:
|
e_paper:
|
||||||
|
all_criteria: 所有電子報
|
||||||
show_progress: "顯示進度"
|
show_progress: "顯示進度"
|
||||||
delete_subscribers_hint2: "永久刪除以下訂閱者"
|
delete_subscribers_hint2: "永久刪除以下訂閱者"
|
||||||
delete_subscribers_hint1: "您確定真的要永久刪除所選的訂閱者嗎?"
|
delete_subscribers_hint1: "您確定真的要永久刪除所選的訂閱者嗎?"
|
||||||
|
|
|
@ -18,7 +18,7 @@ module EPaper
|
||||||
base_url File.expand_path File.dirname(__FILE__)
|
base_url File.expand_path File.dirname(__FILE__)
|
||||||
#widget_methods ["criteria_list","category_wise_articles","latest_criteria", "latest_slider", "subscribe"]
|
#widget_methods ["criteria_list","category_wise_articles","latest_criteria", "latest_slider", "subscribe"]
|
||||||
widget_methods ["widget"]
|
widget_methods ["widget"]
|
||||||
widget_settings [{"data_count"=>30}]
|
widget_settings [{"data_count"=>30, "enable_custom_widget_data"=>true}]
|
||||||
taggable "EPaperCriteria"
|
taggable "EPaperCriteria"
|
||||||
categorizable
|
categorizable
|
||||||
authorizable
|
authorizable
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
<%= javascript_include_tag "plugin/owl.carousel.min.js"%>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/assets/template/owl.carousel.min.css">
|
|
||||||
<link rel="stylesheet" type="text/css" href="/assets/template/owl.theme.default.min.css">
|
|
||||||
|
|
||||||
<div class="latest_slider" data-list="categories" data-level="0">
|
<div class="latest_slider" data-list="categories" data-level="0">
|
||||||
<div class="banner-Container owl-carousel owl-theme" data-list="topics" data-level="1">
|
<div class="banner-Container owl-carousel owl-theme" data-list="topics" data-level="1">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
|
|
|
@ -1,7 +1,3 @@
|
||||||
<%= javascript_include_tag "plugin/owl.carousel.min.js"%>
|
|
||||||
<link rel="stylesheet" type="text/css" href="/assets/template/owl.carousel.min.css">
|
|
||||||
<link rel="stylesheet" type="text/css" href="/assets/template/owl.theme.default.min.css">
|
|
||||||
|
|
||||||
<div class="latest-fullslider" data-list="categories" data-level="0">
|
<div class="latest-fullslider" data-list="categories" data-level="0">
|
||||||
<div class="banner-Container owl-carousel owl-theme" data-list="topics" data-level="1">
|
<div class="banner-Container owl-carousel owl-theme" data-list="topics" data-level="1">
|
||||||
<div class="item">
|
<div class="item">
|
||||||
|
|
|
@ -20,3 +20,5 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{pagination_goes_here}}
|
|
@ -27,3 +27,4 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{{pagination_goes_here}}
|
|
@ -0,0 +1,20 @@
|
||||||
|
<div class="latest-criteria epaper-index2" data-list="categories" data-level="0">
|
||||||
|
<h3><a href="{{category_link}}">{{category_title}}</a></h3>
|
||||||
|
<div data-list="topics" data-level="1">
|
||||||
|
<div class='epaper-index2-container row'>
|
||||||
|
<h4>
|
||||||
|
<a href="{{link_to_show}}">{{title}}</a>
|
||||||
|
<a href="{{link_to_show}}"><span>{{category_title}}</span></a>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<div class="epaper-leftimg col-lg-5 col-xs-12">
|
||||||
|
<img src="{{img_url_thumb}}" alt="{{title}}">
|
||||||
|
</div>
|
||||||
|
<div class="epaper-rightContent col-lg-7 col-xs-12" >
|
||||||
|
<div class="epaper-description"><a href="{{link_to_show}}">{{description}}</a></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{{pagination_goes_here}}
|
|
@ -12,7 +12,15 @@
|
||||||
"filename" : "epaper_index2",
|
"filename" : "epaper_index2",
|
||||||
"name" : {
|
"name" : {
|
||||||
"zh_tw" : "2. 電子報列表-title",
|
"zh_tw" : "2. 電子報列表-title",
|
||||||
"en" : "1. Thumbnail ( widget-title, question )"
|
"en" : "2. Thumbnail ( widget-title, question )"
|
||||||
|
},
|
||||||
|
"thumbnail" : "thumb.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"filename" : "epaper_index2_latest",
|
||||||
|
"name" : {
|
||||||
|
"zh_tw" : "3. 電子報列表-latest",
|
||||||
|
"en" : "3. Thumbnail ( widget-title, question )"
|
||||||
},
|
},
|
||||||
"thumbnail" : "thumb.png"
|
"thumbnail" : "thumb.png"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue