Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 # CMS # | 1 # CMS # |
2 | 2 |
3 We use this CMS for [adblockplus.org](https://github.com/adblockplus/web.adblock plus.org/) | 3 We use this CMS for [adblockplus.org](https://github.com/adblockplus/web.adblock plus.org/) |
4 and related websites. It converts a directory with content data into static | 4 and related websites. It converts a directory with content data into static |
5 files. You are free to use it for other projects but please keep in mind that we | 5 files. You are free to use it for other projects but please keep in mind that we |
6 make no stability guarantees whatsoever and might change functionality any time. | 6 make no stability guarantees whatsoever and might change functionality any time. |
7 | 7 |
8 ## How to use ## | 8 ## How to use ## |
9 | 9 |
10 ### Running the test server ### | 10 ### Running the test server ### |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
258 | 258 |
259 * `page`: The page name | 259 * `page`: The page name |
260 * `config`: Contents of the `settings.ini` file in this repository (a | 260 * `config`: Contents of the `settings.ini` file in this repository (a |
261 [configparser object](http://docs.python.org/2/library/configparser.html)) | 261 [configparser object](http://docs.python.org/2/library/configparser.html)) |
262 * `locale`: Locale code of the page language | 262 * `locale`: Locale code of the page language |
263 * `available_locales`: Locale codes of all languages available for this page | 263 * `available_locales`: Locale codes of all languages available for this page |
264 | 264 |
265 Following custom filters can be used: | 265 Following custom filters can be used: |
266 | 266 |
267 * `translate(default, name, comment=None)`: translates the given default string | 267 * `translate(default, name, comment=None)`: translates the given default string |
268 for the given page name into the current language. Optionally a comment or | 268 and string name for the current page and locale. The string name should be |
269 description can be specified as well. | 269 unique for the page but otherwise is only seen by the translators. Optionally |
Wladimir Palant
2015/09/03 13:37:37
What's the difference between comment and descript
kzar
2015/09/03 14:04:14
Well we seem to use both "comment" and "descriptio
| |
270 a comment (description) can be specified to help provide the translators with | |
271 additional context. | |
270 * `linkify(url)`: generates an `<a href="...">` tag for the URL. If the URL is | 272 * `linkify(url)`: generates an `<a href="...">` tag for the URL. If the URL is |
271 a page name it will be converted into a link to the most appropriate page | 273 a page name it will be converted into a link to the most appropriate page |
272 language. | 274 language. |
273 * `toclist(html)`: extracts a list of headings from HTML code, this can be used | 275 * `toclist(html)`: extracts a list of headings from HTML code, this can be used |
274 to generate a table of contents. | 276 to generate a table of contents. |
275 | 277 |
276 The following global functions can be used: | 278 The following global functions can be used: |
277 | 279 |
278 * `get_string(name, page=None)`: retrieves a string from a locale file. | 280 * `get_string(name, page=None)`: retrieves a string from a locale file. |
279 Unless a page is specified the locale file matching the name of the current | 281 Unless a page is specified the locale file matching the name of the current |
280 page is used. | 282 page is used. |
281 * `get_page_content(page, locale=None)`: returns a dictionary of the content | 283 * `get_page_content(page, locale=None)`: returns a dictionary of the content |
282 and params for the given page and locale. Locale defaults to the current one | 284 and params for the given page and locale. Locale defaults to the current one |
283 if not specified. Provided keys include: | 285 if not specified. Provided keys include `head`, `body`, `available_locales` |
284 | 286 and `translation_ratio`. |
285 ``` | |
286 ['head', 'body', 'available_locales', 'translation_ratio'] | |
287 ``` | |
Wladimir Palant
2015/09/03 13:37:37
Why have this as a Python list? "Provided keys inc
kzar
2015/09/03 14:04:14
Done.
| |
288 | 287 |
289 ### Static files ### | 288 ### Static files ### |
290 | 289 |
291 Any files located in the `static` directory will be available on the server | 290 Any files located in the `static` directory will be available on the server |
292 unchanged. The file `static/css/foo.css` will be available under the URL | 291 unchanged. The file `static/css/foo.css` will be available under the URL |
293 `/css/foo.css`. | 292 `/css/foo.css`. |
294 | 293 |
295 ### Templates ### | 294 ### Templates ### |
296 | 295 |
297 The templates specified in the `templates` directory specify the overall | 296 The templates specified in the `templates` directory specify the overall |
(...skipping 17 matching lines...) Expand all Loading... | |
315 filter is invoked. For more information on Jinja2 filters see | 314 filter is invoked. For more information on Jinja2 filters see |
316 [official documentation](http://jinja.pocoo.org/docs/dev/api/#writing-filters). | 315 [official documentation](http://jinja.pocoo.org/docs/dev/api/#writing-filters). |
317 | 316 |
318 ### Custom functions and variables ### | 317 ### Custom functions and variables ### |
319 | 318 |
320 The `globals` directory can define custom Jinja2 globals which will be available | 319 The `globals` directory can define custom Jinja2 globals which will be available |
321 in all Jinja2 templates. Typically, this is used for custom functions. The file | 320 in all Jinja2 templates. Typically, this is used for custom functions. The file |
322 name should match the name of the function or variable to be defined, and export | 321 name should match the name of the function or variable to be defined, and export |
323 a variable with that name. E.g. `globals/myfunction.py` can define a function | 322 a variable with that name. E.g. `globals/myfunction.py` can define a function |
324 called `myfunction` that will become available to all Jinja2 templates. | 323 called `myfunction` that will become available to all Jinja2 templates. |
LEFT | RIGHT |