Announcing Switch, the CSS Preprocessor!

D

Dave

Powered by Mod_Python, Switch CSS is a full featured, production ready
CSS preprocessor.

Some of the features include:
- variables
- constants
- selector prepending:

#selector {

.class { property: value; }

}

outputs:

#selector { }
#selector .class { property: value; }

With unlimited levels of nesting, this makes CSS easy to read and fast
to write.

- selector copying:

#selector { width: 200px; }

#other_selector { @copy #selector; }

outputs:

#selector { width: 200px; }

#other_selector { width: 200px; }

- selector inheritance:

#selector { width: 200px; }

#other_selector { @inherit #selector; }

outputs:

#other_selector,
#selector { width: 200px; }

#other_selector { }

There are other features, also. I think that's enough to get people
excited.

Switch was designed as a production-ready tool to solve the problem of
front-end design with CSS based-layouts and large CSS files. As we
realized we had 40,000 lines of CSS written and no means of abstracting
or managing the code easily, we decided to write a preprocessor that
was easy to use and had all the bells and whistles a CSS designer could
ever want.

We originally approached the program using PHP. When it took the PHP
version 30 seconds to process one CSS file, we knew PHP wasn't going to
cut it. By re-implementing the appication in Python - using a literal,
1-1 translation of the PHP version, under mod_python, Switch was able
to process the same file in under 1/4 of a second.

YAY! PYTHON!

The sourceforge project link follows. We could really use some tire
kickers... This group was invaluable in the early development process,
so we're announcing it officially here, and on mod_python first.

https://sourceforge.net/projects/switchcss/

Thanks,
Dave Worley
 
S

Sybren Stuvel

Dave enlightened us with:
Powered by Mod_Python, Switch CSS is a full featured, production
ready CSS preprocessor.

It sounds very nice! Really something I could use!

In how far is it coupled with mod_python? I'd rather not re-preprocess
my CSS on every request. IMO it would be nice if the preprocess step
could be done only if the source CSS changes. But hey, maybe you've
already done that.

Does it integrate or live next to Django well?

Sybren
 
D

Dave

It's not tied deeply to mod_python.

The processor works like this:

You create an "sss" file, using Switch specific features. Then, you
place the file under Apache/mod_python OR you can use the command-line
Switch tool to process the SSS file and output a CSS file. In this way,
it works very similar to an XSLT transformation in that you write using
a shorthand method that outputs to a more verbose, crystallized file.

This way, it's platform agnostic. I'm also kicking around the idea of a
GUI tool.

The reason we didn't give it the ability to "preprocess if changed" is
because we're looking forward to implementing a system that can handle
conditional statements:

if $BROWSER is IE and $BROWSER_VERSION > 6 {

/* output this */

} else {

/* output this */

}

This would need to be compiled with every request. Maybe, though, we
could have different settings in which you could compile with every
request, compile on change, or precompile...

Actually, it's an open source program. Hack away!
 
F

fuzzylollipop

Dave said:
Powered by Mod_Python, Switch CSS is a full featured, production ready
The sourceforge project link follows. We could really use some tire
kickers... This group was invaluable in the early development process,
so we're announcing it officially here, and on mod_python first.

https://sourceforge.net/projects/switchcss/

Thanks,
Dave Worley

Is there any documentation or anything available? The sourceforge home
page is empty?
 
P

poorgeek

The zip file contains HTML docs but the menus are broken so that you
can't navigate them if you just want browse them from the local
filesystem.
 
S

Sybren Stuvel

Dave enlightened us with:
You create an "sss" file, using Switch specific features. Then, you
place the file under Apache/mod_python OR you can use the
command-line Switch tool to process the SSS file and output a CSS
file.

That's just the way I like it :0
The reason we didn't give it the ability to "preprocess if changed"
is because we're looking forward to implementing a system that can
handle conditional statements:

You could also compile a SSS file with conditional statements into one
CSS file for each condition, and Python code that contains the
conditions to pick the right CSS file. That way, you still have your
dynamic nature _and_ only process the SSS file once.
Actually, it's an open source program. Hack away!

Perhaps I will :)

Sybren
 
S

Sybren Stuvel

Dave enlightened us with:
Actually, it's an open source program. Hack away!

Before I start on that, you first need to document it! There are no
docstrings at all! It would be much better if the functions and
methods are documented, along with the classes and modules. Perhaps
you should stick to http://www.python.org/dev/peps/pep-0008/ a bit
more. Try to make it into a habit to document functions, classes and
modules before you actually write the code.

Sybren
 
J

John J. Lee

Dave said:
It's not tied deeply to mod_python.

The processor works like this:

You create an "sss" file, using Switch specific features. Then, you
place the file under Apache/mod_python OR you can use the command-line
Switch tool to process the SSS file and output a CSS file. In this way,
it works very similar to an XSLT transformation in that you write using
a shorthand method that outputs to a more verbose, crystallized file.

This way, it's platform agnostic. I'm also kicking around the idea of a
GUI tool.

The reason we didn't give it the ability to "preprocess if changed" is
because we're looking forward to implementing a system that can handle
conditional statements:

if $BROWSER is IE and $BROWSER_VERSION > 6 {

/* output this */

} else {

/* output this */

}

This would need to be compiled with every request. Maybe, though, we
could have different settings in which you could compile with every
request, compile on change, or precompile...
[...]

How about a mod_rewrite rule or two to auto-generate the .css files
from the .sss files? That way, you retain really fast static-file
Apache serving of CSS, no Python process involved except for the very
first hit on each .css file. To invalidate the cache, rm *.css (you
can do this as part of the code promotion process). We've used this
at work with PDF files, and it works nicely.

I think you could still implement the browser detection thing exactly
as you describe it with this scheme just by auto-generating more than
one .css file per .sss file (perhaps making use of CSS imports), and
referencing the appropriate .css file in your dynamically-generated
HTML (or, if static HTML and JavaScript, using document.write to
reference the right .css file).


John
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top