##// END OF EJS Templates
js: fixed usage of minimized JS
marcink -
r4023:2f0df463 default
parent child Browse files
Show More
@@ -1,296 +1,296 b''
1 1 # Nix environment for the community edition
2 2 #
3 3 # This shall be as lean as possible, just producing the enterprise-ce
4 4 # derivation. For advanced tweaks to pimp up the development environment we use
5 5 # "shell.nix" so that it does not have to clutter this file.
6 6 #
7 7 # Configuration, set values in "~/.nixpkgs/config.nix".
8 8 # example
9 9 # {
10 10 # # Thoughts on how to configure the dev environment
11 11 # rc = {
12 12 # codeInternalUrl = "https://usr:token@code.rhodecode.com/internal";
13 13 # sources = {
14 14 # rhodecode-vcsserver = "/home/user/work/rhodecode-vcsserver";
15 15 # rhodecode-enterprise-ce = "/home/user/work/rhodecode-enterprise-ce";
16 16 # rhodecode-enterprise-ee = "/home/user/work/rhodecode-enterprise-ee";
17 17 # };
18 18 # };
19 19 # }
20 20
21 21 args@
22 22 { system ? builtins.currentSystem
23 23 , pythonPackages ? "python27Packages"
24 24 , pythonExternalOverrides ? self: super: {}
25 25 , doCheck ? false
26 26 , ...
27 27 }:
28 28
29 29 let
30 30 pkgs_ = args.pkgs or (import <nixpkgs> { inherit system; });
31 31 in
32 32
33 33 let
34 34 pkgs = import <nixpkgs> {
35 35 overlays = [
36 36 (import ./pkgs/overlays.nix)
37 37 ];
38 38 inherit
39 39 (pkgs_)
40 40 system;
41 41 };
42 42
43 43 # Works with the new python-packages, still can fallback to the old
44 44 # variant.
45 45 basePythonPackagesUnfix = basePythonPackages.__unfix__ or (
46 46 self: basePythonPackages.override (a: { inherit self; }));
47 47
48 48 # Evaluates to the last segment of a file system path.
49 49 basename = path: with pkgs.lib; last (splitString "/" path);
50 50
51 51 # source code filter used as arugment to builtins.filterSource.
52 52 src-filter = path: type: with pkgs.lib;
53 53 let
54 54 ext = last (splitString "." path);
55 55 in
56 56 !builtins.elem (basename path) [
57 57 ".git" ".hg" "__pycache__" ".eggs" ".idea" ".dev"
58 58 "node_modules" "node_binaries"
59 59 "build" "data" "result" "tmp"] &&
60 60 !builtins.elem ext ["egg-info" "pyc"] &&
61 61 # TODO: johbo: This check is wrong, since "path" contains an absolute path,
62 62 # it would still be good to restore it since we want to ignore "result-*".
63 63 !hasPrefix "result" path;
64 64
65 65 sources =
66 66 let
67 67 inherit
68 68 (pkgs.lib)
69 69 all
70 70 isString
71 71 attrValues;
72 72 sourcesConfig = pkgs.config.rc.sources or {};
73 73 in
74 74 # Ensure that sources are configured as strings. Using a path
75 75 # would result in a copy into the nix store.
76 76 assert all isString (attrValues sourcesConfig);
77 77 sourcesConfig;
78 78
79 79 version = builtins.readFile "${rhodecode-enterprise-ce-src}/rhodecode/VERSION";
80 80 rhodecode-enterprise-ce-src = builtins.filterSource src-filter ./.;
81 81
82 82 nodeEnv = import ./pkgs/node-default.nix {
83 83 inherit
84 84 pkgs
85 85 system;
86 86 };
87 87 nodeDependencies = nodeEnv.shell.nodeDependencies;
88 88
89 89 rhodecode-testdata-src = sources.rhodecode-testdata or (
90 90 pkgs.fetchhg {
91 91 url = "https://code.rhodecode.com/upstream/rc_testdata";
92 92 rev = "v0.10.0";
93 93 sha256 = "0zn9swwvx4vgw4qn8q3ri26vvzgrxn15x6xnjrysi1bwmz01qjl0";
94 94 });
95 95
96 96 rhodecode-testdata = import "${rhodecode-testdata-src}/default.nix" {
97 97 inherit
98 98 doCheck
99 99 pkgs
100 100 pythonPackages;
101 101 };
102 102
103 103 pythonLocalOverrides = self: super: {
104 104 rhodecode-enterprise-ce =
105 105 let
106 106 linkNodePackages = ''
107 107 export RHODECODE_CE_PATH=${rhodecode-enterprise-ce-src}
108 108
109 109 echo "[BEGIN]: Link node packages and binaries"
110 110 # johbo: Linking individual packages allows us to run "npm install"
111 111 # inside of a shell to try things out. Re-entering the shell will
112 112 # restore a clean environment.
113 113 rm -fr node_modules
114 114 mkdir node_modules
115 115 ln -s ${nodeDependencies}/lib/node_modules/* node_modules/
116 116 export NODE_PATH=./node_modules
117 117
118 118 rm -fr node_binaries
119 119 mkdir node_binaries
120 120 ln -s ${nodeDependencies}/bin/* node_binaries/
121 121 echo "[DONE ]: Link node packages and binaries"
122 122 '';
123 123
124 124 releaseName = "RhodeCodeEnterpriseCE-${version}";
125 125 in super.rhodecode-enterprise-ce.override (attrs: {
126 126 inherit
127 127 doCheck
128 128 version;
129 129
130 130 name = "rhodecode-enterprise-ce-${version}";
131 131 releaseName = releaseName;
132 132 src = rhodecode-enterprise-ce-src;
133 133 dontStrip = true; # prevent strip, we don't need it.
134 134
135 135 # expose following attributed outside
136 136 passthru = {
137 137 inherit
138 138 rhodecode-testdata
139 139 linkNodePackages
140 140 myPythonPackagesUnfix
141 141 pythonLocalOverrides
142 142 pythonCommunityOverrides;
143 143
144 144 pythonPackages = self;
145 145 };
146 146
147 147 buildInputs =
148 148 attrs.buildInputs or [] ++ [
149 149 rhodecode-testdata
150 150 ];
151 151
152 152 #NOTE: option to inject additional propagatedBuildInputs
153 153 propagatedBuildInputs =
154 154 attrs.propagatedBuildInputs or [] ++ [
155 155
156 156 ];
157 157
158 158 LC_ALL = "en_US.UTF-8";
159 159 LOCALE_ARCHIVE =
160 160 if pkgs.stdenv.isLinux
161 161 then "${pkgs.glibcLocales}/lib/locale/locale-archive"
162 162 else "";
163 163
164 164 # Add bin directory to path so that tests can find 'rhodecode'.
165 165 preCheck = ''
166 166 export PATH="$out/bin:$PATH"
167 167 '';
168 168
169 169 # custom check phase for testing
170 170 checkPhase = ''
171 171 runHook preCheck
172 172 PYTHONHASHSEED=random py.test -vv -p no:sugar -r xw --cov-config=.coveragerc --cov=rhodecode --cov-report=term-missing rhodecode
173 173 runHook postCheck
174 174 '';
175 175
176 176 postCheck = ''
177 177 echo "Cleanup of rhodecode/tests"
178 178 rm -rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/tests
179 179 '';
180 180
181 181 preBuild = ''
182 182 echo "[BEGIN]: Building frontend assets"
183 183 ${linkNodePackages}
184 184 make web-build
185 185 rm -fr node_modules
186 186 rm -fr node_binaries
187 187 echo "[DONE ]: Building frontend assets"
188 188 '';
189 189
190 190 postInstall = ''
191 191 # check required files
192 192 STATIC_CHECK="/robots.txt /502.html
193 /js/scripts.js /js/rhodecode-components.js
193 /js/scripts.min.js /js/rhodecode-components.js
194 194 /css/style.css /css/style-polymer.css /css/style-ipython.css"
195 195
196 196 for file in $STATIC_CHECK;
197 197 do
198 198 if [ ! -f rhodecode/public/$file ]; then
199 199 echo "Missing $file"
200 200 exit 1
201 201 fi
202 202 done
203 203
204 204 echo "Writing enterprise-ce meta information for rccontrol to nix-support/rccontrol"
205 205 mkdir -p $out/nix-support/rccontrol
206 206 cp -v rhodecode/VERSION $out/nix-support/rccontrol/version
207 207 echo "[DONE ]: enterprise-ce meta information for rccontrol written"
208 208
209 209 mkdir -p $out/etc
210 210 cp configs/production.ini $out/etc
211 211 echo "[DONE ]: saved enterprise-ce production.ini into $out/etc"
212 212
213 213 cp -Rf rhodecode/config/rcextensions $out/etc/rcextensions.tmpl
214 214 echo "[DONE ]: saved enterprise-ce rcextensions into $out/etc/rcextensions.tmpl"
215 215
216 216 # python based programs need to be wrapped
217 217 mkdir -p $out/bin
218 218
219 219 # required binaries from dependencies
220 220 ln -s ${self.supervisor}/bin/supervisorctl $out/bin/
221 221 ln -s ${self.supervisor}/bin/supervisord $out/bin/
222 222 ln -s ${self.pastescript}/bin/paster $out/bin/
223 223 ln -s ${self.channelstream}/bin/channelstream $out/bin/
224 224 ln -s ${self.celery}/bin/celery $out/bin/
225 225 ln -s ${self.gunicorn}/bin/gunicorn $out/bin/
226 226 ln -s ${self.pyramid}/bin/prequest $out/bin/
227 227 ln -s ${self.pyramid}/bin/pserve $out/bin/
228 228
229 229 echo "[DONE ]: created symlinks into $out/bin"
230 230 DEPS="$out/bin/supervisorctl \
231 231 $out/bin/supervisord \
232 232 $out/bin/paster \
233 233 $out/bin/channelstream \
234 234 $out/bin/celery \
235 235 $out/bin/gunicorn \
236 236 $out/bin/prequest \
237 237 $out/bin/pserve"
238 238
239 239 # wrap only dependency scripts, they require to have full PYTHONPATH set
240 240 # to be able to import all packages
241 241 for file in $DEPS;
242 242 do
243 243 wrapProgram $file \
244 244 --prefix PATH : $PATH \
245 245 --prefix PYTHONPATH : $PYTHONPATH \
246 246 --set PYTHONHASHSEED random
247 247 done
248 248
249 249 echo "[DONE ]: enterprise-ce binary wrapping"
250 250
251 251 # rhodecode-tools don't need wrapping
252 252 ln -s ${self.rhodecode-tools}/bin/rhodecode-* $out/bin/
253 253
254 254 # expose sources of CE
255 255 ln -s $out $out/etc/rhodecode_enterprise_ce_source
256 256
257 257 # expose static files folder
258 258 cp -Rf $out/lib/${self.python.libPrefix}/site-packages/rhodecode/public/ $out/etc/static
259 259 chmod 755 -R $out/etc/static
260 260
261 261 '';
262 262 });
263 263
264 264 };
265 265
266 266 basePythonPackages = with builtins;
267 267 if isAttrs pythonPackages then
268 268 pythonPackages
269 269 else
270 270 getAttr pythonPackages pkgs;
271 271
272 272 pythonGeneratedPackages = import ./pkgs/python-packages.nix {
273 273 inherit
274 274 pkgs;
275 275 inherit
276 276 (pkgs)
277 277 fetchurl
278 278 fetchgit
279 279 fetchhg;
280 280 };
281 281
282 282 pythonCommunityOverrides = import ./pkgs/python-packages-overrides.nix {
283 283 inherit pkgs basePythonPackages;
284 284 };
285 285
286 286 # Apply all overrides and fix the final package set
287 287 myPythonPackagesUnfix = with pkgs.lib;
288 288 (extends pythonExternalOverrides
289 289 (extends pythonLocalOverrides
290 290 (extends pythonCommunityOverrides
291 291 (extends pythonGeneratedPackages
292 292 basePythonPackagesUnfix))));
293 293
294 294 myPythonPackages = (pkgs.lib.fix myPythonPackagesUnfix);
295 295
296 296 in myPythonPackages.rhodecode-enterprise-ce
@@ -1,141 +1,141 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2010-2019 RhodeCode GmbH
4 4 #
5 5 # This program is free software: you can redistribute it and/or modify
6 6 # it under the terms of the GNU Affero General Public License, version 3
7 7 # (only), as published by the Free Software Foundation.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU Affero General Public License
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16 #
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21
22 22 import pytest
23 23
24 24 import rhodecode
25 25 from rhodecode.model.db import Repository
26 26 from rhodecode.model.meta import Session
27 27 from rhodecode.model.repo import RepoModel
28 28 from rhodecode.model.repo_group import RepoGroupModel
29 29 from rhodecode.model.settings import SettingsModel
30 30 from rhodecode.tests import TestController
31 31 from rhodecode.tests.fixture import Fixture
32 32 from rhodecode.lib import helpers as h
33 33
34 34 fixture = Fixture()
35 35
36 36
37 37 def route_path(name, **kwargs):
38 38 return {
39 39 'home': '/',
40 40 'repo_group_home': '/{repo_group_name}'
41 41 }[name].format(**kwargs)
42 42
43 43
44 44 class TestHomeController(TestController):
45 45
46 46 def test_index(self):
47 47 self.log_user()
48 48 response = self.app.get(route_path('home'))
49 49 # if global permission is set
50 50 response.mustcontain('New Repository')
51 51
52 52 # search for objects inside the JavaScript JSON
53 53 for repo in Repository.getAll():
54 54 response.mustcontain('"name_raw": "%s"' % repo.repo_name)
55 55
56 56 def test_index_contains_statics_with_ver(self):
57 57 from rhodecode.lib.base import calculate_version_hash
58 58
59 59 self.log_user()
60 60 response = self.app.get(route_path('home'))
61 61
62 62 rhodecode_version_hash = calculate_version_hash(
63 63 {'beaker.session.secret': 'test-rc-uytcxaz'})
64 64 response.mustcontain('style.css?ver={0}'.format(rhodecode_version_hash))
65 response.mustcontain('scripts.js?ver={0}'.format(rhodecode_version_hash))
65 response.mustcontain('scripts.min.js?ver={0}'.format(rhodecode_version_hash))
66 66
67 67 def test_index_contains_backend_specific_details(self, backend):
68 68 self.log_user()
69 69 response = self.app.get(route_path('home'))
70 70 tip = backend.repo.get_commit().raw_id
71 71
72 72 # html in javascript variable:
73 73 response.mustcontain(r'<i class=\"icon-%s\"' % (backend.alias, ))
74 74 response.mustcontain(r'href=\"/%s\"' % (backend.repo_name, ))
75 75
76 76 response.mustcontain("""/%s/changeset/%s""" % (backend.repo_name, tip))
77 77 response.mustcontain("""Added a symlink""")
78 78
79 79 def test_index_with_anonymous_access_disabled(self):
80 80 with fixture.anon_access(False):
81 81 response = self.app.get(route_path('home'), status=302)
82 82 assert 'login' in response.location
83 83
84 84 def test_index_page_on_groups(self, autologin_user, repo_group):
85 85 response = self.app.get(route_path('repo_group_home', repo_group_name='gr1'))
86 86 response.mustcontain("gr1/repo_in_group")
87 87
88 88 def test_index_page_on_group_with_trailing_slash(
89 89 self, autologin_user, repo_group):
90 90 response = self.app.get(route_path('repo_group_home', repo_group_name='gr1') + '/')
91 91 response.mustcontain("gr1/repo_in_group")
92 92
93 93 @pytest.fixture(scope='class')
94 94 def repo_group(self, request):
95 95 gr = fixture.create_repo_group('gr1')
96 96 fixture.create_repo(name='gr1/repo_in_group', repo_group=gr)
97 97
98 98 @request.addfinalizer
99 99 def cleanup():
100 100 RepoModel().delete('gr1/repo_in_group')
101 101 RepoGroupModel().delete(repo_group='gr1', force_delete=True)
102 102 Session().commit()
103 103
104 104 def test_index_with_name_with_tags(self, user_util, autologin_user):
105 105 user = user_util.create_user()
106 106 username = user.username
107 107 user.name = '<img src="/image1" onload="alert(\'Hello, World!\');">'
108 108 user.lastname = '#"><img src=x onerror=prompt(document.cookie);>'
109 109
110 110 Session().add(user)
111 111 Session().commit()
112 112 user_util.create_repo(owner=username)
113 113
114 114 response = self.app.get(route_path('home'))
115 115 response.mustcontain(h.html_escape(user.first_name))
116 116 response.mustcontain(h.html_escape(user.last_name))
117 117
118 118 @pytest.mark.parametrize("name, state", [
119 119 ('Disabled', False),
120 120 ('Enabled', True),
121 121 ])
122 122 def test_index_show_version(self, autologin_user, name, state):
123 123 version_string = 'RhodeCode Enterprise %s' % rhodecode.__version__
124 124
125 125 sett = SettingsModel().create_or_update_setting(
126 126 'show_version', state, 'bool')
127 127 Session().add(sett)
128 128 Session().commit()
129 129 SettingsModel().invalidate_settings_cache()
130 130
131 131 response = self.app.get(route_path('home'))
132 132 if state is True:
133 133 response.mustcontain(version_string)
134 134 if state is False:
135 135 response.mustcontain(no=[version_string])
136 136
137 137 def test_logout_form_contains_csrf(self, autologin_user, csrf_token):
138 138 response = self.app.get(route_path('home'))
139 139 assert_response = response.assert_response()
140 140 element = assert_response.get_element('.logout #csrf_token')
141 141 assert element.value == csrf_token
@@ -1,93 +1,93 b''
1 1 ## -*- coding: utf-8 -*-
2 2 <!DOCTYPE html>
3 3 <html xmlns="http://www.w3.org/1999/xhtml">
4 4 <head>
5 5 <title>Error - ${c.error_message}</title>
6 6 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
7 7 <meta name="robots" content="index, nofollow"/>
8 8
9 9 <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
10 10 %if c.redirect_time:
11 11 <meta http-equiv="refresh" content="${c.redirect_time}; url=${c.url_redirect}"/>
12 12 %endif
13 13
14 14 <link rel="icon" href="${h.asset('images/favicon.ico', ver=c.rhodecode_version_hash)}" sizes="16x16 32x32" type="image/png" />
15 15 <script src="${h.asset('js/vendors/webcomponentsjs/custom-elements-es5-adapter.js', ver=c.rhodecode_version_hash)}"></script>
16 16 <script src="${h.asset('js/vendors/webcomponentsjs/webcomponents-bundle.js', ver=c.rhodecode_version_hash)}"></script>
17 17
18 18 <link rel="stylesheet" type="text/css" href="${h.asset('css/style.css', ver=c.rhodecode_version_hash)}" media="screen"/>
19 19 <style>body { background:#eeeeee; }</style>
20 20 <script type="text/javascript">
21 21 // register templateContext to pass template variables to JS
22 22 var templateContext = {timeago: {}};
23 23 </script>
24 <script type="text/javascript" src="${h.asset('js/scripts.js', ver=c.rhodecode_version_hash)}"></script>
24 <script type="text/javascript" src="${h.asset('js/scripts.min.js', ver=c.rhodecode_version_hash)}"></script>
25 25 </head>
26 26 <body>
27 27
28 28 <div class="wrapper error_page">
29 29 <div class="sidebar">
30 30 <a href="${h.route_path('home')}"><img class="error-page-logo" src="${h.asset('images/RhodeCode_Logo_Black.png')}" alt="RhodeCode"/></a>
31 31 </div>
32 32 <div class="main-content">
33 33 <h1>
34 34 <span class="error-branding">
35 35 ${h.branding(c.rhodecode_name)}
36 36 </span><br/>
37 37 ${c.error_message}
38 38 <br/>
39 39 <span class="error_message">${c.error_explanation}</span>
40 40 </h1>
41 41 % if c.messages:
42 42 % for message in c.messages:
43 43 <div class="alert alert-${message.category}">${message}</div>
44 44 % endfor
45 45 % endif
46 46 %if c.redirect_time:
47 47 <p>${_('You will be redirected to %s in %s seconds') % (c.redirect_module,c.redirect_time)}</p>
48 48 %endif
49 49 <div class="inner-column">
50 50 <h4>Possible Causes</h4>
51 51 <ul>
52 52 % if c.causes:
53 53 %for cause in c.causes:
54 54 <li>${cause}</li>
55 55 %endfor
56 56 %else:
57 57 <li>The resource may have been deleted.</li>
58 58 <li>You may not have access to this repository.</li>
59 59 <li>The link may be incorrect.</li>
60 60 %endif
61 61 </ul>
62 62 </div>
63 63 <div class="inner-column">
64 64 <h4>Support</h4>
65 65 <p>For help and support, go to the <a href="${c.visual.rhodecode_support_url}" target="_blank">${_('Support Page')}</a>.
66 66 It may be useful to include your log file; see the log file locations <a href="${h.route_url('enterprise_log_file_locations')}">here</a>.
67 67 </p>
68 68
69 69 </div>
70 70 <div class="inner-column">
71 71 <h4>Documentation</h4>
72 72 <p>For more information, see <a href="${h.route_url('enterprise_docs')}">docs.rhodecode.com</a>.</p>
73 73 </div>
74 74 </div>
75 75
76 76 % if c.show_exception_id:
77 77 <div class="sidebar" style="width: 130px">
78 78
79 79 </div>
80 80 <div class="main-content">
81 81 <p>
82 82 <strong>Exception ID: <code><a href="${c.exception_id_url}">${c.exception_id}</a></code> </strong> <br/>
83 83
84 84 Super Admins can see detailed traceback information from this exception by checking the below Exception ID.<br/>
85 85 Please include the above link for further details of this exception.
86 86 </p>
87 87 </div>
88 88 % endif
89 89 </div>
90 90
91 91 </body>
92 92
93 93 </html>
General Comments 0
You need to be logged in to leave comments. Login now