Show More
@@ -1,219 +1,225 b'' | |||||
1 | "use strict"; |
|
1 | "use strict"; | |
2 | /** leak object to top level scope **/ |
|
2 | /** leak object to top level scope **/ | |
3 | var ccLog = undefined; |
|
3 | var ccLog = undefined; | |
4 | // global code-mirror logger;, to enable run |
|
4 | // global code-mirror logger;, to enable run | |
5 | // Logger.get('ConnectionController').setLevel(Logger.DEBUG) |
|
5 | // Logger.get('ConnectionController').setLevel(Logger.DEBUG) | |
6 | ccLog = Logger.get('ConnectionController'); |
|
6 | ccLog = Logger.get('ConnectionController'); | |
7 | ccLog.setLevel(Logger.OFF); |
|
7 | ccLog.setLevel(Logger.OFF); | |
8 |
|
8 | |||
9 | var ConnectionController; |
|
9 | var ConnectionController; | |
10 | var connCtrlr; |
|
10 | var connCtrlr; | |
11 | var registerViewChannels; |
|
11 | var registerViewChannels; | |
12 |
|
12 | |||
13 | (function () { |
|
13 | (function () { | |
14 | ConnectionController = function (webappUrl, serverUrl, urls) { |
|
14 | ConnectionController = function (webappUrl, serverUrl, urls) { | |
15 | var self = this; |
|
15 | var self = this; | |
16 |
|
16 | |||
17 | var channels = ['broadcast']; |
|
17 | var channels = ['broadcast']; | |
18 | this.state = { |
|
18 | this.state = { | |
19 | open: false, |
|
19 | open: false, | |
20 | webappUrl: webappUrl, |
|
20 | webappUrl: webappUrl, | |
21 | serverUrl: serverUrl, |
|
21 | serverUrl: serverUrl, | |
22 | connId: null, |
|
22 | connId: null, | |
23 | socket: null, |
|
23 | socket: null, | |
24 | channels: channels, |
|
24 | channels: channels, | |
25 | heartbeat: null, |
|
25 | heartbeat: null, | |
26 | channelsInfo: {}, |
|
26 | channelsInfo: {}, | |
27 | urls: urls |
|
27 | urls: urls | |
28 | }; |
|
28 | }; | |
29 | this.channelNameParsers = []; |
|
29 | this.channelNameParsers = []; | |
30 |
|
30 | |||
31 | this.addChannelNameParser = function (fn) { |
|
31 | this.addChannelNameParser = function (fn) { | |
32 | if (this.channelNameParsers.indexOf(fn) === -1) { |
|
32 | if (this.channelNameParsers.indexOf(fn) === -1) { | |
33 | this.channelNameParsers.push(fn); |
|
33 | this.channelNameParsers.push(fn); | |
34 | } |
|
34 | } | |
35 | }; |
|
35 | }; | |
36 |
|
36 | |||
37 | this.listen = function () { |
|
37 | this.listen = function () { | |
38 | if (window.WebSocket) { |
|
38 | if (window.WebSocket) { | |
39 | ccLog.debug('attempting to create socket'); |
|
39 | ccLog.debug('attempting to create socket'); | |
40 | var socket_url = self.state.serverUrl + "/ws?conn_id=" + self.state.connId; |
|
40 | var socket_url = self.state.serverUrl + "/ws?conn_id=" + self.state.connId; | |
41 | var socket_conf = { |
|
41 | var socket_conf = { | |
42 | url: socket_url, |
|
42 | url: socket_url, | |
43 | handleAs: 'json', |
|
43 | handleAs: 'json', | |
44 | headers: { |
|
44 | headers: { | |
45 | "Accept": "application/json", |
|
45 | "Accept": "application/json", | |
46 | "Content-Type": "application/json" |
|
46 | "Content-Type": "application/json" | |
47 | } |
|
47 | } | |
48 | }; |
|
48 | }; | |
49 | self.state.socket = new WebSocket(socket_conf.url); |
|
49 | self.state.socket = new WebSocket(socket_conf.url); | |
50 |
|
50 | |||
51 | self.state.socket.onopen = function (event) { |
|
51 | self.state.socket.onopen = function (event) { | |
52 | ccLog.debug('open event', event); |
|
52 | ccLog.debug('open event', event); | |
53 | if (self.state.heartbeat === null) { |
|
53 | if (self.state.heartbeat === null) { | |
54 | self.state.heartbeat = setInterval(function () { |
|
54 | self.state.heartbeat = setInterval(function () { | |
55 | if (self.state.socket.readyState === WebSocket.OPEN) { |
|
55 | if (self.state.socket.readyState === WebSocket.OPEN) { | |
56 | self.state.socket.send('heartbeat'); |
|
56 | self.state.socket.send('heartbeat'); | |
57 | } |
|
57 | } | |
58 | }, 10000) |
|
58 | }, 10000) | |
59 | } |
|
59 | } | |
60 | }; |
|
60 | }; | |
61 | self.state.socket.onmessage = function (event) { |
|
61 | self.state.socket.onmessage = function (event) { | |
62 | var data = $.parseJSON(event.data); |
|
62 | var data = $.parseJSON(event.data); | |
63 | for (var i = 0; i < data.length; i++) { |
|
63 | for (var i = 0; i < data.length; i++) { | |
64 | if (data[i].message.topic) { |
|
64 | if (data[i].message.topic) { | |
65 | ccLog.debug('publishing', |
|
65 | ccLog.debug('publishing', | |
66 | data[i].message.topic, data[i]); |
|
66 | data[i].message.topic, data[i]); | |
67 | $.Topic(data[i].message.topic).publish(data[i]) |
|
67 | $.Topic(data[i].message.topic).publish(data[i]) | |
68 | } |
|
68 | } | |
69 | else { |
|
69 | else { | |
70 | ccLog.warn('unhandled message', data); |
|
70 | ccLog.warn('unhandled message', data); | |
71 | } |
|
71 | } | |
72 | } |
|
72 | } | |
73 | }; |
|
73 | }; | |
74 | self.state.socket.onclose = function (event) { |
|
74 | self.state.socket.onclose = function (event) { | |
75 | ccLog.debug('closed event', event); |
|
75 | ccLog.debug('closed event', event); | |
76 | setTimeout(function () { |
|
76 | setTimeout(function () { | |
77 | self.connect(true); |
|
77 | self.connect(true); | |
78 | }, 5000); |
|
78 | }, 5000); | |
79 | }; |
|
79 | }; | |
80 |
|
80 | |||
81 | self.state.socket.onerror = function (event) { |
|
81 | self.state.socket.onerror = function (event) { | |
82 | ccLog.debug('error event', event); |
|
82 | ccLog.debug('error event', event); | |
83 | }; |
|
83 | }; | |
84 | } |
|
84 | } | |
85 | else { |
|
85 | else { | |
86 | ccLog.debug('attempting to create long polling connection'); |
|
86 | ccLog.debug('attempting to create long polling connection'); | |
87 | var poolUrl = self.state.serverUrl + "/listen?conn_id=" + self.state.connId; |
|
87 | var poolUrl = self.state.serverUrl + "/listen?conn_id=" + self.state.connId; | |
88 | self.state.socket = $.ajax({ |
|
88 | self.state.socket = $.ajax({ | |
89 | url: poolUrl |
|
89 | url: poolUrl | |
90 | }).done(function (data) { |
|
90 | }).done(function (data) { | |
91 | ccLog.debug('data', data); |
|
91 | ccLog.debug('data', data); | |
92 | var data = $.parseJSON(data); |
|
92 | var data = $.parseJSON(data); | |
93 | for (var i = 0; i < data.length; i++) { |
|
93 | for (var i = 0; i < data.length; i++) { | |
94 | if (data[i].message.topic) { |
|
94 | if (data[i].message.topic) { | |
95 | ccLog.info('publishing', |
|
95 | ccLog.info('publishing', | |
96 | data[i].message.topic, data[i]); |
|
96 | data[i].message.topic, data[i]); | |
97 | $.Topic(data[i].message.topic).publish(data[i]) |
|
97 | $.Topic(data[i].message.topic).publish(data[i]) | |
98 | } |
|
98 | } | |
99 | else { |
|
99 | else { | |
100 | ccLog.warn('unhandled message', data); |
|
100 | ccLog.warn('unhandled message', data); | |
101 | } |
|
101 | } | |
102 | } |
|
102 | } | |
103 | self.listen(); |
|
103 | self.listen(); | |
104 | }).fail(function () { |
|
104 | }).fail(function () { | |
105 | ccLog.debug('longpoll error'); |
|
105 | ccLog.debug('longpoll error'); | |
106 | setTimeout(function () { |
|
106 | setTimeout(function () { | |
107 | self.connect(true); |
|
107 | self.connect(true); | |
108 | }, 5000); |
|
108 | }, 5000); | |
109 | }); |
|
109 | }); | |
110 | } |
|
110 | } | |
111 |
|
111 | |||
112 | }; |
|
112 | }; | |
113 |
|
113 | |||
114 | this.connect = function (create_new_socket) { |
|
114 | this.connect = function (create_new_socket) { | |
115 | var connReq = {'channels': self.state.channels}; |
|
115 | var connReq = {'channels': self.state.channels}; | |
116 | ccLog.debug('try obtaining connection info', connReq); |
|
116 | ccLog.debug('try obtaining connection info', connReq); | |
117 | $.ajax({ |
|
117 | $.ajax({ | |
118 | url: self.state.urls.connect, |
|
118 | url: self.state.urls.connect, | |
119 | type: "POST", |
|
119 | type: "POST", | |
120 | contentType: "application/json", |
|
120 | contentType: "application/json", | |
121 | data: JSON.stringify(connReq), |
|
121 | data: JSON.stringify(connReq), | |
122 | dataType: "json" |
|
122 | dataType: "json" | |
123 | }).done(function (data) { |
|
123 | }).done(function (data) { | |
124 | ccLog.debug('Got connection:', data.conn_id); |
|
124 | ccLog.debug('Got connection:', data.conn_id); | |
125 | self.state.channels = data.channels; |
|
125 | self.state.channels = data.channels; | |
126 | self.state.channelsInfo = data.channels_info; |
|
126 | self.state.channelsInfo = data.channels_info; | |
127 | self.state.connId = data.conn_id; |
|
127 | self.state.connId = data.conn_id; | |
128 | if (create_new_socket) { |
|
128 | if (create_new_socket) { | |
129 | self.listen(); |
|
129 | self.listen(); | |
130 | } |
|
130 | } | |
131 | self.update(); |
|
131 | self.update(); | |
132 | }).fail(function () { |
|
132 | }).fail(function () { | |
133 | setTimeout(function () { |
|
133 | setTimeout(function () { | |
134 | self.connect(create_new_socket); |
|
134 | self.connect(create_new_socket); | |
135 | }, 5000); |
|
135 | }, 5000); | |
136 | }); |
|
136 | }); | |
137 | self.update(); |
|
137 | self.update(); | |
138 | }; |
|
138 | }; | |
139 |
|
139 | |||
140 | this.subscribeToChannels = function (channels) { |
|
140 | this.subscribeToChannels = function (channels) { | |
141 | var new_channels = []; |
|
141 | var new_channels = []; | |
142 | for (var i = 0; i < channels.length; i++) { |
|
142 | for (var i = 0; i < channels.length; i++) { | |
143 | var channel = channels[i]; |
|
143 | var channel = channels[i]; | |
144 | if (self.state.channels.indexOf(channel)) { |
|
144 | if (self.state.channels.indexOf(channel)) { | |
145 | self.state.channels.push(channel); |
|
145 | self.state.channels.push(channel); | |
146 | new_channels.push(channel) |
|
146 | new_channels.push(channel) | |
147 | } |
|
147 | } | |
148 | } |
|
148 | } | |
149 | /** |
|
149 | /** | |
150 | * only execute the request if socket is present because subscribe |
|
150 | * only execute the request if socket is present because subscribe | |
151 | * can actually add channels before initial app connection |
|
151 | * can actually add channels before initial app connection | |
152 | **/ |
|
152 | **/ | |
153 | if (new_channels && self.state.socket !== null) { |
|
153 | if (new_channels && self.state.socket !== null) { | |
154 | var connReq = { |
|
154 | var connReq = { | |
155 | 'channels': self.state.channels, |
|
155 | 'channels': self.state.channels, | |
156 | 'conn_id': self.state.connId |
|
156 | 'conn_id': self.state.connId | |
157 | }; |
|
157 | }; | |
158 | $.ajax({ |
|
158 | $.ajax({ | |
159 | url: self.state.urls.subscribe, |
|
159 | url: self.state.urls.subscribe, | |
160 | type: "POST", |
|
160 | type: "POST", | |
161 | contentType: "application/json", |
|
161 | contentType: "application/json", | |
162 | data: JSON.stringify(connReq), |
|
162 | data: JSON.stringify(connReq), | |
163 | dataType: "json" |
|
163 | dataType: "json" | |
164 | }).done(function (data) { |
|
164 | }).done(function (data) { | |
165 | self.state.channels = data.channels; |
|
165 | self.state.channels = data.channels; | |
166 | self.state.channelsInfo = data.channels_info; |
|
166 | self.state.channelsInfo = data.channels_info; | |
167 | self.update(); |
|
167 | self.update(); | |
168 | }); |
|
168 | }); | |
169 | } |
|
169 | } | |
170 | self.update(); |
|
170 | self.update(); | |
171 | }; |
|
171 | }; | |
172 |
|
172 | |||
173 | this.update = function () { |
|
173 | this.update = function () { | |
174 | for (var key in this.state.channelsInfo) { |
|
174 | for (var key in this.state.channelsInfo) { | |
175 | if (this.state.channelsInfo.hasOwnProperty(key)) { |
|
175 | if (this.state.channelsInfo.hasOwnProperty(key)) { | |
176 | // update channels with latest info |
|
176 | // update channels with latest info | |
177 | $.Topic('/connection_controller/channel_update').publish( |
|
177 | $.Topic('/connection_controller/channel_update').publish( | |
178 | {channel: key, state: this.state.channelsInfo[key]}); |
|
178 | {channel: key, state: this.state.channelsInfo[key]}); | |
179 | } |
|
179 | } | |
180 | } |
|
180 | } | |
181 | /** |
|
181 | /** | |
182 | * checks current channel list in state and if channel is not present |
|
182 | * checks current channel list in state and if channel is not present | |
183 | * converts them into executable "commands" and pushes them on topics |
|
183 | * converts them into executable "commands" and pushes them on topics | |
184 | */ |
|
184 | */ | |
185 | for (var i = 0; i < this.state.channels.length; i++) { |
|
185 | for (var i = 0; i < this.state.channels.length; i++) { | |
186 | var channel = this.state.channels[i]; |
|
186 | var channel = this.state.channels[i]; | |
187 | for (var j = 0; j < this.channelNameParsers.length; j++) { |
|
187 | for (var j = 0; j < this.channelNameParsers.length; j++) { | |
188 | this.channelNameParsers[j](channel); |
|
188 | this.channelNameParsers[j](channel); | |
189 | } |
|
189 | } | |
190 | } |
|
190 | } | |
191 | }; |
|
191 | }; | |
192 |
|
192 | |||
193 | this.run = function () { |
|
193 | this.run = function () { | |
194 | this.connect(true); |
|
194 | this.connect(true); | |
195 | }; |
|
195 | }; | |
196 |
|
196 | |||
197 | $.Topic('/connection_controller/subscribe').subscribe( |
|
197 | $.Topic('/connection_controller/subscribe').subscribe( | |
198 | self.subscribeToChannels); |
|
198 | self.subscribeToChannels); | |
199 | }; |
|
199 | }; | |
200 |
|
200 | |||
201 | $.Topic('/plugins/__REGISTER__').subscribe(function (data) { |
|
201 | $.Topic('/plugins/__REGISTER__').subscribe(function (data) { | |
202 | // enable chat controller |
|
|||
203 | if (window.CHANNELSTREAM_SETTINGS && window.CHANNELSTREAM_SETTINGS.enabled) { |
|
202 | if (window.CHANNELSTREAM_SETTINGS && window.CHANNELSTREAM_SETTINGS.enabled) { | |
|
203 | connCtrlr = new ConnectionController( | |||
|
204 | CHANNELSTREAM_SETTINGS.webapp_location, | |||
|
205 | CHANNELSTREAM_SETTINGS.ws_location, | |||
|
206 | CHANNELSTREAM_URLS | |||
|
207 | ); | |||
|
208 | registerViewChannels(); | |||
|
209 | ||||
204 | $(document).ready(function () { |
|
210 | $(document).ready(function () { | |
205 | connCtrlr.run(); |
|
211 | connCtrlr.run(); | |
206 | }); |
|
212 | }); | |
207 | } |
|
213 | } | |
208 | }); |
|
214 | }); | |
209 |
|
215 | |||
210 | registerViewChannels = function (){ |
|
216 | registerViewChannels = function (){ | |
211 | // subscribe to PR repo channel for PR's' |
|
217 | // subscribe to PR repo channel for PR's' | |
212 | if (templateContext.pull_request_data.pull_request_id) { |
|
218 | if (templateContext.pull_request_data.pull_request_id) { | |
213 | var channelName = '/repo$' + templateContext.repo_name + '$/pr/' + |
|
219 | var channelName = '/repo$' + templateContext.repo_name + '$/pr/' + | |
214 | String(templateContext.pull_request_data.pull_request_id); |
|
220 | String(templateContext.pull_request_data.pull_request_id); | |
215 | connCtrlr.state.channels.push(channelName); |
|
221 | connCtrlr.state.channels.push(channelName); | |
216 | } |
|
222 | } | |
217 | } |
|
223 | } | |
218 |
|
224 | |||
219 | })(); |
|
225 | })(); |
@@ -1,14 +1,11 b'' | |||||
1 | <% |
|
1 | <% | |
2 | from pyramid.renderers import render as pyramid_render |
|
2 | from pyramid.renderers import render as pyramid_render | |
3 | from pyramid.threadlocal import get_current_registry, get_current_request |
|
3 | from pyramid.threadlocal import get_current_registry, get_current_request | |
4 | pyramid_registry = get_current_registry() |
|
4 | pyramid_registry = get_current_registry() | |
5 | %> |
|
5 | %> | |
6 | % for plugin, config in getattr(pyramid_registry, 'rhodecode_plugins', {}).items(): |
|
6 | % for plugin, config in getattr(pyramid_registry, 'rhodecode_plugins', {}).items(): | |
7 | % if config['template_hooks'].get('plugin_init_template'): |
|
7 | % if config['template_hooks'].get('plugin_init_template'): | |
8 | ${pyramid_render(config['template_hooks'].get('plugin_init_template'), |
|
8 | ${pyramid_render(config['template_hooks'].get('plugin_init_template'), | |
9 | {'config':config}, request=get_current_request(), package='rc_ae')|n} |
|
9 | {'config':config}, request=get_current_request(), package='rc_ae')|n} | |
10 | % endif |
|
10 | % endif | |
11 | % endfor |
|
11 | % endfor | |
12 | <script> |
|
|||
13 | $.Topic('/plugins/__REGISTER__').prepareOrPublish({}); |
|
|||
14 | </script> |
|
@@ -1,177 +1,179 b'' | |||||
1 | ## -*- coding: utf-8 -*- |
|
1 | ## -*- coding: utf-8 -*- | |
2 | <!DOCTYPE html> |
|
2 | <!DOCTYPE html> | |
3 |
|
3 | |||
4 | <% |
|
4 | <% | |
5 | c.template_context['repo_name'] = getattr(c, 'repo_name', '') |
|
5 | c.template_context['repo_name'] = getattr(c, 'repo_name', '') | |
6 |
|
6 | |||
7 | if hasattr(c, 'rhodecode_db_repo'): |
|
7 | if hasattr(c, 'rhodecode_db_repo'): | |
8 | c.template_context['repo_type'] = c.rhodecode_db_repo.repo_type |
|
8 | c.template_context['repo_type'] = c.rhodecode_db_repo.repo_type | |
9 | c.template_context['repo_landing_commit'] = c.rhodecode_db_repo.landing_rev[1] |
|
9 | c.template_context['repo_landing_commit'] = c.rhodecode_db_repo.landing_rev[1] | |
10 |
|
10 | |||
11 | if getattr(c, 'rhodecode_user', None) and c.rhodecode_user.user_id: |
|
11 | if getattr(c, 'rhodecode_user', None) and c.rhodecode_user.user_id: | |
12 | c.template_context['rhodecode_user']['username'] = c.rhodecode_user.username |
|
12 | c.template_context['rhodecode_user']['username'] = c.rhodecode_user.username | |
13 | c.template_context['rhodecode_user']['email'] = c.rhodecode_user.email |
|
13 | c.template_context['rhodecode_user']['email'] = c.rhodecode_user.email | |
14 | c.template_context['rhodecode_user']['notification_status'] = c.rhodecode_user.get_instance().user_data.get('notification_status', True) |
|
14 | c.template_context['rhodecode_user']['notification_status'] = c.rhodecode_user.get_instance().user_data.get('notification_status', True) | |
15 |
|
15 | |||
16 | c.template_context['visual']['default_renderer'] = h.get_visual_attr(c, 'default_renderer') |
|
16 | c.template_context['visual']['default_renderer'] = h.get_visual_attr(c, 'default_renderer') | |
17 | %> |
|
17 | %> | |
18 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|
18 | <html xmlns="http://www.w3.org/1999/xhtml"> | |
19 | <head> |
|
19 | <head> | |
20 | <title>${self.title()}</title> |
|
20 | <title>${self.title()}</title> | |
21 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> |
|
21 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> | |
22 | <%def name="robots()"> |
|
22 | <%def name="robots()"> | |
23 | <meta name="robots" content="index, nofollow"/> |
|
23 | <meta name="robots" content="index, nofollow"/> | |
24 | </%def> |
|
24 | </%def> | |
25 | ${self.robots()} |
|
25 | ${self.robots()} | |
26 | <link rel="icon" href="${h.asset('images/favicon.ico', ver=c.rhodecode_version_hash)}" sizes="16x16 32x32" type="image/png" /> |
|
26 | <link rel="icon" href="${h.asset('images/favicon.ico', ver=c.rhodecode_version_hash)}" sizes="16x16 32x32" type="image/png" /> | |
27 |
|
27 | |||
28 | ## CSS definitions |
|
28 | ## CSS definitions | |
29 | <%def name="css()"> |
|
29 | <%def name="css()"> | |
30 | <link rel="stylesheet" type="text/css" href="${h.asset('css/style.css', ver=c.rhodecode_version_hash)}" media="screen"/> |
|
30 | <link rel="stylesheet" type="text/css" href="${h.asset('css/style.css', ver=c.rhodecode_version_hash)}" media="screen"/> | |
31 | <!--[if lt IE 9]> |
|
31 | <!--[if lt IE 9]> | |
32 | <link rel="stylesheet" type="text/css" href="${h.asset('css/ie.css', ver=c.rhodecode_version_hash)}" media="screen"/> |
|
32 | <link rel="stylesheet" type="text/css" href="${h.asset('css/ie.css', ver=c.rhodecode_version_hash)}" media="screen"/> | |
33 | <![endif]--> |
|
33 | <![endif]--> | |
34 | ## EXTRA FOR CSS |
|
34 | ## EXTRA FOR CSS | |
35 | ${self.css_extra()} |
|
35 | ${self.css_extra()} | |
36 | </%def> |
|
36 | </%def> | |
37 | ## CSS EXTRA - optionally inject some extra CSS stuff needed for specific websites |
|
37 | ## CSS EXTRA - optionally inject some extra CSS stuff needed for specific websites | |
38 | <%def name="css_extra()"> |
|
38 | <%def name="css_extra()"> | |
39 | </%def> |
|
39 | </%def> | |
40 |
|
40 | |||
41 | ${self.css()} |
|
41 | ${self.css()} | |
42 |
|
42 | |||
43 | ## JAVASCRIPT |
|
43 | ## JAVASCRIPT | |
44 | <%def name="js()"> |
|
44 | <%def name="js()"> | |
45 | <script> |
|
45 | <script> | |
46 | // setup Polymer options |
|
46 | // setup Polymer options | |
47 | window.Polymer = {lazyRegister: true, dom: 'shadow'}; |
|
47 | window.Polymer = {lazyRegister: true, dom: 'shadow'}; | |
48 |
|
48 | |||
49 | // Load webcomponentsjs polyfill if browser does not support native Web Components |
|
49 | // Load webcomponentsjs polyfill if browser does not support native Web Components | |
50 | (function() { |
|
50 | (function() { | |
51 | 'use strict'; |
|
51 | 'use strict'; | |
52 | var onload = function() { |
|
52 | var onload = function() { | |
53 | // For native Imports, manually fire WebComponentsReady so user code |
|
53 | // For native Imports, manually fire WebComponentsReady so user code | |
54 | // can use the same code path for native and polyfill'd imports. |
|
54 | // can use the same code path for native and polyfill'd imports. | |
55 | if (!window.HTMLImports) { |
|
55 | if (!window.HTMLImports) { | |
56 | document.dispatchEvent( |
|
56 | document.dispatchEvent( | |
57 | new CustomEvent('WebComponentsReady', {bubbles: true}) |
|
57 | new CustomEvent('WebComponentsReady', {bubbles: true}) | |
58 | ); |
|
58 | ); | |
59 | } |
|
59 | } | |
60 | }; |
|
60 | }; | |
61 | var webComponentsSupported = ( |
|
61 | var webComponentsSupported = ( | |
62 | 'registerElement' in document |
|
62 | 'registerElement' in document | |
63 | && 'import' in document.createElement('link') |
|
63 | && 'import' in document.createElement('link') | |
64 | && 'content' in document.createElement('template') |
|
64 | && 'content' in document.createElement('template') | |
65 | ); |
|
65 | ); | |
66 | if (!webComponentsSupported) { |
|
66 | if (!webComponentsSupported) { | |
67 | var e = document.createElement('script'); |
|
67 | var e = document.createElement('script'); | |
68 | e.async = true; |
|
68 | e.async = true; | |
69 | e.src = '${h.asset('js/vendors/webcomponentsjs/webcomponents-lite.min.js', ver=c.rhodecode_version_hash)}'; |
|
69 | e.src = '${h.asset('js/vendors/webcomponentsjs/webcomponents-lite.min.js', ver=c.rhodecode_version_hash)}'; | |
70 | document.head.appendChild(e); |
|
70 | document.head.appendChild(e); | |
71 | } else { |
|
71 | } else { | |
72 | onload(); |
|
72 | onload(); | |
73 | } |
|
73 | } | |
74 | })(); |
|
74 | })(); | |
75 | </script> |
|
75 | </script> | |
76 |
|
76 | |||
77 | <script src="${h.asset('js/rhodecode/i18n/%s.js' % c.language, ver=c.rhodecode_version_hash)}"></script> |
|
77 | <script src="${h.asset('js/rhodecode/i18n/%s.js' % c.language, ver=c.rhodecode_version_hash)}"></script> | |
78 | <script type="text/javascript"> |
|
78 | <script type="text/javascript"> | |
79 | // register templateContext to pass template variables to JS |
|
79 | // register templateContext to pass template variables to JS | |
80 | var templateContext = ${h.json.dumps(c.template_context)|n}; |
|
80 | var templateContext = ${h.json.dumps(c.template_context)|n}; | |
81 |
|
81 | |||
82 | var REPO_NAME = "${getattr(c, 'repo_name', '')}"; |
|
82 | var REPO_NAME = "${getattr(c, 'repo_name', '')}"; | |
83 | %if hasattr(c, 'rhodecode_db_repo'): |
|
83 | %if hasattr(c, 'rhodecode_db_repo'): | |
84 | var REPO_LANDING_REV = '${c.rhodecode_db_repo.landing_rev[1]}'; |
|
84 | var REPO_LANDING_REV = '${c.rhodecode_db_repo.landing_rev[1]}'; | |
85 | var REPO_TYPE = '${c.rhodecode_db_repo.repo_type}'; |
|
85 | var REPO_TYPE = '${c.rhodecode_db_repo.repo_type}'; | |
86 | %else: |
|
86 | %else: | |
87 | var REPO_LANDING_REV = ''; |
|
87 | var REPO_LANDING_REV = ''; | |
88 | var REPO_TYPE = ''; |
|
88 | var REPO_TYPE = ''; | |
89 | %endif |
|
89 | %endif | |
90 | var APPLICATION_URL = "${h.url('home').rstrip('/')}"; |
|
90 | var APPLICATION_URL = "${h.url('home').rstrip('/')}"; | |
91 | var ASSET_URL = "${h.asset('')}"; |
|
91 | var ASSET_URL = "${h.asset('')}"; | |
92 | var DEFAULT_RENDERER = "${h.get_visual_attr(c, 'default_renderer')}"; |
|
92 | var DEFAULT_RENDERER = "${h.get_visual_attr(c, 'default_renderer')}"; | |
93 | var CSRF_TOKEN = "${getattr(c, 'csrf_token', '')}"; |
|
93 | var CSRF_TOKEN = "${getattr(c, 'csrf_token', '')}"; | |
94 | % if getattr(c, 'rhodecode_user', None): |
|
94 | % if getattr(c, 'rhodecode_user', None): | |
95 | var USER = {name:'${c.rhodecode_user.username}'}; |
|
95 | var USER = {name:'${c.rhodecode_user.username}'}; | |
96 | % else: |
|
96 | % else: | |
97 | var USER = {name:null}; |
|
97 | var USER = {name:null}; | |
98 | % endif |
|
98 | % endif | |
99 |
|
99 | |||
100 | var APPENLIGHT = { |
|
100 | var APPENLIGHT = { | |
101 | enabled: ${'true' if getattr(c, 'appenlight_enabled', False) else 'false'}, |
|
101 | enabled: ${'true' if getattr(c, 'appenlight_enabled', False) else 'false'}, | |
102 | key: '${getattr(c, "appenlight_api_public_key", "")}', |
|
102 | key: '${getattr(c, "appenlight_api_public_key", "")}', | |
103 | % if getattr(c, 'appenlight_server_url', None): |
|
103 | % if getattr(c, 'appenlight_server_url', None): | |
104 | serverUrl: '${getattr(c, "appenlight_server_url", "")}', |
|
104 | serverUrl: '${getattr(c, "appenlight_server_url", "")}', | |
105 | % endif |
|
105 | % endif | |
106 | requestInfo: { |
|
106 | requestInfo: { | |
107 | % if getattr(c, 'rhodecode_user', None): |
|
107 | % if getattr(c, 'rhodecode_user', None): | |
108 | ip: '${c.rhodecode_user.ip_addr}', |
|
108 | ip: '${c.rhodecode_user.ip_addr}', | |
109 | username: '${c.rhodecode_user.username}' |
|
109 | username: '${c.rhodecode_user.username}' | |
110 | % endif |
|
110 | % endif | |
111 | } |
|
111 | } | |
112 | }; |
|
112 | }; | |
113 | </script> |
|
113 | </script> | |
|
114 | <%include file="/base/plugins_base.html"/> | |||
114 | <!--[if lt IE 9]> |
|
115 | <!--[if lt IE 9]> | |
115 | <script language="javascript" type="text/javascript" src="${h.asset('js/excanvas.min.js')}"></script> |
|
116 | <script language="javascript" type="text/javascript" src="${h.asset('js/excanvas.min.js')}"></script> | |
116 | <![endif]--> |
|
117 | <![endif]--> | |
117 | <script language="javascript" type="text/javascript" src="${h.asset('js/rhodecode/routes.js', ver=c.rhodecode_version_hash)}"></script> |
|
118 | <script language="javascript" type="text/javascript" src="${h.asset('js/rhodecode/routes.js', ver=c.rhodecode_version_hash)}"></script> | |
118 | <script language="javascript" type="text/javascript" src="${h.asset('js/scripts.js', ver=c.rhodecode_version_hash)}"></script> |
|
119 | <script language="javascript" type="text/javascript" src="${h.asset('js/scripts.js', ver=c.rhodecode_version_hash)}"></script> | |
119 | <script> |
|
120 | <script> | |
120 | var e = document.createElement('script'); |
|
121 | var e = document.createElement('script'); | |
121 | e.src = '${h.asset('js/rhodecode-components.js', ver=c.rhodecode_version_hash)}'; |
|
122 | e.src = '${h.asset('js/rhodecode-components.js', ver=c.rhodecode_version_hash)}'; | |
122 | document.head.appendChild(e); |
|
123 | document.head.appendChild(e); | |
123 | </script> |
|
124 | </script> | |
124 | <link rel="import" href="${h.asset('js/rhodecode-components.html', ver=c.rhodecode_version_hash)}"> |
|
125 | <link rel="import" href="${h.asset('js/rhodecode-components.html', ver=c.rhodecode_version_hash)}"> | |
125 | ## avoide escaping the %N |
|
126 | ## avoide escaping the %N | |
126 | <script>CodeMirror.modeURL = "${h.asset('') + 'js/mode/%N/%N.js?ver='+c.rhodecode_version_hash}";</script> |
|
127 | <script>CodeMirror.modeURL = "${h.asset('') + 'js/mode/%N/%N.js?ver='+c.rhodecode_version_hash}";</script> | |
127 |
|
128 | |||
128 |
|
129 | |||
129 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates |
|
130 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates | |
130 | ${self.js_extra()} |
|
131 | ${self.js_extra()} | |
131 |
|
132 | |||
132 | <script type="text/javascript"> |
|
133 | <script type="text/javascript"> | |
133 | $(document).ready(function(){ |
|
134 | $(document).ready(function(){ | |
134 | show_more_event(); |
|
135 | show_more_event(); | |
135 | timeagoActivate(); |
|
136 | timeagoActivate(); | |
136 | }) |
|
137 | }) | |
137 | </script> |
|
138 | </script> | |
138 |
|
139 | |||
139 | </%def> |
|
140 | </%def> | |
140 |
|
141 | |||
141 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates |
|
142 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates | |
142 | <%def name="js_extra()"></%def> |
|
143 | <%def name="js_extra()"></%def> | |
143 | ${self.js()} |
|
144 | ${self.js()} | |
144 |
|
145 | |||
145 | <%def name="head_extra()"></%def> |
|
146 | <%def name="head_extra()"></%def> | |
146 | ${self.head_extra()} |
|
147 | ${self.head_extra()} | |
147 | <%include file="/base/plugins_base.html"/> |
|
148 | <script> | |
148 |
|
149 | $.Topic('/plugins/__REGISTER__').prepareOrPublish({}); | ||
|
150 | </script> | |||
149 | ## extra stuff |
|
151 | ## extra stuff | |
150 | %if c.pre_code: |
|
152 | %if c.pre_code: | |
151 | ${c.pre_code|n} |
|
153 | ${c.pre_code|n} | |
152 | %endif |
|
154 | %endif | |
153 | </head> |
|
155 | </head> | |
154 | <body id="body"> |
|
156 | <body id="body"> | |
155 | <noscript> |
|
157 | <noscript> | |
156 | <div class="noscript-error"> |
|
158 | <div class="noscript-error"> | |
157 | ${_('Please enable JavaScript to use RhodeCode Enterprise')} |
|
159 | ${_('Please enable JavaScript to use RhodeCode Enterprise')} | |
158 | </div> |
|
160 | </div> | |
159 | </noscript> |
|
161 | </noscript> | |
160 | ## IE hacks |
|
162 | ## IE hacks | |
161 | <!--[if IE 7]> |
|
163 | <!--[if IE 7]> | |
162 | <script>$(document.body).addClass('ie7')</script> |
|
164 | <script>$(document.body).addClass('ie7')</script> | |
163 | <![endif]--> |
|
165 | <![endif]--> | |
164 | <!--[if IE 8]> |
|
166 | <!--[if IE 8]> | |
165 | <script>$(document.body).addClass('ie8')</script> |
|
167 | <script>$(document.body).addClass('ie8')</script> | |
166 | <![endif]--> |
|
168 | <![endif]--> | |
167 | <!--[if IE 9]> |
|
169 | <!--[if IE 9]> | |
168 | <script>$(document.body).addClass('ie9')</script> |
|
170 | <script>$(document.body).addClass('ie9')</script> | |
169 | <![endif]--> |
|
171 | <![endif]--> | |
170 |
|
172 | |||
171 | ${next.body()} |
|
173 | ${next.body()} | |
172 | %if c.post_code: |
|
174 | %if c.post_code: | |
173 | ${c.post_code|n} |
|
175 | ${c.post_code|n} | |
174 | %endif |
|
176 | %endif | |
175 | <rhodecode-toast id="notifications"></rhodecode-toast> |
|
177 | <rhodecode-toast id="notifications"></rhodecode-toast> | |
176 | </body> |
|
178 | </body> | |
177 | </html> |
|
179 | </html> |
@@ -1,24 +1,16 b'' | |||||
1 | <script> |
|
1 | <script> | |
2 | var CHANNELSTREAM_URLS = ${config['url_gen'](request)|n}; |
|
2 | var CHANNELSTREAM_URLS = ${config['url_gen'](request)|n}; | |
3 | %if request.registry.rhodecode_plugins['channelstream']['enabled'] and c.rhodecode_user.username != h.DEFAULT_USER: |
|
3 | %if request.registry.rhodecode_plugins['channelstream']['enabled'] and c.rhodecode_user.username != h.DEFAULT_USER: | |
4 | var CHANNELSTREAM_SETTINGS = { |
|
4 | var CHANNELSTREAM_SETTINGS = { | |
5 | 'enabled': true, |
|
5 | 'enabled': true, | |
6 | 'ws_location': '${request.registry.settings.get('channelstream.ws_url')}', |
|
6 | 'ws_location': '${request.registry.settings.get('channelstream.ws_url')}', | |
7 | 'webapp_location': '${h.url('/', qualified=True)[:-1]}' |
|
7 | 'webapp_location': '${h.url('/', qualified=True)[:-1]}' | |
8 | }; |
|
8 | }; | |
9 | %else: |
|
9 | %else: | |
10 | var CHANNELSTREAM_SETTINGS = { |
|
10 | var CHANNELSTREAM_SETTINGS = { | |
11 | 'enabled':false, |
|
11 | 'enabled':false, | |
12 | 'ws_location': '', |
|
12 | 'ws_location': '', | |
13 | 'webapp_location': ''}; |
|
13 | 'webapp_location': ''}; | |
14 | %endif |
|
14 | %endif | |
15 |
|
15 | |||
16 | if (CHANNELSTREAM_SETTINGS.enabled) { |
|
|||
17 | connCtrlr = new ConnectionController( |
|
|||
18 | CHANNELSTREAM_SETTINGS.webapp_location, |
|
|||
19 | CHANNELSTREAM_SETTINGS.ws_location, |
|
|||
20 | CHANNELSTREAM_URLS |
|
|||
21 | ); |
|
|||
22 | registerViewChannels(); |
|
|||
23 | } |
|
|||
24 | </script> |
|
16 | </script> |
General Comments 0
You need to be logged in to leave comments.
Login now