From 4bf8548dc5419a0917cc8e4d2e1f3ff411cc2ad8 Mon Sep 17 00:00:00 2001 From: Pat David Date: Fri, 5 May 2017 18:08:18 -0400 Subject: [PATCH] Add embed class name setup for embeddable hosts --- .../javascripts/admin/components/embeddable-host.js.es6 | 2 +- .../admin/templates/components/embeddable-host.hbs | 4 ++++ app/assets/javascripts/admin/templates/embedding.hbs | 7 ++++--- app/controllers/admin/embeddable_hosts_controller.rb | 1 + app/models/embeddable_host.rb | 1 + app/serializers/embeddable_host_serializer.rb | 2 +- config/locales/client.en.yml | 1 + .../20170505_add_embed_class_name_to_embeddable_hosts.rb | 5 +++++ 8 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20170505_add_embed_class_name_to_embeddable_hosts.rb diff --git a/app/assets/javascripts/admin/components/embeddable-host.js.es6 b/app/assets/javascripts/admin/components/embeddable-host.js.es6 index 2a5d7c030b4..70c1ed272cf 100644 --- a/app/assets/javascripts/admin/components/embeddable-host.js.es6 +++ b/app/assets/javascripts/admin/components/embeddable-host.js.es6 @@ -30,7 +30,7 @@ export default Ember.Component.extend(bufferedProperty('host'), { save() { if (this.get('cantSave')) { return; } - const props = this.get('buffered').getProperties('host', 'path_whitelist'); + const props = this.get('buffered').getProperties('host', 'path_whitelist', 'class_name'); props.category_id = this.get('categoryId'); const host = this.get('host'); diff --git a/app/assets/javascripts/admin/templates/components/embeddable-host.hbs b/app/assets/javascripts/admin/templates/components/embeddable-host.hbs index 5f2581138f5..f4367abefff 100644 --- a/app/assets/javascripts/admin/templates/components/embeddable-host.hbs +++ b/app/assets/javascripts/admin/templates/components/embeddable-host.hbs @@ -2,6 +2,9 @@ {{input value=buffered.host placeholder="example.com" enter="save" class="host-name"}} + + {{input value=buffered.class_name placeholder="class" enter="save" class="class-name"}} + {{input value=buffered.path_whitelist placeholder="/blog/.*" enter="save" class="path-whitelist"}} @@ -14,6 +17,7 @@ {{else}} {{host.host}} + {{host.class_name}} {{host.path_whitelist}} {{category-badge host.category}} diff --git a/app/assets/javascripts/admin/templates/embedding.hbs b/app/assets/javascripts/admin/templates/embedding.hbs index 965e663c776..752f7a920db 100644 --- a/app/assets/javascripts/admin/templates/embedding.hbs +++ b/app/assets/javascripts/admin/templates/embedding.hbs @@ -2,9 +2,10 @@ {{#if embedding.embeddable_hosts}} - - - + + + + {{#each embedding.embeddable_hosts as |host|}} diff --git a/app/controllers/admin/embeddable_hosts_controller.rb b/app/controllers/admin/embeddable_hosts_controller.rb index 7f15c9fd05e..60d24a310c9 100644 --- a/app/controllers/admin/embeddable_hosts_controller.rb +++ b/app/controllers/admin/embeddable_hosts_controller.rb @@ -22,6 +22,7 @@ class Admin::EmbeddableHostsController < Admin::AdminController def save_host(host) host.host = params[:embeddable_host][:host] host.path_whitelist = params[:embeddable_host][:path_whitelist] + host.class_name = params[:embeddable_host][:class_name] host.category_id = params[:embeddable_host][:category_id] host.category_id = SiteSetting.uncategorized_category_id if host.category_id.blank? diff --git a/app/models/embeddable_host.rb b/app/models/embeddable_host.rb index 1bcd29af021..e87623af9b4 100644 --- a/app/models/embeddable_host.rb +++ b/app/models/embeddable_host.rb @@ -57,4 +57,5 @@ end # created_at :datetime # updated_at :datetime # path_whitelist :string +# class_name :string # diff --git a/app/serializers/embeddable_host_serializer.rb b/app/serializers/embeddable_host_serializer.rb index 61cf16e694d..e99ce6d4b67 100644 --- a/app/serializers/embeddable_host_serializer.rb +++ b/app/serializers/embeddable_host_serializer.rb @@ -1,6 +1,6 @@ class EmbeddableHostSerializer < ApplicationSerializer - TO_SERIALIZE = [:id, :host, :path_whitelist, :category_id] + TO_SERIALIZE = [:id, :host, :path_whitelist, :class_name, :category_id] attributes *TO_SERIALIZE diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index e431d969cec..ac8138342af 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -3465,6 +3465,7 @@ en: sample: "Use the following HTML code into your site to create and embed discourse topics. Replace REPLACE_ME with the canonical URL of the page you are embedding it on." title: "Embedding" host: "Allowed Hosts" + class_name: "Class Name" path_whitelist: "Path Whitelist" edit: "edit" category: "Post to Category" diff --git a/db/migrate/20170505_add_embed_class_name_to_embeddable_hosts.rb b/db/migrate/20170505_add_embed_class_name_to_embeddable_hosts.rb new file mode 100644 index 00000000000..a2f6c5e5593 --- /dev/null +++ b/db/migrate/20170505_add_embed_class_name_to_embeddable_hosts.rb @@ -0,0 +1,5 @@ +class AddEmbedClassNameToEmbeddableHosts < ActiveRecord::Migration + def change + add_column :embeddable_hosts, :class_name, :string + end +end
{{i18n "admin.embedding.host"}}{{i18n "admin.embedding.path_whitelist"}}{{i18n "admin.embedding.category"}}{{i18n "admin.embedding.host"}}{{i18n "admin.embedding.class_name"}}{{i18n "admin.embedding.path_whitelist"}}{{i18n "admin.embedding.category"}}