asciidoctor / docgist

Render AsciiDoc documents from Gists, GitHub, DropBox and other remote sources in the browser.
http://gist.asciidoctor.org
57 stars 79 forks source link

Absolute image paths on GitHub #17

Closed mojavelinux closed 9 years ago

mojavelinux commented 9 years ago

I think that an absolute image path in a document rendered from GitHub should refer to the root of the repository. Currently, it doesn't work.

You can see an example here: http://gist.asciidoctor.org/?github-powerman%2Fasciidoc-cheatsheet%2F%2FREADME.adoc (look for the screenshot)

This is definitely an edge case and I'm wondering if it should work. Really, a document shouldn't be relying on absolute paths because then it won't work when used locally (only on a web server). But I'm filing this issue for reference in case people come across the use case and are curious about it...regardless of what we decide to do.

nawroth commented 9 years ago

I thought about that case yesterday but didn't get around implementing it!

nawroth commented 9 years ago

When creating a web site using AsciiDoc it might make sense to use root-relative locations.

BTW this has two aspects: root-relative settings for imagesdir and root-relative src on the images themselves.

nawroth commented 9 years ago

See: http://nawroth.github.io/docgist/?github-powerman%2Fasciidoc-cheatsheet%2F%2FREADME.adoc It also fixes the link to the image!

nawroth commented 9 years ago

It now works for GitHub repos, but not in most other cases. Feel free to reopen @mojavelinux

mojavelinux commented 9 years ago

What are the other cases it doesn't work? You mean Dropbox or gist?

nawroth commented 9 years ago

GitHub gists are more or less impossible as they don't allow binary data.

We would need code to cover Dropbox and copy.com. I think it works well enough for "unidentified URLs".

mojavelinux commented 9 years ago

GitHub gists are more or less impossible as they don't allow binary data.

Actually they do. It's just that the only way to get the file there is by using the git client.

Here's an example:

http://gist.asciidoctor.org/?f56f067d595eae1e2974

What's funny is that the images don't work in GitHub's gist, but I can make them work on docgist (note that right now I'm hardcoding the image URL...maybe we can calculate it).