1
1
Using with Flask
2
2
================
3
3
4
- This guide explains how to use libsass with Flask _ web framework.
4
+ This guide explains how to use libsass with the Flask _ web framework.
5
5
:mod: `sassutils ` package provides several tools that can be integrated
6
- to web applications written in Flask.
6
+ into web applications written in Flask.
7
7
8
8
.. _Flask : http://flask.pocoo.org/
9
9
@@ -35,31 +35,31 @@ Defining manifest
35
35
-----------------
36
36
37
37
The :mod: `sassutils ` defines a concept named :dfn: `manifest `.
38
- Manifest is building settings of Sass/SCSS. It specifies some paths
38
+ Manifest is the build settings of Sass/SCSS. It specifies some paths
39
39
related to building Sass/SCSS:
40
40
41
41
- The path of the directory which contains Sass/SCSS source files.
42
- - The path of the directory compiled CSS files will go.
43
- - The path, is exposed to HTTP (through WSGI), of the directory that
44
- will contain compiled CSS files.
42
+ - The path of the directory which the compiled CSS files will go.
43
+ - The path, exposed to HTTP (through WSGI), of the directory that
44
+ will contain the compiled CSS files.
45
45
46
- Every package may have their own manifest. Paths have to be relative
46
+ Every package may have its own manifest. Paths have to be relative
47
47
to the path of the package.
48
48
49
- For example, in the project the package name is :mod: `myapp `.
50
- The path of the package is :file: `myapp/ `. The path of Sass/SCSS directory
51
- is :file: `static/sass/ ` (relative to the package directory).
52
- The path of CSS directory is :file: `static/css/ `.
49
+ For example, in the above project, the package name is :mod: `myapp `.
50
+ The path of the package is :file: `myapp/ `. The path of the Sass/SCSS
51
+ directory is :file: `static/sass/ ` (relative to the package directory).
52
+ The path of the CSS directory is :file: `static/css/ `.
53
53
The exposed path is :file: `/static/css `.
54
54
55
- This settings can be represented as the following manifests::
55
+ These settings can be represented as the following manifests::
56
56
57
57
{
58
58
'myapp': ('static/sass', 'static/css', '/static/css')
59
59
}
60
60
61
- As you can see the above, the set of manifests are represented in dictionary.
62
- Keys are packages names. Values are tuples of paths.
61
+ As you can see the above, the set of manifests are represented in dictionary,
62
+ in which the keys are packages names and the values are tuples of paths.
63
63
64
64
65
65
Building Sass/SCSS for each request
@@ -72,21 +72,21 @@ Building Sass/SCSS for each request
72
72
Flask.
73
73
74
74
Flask --- :ref: `flask:app-dispatch `
75
- The documentation which explains how Flask dispatch each
75
+ The documentation which explains how Flask dispatches each
76
76
request internally.
77
77
78
78
__ http://flask.pocoo.org/docs/quickstart/#hooking-in-wsgi-middlewares
79
79
80
- In development, to manually build Sass/SCSS files for each change is
81
- so tiring . :class: `~sassutils.wsgi.SassMiddleware ` makes the web
82
- application to automatically build Sass/SCSS files for each request.
80
+ In development, manually building Sass/SCSS files for each change is
81
+ a tedious task . :class: `~sassutils.wsgi.SassMiddleware ` makes the web
82
+ application build Sass/SCSS files for each request automatically .
83
83
It's a WSGI middleware, so it can be plugged into the web app written in
84
84
Flask.
85
85
86
86
:class: `~sassutils.wsgi.SassMiddleware ` takes two required parameters:
87
87
88
88
- The WSGI-compliant callable object.
89
- - The set of manifests represented as dictionary.
89
+ - The set of manifests represented as a dictionary.
90
90
91
91
So::
92
92
99
99
'myapp': ('static/sass', 'static/css', '/static/css')
100
100
})
101
101
102
- And then, if you want to link a compiled CSS file, use :func: ` ~flask.url_for() `
103
- function:
102
+ And then, if you want to link a compiled CSS file, use the
103
+ :func: ` ~flask.url_for() ` function:
104
104
105
105
.. sourcecode :: html+jinja
106
106
@@ -125,10 +125,10 @@ Building Sass/SCSS for each deployment
125
125
Flask --- :ref: `flask:distribute-deployment `
126
126
How to deploy Flask application using setuptools _.
127
127
128
- If libsass has been installed in the :file: `site-packages ` (for example,
129
- your virtualenv), :file: `setup.py ` script also gets had new command
128
+ If libsass is installed in the :file: `site-packages ` (for example,
129
+ your virtualenv), the :file: `setup.py ` script also gets a new command
130
130
provided by libsass: :class: `~sassutils.distutils.build_sass `.
131
- The command is aware of ``sass_manifests `` option of :file: `setup.py ` and
131
+ The command is aware of the ``sass_manifests `` option of :file: `setup.py ` and
132
132
builds all Sass/SCSS sources according to the manifests.
133
133
134
134
Add these arguments to :file: `setup.py ` script::
@@ -141,35 +141,35 @@ Add these arguments to :file:`setup.py` script::
141
141
}
142
142
)
143
143
144
- The ``setup_requires `` option makes sure that the libsass is installed
144
+ The ``setup_requires `` option makes sure that libsass is installed
145
145
in :file: `site-packages ` (for example, your virtualenv) before
146
- :file: `setup.py ` script. That means: if you run :file: `setup.py ` script
147
- and libsass isn't installed yet at the moment , it will automatically
146
+ the :file: `setup.py ` script. That means if you run the :file: `setup.py `
147
+ script and libsass isn't installed in advance , it will automatically
148
148
install libsass first.
149
149
150
150
The ``sass_manifests `` specifies the manifests for libsass.
151
151
152
152
Now :program: `setup.py build_sass ` will compile all Sass/SCSS files
153
- in the specified path and generates compiled CSS files into the specified
153
+ in the specified path and generates compiled CSS files inside the specified
154
154
path (according to the manifests).
155
155
156
- If you use it with ``sdist `` or ``bdist `` command, a packed archive also
157
- will contain compiled CSS files!
156
+ If you use it with ``sdist `` or ``bdist `` commands, the packed archive will
157
+ also contain the compiled CSS files!
158
158
159
159
.. sourcecode :: console
160
160
161
161
$ python setup.py build_sass sdist
162
162
163
- You can add aliases to make these commands to always run ``build_sass ``
164
- command before . Make :file: `setup.cfg ` config:
163
+ You can add aliases to make these commands always run the ``build_sass ``
164
+ command first . Make :file: `setup.cfg ` config:
165
165
166
166
.. sourcecode :: ini
167
167
168
168
[aliases]
169
169
sdist = build_sass sdist
170
170
bdist = build_sass bdist
171
171
172
- Now it automatically builds Sass/SCSS sources and include compiled CSS files
172
+ Now it automatically builds Sass/SCSS sources and include the compiled CSS files
173
173
to the package archive when you run :program: `setup.py sdist `.
174
174
175
175
.. _setuptools : https://pypi.org/pypi/setuptools/
0 commit comments