Discourse Plugin Dev Notes: neo-revive-discourse

Yesterday I forked the discourse official ad plugin with an eye toward running ads to unregistered users many months from now, maybe next year, if traffic significantly goes up, based on search engine SEO voodoo and magic.

Basically, the existing "official plugin" (before forking) serves ads to registered users based on trust level and it also had no trust level threshold for house ads, so I have started changing this plugin, step-by-step. The ad placements are also not very nice, so I started to work on that as well. No hurry, since ads are not going to served to unregistered users anytime soon.

So far:

Versions

  • Version 1.2.6.3 16 Map 2020, ADD: Disable house ads for members (overrides TLs).
  • Version 1.2.6.2 16 Map 2020, ADD: Trust levels for house ads.
  • Version 1.2.6.1 16 Map 2020, INIT: Remove cors, use iframe for now.
  • Version 1.2.6.0 15 May 2020, INIT: Add site setting to enable / disable

TODO

  • Disable ads for members setting for all ad types.
  • Fix ad placement errors (poor placements) in CSS/HTML

However, since I have a working discourse development environment on my mac now, it's must faster to develop plugins, so I will work on this "second plugin" from time to time.

2 Likes

I totally cloned this and started a fresh repo because I am afraid I will accidentally push a PR out to the official plugin repo and have the meta team beating me up again.

Also, I will make a lot of changes to this plugin over time, and I don't want to argue or quibble with the meta dev team on the changes I need to make.

So, far (and I am barely getting started):

  • Version 1.2.6.5 16 May 2020, CLONED: Avoid accidential PR issues with orig plugin.
  • Version 1.2.6.4 16 May 2020, FIX: topic-above-suggested placement CSS
  • Version 1.2.6.3 16 May 2020, ADD: Disable house ads for members (overrides TLs).
  • Version 1.2.6.2 16 May 2020, ADD: Trust levels for house ads.
  • Version 1.2.6.1 16 May 2020, INIT: Remove cors, use iframe for now.
  • Version 1.2.6.0 15 May 2020, INIT: Add site setting to enable / disable

The good news is that discourse plugin skills are increasing :slight_smile:

1 Like

Done for the day modifying this plugin only to use months down the road:

Summary of changes so far

Versions

  • Version 1.2.6.8 16 May 2020, MOVE: Disable ads for members to top level settings
  • Version 1.2.6.7 16 May 2020, ADD: Disable ads for members (adsense,dfp,codefund,amazon, adbutler, but not carbon ads)
  • Version 1.2.6.6 16 May 2020, FIX: typos
  • Version 1.2.6.5 16 May 2020, CLONED: Avoid accidential PR issues with orig plugin.
  • Version 1.2.6.4 16 May 2020, FIX: topic-above-suggested placement CSS
  • Version 1.2.6.3 16 May 2020, ADD: Disable house ads for members (overrides TLs).
  • Version 1.2.6.2 16 May 2020, ADD: Trust levels for house ads.
  • Version 1.2.6.1 16 May 2020, INIT: Remove cors, use iframe for now.
  • Version 1.2.6.0 15 May 2020, INIT: Add site setting to enable / disable

TODO

  • Fix ad placement errors (poor placements) in CSS/HTML
  • Search for more things to fix and bugs to squash
2 Likes

Mobile house ad component is "broken", so I created a new switch and code to turn it off for mobile:

Versions

  • Version 1.2.6.9 17 May 2020, ADD: Disable house ads on mobile (mobile house ads broken)
  • Version 1.2.6.8 16 May 2020, MOVE: Disable ads for members to top level settings
  • Version 1.2.6.7 16 May 2020, ADD: Disable ads for members (adsense,dfp,codefund,amazon, adbutler, but not carbon ads)
  • Version 1.2.6.6 16 May 2020, FIX: typos
  • Version 1.2.6.5 16 May 2020, CLONED: Avoid accidential PR issues with orig plugin.
  • Version 1.2.6.4 16 May 2020, FIX: topic-above-suggested placement CSS
  • Version 1.2.6.3 16 May 2020, ADD: Disable house ads for members (overrides TLs).
  • Version 1.2.6.2 16 May 2020, ADD: Trust levels for house ads.
  • Version 1.2.6.1 16 May 2020, INIT: Remove cors, use iframe for now.
  • Version 1.2.6.0 15 May 2020, INIT: Add site setting to enable / disable

