forked from saurabh/personal-journal
54 lines
2.2 KiB
Ruby
54 lines
2.2 KiB
Ruby
class JournalPapersController < ApplicationController
|
|
def index
|
|
journal_papers = JournalPaper.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
|
journal_paper_list = journal_papers.collect do |journal_paper|
|
|
{
|
|
"year" => journal_paper.year,
|
|
"paper_title" => journal_paper.paper_title,
|
|
"author" => journal_paper.authors,
|
|
"link_to_show" => OrbitHelper.url_to_show(journal_paper.to_param)
|
|
}
|
|
end
|
|
{
|
|
"journal_papers" => journal_paper_list,
|
|
"extras" => {
|
|
"widget-title" => t("module_name.journal_paper"),
|
|
"th_year" => t('personal_plugins.year'),
|
|
"th_title" => t("personal_conference.paper_title"),
|
|
"th_author" => t('personal_plugins.author')
|
|
},
|
|
"total_pages" => journal_papers.total_pages
|
|
}
|
|
end
|
|
|
|
def show
|
|
params = OrbitHelper.params
|
|
journal_paper = JournalPaper.find_by(uid: params[:uid])
|
|
field_to_show = ["year", "language", "vol_no", "issue_no", "form_to_start", "form_to_end", "total_pages", "isbn", "publication_date", "url", "note", "journal_title", "paper_title", "updated_at", "created_at", "uid", "journal_level_ids", "journal_paper_author_type_ids", "member_profile_id"]
|
|
|
|
publication_date = journal_paper.publication_date.to_date.strftime("%Y/%m/%d") rescue nil
|
|
files = journal_paper.journal_paper_files.map{|file| { "file_url" => file.journal_file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title) } } rescue []
|
|
{
|
|
"journal_paper_files" => files,
|
|
"data" => {
|
|
"title" => journal_paper.paper_title,
|
|
"journal_title" => journal_paper.journal_title,
|
|
"year" => journal_paper.year,
|
|
"authors" => journal_paper.authors,
|
|
"isbn" => journal_paper.isbn,
|
|
"vol_no" => journal_paper.vol_no,
|
|
"issue_no" => journal_paper.issue_no,
|
|
"form_to_start" => journal_paper.form_to_start,
|
|
"form_to_end" => journal_paper.form_to_end,
|
|
"language" => journal_paper.language,
|
|
"total_pages" => journal_paper.total_pages,
|
|
"keywords" => journal_paper.keywords,
|
|
"abstract" => journal_paper.abstract,
|
|
"publication_date" => publication_date,
|
|
"url" => journal_paper.url,
|
|
"note" => journal_paper.note
|
|
}
|
|
}
|
|
end
|
|
end
|