cdbb426601c045361ac74f524182fd5be8edf076
[redakcja.git] / apps / wiki / templates / wiki / bootstrap.html
1 {% load static %}
2 {% load i18n %}
3
4 <!DOCTYPE html>
5 <html>
6     <head>
7         {% if RAVEN_CONFIG %}
8             <script src="http://cdn.ravenjs.com/1.1.7/jquery,native/raven.min.js"></script>
9             <script>
10                 Raven.config('{{RAVEN_CONFIG.SENTRY_URL}}', {{RAVEN_CONFIG.SETTINGS|default:'{}'}}).install();
11                 {% if request.user.is_authenticated %}
12                     Raven.setUser({
13                         name: '{{request.user.username}}',
14                         email: '{{request.user.email}}',
15                         id: {{request.user.id}}
16                     });
17                 {% endif %}
18             </script>
19         {% endif %}
20         <script src="{% url 'django.views.i18n.javascript_catalog' %}"></script>
21         
22         {% if DEBUG %}
23             <link rel="stylesheet/less" type="text/css" href="{% static 'wiki/editor/src/editor/styles/main.less' %}"/>
24             <script type="text/javascript">less = {relativeUrls: true};</script>
25             <script src="{% static 'wiki/editor/libs/less-1.3.3.min.js' %}"></script>
26             <script src="{% static 'wiki/editor/libs/require.js' %}" data-main="{% static 'wiki/editor/src/editor/entrypoint.js' %}" ></script>
27             <script src="{% static 'wiki/editor/libs/jquery-1.9.1.min.js' %}"></script>
28             <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
29         {% else %}
30             <link href="{% static 'wiki/build/rng.css' %}" rel="stylesheet">
31             <script src="{% static 'wiki/build/rng.js' %}"></script>
32         {% endif %}
33         <script src="{% static 'js/catalogue/catalogue.js' %}"></script> {# for tutorial #}
34     </head>
35     <body>
36         <script type="text/javascript">
37
38             var config = {
39                 rootSelector: '#editor_root',
40                 jsonifySentPayload: false,
41
42                 {% if request.user.is_authenticated %}
43                 user: {
44                     name: '{{request.user.username}}',
45                     email: '{{request.user.email}}',
46                     id: {{request.user.id}}
47                 },
48                 {% endif %}
49
50                 logging: {
51                     handlers: {
52                         'sentry': {
53                             level: 'info',
54                             handler: 'raven',
55                             formatter: 'noop'
56                         },
57                         'console': {
58                             level: 'debug',
59                             handler: 'console',
60                             formatter: 'simple'
61                         }
62                     },
63                     loggers: {
64                         '': {
65                             level: 'debug',
66                             handlers: ['console', 'sentry']
67                         }
68                     }
69                 },
70               
71                 documentSummaryView: {
72                     title: '{% trans 'Informations about lesson' %}',
73                     properties: [
74                         {name: 'version', label: '{% trans 'Version' %}'},
75                         {name: 'stage_name', label: '{% trans 'Stage' %}'},
76                         {name: 'assignment', label: '{% trans 'Assignment' %}'}
77                     ]
78                 },
79
80                 plugins: {
81                     core: {
82                         templates: {{serialized_templates|safe}},
83                         metadata: [
84                             {key: 'audience', values: [
85                                 '3-6', '6-9', '9-12', '12-18', '18+', 'Adults'
86                             ]},
87                             {key: 'creator'},
88                             {key: 'description'},
89                             {key: 'publisher'},
90                             {key: 'language'},
91                             {key: 'rights'},
92                             {key: 'relation.coverimage.url', isFile: true}
93                         ]
94                     }
95                 },
96
97                 toolbar: [
98                     ['core.undo', 'core.redo'],
99                     
100                     [
101                     {actionName: 'core.switchToHeader'},
102                     {actionName: 'core.switchToParagraph'},
103                     {actionName: 'core.switchToImage'},
104                     {actionName: 'core.switchToVideo'},
105                     'core.toggleBulletList', 'core.toggleEnumList'
106                     ],
107
108                     [
109                         {actionName: 'core.emphasis', actionConfig: {label: '{% trans "emphasis" %}'}},
110                         {actionName: 'core.cite', actionConfig: {label: '{% trans "cite" %}'}},
111                         {actionName: 'core.link', actionConfig: {label: '{% trans "link" %}'}}
112                     ],
113                     
114                     //['core.template'],
115
116                     ['core.showMetadataEditor']
117                     /*[
118                         'core.insertOrderExercise',
119                         'core.insertChoiceSingleExercise',
120                         'core.insertChoiceMultiExercise',
121                         'core.insertChoiceTrueOrFalseExercise',
122                         'core.insertGapsExercise',
123                         'core.insertReplaceExercise'
124                     ]*/
125                 ],
126                 
127                 documentSaveUrl: function(id) { return '/editor/text/' + id + '/'; },
128                 documentHistoryUrl: function(id) { return '/editor/history/' + id + '/'},
129                 documentDiffUrl: function(id) { return '/editor/diff/' + id + '/'; },
130                 documentRestoreUrl: function(id) { return '/editor/revert/' + id + '/'},
131                 documentPublishUrl: '{% url "catalogue_publish" pk %}',
132
133                 documentScheduleUrl: '{% url "catalogue_book_schedule" pk %}',
134                 documentForkUrl: '{% url "catalogue_fork" pk %}',
135                 documentGalleryUrl: '{% url "catalogue_book_gallery" pk %}',
136
137                 documentAttachmentUrl: function(attachmentName) {
138                     return '{{MEDIA_URL}}uploads/{{ pk }}/' + attachmentName;
139                 },
140                 documentUrl: function(id, version) {
141                     var url = '{% url 'wiki_editor' pk %}';
142                     if(version) {
143                         url = url + '?version=' + version;
144                     }
145                     return url;
146                 },
147                 documentPreviewUrl: function(id) { return '/documents/{{ pk }}/rev' + id + '/preview/' },
148                 documentPreviewMainUrl: function() { return '/documents/{{ pk }}/preview/' },
149
150                 documentSaveForm: {
151                     fields: [
152                         {label: '{{forms.text_save.comment.label}}', name: '{{forms.text_save.comment.html_name}}', type: 'textarea'},
153                         {label: '{{forms.text_save.stage.label}}', name: '{{forms.text_save.stage.html_name}}', type: 'select', options: [
154                             {% for value, text in forms.text_save.stage.field.choices %}
155                                 {value:'{{value|default:''}}', text:'{{text}}'} {% if not forloop.last %}, {% endif %}
156                             {% endfor %}
157                         ], description: '{{forms.text_save.stage.help_text}}'}
158                     ],
159                     content_field_name: '{{forms.text_save.text.html_name}}',
160                     version_field_name: '{{forms.text_save.parent_revision.html_name}}'
161                 },
162
163                 documentRestoreForm: {
164                     fields: [
165                         {label: '{{forms.text_revert.comment.label}}', name: '{{forms.text_revert.comment.html_name}}', type: 'textarea'}
166                     ],
167                     version_field_name: '{{forms.text_revert.revision.html_name}}'
168                 },
169
170                 documentPublishForm: {
171                     fields: [
172                     ],
173                     revision_field_name: '{{forms.text_publish.revision.html_name}}'
174                 },
175
176                 tutorial: [
177                     {name: 'editor', text: 'e'},
178                     {name: 'sourceEditor', text: 's'},
179                     {name: 'history', text: 's'},
180                     {name: 'switchToHeader', text: 's'},
181                     {name: 'switchToParagraph', text: 's'},
182                     {name: 'switchToImage', text: 's'},
183                     {name: 'switchToVideo', text: 's'},
184                     {name: 'toggleBulletList', text: 's'},
185                     {name: 'toggleEnumList', text: 's'},
186                     {name: 'emphasis', text: 's'},
187                     {name: 'cite', text: 's'},
188                     {name: 'link', text: 's'},
189                     {name: 'showMetadataEditor', text: 's'},
190                     {name: 'preview', text: 's'},
191                     {name: 'attachments', text: 's'},
192                     {name: 'draft', text: 's'},
193                     {name: 'comment', text: 's'}, // needs to be set manually in comments.html :(
194                     {name: 'save', text: 's'},
195                     {name: 'mainpage', text: 's'},
196                     {name: 'exit', text: 's'}
197                 ]
198             };
199
200             {% if can_pubmark %}
201                 config.documentSaveForm.fields.push(
202                     {label: '{{forms.text_save.publishable.label}}', name: '{{forms.text_save.publishable.html_name}}', type: 'checkbox', description: '{{forms.text_save.publishable.help_text}}'}
203                 );
204             {% endif %}
205
206             {% if not request.user.is_authenticated %}
207                 config.documentSaveForm.fields.push(
208                     {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}}'},
209                     {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}}'}
210                 );
211
212                 config.documentRestoreForm.fields.push(
213                     {label: '{{forms.text_revert.author_name.label}}', name: '{{forms.text_revert.author_name.html_name}}', type: 'input', description: '{{forms.text_revert.author_name.help_text}}'},
214                     {label: '{{forms.text_revert.author_email.label}}', name: '{{forms.text_revert.author_email.html_name}}', type: 'input', description: '{{forms.text_revert.author_email.help_text}}'}
215                 );
216             {% endif %}
217
218             {% autoescape off%}
219             var data = {{serialized_document_data}};
220             {%endautoescape%}
221
222             var editor_init = function(Editor) {            
223                 Editor.setBootstrappedData('data', data);
224                 Editor.start(config);
225             };
226
227
228
229
230         </script>
231         <div id="editor_root"></div>
232     </body>
233 </html>