Monday, October 29, 2012

managing relative urls for django ssi command

I have a static directory which contains bunch of html files and images. All html files contain links to each other using relative paths. For instance, a page describing an algorithm has a link such as <a href ../../newmethod/algo2.html>Algorithm 2</a>
Everything in this directory works very well in a portable manner in any static server.

I want to use django to add a page banner to each html file under this directory. Is there anyway to achieve this using a template which contains the banner code and includes the static htmls file using an "ssi" directive?

The problem that I cannot find a solution is the relative paths in the static htmls. When I include the static html in the template with ssi, the relative paths (such as the image paths in the html file or links to other pages), becomes completely wrong. In other words, the http client interprets all the relative paths with respect to view's base urls. I guess I may use urlconf to handle the html files, but I cannot foresee a method to correct the inline image paths.

To be more clear let me paraphrase my question once more: Is there any way to serve the content of such a static directory using the django's view functions? It is obvious that HttpResponse(my_static_htmlfile.read()) won't work because, all the links in the returning page will be wrong.

PS: I am not allowed to modify the original html files by any means.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/yQML6twSb_4J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment