rustdoc
rustdoc copied to clipboard
Investigate the best way to load data.json
So, in order to preserve the ability to load off of the file system, we currently make a relative call to load data.json https://github.com/steveklabnik/rustdoc/blob/master/frontend/app/routes/application.js#L6
But, this means that if yo uhit any URL other than the root, it mis-loads it.
We should find some way to fix this. Loading with /
works in every case except when you're browsing as file://
. ☹️
Hey @steveklabnik, so I'm coming into this completely out of the blue and looking for frontend-tagged issues and don't really have any Ember experience 😛 , but if the only issue is literally file://
itself and we're always in a browser, would it be sufficient to do something like fetch((document.location.protocol === 'file:' ? '/' : '') + 'data.json')
(possibly exploded into multiple lines for readability)?
that's an interesting idea! Quite possibly!
Disclaimer: New to ember.
I'm trying to fix this, but I'm finding a bunch of questions on StackOverflow that say that you just can't run ember without a server, because the relative paths won't resolve correctly. In addition, even if you fix them, the router will break. There is an ember plugin that lets you render everything statically, but that would require us knowing all the visitable routes upfront.
Not sure if there's a solution here other than running the ember server, or booting out ember and keeping everything static.
that you just can't run ember without a server, because the relative paths won't resolve correctly.
Yeah so I've seen some buggy behavior when not loading up the root, even though by loading up the root it does work.
I think this stackoverflow post gives some insight as to why and this one. Looks like ember-cli without a server is a no go.
Soooo I've been thinking about this, and I'm not even sure we need to load it as ajax. Consider current rustdoc, for example: the search index is a js file that defines an object, like this: https://doc.rust-lang.org/stable/search-index.js
we could do the same, and then not even make the ajax call at all, and this would remove this path issue.
That seems reasonable. If we don't need to make any Ajax calls at all that would be great. The docs are best treated as a static site for the most part.
Won't we still run into the same issues with ember? It would still be
looking for the file at /
.
On Wed, Aug 9, 2017, 5:48 PM Michael Gattozzi [email protected] wrote:
That seems reasonable. If we don't need to make any Ajax calls at all that would be great. The docs are best treated as a static site for the most part.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/steveklabnik/rustdoc/issues/76#issuecomment-321391021, or mute the thread https://github.com/notifications/unsubscribe-auth/ABTxFmusl5ASGMyW7ml7Y6YJYhumEuu5ks5sWikpgaJpZM4OlgbW .
@euclio no, because the js gets concatenated, there's only one file.
Oh well, that'd be at build time, it'd end up being two files. Hm.
It still should work it's just figuring out how to work it into the tooling.
Is this all going to live in the same route? If not, we would still need ember to use the server to resolve the paths correctly. If so, why not just generate static HTML from data.json?