Skip to content
This repository was archived by the owner on Jun 28, 2018. It is now read-only.

Commit 7be2596

Browse files
author
faruken
committed
first
0 parents  commit 7be2596

File tree

13 files changed

+360
-0
lines changed

13 files changed

+360
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.DS_Store
2+
*.pyc
3+
dist
4+
*.egg
5+
*.egg-info

LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright (c) 2012, Faruk Akgul.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
1. Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
2. Redistributions in binary form must reproduce the above copyright
9+
notice, this list of conditions and the following disclaimer in the
10+
documentation and/or other materials provided with the distribution.
11+
3. All advertising materials mentioning features or use of this software
12+
must display the following acknowledgement:
13+
This product includes software developed by the contributors.
14+
4. Neither the name of the contributors nor the
15+
names of its contributors may be used to endorse or promote products
16+
derived from this software without specific prior written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY
19+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
22+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include LICENSE

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#LessCSS
2+
3+
LessCSS is a helper which automatically compiles LESS files to CSS whenever the LESS files are modified.
4+
5+
It works with Brubeck and web.py web frameworks. Although it's not tested on other frameworks such as bottle, it should work without any problems.
6+
7+
Sample Brubeck and web.py projects are in `examples` folder.
8+
9+
**Note:** You need to install `less` before using this helper.
10+
11+
##Installation
12+
13+
`$ pip -U install lesscss`
14+
15+
##Usage
16+
17+
from lesscss.lesscss import LessCSS
18+
LessCSS(media_dir='media', exclude_dirs=['img', 'js'], based=True)
19+
20+
###Parameters
21+
22+
- **media_dir**: Directory where you put static/media files such as css/js/img.
23+
- **exclude_dirs**: Directories you don't want to be searched. It'd be pointless to search for `less` files in an images directory. This parameter is expected to be a list.
24+
- **based**: If it's set `True` then LessCSS will generate the `style-(base60).css` version as well (for example; `style-dHCFD.css`). This is useful if you set expire times of static files to a distant future since browsers will not retrieve those files unless the name is different or the cache has expired. This parameter is expected to be a boolean value.
25+
26+
27+
##TODO
28+
- Automatically set CSS name in HTML templates.
29+
30+
#LICENSE
31+
Released under BSD, see LICENSE for details.
32+
33+
##Else
34+
Code is based on Steve Losh's [flask-lesscss](http://sjl.bitbucket.org/flask-lesscss/).

examples/brubeck/main.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
import logging
5+
from brubeck.templating import load_jinja2_env
6+
from brubeck.request_handling import Brubeck
7+
from brubeck.templating import Jinja2Rendering
8+
9+
10+
class IndexHandler(Jinja2Rendering):
11+
def get(self):
12+
return self.render_template('index.html')
13+
14+
15+
config = {
16+
'mongrel2_pair': ('ipc://127.0.0.1:9999', 'ipc://127.0.0.1:9998'),
17+
'handler_tuples': [(r'^/$', IndexHandler)],
18+
'log_level': logging.DEBUG,
19+
'template_loader': load_jinja2_env('templates'),
20+
}
21+
22+
app = Brubeck(**config)
23+
24+
if __name__ == '__main__':
25+
DEBUG = True
26+
if DEBUG:
27+
from lesscss import LessCSS
28+
LessCSS(media_dir='static', exclude_dirs=['.fr'], based=False)
29+
30+
app.run()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@base: #333;
2+
3+
body {
4+
font-family:arial, sans-serif;
5+
color: @base;
6+
}
7+
8+
.box-shadow(@style, @c) when (iscolor(@c)) {
9+
box-shadow: @style @c;
10+
-webkit-box-shadow: @style @c;
11+
-moz-box-shadow: @style @c;
12+
}
13+
.box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
14+
.box-shadow(@style, rgba(0, 0, 0, @alpha));
15+
}
16+
.box {
17+
color: saturate(@base, 5%);
18+
border-color: lighten(@base, 30%);
19+
div { .box-shadow(0 0 5px, 30%) }
20+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>Brubeck LessCSS</title>
6+
<link rel="stylesheet" type="text/css" href="/static/css/style.css" />
7+
</head>
8+
<body>
9+
<header><h1 class="box">Brubeck LessCSS</h1></header>
10+
11+
<section class="box">
12+
<div>Testing, attention please...</div>
13+
</section>
14+
15+
<footer>Seven dwarfs and Snow White.</footer>
16+
</body>
17+
</html>

examples/webpy/main.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env python
2+
# -*- coding: utf-8 -*-
3+
4+
import web
5+
6+
render = web.template.render('templates')
7+
8+
class Index(object):
9+
def GET(self):
10+
return render.index()
11+
12+
DEBUG = True
13+
web.config.debug = DEBUG
14+
app = web.application((r'^/', 'Index'), globals(), autoreload=True)
15+
16+
if __name__ == '__main__':
17+
if DEBUG:
18+
from lesscss.lesscss import LessCSS
19+
LessCSS()
20+
app.run()
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
@base: #333;
2+
3+
body {
4+
font-family:arial, sans-serif;
5+
color: @base;
6+
}
7+
8+
.box-shadow(@style, @c) when (iscolor(@c)) {
9+
box-shadow: @style @c;
10+
-webkit-box-shadow: @style @c;
11+
-moz-box-shadow: @style @c;
12+
}
13+
.box-shadow(@style, @alpha: 50%) when (isnumber(@alpha)) {
14+
.box-shadow(@style, rgba(0, 0, 0, @alpha));
15+
}
16+
.box {
17+
color: saturate(@base, 5%);
18+
border-color: lighten(@base, 30%);
19+
div { .box-shadow(0 0 5px, 30%) }
20+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<title>web.py LessCSS</title>
6+
<link rel="stylesheet" type="text/css" href="/static/css/style.css" />
7+
</head>
8+
<body>
9+
<header><h1 class="box">web.py LessCSS</h1></header>
10+
11+
<section class="box">
12+
<div>Testing, attention please...</div>
13+
</section>
14+
15+
<footer>Seven dwarfs and Snow White.</footer>
16+
</body>
17+
</html>

0 commit comments

Comments
 (0)