Add a get-option to enable noscript view of a page

AI-generated summary

The discussion is about adding a get-option to enable a noscript view of a page on Discourse forums. rubo77 suggests adding a link to the read-only view at the bottom of the page, allowing users to print or translate the page without JavaScript enabled. A patch has been proposed to add a ?noscript parameter to achieve this, but it currently lacks a stylesheet.

rubro77 has made changes to the code, but the issue remains unsolved. codinghorror questions the need for a noscript view, suggesting users can change their browser’s user agent instead. However, rubo77 explains that the goal is to make sites like Google Translate work with Discourse without JavaScript.

Other users discuss the idea of an AMP (Accelerated Mobile Pages) view, but rubo77 clarifies that this is a separate issue. eviltrout mentions an existing parameter _escaped_fragment_ that can be used to get a crawlable version of the page, but rubo77 points out that this also lacks a stylesheet.

The discussion concludes with rubo77 suggesting that adding a “print-view” link with the ?noscript option would be a simple solution, requiring only two lines of code changes.

If you watch a discourse forum with javascript disabled, you get a read-only view of that page.

could you add a link to the read-only view at the bottom? so you can for example print the whole page or translate it with google,…

also a functioning noscript view of a search result should be easy to implement with this option. At the moment it doesn’t work without js like this:
https://meta.discourse.org/search?q=something

إعجاب واحد (1)

The patch should be added here:


Perhaps `params.key?(:noscript)

إعجابَين (2)

I changed the line to

def use_crawler_layout? 
  @use_crawler_layout ||= (has_escaped_fragment? || params.key?(:noscript) || CrawlerDetection.crawler?(request.user_agent))
end

And this seems to work, if I add ?noscript=1 to any site, I get the crawler-view, but the stylesheet is not included there, I guess there has to be changed somethhing in the layout too?

Why would you need this? Just set the user agent in your browser as required.

We could build an AMP view of the topic page for quick loading for first-time, anonymous visitors.

I guess you refer to Google Accelerated Mobile Pages, to accelerate content loading on mobile devices.
I think that’s another issue.

My point here is to make sites like Google translate work with discourse by adding a parameter not to use JavaScript.

Don’t see the point of amp, we already have html views, just beef them up and expose

Isn’t a beefed up HTML view and AMP basically the same thing? What got me excited about AMP was that it seemed like a good specification for a beefed up Discourse HTML front-end to target.

There is already a param for this: _escaped_fragment_ – just add it to any URL to get the crawlable version.

إعجاب واحد (1)

But that’s also without stylesheet: Add a get-option to enable noscript view of a page

Try this instead: disable JavaScript and look at this page.
It has a style and is crawlable

I have a WIP AMP view on my machine, triggered by adding ?amp to the URL.

It has some code quality issues which is why I haven’t shared it yet, also waiting on some pretty bad bugs to be resolved with the AMP script.

Oh I see you are advocating for a basic no-JS discourse.

Your patch however does not do that of course, but the issue is not _escaped_fragment it’s that we’ve never programmed that functionality.

We have discussed improving the no-JS layout but it hasn’t been a priority yet. It’s designed to be crawled now which it does well.

إعجابَين (2)

It would be so easy, to just add a link aat the bottom: “print-view” that leads to adding the ?noscript option. I think only two lines of code have to be changed:

  • the one above and
  • one line (to be found) where the stylesheet will be included in case the option is set

does anybody understand the code, to tell this second lline? then the patch would be ready to be implemented

Why do you need print links? Just do File, Print in your browser.

Not really following anything about what you are doing or requesting here.

3 إعجابات

It seems broken in Chrome stable OS X 10.9.5. Choosing File, Print pops up the dialog for about a second then, before any interaction, it disappears and nothing is printed.

It did that for me too, but when I do it a second time, it remains open… very weird. Chrome stable (v45) on Linux

Seems to only affected me if I’m logged in. Opening an incognito window and trying to Print seems to work. Exact Chrome version is 46.0.2490.71 (64-bit).

I want two things:

  • a link, that I can feed into google translator that works.
  • create a working search function that works, when javascript is disabled
إعجاب واحد (1)

[quote=“eviltrout, post:9, topic:33823, full:true”]
There is already a param for this: escaped_fragment – just add it to any URL to get the crawlable version.
[/quote]his doesn’t work anyway:

→ https://meta.discourse.org/search?q=something&_escaped_fragment_

[quote=“rubo77, post:20, topic:33823, full:true”]

search page doesn’t show anything if you disable javascript, differrent issue IMO.

إعجاب واحد (1)