Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When build in local mode, links in sidebar will be absolute so it doesn't work on a different machine #9

Closed
nantas opened this issue Oct 29, 2015 · 8 comments
Assignees

Comments

@nantas
Copy link
Contributor

nantas commented Oct 29, 2015

If use relative path in sidebar links, open a file in a sub folder will cause relative path to be invalid:

href='./modules/my_page.html' works for index.html, but in modules/my_page.html, the link will be modules/modules/my_page.html

@yorkie
Copy link
Contributor

yorkie commented Oct 30, 2015

@nantas how about integrating a tiny server with the generated files? Actually I created a file server https:/yorkie/serve which is only 140KB and most importantly, it doesn't require any runtime.

So that we can remove the local mode, and use HTTP anywhere, the file protocol really sucks on us, isn't it :-)

@nantas
Copy link
Contributor Author

nantas commented Nov 10, 2015

it would be great if we can get around http server so that we can create api docs that are portable and can be opened anywhere.

Just need to figure out how to get each page's path when rendering template.

@nantas
Copy link
Contributor Author

nantas commented Nov 11, 2015

It works great for viewing pages locally, but I found a glitch when access generated website. To reproduce:

  1. First complete firedoc build (I believe --http option is not relevant now, correct?)
  2. start a http server in output directory
  3. open the index page of the website, eg: localhost:8000/index.html
  4. Click on any module or class link in left sidebar, now the main page has updated with your module or class information.
  5. But the links in left sidebar are not updated. Now when you inspect the same module/class link you'll see ./modules/MyModule.html as in root level pages, insead of ../modules/MyModule.html
  6. If you refresh the web page, all links will be correct. If you jump from one module page to another it's also good.

So what happened when user jump from index page to a module page? Why the link is not updated?

@nantas nantas reopened this Nov 11, 2015
@nantas
Copy link
Contributor Author

nantas commented Nov 11, 2015

Another issue, ../base works fine for page level links such as modules and classes: https:/fireball-x/firedoc-theme-notab/blob/master/partials/sidebar.handlebars#L11

But it doesn't work for properties and methods link (sidebar-members):
https:/fireball-x/firedoc-theme-notab/blob/master/partials/sidebar-members.handlebars#L9

In one of those sidebar-member template, I can get one level of parent correctly {{../this}} will return module context correctly, but {{../../this}} will not go up any further.

So I cannot get view.base from sidebar-member template. Any idea how to get around this?

@yorkie
Copy link
Contributor

yorkie commented Nov 11, 2015

try this one {{../../view.base}}?

@nantas
Copy link
Contributor Author

nantas commented Nov 12, 2015

nah, in sidebar-member template it can only go up one level, ../this and ../../this point to the same parent context.

@nantas
Copy link
Contributor Author

nantas commented Nov 12, 2015

ok, a tad more research shows me the discussion on handlebars issues:

handlebars-lang/handlebars.js#182
handlebars-lang/handlebars.js#392

This problem has been confirmed long ago and the solution is to use @root from partial template to get the context of where the template starts rendering, you can search @root in this API reference doc:

http://handlebarsjs.com/reference.html

I've updated the #10 to fix sidebar member links.

nantas added a commit to nantas/firedoc-theme-notab that referenced this issue Nov 12, 2015
@nantas
Copy link
Contributor Author

nantas commented Nov 12, 2015

sidebar link updating issue is located, see discussion in #10 (comment)

@nantas nantas closed this as completed Nov 14, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants