forked from openlibhums/pandoc_plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhooks.py
More file actions
40 lines (31 loc) · 1.58 KB
/
hooks.py
File metadata and controls
40 lines (31 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from django.template.loader import render_to_string
from plugins.pandoc_plugin import plugin_settings
from utils import models, setting_handler
def inject_pandoc(context):
"""
Provides buttons for users to automatically convert manuscript files (docx or rtf) to html.
Uses the pandoc plugin, which must be installed on the server.
"""
plugin = models.Plugin.objects.get(name=plugin_settings.SHORT_NAME)
request = context.get('request')
pandoc_enabled = setting_handler.get_plugin_setting(plugin, 'pandoc_enabled', request.journal, create=True,
pretty='Pandoc Enabled', types='boolean')
if pandoc_enabled.processed_value:
return render_to_string('pandoc_plugin/inject.html', context={'article': context.get('article'), 'file': context.get('file')}, request=request)
else:
return ''
def conversion_row_hook(context, file_, article):
""" Provides a verbose menu for pandoc transformations in a row format"""
plugin = models.Plugin.objects.get(name=plugin_settings.SHORT_NAME)
request = context["request"]
pandoc_enabled = setting_handler.get_plugin_setting(plugin, 'pandoc_enabled', request.journal, create=True,
pretty='Pandoc Enabled', types='boolean')
if pandoc_enabled.processed_value:
context={'article': article, 'file': file_}
return render_to_string(
"pandoc_plugin/row_hook.html",
context=context,
request=request,
)
else:
return ''