2020-01-26 14:47:50 +00:00
# mycreole
2024-10-06 18:23:20 +02:00
With the django library mycreole, you are abel to use the creole language to create html output in your django application.
2024-10-07 12:31:17 +02:00
## Requirements
You need to ensure that python-mycreole is available in your python environment.
2024-10-06 18:23:20 +02:00
## Integration
Clone the library in your django application.
### Configurations in your settings.py
Add the following line to the list ```INSTALLED_APPS` ``:
```
'mycreole.apps.MycreoleConfig',
```
2024-10-07 00:37:31 +02:00
### Parameter
All parameters can be added in the django ```settings.py` `` or in a ` ``config.py` `` in the root django folder. The definitions in the ` ``config.py` `` will be used before the definitions in ` ``settings.py` ``.
#### MYCREOLE_ROOT
2024-10-06 18:23:20 +02:00
Define the folder, where the attachments are stored with the following line:
```
MYCREOLE_ROOT = os.path.join(BASE_DIR, 'data', 'pages')
```
2024-10-07 00:37:31 +02:00
#### MYCREOLE_ATTACHMENT_ACCESS
2024-10-06 18:23:20 +02:00
Define the methods to grant or deny the access to the attachments by:
```
MYCREOLE_ATTACHMENT_ACCESS = {
'read': 'pages.access.read_attachment',
'modify': 'pages.access.modify_attachment',
}
```
2024-10-07 00:37:31 +02:00
#### MYCREOLE_BAR
2024-10-06 18:23:20 +02:00
Define the methods to extend the navigationbar and menubar by this statement:
```
MYCREOLE_BAR = {
'navibar': 'pages.context.navigationbar',
'menubar': 'pages.context.menubar',
}
```
## Usage
### Creole help page
In this example, you see a method in ```views.py` `` which returns a creole help page:
```
from django.conf import settings
from django.http import HttpResponse
import mycreole
import os
def help_on_creole(request):
attachment_path = os.path.join(settings.MYCREOLE_ROOT, 'creole_help_page')
html = mycreole.render(request, creole.help.MYCREOLE_HELP, self.attachment_path)
```
### Usage of next_achor
2024-10-07 00:37:31 +02:00
Defines the additional html anchor, which will be used after an upload.
2024-10-06 18:23:20 +02:00
### Usage of macros
You can give a dictonary as macros parameter to the render method, to define your own macros. Here an example of such a dict:
```
macros={
'mymacro': method_to_be_called,
2024-10-07 00:37:31 +02:00
}
```