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