Re: staticfile app question

2011-03-31 Thread Javier Guerra Giraldez
On Thu, Mar 31, 2011 at 9:55 AM, Micah Carrick  wrote:
> IMO, relative URLs are preferable in external stylesheets.

+1

-- 
Javier

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



Re: staticfile app question

2011-03-31 Thread Micah Carrick
I had to look up "grok". Guess I'm out of the loop.

Anyway, one other pitfall with using absolute URLs in CSS is that you can
break SSL (https) when you have common CSS for both the SSL and non-SSL
pages. So watch out for that. IMO, relative URLs are preferable in external
stylesheets. In fact, that has been a firm rule in most projects I've been
involved with.

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



RE: staticfile app question

2011-03-31 Thread Chris Matthews
Hi,
I liked this explanation/convention 
http://forum.webfaction.com/viewtopic.php?id=4345 (I opted for this one).

If you want more consider django-css 
https://github.com/dziegler/django-css#readme (I have not tried this).

Regards
Chris


-Original Message-
From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On 
Behalf Of typeshige
Sent: 31 March 2011 01:07
To: Django users
Subject: staticfile app question

Like many people, I'm switching over to use a static directory to
serve site media. Overall, it works extremely well, but I have a
question about one aspect of it.

I have a CSS file that includes urls. I was wondering about the
possibility of the staticfile app inserting the proper STATIC_URL as
it's being collected.

For example, things like:

#container-head {
background: transparent url('/static/img/bg/cap/head-inner-
bg.gif') 50% 0 no-repeat;
}

Would it be a bad idea to write like this:

#container-head {
background: transparent url('{{ STATIC_URL }}img/bg/cap/head-inner-
bg.gif') 50% 0 no-repeat;
}

the collectstatic command could insert the right url as it is being
copied?

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

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



Re: staticfile app question

2011-03-30 Thread Mike Ramirez
On Wednesday, March 30, 2011 05:34:05 pm Jason Culverhouse wrote:

Just to add, if you have a seperate server and/or non-normal directory layout 
for for images and css files, this method doesn't work that well either.  

Again I'm not saying your suggestion is not a good one, it's just not one that 
fits every situation. 

Mike

-- 
You will become rich and famous unless you don't.

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



Re: staticfile app question

2011-03-30 Thread Mike Ramirez
On Wednesday, March 30, 2011 05:34:05 pm Jason Culverhouse wrote:

I don't think you don't grok me, I'm not arguing they aren't allowed and I do 
know how they work. Your suggestion has been thought about, tossed around and 
rejected, way before this conversation took place.

Mike

-- 
Of all forms of caution, caution in love is the most fatal.

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



Re: staticfile app question

2011-03-30 Thread Jason Culverhouse

On Mar 30, 2011, at 5:10 PM, Mike Ramirez wrote:

> On Wednesday, March 30, 2011 05:01:08 pm Jason Culverhouse wrote:
>> On Mar 30, 2011, at 4:50 PM, Mike Ramirez wrote:
>>> On Wednesday, March 30, 2011 04:20:32 pm Shawn Milochik wrote:
 I have the exact same problem. I hope there is a solution, because
 good site design often results in image references in the CSS.
>> 
>> I think you guys are over analyzing the problem
>> 
>> You can use relative urls in css
>> 
>> Just look at
>>  http://www.djangoproject.com/m/css/base.css
>> 
> 
> Never really been a fan of relative urls or paths. It feels clumsy and full 
> of 
> pitfalls. The angst it causes me isn't worth it, since absolute solves all 
> that. 
> 

Some don't immediately grok that the that the url references in the style sheet 
are relative to the css file.  If your reference are relative, then everything 
stays
modular and you'll make a python developer happy when he doesn't have to 
muck  css.

To quote the spec
http://www.w3.org/TR/CSS21/syndata.html#uri
4.3.4 URLs and URIs

"""
In order to create modular style sheets that are not dependent on the absolute
location of a resource, authors may use relative URIs. Relative URIs
(as defined in [RFC3986]) are resolved to full URIs using a base URI.
RFC 3986, section 5, defines the normative algorithm for this process.

For CSS style sheets, the base URI is that of the style sheet, not that of the 
source document.

For example, suppose the following rule:

body { background: url("yellow") }

is located in a style sheet designated by the URI:

http://www.example.org/style/basic.css
The background of the source document's BODY will be tiled with whatever image 
is described by the resource designated by the URI

http://www.example.org/style/yellow

"""

> Mike
> -- 
> Avoid Quiet and Placid persons unless you are in Need of Sleep.
>   -- National Lampoon, "Deteriorata"
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



Re: staticfile app question

