launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #08759
[Merge] lp:~rvb/maas/use-yui-from-package2 into lp:maas
Raphaël Badin has proposed merging lp:~rvb/maas/use-yui-from-package2 into lp:maas with lp:~rvb/maas/use-yui-from-package as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~rvb/maas/use-yui-from-package2/+merge/110035
This branch adds a setting named 'YUI_LOCATION' which can be used (for instance) to serve the YUI3 files from the ubuntu package libjs-yui instead of from the copy of YUI3 in the MAAS tree.
The only real trick is the YUI loader configuration:
root: '',
base: '{% if FORCE_SCRIPT_NAME %}{{ FORCE_SCRIPT_NAME }}{% endif%}/{{YUI_COMBO_URL }}?',
'root' by default is {yui_version]/build. I've set this to '' because we've removed {yui_version]/build to better match the way the files are structured in the package.
'base': is use to load the loader.js file. I've set it to use the combo loader. This way, all the requests for YUI3 files go through convoy which loads files from our copy or the package depending on the setting 'YUI_LOCATION'.
Note that I had to fix the paths in the HTML test files (used for testing the JS code) and that we will need to do one more branch to be able to use the package's files in the JS tests. The problem is that these files are completely isolated from the Django stuff and thus have no way to know about any of the Django settings… but we will find a way (for instance by generating a JS files with the proper conf option) when we will move to using only the YUI package.
--
https://code.launchpad.net/~rvb/maas/use-yui-from-package2/+merge/110035
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/use-yui-from-package2 into lp:maas.
=== modified file 'contrib/maas_local_settings_sample.py'
--- contrib/maas_local_settings_sample.py 2012-04-13 22:01:42 +0000
+++ contrib/maas_local_settings_sample.py 2012-06-13 11:11:20 +0000
@@ -17,6 +17,9 @@
# Where to store the user uploaded files.
MEDIA_ROOT = '/var/lib/maas/media/'
+# Use the (libjs-yui) package's files to serve YUI3.
+YUI_LOCATION = '/usr/share/javascript/yui/'
+
# RabbitMQ settings.
RABBITMQ_HOST = 'localhost'
RABBITMQ_USERID = 'maas_longpoll'
=== modified file 'src/maas/settings.py'
--- src/maas/settings.py 2012-06-11 14:32:48 +0000
+++ src/maas/settings.py 2012-06-13 11:11:20 +0000
@@ -78,8 +78,15 @@
PISTON_DISPLAY_ERRORS = False
TEMPLATE_DEBUG = DEBUG
+
YUI_DEBUG = DEBUG
-YUI_VERSION = '3.5.1'
+
+# Set this to where YUI3 files can be found to serve these files from a
+# custom location. For instance, you can set it to
+# '/usr/share/javascript/yui/' to serve the files from the YUI package
+# (libjs-yui).
+YUI_LOCATION = None
+
STATIC_LOCAL_SERVE = DEBUG
AUTH_PROFILE_MODULE = 'maasserver.UserProfile'
=== modified file 'src/maasserver/context_processors.py'
--- src/maasserver/context_processors.py 2012-06-11 12:25:37 +0000
+++ src/maasserver/context_processors.py 2012-06-13 11:11:20 +0000
@@ -25,7 +25,6 @@
def yui(context):
return {
'YUI_DEBUG': settings.YUI_DEBUG,
- 'YUI_VERSION': settings.YUI_VERSION,
'YUI_COMBO_URL': settings.YUI_COMBO_URL,
'FORCE_SCRIPT_NAME': settings.FORCE_SCRIPT_NAME,
}
=== modified file 'src/maasserver/static/js/tests/test_enums.html'
--- src/maasserver/static/js/tests/test_enums.html 2012-04-30 13:49:53 +0000
+++ src/maasserver/static/js/tests/test_enums.html 2012-06-13 11:11:20 +0000
@@ -5,7 +5,7 @@
<!-- YUI and test setup -->
<script type="text/javascript" src="../testing/yui_test_conf.js"></script>
- <script type="text/javascript" src="../../jslibs/yui/tests/build/yui/yui.js"></script>
+ <script type="text/javascript" src="../../jslibs/yui/yui/yui.js"></script>
<script type="text/javascript" src="../testing/testrunner.js"></script>
<script type="text/javascript" src="../testing/testing.js"></script>
<script type="text/javascript" src="../node.js"></script>
=== modified file 'src/maasserver/static/js/tests/test_longpoll.html'
--- src/maasserver/static/js/tests/test_longpoll.html 2012-03-13 17:13:01 +0000
+++ src/maasserver/static/js/tests/test_longpoll.html 2012-06-13 11:11:20 +0000
@@ -5,7 +5,7 @@
<!-- YUI and test setup -->
<script type="text/javascript" src="../testing/yui_test_conf.js"></script>
- <script type="text/javascript" src="../../jslibs/yui/tests/build/yui/yui.js"></script>
+ <script type="text/javascript" src="../../jslibs/yui/yui/yui.js"></script>
<script type="text/javascript" src="../testing/testrunner.js"></script>
<script type="text/javascript" src="../testing/testing.js"></script>
<!-- The module under test -->
=== modified file 'src/maasserver/static/js/tests/test_morph.html'
--- src/maasserver/static/js/tests/test_morph.html 2012-05-20 13:03:54 +0000
+++ src/maasserver/static/js/tests/test_morph.html 2012-06-13 11:11:20 +0000
@@ -5,7 +5,7 @@
<!-- YUI and test setup -->
<script type="text/javascript" src="../testing/yui_test_conf.js"></script>
- <script type="text/javascript" src="../../jslibs/yui/tests/build/yui/yui.js"></script>
+ <script type="text/javascript" src="../../jslibs/yui/yui/yui.js"></script>
<script type="text/javascript" src="../testing/testrunner.js"></script>
<script type="text/javascript" src="../testing/testing.js"></script>
<!-- The module under test -->
=== modified file 'src/maasserver/static/js/tests/test_node.html'
--- src/maasserver/static/js/tests/test_node.html 2012-03-07 16:26:04 +0000
+++ src/maasserver/static/js/tests/test_node.html 2012-06-13 11:11:20 +0000
@@ -5,7 +5,7 @@
<!-- YUI and test setup -->
<script type="text/javascript" src="../testing/yui_test_conf.js"></script>
- <script type="text/javascript" src="../../jslibs/yui/tests/build/yui/yui.js"></script>
+ <script type="text/javascript" src="../../jslibs/yui/yui/yui.js"></script>
<script type="text/javascript" src="../testing/testrunner.js"></script>
<!-- The module under test -->
<script type="text/javascript" src="../node.js"></script>
=== modified file 'src/maasserver/static/js/tests/test_node_add.html'
--- src/maasserver/static/js/tests/test_node_add.html 2012-06-11 12:25:37 +0000
+++ src/maasserver/static/js/tests/test_node_add.html 2012-06-13 11:11:20 +0000
@@ -5,7 +5,7 @@
<!-- YUI and test setup -->
<script type="text/javascript" src="../testing/yui_test_conf.js"></script>
- <script type="text/javascript" src="../../jslibs/yui/tests/build/yui/yui.js"></script>
+ <script type="text/javascript" src="../../jslibs/yui/yui/yui.js"></script>
<script type="text/javascript" src="../testing/testrunner.js"></script>
<script type="text/javascript" src="../testing/testing.js"></script>
<script type="text/javascript" src="../morph.js"></script>
=== modified file 'src/maasserver/static/js/tests/test_node_views.html'
--- src/maasserver/static/js/tests/test_node_views.html 2012-05-15 11:29:41 +0000
+++ src/maasserver/static/js/tests/test_node_views.html 2012-06-13 11:11:20 +0000
@@ -6,7 +6,7 @@
<!-- YUI and test setup -->
<script type="text/javascript" src="../../jslibs/raphael/raphael-min.js"></script>
<script type="text/javascript" src="../testing/yui_test_conf.js"></script>
- <script type="text/javascript" src="../../jslibs/yui/tests/build/yui/yui.js"></script>
+ <script type="text/javascript" src="../../jslibs/yui/yui/yui.js"></script>
<script type="text/javascript" src="../testing/testrunner.js"></script>
<script type="text/javascript" src="../testing/testing.js"></script>
<script type="text/javascript" src="../enums.js"></script>
=== modified file 'src/maasserver/static/js/tests/test_nodes_chart.html'
--- src/maasserver/static/js/tests/test_nodes_chart.html 2012-04-17 15:48:27 +0000
+++ src/maasserver/static/js/tests/test_nodes_chart.html 2012-06-13 11:11:20 +0000
@@ -6,7 +6,7 @@
<!-- YUI and test setup -->
<script type="text/javascript" src="../../jslibs/raphael/raphael-min.js"></script>
<script type="text/javascript" src="../testing/yui_test_conf.js"></script>
- <script type="text/javascript" src="../../jslibs/yui/tests/build/yui/yui.js"></script>
+ <script type="text/javascript" src="../../jslibs/yui/yui/yui.js"></script>
<script type="text/javascript" src="../testing/testrunner.js"></script>
<script type="text/javascript" src="../testing/testing.js"></script>
<!-- The module under test -->
=== modified file 'src/maasserver/static/js/tests/test_power_parameters.html'
--- src/maasserver/static/js/tests/test_power_parameters.html 2012-06-06 16:21:13 +0000
+++ src/maasserver/static/js/tests/test_power_parameters.html 2012-06-13 11:11:20 +0000
@@ -5,7 +5,7 @@
<!-- YUI and test setup -->
<script type="text/javascript" src="../testing/yui_test_conf.js"></script>
- <script type="text/javascript" src="../../jslibs/yui/tests/build/yui/yui.js"></script>
+ <script type="text/javascript" src="../../jslibs/yui/yui/yui.js"></script>
<script type="text/javascript" src="../testing/testrunner.js"></script>
<script type="text/javascript" src="../testing/testing.js"></script>
<!-- The module under test -->
=== modified file 'src/maasserver/static/js/tests/test_prefs.html'
--- src/maasserver/static/js/tests/test_prefs.html 2012-04-17 15:48:27 +0000
+++ src/maasserver/static/js/tests/test_prefs.html 2012-06-13 11:11:20 +0000
@@ -5,7 +5,7 @@
<!-- YUI and test setup -->
<script type="text/javascript" src="../testing/yui_test_conf.js"></script>
- <script type="text/javascript" src="../../jslibs/yui/tests/build/yui/yui.js"></script>
+ <script type="text/javascript" src="../../jslibs/yui/yui/yui.js"></script>
<script type="text/javascript" src="../testing/testrunner.js"></script>
<script type="text/javascript" src="../testing/testing.js"></script>
<!-- The module under test -->
=== modified file 'src/maasserver/static/js/tests/test_user_panel.html'
--- src/maasserver/static/js/tests/test_user_panel.html 2012-03-07 16:26:04 +0000
+++ src/maasserver/static/js/tests/test_user_panel.html 2012-06-13 11:11:20 +0000
@@ -5,7 +5,7 @@
<!-- YUI and test setup -->
<script type="text/javascript" src="../testing/yui_test_conf.js"></script>
- <script type="text/javascript" src="../../jslibs/yui/tests/build/yui/yui.js"></script>
+ <script type="text/javascript" src="../../jslibs/yui/yui/yui.js"></script>
<script type="text/javascript" src="../testing/testrunner.js"></script>
<script type="text/javascript" src="../testing/testing.js"></script>
<!-- The module under test -->
=== modified file 'src/maasserver/static/js/tests/test_utils.html'
--- src/maasserver/static/js/tests/test_utils.html 2012-03-15 13:58:32 +0000
+++ src/maasserver/static/js/tests/test_utils.html 2012-06-13 11:11:20 +0000
@@ -5,7 +5,7 @@
<!-- YUI and test setup -->
<script type="text/javascript" src="../testing/yui_test_conf.js"></script>
- <script type="text/javascript" src="../../jslibs/yui/tests/build/yui/yui.js"></script>
+ <script type="text/javascript" src="../../jslibs/yui/yui/yui.js"></script>
<script type="text/javascript" src="../testing/testrunner.js"></script>
<script type="text/javascript" src="../testing/testing.js"></script>
<!-- The module under test -->
=== modified file 'src/maasserver/templates/maasserver/js-conf.html'
--- src/maasserver/templates/maasserver/js-conf.html 2012-06-11 12:25:37 +0000
+++ src/maasserver/templates/maasserver/js-conf.html 2012-06-13 11:11:20 +0000
@@ -4,7 +4,8 @@
debug: {% if YUI_DEBUG %}true{% else %}false{% endif %},
combine: true,
filter: {% if YUI_DEBUG %}'raw'{% else %}'min'{% endif %},
- base: '{{ STATIC_URL }}jslibs/yui/{{ YUI_VERSION }}/build/',
+ root: '',
+ base: '{% if FORCE_SCRIPT_NAME %}{{ FORCE_SCRIPT_NAME }}{% endif%}/{{YUI_COMBO_URL }}?',
comboBase: '{% if FORCE_SCRIPT_NAME %}{{ FORCE_SCRIPT_NAME }}{% endif%}/{{ YUI_COMBO_URL }}?',
};
var MAAS_config = {
@@ -20,7 +21,7 @@
// -->
</script>
<script type="text/javascript"
- src="{{ STATIC_URL }}jslibs/yui/{{ YUI_VERSION }}/build/yui-base/yui-base-min.js">
+ src="{% if FORCE_SCRIPT_NAME %}{{ FORCE_SCRIPT_NAME }}{% endif%}/{{ YUI_COMBO_URL }}?yui-base/yui-base-min.js">
</script>
<script type="text/javascript" src="{{ STATIC_URL }}js/morph.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}js/user_panel.js"></script>
=== modified file 'src/maasserver/tests/test_views_combo.py'
--- src/maasserver/tests/test_views_combo.py 2012-04-23 13:50:41 +0000
+++ src/maasserver/tests/test_views_combo.py 2012-06-13 11:11:20 +0000
@@ -23,6 +23,11 @@
class TestUtilities(TestCase):
+ def test_get_yui_location_if_yui_location_set(self):
+ yui_location = factory.getRandomString()
+ self.patch(settings, 'YUI_LOCATION', yui_location)
+ self.assertEqual(yui_location, get_yui_location())
+
def test_get_yui_location_if_static_root_is_none(self):
self.patch(settings, 'STATIC_ROOT', None)
yui_location = os.path.join(
@@ -42,8 +47,8 @@
def test_load_js(self):
requested_files = [
- 'tests/build/oop/oop.js',
- 'tests/build/event-custom-base/event-custom-base.js'
+ 'oop/oop.js',
+ 'event-custom-base/event-custom-base.js'
]
response = self.client.get('/combo/?%s' % '&'.join(requested_files))
self.assertIn('text/javascript', response['Content-Type'])
@@ -56,8 +61,8 @@
def test_load_css(self):
requested_files = [
- 'tests/build/widget-base/assets/skins/sam/widget-base.css',
- 'tests/build/widget-stack/assets/skins/sam/widget-stack.css',
+ 'widget-base/assets/skins/sam/widget-base.css',
+ 'widget-stack/assets/skins/sam/widget-stack.css',
]
response = self.client.get('/combo/?%s' % '&'.join(requested_files))
self.assertIn('text/css', response['Content-Type'])
=== modified file 'src/maasserver/views/combo.py'
--- src/maasserver/views/combo.py 2012-04-23 13:30:11 +0000
+++ src/maasserver/views/combo.py 2012-06-13 11:11:20 +0000
@@ -29,7 +29,9 @@
def get_yui_location():
- if django_settings.STATIC_ROOT:
+ if django_settings.YUI_LOCATION is not None:
+ return django_settings.YUI_LOCATION
+ elif django_settings.STATIC_ROOT:
return os.path.join(
django_settings.STATIC_ROOT, 'jslibs', 'yui')
else: