FIX: CodeFund is shutting down (#85)
This commit is contained in:
parent
3d0ee3f28a
commit
3fc872520e
|
@ -17,7 +17,6 @@ This is the official Discourse advertising plugin. It allows advertisements to
|
|||
* [Google Adsense](http://www.google.com.au/adsense/start/why-adsense.html)
|
||||
* [Google Double Click for Publishers](https://www.google.com/dfp)
|
||||
* [Amazon Affiliates](http://affiliate-program.amazon.com) - Banner and Product Link Ads
|
||||
* [CodeFund](https://codefund.io) - Ethical Ad Platform for Developers
|
||||
* [Carbon Ads](https://www.carbonads.net/)
|
||||
* [AdButler](https://www.adbutler.com/)
|
||||
|
||||
|
@ -80,7 +79,6 @@ the ad slots. The ads will start showing as soon as you add them to slots.
|
|||
<li>House Ads - if you want to create and serve ads from your Discourse instance.</li>
|
||||
<li>Adsense - if using Adsense as your advertisement platform.</li>
|
||||
<li>DFP - if using the DoubleClick for Publishers advertisement platform.</li>
|
||||
<li>CodeFund - if using the CodeFund ethical advertisement platform.</li>
|
||||
<li>Carbon Ads - if using the Carbon Ads advertisement platform.</li>
|
||||
<li>AdButler - if using the AdButler advertisement platform.</li>
|
||||
</ul>
|
||||
|
@ -107,10 +105,6 @@ Only for Product Link and Banner Ads.
|
|||
|
||||
![](https://www.dropbox.com/sc/l67fb5c3tl8bq3d/AAAAMmccMW3kkIeBR7cBdWoFa?dl=1)
|
||||
|
||||
##### CodeFund Embed Tag to Discourse's Site Settings
|
||||
|
||||
![CodeFund Instructions](https://s3-us-west-2.amazonaws.com/codesponsor/discourse-codefund-instructions.png)
|
||||
|
||||
##### Carbon Ads Script Tag to Discourse's Site Settings
|
||||
|
||||
![Carbon Ads](https://d11a6trkgmumsb.cloudfront.net/original/3X/3/a/3acc7488db2b53733cdd427d3cb1b76361c786e1.png)
|
||||
|
|
|
@ -30,17 +30,6 @@ const adConfig = Ember.Object.create({
|
|||
"topic-above-suggested": "amazon_mobile_topic_above_suggested_src_code"
|
||||
}
|
||||
},
|
||||
"codefund-ad": {
|
||||
settingPrefix: "codefund",
|
||||
enabledSetting: "codefund_property_id",
|
||||
nthPost: "codefund_nth_post",
|
||||
desktop: {
|
||||
"topic-list-top": "codefund_top_of_topic_list_enabled",
|
||||
"post-bottom": "codefund_below_post_enabled",
|
||||
"topic-above-post-stream": "codefund_above_post_stream_enabled",
|
||||
"topic-above-suggested": "codefund_above_suggested_enabled"
|
||||
}
|
||||
},
|
||||
"carbonads-ad": {
|
||||
settingPrefix: "carbonads",
|
||||
enabledSetting: "carbonads_serve_id",
|
||||
|
|
|
@ -1,139 +0,0 @@
|
|||
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
|
||||
import discourseComputed, { observes } from "discourse-common/utils/decorators";
|
||||
import { Promise } from "rsvp";
|
||||
|
||||
let _loaded = false,
|
||||
_promise = null;
|
||||
|
||||
const propertyId = Discourse.SiteSettings.codefund_property_id;
|
||||
|
||||
function loadCodeFund() {
|
||||
if (_loaded) {
|
||||
return Ember.RSVP.resolve();
|
||||
}
|
||||
|
||||
if (_promise) {
|
||||
return _promise;
|
||||
}
|
||||
|
||||
const url = "https://codefund.io/properties/" + propertyId + "/funder.json";
|
||||
|
||||
_promise = new Promise(function(resolve, reject) {
|
||||
let xhr = new XMLHttpRequest();
|
||||
|
||||
xhr.open("GET", url);
|
||||
xhr.onreadystatechange = handler;
|
||||
xhr.responseType = "json";
|
||||
xhr.setRequestHeader("Accept", "application/json");
|
||||
xhr.send();
|
||||
|
||||
function handler() {
|
||||
if (this.readyState === this.DONE) {
|
||||
_loaded = true;
|
||||
|
||||
if (this.status === 200) {
|
||||
resolve(this.response);
|
||||
} else {
|
||||
reject(
|
||||
new Error(
|
||||
"getJSON: `" + url + "` failed with status: [" + this.status + "]"
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return _promise;
|
||||
}
|
||||
|
||||
export default AdComponent.extend({
|
||||
classNameBindings: [":codefund-ad"],
|
||||
propertyId: propertyId,
|
||||
adRequested: false,
|
||||
adDetails: {},
|
||||
|
||||
displayPostBottom: Ember.computed.equal("placement", "post-bottom"),
|
||||
displayTopicAbovePostStream: Ember.computed.equal(
|
||||
"placement",
|
||||
"topic-above-post-stream"
|
||||
),
|
||||
displayTopicAboveSuggested: Ember.computed.equal(
|
||||
"placement",
|
||||
"topic-above-suggested"
|
||||
),
|
||||
displayTopicListTop: Ember.computed.equal("placement", "topic-list-top"),
|
||||
|
||||
_triggerAds() {
|
||||
if (!propertyId) return;
|
||||
|
||||
this.set("adRequested", true);
|
||||
loadCodeFund()
|
||||
.then(data => {
|
||||
_loaded = false;
|
||||
_promise = null;
|
||||
this.set("adDetails", data);
|
||||
this.set("adRequested", false);
|
||||
})
|
||||
.catch(error => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super();
|
||||
|
||||
if (!this.get("showAd")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.get("listLoading")) {
|
||||
return;
|
||||
}
|
||||
|
||||
Ember.run.scheduleOnce("afterRender", this, this._triggerAds);
|
||||
},
|
||||
|
||||
@observes("listLoading")
|
||||
waitForLoad() {
|
||||
if (this.get("adRequested")) {
|
||||
return;
|
||||
} // already requested that this ad unit be populated
|
||||
if (!this.get("listLoading")) {
|
||||
Ember.run.scheduleOnce("afterRender", this, this._triggerAds);
|
||||
}
|
||||
},
|
||||
|
||||
@discourseComputed("currentUser.trust_level")
|
||||
showToTrustLevel(trustLevel) {
|
||||
return !(
|
||||
trustLevel && trustLevel > this.siteSettings.codefund_through_trust_level
|
||||
);
|
||||
},
|
||||
|
||||
@discourseComputed(
|
||||
"showToTrustLevel",
|
||||
"showToGroups",
|
||||
"showAfterPost",
|
||||
"showOnCurrentPage"
|
||||
)
|
||||
showAd(showToTrustLevel, showToGroups, showAfterPost, showOnCurrentPage) {
|
||||
return (
|
||||
this.siteSettings.codefund_property_id &&
|
||||
showToTrustLevel &&
|
||||
showToGroups &&
|
||||
showAfterPost &&
|
||||
showOnCurrentPage
|
||||
);
|
||||
},
|
||||
|
||||
@discourseComputed("postNumber")
|
||||
showAfterPost(postNumber) {
|
||||
if (!postNumber) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return this.isNthPost(parseInt(this.siteSettings.codefund_nth_post, 10));
|
||||
}
|
||||
});
|
|
@ -1,29 +0,0 @@
|
|||
{{#if showAd}}
|
||||
{{#if site.mobileView}}
|
||||
{{#if displayPostBottom}}
|
||||
{{partial "components/codefund/post-bottom"}}
|
||||
{{/if}}
|
||||
{{#if displayTopicAbovePostStream}}
|
||||
{{partial "components/codefund/topic-above-post-stream"}}
|
||||
{{/if}}
|
||||
{{#if displayTopicAboveSuggested}}
|
||||
{{partial "components/codefund/topic-above-suggested"}}
|
||||
{{/if}}
|
||||
{{#if displayTopicListTop}}
|
||||
{{partial "components/codefund/topic-list-top"}}
|
||||
{{/if}}
|
||||
{{else}}
|
||||
{{#if displayPostBottom}}
|
||||
{{partial "components/codefund/post-bottom"}}
|
||||
{{/if}}
|
||||
{{#if displayTopicAbovePostStream}}
|
||||
{{partial "components/codefund/topic-above-post-stream"}}
|
||||
{{/if}}
|
||||
{{#if displayTopicAboveSuggested}}
|
||||
{{partial "components/codefund/topic-above-suggested"}}
|
||||
{{/if}}
|
||||
{{#if displayTopicListTop}}
|
||||
{{partial "components/codefund/topic-list-top"}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
|
@ -1,9 +0,0 @@
|
|||
<span class="codefund-wrapper codefund-post-bottom">
|
||||
<a href="{{adDetails.campaignUrl}}" class="codefund-text" target="_blank" rel="noopener">
|
||||
{{#if siteSettings.codefund_display_advertiser_labels}}
|
||||
<span class="codefund-label">{{siteSettings.codefund_advertiser_short_label}}</span>
|
||||
{{/if}}
|
||||
<strong>{{adDetails.headline}}</strong> {{adDetails.body}}
|
||||
</a>
|
||||
<img src="{{adDetails.impressionUrl}}" class="codefund-pixel">
|
||||
</span>
|
|
@ -1,12 +0,0 @@
|
|||
<span class="codefund-wrapper codefund-topic-above-post-stream">
|
||||
<a href="{{adDetails.campaignUrl}}" class="codefund-text" target="_blank" rel="noopener">
|
||||
{{#if siteSettings.codefund_display_advertiser_labels}}
|
||||
<span class="codefund-label">{{siteSettings.codefund_advertiser_label}}</span>
|
||||
{{/if}}
|
||||
<strong>{{adDetails.headline}}</strong> {{adDetails.body}}
|
||||
</a>
|
||||
<a href={{adDetails.codefundUrl}} class="codefund-powered-by" target="_blank" rel="noopener">
|
||||
ads via codefund.io
|
||||
</a>
|
||||
<img src="{{adDetails.impressionUrl}}" class="codefund-pixel">
|
||||
</span>
|
|
@ -1,12 +0,0 @@
|
|||
<span class="codefund-wrapper codefund-topic-above-suggested">
|
||||
<a href="{{adDetails.campaignUrl}}" class="codefund-text" target="_blank" rel="noopener">
|
||||
{{#if siteSettings.codefund_display_advertiser_labels}}
|
||||
<span class="codefund-label">{{siteSettings.codefund_advertiser_label}}</span>
|
||||
{{/if}}
|
||||
<strong>{{adDetails.headline}}</strong> {{adDetails.body}}
|
||||
</a>
|
||||
<a href={{adDetails.codefundUrl}} class="codefund-powered-by" target="_blank" rel="noopener">
|
||||
ads via codefund.io
|
||||
</a>
|
||||
<img src="{{adDetails.impressionUrl}}" class="codefund-pixel">
|
||||
</span>
|
|
@ -1,12 +0,0 @@
|
|||
<span class="codefund-wrapper codefund-topic-list-top">
|
||||
<a href="{{adDetails.campaignUrl}}" class="codefund-text" target="_blank" rel="noopener">
|
||||
{{#if siteSettings.codefund_display_advertiser_labels}}
|
||||
<span class="codefund-label">{{siteSettings.codefund_advertiser_label}}</span>
|
||||
{{/if}}
|
||||
<strong>{{adDetails.headline}}</strong> {{adDetails.body}}
|
||||
</a>
|
||||
<a href={{adDetails.codefundUrl}} class="codefund-powered-by" target="_blank" rel="noopener">
|
||||
ads via codefund.io
|
||||
</a>
|
||||
<img src="{{adDetails.impressionUrl}}" class="codefund-pixel">
|
||||
</span>
|
|
@ -134,83 +134,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
.codefund-wrapper {
|
||||
z-index: 1;
|
||||
font-family: system, "Helvetica Neue", Helvetica, Arial;
|
||||
font-size: 13px;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
line-height: 1.5;
|
||||
display: block;
|
||||
background-color: $primary-very-low;
|
||||
padding: 12px 11px;
|
||||
text-align: left;
|
||||
margin: 12px 0;
|
||||
}
|
||||
|
||||
.codefund-wrapper .codefund-text {
|
||||
color: dark-light-choose($primary-medium, $secondary-medium);
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.codefund-wrapper .codefund-text:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.codefund-wrapper .codefund-text strong {
|
||||
color: $primary;
|
||||
}
|
||||
|
||||
.codefund-wrapper .codefund-powered-by:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.codefund-wrapper .codefund-label {
|
||||
margin-right: 4px;
|
||||
padding: 2px 6px;
|
||||
border-radius: 3px;
|
||||
background-color: $tertiary;
|
||||
color: $secondary;
|
||||
}
|
||||
|
||||
.codefund-wrapper .codefund-label:hover {
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.codefund-wrapper .codefund-powered-by {
|
||||
text-decoration: none;
|
||||
color: dark-light-choose($primary-medium, $secondary-medium);
|
||||
float: right;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.codefund-wrapper .codefund-powered-by:hover {
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.codefund-wrapper.codefund-post-bottom {
|
||||
width: calc(#{$topic-body-width} + 67px);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@media all and (max-width: 775px) {
|
||||
.codefund-wrapper.codefund-post-bottom {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.codefund-wrapper.codefund-topic-above-suggested {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.codefund-wrapper .codefund-pixel {
|
||||
visibility: hidden;
|
||||
height: 1px;
|
||||
width: 1px;
|
||||
}
|
||||
|
||||
#carbonads {
|
||||
display: block;
|
||||
overflow: hidden;
|
||||
|
|
|
@ -10,7 +10,6 @@ en:
|
|||
dfp_plugin: 'DFP/Ad Manager'
|
||||
adsense_plugin: 'AdSense'
|
||||
amazon_plugin: 'Amazon'
|
||||
codefund_plugin: 'CodeFund'
|
||||
carbonads_plugin: 'Carbon Ads'
|
||||
adbutler_plugin: 'AdButler'
|
||||
adplugin:
|
||||
|
|
|
@ -89,17 +89,6 @@ en:
|
|||
amazon_mobile_post_bottom_ad_height_code: "Input your ad height (mobile)"
|
||||
amazon_nth_post_code: "Show an ad after every N posts, where N is this value."
|
||||
|
||||
codefund_property_id: "Your CodeFund property ID"
|
||||
codefund_advertiser_label: "Label that appears before the advertisement (e.g. Advertiser or Supporter)"
|
||||
codefund_advertiser_short_label: "Abbreviated label that appears before the advertisement (e.g. Ad)"
|
||||
codefund_display_advertiser_labels: "Show the advertiser label (e.g. 'Advertiser') on the ads"
|
||||
codefund_through_trust_level: "Show your ads to users based on trust levels. Users with trust level higher than this value will not see ads"
|
||||
codefund_nth_post: "Show an ad after every N posts, where N is this value"
|
||||
codefund_below_post_enabled: "Show an ad below each post"
|
||||
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_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."
|
||||
|
|
|
@ -380,40 +380,6 @@ amazon_plugin:
|
|||
client: true
|
||||
default: ""
|
||||
|
||||
codefund_plugin:
|
||||
codefund_property_id:
|
||||
client: true
|
||||
default: ""
|
||||
codefund_advertiser_label:
|
||||
client: true
|
||||
default: "Advertiser"
|
||||
codefund_advertiser_short_label:
|
||||
client: true
|
||||
default: "Ad"
|
||||
codefund_through_trust_level:
|
||||
client: true
|
||||
default: 2
|
||||
enum: "TrustLevelSetting"
|
||||
codefund_nth_post:
|
||||
client: true
|
||||
default: 4
|
||||
min: 1
|
||||
codefund_display_advertiser_labels:
|
||||
default: true
|
||||
client: true
|
||||
codefund_below_post_enabled:
|
||||
default: true
|
||||
client: true
|
||||
codefund_above_post_stream_enabled:
|
||||
default: true
|
||||
client: true
|
||||
codefund_above_suggested_enabled:
|
||||
default: true
|
||||
client: true
|
||||
codefund_top_of_topic_list_enabled:
|
||||
default: true
|
||||
client: true
|
||||
|
||||
carbonads_plugin:
|
||||
carbonads_serve_id:
|
||||
client: true
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RemoveCodefundSiteSettings < ActiveRecord::Migration[5.2]
|
||||
def up
|
||||
execute <<~SQL
|
||||
DELETE FROM site_settings
|
||||
WHERE name IN (
|
||||
'codefund_property_id',
|
||||
'codefund_advertiser_label',
|
||||
'codefund_advertiser_short_label',
|
||||
'codefund_through_trust_level',
|
||||
'codefund_nth_post',
|
||||
'codefund_display_advertiser_labels',
|
||||
'codefund_below_post_enabled',
|
||||
'codefund_above_post_stream_enabled',
|
||||
'codefund_above_suggested_enabled',
|
||||
'codefund_top_of_topic_list_enabled'
|
||||
)
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue