22ad831b12fd5773b38be0a7a0a00771af5f7e55
[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         {% else %}
28             <link href="{% static 'wiki/build/rng.css' %}" rel="stylesheet">
29             <script src="{% static 'wiki/build/rng.js' %}"></script>
30         {% endif %}
31     </head>
32     <body>
33         <script type="text/javascript">
34
35             var config = {
36                 rootSelector: '#editor_root',
37                 jsonifySentPayload: false,
38
39                 {% if request.user.is_authenticated %}
40                 user: {
41                     name: '{{request.user.username}}',
42                     email: '{{request.user.email}}',
43                     id: {{request.user.id}}
44                 },
45                 {% endif %}
46
47                 logging: {
48                     handlers: {
49                         'sentry': {
50                             level: 'info',
51                             handler: 'raven',
52                             formatter: 'noop'
53                         },
54                         'console': {
55                             level: 'debug',
56                             handler: 'console',
57                             formatter: 'simple'
58                         }
59                     },
60                     loggers: {
61                         '': {
62                             level: 'debug',
63                             handlers: ['console', 'sentry']
64                         }
65                     }
66                 },
67               
68                 documentSummaryView: {
69                     title: '{% trans 'Informations about lesson' %}',
70                     properties: [
71                         {name: 'version', label: '{% trans 'Version' %}'},
72                         {name: 'stage_name', label: '{% trans 'Stage' %}'},
73                         {name: 'assignment', label: '{% trans 'Assignment' %}'}
74                     ]
75                 },
76
77                 plugins: {
78                     core: {
79                         templates: {{serialized_templates|safe}},
80                         metadata: [
81                             {key: 'audience', values: [
82                                 '3-6', '6-9', '9-12', '12-18', '18+', 'Adults'
83                             ]},
84                             {key: 'creator'},
85                             {key: 'description'},
86                             {key: 'publisher'},
87                             {key: 'language'},
88                             {key: 'rights'},
89                             {key: 'relation.coverimage.url', isFile: true}
90                         ]
91                     }
92                 },
93
94                 toolbar: [
95                     ['core.undo', 'core.redo'],
96                     
97                     [
98                     {actionName: 'core.switchToHeader'},
99                     {actionName: 'core.switchToParagraph'},
100                     {actionName: 'core.switchToImage'},
101                     {actionName: 'core.switchToVideo'},
102                     'core.toggleBulletList', 'core.toggleEnumList'
103                     ],
104
105                     [
106                         {actionName: 'core.emphasis', actionConfig: {label: 'emphasis'}},
107                         {actionName: 'core.cite', actionConfig: {label: 'cite'}},
108                         {actionName: 'core.link'}
109                     ],
110                     
111                     //['core.template'],
112
113                     ['core.showMetadataEditor']
114                     /*[
115                         'core.insertOrderExercise',
116                         'core.insertChoiceSingleExercise',
117                         'core.insertChoiceMultiExercise',
118                         'core.insertChoiceTrueOrFalseExercise',
119                         'core.insertGapsExercise',
120                         'core.insertReplaceExercise'
121                     ]*/
122                 ],
123                 
124                 documentSaveUrl: function(id) { return '/editor/text/' + id + '/'; },
125                 documentHistoryUrl: function(id) { return '/editor/history/' + id + '/'},
126                 documentDiffUrl: function(id) { return '/editor/diff/' + id + '/'; },
127                 documentRestoreUrl: function(id) { return '/editor/revert/' + id + '/'},
128                 documentPublishUrl: '{% url "catalogue_publish" pk %}',
129
130                 documentScheduleUrl: '{% url "catalogue_book_schedule" pk %}',
131                 documentForkUrl: '{% url "catalogue_fork" pk %}',
132                 documentGalleryUrl: '{% url "catalogue_book_gallery" pk %}',
133
134                 documentAttachmentUrl: function(attachmentName) {
135                     return '{{MEDIA_URL}}uploads/{{ pk }}/' + attachmentName;
136                 },
137                 documentUrl: function(id, version) {
138                     var url = '{% url 'wiki_editor' pk %}';
139                     if(version) {
140                         url = url + '?version=' + version;
141                     }
142                     return url;
143                 },
144                 documentPreviewUrl: function(id) { return '/documents/{{ pk }}/rev' + id + '/preview/' },
145                 documentPreviewMainUrl: function() { return '/documents/{{ pk }}/preview/' },
146
147                 documentSaveForm: {
148                     fields: [
149                         {label: '{{forms.text_save.comment.label}}', name: '{{forms.text_save.comment.html_name}}', type: 'textarea'},
150                         {label: '{{forms.text_save.stage.label}}', name: '{{forms.text_save.stage.html_name}}', type: 'select', options: [
151                             {% for value, text in forms.text_save.stage.field.choices %}
152                                 {value:'{{value|default:''}}', text:'{{text}}'} {% if not forloop.last %}, {% endif %}
153                             {% endfor %}
154                         ], description: '{{forms.text_save.stage.help_text}}'}
155                     ],
156                     content_field_name: '{{forms.text_save.text.html_name}}',
157                     version_field_name: '{{forms.text_save.parent_revision.html_name}}'
158                 },
159
160                 documentRestoreForm: {
161                     fields: [
162                         {label: '{{forms.text_revert.comment.label}}', name: '{{forms.text_revert.comment.html_name}}', type: 'textarea'}
163                     ],
164                     version_field_name: '{{forms.text_revert.revision.html_name}}'
165                 },
166
167                 documentPublishForm: {
168                     fields: [
169                     ],
170                     revision_field_name: '{{forms.text_publish.revision.html_name}}'
171                 }
172
173             };
174
175             {% if can_pubmark %}
176                 config.documentSaveForm.fields.push(
177                     {label: '{{forms.text_save.publishable.label}}', name: '{{forms.text_save.publishable.html_name}}', type: 'checkbox', description: '{{forms.text_save.publishable.help_text}}'}
178                 );
179             {% endif %}
180
181             {% if not request.user.is_authenticated %}
182                 config.documentSaveForm.fields.push(
183                     {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}}'},
184                     {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}}'}
185                 );
186
187                 config.documentRestoreForm.fields.push(
188                     {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}}'},
189                     {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}}'}
190                 );
191             {% endif %}
192
193             {% autoescape off%}
194             var data = {{serialized_document_data}};
195             {%endautoescape%}
196
197             var editor_init = function(Editor) {            
198                 Editor.setBootstrappedData('data', data);
199                 Editor.start(config);
200             };
201
202
203
204
205         </script>
206         <div id="editor_root"></div>
207     </body>
208 </html>