From abf910d210ffa722ca4c4f69daa95aaedd8b396f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Thu, 2 Jan 2014 16:22:04 +0100 Subject: [PATCH] FEATURE: allow for custom HTML inside the tags --- .../templates/site_content_edit.js.handlebars | 54 +++++++++---------- .../stylesheets/common/admin/admin_base.scss | 6 ++- app/models/site_content.rb | 6 +-- app/models/site_content_type.rb | 7 +-- app/views/layouts/application.html.erb | 2 + app/views/layouts/no_js.html.erb | 1 + config/locales/server.en.yml | 5 +- 7 files changed, 41 insertions(+), 40 deletions(-) diff --git a/app/assets/javascripts/admin/templates/site_content_edit.js.handlebars b/app/assets/javascripts/admin/templates/site_content_edit.js.handlebars index 491019ca67f..5d3cdae712e 100644 --- a/app/assets/javascripts/admin/templates/site_content_edit.js.handlebars +++ b/app/assets/javascripts/admin/templates/site_content_edit.js.handlebars @@ -1,32 +1,26 @@ +

{{model.title}}

+

{{model.description}}

-

{{model.title}}

-

{{model.description}}

+{{#if model.markdown}} + {{pagedown value=model.content}} +{{/if}} +{{#if model.plainText}} + {{textarea value=model.content class="plain"}} +{{/if}} +{{#if model.html}} + {{aceEditor content=model.content mode="html"}} +{{/if}} +{{#if model.css}} + {{aceEditor content=model.content mode="css"}} +{{/if}} - {{#if model.markdown}} - {{pagedown value=model.content}} - {{/if}} - - {{#if model.plainText}} - {{textarea value=model.content class="plain"}} - {{/if}} - - {{#if model.html}} - {{aceEditor content=model.content mode="html"}} - {{/if}} - - {{#if model.css}} - {{aceEditor content=model.content mode="css"}} - {{/if}} - - - -
- - {{#if saved}}{{i18n saved}}{{/if}} -
+
+ + {{#if saved}}{{i18n saved}}{{/if}} +
diff --git a/app/assets/stylesheets/common/admin/admin_base.scss b/app/assets/stylesheets/common/admin/admin_base.scss index 836a9e23ec6..27cc5f56dfd 100644 --- a/app/assets/stylesheets/common/admin/admin_base.scss +++ b/app/assets/stylesheets/common/admin/admin_base.scss @@ -32,6 +32,10 @@ td {border-bottom: 1px solid #ddd; border-top: 1px solid #ddd;} p { margin-left: 6px; } + + .ace-wrapper { + height: 400px; + } } table.report { @@ -957,4 +961,4 @@ table.api-keys { .modal-tab { width: 95%; } -} \ No newline at end of file +} diff --git a/app/models/site_content.rb b/app/models/site_content.rb index e8aa741a4f1..71d899ea50d 100644 --- a/app/models/site_content.rb +++ b/app/models/site_content.rb @@ -20,9 +20,9 @@ class SiteContent < ActiveRecord::Base add_content_type :login_required_welcome_message, default_18n_key: 'login_required.welcome_message' add_content_type :privacy_policy, allow_blank: true add_content_type :faq, allow_blank: true - add_content_type :top, allow_blank: true - add_content_type :bottom, allow_blank: true - + add_content_type :top, allow_blank: true, format: :html + add_content_type :bottom, allow_blank: true, format: :html + add_content_type :head, allow_blank: true, format: :html def site_content_type @site_content_type ||= SiteContent.content_types.find {|t| t.content_type == content_type.to_sym} diff --git a/app/models/site_content_type.rb b/app/models/site_content_type.rb index 5ba91888c87..1b825accce8 100644 --- a/app/models/site_content_type.rb +++ b/app/models/site_content_type.rb @@ -21,10 +21,7 @@ class SiteContentType end def default_content - if @opts[:default_18n_key].present? - return I18n.t(@opts[:default_18n_key]) - end - "" + @opts[:default_18n_key].present? ? I18n.t(@opts[:default_18n_key]) : "" end -end \ No newline at end of file +end diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 6568a400cdc..a2aeb8553e3 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -25,6 +25,8 @@ <%= discourse_csrf_tags %> + <%= raw SiteContent.content_for(:head) %> + <%= yield :head %> diff --git a/app/views/layouts/no_js.html.erb b/app/views/layouts/no_js.html.erb index bd9da09fc1f..871230b50f0 100644 --- a/app/views/layouts/no_js.html.erb +++ b/app/views/layouts/no_js.html.erb @@ -10,6 +10,7 @@ <%= render :partial => "common/special_font_face" %> <%= render :partial => "common/discourse_stylesheet" %> <%= discourse_csrf_tags %> + <%= raw SiteContent.content_for(:head) %> <%- unless customization_disabled? %> diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index d4372debbb5..d87eba7b1ae 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -499,9 +499,12 @@ en: login_required: title: "Login Required: Homepage" description: "The text displayed for unauthorized users when login is required on the site." + head: + title: "HTML head" + description: "HTML that will be inserted inside the tags" top: title: "Top of the pages" - description: "HTML that will be added at the top of every pages (after the header, before the navigation or the topic title)" + description: "HTML that will be added at the top of every pages (after the header, before the navigation or the topic title)." bottom: title: "Bottom of the pages" description: "HTML that will be added at the bottom of every pages"