SPH_SETTINGS
SPH_SETTINGSBack to Snip <-- Previous Change | Next Change -->
| Diff Summary | |||||
|---|---|---|---|---|---|
| Title | |||||
| Date | 2007-07-31 21:41:22 | 2007-08-07 18:55:01 | |||
| Editor | Herbert Poul | Herbert Poul | |||
| Tags | |||||
| 2007-07-31 21:41:22 by Herbert Poul | 2007-08-07 18:55:01 by Herbert Poul | ||||
|---|---|---|---|---|---|
| 53 | This option works together with board_markup_enabl | 53 | This option works together with board_markup_enabl | ||
| > | ed and can be used to add | > | ed and can be used to add | ||
| 54 | custom functions which can be used as markup. | 54 | custom functions which can be used as markup. | ||
| 55 | 55 | ||||
| 56 | For example let's assume we want to create a simpl | 56 | For example let's assume we want to create a simpl | ||
| > | e markup function which only wraps the output into | > | e markup function which only wraps the output into | ||
| > | a html "pre" tag. | > | a html "pre" tag. | ||
| 57 | 57 | ||||
| n | 58 | We start by creating a function somewhere in the p | n | 58 | We start by creating a class somewhere in the pyth |
| > | ython path. In my example it's in sphene/custom_ma | > | on path. In my example it's in sphene/custom_rende | ||
| > | rkup.py | > | rers.py (For your renderers it makes sense to put | ||
| > | them into your own project / application paths) | ||||
| 59 | 59 | ||||
| n | 60 | def simplemarkup(body): | n | 60 | from sphene.sphboard.renderers import BaseRend |
| > | erer | ||||
| 61 | |||||
| 62 | class SimpleMarkup(BaseRenderer): | ||||
| 63 | label = 'Very Simple Markup' | ||||
| 64 | reference = '<a href="/link/to/some/docume | ||||
| > | ntation.html">Very Simple Markup</a>' | ||||
| 65 | |||||
| 66 | def render(self, text): | ||||
| 61 | return "<pre>%s</pre>" % body | 67 | return "<pre>%s</pre>" % body | ||
| 62 | 68 | ||||
| 63 | Now define this markup in your settings.py: | 69 | Now define this markup in your settings.py: | ||
| 64 | 70 | ||||
| n | 65 | SPH_SETTINGS['board_custom_markup'] = { 'sphen | n | 71 | SPH_SETTINGS['board_custom_markup'] = { 'simpl |
| > | e.custom_markup.simplemarkup': 'Very simple markup | > | emarkup': 'sphene.custom_renderers.SimpleMarkup', | ||
| > | ', } | > | } | ||
| 66 | 72 | ||||
| 67 | (The dictionary consists of 1.) the method name in | 73 | (The dictionary consists of 1.) the method name in | ||
| > | cluding the whole module name and 2.) a label whic | > | cluding the whole module name and 2.) a label whic | ||
| > | h is displayed to the user.) | > | h is displayed to the user.) | ||
| 68 | 74 | ||||
| 69 | To allow users to use this markup we have to enabl | 75 | To allow users to use this markup we have to enabl | ||
| > | e it, just like any other markup using board_marku | > | e it, just like any other markup using board_marku | ||
| > | p_enabled: | > | p_enabled: | ||
| 70 | 76 | ||||
| t | 71 | SPH_SETTINGS['board_markup_enabled'] = ( 'bbco | t | 77 | SPH_SETTINGS['board_markup_enabled'] = ( 'bbco |
| > | de', 'sphene.custom_markup.simplemarkup', ) | > | de', 'simplemarkup', ) | ||
| 72 | 78 | ||||
| 73 | This will leave 'bbcode' as the default selection, | 79 | This will leave 'bbcode' as the default selection, | ||
| > | but users can also select the 'Very simple markup | > | but users can also select the 'Very simple markup | ||
| > | '-markup. - You can of course also define only you | > | '-markup. - You can of course also define only you | ||
| > | r custom markup method if you don't want to give y | > | r custom markup method if you don't want to give y | ||
| > | our users a choice. | > | our users a choice. | ||
| 74 | 80 | ||||
| 75 | # Miscellaneous | 81 | # Miscellaneous | ||
| 76 | 82 | ||||
Powered by Sphene Community Tools
