Compare commits

...

2 Commits

Author SHA1 Message Date
BoHung Chiu 6c7d7ad339 Fix author text bug. 2023-10-03 00:16:54 +08:00
BoHung Chiu ffbf29d912 Fix indent. 2023-10-03 00:16:43 +08:00
1 changed files with 52 additions and 37 deletions

View File

@ -1,49 +1,64 @@
module Admin::PersonalBooksHelper
def get_authors_text(book)
def get_authors_text(book)
authors_text = Nokogiri::HTML(book.authors.to_s).text
split_text = authors_text.match(/[、,,\/]/)
split_text = split_text.nil? ? '/' : split_text[0]
full_authors_names = get_member(book).collect(&:name)
if authors_text.present?
authors_names = authors_text.split(split_text).select{|a| !(full_authors_names.include?(a.strip()))}
full_authors_names += authors_names
authors_names = authors_text.split(split_text)
else
authors_names = []
end
full_authors_names.join(split_text)
end
def get_authors_show(book)
authors_text = Nokogiri::HTML(book.authors.to_s).text
split_text = authors_text.match(/[、,,\/]/)
split_text = split_text.nil? ? '/' : split_text[0]
full_authors_names = []
full_authors = get_member(book).collect{|member|
full_authors_names = get_member(book).collect do |member|
member_name = member.name
full_authors_names << member_name
"<a href='#{OrbitHelper.url_to_plugin_show(member.to_param,'member')}' title='#{member_name}'>#{member_name}</a>"
}
if authors_text.present?
authors_names = authors_text.split(split_text).select{|a| !(full_authors_names.include?(a.strip()))}
full_authors += authors_names
idx = authors_names.index{|a| a.chomp('*') == member_name}
if idx
member_name = authors_names[idx]
authors_names[idx] = nil
end
member_name
end
full_authors_names += authors_names.compact
full_authors_names.join(split_text)
end
def get_authors_show(book)
authors_text = Nokogiri::HTML(book.authors.to_s).text
split_text = authors_text.match(/[、,,\/]/)
split_text = split_text.nil? ? '/' : split_text[0]
if authors_text.present?
authors_names = authors_text.split(split_text)
else
authors_names = []
end
full_authors = get_member(book).collect do |member|
member_name = member.name
idx = authors_names.index{|a| a.chomp('*') == member_name}
if idx
member_name = authors_names[idx]
authors_names[idx] = nil
end
"<a href='#{OrbitHelper.url_to_plugin_show(member.to_param,'member')}' title='#{member_name}'>#{member_name}</a>"
end
full_authors += authors_names.compact
full_authors.join(split_text)
end
def get_member(book)
Array(MemberProfile.where(:id.in=>Array(book).collect(&:member_profile_id).flatten))
end
def get_member_show(book)
get_member(book).collect{|member| "<a href='#{OrbitHelper.url_to_plugin_show(member.to_param,'member')}' title='#{member.name}'>#{member.name}</a>"}.join('/')
end
def get_publisher(book)
book.publisher
end
def get_author_type(book)
book.book_author_types.collect(&:title).join(', ') rescue ''
end
def get_paper_type(book)
!book.book_type.blank? ? book.book_type.title : nil
end
def get_publication_date(book)
book.publication_date.strftime('%Y/%m/%d') rescue ''
end
end
def get_member(book)
Array(MemberProfile.where(:id.in=>Array(book).collect(&:member_profile_id).flatten))
end
def get_member_show(book)
get_member(book).collect{|member| "<a href='#{OrbitHelper.url_to_plugin_show(member.to_param,'member')}' title='#{member.name}'>#{member.name}</a>"}.join('/')
end
def get_publisher(book)
book.publisher
end
def get_author_type(book)
book.book_author_types.collect(&:title).join(', ') rescue ''
end
def get_paper_type(book)
!book.book_type.blank? ? book.book_type.title : nil
end
def get_publication_date(book)
book.publication_date.strftime('%Y/%m/%d') rescue ''
end
def get_paper_list
user = current_user.nil? ? OrbitHelper.current_user : current_user
user_profile = user.member_profile