TODO

  • Setting disable ads for carbon ads.
  • Fix mobile house ads (currently not working properly).
  • Disable ads for members setting for all ad types.
  • Fix ad placement errors (poor placements) in CSS/HTML

Found a error after clearing the cache after two days, where the original name of the plugin was hard-coded into the path of the include files. So, I re-forked the original repo and updated that branch because I don't want to work on removing the hard coded paths, just yet (added to TODO list).

The NOT Official Discourse Ad Plugin

This is the NOT official Discourse advertising plugin. It is a WIP by neo@unix.com for development.

Cloned from original, official plugin (avoiding PR errors during WIP):

https://github.com/discourse/discourse-adplugin

Authors: Sarah Ni & Vi Nguyen & unixneo

Version: 1.2.6.15

Contributors: See the original repo (link above) for all the prior coders and team

License: MIT License

REFACTOR: WIP

Versions

  • Version 1.2.6.14 17 May 2020, FIX: change repo name to discourse-adplugin (harded coded into plugin by original authors)
  • Version 1.2.6.13 17 May 2020, FIX: ember registration conflict (2)
  • Version 1.2.6.12 17 May 2020, WIP: debug ember registration conflict
  • Version 1.2.6.11 17 May 2020, FIX: ember registration conflict
  • Version 1.2.6.10 17 May 2020, ADD: Enable content security policy (experimental, not working yet)
  • Version 1.2.6.9 17 May 2020, ADD: Disable house ads on mobile (mobile house ads broken)
  • Version 1.2.6.8 16 May 2020, MOVE: Disable ads for members to top level settings
  • Version 1.2.6.7 16 May 2020, ADD: Disable ads for members (adsense,dfp,codefund,amazon, adbutler, but not carbon ads)
  • Version 1.2.6.6 16 May 2020, FIX: typos
  • Version 1.2.6.5 16 May 2020, CLONED: Avoid accidential PR issues with orig plugin.
  • Version 1.2.6.4 16 May 2020, FIX: topic-above-suggested placement CSS
  • Version 1.2.6.3 16 May 2020, ADD: Disable house ads for members (overrides TLs).
  • Version 1.2.6.2 16 May 2020, ADD: Trust levels for house ads.
  • Version 1.2.6.1 16 May 2020, INIT: Remove cors, use iframe for now.
  • Version 1.2.6.0 15 May 2020, INIT: Add site setting to enable / disable

TODO

  • Remove hard coded paths dependant on name of plugin by original authors
  • Fix CORS issue with house ads with script tags.
  • Setting disable ads for carbon ads.
  • Fix mobile house ads (currently not working properly).
  • Disable ads for members setting for all ad types.
  • Fix ad placement errors (poor placements) in CSS/HTML

After working with this plugin for a few days, I think there is an easier way to create a plugin for the Revive ad server.

So for now, I'm going to stop work on the main branch (at version 1.2.6.19 below) and create a new branch where I strip out most of the functionality (from 1.2.6.19) and create a much simple plugin.


REFACTOR: WIP 1.2.6.19

