personal_writing/app/controllers/personal_writings_controlle...

43 lines
1.3 KiB
Ruby

class PersonalWritingsController < ApplicationController
def index
writings = Writing.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
writing_list = writings.collect do |writing|
{
"year" => writing.year,
"month" => writing.month,
"writing_title" => writing.writing_title,
"other" => writing.other,
"member" => (writing.member_profile.name rescue ""),
"link_to_show" => OrbitHelper.url_to_show(writing.to_param)
}
end
{
"writings" => writing_list,
"extras" => {
"widget-title" => t("module_name.personal_writing"),
"th_year" => t('personal_writing.year'),
"th_month" => t('personal_writing.month'),
"th_writing_title" => t('module_name.personal_writing'),
"th_other" => t('personal_writing.other'),
"th_member" => t('users.name'),
"th_detail" => t('detail')
},
"total_pages" => writings.total_pages
}
end
def show
params = OrbitHelper.params
plugin = Writing.where(:is_hidden=>false).find_by(uid: params[:uid])
fields_to_show = [
"year",
"month",
"writing_title",
"other",
"url",
"file"
]
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
end
end