Help wanted on plugin controller

AI-generated summary

In the “Help wanted on plugin controller” thread, RGJ reports issues developing a Sitemap plugin for Discourse, specifically that the controller code is never executed, resulting in a “page not found” error despite correct routing attempts. zogstrip suggests the problem might be duplicate routes for sitemap.xml. RGJ later shares a workaround involving monkey-patching robots_txt instead of using the engine. EndruK confirms experiencing the same issue where controller methods are not called. Although RGJ admits the original controller issue was never resolved, EndruK provides a solution involving adding a client-side route equivalent to the server route and calling the server controller from the client. However, RGJ counters that this advice is inapplicable because robots.txt is requested by search engine bots rather than users, rendering the Ember route map unnecessary for this specific use case.

We’re building a Sitemap plugin and I’m running into an issue.

(Yes there has been a lot of discussion around the need for a sitemap, but Google News totally requires it)

Somehow the code in the controller is never executed and I get the regular “The page you requested doesn’t exist or is private” message.

Because I suspected an issue with the view, I have stripped the code so it should only output a log line and an error, but this doesn’t work either.

Code is here:
https://github.com/communiteq/discourse-sitemap/blob/master/plugin.rb#L20-L26

Running it does this:

If I rename the generate method or change the route, I get an error that the controller could not be found, so I should be on the right path here. Is there anyone who can spot (the probably very trivial) issue?

Why do you have two routes for get "sitemap.xml" ?

I have now monkey patched robots_txt to make it work, and commented out the part that references the engine.

This is the commit you should be looking at

Did you get it to work?
I got exactly the same problem, that my controller method code never gets called but the application knows the controller and his methods.

Regards

No, I was never able to get that fixed :frowning:

You need a client route as equivalent for a server route
https://meta.discourse.org/t/custom-home-page-to-discourse/12329/2?u=endruk

And on the client you have to call the server controller:

Hope this helps you :slight_smile:

robots.txt is requested by search engine bots, not by the user.
So there is no need / use for an Ember route map…