1b4737a494c80d2ec541ffc387b56bb60e574a45
[redakcja.git] / apps / wiki / templates / wiki / bootstrap.html
1 {% load staticfiles %}
2 {% load i18n %}
3
4 <!DOCTYPE html>
5 <html>
6     <head>
7
8         <script src="{% url 'django.views.i18n.javascript_catalog' %}"></script>
9         <script src="http://cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/ace.js" type="text/javascript" charset="utf-8"></script>
10         
11         {% if DEBUG %}
12             <link rel="stylesheet/less" type="text/css" href="{% static 'wiki/editor/src/editor/styles/main.less' %}"/>
13             <script type="text/javascript">less = {relativeUrls: true};</script>
14             <script src="{% static 'wiki/editor/libs/less-1.3.3.min.js' %}"></script>
15             <script src="{% static 'wiki/editor/libs/require.js' %}" data-main="{% static 'wiki/editor/src/editor/entrypoint.js' %}" ></script>
16         {% else %}
17             <link href="{% static 'wiki/build/rng.css' %}" rel="stylesheet">
18             <script src="{% static 'wiki/build/rng.js' %}"></script>
19         {% endif %}
20     </head>
21     <body>
22         <script type="text/javascript">
23
24             var config = {
25                 rootSelector: '#editor_root',
26                 jsonifySentPayload: false,
27                 
28                 documentSaveUrl: function(id) { return '/editor/text/' + id + '/'; },
29                 documentHistoryUrl: function(id) { return '/editor/history/' + id + '/'},
30                 documentDiffUrl: function(id) { return '/editor/diff/' + id + '/'; },
31
32                 documentSaveForm: {
33                     fields: [
34                         {label: '{{forms.text_save.comment.label}}', name: '{{forms.text_save.comment.html_name}}', type: 'textarea'},
35                         {label: '{{forms.text_save.stage_completed.label}}', name: '{{forms.text_save.stage_completed.html_name}}', type: 'select', options: [
36                             {% for value,text in tags %}
37                                 {value:'{{value|default:''}}', text:'{{text}}'} {% if not forloop.last %}, {% endif %}
38                             {% endfor %}
39                         ], description: '{{forms.text_save.stage_completed.help_text}}'},
40                     ],
41                     content_field_name: '{{forms.text_save.text.html_name}}',
42                     version_field_name: '{{forms.text_save.parent_revision.html_name}}'
43                 }
44             };
45
46             {% if can_pubmark %}
47                 config.documentSaveForm.fields.push(
48                     {label: '{{forms.text_save.publishable.label}}', name: '{{forms.text_save.publishable.html_name}}', type: 'checkbox', description: '{{forms.text_save.publishable.help_text}}'}
49                 );
50             {% endif %}
51
52             {% if not request.user.is_authenticated %}
53                 config.documentSaveForm.fields.push(
54                     {label: '{{forms.text_save.author_name.label}}', name: '{{forms.text_save.author_name.html_name}}', type: 'input', description: '{{forms.text_save.author_name.help_text}}'},
55                     {label: '{{forms.text_save.author_email.label}}', name: '{{forms.text_save.author_email.html_name}}', type: 'input', description: '{{forms.text_save.author_email.help_text}}'}
56                 );
57             {% endif %}
58
59             {% autoescape off%}
60             var data = {{serialized_document_data}},
61                 templates = {{serialized_templates}}
62             {%endautoescape%}
63
64             var editor_init = function(Editor) {            
65                 Editor.setBootstrappedData('data', data);
66                 Editor.setBootstrappedData('documentToolbar', templates);
67                 Editor.start(config);
68             };
69         </script>
70         <div id="editor_root"></div>
71     </body>
72 </html>