Add embed class name setup for embeddable hosts

This commit is contained in:
Pat David 2017-05-05 18:08:18 -04:00 committed by Robin Ward
parent 9b84cd832c
commit 4bf8548dc5
8 changed files with 18 additions and 5 deletions

View File

@ -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');

View File

@ -2,6 +2,9 @@
<td>
{{input value=buffered.host placeholder="example.com" enter="save" class="host-name"}}
</td>
<td>
{{input value=buffered.class_name placeholder="class" enter="save" class="class-name"}}
</td>
<td>
{{input value=buffered.path_whitelist placeholder="/blog/.*" enter="save" class="path-whitelist"}}
</td>
@ -14,6 +17,7 @@
</td>
{{else}}
<td>{{host.host}}</td>
<td>{{host.class_name}}</td>
<td>{{host.path_whitelist}}</td>
<td>{{category-badge host.category}}</td>
<td>

View File

@ -2,9 +2,10 @@
{{#if embedding.embeddable_hosts}}
<table class='embedding'>
<tr>
<th style='width: 30%'>{{i18n "admin.embedding.host"}}</th>
<th style='width: 30%'>{{i18n "admin.embedding.path_whitelist"}}</th>
<th style='width: 30%'>{{i18n "admin.embedding.category"}}</th>
<th style='width: 25%'>{{i18n "admin.embedding.host"}}</th>
<th style='width: 15%'>{{i18n "admin.embedding.class_name"}}</th>
<th style='width: 25%'>{{i18n "admin.embedding.path_whitelist"}}</th>
<th style='width: 25%'>{{i18n "admin.embedding.category"}}</th>
<th style='width: 10%'>&nbsp;</th>
</tr>
{{#each embedding.embeddable_hosts as |host|}}

View File

@ -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?

View File

@ -57,4 +57,5 @@ end
# created_at :datetime
# updated_at :datetime
# path_whitelist :string
# class_name :string
#

View File

@ -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

View File

@ -3465,6 +3465,7 @@ en:
sample: "Use the following HTML code into your site to create and embed discourse topics. Replace <b>REPLACE_ME</b> 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"

View File

@ -0,0 +1,5 @@
class AddEmbedClassNameToEmbeddableHosts < ActiveRecord::Migration
def change
add_column :embeddable_hosts, :class_name, :string
end
end