Updating Docuss to work with new Discourse

You were right @syl, Docuss isn’t working with the new version of Discourse.

What skillset would you recommend for someone coming in to update it, and i’ll start looking for them? A real shame we weren’t able to help anyone during the pandemic but there’s still a lot of good we can do in the world :slight_smile:

If you have any ideas or advice you could pass along it would be greatly received.

Here’s the error message i see in console when i turn the plugin on

_vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:4060 jQuery.Deferred exception: Cannot read property 'docuss_enabled' of undefined TypeError: Cannot read property 'docuss_enabled' of undefined
    at t.init (https://publichappinessmovement.com/assets/plugins/dcs-discourse-plugin2-d5a2afbef6e65827a5bca8eb6418538c503074b92771b50d7ddc037245d84905.js:1:16200)
    at Object.initialize (https://publichappinessmovement.com/assets/plugins/dcs-discourse-plugin2-d5a2afbef6e65827a5bca8eb6418538c503074b92771b50d7ddc037245d84905.js:1:505)
    at Object.i.initialize (https://publichappinessmovement.com/assets/application-978ebde8070485e566b085968e5a3242ea6f538ba518507dfbbbe311e292aa06.js:1:202281)
    at https://publichappinessmovement.com/assets/vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:36:254194
    at e.each (https://publichappinessmovement.com/assets/vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:36:417034)
    at e.walk (https://publichappinessmovement.com/assets/vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:36:416050)
    at e.each (https://publichappinessmovement.com/assets/vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:36:415400)
    at e.topsort (https://publichappinessmovement.com/assets/vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:36:415446)
    at n._runInitializer (https://publichappinessmovement.com/assets/vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:36:254425)
    at n.runInstanceInitializers (https://publichappinessmovement.com/assets/vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:36:254138) undefined
Uncaught TypeError: Cannot read property 'docuss_enabled' of undefined
    at t.init (_dcs-discourse-plugin2-d5a2afbef6e65827a5bca8eb6418538c503074b92771b50d7ddc037245d84905.js:2140)
    at Object.initialize (_dcs-discourse-plugin2-d5a2afbef6e65827a5bca8eb6418538c503074b92771b50d7ddc037245d84905.js:40)
    at Object.i.initialize (_application-978ebde8070485e566b085968e5a3242ea6f538ba518507dfbbbe311e292aa06.js:7893)
    at _vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:49347
    at e.each (_vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:67724)
    at e.walk (_vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:67638)
    at e.each (_vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:67568)
    at e.topsort (_vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:67576)
    at n._runInitializer (_vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:49361)
    at n.runInstanceInitializers (_vendor-d0c9e6c505a84fa8f3e94def4d2b21ca24b3da8a8d3d2ae26f90b26f3ea9fa94.js:49345)
/logs/report_js_error:1 Failed to load resource: net::ERR_BLOCKED_BY_CLIENT

The 1st half is a yellow advisory. The second is the red breaking issue.

Anyone working on this issue, here’s other info you’ll need:

The changes to tags look sus to me.

Copying messages across from kind people who have offered to help on Reddit

Charles_Stover says:

The error is happening here:

export function init(a,b){
  if (b.SiteSettings.docuss_enabled) { // <--

It’s happening because you are calling the init function, passing an options object that does not contain a SiteSettings property.

The initialization function appears to be exposed here.

I suspect your code, somewhere, says:

initialize(container, { some, object, here })

where the object does not contain SiteSettings. This call may be abstracted away for you by the plugin system.

If your codebase contains a function called runInstanceInitializers, I’d check that. I’m not familiar with Discourse or Docuss at all, so I can’t really debug any further without seeing the source code of your website itself.

Jack_Waugh says:

If anyone is taking the time to dig into Discourse, I would like to know the mapping from the “raw” text they store, to the HTML (or DOM manipulations) it is translated into. I know they use some version of Markdown, and they also do some mapping along the lines of what is called “BBcode” or something like that, and I guess that includes the [quote]…[/quote] sequences. But I think the docs don’t make clear the order of composition of the mapping functions, and also exactly which version of each.

ghepard3007 says:

I’m not familiar with this technology, but it seems it breaks at the initialization point, specifically the app.SiteSettings variable is undefined.

If I’d guess, I’d say it’s something about the configuration of the plugin? Or something else not getting initialized before the plugin. Maybe check the configuration steps from the plugin’s repository?

Other things I’d try: clear cache, clear tmp folder, try to access SiteSettings from this => in lib.js.es6 change b.SiteSettings. docuss_enabled to this.SiteSettings.docuss_enabled

LextersDuboratory says:

After looking over the github repo, I have to agree with u/bezier-curve [[+1]](javascript:void 0) as I dont think it’s salvageable either. Most files look to be just config or simple setups except for the 2 files located in the lib folder (dcs-discourse-plugin/assets/javascripts/discourse/lib at master · sylque/dcs-discourse-plugin · GitHub) and that would be a pain to sort through and try and figure out where the bug is.

If you still have access to the original dev, then I’d suggest asking them if they can provide an un-minified version of the code.

@syl has offered to provide the source code directly to anyone who is working on upgrading it, but would rather not post it publicly as he says “it’s really hacky, up to the point that I would be ashamed of showing it publicly”.

Our plan now is to fix the breaking issues, then clean it up, then opensource it for others to use, improve and mod :slight_smile:

I’ve just published a new version of the Docuss plugin, which includes the unminified source code:

It seems to run well with the latest Discourse version.
Notice, however, that it contains bugs (mostly cosmetic, I hope) introduced in the past year by the evolutions of the Discourse codebase.

1 Like

Oh, that’s very cool. I’ll check it out right away. This would then be a more cosmetic bug hunt.

Thank you Sylvain :orange_heart:

This, and some other bugs I fixed this morning, were due to changes in the Discourse API during the last year.

You should expect more surprises. In particular, Docuss uses CSS a lot to hide Discourse features (tags, etc.). But as the Discourse team often modifies the HTML structure of Discourse, the Docuss CSS file will need to be updated.

1 Like

Great. I’ll update the testing server 1st to check it out as there is no-way to roll back. The last update was a big one from them, a lot of plugins broke. Hopefully they won’t do that again for a long while.

ok, the forum is loading again now. thanks to @syl and @ghepard3007

1st success of the day!

The issue now is that the app is timing out. it looks like a “same-origin” issue we had before which we think is the plugin not communicating with the dcs client libraries.

We can also now access the admin area here with the app on. I’m going to dig in there.

edit: it died again the next morning bizarrely

Couldn’t sleep so I’ve been playing around and i’ve been able to force a different error message from console:

The normal message ha returned to:

Failed to load resource: the server responded with a status of 504 ()
chromewebdata/:1 Refused to display 'https://fl-maps.publichappinessmovement.com/' in a frame because it set 'X-Frame-Options' to 'sameorigin'

The message i was able to force was… i hope of more value:

Uncaught (in promise) TypeError: Cannot read property 'forEach' of undefined
    at _dcs-discourse-plugin-8a9dc570f7d436d5b75f8f0129885e6478b876909a07c086fe2bac5124b50766.js:3873
    at _dcs-discourse-plugin-8a9dc570f7d436d5b75f8f0129885e6478b876909a07c086fe2bac5124b50766.js:3839
    at async Promise.all (/index 1)
    at async Promise.all (/index 0)

Which lead to:

  function transformOriginalDescr(descr, jsonUrl) {
    // Transform page urls from relative to absolute
    descr['pages'].forEach(function (page) {
      page['url'] = new URL(page['url'], jsonUrl).href;
  } //------------------------------------------------------------------------------


  // Load the embedded website descriptor from the url of the json data
  var loadWebsiteDescr = function loadWebsiteDescr(jsonUrls, validCatNames, proxyUrl) {
    // Load and check all jsonUrl separately
    var loadAll = jsonUrls.map(function (jsonUrl) {
      return getJSON(jsonUrl).then(function (descr) {
        transformOriginalDescr(descr, jsonUrl);
        var clone = (0, _deepCloneJSON.deepCloneJSON)(descr);

( line 3839 is transformOriginalDescr(descr, jsonUrl); )

@syl do these errors mean anything to you?

(i raised all user DB levels. turned off all other plugins and hit this message when reloading the site after a few times)

One last thought. We also load youtube videos inside each event using YT’s code. These probably load in i-frames and i wouldn’t be surprised if YT have changed their embed code. Would that be enough to prevent our app from loading with an x-frame same origin error?

@Marvelxy and @JFort you are also both welcome to weigh in if anything above looks familiar to you

1 Like

I’ve just fixed a bug in Docuss:

Maybe it will help, I’m not sure. Please upgrade the plugin and let me know.

1 Like

Thanks @syl i tried that but get the same error, although i found something else thats interesting.

This url 504 times out: https://fl-maps.publichappinessmovement.com/map?discourse-login=true

This url loads: https://fl-maps.publichappinessmovement.com

This url also loads: https://fl-maps.publichappinessmovement.com/map

Yes, the app is loading but crashing when a user tries to login. It runs ok in incognito mode. That’s going to be Docuss failing to communicate with the DB, right?

I get this error in the console:

Refused to display ‘https://fl-maps.publichappinessmovement.com/’ in a frame because it set ‘X-Frame-Options’ to ‘sameorigin’.

The server-side code that deals with CORS in your webapp is here:

It seems it’s correctly included in your project, but you might want to check (with a console.log() in the terminal, for example) that this function is properly called.

If it is, then maybe this code doesn’t work anymore, for whatever reason (change in Meteor behavior, etc.). You might try to replace it with this:

WebApp.rawConnectHandlers.use(function(req, res, next) {
  res.setHeader("Access-Control-Allow-Origin", "*");
  res.setHeader("Access-Control-Allow-Headers", "Authorization,Content-Type");
  return next();

(source here)

1 Like

Thank you @syl. I seem to have lost permission to make pull requests on Github somewhere along the line as mine are being blocked and not building in Travis. I’ll resolve that and make a PR asap to test that out. It certainly sounds like the error message we’re seeing :slight_smile:

1 Like

actually @syl can you make PRs on our repo?

You can see i’ve made a commit here: Adding Syl’s suggested change · focallocal/[email protected] · GitHub

Would you mind just submitting the same commit to the deploy-phm branch as a PR if you still have access? Pretty sure i can approve them.

Not sure I understand what you mean, but I’m notoriously unskilled with git :slight_smile:
AFAICS, your change has already been committed in deploy-phm.

1 Like

It has been, but the Git is built by Travis and its been blocked saying my PRs are unauthorised. I’ve asked Tom to look into it, but i get the idea he’s pretty busy the last few days.