mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Work in Progress: Content Editing in Admin Section
This commit is contained in:
24
app/models/site_content.rb
Normal file
24
app/models/site_content.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
require_dependency 'site_content_type'
|
||||
require_dependency 'site_content_class_methods'
|
||||
|
||||
class SiteContent < ActiveRecord::Base
|
||||
extend SiteContentClassMethods
|
||||
|
||||
set_primary_key :content_type
|
||||
validates_presence_of :content
|
||||
|
||||
def self.formats
|
||||
@formats ||= Enum.new(:plain, :markdown, :html, :css)
|
||||
end
|
||||
|
||||
content_type :usage_tips, :markdown, default_18n_key: 'system_messages.usage_tips.text_body_template'
|
||||
content_type :welcome_user, :markdown, default_18n_key: 'system_messages.welcome_user.text_body_template'
|
||||
content_type :welcome_invite, :markdown, default_18n_key: 'system_messages.welcome_invite.text_body_template'
|
||||
content_type :education_new_topic, :markdown, default_18n_key: 'education.new-topic'
|
||||
content_type :education_new_reply, :markdown, default_18n_key: 'education.new-reply'
|
||||
|
||||
def site_content_type
|
||||
@site_content_type ||= SiteContent.content_types.find {|t| t.content_type == content_type.to_sym}
|
||||
end
|
||||
|
||||
end
|
||||
28
app/models/site_content_type.rb
Normal file
28
app/models/site_content_type.rb
Normal file
@@ -0,0 +1,28 @@
|
||||
require_dependency 'multisite_i18n'
|
||||
|
||||
class SiteContentType
|
||||
|
||||
attr_accessor :content_type, :format
|
||||
|
||||
def initialize(content_type, format, opts=nil)
|
||||
@opts = opts || {}
|
||||
@content_type = content_type
|
||||
@format = format
|
||||
end
|
||||
|
||||
def title
|
||||
I18n.t("content_types.#{content_type}.title")
|
||||
end
|
||||
|
||||
def description
|
||||
I18n.t("content_types.#{content_type}.description")
|
||||
end
|
||||
|
||||
def default_content
|
||||
if @opts[:default_18n_key].present?
|
||||
return MultisiteI18n.t(@opts[:default_18n_key])
|
||||
end
|
||||
""
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user