##// END OF EJS Templates
polymer: slim out the styles and change the flow of initialization to avoid race conditions
ergo -
r714:822499e8 default
parent child Browse files
Show More
@@ -1,63 +1,64 b''
1 1 syntax: glob
2 2 *.egg
3 3 *.egg-info
4 4 *.idea
5 5 *.orig
6 6 *.pyc
7 7 *.sqlite-journal
8 8 *.swp
9 9 *.tox
10 10 *.DS_Store*
11 11 rhodecode/public/js/src/components/**/*.css
12 12
13 13 syntax: regexp
14 14
15 15 #.filename
16 16 ^\.settings$
17 17 ^\.project$
18 18 ^\.pydevproject$
19 19 ^\.coverage$
20 20 ^\.cache.*$
21 21 ^\.rhodecode$
22 22
23 23 ^rcextensions
24 24 ^_dev
25 25 ^._dev
26 26 ^build/
27 27 ^bower_components/
28 28 ^coverage\.xml$
29 29 ^data$
30 30 ^\.eggs/
31 31 ^configs/data$
32 32 ^dev.ini$
33 33 ^acceptance_tests/dev.*\.ini$
34 34 ^dist/
35 35 ^fabfile.py
36 36 ^htmlcov
37 37 ^junit\.xml$
38 38 ^node_modules/
39 39 ^pylint.log$
40 40 ^rcextensions/
41 41 ^result$
42 42 ^rhodecode/public/css/style.css$
43 43 ^rhodecode/public/css/style-polymer.css$
44 44 ^rhodecode/public/js/scripts.js$
45 45 ^rhodecode/public/js/rhodecode-components.html$
46 ^rhodecode/public/js/src/components/root-styles.gen.html$
46 47 ^rhodecode\.db$
47 48 ^rhodecode\.log$
48 49 ^rhodecode_dev\.log$
49 50 ^test\.db$
50 51
51 52 # ac-tests
52 53 ^acceptance_tests/\.cache.*$
53 54 ^acceptance_tests/externals
54 55 ^acceptance_tests/ghostdriver.log$
55 56 ^acceptance_tests/local(_.+)?\.ini$
56 57
57 58 # docs
58 59 ^docs/_build$
59 60 ^docs/result$
60 61 ^docs-internal/_build$
61 62
62 63 # Cythonized things
63 64 ^rhodecode/.*\.(c|so)$
@@ -1,177 +1,187 b''
1 1 module.exports = function(grunt) {
2 2 grunt.initConfig({
3 3
4 4 dirs: {
5 5 css: "rhodecode/public/css",
6 6 js: {
7 7 "src": "rhodecode/public/js/src",
8 8 "dest": "rhodecode/public/js"
9 9 }
10 10 },
11 11 copy: {
12 12 main: {
13 13 expand: true,
14 14 cwd: 'bower_components',
15 15 src: 'webcomponentsjs/**',
16 16 dest: '<%= dirs.js.dest %>/vendors',
17 17 },
18 18 },
19 19 concat: {
20 polymercss:{
21 src: [
22 // Base libraries
23 '<%= dirs.js.src %>/components/root-styles-prefix.html',
24 '<%= dirs.css %>/style-polymer.css',
25 '<%= dirs.js.src %>/components/root-styles-suffix.html'
26 ],
27 dest: '<%= dirs.js.dest %>/src/components/root-styles.gen.html',
28 nonull: true
29 },
20 30 dist: {
21 31 src: [
22 32 // Base libraries
23 33 '<%= dirs.js.src %>/jquery-1.11.1.min.js',
24 34 '<%= dirs.js.src %>/logging.js',
25 35 '<%= dirs.js.src %>/bootstrap.js',
26 36 '<%= dirs.js.src %>/mousetrap.js',
27 37 '<%= dirs.js.src %>/moment.js',
28 38 '<%= dirs.js.src %>/appenlight-client-0.4.1.min.js',
29 39 '<%= dirs.js.src %>/i18n_utils.js',
30 40 '<%= dirs.js.src %>/deform.js',
31 41
32 42 // Plugins
33 43 '<%= dirs.js.src %>/plugins/jquery.pjax.js',
34 44 '<%= dirs.js.src %>/plugins/jquery.dataTables.js',
35 45 '<%= dirs.js.src %>/plugins/flavoured_checkbox.js',
36 46 '<%= dirs.js.src %>/plugins/jquery.auto-grow-input.js',
37 47 '<%= dirs.js.src %>/plugins/jquery.autocomplete.js',
38 48 '<%= dirs.js.src %>/plugins/jquery.debounce.js',
39 49 '<%= dirs.js.src %>/plugins/jquery.mark.js',
40 50 '<%= dirs.js.src %>/plugins/jquery.timeago.js',
41 51 '<%= dirs.js.src %>/plugins/jquery.timeago-extension.js',
42 52
43 53 // Select2
44 54 '<%= dirs.js.src %>/select2/select2.js',
45 55
46 56 // Code-mirror
47 57 '<%= dirs.js.src %>/codemirror/codemirror.js',
48 58 '<%= dirs.js.src %>/codemirror/codemirror_loadmode.js',
49 59 '<%= dirs.js.src %>/codemirror/codemirror_hint.js',
50 60 '<%= dirs.js.src %>/codemirror/codemirror_overlay.js',
51 61 '<%= dirs.js.src %>/codemirror/codemirror_placeholder.js',
52 62 // TODO: mikhail: this is an exception. Since the code mirror modes
53 63 // are loaded "on the fly", we need to keep them in a public folder
54 64 '<%= dirs.js.dest %>/mode/meta.js',
55 65 '<%= dirs.js.dest %>/mode/meta_ext.js',
56 66 '<%= dirs.js.dest %>/rhodecode/i18n/select2/translations.js',
57 67
58 68 // Rhodecode utilities
59 69 '<%= dirs.js.src %>/rhodecode/utils/array.js',
60 70 '<%= dirs.js.src %>/rhodecode/utils/string.js',
61 71 '<%= dirs.js.src %>/rhodecode/utils/pyroutes.js',
62 72 '<%= dirs.js.src %>/rhodecode/utils/ajax.js',
63 73 '<%= dirs.js.src %>/rhodecode/utils/autocomplete.js',
64 74 '<%= dirs.js.src %>/rhodecode/utils/colorgenerator.js',
65 75 '<%= dirs.js.src %>/rhodecode/utils/ie.js',
66 76 '<%= dirs.js.src %>/rhodecode/utils/os.js',
67 77 '<%= dirs.js.src %>/rhodecode/utils/topics.js',
68 78
69 79 // Rhodecode widgets
70 80 '<%= dirs.js.src %>/rhodecode/widgets/multiselect.js',
71 81
72 82 // Rhodecode components
73 83 '<%= dirs.js.src %>/rhodecode/init.js',
74 84 '<%= dirs.js.src %>/rhodecode/connection_controller.js',
75 85 '<%= dirs.js.src %>/rhodecode/codemirror.js',
76 86 '<%= dirs.js.src %>/rhodecode/comments.js',
77 87 '<%= dirs.js.src %>/rhodecode/constants.js',
78 88 '<%= dirs.js.src %>/rhodecode/files.js',
79 89 '<%= dirs.js.src %>/rhodecode/followers.js',
80 90 '<%= dirs.js.src %>/rhodecode/menus.js',
81 91 '<%= dirs.js.src %>/rhodecode/notifications.js',
82 92 '<%= dirs.js.src %>/rhodecode/permissions.js',
83 93 '<%= dirs.js.src %>/rhodecode/pjax.js',
84 94 '<%= dirs.js.src %>/rhodecode/pullrequests.js',
85 95 '<%= dirs.js.src %>/rhodecode/settings.js',
86 96 '<%= dirs.js.src %>/rhodecode/select2_widgets.js',
87 97 '<%= dirs.js.src %>/rhodecode/tooltips.js',
88 98 '<%= dirs.js.src %>/rhodecode/users.js',
89 99 '<%= dirs.js.src %>/rhodecode/utils/notifications.js',
90 100 '<%= dirs.js.src %>/rhodecode/appenlight.js',
91 101
92 102 // Rhodecode main module
93 103 '<%= dirs.js.src %>/rhodecode.js'
94 104 ],
95 105 dest: '<%= dirs.js.dest %>/scripts.js',
96 106 nonull: true
97 107 }
98 108 },
99 109
100 110 less: {
101 111 development: {
102 112 options: {
103 113 compress: false,
104 114 yuicompress: false,
105 115 optimization: 0
106 116 },
107 117 files: {
108 118 "<%= dirs.css %>/style.css": "<%= dirs.css %>/main.less",
109 119 "<%= dirs.css %>/style-polymer.css": "<%= dirs.css %>/polymer.less"
110 120 }
111 121 },
112 122 production: {
113 123 options: {
114 124 compress: true,
115 125 yuicompress: true,
116 126 optimization: 2
117 127 },
118 128 files: {
119 129 "<%= dirs.css %>/style.css": "<%= dirs.css %>/main.less",
120 130 "<%= dirs.css %>/style-polymer.css": "<%= dirs.css %>/polymer.less"
121 131 }
122 132 },
123 133 components: {
124 134 files: [{
125 135 cwd: '<%= dirs.js.src %>/components/',
126 136 dest: '<%= dirs.js.src %>/components/',
127 137 src: ['**/*.less'],
128 138 expand: true,
129 139 ext: '.css'
130 140 }]
131 141 }
132 142 },
133 143
134 144 watch: {
135 145 less: {
136 files: ["<%= dirs.css %>/*.less"],
137 tasks: ["less:development", 'less:components', "vulcanize"]
146 files: ["<%= dirs.css %>/**/*.less"],
147 tasks: ["less:development", 'less:components', 'concat:polymercss', "vulcanize"]
138 148 },
139 149 js: {
140 files: ["<%= dirs.js.src %>/**/*.js", "<%= dirs.js.src %>/components/*.*"],
141 tasks: ["vulcanize", "concat:dist"]
150 files: ["<%= dirs.js.src %>/**/*.js", "<%= dirs.js.src %>/components/**/*.html"],
151 tasks: ['less:components', 'concat:polymercss', "vulcanize", "concat:dist"]
142 152 }
143 153 },
144 154
145 155 jshint: {
146 156 rhodecode: {
147 157 src: '<%= dirs.js.src %>/rhodecode/**/*.js',
148 158 options: {
149 159 jshintrc: '.jshintrc'
150 160 }
151 161 }
152 162 },
153 163 vulcanize: {
154 164 default: {
155 165 options: {
156 166 abspath: '',
157 167 inlineScripts: true,
158 168 inlineCss: true,
159 169 stripComments: true
160 170 },
161 171 files: {
162 172 '<%= dirs.js.dest %>/rhodecode-components.html': '<%= dirs.js.src %>/components/shared-components.html'
163 173 }
164 174 }
165 175 }
166 176 });
167 177
168 178 grunt.loadNpmTasks('grunt-contrib-less');
169 179 grunt.loadNpmTasks('grunt-contrib-concat');
170 180 grunt.loadNpmTasks('grunt-contrib-watch');
171 181 grunt.loadNpmTasks('grunt-contrib-jshint');
172 182 grunt.loadNpmTasks('grunt-vulcanize');
173 183 grunt.loadNpmTasks('grunt-crisper');
174 184 grunt.loadNpmTasks('grunt-contrib-copy');
175 185
176 grunt.registerTask('default', ['less:production', 'less:components', 'copy','vulcanize', 'concat:dist']);
186 grunt.registerTask('default', ['less:production', 'less:components', 'concat:polymercss', 'copy','vulcanize', 'concat:dist']);
177 187 };
@@ -1,26 +1,23 b''
1 1 //Primary CSS
2 2 //--- IMPORTS ------------------//
3 3 @import 'helpers';
4 4 @import 'mixins';
5 @import 'rcicons';
6 @import 'fonts';
7 5 @import 'variables';
8 @import 'type';
9 6 @import 'buttons';
10 7
11 8 :root {
12 9 --primary-color: @rcblue;
13 10 --light-primary-color: @rclightblue;
14 11 --dark-primary-color: @rcdarkblue;
15 12 --primary-text-color: @text-color;
16 13
17 14 --paper-spinner-layer-1-color: @grey6;
18 15 --paper-spinner-layer-2-color: @grey5;
19 16 --paper-spinner-layer-3-color: @grey4;
20 17 --paper-spinner-layer-4-color: @grey3;
21 18 }
22 19
23 20 .paper-toggle-button {
24 21 display: inline;
25 22 }
26 23
@@ -1,3 +1,3 b''
1 <dom-module id="shared-styles">
1 <dom-module id="root-styles">
2 2 <template>
3 3 <style>
1 NO CONTENT: file renamed from rhodecode/public/js/src/components/shared-styles-suffix.html to rhodecode/public/js/src/components/root-styles-suffix.html
@@ -1,94 +1,93 b''
1 1 <template is="dom-bind" id="notificationsPage">
2 <style include="shared-styles" is="custom-style"></style>
3 2 <iron-ajax id="toggleNotifications"
4 3 method="post"
5 4 url="${url('my_account_notifications_toggle_visibility')}"
6 5 content-type="application/json"
7 6 loading="{{changeNotificationsLoading}}"
8 7 on-response="handleNotifications"
9 8 handle-as="json"></iron-ajax>
10 9
11 10 <div class="panel panel-default">
12 11 <div class="panel-heading">
13 12 <h3 class="panel-title">${_('Your Live Notification Settings')}</h3>
14 13 </div>
15 14 <div class="panel-body">
16 15
17 16 <p><strong>IMPORTANT:</strong> This feature requires enabled channelstream websocket server to function correctly.</p>
18 17
19 18 <p class="hidden">Status of browser notifications permission: <strong id="browser-notification-status"></strong></p>
20 19
21 20 <div class="form">
22 21 <!-- fields -->
23 22 <div class="fields">
24 23 <div class="field">
25 24 <div class="label">
26 25 <label for="new_email">${_('Notifications Status')}:</label>
27 26 </div>
28 27 <div class="checkboxes">
29 28 <paper-toggle-button class="paper-toggle-button" on-change="toggleNotifications" ${'checked' if c.rhodecode_user.get_instance().user_data.get('notification_status') else ''}></paper-toggle-button>
30 29 <paper-tooltip>Toggle your notifications on/off globally.</paper-tooltip>
31 30 <template is="dom-if" if="{{changeNotificationsLoading}}">
32 31 <paper-spinner active class="toggle-ajax-spinner"></paper-spinner>
33 32 </template>
34 33 </div>
35 34 </div>
36 35 <div class="buttons">
37 36 <a class="btn btn-default" id="test-notification">Test notification</a>
38 37 </div>
39 38 </div>
40 39 </div>
41 40
42 41 </div>
43 42 </div>
44 43
45 44 <script type="application/javascript">
46 45 /** because im not creating a custom element for this page
47 46 * we need to push the function onto the dom-template
48 47 * ideally we turn this into notification-settings elements
49 48 * then it will be cleaner
50 49 */
51 50 var ctrlr = $('#notificationsPage')[0];
52 51 ctrlr.toggleNotifications = function(event){
53 52 var ajax = $('#toggleNotifications')[0];
54 53 ajax.headers = {"X-CSRF-Token": CSRF_TOKEN}
55 54 ajax.body = {notification_status:event.target.active};
56 55 ajax.generateRequest();
57 56 };
58 57 ctrlr.handleNotifications = function(event){
59 58 $('paper-toggle-button')[0].active = event.detail.response;
60 59 };
61 60
62 61 function checkBrowserStatus(){
63 62 var browserStatus = 'Unknown';
64 63
65 64 if (!("Notification" in window)) {
66 65 browserStatus = 'Not supported'
67 66 }
68 67 else if(Notification.permission === 'denied'){
69 68 browserStatus = 'Denied';
70 69 $('.flash_msg').append('<div class="alert alert-error">Notifications are blocked on browser level - you need to enable them in your browser settings.</div>')
71 70 }
72 71 else if(Notification.permission === 'granted'){
73 72 browserStatus = 'Allowed';
74 73 }
75 74
76 75 $('#browser-notification-status').text(browserStatus);
77 76 };
78 77
79 78 checkBrowserStatus();
80 79
81 80 $('#test-notification').on('click', function(e){
82 81 var levels = ['info', 'error', 'warning', 'success'];
83 82 var level = levels[Math.floor(Math.random()*levels.length)];
84 83 var payload = {
85 84 message: {
86 85 message: 'This is a test notification.',
87 86 level: level,
88 87 testMessage: true
89 88 }
90 89 };
91 90 $.Topic('/notifications').publish(payload);
92 91 })
93 92 </script>
94 93 </template>
@@ -1,159 +1,160 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 webcomponents polyfills
50 50 (function() {
51 51 if ('registerElement' in document
52 52 && 'import' in document.createElement('link')
53 53 && 'content' in document.createElement('template')) {
54 54 // browser has web components
55 55 } else {
56 56 // polyfill web components
57 57 var e = document.createElement('script');
58 58 e.src = '${h.asset('js/vendors/webcomponentsjs/webcomponents-lite.min.js', ver=c.rhodecode_version_hash)}';
59 59 document.head.appendChild(e);
60 60 }
61 61 })();
62 62 </script>
63 <link rel="import" href="${h.asset('js/rhodecode-components.html', ver=c.rhodecode_version_hash)}" async>
64 63
65 64 <script src="${h.asset('js/rhodecode/i18n/%s.js' % c.language, ver=c.rhodecode_version_hash)}"></script>
66 65 <script type="text/javascript">
67 66 // register templateContext to pass template variables to JS
68 67 var templateContext = ${h.json.dumps(c.template_context)|n};
69 68
70 69 var REPO_NAME = "${getattr(c, 'repo_name', '')}";
71 70 %if hasattr(c, 'rhodecode_db_repo'):
72 71 var REPO_LANDING_REV = '${c.rhodecode_db_repo.landing_rev[1]}';
73 72 var REPO_TYPE = '${c.rhodecode_db_repo.repo_type}';
74 73 %else:
75 74 var REPO_LANDING_REV = '';
76 75 var REPO_TYPE = '';
77 76 %endif
78 77 var APPLICATION_URL = "${h.url('home').rstrip('/')}";
79 78 var ASSET_URL = "${h.asset('')}";
80 79 var DEFAULT_RENDERER = "${h.get_visual_attr(c, 'default_renderer')}";
81 80 var CSRF_TOKEN = "${getattr(c, 'csrf_token', '')}";
82 81 % if getattr(c, 'rhodecode_user', None):
83 82 var USER = {name:'${c.rhodecode_user.username}'};
84 83 % else:
85 84 var USER = {name:null};
86 85 % endif
87 86
88 87 var APPENLIGHT = {
89 88 enabled: ${'true' if getattr(c, 'appenlight_enabled', False) else 'false'},
90 89 key: '${getattr(c, "appenlight_api_public_key", "")}',
91 90 % if getattr(c, 'appenlight_server_url', None):
92 91 serverUrl: '${getattr(c, "appenlight_server_url", "")}',
93 92 % endif
94 93 requestInfo: {
95 94 % if getattr(c, 'rhodecode_user', None):
96 95 ip: '${c.rhodecode_user.ip_addr}',
97 96 username: '${c.rhodecode_user.username}'
98 97 % endif
99 98 }
100 99 };
101 100 </script>
102 101 <!--[if lt IE 9]>
103 102 <script language="javascript" type="text/javascript" src="${h.asset('js/excanvas.min.js')}"></script>
104 103 <![endif]-->
105 104 <script language="javascript" type="text/javascript" src="${h.asset('js/rhodecode/routes.js', ver=c.rhodecode_version_hash)}"></script>
106 105 <script language="javascript" type="text/javascript" src="${h.asset('js/scripts.js', ver=c.rhodecode_version_hash)}"></script>
106 <link rel="import" href="${h.asset('js/rhodecode-components.html', ver=c.rhodecode_version_hash)}">
107 <style include="shared-styles" is="custom-style"></style>
107 108 ## avoide escaping the %N
108 109 <script>CodeMirror.modeURL = "${h.asset('') + 'js/mode/%N/%N.js?ver='+c.rhodecode_version_hash}";</script>
109 110
110 111
111 112 ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates
112 113 ${self.js_extra()}
113 114
114 115 <script type="text/javascript">
115 116 $(document).ready(function(){
116 117 show_more_event();
117 118 timeagoActivate();
118 119 })
119 120 </script>
120 121
121 122 </%def>
122 123
123 124 ## JAVASCRIPT EXTRA - optionally inject some extra JS for specificed templates
124 125 <%def name="js_extra()"></%def>
125 126 ${self.js()}
126 127
127 128 <%def name="head_extra()"></%def>
128 129 ${self.head_extra()}
129 130 <%include file="/base/plugins_base.html"/>
130 131
131 132 ## extra stuff
132 133 %if c.pre_code:
133 134 ${c.pre_code|n}
134 135 %endif
135 136 </head>
136 137 <body id="body">
137 138 <noscript>
138 139 <div class="noscript-error">
139 140 ${_('Please enable JavaScript to use RhodeCode Enterprise')}
140 141 </div>
141 142 </noscript>
142 143 ## IE hacks
143 144 <!--[if IE 7]>
144 145 <script>$(document.body).addClass('ie7')</script>
145 146 <![endif]-->
146 147 <!--[if IE 8]>
147 148 <script>$(document.body).addClass('ie8')</script>
148 149 <![endif]-->
149 150 <!--[if IE 9]>
150 151 <script>$(document.body).addClass('ie9')</script>
151 152 <![endif]-->
152 153
153 154 ${next.body()}
154 155 %if c.post_code:
155 156 ${c.post_code|n}
156 157 %endif
157 158 <rhodecode-toast id="notifications"></rhodecode-toast>
158 159 </body>
159 160 </html>
General Comments 0
You need to be logged in to leave comments. Login now