On Dec 2, 2011, at 8:28 AM, Anthony wrote: > I thought CSS files interpreted relative URLs relative to the CSS file > itself, not the page in which it was loaded. If the CSS file is in > /static/css and the font is in /static/plugin_framework/fonts, maybe src: > url(../plugin_framework/fonts/websymbols-regular-webfont.woff) will work.
I think that's right, and also it ignores <base>. IE6 excepted, perhaps. My comments below apply only to relative URLs in the html file. > > Anthony > > On Friday, December 2, 2011 11:10:25 AM UTC-5, Jonathan Lundell wrote: > On Dec 2, 2011, at 7:41 AM, monotasker wrote: > >> It resolves to >> http://127.0.0.1:8000/topoi/plugin_listandedit/list/notes/static/plugin_framework/fonts/websymbols-regular-webfont.woff >> >> This is treating the font url as relative to the full request URL (including >> arguments), not the app root directory. That's what's confusing me. > > This is when your url is 'static/...', right? That's normal behavior, and > nothing to do with web2py. The browser knows that it accessed > http://127.0.0.1:8000/topoi/plugin_listandedit/list/notes and all relative > URLs are relative to that path. The browser knows nothing about how elements > of the path are interpreted by the server; a path is a path. > > To summarize, what you want is this: > >> >> http://127.0.0.1:8000/topoi/static/plugin_framework/fonts/websymbols-regular-webfont.woff > > but without specifying 'topoi', because you want it appname-independent, > right? > > One option is the <base> tag (generated dynamically via a template, so you > don't type the appname literally): > > <base href="/topoi/" /> > > The problem is that it applies to *all* relative URLs, so make sure you take > that into account. Fortunately the URL() helper always generates absolute > URLs. > > Another option is to server your CSS files dynamically via a css controller. > Depending on your application, the performance hit needn't be too bad if you > make sure that the generated pages are cached by the browser. This is a handy > technique, because it lets you parameterize anything you like in your CSS.