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

Clean URLs that contain dots do not work with the built-in server #278

Open
callaa opened this issue May 30, 2015 · 4 comments
Open

Clean URLs that contain dots do not work with the built-in server #278

callaa opened this issue May 30, 2015 · 4 comments

Comments

@callaa
Copy link

callaa commented May 30, 2015

The built-in server, when using the urlcleaner plugin, does not resolve clean URLs containing dots (e.g. "/news/release-1.0.0/") correctly.
The culprit seems to be this line in server.py (function translate_path):

if path.strip() == "" or File(path).kind.strip() == "":

If the path contains a dot, File(path).kind will return the part after the last dot. A more robust approach might be to see if the file does not exists and then try the choices from strip_extensions.

@llonchj
Copy link
Contributor

llonchj commented May 30, 2015

@callaa I have investigated the case.

My first thought about the UrlCleanerPlugin is that this feature has to be followed with specific web server url-rewrite configuration.

@lakshmivyas, shall UrlCleanerPlugin be a production plugin? If not, will fix the issue.

@navilan
Copy link
Member

navilan commented May 31, 2015

@llonchj: @callaa's problem is a specific one in that his path has dots, but they are not file extension related dots and hence they are being missed. So his suggested approach is a good one. I'd say that:
https://github.com/hyde/hyde/blob/master/hyde/server.py#L68
should be the first conditional that we evaluate.

@llonchj
Copy link
Contributor

llonchj commented May 31, 2015

The bug itself is simple to fix.

@lakshmivyas, my question was about the plugin. +1 on having clean URL's.

The plugin updates urls by removing extensions based on strip_extensions setting.

Generated markup using this plugin makes URL's makes them not to match the static file.

Publishing a site using this plugin requires some kind of URL-rewrite configuration in the production web server.

And this is why hyde server source code has to be modified, creating sort-of-coupling between the plugin and core functionality, including this current bug. This is the reason why I was asking about.

From the architectural point of view, core functionality and plugins shall be completely decoupled.

IMHO, a possible solution will be to improve the plugin in order to rename every node from /news/releases-1.0.0.html to /news/releases-1.0.0/index.html? Something like that will be tricky and require to set the base tag. This solution will not require patching hyde server or having to define URL-rewrite clauses in the production web server.

Another solution, will be to filter the plugin to mode=="production".

Does that make sense?

@navilan
Copy link
Member

navilan commented Jun 1, 2015

And this is why hyde server source code has to be modified, creating sort-of-coupling between the plugin and > core functionality, including this current bug. This is the reason why I was asking about.

I see. Yes. In the long term, ideally the plugins should have an event related to serving. Perhaps a translate URL for serving event, which could also help us in doing the url rewrites in the future.

Right now though, since URL Cleaner is the only plugin with such a dependency, we could potentially fix the issue in the server code knowing that there would be a better solution in the long term.

Another solution, will be to filter the plugin to mode=="production".

While this is certainly something that will help avoid these corner case issues and keep the server simple, it also makes the behavior of the local site different from the production site and may cause issues with automated tests and even applications as it involves URLs. Hyde is also used in a lot of rich js applications.

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

3 participants