Pass user data to ravenjs
[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.3/jquery,native/raven.min.js"></script>
9             <script>
10                 Raven.config('{{RAVEN_CONFIG.SENTRY_URL}}', {{RAVEN_CONFIG.SETTINGS|default:'{}'}}).install();
11                 {% if request.user %}
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                 logging: {
41                     handlers: {
42                         'sentry': {
43                             level: 'info',
44                             handler: 'raven'
45                         }
46                     },
47                     loggers: {
48                         '': {
49                             level: 'info',
50                             handlers: ['sentry']
51                         }
52                     }
53                 },
54                 
55                 documentSaveUrl: function(id) { return '/editor/text/' + id + '/'; },
56                 documentHistoryUrl: function(id) { return '/editor/history/' + id + '/'},
57                 documentDiffUrl: function(id) { return '/editor/diff/' + id + '/'; },
58                 documentRestoreUrl: function(id) { return '/editor/revert/' + id + '/'},
59
60                 documentSaveForm: {
61                     fields: [
62                         {label: '{{forms.text_save.comment.label}}', name: '{{forms.text_save.comment.html_name}}', type: 'textarea'},
63                         {label: '{{forms.text_save.stage_completed.label}}', name: '{{forms.text_save.stage_completed.html_name}}', type: 'select', options: [
64                             {% for value,text in tags %}
65                                 {value:'{{value|default:''}}', text:'{{text}}'} {% if not forloop.last %}, {% endif %}
66                             {% endfor %}
67                         ], description: '{{forms.text_save.stage_completed.help_text}}'},
68                     ],
69                     content_field_name: '{{forms.text_save.text.html_name}}',
70                     version_field_name: '{{forms.text_save.parent_revision.html_name}}'
71                 },
72
73                 documentRestoreForm: {
74                     fields: [
75                         {label: '{{forms.text_revert.comment.label}}', name: '{{forms.text_revert.comment.html_name}}', type: 'textarea'}
76                     ],
77                     version_field_name: '{{forms.text_revert.revision.html_name}}'
78                 }
79             };
80
81             {% if can_pubmark %}
82                 config.documentSaveForm.fields.push(
83                     {label: '{{forms.text_save.publishable.label}}', name: '{{forms.text_save.publishable.html_name}}', type: 'checkbox', description: '{{forms.text_save.publishable.help_text}}'}
84                 );
85             {% endif %}
86
87             {% if not request.user.is_authenticated %}
88                 config.documentSaveForm.fields.push(
89                     {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}}'},
90                     {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}}'}
91                 );
92
93                 config.documentRestoreForm.fields.push(
94                     {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}}'},
95                     {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}}'}
96                 );
97             {% endif %}
98
99             {% autoescape off%}
100             var data = {{serialized_document_data}},
101                 templates = {{serialized_templates}}
102             {%endautoescape%}
103
104             var editor_init = function(Editor) {            
105                 Editor.setBootstrappedData('data', data);
106                 Editor.setBootstrappedData('documentToolbar', templates);
107                 Editor.start(config);
108             };
109         </script>
110         <div id="editor_root"></div>
111     </body>
112 </html>