Versions

  • Version 1.2.6.19 18 May 2020, WIP: Debug CORS roadblock (site settings)
  • Version 1.2.6.18 17 May 2020, WIP: Revive ad server component CORS roadblock
  • Version 1.2.6.17 17 May 2020, WIP: Revive ad server component begin
  • Version 1.2.6.16 17 May 2020, ADD: Settings, on/off switches and more (house, adsense, dfp)
  • Version 1.2.6.14 17 May 2020, FIX: change repo name to discourse-adplugin (harded coded into plugin by original authors)
  • Version 1.2.6.13 17 May 2020, FIX: ember registration conflict (2)
  • Version 1.2.6.12 17 May 2020, WIP: debug ember registration conflict
  • Version 1.2.6.11 17 May 2020, FIX: ember registration conflict
  • Version 1.2.6.10 17 May 2020, ADD: Enable content security policy (experimental, not working yet)
  • Version 1.2.6.9 17 May 2020, ADD: Disable house ads on mobile (mobile house ads broken)
  • Version 1.2.6.8 16 May 2020, MOVE: Disable ads for members to top level settings
  • Version 1.2.6.7 16 May 2020, ADD: Disable ads for members (adsense,dfp,codefund,amazon, adbutler, but not carbon ads)
  • Version 1.2.6.6 16 May 2020, FIX: typos
  • Version 1.2.6.5 16 May 2020, CLONED: Avoid accidential PR issues with orig plugin.
  • Version 1.2.6.4 16 May 2020, FIX: topic-above-suggested placement CSS
  • Version 1.2.6.3 16 May 2020, ADD: Disable house ads for members (overrides TLs).
  • Version 1.2.6.2 16 May 2020, ADD: Trust levels for house ads.
  • Version 1.2.6.1 16 May 2020, INIT: Remove cors, use iframe for now.
  • Version 1.2.6.0 15 May 2020, INIT: Add site setting to enable / disable

TODO

  • Debug CORS issues with Revive ad server (CORS in general)
  • Remove hard coded paths dependant on name of plugi
  • Debug logic issue with adsense on/off switch
  • Remove hard coded paths dependant on name of plugin by original authors
  • Fix CORS issue with house ads with script tags.
  • Setting disable ads for carbon ads.
  • Fix mobile house ads (currently not working properly).
  • Disable ads for members setting for all ad types.
  • Fix ad placement errors (poor placements) in CSS/HTML

Version 1.2.7.1 REFACTOR FOR HOUSE ONLY (REVIVE AD SERVER)

After working on this plugin for a few days, I noticed that, when we run our own ad server, we don't need most of this plugin. This plugin (before) acts as an ad server, and to be honest, is a poor implementation of an adserver, for sure. It's best to run our own add server.

Also,after three days of working with the original plugin, I also noticed that a better starting point is "house ads" component, and so I have refactored this plugin in the "house-only" branch.

So, I updated and am now going to work on a new "house-only" branch where I have:

  • Deleted all non-house ad code,
  • Deleted all non-english locales, settings, etc.

https://github.com/unixneo/discourse-adplugin/tree/house-only

Versions

  • Version 1.2.7.1 19 May 2020, Strip non-house ad code, strip non-english locales
  • Version 1.2.7.0 19 May 2020, Create branch for house ads only
  • Version 1.2.6.19 18 May 2020, WIP: Debug CORS roadblock (site settings)
  • Version 1.2.6.18 17 May 2020, WIP: Revive ad server component CORS roadblock
  • Version 1.2.6.17 17 May 2020, WIP: Revive ad server component begin
  • Version 1.2.6.16 17 May 2020, ADD: Settings, on/off switches and more (house, adsense, dfp)
  • Version 1.2.6.14 17 May 2020, FIX: change repo name to discourse-adplugin (harded coded into plugin by original authors)
  • Version 1.2.6.13 17 May 2020, FIX: ember registration conflict (2)
  • Version 1.2.6.12 17 May 2020, WIP: debug ember registration conflict
  • Version 1.2.6.11 17 May 2020, FIX: ember registration conflict
  • Version 1.2.6.10 17 May 2020, ADD: Enable content security policy (experimental, not working yet)
  • Version 1.2.6.9 17 May 2020, ADD: Disable house ads on mobile (mobile house ads broken)
  • Version 1.2.6.8 16 May 2020, MOVE: Disable ads for members to top level settings
  • Version 1.2.6.7 16 May 2020, ADD: Disable ads for members (adsense,dfp,codefund,amazon, adbutler, but not carbon ads)
  • Version 1.2.6.6 16 May 2020, FIX: typos
  • Version 1.2.6.5 16 May 2020, CLONED: Avoid accidential PR issues with orig plugin.
  • Version 1.2.6.4 16 May 2020, FIX: topic-above-suggested placement CSS
  • Version 1.2.6.3 16 May 2020, ADD: Disable house ads for members (overrides TLs).
  • Version 1.2.6.2 16 May 2020, ADD: Trust levels for house ads.
  • Version 1.2.6.1 16 May 2020, INIT: Remove cors, use iframe for now.
  • Version 1.2.6.0 15 May 2020, INIT: Add site setting to enable / disable

