Update frontend

This commit is contained in:
manson 2014-08-01 19:47:43 +08:00
parent 9577859d45
commit 52b22f3f45
4 changed files with 49 additions and 20 deletions

View File

@ -26,26 +26,18 @@ class PersonalHonorsController < ApplicationController
def show
params = OrbitHelper.params
honor = Honor.where(:is_hidden=>false).find_by(uid: params[:uid])
plugin = Honor.where(:is_hidden=>false).find_by(uid: params[:uid])
fields_to_show = [
"award_name",
"honoree",
"awarding_unit",
"year",
"honor_type",
"keywords",
"url",
"note"
]
{
"year" => honor.year,
"honor_type" => honor.honor_type.title,
"award_name" => honor.award_name,
"awarding_unit" => honor.awarding_unit,
"language" => t(honor.language),
"keywords" => honor.keywords,
"url" => honor.url,
"note" => honor.note,
"th_year" => t("personal_honor.year"),
"th_honor_type" => t("personal_honor.honor_category"),
"th_award_name" => t("personal_honor.award_name"),
"th_awarding_unit" => t("personal_honor.awarding_unit"),
"th_language" => t("personal_honor.language"),
"th_keywords" => t("personal_honor.keywords"),
"th_url" => t("personal_honor.url"),
"th_note" => t("personal_honor.note")
}
{"plugin_datas"=>plugin.get_plugin_data(fields_to_show)}
end
end

View File

@ -26,6 +26,39 @@ class Honor
self.award_name+' '+self.awarding_unit
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 "honoree"
value = self.member_profile.name
when "language"
value = I18n.t(self.language) rescue ""
when "honor_type"
value = self.honor_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"=>"honor-#{field.gsub('_','-')}-field",
"value_class"=>"honor-#{field.gsub('_','-')}-value",
"title"=>I18n.t('personal_honor.'+field),
"value"=>value
}
end
protected
def add_http

View File

@ -8,8 +8,10 @@ en:
award_name : "Award Name"
awarding_unit : "Awarding Unit"
honor_category : "Honor Category"
honor_type: "Honor Category"
extracted_chapters : "Extracted Chapters"
publishers : "Publishers"
honoree: "Honoree"
authors : "Authors"
tags : "Tags"
year : "Year"

View File

@ -8,6 +8,8 @@ zh_tw:
award_name : "獎項名稱"
awarding_unit : "頒獎單位"
honor_category : "類別"
honor_type: "類別"
honoree: "受獎人"
authors : "作者"
tags : "領域"
year : "年度"