Show More
@@ -1,133 +1,129 b'' | |||
|
1 | 1 | ccLog = Logger.get('RhodeCodeApp'); |
|
2 | 2 | ccLog.setLevel(Logger.OFF); |
|
3 | 3 | |
|
4 | 4 | var rhodeCodeApp = Polymer({ |
|
5 | 5 | is: 'rhodecode-app', |
|
6 | 6 | attached: function () { |
|
7 | 7 | ccLog.debug('rhodeCodeApp created'); |
|
8 | 8 | $.Topic('/notifications').subscribe(this.handleNotifications.bind(this)); |
|
9 | 9 | |
|
10 | 10 | for (var i = 0; i < alertMessagePayloads.length; i++) { |
|
11 | 11 | $.Topic('/notifications').publish(alertMessagePayloads[i]); |
|
12 | 12 | } |
|
13 | ||
|
14 | $.Topic('/plugins/__REGISTER__').subscribe( | |
|
15 | this.kickoffChannelstreamPlugin.bind(this) | |
|
16 | ); | |
|
17 | ||
|
18 | 13 | $.Topic('/connection_controller/subscribe').subscribe( |
|
19 | 14 | this.subscribeToChannelTopic.bind(this)); |
|
15 | this.kickoffChannelstreamPlugin(); | |
|
20 | 16 | }, |
|
21 | 17 | |
|
22 | 18 | /** proxy to channelstream connection */ |
|
23 | 19 | getChannelStreamConnection: function () { |
|
24 | 20 | return this.$['channelstream-connection']; |
|
25 | 21 | }, |
|
26 | 22 | |
|
27 | 23 | handleNotifications: function (data) { |
|
28 | 24 | this.$['notifications'].handleNotification(data); |
|
29 | 25 | }, |
|
30 | 26 | |
|
31 | 27 | /** opens connection to ws server */ |
|
32 | 28 | kickoffChannelstreamPlugin: function (data) { |
|
33 | 29 | ccLog.debug('kickoffChannelstreamPlugin'); |
|
34 | 30 | var channels = ['broadcast']; |
|
35 | 31 | var addChannels = this.checkViewChannels(); |
|
36 | 32 | for (var i = 0; i < addChannels.length; i++) { |
|
37 | 33 | channels.push(addChannels[i]); |
|
38 | 34 | } |
|
39 | 35 | if (window.CHANNELSTREAM_SETTINGS && CHANNELSTREAM_SETTINGS.enabled){ |
|
40 | 36 | var channelstreamConnection = this.$['channelstream-connection']; |
|
41 | 37 | channelstreamConnection.connectUrl = CHANNELSTREAM_URLS.connect; |
|
42 | 38 | channelstreamConnection.subscribeUrl = CHANNELSTREAM_URLS.subscribe; |
|
43 | 39 | channelstreamConnection.websocketUrl = CHANNELSTREAM_URLS.ws + '/ws'; |
|
44 | 40 | channelstreamConnection.longPollUrl = CHANNELSTREAM_URLS.longpoll + '/listen'; |
|
45 | 41 | // some channels might already be registered by topic |
|
46 | 42 | for (var i = 0; i < channels.length; i++) { |
|
47 | 43 | channelstreamConnection.push('channels', channels[i]); |
|
48 | 44 | } |
|
49 | 45 | // append any additional channels registered in other plugins |
|
50 | 46 | $.Topic('/connection_controller/subscribe').processPrepared(); |
|
51 | 47 | channelstreamConnection.connect(); |
|
52 | 48 | } |
|
53 | 49 | }, |
|
54 | 50 | |
|
55 | 51 | checkViewChannels: function () { |
|
56 | 52 | var channels = [] |
|
57 | 53 | // subscribe to PR repo channel for PR's' |
|
58 | 54 | if (templateContext.pull_request_data.pull_request_id) { |
|
59 | 55 | var channelName = '/repo$' + templateContext.repo_name + '$/pr/' + |
|
60 | 56 | String(templateContext.pull_request_data.pull_request_id); |
|
61 | 57 | channels.push(channelName); |
|
62 | 58 | } |
|
63 | 59 | return channels; |
|
64 | 60 | }, |
|
65 | 61 | |
|
66 | 62 | /** subscribes users from channels in channelstream */ |
|
67 | 63 | subscribeToChannelTopic: function (channels) { |
|
68 | 64 | var channelstreamConnection = this.$['channelstream-connection']; |
|
69 | 65 | var toSubscribe = channelstreamConnection.calculateSubscribe(channels); |
|
70 | 66 | ccLog.debug('subscribeToChannelTopic', toSubscribe); |
|
71 | 67 | if (toSubscribe.length > 0) { |
|
72 | 68 | // if we are connected then subscribe |
|
73 | 69 | if (channelstreamConnection.connected) { |
|
74 | 70 | channelstreamConnection.subscribe(toSubscribe); |
|
75 | 71 | } |
|
76 | 72 | // not connected? just push channels onto the stack |
|
77 | 73 | else { |
|
78 | 74 | for (var i = 0; i < toSubscribe.length; i++) { |
|
79 | 75 | channelstreamConnection.push('channels', toSubscribe[i]); |
|
80 | 76 | } |
|
81 | 77 | } |
|
82 | 78 | } |
|
83 | 79 | }, |
|
84 | 80 | |
|
85 | 81 | /** publish received messages into correct topic */ |
|
86 | 82 | receivedMessage: function (event) { |
|
87 | 83 | for (var i = 0; i < event.detail.length; i++) { |
|
88 | 84 | var message = event.detail[i]; |
|
89 | 85 | if (message.message.topic) { |
|
90 | 86 | ccLog.debug('publishing', message.message.topic); |
|
91 | 87 | $.Topic(message.message.topic).publish(message); |
|
92 | 88 | } |
|
93 | 89 | else if (message.type === 'presence'){ |
|
94 | 90 | $.Topic('/connection_controller/presence').publish(message); |
|
95 | 91 | } |
|
96 | 92 | else { |
|
97 | 93 | ccLog.warn('unhandled message', message); |
|
98 | 94 | } |
|
99 | 95 | } |
|
100 | 96 | }, |
|
101 | 97 | |
|
102 | 98 | handleConnected: function (event) { |
|
103 | 99 | var channelstreamConnection = this.$['channelstream-connection']; |
|
104 | 100 | channelstreamConnection.set('channelsState', |
|
105 | 101 | event.detail.channels_info); |
|
106 | 102 | channelstreamConnection.set('userState', event.detail.state); |
|
107 | 103 | channelstreamConnection.set('channels', event.detail.channels); |
|
108 | 104 | this.propagageChannelsState(); |
|
109 | 105 | }, |
|
110 | 106 | handleSubscribed: function (event) { |
|
111 | 107 | var channelstreamConnection = this.$['channelstream-connection']; |
|
112 | 108 | var channelInfo = event.detail.channels_info; |
|
113 | 109 | var channelKeys = Object.keys(event.detail.channels_info); |
|
114 | 110 | for (var i = 0; i < channelKeys.length; i++) { |
|
115 | 111 | var key = channelKeys[i]; |
|
116 | 112 | channelstreamConnection.set(['channelsState', key], channelInfo[key]); |
|
117 | 113 | } |
|
118 | 114 | channelstreamConnection.set('channels', event.detail.channels); |
|
119 | 115 | this.propagageChannelsState(); |
|
120 | 116 | }, |
|
121 | 117 | /** propagates channel states on topics */ |
|
122 | 118 | propagageChannelsState: function (event) { |
|
123 | 119 | var channelstreamConnection = this.$['channelstream-connection']; |
|
124 | 120 | var channel_data = channelstreamConnection.channelsState; |
|
125 | 121 | var channels = channelstreamConnection.channels; |
|
126 | 122 | for (var i = 0; i < channels.length; i++) { |
|
127 | 123 | var key = channels[i]; |
|
128 | 124 | $.Topic('/connection_controller/channel_update').publish( |
|
129 | 125 | {channel: key, state: channel_data[key]} |
|
130 | 126 | ); |
|
131 | 127 | } |
|
132 | 128 | } |
|
133 | 129 | }); |
@@ -1,182 +1,177 b'' | |||
|
1 | 1 | ## -*- coding: utf-8 -*- |
|
2 | 2 | <!DOCTYPE html> |
|
3 | 3 | |
|
4 | 4 | <% |
|
5 | 5 | c.template_context['repo_name'] = getattr(c, 'repo_name', '') |
|
6 | 6 | |
|
7 | 7 | if hasattr(c, 'rhodecode_db_repo'): |
|
8 | 8 | c.template_context['repo_type'] = c.rhodecode_db_repo.repo_type |
|
9 | 9 | c.template_context['repo_landing_commit'] = c.rhodecode_db_repo.landing_rev[1] |
|
10 | 10 | |
|
11 | 11 | if getattr(c, 'rhodecode_user', None) and c.rhodecode_user.user_id: |
|
12 | 12 | c.template_context['rhodecode_user']['username'] = c.rhodecode_user.username |
|
13 | 13 | c.template_context['rhodecode_user']['email'] = c.rhodecode_user.email |
|
14 | 14 | c.template_context['rhodecode_user']['notification_status'] = c.rhodecode_user.get_instance().user_data.get('notification_status', True) |
|
15 | 15 | |
|
16 | 16 | c.template_context['visual']['default_renderer'] = h.get_visual_attr(c, 'default_renderer') |
|
17 | 17 | %> |
|
18 | 18 | <html xmlns="http://www.w3.org/1999/xhtml"> |
|
19 | 19 | <head> |
|
20 | 20 | <title>${self.title()}</title> |
|
21 | 21 | <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> |
|
22 | 22 | <%def name="robots()"> |
|
23 | 23 | <meta name="robots" content="index, nofollow"/> |
|
24 | 24 | </%def> |
|
25 | 25 | ${self.robots()} |
|
26 | 26 | <link rel="icon" href="${h.asset('images/favicon.ico', ver=c.rhodecode_version_hash)}" sizes="16x16 32x32" type="image/png" /> |
|
27 | 27 | |
|
28 | 28 | ## CSS definitions |
|
29 | 29 | <%def name="css()"> |
|
30 | 30 | <link rel="stylesheet" type="text/css" href="${h.asset('css/style.css', ver=c.rhodecode_version_hash)}" media="screen"/> |
|
31 | 31 | <!--[if lt IE 9]> |
|
32 | 32 | <link rel="stylesheet" type="text/css" href="${h.asset('css/ie.css', ver=c.rhodecode_version_hash)}" media="screen"/> |
|
33 | 33 | <![endif]--> |
|
34 | 34 | ## EXTRA FOR CSS |
|
35 | 35 | ${self.css_extra()} |
|
36 | 36 | </%def> |
|
37 | 37 | ## CSS EXTRA - optionally inject some extra CSS stuff needed for specific websites |
|
38 | 38 | <%def name="css_extra()"> |
|
39 | 39 | </%def> |
|
40 | 40 | |
|
41 | 41 | ${self.css()} |
|
42 | 42 | |
|
43 | 43 | ## JAVASCRIPT |
|
44 | 44 | <%def name="js()"> |
|
45 | 45 | <script> |
|
46 | 46 | // setup Polymer options |
|
47 | 47 | window.Polymer = {lazyRegister: true, dom: 'shadow'}; |
|
48 | 48 | |
|
49 | 49 | // Load webcomponentsjs polyfill if browser does not support native Web Components |
|
50 | 50 | (function() { |
|
51 | 51 | 'use strict'; |
|
52 | 52 | var onload = function() { |
|
53 | 53 | // For native Imports, manually fire WebComponentsReady so user code |
|
54 | 54 | // can use the same code path for native and polyfill'd imports. |
|
55 | 55 | if (!window.HTMLImports) { |
|
56 | 56 | document.dispatchEvent( |
|
57 | 57 | new CustomEvent('WebComponentsReady', {bubbles: true}) |
|
58 | 58 | ); |
|
59 | 59 | } |
|
60 | 60 | }; |
|
61 | 61 | var webComponentsSupported = ( |
|
62 | 62 | 'registerElement' in document |
|
63 | 63 | && 'import' in document.createElement('link') |
|
64 | 64 | && 'content' in document.createElement('template') |
|
65 | 65 | ); |
|
66 | 66 | if (!webComponentsSupported) { |
|
67 | 67 | var e = document.createElement('script'); |
|
68 | 68 | e.async = true; |
|
69 | 69 | e.src = '${h.asset('js/vendors/webcomponentsjs/webcomponents-lite.min.js', ver=c.rhodecode_version_hash)}'; |
|
70 | 70 | document.head.appendChild(e); |
|
71 | 71 | } else { |
|
72 | 72 | onload(); |
|
73 | 73 | } |
|
74 | 74 | })(); |
|
75 | 75 | </script> |
|
76 | 76 | |
|
77 | 77 | <script src="${h.asset('js/rhodecode/i18n/%s.js' % c.language, ver=c.rhodecode_version_hash)}"></script> |
|
78 | 78 | <script type="text/javascript"> |
|
79 | 79 | // register templateContext to pass template variables to JS |
|
80 | 80 | var templateContext = ${h.json.dumps(c.template_context)|n}; |
|
81 | 81 | |
|
82 | 82 | var REPO_NAME = "${getattr(c, 'repo_name', '')}"; |
|
83 | 83 | %if hasattr(c, 'rhodecode_db_repo'): |
|
84 | 84 | var REPO_LANDING_REV = '${c.rhodecode_db_repo.landing_rev[1]}'; |
|
85 | 85 | var REPO_TYPE = '${c.rhodecode_db_repo.repo_type}'; |
|
86 | 86 | %else: |
|
87 | 87 | var REPO_LANDING_REV = ''; |
|
88 | 88 | var REPO_TYPE = ''; |
|
89 | 89 | %endif |
|
90 | 90 | var APPLICATION_URL = "${h.url('home').rstrip('/')}"; |
|
91 | 91 | var ASSET_URL = "${h.asset('')}"; |
|
92 | 92 | var DEFAULT_RENDERER = "${h.get_visual_attr(c, 'default_renderer')}"; |
|
93 | 93 | var CSRF_TOKEN = "${getattr(c, 'csrf_token', '')}"; |
|
94 | 94 | % if getattr(c, 'rhodecode_user', None): |
|
95 | 95 | var USER = {name:'${c.rhodecode_user.username}'}; |
|
96 | 96 | % else: |
|
97 | 97 | var USER = {name:null}; |
|
98 | 98 | % endif |
|
99 | 99 | |
|
100 | 100 | var APPENLIGHT = { |
|
101 | 101 | enabled: ${'true' if getattr(c, 'appenlight_enabled', False) else 'false'}, |
|
102 | 102 | key: '${getattr(c, "appenlight_api_public_key", "")}', |
|
103 | 103 | % if getattr(c, 'appenlight_server_url', None): |
|
104 | 104 | serverUrl: '${getattr(c, "appenlight_server_url", "")}', |
|
105 | 105 | % endif |
|
106 | 106 | requestInfo: { |
|
107 | 107 | % if getattr(c, 'rhodecode_user', None): |
|
108 | 108 | ip: '${c.rhodecode_user.ip_addr}', |
|
109 | 109 | username: '${c.rhodecode_user.username}' |
|
110 | 110 | % endif |
|
111 | 111 | } |
|
112 | 112 | }; |
|
113 | 113 | </script> |
|
114 | 114 | <%include file="/base/plugins_base.html"/> |
|
115 | 115 | <!--[if lt IE 9]> |
|
116 | 116 | <script language="javascript" type="text/javascript" src="${h.asset('js/excanvas.min.js')}"></script> |
|
117 | 117 | <![endif]--> |
|
118 | 118 | <script language="javascript" type="text/javascript" src="${h.asset('js/rhodecode/routes.js', ver=c.rhodecode_version_hash)}"></script> |
|
119 | 119 | <script> var alertMessagePayloads = ${h.flash.json_alerts()|n}; </script> |
|
120 | 120 | <script language="javascript" type="text/javascript" src="${h.asset('js/scripts.js', ver=c.rhodecode_version_hash)}"></script> |
|
121 | 121 | <script> |
|
122 | 122 | var e = document.createElement('script'); |
|
123 | 123 | e.src = '${h.asset('js/rhodecode-components.js', ver=c.rhodecode_version_hash)}'; |
|
124 | 124 | document.head.appendChild(e); |
|
125 | 125 | </script> |
|
126 | 126 | <link rel="import" href="${h.asset('js/rhodecode-components.html', ver=c.rhodecode_version_hash)}"> |
|
127 | 127 | ## avoide escaping the %N |
|
128 | 128 | <script>CodeMirror.modeURL = "${h.asset('') + 'js/mode/%N/%N.js?ver='+c.rhodecode_version_hash}";</script> |
|
129 | 129 | |
|
130 | 130 | |
|
131 | 131 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates |
|
132 | 132 | ${self.js_extra()} |
|
133 | 133 | |
|
134 | 134 | <script type="text/javascript"> |
|
135 | 135 | $(document).ready(function(){ |
|
136 | 136 | show_more_event(); |
|
137 | 137 | timeagoActivate(); |
|
138 | 138 | }) |
|
139 | 139 | </script> |
|
140 | 140 | |
|
141 | 141 | </%def> |
|
142 | 142 | |
|
143 | 143 | ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates |
|
144 | 144 | <%def name="js_extra()"></%def> |
|
145 | 145 | ${self.js()} |
|
146 | 146 | |
|
147 | 147 | <%def name="head_extra()"></%def> |
|
148 | 148 | ${self.head_extra()} |
|
149 | <script> | |
|
150 | window.addEventListener("load", function(event) { | |
|
151 | $.Topic('/plugins/__REGISTER__').prepareOrPublish({}); | |
|
152 | }); | |
|
153 | </script> | |
|
154 | 149 | ## extra stuff |
|
155 | 150 | %if c.pre_code: |
|
156 | 151 | ${c.pre_code|n} |
|
157 | 152 | %endif |
|
158 | 153 | </head> |
|
159 | 154 | <body id="body"> |
|
160 | 155 | <noscript> |
|
161 | 156 | <div class="noscript-error"> |
|
162 | 157 | ${_('Please enable JavaScript to use RhodeCode Enterprise')} |
|
163 | 158 | </div> |
|
164 | 159 | </noscript> |
|
165 | 160 | ## IE hacks |
|
166 | 161 | <!--[if IE 7]> |
|
167 | 162 | <script>$(document.body).addClass('ie7')</script> |
|
168 | 163 | <![endif]--> |
|
169 | 164 | <!--[if IE 8]> |
|
170 | 165 | <script>$(document.body).addClass('ie8')</script> |
|
171 | 166 | <![endif]--> |
|
172 | 167 | <!--[if IE 9]> |
|
173 | 168 | <script>$(document.body).addClass('ie9')</script> |
|
174 | 169 | <![endif]--> |
|
175 | 170 | |
|
176 | 171 | ${next.body()} |
|
177 | 172 | %if c.post_code: |
|
178 | 173 | ${c.post_code|n} |
|
179 | 174 | %endif |
|
180 | 175 | <rhodecode-app></rhodecode-app> |
|
181 | 176 | </body> |
|
182 | 177 | </html> |
General Comments 0
You need to be logged in to leave comments.
Login now