On Oct 6, 2009, at 1:35 PM, mdipierro wrote: > It is good practice to put in the CSS only relative urls to other > static files. That is not a problem with web2py. > > If you need to include in the CSS urls generated by {{=URL(....)}} > then you should promote the css from a static file to a dynamic page: > 1) make a controller for it > 2) make a view ending in .css > 3) call the action from the layout ending in .css > 4) in the .css view use absolute paths to include images
When I tried serving dynamic CSS (I wanted to dynamically control colors, fonts, etc), I had to do some work to get the result served as text/css (which is necessary). I ended up hacking that (and some other header stuff, like caching) in the controller, but I suppose it could happen in the view. I notice that there's no generic.css. I have a controller, css.py, that looks like this: import time from gluon.storage import Storage def __cssheaders(): ''' edit default response headers for CSS serve text/css with limited caching ''' response.cookies = Storage() response.headers['Content-Type']='text/css' response.headers['Cache-Control'] = 'max-age=3600, must-revalidate' if 'Last-Modified' in response.headers: del response.headers ['Last-Modified'] if 'Expires' in response.headers: del response.headers['Expires'] if 'Pragma' in response.headers: del response.headers['Pragma'] def xxx(): ''' app/css/xxx.css set fonts and colors to be substituted via xxx.css view ''' __cssheaders() font_serif = 'cambria, georgia, "times new roman", serif' font_sans = 'corbel, "Helvetica Neue", Helvetica, Arial, sans- serif' return dict(dark_color="#8e1650", second_color="#635e54", light_color="#e9e7de", accent_color="#edab05", flash_color="white", flash_background="#8e1650", body_background_color="#e8e8e8", content_background_color="white", font_body=font_serif, font_logo=font_sans, font_head=font_sans,) --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web2py@googlegroups.com To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/web2py?hl=en -~----------~----~----~----~------~----~------~--~---