UX: Init Carbon Ads

This commit is contained in:
Diego Barreiro
2019-04-15 11:54:18 -04:00
committed by Neil Lalonde
parent 4516dbca26
commit c5272db7f3
7 changed files with 74 additions and 0 deletions
@@ -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}}
{{codefund-ad placement="topic-list-top" listLoading=listLoading refreshOnChange=listLoading}}
{{/if}}
{{#if siteSettings.carbonads_topic_list_top_enabled}}
{{carbonads-ad}}
{{/if}}
{{else}}
{{#if siteSettings.adsense_topic_list_top_code}}
{{google-adsense placement="topic-list-top" listLoading=listLoading}}
@@ -24,4 +27,7 @@
{{#if siteSettings.codefund_top_of_topic_list_enabled}}
{{codefund-ad placement="topic-list-top" listLoading=listLoading refreshOnChange=listLoading}}
{{/if}}
{{#if siteSettings.carbonads_topic_list_top_enabled}}
{{carbonads-ad}}
{{/if}}
{{/if}}
@@ -11,6 +11,9 @@
{{#if siteSettings.codefund_above_post_stream_enabled}}
{{codefund-ad placement="topic-above-post-stream"}}
{{/if}}
{{#if siteSettings.carbonads_above_post_stream_enabled}}
{{carbonads-ad}}
{{/if}}
{{else}}
{{#if siteSettings.adsense_topic_above_post_stream_code}}
{{google-adsense placement="topic-above-post-stream"}}
@@ -24,4 +27,7 @@
{{#if siteSettings.codefund_above_post_stream_enabled}}
{{codefund-ad placement="topic-above-post-stream"}}
{{/if}}
{{#if siteSettings.carbonads_above_post_stream_enabled}}
{{carbonads-ad}}
{{/if}}
{{/if}}