personal-journal1/app/controllers/journal_papers_controller.rb

44 lines
1.5 KiB
Ruby

class JournalPapersController < ApplicationController
def index
journal_papers = JournalPaper.asc(:created_at)
journal_paper_list = journal_papers.collect do |journal_paper|
{
"paper_title" => journal_paper.paper_title,
"authors" => journal_paper.authors,
"link_to_show" => OrbitHelper.url_to_show(journal_paper.to_param)
}
end
{
"journal_papers" => journal_paper_list,
"extras" => {"widget-title" => "Journal Papers"}
}
end
def show
params = OrbitHelper.params
journal_paper = JournalPaper.find_by(uid: params[:uid])
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" => journal_paper.publication_date.to_date.strftime("%Y/%m/%d"),
"url" => journal_paper.url,
"note" => journal_paper.note
}
}
end
end