Update frontend
This commit is contained in:
parent
582757864b
commit
f92689293e
|
@ -26,41 +26,55 @@ class PersonalResearchesController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
research = Research.where(:is_hidden=>false).find_by(uid: params[:uid])
|
plugin = Research.where(:is_hidden=>false).find_by(uid: params[:uid])
|
||||||
|
fields_to_show =[
|
||||||
|
"research_title",
|
||||||
|
"authors",
|
||||||
|
"extracted_chapters",
|
||||||
|
"year",
|
||||||
|
"language",
|
||||||
|
"publish_date",
|
||||||
|
"keywords",
|
||||||
|
"url",
|
||||||
|
"note",
|
||||||
|
"file"
|
||||||
|
]
|
||||||
|
|
||||||
files = research.research_files.map do |file|
|
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
|
||||||
{
|
|
||||||
"file_url" => file.file.url,
|
|
||||||
"file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title),
|
|
||||||
"file_ext" => File.extname(file.file.path).sub('.',''),
|
|
||||||
"file_description" => file.description
|
|
||||||
}
|
|
||||||
end
|
|
||||||
|
|
||||||
{
|
# files = research.research_files.map do |file|
|
||||||
"files" => files,
|
# {
|
||||||
"data" => {
|
# "file_url" => file.file.url,
|
||||||
"research_title" => research.research_title,
|
# "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title),
|
||||||
"authors" => research.authors,
|
# "file_ext" => File.extname(file.file.path).sub('.',''),
|
||||||
"extracted_chapters" => research.extracted_chapters,
|
# "file_description" => file.description
|
||||||
"year" => research.year,
|
# }
|
||||||
"language" => t(research.language),
|
# end
|
||||||
"publish_date" => (research.publish_date.strftime("%Y.%m") rescue ""),
|
|
||||||
"keywords" => research.keywords,
|
|
||||||
"url" => research.url,
|
|
||||||
"note" => research.note,
|
|
||||||
|
|
||||||
"th_research_title" => t("personal_research.research_title"),
|
# {
|
||||||
"th_authors" => t("personal_research.authors"),
|
# "files" => files,
|
||||||
"th_extracted_chapters" => t("personal_research.extracted_chapters"),
|
# "data" => {
|
||||||
"th_year" => t("personal_research.year"),
|
# "research_title" => research.research_title,
|
||||||
"th_language" => t("personal_research.language"),
|
# "authors" => research.authors,
|
||||||
"th_publish_date" => t("personal_research.publication_date"),
|
# "extracted_chapters" => research.extracted_chapters,
|
||||||
"th_keywords" => t("personal_research.keywords"),
|
# "year" => research.year,
|
||||||
"th_url" => t("personal_research.url"),
|
# "language" => t(research.language),
|
||||||
"th_note" => t("personal_research.note"),
|
# "publish_date" => (research.publish_date.strftime("%Y.%m") rescue ""),
|
||||||
"th_files" => t(:file_)
|
# "keywords" => research.keywords,
|
||||||
}
|
# "url" => research.url,
|
||||||
}
|
# "note" => research.note,
|
||||||
|
|
||||||
|
# "th_research_title" => t("personal_research.research_title"),
|
||||||
|
# "th_authors" => t("personal_research.authors"),
|
||||||
|
# "th_extracted_chapters" => t("personal_research.extracted_chapters"),
|
||||||
|
# "th_year" => t("personal_research.year"),
|
||||||
|
# "th_language" => t("personal_research.language"),
|
||||||
|
# "th_publish_date" => t("personal_research.publication_date"),
|
||||||
|
# "th_keywords" => t("personal_research.keywords"),
|
||||||
|
# "th_url" => t("personal_research.url"),
|
||||||
|
# "th_note" => t("personal_research.note"),
|
||||||
|
# "th_files" => t(:file_)
|
||||||
|
# }
|
||||||
|
# }
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -28,6 +28,45 @@ class Research
|
||||||
|
|
||||||
before_validation :add_http
|
before_validation :add_http
|
||||||
|
|
||||||
|
def get_plugin_data(fields_to_show)
|
||||||
|
plugin_datas = []
|
||||||
|
fields_to_show.each do |field|
|
||||||
|
plugin_data = self.get_plugin_field_data(field)
|
||||||
|
next if plugin_data.blank? or plugin_data['value'].blank?
|
||||||
|
plugin_datas << plugin_data
|
||||||
|
end
|
||||||
|
plugin_datas
|
||||||
|
end
|
||||||
|
|
||||||
|
def get_plugin_field_data(field)
|
||||||
|
case field
|
||||||
|
when "language"
|
||||||
|
value = I18n.t(self.language) rescue ""
|
||||||
|
when "publish_date"
|
||||||
|
value = self.publish_date.strftime("%Y-%m") rescue ""
|
||||||
|
when "file"
|
||||||
|
files = []
|
||||||
|
self.research_files.each do |research_file|
|
||||||
|
url = research_file.file.url
|
||||||
|
title = (research_file.title.blank? ? File.basename(research_file.file.path) : research_file.title)
|
||||||
|
files << "<li><a href='#{url}'' target='_blank'>#{title}</li>"
|
||||||
|
end
|
||||||
|
value = files.join("")
|
||||||
|
else
|
||||||
|
value = self.send(field) rescue ""
|
||||||
|
end
|
||||||
|
|
||||||
|
value = (value =~ /\A#{URI::regexp(['http', 'https'])}\z/) ? "<a href='#{value}' target='blank'>#{value}</a>" : value
|
||||||
|
|
||||||
|
{
|
||||||
|
"key"=>field,
|
||||||
|
"title_class"=>"research-#{field.gsub('_','-')}-field",
|
||||||
|
"value_class"=>"research-#{field.gsub('_','-')}-value",
|
||||||
|
"title"=>I18n.t('personal_research.'+field),
|
||||||
|
"value"=>value
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def add_http
|
def add_http
|
||||||
|
|
|
@ -19,6 +19,7 @@ en:
|
||||||
keywords : "Keywords"
|
keywords : "Keywords"
|
||||||
abstract : "Abstract"
|
abstract : "Abstract"
|
||||||
publication_date : "Date of Publication"
|
publication_date : "Date of Publication"
|
||||||
|
publish_date: "Publish Date"
|
||||||
url : "Reference URL"
|
url : "Reference URL"
|
||||||
note : "Note"
|
note : "Note"
|
||||||
level_type : "Level Type"
|
level_type : "Level Type"
|
||||||
|
|
|
@ -19,6 +19,7 @@ zh_tw:
|
||||||
keywords : "關鍵字"
|
keywords : "關鍵字"
|
||||||
abstract : "摘要"
|
abstract : "摘要"
|
||||||
publication_date : "發表日期"
|
publication_date : "發表日期"
|
||||||
|
publish_date: "發表日期"
|
||||||
url : "參考連結"
|
url : "參考連結"
|
||||||
note : "記事"
|
note : "記事"
|
||||||
level_type : "期刊類別"
|
level_type : "期刊類別"
|
||||||
|
|
Loading…
Reference in New Issue