Add hide time fields setting file for create_link.

This commit is contained in:
BoHung Chiu 2023-01-07 10:26:01 +08:00
parent 3b9e5d1536
commit c901f08b33
1 changed files with 10 additions and 9 deletions

View File

@ -6,7 +6,7 @@ class Book
include OrbitModel::Status include OrbitModel::Status
include MemberHelper include MemberHelper
include Slug include Slug
HideTimeInLinK = (File.exist?("#{Rails.root}/hide_time_fields_for_plugins.txt") rescue false)
field :book_title, as: :slug_title, localize: true field :book_title, as: :slug_title, localize: true
field :extracted_chapters, type: String, localize: true field :extracted_chapters, type: String, localize: true
field :publisher, type: String, localize: true field :publisher, type: String, localize: true
@ -53,15 +53,16 @@ class Book
title << self.extracted_chapters if self.extracted_chapters.present? title << self.extracted_chapters if self.extracted_chapters.present?
title << self.publisher if self.publisher.present? title << self.publisher if self.publisher.present?
title << self.isbn if self.isbn.present? title << self.isbn if self.isbn.present?
if !self.publish_date.nil?
pd = self.publish_date.strftime("%Y-%m-%d").split('-')
title << pd[0]+"/"+pd[1]
end
title << self.pages if self.pages.present? title << self.pages if self.pages.present?
# title << self.year unless HideTimeInLinK
if self.publish_date
title << (self.publish_date.strftime("%b. %Y") rescue nil)
elsif self.publication_date
title << (self.publication_date.strftime("%b. %Y") rescue nil)
elsif self.year.present?
title << self.year
end
end
title.join(', ') title.join(', ')
end end