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
aways use posix paths on generated relative paths in html #206
Conversation
@@ -23,7 +24,7 @@ def read_asset(*paths): | |||
|
|||
|
|||
def get_relpath(path, current): | |||
return os.path.relpath(path, os.path.dirname(current)) | |||
return posixpath.relpath(path, os.path.dirname(current)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@shashigharti
BTW it's a good way to solve the problem when we need "/" on windown we had similar situation with ZIP files if you remember. So we could have used this posixpath
module
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aivuk
Good catch!
I would make the solution more explicit. Currently, this function is called helpers.get_relpath
. One expect that it will be a relative path on UNIX and Windows. So after the fix, this function seems to be misleading for me.
I would add a new function helpers.get_relurl/get_url_relpath/get_relative_url
with this implementation and use it in the codebase (probably all the get_relpath
usage needs to be replaced by the new function)
…ent with get_relpath
@roll I added get_url_repath and changed some places to use it, but I still haven't tested on windows. Not all places that I changed I'm sure if we need a POSIX path or the local OS one. I will test in few minutes (as soon as my Ubuntu finish upgrading and I can reboot my machine!). |
@roll tested the branch in windows, generated the website at https://github.com/Andrelamor/erros-validacao and it worked. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
livemark build
on Windows #205With livemark is used in Windows, outside a POSIX compliant system the generated URLs inside the generated HTML will have Window back slashes (\folder\file instead of /folder/file). This happens because of how
gel_relapath
is generating the path using os.path.join. os.path always follows the format of the current OS, this means, if you are in windows it is going to use back slashes. The problem happens that urls follow POSIX path, with this slash /.I don't know if there are other places that we need to change the paths to POSIX ones. If we just change everywhere that os.path is used, this will causes problems for windows user when livemark need to open a file somewhere.