5fa6d57e3b184b10d07c417e5abf847f1d2068e6
[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 '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: '{% trans "Edit your document text." %}'},
178                     {name: 'sourceEditor', text: '{% trans "View the xml code of your document." %}'},
179                     {name: 'history', text: '{% trans "Here you can view the change history." %}'},
180                     {name: 'switchToHeader', text: '{% trans "Place the cursor at the end of the line after which you want to add a new header, and press Enter. Click “header” to switch the new paragraph into a header." %}'},
181                     {name: 'switchToParagraph', text: '{% trans "Use this option to switch a header to a paragraph." %}'},
182                     {name: 'switchToImage', text: '{% trans "Add graphics to your document. Click “image” to make a frame, then click this frame to insert an image file (JPG, PNG, GIF, SVG)." %}'},
183                     {name: 'switchToVideo', text: '{% trans "Add a video material to your document to make it more attractive. Paste the http link from a YouTube channel." %}'},
184                     {name: 'toggleBulletList', text: '{% trans "Select this option to create a bullet list. Press Enter to add another item. To end the list, place the cursor at the end of the last item, and press Enter twice." %}'},
185                     {name: 'toggleEnumList', text: '{% trans "Create numbered lists. To end the list, set the cursor at the end of the last item, and press Enter twice." %}'},
186                     {name: 'emphasis', text: '{% trans "Emphasize some text by using boldface. To turn it off, click the specific word and then click “emphasis”." %}'},
187                     {name: 'cite', text: '{% trans "Select some text and click “cite” to make it italic. To turn it off, set the cursor on the specific word then click “cite” again." %}'},
188                     {name: 'link', text: '{% trans "Paste the link and select it, or select text and click “link” to add a hyperlink or to link additional materials (ODT, DOC, PDF)." %}'},
189                     {name: 'showMetadataEditor', text: '{% trans "Here you can review and edit metadata. In “Attachments” you can add or change the cover of your document." %}'},
190                     {name: 'preview', text: '{% trans "Review your document before publication." %}'},
191                     {name: 'attachments', text: '{% trans "Here you can add other important materials to this document (audio files, JPG, PNG, ODT, PDF etc.)" %}'},
192                     {name: 'draft', text: '{% trans "Select this option if you do not like your unsaved changes. Warning! Dropped changes will be lost and they cannot be restored." %}'},
193                     {name: 'comment', text: '{% trans "If you work on a document with a group, you can leave comments on each line of the document. Your comment will appear as a “bubble” on the left." %}'},
194                     {name: 'save', text: '{% trans "Click “Save” to save all the changes in your document. Remember to select the appropriate stage of the work on the document (Draft, Comments, Comments review, Proofreading, Publication)." %}'},
195                     {name: 'mainpage', text: '{% trans "Click on the MIL/PEER logo to open the home page in a new window." %}'},
196                     {name: 'exit', text: '{% trans "“Exit” will take you to the main page." %}'}
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         </script>
228         <div id="tuton"></div>
229         <div id="editor_root"></div>
230     </body>
231 </html>