Editor update - Hinting metadata values
[redakcja.git] / apps / wiki / templates / wiki / bootstrap.html
1 {% load staticfiles %}
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         <script src="http://cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/ace.js" type="text/javascript" charset="utf-8"></script>
22         
23         {% if DEBUG %}
24             <link rel="stylesheet/less" type="text/css" href="{% static 'wiki/editor/src/editor/styles/main.less' %}"/>
25             <script type="text/javascript">less = {relativeUrls: true};</script>
26             <script src="{% static 'wiki/editor/libs/less-1.3.3.min.js' %}"></script>
27             <script src="{% static 'wiki/editor/libs/require.js' %}" data-main="{% static 'wiki/editor/src/editor/entrypoint.js' %}" ></script>
28         {% else %}
29             <link href="{% static 'wiki/build/rng.css' %}" rel="stylesheet">
30             <script src="{% static 'wiki/build/rng.js' %}"></script>
31         {% endif %}
32     </head>
33     <body>
34         <script type="text/javascript">
35
36             var config = {
37                 rootSelector: '#editor_root',
38                 jsonifySentPayload: false,
39
40                 {% if request.user.is_authenticated %}
41                 user: {
42                     name: '{{request.user.username}}',
43                     email: '{{request.user.email}}',
44                     id: {{request.user.id}}
45                 },
46                 {% endif %}
47
48                 logging: {
49                     handlers: {
50                         'sentry': {
51                             level: 'info',
52                             handler: 'raven',
53                             formatter: 'noop'
54                         },
55                         'console': {
56                             level: 'debug',
57                             handler: 'console'
58                         }
59                     },
60                     loggers: {
61                         '': {
62                             level: 'debug',
63                             handlers: ['sentry', 'console']
64                         }
65                     }
66                 },
67               
68                 metadata: [
69                     {key: 'creator.expert'},
70                     {key: 'creator.scenario'},
71                     {key: 'creator.textbook'},
72                     {key: 'title'},
73                     {key: 'relation.isPartOf'},
74                     {key: 'publisher'},
75                     {key: 'subject.competence'},
76                     {key: 'subject.curriculum'},
77                     {key: 'subject'},
78                     {key: 'description'},
79                     {key: 'description.material'},
80                     {key: 'identifier.url'},
81                     {key: 'rights'},
82                     {key: 'rights.license'},
83                     {key: 'format'},
84                     {key: 'type'},
85                     {key: 'date'},
86                     {key: 'audience'}
87
88                 ],
89
90                 documentSummaryView: {
91                     title: '{% trans 'Informations about lesson' %}',
92                     properties: [
93                         {name: 'stage', label: '{% trans 'Stage' %}'},
94                         {name: 'assignment', label: '{% trans 'Assignment' %}'}
95                     ]
96                 },
97                 
98                 documentSaveUrl: function(id) { return '/editor/text/' + id + '/'; },
99                 documentHistoryUrl: function(id) { return '/editor/history/' + id + '/'},
100                 documentDiffUrl: function(id) { return '/editor/diff/' + id + '/'; },
101                 documentRestoreUrl: function(id) { return '/editor/revert/' + id + '/'},
102
103                 documentSaveForm: {
104                     fields: [
105                         {label: '{{forms.text_save.comment.label}}', name: '{{forms.text_save.comment.html_name}}', type: 'textarea'},
106                         {label: '{{forms.text_save.stage_completed.label}}', name: '{{forms.text_save.stage_completed.html_name}}', type: 'select', options: [
107                             {% for value,text in tags %}
108                                 {value:'{{value|default:''}}', text:'{{text}}'} {% if not forloop.last %}, {% endif %}
109                             {% endfor %}
110                         ], description: '{{forms.text_save.stage_completed.help_text}}'},
111                     ],
112                     content_field_name: '{{forms.text_save.text.html_name}}',
113                     version_field_name: '{{forms.text_save.parent_revision.html_name}}'
114                 },
115
116                 documentRestoreForm: {
117                     fields: [
118                         {label: '{{forms.text_revert.comment.label}}', name: '{{forms.text_revert.comment.html_name}}', type: 'textarea'}
119                     ],
120                     version_field_name: '{{forms.text_revert.revision.html_name}}'
121                 }
122             };
123
124             {% if can_pubmark %}
125                 config.documentSaveForm.fields.push(
126                     {label: '{{forms.text_save.publishable.label}}', name: '{{forms.text_save.publishable.html_name}}', type: 'checkbox', description: '{{forms.text_save.publishable.help_text}}'}
127                 );
128             {% endif %}
129
130             {% if not request.user.is_authenticated %}
131                 config.documentSaveForm.fields.push(
132                     {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}}'},
133                     {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}}'}
134                 );
135
136                 config.documentRestoreForm.fields.push(
137                     {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}}'},
138                     {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}}'}
139                 );
140             {% endif %}
141
142             {% autoescape off%}
143             var data = {{serialized_document_data}},
144                 templates = {{serialized_templates}}
145             {%endautoescape%}
146
147             var editor_init = function(Editor) {            
148                 Editor.setBootstrappedData('data', data);
149                 Editor.setBootstrappedData('documentToolbar', templates);
150                 Editor.start(config);
151             };
152         </script>
153         <div id="editor_root"></div>
154     </body>
155 </html>