TODO

  • Debug CORS issues with Revive ad server (CORS in general)
  • Remove hard coded paths dependant on name of plugi
  • Debug logic issue with adsense on/off switch
  • Remove hard coded paths dependant on name of plugin by original authors
  • Fix CORS issue with house ads with script tags.
  • Setting disable ads for carbon ads.
  • Fix mobile house ads (currently not working properly).
  • Disable ads for members setting for all ad types.
  • Fix ad placement errors (poor placements) in CSS/HTML

Yay.

I have completed phase one of stripping out and deleting most of the code we don't need to serve ads (in the future) to unregistered users using, in my new "house-only" branch

TODO

  • Fix mobile house ads (currently not working properly).
  • Debug CORS issues with Revive ad server (CORS in general)
  • Remove hard coded paths dependant on name of plugin (by original authors)
  • Fix ad placement errors (poor placements) in CSS/HTML

Schedule

Currently, I am many months ahead of schedule on this plugin. All of the TODO issues are easy to fix except the CORS issue, which I will have to test in deployment because I cannot get the CORS issues to work in dev, for some reason. For this reason, I have added a new switch to only show the ads to the admins so I can debug CORS in the future without showing ads to others.

1 Like

Now, mobile ads are almost working in the "house-only" branch:

https://github.com/unixneo/discourse-adplugin/tree/house-only

Notes

With version 1.2.7.4 can enter both mobile and desktop ads as house ads. Ads with 'mobile' in the name will be array filtered into the mobile ad array and those without will be filtered into the desktop ad array. This creates a small bug in the randomizer for the array index which needs to be fixed.

Version

  • Version 1.2.7.4.0 19 May 2020, Added initial code for mobile ads
  • Version 1.2.7.3 19 May 2020, Add "show to admins only" setting for live site testing
  • Version 1.2.7.2 19 May 2020, Test and finish stripping non-house ads, set up dev scss for testing
  • Version 1.2.7.1 19 May 2020, Strip non-house ad code, strip non-english locales
  • Version 1.2.7.0 19 May 2020, Create branch for house ads only
  • Version 1.2.6.19 18 May 2020, WIP: Debug CORS roadblock (site settings)
  • Version 1.2.6.18 17 May 2020, WIP: Revive ad server component CORS roadblock
  • Version 1.2.6.17 17 May 2020, WIP: Revive ad server component begin
  • Version 1.2.6.16 17 May 2020, ADD: Settings, on/off switches and more (house, adsense, dfp)
  • Version 1.2.6.14 17 May 2020, FIX: change repo name to discourse-adplugin (harded coded into plugin by original authors)
  • Version 1.2.6.13 17 May 2020, FIX: ember registration conflict (2)
  • Version 1.2.6.12 17 May 2020, WIP: debug ember registration conflict
  • Version 1.2.6.11 17 May 2020, FIX: ember registration conflict
  • Version 1.2.6.10 17 May 2020, ADD: Enable content security policy (experimental, not working yet)
  • Version 1.2.6.9 17 May 2020, ADD: Disable house ads on mobile (mobile house ads broken)
  • Version 1.2.6.8 16 May 2020, MOVE: Disable ads for members to top level settings
  • Version 1.2.6.7 16 May 2020, ADD: Disable ads for members (adsense,dfp,codefund,amazon, adbutler, but not carbon ads)
  • Version 1.2.6.6 16 May 2020, FIX: typos
  • Version 1.2.6.5 16 May 2020, CLONED: Avoid accidential PR issues with orig plugin.
  • Version 1.2.6.4 16 May 2020, FIX: topic-above-suggested placement CSS
  • Version 1.2.6.3 16 May 2020, ADD: Disable house ads for members (overrides TLs).
  • Version 1.2.6.2 16 May 2020, ADD: Trust levels for house ads.
  • Version 1.2.6.1 16 May 2020, INIT: Remove cors, use iframe for now.
  • Version 1.2.6.0 15 May 2020, INIT: Add site setting to enable / disable

