personal_writing/app/controllers/personal_writings_controlle...

47 lines
1.4 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,
"writing_title" => writing.writing_title,
"location" => writing.location,
"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_writing_title" => t('module_name.personal_writing'),
"th_location" => t('personal_writing.location'),
"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",
"writing_title",
"location",
"participating_professor",
"participating_student",
"research_direction",
"facility",
"keywords",
"extension_no",
"url",
"note",
"file"
]
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
end
end