# == Schema Information
#
# Table name: page_themes
#
#  id             :integer          not null, primary key
#  name           :string(255)      not null
#  language_frame :integer          default("0")
#  image_url      :string(255)
#  clone_url      :string(255)      not null
#  order_index    :integer          default("0")
#  created_at     :datetime         not null
#  updated_at     :datetime         not null
#

class PageTheme < ApplicationRecord
    enum language_frame: { hugo: 0, jeklly: 1, hexo: 2, files:3}
    validates :name, presence: {message: "主题名不能为空"}, uniqueness: {message: "主题名已存在",scope: :language_frame},length: {maximum: 255}

  def image
    page_image_url('image')
  end
  private

  def page_image_url(type)
    return nil unless Util::FileManage.exists?(self, type)
    Util::FileManage.source_disk_file_url(self, type)
  end

end
