UX: Init Carbon Ads
This commit is contained in:
parent
4516dbca26
commit
c5272db7f3
|
@ -0,0 +1,33 @@
|
||||||
|
import {
|
||||||
|
default as computed,
|
||||||
|
observes
|
||||||
|
} from "ember-addons/ember-computed-decorators";
|
||||||
|
|
||||||
|
var currentUser = Discourse.User.current(),
|
||||||
|
serve_id = Discourse.SiteSettings.carbonads_serve_id,
|
||||||
|
placement = Discourse.SiteSettings.carbonads_placement;
|
||||||
|
|
||||||
|
export default Ember.Component.extend({
|
||||||
|
init: function() {
|
||||||
|
this.set("serve_id", serve_id);
|
||||||
|
this.set("placement", placement);
|
||||||
|
this._super();
|
||||||
|
},
|
||||||
|
|
||||||
|
url: function() {
|
||||||
|
return (`//cdn.carbonads.com/carbon.js?serve=${this.get("serve_id")}&placement=${this.get("placement")}`).htmlSafe();
|
||||||
|
}.property("serve_id", "placement"),
|
||||||
|
|
||||||
|
checkTrustLevels: function() {
|
||||||
|
return !(
|
||||||
|
currentUser &&
|
||||||
|
currentUser.get("trust_level") >
|
||||||
|
Discourse.SiteSettings.carbonads_through_trust_level
|
||||||
|
);
|
||||||
|
}.property("trust_level"),
|
||||||
|
|
||||||
|
@computed("checkTrustLevels")
|
||||||
|
showAd: function(checkTrustLevels) {
|
||||||
|
return placement && serve_id && checkTrustLevels;
|
||||||
|
}
|
||||||
|
});
|
|
@ -0,0 +1,4 @@
|
||||||
|
{{#if showAd}}
|
||||||
|
<script src={{url}} id="_carbonads_js" async type="text/javascript">
|
||||||
|
</script>
|
||||||
|
{{/if}}
|
|
@ -11,6 +11,9 @@
|
||||||
{{#if siteSettings.codefund_top_of_topic_list_enabled}}
|
{{#if siteSettings.codefund_top_of_topic_list_enabled}}
|
||||||
{{codefund-ad placement="topic-list-top" listLoading=listLoading refreshOnChange=listLoading}}
|
{{codefund-ad placement="topic-list-top" listLoading=listLoading refreshOnChange=listLoading}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#if siteSettings.carbonads_topic_list_top_enabled}}
|
||||||
|
{{carbonads-ad}}
|
||||||
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if siteSettings.adsense_topic_list_top_code}}
|
{{#if siteSettings.adsense_topic_list_top_code}}
|
||||||
{{google-adsense placement="topic-list-top" listLoading=listLoading}}
|
{{google-adsense placement="topic-list-top" listLoading=listLoading}}
|
||||||
|
@ -24,4 +27,7 @@
|
||||||
{{#if siteSettings.codefund_top_of_topic_list_enabled}}
|
{{#if siteSettings.codefund_top_of_topic_list_enabled}}
|
||||||
{{codefund-ad placement="topic-list-top" listLoading=listLoading refreshOnChange=listLoading}}
|
{{codefund-ad placement="topic-list-top" listLoading=listLoading refreshOnChange=listLoading}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#if siteSettings.carbonads_topic_list_top_enabled}}
|
||||||
|
{{carbonads-ad}}
|
||||||
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
|
@ -11,6 +11,9 @@
|
||||||
{{#if siteSettings.codefund_above_post_stream_enabled}}
|
{{#if siteSettings.codefund_above_post_stream_enabled}}
|
||||||
{{codefund-ad placement="topic-above-post-stream"}}
|
{{codefund-ad placement="topic-above-post-stream"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#if siteSettings.carbonads_above_post_stream_enabled}}
|
||||||
|
{{carbonads-ad}}
|
||||||
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{#if siteSettings.adsense_topic_above_post_stream_code}}
|
{{#if siteSettings.adsense_topic_above_post_stream_code}}
|
||||||
{{google-adsense placement="topic-above-post-stream"}}
|
{{google-adsense placement="topic-above-post-stream"}}
|
||||||
|
@ -24,4 +27,7 @@
|
||||||
{{#if siteSettings.codefund_above_post_stream_enabled}}
|
{{#if siteSettings.codefund_above_post_stream_enabled}}
|
||||||
{{codefund-ad placement="topic-above-post-stream"}}
|
{{codefund-ad placement="topic-above-post-stream"}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{#if siteSettings.carbonads_above_post_stream_enabled}}
|
||||||
|
{{carbonads-ad}}
|
||||||
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
|
@ -10,3 +10,4 @@ en:
|
||||||
adsense_plugin: 'AdSense'
|
adsense_plugin: 'AdSense'
|
||||||
amazon_plugin: 'Amazon'
|
amazon_plugin: 'Amazon'
|
||||||
codefund_plugin: 'CodeFund'
|
codefund_plugin: 'CodeFund'
|
||||||
|
carbonads_plugin: 'Carbon Ads'
|
||||||
|
|
|
@ -90,3 +90,9 @@ en:
|
||||||
codefund_above_post_stream_enabled: "Show an ad above the post stream"
|
codefund_above_post_stream_enabled: "Show an ad above the post stream"
|
||||||
codefund_above_suggested_enabled: "Show an ad above the suggested topic list"
|
codefund_above_suggested_enabled: "Show an ad above the suggested topic list"
|
||||||
codefund_top_of_topic_list_enabled: "Show an ad above the topic list"
|
codefund_top_of_topic_list_enabled: "Show an ad above the topic list"
|
||||||
|
|
||||||
|
carbonads_serve_id: "Your Carbon Ads Serve ID"
|
||||||
|
carbonads_placement: "Your Carbon Ads Placement"
|
||||||
|
carbonads_through_trust_level: "Show your ads to users based on trust levels. Users with trust level higher than this value will not see ads."
|
||||||
|
carbonads_topic_list_top_enabled: "Show an ad above the topic list"
|
||||||
|
carbonads_above_post_stream_enabled: "Show an ad above the post stream"
|
||||||
|
|
|
@ -379,3 +379,21 @@ codefund_plugin:
|
||||||
codefund_top_of_topic_list_enabled:
|
codefund_top_of_topic_list_enabled:
|
||||||
default: true
|
default: true
|
||||||
client: true
|
client: true
|
||||||
|
|
||||||
|
carbonads_plugin:
|
||||||
|
carbonads_serve_id:
|
||||||
|
client: true
|
||||||
|
default: ""
|
||||||
|
carbonads_placement:
|
||||||
|
client: true
|
||||||
|
default: ""
|
||||||
|
carbonads_through_trust_level:
|
||||||
|
client: true
|
||||||
|
default: 2
|
||||||
|
enum: "TrustLevelSetting"
|
||||||
|
carbonads_topic_list_top_enabled:
|
||||||
|
client: true
|
||||||
|
default: false
|
||||||
|
carbonads_above_post_stream_enabled:
|
||||||
|
client: true
|
||||||
|
default: false
|
||||||
|
|
Loading…
Reference in New Issue