slara / generator-reveal

Yeoman generator for Reveal.js
MIT License
429 stars 52 forks source link

Fails to get the Markdown or HTML files in the slides directory in Chrome, cross platform. #83

Closed vizJS closed 7 years ago

vizJS commented 7 years ago

Problem

Slideshow stops and shows error dialogue, awaiting user interaction, every time index.html loads an html or markdown slide in Chrome. On both Mac OS X 10.11 and Windows Vista.

Steps to Recreate the Issue

  1. start up the generator to create a new reveal.js slideshow with command
    yo reveal
  2. Give just enough info for the generator to complete. Scss use or disuse won't change the outcome.
  3. Build with grunt dist command. Necessary.
  4. open dist/index.html in Chrome

Alternatively, just make a new html or markdown slide with

yo reveal:slide "New Slide Title"

with or without the --markdown or --attributes, build, and open dist/index.html in Chrome. The result will be the same.

Result

When index.html loads, a pop up error dialogue box appears that says:

Failed to get the Markdown file slides/index.md. Make sure that the presentation and the file are served by a HTTP server and the file can be found there. NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///< project folder path >/dist/slides/index.md'.

The slide show just sits there waiting for user interaction, effectively disabled. There is a checkbox to disable future dialogues from this page. Once the error is acknowledged by clicking the 'OK' button, the slide show continues and plays as normal, except for two things:

  1. Whenever the body-keepers.html slide would show, only it's background image shows instead.
  2. It fails in the same way every time index.html refreshes.

Interestingly, the issue doesn't appear when opening http://localhost:9000/, only when opening index.html or dist/index.html directly.

My application requires a 5 minute auto-refresh cycle in Chrome, with no NodeJS supported on the release machine, and so this bug disables my use of this tool, except if I continue to produce slide content exclusively in the form of background images. I wish I had discovered this before I developed all that content!!! It took me a while to discover, because my slides were initially just background images attached in the attributes for each slide, with zero markdown or html references. Ouch!

First Response

As a temporary fix, I:

Diagnostic Efforts

Then to try to diagnose the issue, I:

Status

At this point it's very clear to me that this is a fault in generator-reveal. So I'm reporting to you!

I imagine further steps could be taken to narrow down the source of the XmlHttpRequest error. I don't yet know what those steps would be.

slara commented 7 years ago

Hi @vizJS, do you have a presentation example so we can reproduce the problem? Thanks!

janraasch commented 7 years ago

Hi @vizJS, you already described the solution to your problem here, when saying

Interestingly, the issue doesn't appear when opening http://localhost:9000/, only when opening index.html or dist/index.html directly.

The behavior you are seeing is due to a security restriction in your browser when using the file:// protocol. The error message

Failed to get the Markdown file slides/index.md. Make sure that the presentation and the file are served by a HTTP server and the file can be found there. NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load 'file:///< project folder path >/dist/slides/index.md'.

already includes the hint

Make sure that the presentation and the file are served by a HTTP server and the file can be found there.

So, this is not a bug, you just need to access your index.html via an http server (not via file://).

slara commented 7 years ago

Hi @vizJS, as @janraasch said, you need a http server. You could use something like python -m SimpleHTTPServeror Node's http-server.

vizJS commented 7 years ago

Thank you for the clarification. I understand now what was happening, and I'll concede that the generator appears to be working as it was designed to.

I had different expectations for the behavior of the generated app in Chrome, based on the behavior I'd observed in Safari. My mistake!

When running the produced html files in Safari, the generator effectively creates a standalone html slider without any need of an http server. This would have been very useful to me if it had also worked that way in Chrome.

Unfortunately, I can't run Safari in production. So altho the generator works as designed, I'll still need to find a workaround for my particular use case.

The key constraints are that I don't have admin privileges, and I have to run in Chrome on Windows Vista. Strange, I know. I guess my next step is to find a preferred http server I can install in user mode.

Thank you again for making this tool, and for your timely response to my issue!

dralexk commented 6 years ago

With Firefox, there is no problem displaying via file://