Update frontend

This commit is contained in:
manson 2014-08-01 19:47:16 +08:00
parent 48eb11cca9
commit 8aa42bd5a1
4 changed files with 70 additions and 25 deletions

View File

@ -28,32 +28,44 @@ class PersonalExperiencesController < ApplicationController
def show def show
params = OrbitHelper.params params = OrbitHelper.params
experience = Experience.where(:is_hidden=>false).find_by(uid: params[:uid]) plugin = Experience.where(:is_hidden=>false).find_by(uid: params[:uid])
{ fields_to_show = [
"organizationt_title" => experience.organizationt_title, "organizationt_title",
"department" => experience.department, "department",
"job_title" => experience.job_title, "job_title",
"experience_type" => (experience.experience_type.title rescue ""), "experience_type",
"language" => t(experience.language), "duration",
"start_date" => experience.start_date, "keywords",
"end_date" => experience.end_date, "url",
"duration" => experience.duration, "note"
"keywords" => experience.keywords, ]
"url" => experience.url,
"note" => experience.note,
"th_organizationt_title" =>t("personal_experience.organizationt_title") , {"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
"th_department" =>t("personal_experience.department") , # {
"th_job_title" =>t("personal_experience.job_title") , # "organizationt_title" => experience.organizationt_title,
"th_experience_type" =>t("personal_experience.experience_category") , # "department" => experience.department,
"th_language" =>t("personal_experience.language") , # "job_title" => experience.job_title,
"th_start_date" =>t("personal_experience.start_date") , # "experience_type" => (experience.experience_type.title rescue ""),
"th_end_date" =>t("personal_experience.end_date") , # "language" => t(experience.language),
"th_duration" =>t("personal_experience.duration") , # "start_date" => experience.start_date,
"th_keywords" =>t("personal_experience.keywords") , # "end_date" => experience.end_date,
"th_url" =>t("personal_experience.url") , # "duration" => experience.duration,
"th_note" =>t("personal_experience.note") # "keywords" => experience.keywords,
} # "url" => experience.url,
# "note" => experience.note,
# "th_organizationt_title" =>t("personal_experience.organizationt_title") ,
# "th_department" =>t("personal_experience.department") ,
# "th_job_title" =>t("personal_experience.job_title") ,
# "th_experience_type" =>t("personal_experience.experience_category") ,
# "th_language" =>t("personal_experience.language") ,
# "th_start_date" =>t("personal_experience.start_date") ,
# "th_end_date" =>t("personal_experience.end_date") ,
# "th_duration" =>t("personal_experience.duration") ,
# "th_keywords" =>t("personal_experience.keywords") ,
# "th_url" =>t("personal_experience.url") ,
# "th_note" =>t("personal_experience.note")
# }
end end
end end

View File

@ -37,6 +37,37 @@ class Experience
[self.organizationt_title,self.department,self.job_title].join(' ') [self.organizationt_title,self.department,self.job_title].join(' ')
end 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 "experience_type"
value = self.experience_type.title rescue ""
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"=>"experience-#{field.gsub('_','-')}-field",
"value_class"=>"experience-#{field.gsub('_','-')}-value",
"title"=>I18n.t('personal_experience.'+field),
"value"=>value
}
end
protected protected
def add_http def add_http

View File

@ -4,6 +4,7 @@ en:
personal_experience: personal_experience:
department : "Department" department : "Department"
experience_category : "Experience Category" experience_category : "Experience Category"
experience_type: "Experience Category"
organizationt_title : "Organization Title" organizationt_title : "Organization Title"
paper_title : "Paper Title" paper_title : "Paper Title"
book_title : "Book Title" book_title : "Book Title"

View File

@ -4,6 +4,7 @@ zh_tw:
personal_experience: personal_experience:
department : "單位" department : "單位"
experience_category : 經歷類別 experience_category : 經歷類別
experience_type: 經歷類別
end_date : "結束日期" end_date : "結束日期"
start_date : "開始日期" start_date : "開始日期"
duration: "期間" duration: "期間"