From 3fc872520e507ecd8ea60893149b9e6245faec13 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Fri, 10 Jul 2020 18:09:32 +0300 Subject: [PATCH] FIX: CodeFund is shutting down (#85) --- README.md | 6 - .../discourse/components/ad-slot.js.es6 | 11 -- .../discourse/components/codefund-ad.js.es6 | 139 ------------------ .../templates/components/codefund-ad.hbs | 29 ---- .../components/codefund/post-bottom.hbs | 9 -- .../codefund/topic-above-post-stream.hbs | 12 -- .../codefund/topic-above-suggested.hbs | 12 -- .../components/codefund/topic-list-top.hbs | 12 -- assets/stylesheets/adplugin.scss | 77 ---------- config/locales/client.en.yml | 1 - config/locales/server.en.yml | 11 -- config/settings.yml | 34 ----- ...703082449_remove_codefund_site_settings.rb | 25 ++++ 13 files changed, 25 insertions(+), 353 deletions(-) delete mode 100644 assets/javascripts/discourse/components/codefund-ad.js.es6 delete mode 100644 assets/javascripts/discourse/templates/components/codefund-ad.hbs delete mode 100644 assets/javascripts/discourse/templates/components/codefund/post-bottom.hbs delete mode 100644 assets/javascripts/discourse/templates/components/codefund/topic-above-post-stream.hbs delete mode 100644 assets/javascripts/discourse/templates/components/codefund/topic-above-suggested.hbs delete mode 100644 assets/javascripts/discourse/templates/components/codefund/topic-list-top.hbs create mode 100644 db/migrate/20200703082449_remove_codefund_site_settings.rb diff --git a/README.md b/README.md index fb15a45..6d20dec 100644 --- a/README.md +++ b/README.md @@ -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.
  • House Ads - if you want to create and serve ads from your Discourse instance.
  • Adsense - if using Adsense as your advertisement platform.
  • DFP - if using the DoubleClick for Publishers advertisement platform.
  • -
  • CodeFund - if using the CodeFund ethical advertisement platform.
  • Carbon Ads - if using the Carbon Ads advertisement platform.
  • AdButler - if using the AdButler advertisement platform.
  • @@ -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) diff --git a/assets/javascripts/discourse/components/ad-slot.js.es6 b/assets/javascripts/discourse/components/ad-slot.js.es6 index 741ce93..608d3e3 100644 --- a/assets/javascripts/discourse/components/ad-slot.js.es6 +++ b/assets/javascripts/discourse/components/ad-slot.js.es6 @@ -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", diff --git a/assets/javascripts/discourse/components/codefund-ad.js.es6 b/assets/javascripts/discourse/components/codefund-ad.js.es6 deleted file mode 100644 index c480d37..0000000 --- a/assets/javascripts/discourse/components/codefund-ad.js.es6 +++ /dev/null @@ -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)); - } -}); diff --git a/assets/javascripts/discourse/templates/components/codefund-ad.hbs b/assets/javascripts/discourse/templates/components/codefund-ad.hbs deleted file mode 100644 index 1c0f80d..0000000 --- a/assets/javascripts/discourse/templates/components/codefund-ad.hbs +++ /dev/null @@ -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}} \ No newline at end of file diff --git a/assets/javascripts/discourse/templates/components/codefund/post-bottom.hbs b/assets/javascripts/discourse/templates/components/codefund/post-bottom.hbs deleted file mode 100644 index b7d990a..0000000 --- a/assets/javascripts/discourse/templates/components/codefund/post-bottom.hbs +++ /dev/null @@ -1,9 +0,0 @@ - - - {{#if siteSettings.codefund_display_advertiser_labels}} - {{siteSettings.codefund_advertiser_short_label}} - {{/if}} - {{adDetails.headline}} {{adDetails.body}} - - - diff --git a/assets/javascripts/discourse/templates/components/codefund/topic-above-post-stream.hbs b/assets/javascripts/discourse/templates/components/codefund/topic-above-post-stream.hbs deleted file mode 100644 index bcdba6b..0000000 --- a/assets/javascripts/discourse/templates/components/codefund/topic-above-post-stream.hbs +++ /dev/null @@ -1,12 +0,0 @@ - - - {{#if siteSettings.codefund_display_advertiser_labels}} - {{siteSettings.codefund_advertiser_label}} - {{/if}} - {{adDetails.headline}} {{adDetails.body}} - - - ads via codefund.io - - - diff --git a/assets/javascripts/discourse/templates/components/codefund/topic-above-suggested.hbs b/assets/javascripts/discourse/templates/components/codefund/topic-above-suggested.hbs deleted file mode 100644 index f7923b6..0000000 --- a/assets/javascripts/discourse/templates/components/codefund/topic-above-suggested.hbs +++ /dev/null @@ -1,12 +0,0 @@ - - - {{#if siteSettings.codefund_display_advertiser_labels}} - {{siteSettings.codefund_advertiser_label}} - {{/if}} - {{adDetails.headline}} {{adDetails.body}} - - - ads via codefund.io - - - diff --git a/assets/javascripts/discourse/templates/components/codefund/topic-list-top.hbs b/assets/javascripts/discourse/templates/components/codefund/topic-list-top.hbs deleted file mode 100644 index b1fe950..0000000 --- a/assets/javascripts/discourse/templates/components/codefund/topic-list-top.hbs +++ /dev/null @@ -1,12 +0,0 @@ - - - {{#if siteSettings.codefund_display_advertiser_labels}} - {{siteSettings.codefund_advertiser_label}} - {{/if}} - {{adDetails.headline}} {{adDetails.body}} - - - ads via codefund.io - - - diff --git a/assets/stylesheets/adplugin.scss b/assets/stylesheets/adplugin.scss index cffe702..46b32e8 100644 --- a/assets/stylesheets/adplugin.scss +++ b/assets/stylesheets/adplugin.scss @@ -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; diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 4fe27f5..4b5db05 100755 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -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: diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index a29c679..a6c73bf 100755 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -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." diff --git a/config/settings.yml b/config/settings.yml index 871c729..131febd 100755 --- a/config/settings.yml +++ b/config/settings.yml @@ -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 diff --git a/db/migrate/20200703082449_remove_codefund_site_settings.rb b/db/migrate/20200703082449_remove_codefund_site_settings.rb new file mode 100644 index 0000000..58f878f --- /dev/null +++ b/db/migrate/20200703082449_remove_codefund_site_settings.rb @@ -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