tags in editor metadata window
[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                             {% for category in tag_categories %}
85                                 {key: '{{ category.dc_tag }}', values: [
86                                     {% for tag in category.tag_set.all %}
87                                         '{{ tag.dc_value }}'{% if not forloop.last %},{% endif %}
88                                     {% endfor %}
89                                 ]},
90                             {% endfor %}
91                             {key: 'creator'},
92                             {key: 'description'},
93                             {key: 'publisher'},
94                             {key: 'relation.coverimage.url', isFile: true}
95                         ]
96                     }
97                 },
98
99                 toolbar: [
100                     ['core.undo', 'core.redo'],
101                     
102                     [
103                     {actionName: 'core.switchToHeader'},
104                     {actionName: 'core.switchToParagraph'},
105                     {actionName: 'core.switchToImage'},
106                     {actionName: 'core.switchToVideo'},
107                     'core.toggleBulletList', 'core.toggleEnumList'
108                     ],
109
110                     [
111                         {actionName: 'core.emphasis', actionConfig: {label: '{% trans "emphasis" %}'}},
112                         {actionName: 'core.cite', actionConfig: {label: '{% trans "cite" %}'}},
113                         {actionName: 'core.link', actionConfig: {label: '{% trans "link" %}'}}
114                     ],
115                     
116                     //['core.template'],
117
118                     ['core.showMetadataEditor']
119                     /*[
120                         'core.insertOrderExercise',
121                         'core.insertChoiceSingleExercise',
122                         'core.insertChoiceMultiExercise',
123                         'core.insertChoiceTrueOrFalseExercise',
124                         'core.insertGapsExercise',
125                         'core.insertReplaceExercise'
126                     ]*/
127                 ],
128                 
129                 documentSaveUrl: function(id) { return '/editor/text/' + id + '/'; },
130                 documentHistoryUrl: function(id) { return '/editor/history/' + id + '/'},
131                 documentDiffUrl: function(id) { return '/editor/diff/' + id + '/'; },
132                 documentRestoreUrl: function(id) { return '/editor/revert/' + id + '/'},
133                 documentPublishUrl: '{% url "catalogue_publish" pk %}',
134
135                 documentScheduleUrl: '{% url "catalogue_book_schedule" pk %}',
136                 documentForkUrl: '{% url "catalogue_fork" pk %}',
137                 documentGalleryUrl: '{% url "catalogue_book_gallery" pk %}',
138
139                 documentAttachmentUrl: function(attachmentName) {
140                     return '{{MEDIA_URL}}uploads/{{ pk }}/' + attachmentName;
141                 },
142                 documentUrl: function(id, version) {
143                     var url = '{% url 'wiki_editor' pk %}';
144                     if(version) {
145                         url = url + '?version=' + version;
146                     }
147                     return url;
148                 },
149                 documentPreviewUrl: function(id) { return '/documents/{{ pk }}/rev' + id + '/preview/' },
150                 documentPreviewMainUrl: function() { return '/documents/{{ pk }}/preview/' },
151
152                 documentSaveForm: {
153                     fields: [
154                         {label: '{{forms.text_save.comment.label}}', name: '{{forms.text_save.comment.html_name}}', type: 'textarea'},
155                         {label: '{{forms.text_save.stage.label}}', name: '{{forms.text_save.stage.html_name}}', type: 'select', options: [
156                             {% for value, text in forms.text_save.stage.field.choices %}
157                                 {value:'{{value|default:''}}', text:'{{text}}'} {% if not forloop.last %}, {% endif %}
158                             {% endfor %}
159                         ], description: '{{forms.text_save.stage.help_text}}'}
160                     ],
161                     content_field_name: '{{forms.text_save.text.html_name}}',
162                     version_field_name: '{{forms.text_save.parent_revision.html_name}}'
163                 },
164
165                 documentRestoreForm: {
166                     fields: [
167                         {label: '{{forms.text_revert.comment.label}}', name: '{{forms.text_revert.comment.html_name}}', type: 'textarea'}
168                     ],
169                     version_field_name: '{{forms.text_revert.revision.html_name}}'
170                 },
171
172                 documentPublishForm: {
173                     fields: [
174                     ],
175                     revision_field_name: '{{forms.text_publish.revision.html_name}}'
176                 },
177
178                 tutorial: [
179                     {name: 'editor', text: '{% trans "Edit your document text." %}'},
180                     {name: 'sourceEditor', text: '{% trans "View the xml code of your document." %}'},
181                     {name: 'history', text: '{% trans "Here you can view the change history." %}'},
182                     {name: 'statusBar', text: '{% trans "The status bar shows helpful messages when you place the mouse cursor over toolbar buttons." %}'},
183                     {name: 'undo', text: '{% trans "Click Undo to revert recent changes." %}'},
184                     {name: 'redo', text: '{% trans "Redo will reapply undone changes." %}'},
185                     {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." %}'},
186                     {name: 'switchToParagraph', text: '{% trans "Use this option to switch a header to a paragraph." %}'},
187                     {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)." %}'},
188                     {name: 'switchToVideo', text: '{% trans "Add a video material to your document to make it more attractive. Paste the http link from a YouTube channel." %}'},
189                     {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." %}'},
190                     {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." %}'},
191                     {name: 'emphasis', text: '{% trans "Emphasize some text by using boldface. To turn it off, click the specific word and then click “emphasis”." %}'},
192                     {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." %}'},
193                     {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)." %}'},
194                     {name: 'showMetadataEditor', text: '{% trans "Here you can review and edit metadata. In “Attachments” you can add or change the cover of your document." %}'},
195                     {name: 'preview', text: '{% trans "Review your document before publication." %}'},
196                     {name: 'attachments', text: '{% trans "Here you can add other important materials to this document (audio files, JPG, PNG, ODT, PDF etc.)" %}'},
197                     {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." %}'},
198                     {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." %}'},
199                     {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)." %}'},
200                     {name: 'mainpage', text: '{% trans "Click on the MIL/PEER logo to open the home page in a new window." %}'},
201                     {name: 'exit', text: '{% trans "“Exit” will take you to the main page." %}'}
202                 ]
203             };
204
205             {% if can_pubmark %}
206                 config.documentSaveForm.fields.push(
207                     {label: '{{forms.text_save.publishable.label}}', name: '{{forms.text_save.publishable.html_name}}', type: 'checkbox', description: '{{forms.text_save.publishable.help_text}}'}
208                 );
209             {% endif %}
210
211             {% if not request.user.is_authenticated %}
212                 config.documentSaveForm.fields.push(
213                     {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}}'},
214                     {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}}'}
215                 );
216
217                 config.documentRestoreForm.fields.push(
218                     {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}}'},
219                     {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}}'}
220                 );
221             {% endif %}
222
223             {% autoescape off%}
224             var data = {{serialized_document_data}};
225             {%endautoescape%}
226
227             var editor_init = function(Editor) {            
228                 Editor.setBootstrappedData('data', data);
229                 Editor.start(config);
230             };
231
232         </script>
233         <div id="tuton"></div>
234         <div id="editor_root"></div>
235     </body>
236 </html>