Page 1 of 1

python mimes css!! MAUAHAHAH

Posted: Fri Jun 24, 2011 9:00 am
by Isaac
http://testing.isaacg.net/csstest/

This is great for me. I hate css problems between platforms.

I will later attempt to make a converter that takes one css file, made for a single browser, and convert all its syntax and style to the browser visiting.

It will also convert png transparencies into gifs, when necessary, via imagemagicks.

It could also resize images for mobile devices, via imagemagicks.

Any reasoning why this is a waste of time? I have yet to see a better solution for css problems.

edit:
In theory, this is how you'd tell python which css file, or files, to use.
...HREF="mycsspage.cgi?file=mycssfile.css".....

Re: python mimes css!! MAUAHAHAH

Posted: Fri Jun 24, 2011 12:31 pm
by Jeff250
type="text/css" => mime type is text/css.
Isaac wrote:Any reasoning why this is a waste of time? I have yet to see a better solution for css problems.
It's better to handle this on a case-by-case basis for your specific application rather than try to write a general converter. Also, png's colors are 32-bit, 24 bits for RGB and 8 for transparency, whereas gif's are only 8-bit paletted, where one of the 2^8 palette possible colors can be chosen to be 100% transparent and all of the others are 100% opaque. In other words, png -> gif creates massive information loss.

Re: python mimes css!! MAUAHAHAH

Posted: Fri Jun 24, 2011 1:53 pm
by fliptw
for PNG transparency: http://24ways.org/2007/supersleight-tra ... png-in-ie6

if you want a website to look good in all browsers, then you have to, as jeff said, do it on a case-by-case basis - other wise you will end up with it looking so-so for browsers other than the one you test on.

Re: python mimes css!! MAUAHAHAH

Posted: Fri Jun 24, 2011 2:23 pm
by Isaac
That's true, according to everything else I've read, Jeff and Flip. Each css setup should be geared for a specific browser and, sometimes, version. However, python can do that too! It can easily detect what the user agent is and perform the same function. The great part is, you don't rely on the user's browser to make the decision on what css file to use. Python makes the decision.

PNGs to GIfs won't ever be a perfect match. Yeah, Flip, thanks. I'll have to try those out. Also there's a chance Imagemagicks can reproduce the PNGs' background color so that it does not need to be transparent, though this could cause other problems. I think PNG conversion would only happen on clamshell phones, and other extreme cases. I'm not too worried about full featured desktop browsers.

I'm going to try this out. I mean, this is a pretty easy script to write. I just have to build a large list of syntax with rules.

Re: python mimes css!! MAUAHAHAH

Posted: Fri Jun 24, 2011 3:33 pm
by fliptw
For platforms like clamshells, if anyone does browse on something that small, I'd just feed a site thats just text.

There is no way to really match what the user sees as the background colour.

Just... don't use imagemagik.

Re: python mimes css!! MAUAHAHAH

Posted: Fri Jun 24, 2011 4:10 pm
by Isaac
I think playing on my little nokia is great. It's such a primative device, but with python, I can have all kinds of stuff work with it. CSS styled text and gifs run pretty well with it.
fliptw wrote:Just... don't use imagemagik.
Oh, you don't like it?

Re: python mimes css!! MAUAHAHAH

Posted: Fri Jun 24, 2011 4:19 pm
by fliptw
Its perfectly fine; its not a tool to magically make websites "just work" on a given platform.

Re: python mimes css!! MAUAHAHAH

Posted: Fri Jun 24, 2011 4:41 pm
by Isaac
Oh, of course not. It's a command line graphics tool, that happens to be magical.

Re: python mimes css!! MAUAHAHAH

Posted: Fri Jun 24, 2011 7:13 pm
by Jeff250
You could probably make sniffing user agents and outputting variable CSS work, but it's not the most robust way, especially since user agent strings are not always reliable. Besides, this is already a solved problem. Link to the *.css file containing your IE-isms inside of IE conditional comments. Most other cases are something of the form (to borrow your example from the other thread):

Code: Select all

background-size: cover;
-webkit-background-size: cover;
-o-background-size: cover;
-moz-background-size: cover;
Unless you're a purist, there's no harm in Firefox seeing the -webkit-foo style (and vice versa), so you can put all of them in the same *.css file. They were specifically designed with this in mind.

For clamshell phones and the like, see the "media" attribute on the link tag. Like Flip said, you shouldn't strive for pixel-perfect replication on them.

Re: python mimes css!! MAUAHAHAH

Posted: Fri Jun 24, 2011 7:54 pm
by Isaac
True. I've been doing that, trying to get things to align the same way form one browser to the next. And there's a basic html tag that can let me make a separate css file for each type. I don't think more than three css contingencies is necessary, but I've seen examples that have many more than that.

There's also something called a reset sheet, but the concept is strange and it seems like it complicates things more.

I was once looking for a css compatibility script. I figured someone would have made one by now, since it could potentially eliminate, if done correctly, cross browser checking. I thought jquery, with its javascript cross compatibility features, would go into making css more cross browser friendly. Though there are css features in jquery it makes no adjustments for css between browsers.

Where I stand I can either,
1. work on something else and just learn basic work arounds, regarding css. It's also what I think you guys are implying I should do, meaning it's probably the best decision and what I should do. I'd rather be making my jQuery/Ajax/Python RPG.
2. I can make a javascript css converter, which I think has the highest potential of being used by others.
3. I can make a python css converter, which I think will work better than javascript, and for any platform.

After writing that list above, it makes more sense that I pick 1.

Re: python mimes css!! MAUAHAHAH

Posted: Fri Jun 24, 2011 10:53 pm
by Jeff250
Aside from IE-isms, cross-browser CSS shouldn't even be a big problem. If it is, you might be trying to use too much experimental CSS3 stuff. For now, try to mostly stick with CSS2 stuff. Sometimes you just have to shrug off cool new CSS stuff until it's more widely supported.

Re: python mimes css!! MAUAHAHAH

Posted: Sat Jun 25, 2011 5:35 am
by Isaac
Yeah, ok. I'll need to watch out for css3 stuff. Right now I'm just plugging in anything that works without any real thought, into my CSS file. I guess that's where all my trouble is coming from.

Thanks for the advice!