forked from saurabh/personal-project
Update frontend
This commit is contained in:
parent
40eea87a01
commit
26418ef119
|
@ -1,6 +1,6 @@
|
||||||
class PersonalProjectsController < ApplicationController
|
class PersonalProjectsController < ApplicationController
|
||||||
def index
|
def index
|
||||||
projects = Project.where(:is_hidden=>false).order_by(:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
projects = Project.where(:is_hidden=>false).order_by(:period_start_date=>'desc',:year=>'desc').page(OrbitHelper.params[:page_no]).per(OrbitHelper.page_data_count)
|
||||||
project_list = projects.collect do |project|
|
project_list = projects.collect do |project|
|
||||||
{
|
{
|
||||||
"duration" => project.duration,
|
"duration" => project.duration,
|
||||||
|
@ -27,49 +27,66 @@ class PersonalProjectsController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
params = OrbitHelper.params
|
params = OrbitHelper.params
|
||||||
project = Project.where(:is_hidden=>false).find_by(uid: params[:uid])
|
plugin = Project.where(:is_hidden=>false).find_by(uid: params[:uid])
|
||||||
|
fields_to_show = [
|
||||||
|
"project_title",
|
||||||
|
"project_type",
|
||||||
|
"job_title",
|
||||||
|
"participator",
|
||||||
|
"unit",
|
||||||
|
"year",
|
||||||
|
"language",
|
||||||
|
"keywords",
|
||||||
|
"abstract",
|
||||||
|
"period",
|
||||||
|
"url",
|
||||||
|
"note",
|
||||||
|
"file"
|
||||||
|
]
|
||||||
|
|
||||||
files = project.project_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 = project.project_files.map do |file|
|
||||||
"files" => files,
|
# {
|
||||||
|
# "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
|
||||||
|
|
||||||
"data" => {
|
# {
|
||||||
"project_title" => project.project_title,
|
# "files" => files,
|
||||||
"project_type" => project.project_type.title,
|
|
||||||
"job_title" => project.job_title,
|
|
||||||
"participator" => project.participator,
|
|
||||||
"unit" => project.unit,
|
|
||||||
"year" => project.year,
|
|
||||||
"language" => project.language,
|
|
||||||
"keywords" => project.keywords,
|
|
||||||
"abstract" => project.abstract,
|
|
||||||
"duration" => project.duration,
|
|
||||||
"url" => project.url,
|
|
||||||
"note" => project.note,
|
|
||||||
|
|
||||||
"th_project_title" => t("personal_project.project_title"),
|
# "data" => {
|
||||||
"th_job_title" => t("personal_project.job_title"),
|
# "project_title" => project.project_title,
|
||||||
"th_participator" => t("personal_project.participator"),
|
# "project_type" => project.project_type.title,
|
||||||
"th_unit" => t("personal_project.unit"),
|
# "job_title" => project.job_title,
|
||||||
"th_year" => t("personal_project.year"),
|
# "participator" => project.participator,
|
||||||
"th_language" => t("personal_project.language"),
|
# "unit" => project.unit,
|
||||||
"th_keywords" => t("personal_project.keywords"),
|
# "year" => project.year,
|
||||||
"th_abstract" => t("personal_project.abstract"),
|
# "language" => project.language,
|
||||||
"th_duration" => t("personal_project.period"),
|
# "keywords" => project.keywords,
|
||||||
"th_url" => t("personal_project.url"),
|
# "abstract" => project.abstract,
|
||||||
"th_note" => t("personal_project.note"),
|
# "duration" => project.duration,
|
||||||
|
# "url" => project.url,
|
||||||
|
# "note" => project.note,
|
||||||
|
|
||||||
"th_project_type" => t("personal_project.project_category"),
|
# "th_project_title" => t("personal_project.project_title"),
|
||||||
"th_files" => t(:file_)
|
# "th_job_title" => t("personal_project.job_title"),
|
||||||
}
|
# "th_participator" => t("personal_project.participator"),
|
||||||
}
|
# "th_unit" => t("personal_project.unit"),
|
||||||
|
# "th_year" => t("personal_project.year"),
|
||||||
|
# "th_language" => t("personal_project.language"),
|
||||||
|
# "th_keywords" => t("personal_project.keywords"),
|
||||||
|
# "th_abstract" => t("personal_project.abstract"),
|
||||||
|
# "th_duration" => t("personal_project.period"),
|
||||||
|
# "th_url" => t("personal_project.url"),
|
||||||
|
# "th_note" => t("personal_project.note"),
|
||||||
|
|
||||||
|
# "th_project_type" => t("personal_project.project_category"),
|
||||||
|
# "th_files" => t(:file_)
|
||||||
|
# }
|
||||||
|
# }
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -34,7 +34,48 @@ class Project
|
||||||
before_validation :add_http
|
before_validation :add_http
|
||||||
|
|
||||||
def duration
|
def duration
|
||||||
"#{self.period_start_date.strftime("%Y.%m")} ~ #{self.period_end_date.strftime("%Y.%m")}"
|
"#{self.period_start_date.strftime("%Y.%m") rescue ""} ~ #{self.period_end_date.strftime("%Y.%m") rescue ""}"
|
||||||
|
end
|
||||||
|
|
||||||
|
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 "project_type"
|
||||||
|
value = self.project_type.title rescue ""
|
||||||
|
when "period"
|
||||||
|
value = self.duration
|
||||||
|
when "file"
|
||||||
|
files = []
|
||||||
|
self.project_files.each do |project_file|
|
||||||
|
url = project_file.file.url
|
||||||
|
title = (project_file.title.blank? ? File.basename(project_file.file.path) : project_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"=>"project-#{field.gsub('_','-')}-field",
|
||||||
|
"value_class"=>"project-#{field.gsub('_','-')}-value",
|
||||||
|
"title"=>I18n.t('personal_project.'+field),
|
||||||
|
"value"=>value
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
|
@ -6,6 +6,7 @@ en:
|
||||||
job_title : "Job Title"
|
job_title : "Job Title"
|
||||||
participator : "Participartor"
|
participator : "Participartor"
|
||||||
project_category : "Project Category"
|
project_category : "Project Category"
|
||||||
|
project_type: "Project Category"
|
||||||
period : "Period"
|
period : "Period"
|
||||||
end_date : "End Date"
|
end_date : "End Date"
|
||||||
start_date : "Start Date"
|
start_date : "Start Date"
|
||||||
|
|
|
@ -7,6 +7,7 @@ zh_tw:
|
||||||
participator : "參與人"
|
participator : "參與人"
|
||||||
extracted_chapters : "Extracted Chapters"
|
extracted_chapters : "Extracted Chapters"
|
||||||
project_category : "計畫類別"
|
project_category : "計畫類別"
|
||||||
|
project_type : "計畫類別"
|
||||||
period : "計畫期間"
|
period : "計畫期間"
|
||||||
end_date : "結束日期"
|
end_date : "結束日期"
|
||||||
start_date : "開始日期"
|
start_date : "開始日期"
|
||||||
|
|
Loading…
Reference in New Issue