TODO

  • Fix bug in house-ads.js regarding array indexing because of mobile tags
  • Debug CORS issues with Revive ad server (CORS in general)
  • Remove hard coded paths dependant on name of plugin by original authors
  • Fix CORS issue with house ads with script tags.
  • Fix mobile house ads (currently not working properly).
  • Fix ad placement errors (poor placements) in CSS/HTML

First Redesign of this plugin mostly done. Need to test in staging server on Internet with public IP address and FQDN to research into why there is a CORS issue.

Version

  • Version 1.2.7.5 20 May 2020, Fix ad randomizer for mobile, paths.
  • Version 1.2.7.4.0 19 May 2020, Added initial code for mobile ads
  • Version 1.2.7.3 19 May 2020, Add "show to admins only" setting for live site testing
  • Version 1.2.7.2 19 May 2020, Test and finish stripping non-house ads, set up dev scss for testing
  • Version 1.2.7.1 19 May 2020, Strip non-house ad code, strip non-english locales
  • Version 1.2.7.0 19 May 2020, Create branch for house ads only
  • Version 1.2.6.19 18 May 2020, WIP: Debug CORS roadblock (site settings)
  • Version 1.2.6.18 17 May 2020, WIP: Revive ad server component CORS roadblock
  • Version 1.2.6.17 17 May 2020, WIP: Revive ad server component begin
  • Version 1.2.6.16 17 May 2020, ADD: Settings, on/off switches and more (house, adsense, dfp)
  • Version 1.2.6.14 17 May 2020, FIX: change repo name to discourse-adplugin (harded coded into plugin by original authors)
  • Version 1.2.6.13 17 May 2020, FIX: ember registration conflict (2)
  • Version 1.2.6.12 17 May 2020, WIP: debug ember registration conflict
  • Version 1.2.6.11 17 May 2020, FIX: ember registration conflict
  • Version 1.2.6.10 17 May 2020, ADD: Enable content security policy (experimental, not working yet)
  • Version 1.2.6.9 17 May 2020, ADD: Disable house ads on mobile (mobile house ads broken)
  • Version 1.2.6.8 16 May 2020, MOVE: Disable ads for members to top level settings
  • Version 1.2.6.7 16 May 2020, ADD: Disable ads for members (adsense,dfp,codefund,amazon, adbutler, but not carbon ads)
  • Version 1.2.6.6 16 May 2020, FIX: typos
  • Version 1.2.6.5 16 May 2020, CLONED: Avoid accidential PR issues with orig plugin.
  • Version 1.2.6.4 16 May 2020, FIX: topic-above-suggested placement CSS
  • Version 1.2.6.3 16 May 2020, ADD: Disable house ads for members (overrides TLs).
  • Version 1.2.6.2 16 May 2020, ADD: Trust levels for house ads.
  • Version 1.2.6.1 16 May 2020, INIT: Remove cors, use iframe for now.
  • Version 1.2.6.0 15 May 2020, INIT: Add site setting to enable / disable

TODO

  • Debug CORS issues with Revive ad server (CORS in general).

TODO DEAD CODE

  • Delete dead CSS code for removed ad networks.
  • Remove dead code(?): templateName: "connectors/post-bottom/discourse-adplugin",

Duplicated this "house-only" branch to a new repo before live testing on Internet (off development server on desktop):

Version

  • Version 1.2.8.0 20 May 2020, Move to new repo, neo-revive-discourse

TODO

  • Debug CORS issues with Revive ad server (CORS in general).

TODO DEAD CODE

  • Delete dead CSS code for removed ad networks.
  • Remove dead code(?): templateName: "connectors/post-bottom/discourse-adplugin",

No open issues at this time (all known issues resolved)

Version : 1.2.9.0

Contributors : See the original repo (link above) for all the prior coders and team

License : MIT License

REFACTOR: WIP

Notes

With version 1.2.7.4 can enter both mobile and desktop ads as house ads. Ads with 'mobile' in the name will be array filtered into the mobile ad array and those without will be filtered into the desktop ad array. Also, need to make ads a computed property so they will change without reload (mobile, desktop). This is a workaround since the Revive ad server does not support fully responsive ads.

