FEATURE: Multiple embeddable hosts
- Also refactors two site settings components into one, with tests
This commit is contained in:
parent
71ee84f848
commit
7b6d6b76eb
|
@ -2,7 +2,7 @@ import BufferedContent from 'discourse/mixins/buffered-content';
|
|||
import ScrollTop from 'discourse/mixins/scroll-top';
|
||||
import SiteSetting from 'admin/models/site-setting';
|
||||
|
||||
const CustomTypes = ['bool', 'enum', 'list', 'url_list'];
|
||||
const CustomTypes = ['bool', 'enum', 'list', 'url_list', 'host_list'];
|
||||
|
||||
export default Ember.Component.extend(BufferedContent, ScrollTop, {
|
||||
classNameBindings: [':row', ':setting', 'setting.overridden', 'typeClass'],
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
export default Ember.Component.extend({
|
||||
_setupUrls: function() {
|
||||
const value = this.get('value');
|
||||
this.set('urls', (value && value.length) ? value.split("\n") : []);
|
||||
}.on('init').observes('value'),
|
||||
|
||||
_urlsChanged: function() {
|
||||
this.set('value', this.get('urls').join("\n"));
|
||||
}.observes('urls.@each'),
|
||||
|
||||
urlInvalid: Ember.computed.empty('newUrl'),
|
||||
|
||||
keyDown(e) {
|
||||
if (e.keyCode === 13) {
|
||||
this.send('addUrl');
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
addUrl() {
|
||||
if (this.get('urlInvalid')) { return; }
|
||||
|
||||
this.get('urls').addObject(this.get('newUrl'));
|
||||
this.set('newUrl', '');
|
||||
},
|
||||
|
||||
removeUrl(url) {
|
||||
const urls = this.get('urls');
|
||||
urls.removeObject(url);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -0,0 +1,34 @@
|
|||
export default Ember.Component.extend({
|
||||
classNameBindings: [':value-list'],
|
||||
|
||||
_setupCollection: function() {
|
||||
const values = this.get('values');
|
||||
this.set('collection', (values && values.length) ? values.split("\n") : []);
|
||||
}.on('init').observes('values'),
|
||||
|
||||
_collectionChanged: function() {
|
||||
this.set('values', this.get('collection').join("\n"));
|
||||
}.observes('collection.@each'),
|
||||
|
||||
inputInvalid: Ember.computed.empty('newValue'),
|
||||
|
||||
keyDown(e) {
|
||||
if (e.keyCode === 13) {
|
||||
this.send('addValue');
|
||||
}
|
||||
},
|
||||
|
||||
actions: {
|
||||
addValue() {
|
||||
if (this.get('inputInvalid')) { return; }
|
||||
|
||||
this.get('collection').addObject(this.get('newValue'));
|
||||
this.set('newValue', '');
|
||||
},
|
||||
|
||||
removeValue(value) {
|
||||
const collection = this.get('collection');
|
||||
collection.removeObject(value);
|
||||
}
|
||||
}
|
||||
});
|
|
@ -1,18 +0,0 @@
|
|||
{{#if urls}}
|
||||
<div class='urls'>
|
||||
{{#each url in urls}}
|
||||
<div class='url'>
|
||||
{{d-button action="removeUrl"
|
||||
actionParam=url
|
||||
icon="times"
|
||||
class="btn-small no-text"}}
|
||||
<a href="{{unbound url}}" target="_blank">{{url}}</a>
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class='input'>
|
||||
{{text-field value=newUrl placeholderKey="admin.site_settings.add_url"}}
|
||||
{{d-button action="addUrl" icon="plus" class="btn-primary btn-small no-text" disabled=urlInvalid}}
|
||||
</div>
|
|
@ -0,0 +1,18 @@
|
|||
{{#if collection}}
|
||||
<div class='values'>
|
||||
{{#each collection as |value|}}
|
||||
<div class='value'>
|
||||
{{d-button action="removeValue"
|
||||
actionParam=value
|
||||
icon="times"
|
||||
class="btn-small no-text"}}
|
||||
{{value}}
|
||||
</div>
|
||||
{{/each}}
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
<div class='input'>
|
||||
{{text-field value=newValue placeholderKey=addKey}}
|
||||
{{d-button action="addValue" icon="plus" class="btn-primary btn-small no-text" disabled=inputInvalid}}
|
||||
</div>
|
|
@ -0,0 +1,3 @@
|
|||
{{value-list values=buffered.value addKey="admin.site_settings.add_host"}}
|
||||
{{setting-validation-message message=validationMessage}}
|
||||
<div class='desc'>{{{unbound setting.description}}}</div>
|
|
@ -1,3 +1,3 @@
|
|||
{{url-list value=buffered.value}}
|
||||
{{value-list value=buffered.value addKey="admin.site_settings.add_url"}}
|
||||
{{setting-validation-message message=validationMessage}}
|
||||
<div class='desc'>{{{unbound setting.description}}}</div>
|
||||
|
|
|
@ -1449,8 +1449,8 @@ table#user-badges {
|
|||
}
|
||||
}
|
||||
|
||||
.url-list {
|
||||
.url {
|
||||
.value-list {
|
||||
.value {
|
||||
border-bottom: 1px solid #ddd;
|
||||
padding: 3px;
|
||||
margin-right: 10px;
|
||||
|
@ -1460,7 +1460,7 @@ table#user-badges {
|
|||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.urls {
|
||||
.values {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,8 +53,8 @@ class EmbedController < ApplicationController
|
|||
def ensure_embeddable
|
||||
|
||||
if !(Rails.env.development? && current_user.try(:admin?))
|
||||
raise Discourse::InvalidAccess.new('embeddable host not set') if SiteSetting.normalized_embeddable_host.blank?
|
||||
raise Discourse::InvalidAccess.new('invalid referer host') if URI(request.referer || '').host != SiteSetting.normalized_embeddable_host
|
||||
raise Discourse::InvalidAccess.new('embeddable hosts not set') if SiteSetting.embeddable_hosts.blank?
|
||||
raise Discourse::InvalidAccess.new('invalid referer host') unless SiteSetting.allows_embeddable_host?(request.referer)
|
||||
end
|
||||
|
||||
response.headers['X-Frame-Options'] = "ALLOWALL"
|
||||
|
|
|
@ -68,9 +68,16 @@ class SiteSetting < ActiveRecord::Base
|
|||
@anonymous_menu_items ||= Set.new Discourse.anonymous_filters.map(&:to_s)
|
||||
end
|
||||
|
||||
def self.normalized_embeddable_host
|
||||
return embeddable_host if embeddable_host.blank?
|
||||
embeddable_host.sub(/^https?\:\/\//, '')
|
||||
def self.allows_embeddable_host?(host)
|
||||
return false if embeddable_hosts.blank?
|
||||
uri = URI(host) rescue nil
|
||||
|
||||
return false unless uri.present?
|
||||
|
||||
host = uri.host
|
||||
return false unless host.present?
|
||||
|
||||
!!embeddable_hosts.split("\n").detect {|h| h.sub(/^https?\:\/\//, '') == host }
|
||||
end
|
||||
|
||||
def self.anonymous_homepage
|
||||
|
|
|
@ -842,7 +842,7 @@ class Topic < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def expandable_first_post?
|
||||
SiteSetting.embeddable_host.present? && SiteSetting.embed_truncate? && has_topic_embed?
|
||||
SiteSetting.embeddable_hosts.present? && SiteSetting.embed_truncate? && has_topic_embed?
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -2292,6 +2292,7 @@ en:
|
|||
no_results: "No results found."
|
||||
clear_filter: "Clear"
|
||||
add_url: "add URL"
|
||||
add_host: "add host"
|
||||
categories:
|
||||
all_results: 'All'
|
||||
required: 'Required'
|
||||
|
|
|
@ -738,7 +738,7 @@ bs_BA:
|
|||
default_code_lang: "Default programming language syntax highlighting applied to GitHub code blocks (lang-auto, ruby, python etc.)"
|
||||
warn_reviving_old_topic_age: "When someone starts replying to a topic where the last reply is older than this many days, a warning will be displayed. Disable by setting to 0."
|
||||
autohighlight_all_code: "Force apply code highlighting to all preformatted code blocks even when they didn't explicitly specify the language."
|
||||
embeddable_host: "Host that can embed the comments from this Discourse forum."
|
||||
embeddable_hosts: "Host that can embed the comments from this Discourse forum."
|
||||
feed_polling_enabled: "EMBEDDING ONLY: Whether to embed a RSS/ATOM feed as posts."
|
||||
feed_polling_url: "EMBEDDING ONLY: URL of RSS/ATOM feed to embed."
|
||||
embed_by_username: "Discourse username of the user who creates the embedded topics."
|
||||
|
|
|
@ -937,7 +937,7 @@ de:
|
|||
warn_reviving_old_topic_age: "Wenn jemand beginnt auf ein Thema zu antworten, dessen letzte Antwort älter als diese Anzahl an Tagen ist, wird eine Warnung angezeigt. Deaktiviere dies durch setzen auf 0."
|
||||
autohighlight_all_code: "Erzwinge Syntaxhervorhebung für alle Quellcode-Blöcke, auch dann wenn keine Sprache angeben wurde."
|
||||
highlighted_languages: "Es wurden Syntaxregeln zur Hervorhebung von Textstellen hinzugefügt. (Achtung: Werden zu viele Sprachen hinzugefügt, kann das die Performance beeinflussen) siehe: https://highlightjs.org/static/demo/ für eine Demo."
|
||||
embeddable_host: "Host, der Kommentare aus diesem Discourse Forum einbetten darf. Nur Hostname ohne http://"
|
||||
embeddable_hosts: "Host, der Kommentare aus diesem Discourse Forum einbetten darf. Nur Hostname ohne http://"
|
||||
feed_polling_enabled: "NUR WENN EINGEBETTET: Bestimmt, ob Inhalte eines RSS-/ATOM-Feeds als zusätzliche Beiträge dargestellt werden."
|
||||
feed_polling_url: "NUR WENN EINGEBETTET: URL des einzubettenden RSS-/ATOM-Feeds."
|
||||
embed_by_username: "Discourse-Benutzername des Benutzers, der die eingebetteten Themen erstellt."
|
||||
|
|
|
@ -1126,7 +1126,7 @@ en:
|
|||
autohighlight_all_code: "Force apply code highlighting to all preformatted code blocks even when they didn't explicitly specify the language."
|
||||
highlighted_languages: "Included syntax highlighting rules. (Warning: including too many langauges may impact performance) see: https://highlightjs.org/static/demo/ for a demo"
|
||||
|
||||
embeddable_host: "Host that can embed the comments from this Discourse forum. Hostname only, do not begin with http://"
|
||||
embeddable_hosts: "Host(s) that can embed the comments from this Discourse forum. Hostname only, do not begin with http://"
|
||||
feed_polling_enabled: "EMBEDDING ONLY: Whether to embed a RSS/ATOM feed as posts."
|
||||
feed_polling_url: "EMBEDDING ONLY: URL of RSS/ATOM feed to embed."
|
||||
embed_by_username: "Discourse username of the user who creates the embedded topics."
|
||||
|
|
|
@ -959,7 +959,7 @@ es:
|
|||
warn_reviving_old_topic_age: "Cuando alguien publica en un tema cuya última respuesta fue hace este número de días o más, se le mostrará un aviso para desalentar el hecho de resucitar una antigua discusión. Deshabilita esta opción introduciendo el valor 0."
|
||||
autohighlight_all_code: "Forzar el resaltado de código a los bloques de código preformateado cuando no se especifique el lenguaje del código."
|
||||
highlighted_languages: "Incluye reglas resaltadas de sintaxis. (Advertencia: incluyendo demasiadas lenguages puede afectar al rendimiento) ver: https://highlightjs.org/static/demo/ para una demostración"
|
||||
embeddable_host: "Host que puede incrustar los comentarios de este foro Discourse. Nombre de host solamente, no comienzan con http://"
|
||||
embeddable_hosts: "Host que puede incrustar los comentarios de este foro Discourse. Nombre de host solamente, no comienzan con http://"
|
||||
feed_polling_enabled: "SOLO PARA EMBEBER: embeber feeds RSS/ATOM como posts."
|
||||
feed_polling_url: "SOLO PARA EMBEBER: URL de los feeds RSS/ATOM a embeber."
|
||||
embed_by_username: "Nombre de usuario en Discourse del que crea los temas embebidos."
|
||||
|
|
|
@ -916,7 +916,7 @@ fa_IR:
|
|||
warn_reviving_old_topic_age: "وقتی کسی شروع می کند با پاسخ دادن به جستاری که آخرین پاسخ برمی گردد به خیلی قبل یک هشدار نمایش داده می شود. نمایش با تنظیمات تا 0. "
|
||||
autohighlight_all_code: "اعمال زور برای برجسته کردن کد به تمام بلاک های کد تنظیم نشده حتی وقتی به صراحت زبان را مشخص نمی کنند. "
|
||||
highlighted_languages: "شامل نحوه قوانین برجسته شده. ( اخطار: شامل زبان های متفاوت ممکن است در نحوه اجرا تاثیر گذار باشد) ببین: https://highlightjs.org/static/demo/ برای دمو"
|
||||
embeddable_host: "سروری که می تونه در نوشته ها جا سازی بشه از انجمن دیسکورس. فقط نام سروری که با http:// شروع می شود"
|
||||
embeddable_hosts: "سروری که می تونه در نوشته ها جا سازی بشه از انجمن دیسکورس. فقط نام سروری که با http:// شروع می شود"
|
||||
feed_polling_enabled: "فقط جاسازی: چه جاسازی RSS/ATOM feed به عنوان نوشته"
|
||||
feed_polling_url: "فقط جاسازی: URL of RSS/ATOM feed to embed."
|
||||
embed_by_username: "نام کاربری دیسکورس کاربری که نوشته های جاسازی شده را ساخته."
|
||||
|
|
|
@ -962,7 +962,7 @@ fi:
|
|||
warn_reviving_old_topic_age: "Kun käyttäjä alkaa kirjoittamaan vastausta ketjuun, jonka uusin viesti on tätä vanhempi päivissä, näytetään varoitus. Poista käytöstä asettamalla arvoksi 0."
|
||||
autohighlight_all_code: "Pakota koodin korostus kaikkiin esimuotoiltuihin tekstiblokkeihin, vaikka käyttäjä ei määrittelisi kieltä."
|
||||
highlighted_languages: "Syntaksin korostamisen säännöt. (Varoitus: liian monen kielen sisällyttäminen voi vaikuttaa suorituskykyyn) katso demo: https://highlightjs.org/static/demo/"
|
||||
embeddable_host: "Isäntä, joka voi upottaa kommentteja tältä palstalta. Pelkkä isäntänimi, älä aloita http://"
|
||||
embeddable_hosts: "Isäntä, joka voi upottaa kommentteja tältä palstalta. Pelkkä isäntänimi, älä aloita http://"
|
||||
feed_polling_enabled: "VAIN UPOTUS: Upotetaanko RSS/ATOM syöte viesteinä."
|
||||
feed_polling_url: "VAIN UPOTUS: RSS/ATOM syötteen URL."
|
||||
embed_by_username: "Sen käyttäjän Discourse käyttäjänimi, joka luo upotetut ketjut."
|
||||
|
|
|
@ -963,7 +963,7 @@ fr:
|
|||
warn_reviving_old_topic_age: "Lorsque quelqu'un commence à répondre à un sujet dont la dernière réponse est vielle de plusieurs jours, un avertissement sera affiché. Désactiver la fonctionnalité en indiquant: 0."
|
||||
autohighlight_all_code: "Forcer la mise en évidence de tout les textes dans les balises code, même si ils ne correspondent à aucun langage de programmation."
|
||||
highlighted_languages: "Include les règles de mise en surbrillance de syntaxe. (Avertissement: l'ajout de trop de langages peut impacter les performances) voir l'exemple https://highlightjs.org/static/demo/"
|
||||
embeddable_host: "Hôte qui peut incorporer des messages de ce forum Discourse. Nom d'hôte seulement, sans http://"
|
||||
embeddable_hosts: "Hôte qui peut incorporer des messages de ce forum Discourse. Nom d'hôte seulement, sans http://"
|
||||
feed_polling_enabled: "EMBARQUER UNIQUEMENT: Embarqué le flux RSS/ATOM en tant que messages."
|
||||
feed_polling_url: "EMBARQUER UNIQUEMENT: Url du flux RSS/ATOM à embarqué."
|
||||
embed_by_username: "Pseudo de l'utilisateur Discourse qui crée les sujets embarqués."
|
||||
|
|
|
@ -925,7 +925,7 @@ he:
|
|||
warn_reviving_old_topic_age: "כאשר מישהו/מישהי מתחילים להגיב לנושא שבו התגובה האחרונה היא בת יותר מכמה ימים, אזהרה תוצג. בטלו אפשרות זו באמצעות הזנה של 0."
|
||||
autohighlight_all_code: "לחייב שימוש בקוד הדגשה לכל קוד מעוצב מראש (preformatted code blocks) אפילו אם הם אינם מציינים את השפה."
|
||||
highlighted_languages: "הכללת הדגשת שגיאות תחביר. (אזהרה: הכללת שפות רבות מידי עשוי להשפיע על הביצוע) ראו: https://highlightjs.org/static/demo/ להדגמה"
|
||||
embeddable_host: "מארח (Host) אשר יכול להטמיע את התגובות מפורום Discourse זה. שם מארח בלבד, ללא http:// בהתחלה"
|
||||
embeddable_hosts: "מארח (Host) אשר יכול להטמיע את התגובות מפורום Discourse זה. שם מארח בלבד, ללא http:// בהתחלה"
|
||||
feed_polling_enabled: "הטמעה בלבד: האם לעמבד פידים של RSS/ATOM כפרסומים."
|
||||
feed_polling_url: "הטמעה בלבד: URL של פיד RSS/ATOM להטמעה."
|
||||
embed_by_username: "שם המשתמש של המשתמש/ת שיוצר את הנושאים המוטמעים."
|
||||
|
|
|
@ -837,7 +837,7 @@ ja:
|
|||
warn_reviving_old_topic_age: "最後の返信がこの設定よりも古いトピックに返信すると、警告を表示します。0を設定すると無効になります"
|
||||
autohighlight_all_code: "明示的に言語を指定しなくても、全てのコードブロックにコードハイライトを強制的に適用する"
|
||||
highlighted_languages: "適用するシンタックスハイライトルール(警告: あまりに多くの言語を含むとパフォーマンスに影響を与えます) デモ: https://highlightjs.org/static/demo/ "
|
||||
embeddable_host: "このDiscourseフォーラムのコメントを埋め込む事が出来るHost。Host名のみ、http:// で始めない"
|
||||
embeddable_hosts: "このDiscourseフォーラムのコメントを埋め込む事が出来るHost。Host名のみ、http:// で始めない"
|
||||
feed_polling_enabled: "EMBEDDING ONLY: ポストとしてRSS/Atomフィードを埋め込むかどうか"
|
||||
feed_polling_url: "EMBEDDING ONLY: RSS/ATOMフィードのURLを埋め込む事が出来ます"
|
||||
embed_by_username: "embedされたトピックの作成者として表示されるDiscourseユーザー名"
|
||||
|
|
|
@ -950,7 +950,7 @@ pt:
|
|||
warn_reviving_old_topic_age: "Quando alguém começa a responder a um tópico em que a última resposta é mais antiga que estes dias, um aviso será exibido. Desativar ao configurar para 0."
|
||||
autohighlight_all_code: "Forçar o destaque do código a todos os blocos de código pré-formatados mesmo quando não se especifica a linguagem."
|
||||
highlighted_languages: "Incluídas regras de destaque da sintaxe (Aviso: incluir demasiadas linguagens pode impactar o desempenho) ver: https://highlightjs.org/static/demo/ para uma demonstração"
|
||||
embeddable_host: "Servidor que pode incorporar os comentários deste fórum Discourse. Apenas o nome do servidor, não começar com http://"
|
||||
embeddable_hosts: "Servidor que pode incorporar os comentários deste fórum Discourse. Apenas o nome do servidor, não começar com http://"
|
||||
feed_polling_enabled: "INCORPORAR APENAS: incorporar feeds RSS/ATOM como mensagens."
|
||||
feed_polling_url: "INCORPORAR APENAS: URL dos feeds de RSS/ATOM para embutir."
|
||||
embed_by_username: "Nome de utilizador Discourse do utilizador que cria tópicos embebidos."
|
||||
|
|
|
@ -950,7 +950,7 @@ pt_BR:
|
|||
warn_reviving_old_topic_age: "Quando alguém começa a responder a um tópico mais velho do que este número de dias, um aviso será exibido para desencorajar o usuário de reviver uma velha discussão. Desabilite definindo para 0."
|
||||
autohighlight_all_code: "Aplicar código destacando todos os blocos de código pré-formatados, mesmo quando não for específica o idioma"
|
||||
highlighted_languages: "Incluir regras de destaque de sintaxe. (AVISO: incluir muitas linguagens podem afetar a performance) veja: https://highlightjs.org/static/demo/ para uma demonstração"
|
||||
embeddable_host: "Servidor que pode incorporar os comentários deste forum Discourse. Apenas o Nome do Servidor, não começar com http://"
|
||||
embeddable_hosts: "Servidor que pode incorporar os comentários deste forum Discourse. Apenas o Nome do Servidor, não começar com http://"
|
||||
feed_polling_enabled: "Se um feed RSS / ATOM são importados como mensagens"
|
||||
feed_polling_url: "URL do feed RSS / ATOM para importar"
|
||||
embed_by_username: "Nome de usuário Discourse para o usuário que cria os tópicos"
|
||||
|
|
|
@ -1005,7 +1005,7 @@ ru:
|
|||
warn_reviving_old_topic_age: "Показывать предупреждение, когда кто-то пытается ответить в очень старую тему. Указывается в днях. Чтобы отключить 0."
|
||||
autohighlight_all_code: "Принудительно использовать подсветку кода для всех отформатированных блоков кода, даже когда они явно не указан язык."
|
||||
highlighted_languages: "Включить правила подсветки синтаксиса. (ВНИМАНИЕ: включение для многих языков может вызвать проблемы с производительностью) пример можно посмотреть на: https://highlightjs.org/static/demo/ "
|
||||
embeddable_host: "Имя хоста которому разрешено использовать комменты с данного форума. Не указывайте http://"
|
||||
embeddable_hosts: "Имя хоста которому разрешено использовать комменты с данного форума. Не указывайте http://"
|
||||
feed_polling_enabled: "ТОЛЬКО ДЛЯ ВЛОЖЕННЫХ: Встраивать ли вложенные сообщения в RSS/ATOM ленту"
|
||||
feed_polling_url: "URL адрес импорта RSS/ATOM ленты"
|
||||
embed_by_username: "Имя пользователя который созал вложенную тему"
|
||||
|
|
|
@ -938,7 +938,7 @@ sq:
|
|||
warn_reviving_old_topic_age: "When someone starts replying to a topic where the last reply is older than this many days, a warning will be displayed. Disable by setting to 0."
|
||||
autohighlight_all_code: "Force apply code highlighting to all preformatted code blocks even when they didn't explicitly specify the language."
|
||||
highlighted_languages: "Included syntax highlighting rules. (Warning: including too many langauges may impact performance) see: https://highlightjs.org/static/demo/ for a demo"
|
||||
embeddable_host: "Host that can embed the comments from this Discourse forum. Hostname only, do not begin with http://"
|
||||
embeddable_hosts: "Host that can embed the comments from this Discourse forum. Hostname only, do not begin with http://"
|
||||
feed_polling_enabled: "EMBEDDING ONLY: Whether to embed a RSS/ATOM feed as posts."
|
||||
feed_polling_url: "EMBEDDING ONLY: URL of RSS/ATOM feed to embed."
|
||||
embed_by_username: "Discourse username of the user who creates the embedded topics."
|
||||
|
|
|
@ -903,7 +903,7 @@ tr_TR:
|
|||
warn_reviving_old_topic_age: "Herhangi bir kullanıcı, son cevabın burada belirtilen gün sayısından daha önce yazıldığı bir konuya cevap yazmaya başladığında, bir uyarı mesajı çıkacak. Bu özelliği devre dışı bırakmak için 0 girin. "
|
||||
autohighlight_all_code: "Tüm önceden formatlanan kod bloklarına, açıkça dil seçimi yapılmamış olsa da, zorla kod vurgulaması uygula."
|
||||
highlighted_languages: "Dahil edilen sözdizimi vurgulama kuralları. (Dikkat: çok fazla dili dahil etmek performansı etkileyebilir) Demo için https://highlightjs.org/static/demo/ adresine bakınız"
|
||||
embeddable_host: "Bu Discourse forumundan yorumların yerleştirilebileceği sunucu. Sadece sunucu, http:// ile başlamayın"
|
||||
embeddable_hosts: "Bu Discourse forumundan yorumların yerleştirilebileceği sunucu. Sadece sunucu, http:// ile başlamayın"
|
||||
feed_polling_enabled: "SADECE YERLEŞTİRME İÇİN: RSS/ATOM beslemesinin gönderi olarak yerleştirilip yerleştirilemeyeceği."
|
||||
feed_polling_url: "SADECE YERLEŞTİRME İÇİN: Yerleştirilecek RSS/ATOM beslemesinin URL'i."
|
||||
embed_by_username: "Yerleştirilmiş konuları oluşturan kullanıcıya ait Discourse kullanıcı adı. "
|
||||
|
|
|
@ -934,7 +934,7 @@ zh_CN:
|
|||
warn_reviving_old_topic_age: "当有人开始回复最后一贴超过一定天数前的主题时,将有一个警告显示,不鼓励他们复活一个老的讨论。将其设置为 0 以禁用。"
|
||||
autohighlight_all_code: "即使未显式设定语言,仍为所有预编排代码块应用语法高亮。"
|
||||
highlighted_languages: "包含语法高亮规则。(警告:包含太多的语言可能会印象性能)见:https://highlightjs.org/static/demo/ 查看演示"
|
||||
embeddable_host: "能从这个 Discourse 论坛嵌入评论的主机。\n仅主机名,不要以 http:// 开头"
|
||||
embeddable_hosts: "能从这个 Discourse 论坛嵌入评论的主机。\n仅主机名,不要以 http:// 开头"
|
||||
feed_polling_enabled: "仅用于嵌入:是否将 RSS/ATOM 订阅为帖子。"
|
||||
feed_polling_url: "仅用于嵌入:RSS/ATOM 订阅的 URL。"
|
||||
embed_by_username: "创建嵌入主题的 Discourse 的用户名。"
|
||||
|
|
|
@ -729,9 +729,9 @@ developer:
|
|||
client: true
|
||||
|
||||
embedding:
|
||||
embeddable_host:
|
||||
embeddable_hosts:
|
||||
default: ''
|
||||
regex: "^(?!http).+" # don't allow this to start with http:// or https://
|
||||
type: host_list
|
||||
feed_polling_enabled: false
|
||||
feed_polling_url: ''
|
||||
embed_by_username:
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class MigrateEmbeddableHost < ActiveRecord::Migration
|
||||
def change
|
||||
execute "UPDATE site_settings SET name = 'embeddable_hosts', data_type = 9 WHERE name = 'embeddable_host'"
|
||||
end
|
||||
end
|
|
@ -14,7 +14,7 @@ module SiteSettingExtension
|
|||
end
|
||||
|
||||
def types
|
||||
@types ||= Enum.new(:string, :time, :fixnum, :float, :bool, :null, :enum, :list, :url_list)
|
||||
@types ||= Enum.new(:string, :time, :fixnum, :float, :bool, :null, :enum, :list, :url_list, :host_list)
|
||||
end
|
||||
|
||||
def mutex
|
||||
|
|
|
@ -13,10 +13,7 @@ class TopicRetriever
|
|||
private
|
||||
|
||||
def invalid_host?
|
||||
SiteSetting.normalized_embeddable_host != URI(@embed_url).host
|
||||
rescue URI::InvalidURIError
|
||||
# An invalid URI is an invalid host
|
||||
true
|
||||
SiteSetting.allows_embeddable_host?(@embed_url)
|
||||
end
|
||||
|
||||
def retrieved_recently?
|
||||
|
|
|
@ -11,14 +11,14 @@ describe EmbedController do
|
|||
end
|
||||
|
||||
it "raises an error with a missing host" do
|
||||
SiteSetting.stubs(:embeddable_host).returns(nil)
|
||||
SiteSetting.embeddable_hosts = nil
|
||||
get :comments, embed_url: embed_url
|
||||
expect(response).not_to be_success
|
||||
end
|
||||
|
||||
context "with a host" do
|
||||
before do
|
||||
SiteSetting.stubs(:embeddable_host).returns(host)
|
||||
SiteSetting.embeddable_hosts = host
|
||||
end
|
||||
|
||||
it "raises an error with no referer" do
|
||||
|
@ -27,7 +27,6 @@ describe EmbedController do
|
|||
end
|
||||
|
||||
context "success" do
|
||||
|
||||
before do
|
||||
controller.request.stubs(:referer).returns(embed_url)
|
||||
end
|
||||
|
@ -51,8 +50,31 @@ describe EmbedController do
|
|||
get :comments, embed_url: embed_url
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
context "with multiple hosts" do
|
||||
before do
|
||||
SiteSetting.embeddable_hosts = "#{host}\nhttp://discourse.org"
|
||||
end
|
||||
|
||||
context "success" do
|
||||
it "works with the first host" do
|
||||
controller.request.stubs(:referer).returns("http://eviltrout.com/wat/1-2-3.html")
|
||||
get :comments, embed_url: embed_url
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it "works with the second host" do
|
||||
controller.request.stubs(:referer).returns("https://discourse.org/blog-entry-1")
|
||||
get :comments, embed_url: embed_url
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it "doesn't work with a made up host" do
|
||||
controller.request.stubs(:referer).returns("http://codinghorror.com/invalid-url")
|
||||
get :comments, embed_url: embed_url
|
||||
expect(response).to_not be_success
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -4,21 +4,34 @@ require_dependency 'site_setting_extension'
|
|||
|
||||
describe SiteSetting do
|
||||
|
||||
describe "normalized_embeddable_host" do
|
||||
it 'returns the `embeddable_host` value' do
|
||||
SiteSetting.stubs(:embeddable_host).returns("eviltrout.com")
|
||||
expect(SiteSetting.normalized_embeddable_host).to eq("eviltrout.com")
|
||||
describe "allows_embeddable_host" do
|
||||
it 'works as expected' do
|
||||
SiteSetting.embeddable_hosts = 'eviltrout.com'
|
||||
expect(SiteSetting.allows_embeddable_host?('http://eviltrout.com')).to eq(true)
|
||||
expect(SiteSetting.allows_embeddable_host?('https://eviltrout.com')).to eq(true)
|
||||
expect(SiteSetting.allows_embeddable_host?('https://not-eviltrout.com')).to eq(false)
|
||||
end
|
||||
|
||||
it 'strip http from `embeddable_host` value' do
|
||||
SiteSetting.stubs(:embeddable_host).returns("http://eviltrout.com")
|
||||
expect(SiteSetting.normalized_embeddable_host).to eq("eviltrout.com")
|
||||
it 'works with a http host' do
|
||||
SiteSetting.embeddable_hosts = 'http://eviltrout.com'
|
||||
expect(SiteSetting.allows_embeddable_host?('http://eviltrout.com')).to eq(true)
|
||||
expect(SiteSetting.allows_embeddable_host?('https://eviltrout.com')).to eq(true)
|
||||
expect(SiteSetting.allows_embeddable_host?('https://not-eviltrout.com')).to eq(false)
|
||||
end
|
||||
|
||||
it 'strip https from `embeddable_host` value' do
|
||||
SiteSetting.stubs(:embeddable_host).returns("https://eviltrout.com")
|
||||
expect(SiteSetting.normalized_embeddable_host).to eq("eviltrout.com")
|
||||
it 'works with a https host' do
|
||||
SiteSetting.embeddable_hosts = 'https://eviltrout.com'
|
||||
expect(SiteSetting.allows_embeddable_host?('http://eviltrout.com')).to eq(true)
|
||||
expect(SiteSetting.allows_embeddable_host?('https://eviltrout.com')).to eq(true)
|
||||
expect(SiteSetting.allows_embeddable_host?('https://not-eviltrout.com')).to eq(false)
|
||||
end
|
||||
|
||||
it 'works with multiple hosts' do
|
||||
SiteSetting.embeddable_hosts = "https://eviltrout.com\nhttps://discourse.org"
|
||||
expect(SiteSetting.allows_embeddable_host?('http://eviltrout.com')).to eq(true)
|
||||
expect(SiteSetting.allows_embeddable_host?('http://discourse.org')).to eq(true)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'topic_title_length' do
|
||||
|
|
|
@ -1400,8 +1400,8 @@ describe Topic do
|
|||
let(:topic) { Fabricate.build(:topic) }
|
||||
|
||||
before do
|
||||
SiteSetting.stubs(:embeddable_host).returns("http://eviltrout.com")
|
||||
SiteSetting.stubs(:embed_truncate?).returns(true)
|
||||
SiteSetting.embeddable_hosts = "http://eviltrout.com"
|
||||
SiteSetting.embed_truncate = true
|
||||
topic.stubs(:has_topic_embed?).returns(true)
|
||||
end
|
||||
|
||||
|
@ -1410,12 +1410,12 @@ describe Topic do
|
|||
end
|
||||
|
||||
it "is false if embeddable_host is blank" do
|
||||
SiteSetting.stubs(:embeddable_host).returns(nil)
|
||||
SiteSetting.embeddable_hosts = nil
|
||||
expect(topic.expandable_first_post?).to eq(false)
|
||||
end
|
||||
|
||||
it "is false if embed_truncate? is false" do
|
||||
SiteSetting.stubs(:embed_truncate?).returns(false)
|
||||
SiteSetting.embed_truncate = false
|
||||
expect(topic.expandable_first_post?).to eq(false)
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
moduleForComponent('value-list', {integration: true});
|
||||
|
||||
test('functionality', function(assert) {
|
||||
andThen(() => {
|
||||
this.render('{{value-list value=values}}');
|
||||
});
|
||||
|
||||
andThen(() => {
|
||||
assert.ok(this.$('.values .value').length === 0, 'it has no values');
|
||||
assert.ok(this.$('input').length, 'it renders the input');
|
||||
assert.ok(this.$('.btn-primary[disabled]').length, 'it is disabled with no value');
|
||||
});
|
||||
|
||||
fillIn('input', 'eviltrout');
|
||||
andThen(() => {
|
||||
assert.ok(!this.$('.btn-primary[disabled]').length, "it isn't disabled anymore");
|
||||
});
|
||||
|
||||
click('.btn-primary');
|
||||
andThen(() => {
|
||||
assert.ok(this.$('.values .value').length === 1, 'it adds the value');
|
||||
assert.ok(this.$('input').val() === '', 'it clears the input');
|
||||
assert.ok(this.$('.btn-primary[disabled]').length, "it is disabled again");
|
||||
});
|
||||
|
||||
click('.value .btn-small');
|
||||
andThen(() => {
|
||||
assert.ok(this.$('.values .value').length === 0, 'it removes the value');
|
||||
});
|
||||
|
||||
});
|
Loading…
Reference in New Issue