2011-03-30 Thread Mike Ramirez
On Wednesday, March 30, 2011 05:01:08 pm Jason Culverhouse wrote:
> On Mar 30, 2011, at 4:50 PM, Mike Ramirez wrote:
> > On Wednesday, March 30, 2011 04:20:32 pm Shawn Milochik wrote:
> >> I have the exact same problem. I hope there is a solution, because
> >> good site design often results in image references in the CSS.
> 
> I think you guys are over analyzing the problem
> 
> You can use relative urls in css
> 
> Just look at
>   http://www.djangoproject.com/m/css/base.css
> 

Never really been a fan of relative urls or paths. It feels clumsy and full of 
pitfalls. The angst it causes me isn't worth it, since absolute solves all 
that. 

Mike
-- 
Avoid Quiet and Placid persons unless you are in Need of Sleep.
-- National Lampoon, "Deteriorata"

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



Re: staticfile app question

2011-03-30 Thread Mike Ramirez
On Wednesday, March 30, 2011 04:58:42 pm Sells, Fred wrote:
> This may be using a canon to swat a fly, but...
> 
> I had a project some time ago where I needed a very repetitive
> java/swing UI.  I ended up creating python classes that had a __repr__
> method that generated the java source code.  Then I was able to have
> very concise python files that instantiated the classes I needed and
> used that to generate java.
> 
> Perhaps a similar idea would work with .css possible even using the
> django template system.
> 

pretty much what I was thinking of.  but not using __repr__ or a string just 
the templates, but the idea is the same. I don't find css to repedative, not 
as much as gui programming, no where near as close, so dynamically creating 
sheets wouldn't be really neccessary. Just fill in existing templates.

You could probably do this with flatpages too.


Mike

-- 
What on earth would a man do with himself if something did not stand in his 
way?
-- H.G. Wells

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



Re: staticfile app question

2011-03-30 Thread Jason Culverhouse

On Mar 30, 2011, at 4:50 PM, Mike Ramirez wrote:

> On Wednesday, March 30, 2011 04:20:32 pm Shawn Milochik wrote:
>> I have the exact same problem. I hope there is a solution, because
>> good site design often results in image references in the CSS.
> 
> 

I think you guys are over analyzing the problem

You can use relative urls in css

Just look at 
http://www.djangoproject.com/m/css/base.css

Assuming this layout under STATIC_URL
{{STATIC_URL}}
css/screen.css
images/header.gif

Just use a relative path in screen.css
#container-head {
   background: transparent url('../images/header.gif') 50% 0 no-repeat;
}

Jason


> The best one I've come up with and it's far from 'best' is to run a command 
> that edits css templates and spits them out to the directory they should be 
> served on at update time. AFAIK DJango can not process the .css files in the 
> media/static directory on the fly.  
> 
> But you might be able to trick it, just thought about this as I was writing 
> above.  Have a url  in urls.py of a regex that ends in '.css' and direct it 
> to 
> a view that serves your css.  
> 
> something like this:
> 
> url(r'^media/css/(?P[\w-]+)\.css$', 'views.css', name='serve-css'),
> 
> with my views.css just for processing css templates.
> 
> I don't know how hard it would be to implement or how well it would work, I 
> haven't done it. It's a thought of this.
> 
> Mike
> 
> 
> -- 
> I appoint you ambassador to Fantasy Island!!!
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.
> 

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



RE: staticfile app question

2011-03-30 Thread Sells, Fred
This may be using a canon to swat a fly, but...

I had a project some time ago where I needed a very repetitive
java/swing UI.  I ended up creating python classes that had a __repr__
method that generated the java source code.  Then I was able to have
very concise python files that instantiated the classes I needed and
used that to generate java.

Perhaps a similar idea would work with .css possible even using the
django template system.

Now I use flex/flash a lot more than html/js/css so I could be out of
touch here



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



Re: staticfile app question

2011-03-30 Thread Mike Ramirez
On Wednesday, March 30, 2011 04:20:32 pm Shawn Milochik wrote:
> I have the exact same problem. I hope there is a solution, because
> good site design often results in image references in the CSS.


The best one I've come up with and it's far from 'best' is to run a command 
that edits css templates and spits them out to the directory they should be 
served on at update time. AFAIK DJango can not process the .css files in the 
media/static directory on the fly.  

But you might be able to trick it, just thought about this as I was writing 
above.  Have a url  in urls.py of a regex that ends in '.css' and direct it to 
a view that serves your css.  

something like this:

url(r'^media/css/(?P[\w-]+)\.css$', 'views.css', name='serve-css'),

with my views.css just for processing css templates.

I don't know how hard it would be to implement or how well it would work, I 
haven't done it. It's a thought of this.

Mike


-- 
I appoint you ambassador to Fantasy Island!!!

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



Re: staticfile app question

2011-03-30 Thread Shawn Milochik
I have the exact same problem. I hope there is a solution, because
good site design often results in image references in the CSS.

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