Version

  • Version 1.2.9.0 20 May 2020, Fixed script tag issue vis-a-vis emberjs.
  • Version 1.2.8.1 20 May 2020, Tried to fix script tag rendering issue with safeHtml(), no joy.
  • Version 1.2.8.0 20 May 2020, Move to new repo, neo-revive-discourse
  • Version 1.2.7.5 20 May 2020, Fix ad randomizer for mobile, paths.
  • Version 1.2.7.4.0 19 May 2020, Added initial code for mobile ads
  • Version 1.2.7.3 19 May 2020, Add "show to admins only" setting for live site testing
  • Version 1.2.7.2 19 May 2020, Test and finish stripping non-house ads, set up dev scss for testing
  • Version 1.2.7.1 19 May 2020, Strip non-house ad code, strip non-english locales
  • Version 1.2.7.0 19 May 2020, Create branch for house ads only
  • Version 1.2.6.19 18 May 2020, WIP: Debug CORS roadblock (site settings)
  • Version 1.2.6.18 17 May 2020, WIP: Revive ad server component CORS roadblock
  • Version 1.2.6.17 17 May 2020, WIP: Revive ad server component begin
  • Version 1.2.6.16 17 May 2020, ADD: Settings, on/off switches and more (house, adsense, dfp)
  • Version 1.2.6.14 17 May 2020, FIX: change repo name to discourse-adplugin (harded coded into plugin by original authors)
  • Version 1.2.6.13 17 May 2020, FIX: ember registration conflict (2)
  • Version 1.2.6.12 17 May 2020, WIP: debug ember registration conflict
  • Version 1.2.6.11 17 May 2020, FIX: ember registration conflict
  • Version 1.2.6.10 17 May 2020, ADD: Enable content security policy (experimental, not working yet)
  • Version 1.2.6.9 17 May 2020, ADD: Disable house ads on mobile (mobile house ads broken)
  • Version 1.2.6.8 16 May 2020, MOVE: Disable ads for members to top level settings
  • Version 1.2.6.7 16 May 2020, ADD: Disable ads for members (adsense,dfp,codefund,amazon, adbutler, but not carbon ads)
  • Version 1.2.6.6 16 May 2020, FIX: typos
  • Version 1.2.6.5 16 May 2020, CLONED: Avoid accidential PR issues with orig plugin.
  • Version 1.2.6.4 16 May 2020, FIX: topic-above-suggested placement CSS
  • Version 1.2.6.3 16 May 2020, ADD: Disable house ads for members (overrides TLs).
  • Version 1.2.6.2 16 May 2020, ADD: Trust levels for house ads.
  • Version 1.2.6.1 16 May 2020, INIT: Remove cors, use iframe for now.
  • Version 1.2.6.0 15 May 2020, INIT: Add site setting to enable / disable

TODO

  • No open issues at this time.

TODO DEAD CODE

  • Delete dead CSS code for removed ad networks.
  • Remove dead code(?): templateName: "connectors/post-bottom/discourse-adplugin",

NOTES:

Resolved issue with Ember.js not accepting script tags in handlebar templates by moving the script to the template header for the theme, like so:

<script>
    var js_script = document.createElement('script');
    js_script.type = "text/javascript";
    js_script.src = "https://srv.csavr.com/www/delivery/asyncjs.php";
    js_script.async = true;
    document.getElementsByTagName('head')[0].appendChild(js_script);
</script>

and then calling only this part of revive adserver tag, specifying the ad zone, in the plugin code, like this:

<div style='text-align: center;'>
<ins style='display:inline-block;' data-revive-zoneid="63" data-revive-id="2d220f1e3f63403189face1b493bcc4b"></ins>
</div>

Or better yet, in a template script (for example);

api.onPageChange ((url, title) => {
  var js_script = document.createElement('script'); 
  js_script.type = "text/javascript"; 
   js_script.src = "https://srv.adserver.com/www/delivery/asyncjs.php"; js_script.async = true;
  document.getElementsByTagName('head')[0].appendChild(js_script);
});
1 Like

I just love this. Brilliant.

1 Like

Thanks Brother!

Now, I am going to take a break from coding and s/w development for a while!

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.