Author: jfthomps
Date: Thu Apr  5 16:34:42 2012
New Revision: 1309931

URL: http://svn.apache.org/viewvc?rev=1309931&view=rev
Log:
VCL-505
Dojo is slow to load, especially on pages with many ancillary class files

This script parses utils.php to generate vcl.profile.js which is a dojo layer 
file for building custom layers for each portion of the VCL site.

Added:
    incubator/vcl/sandbox/useful_scripts/generateDojoProfile.py   (with props)

Added: incubator/vcl/sandbox/useful_scripts/generateDojoProfile.py
URL: 
http://svn.apache.org/viewvc/incubator/vcl/sandbox/useful_scripts/generateDojoProfile.py?rev=1309931&view=auto
==============================================================================
--- incubator/vcl/sandbox/useful_scripts/generateDojoProfile.py (added)
+++ incubator/vcl/sandbox/useful_scripts/generateDojoProfile.py Thu Apr  5 
16:34:42 2012
@@ -0,0 +1,84 @@
+#!/usr/bin/python
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import re
+import sys
+
+try:
+       utilsfh = open('utils.php', 'r')
+except:
+       print "utils.php not found. This script needs to be run from the 
directory containing utils.php"
+       sys.exit(1)
+
+for line in utilsfh:
+       if line == '\t# START DOJO PARSING\n':
+               break
+
+mode = 'findname'
+sections = []
+for line in utilsfh:
+       line = line.strip()
+       if line == '# END DOJO PARSING':
+               break
+       if mode == 'findname' and re.search('filename = ', line):
+               tmp = line.split(' ')
+               tmp = tmp[2]
+               tmp = line.split("'");
+               filename = tmp[1]
+               section  = "\t\t{\n"
+               section += '\t\t\tname: "%s",\n' % filename
+               mode = 'findobjects'
+       elif mode == 'findobjects' and re.search('dojoRequires = .*\);$', line):
+               mode = 'addobjects'
+               tmp = line.split('(')
+               tmp = tmp[1].split(')')
+               obj = tmp[0]
+               objs = []
+               objs.append("\t\t\t\t%s" % obj)
+       elif mode == 'findobjects' and re.search('dojoRequires = ', line):
+               mode = 'addobjects'
+               tmp = line.split('(')
+               obj = tmp[1]
+               objs = []
+               objs.append("\t\t\t\t%s" % obj)
+       elif mode == 'addobjects' and re.search('^break;$', line):
+               mode = 'findname'
+               section += '\t\t\tdependencies: [\n'
+               section += '\n'.join(objs)
+               section += '\n\t\t\t]\n'
+               sections.append(section)
+       elif mode == 'addobjects' and re.search('\);$', line):
+               tmp = line.split(')')
+               objs.append("\t\t\t\t%s" % tmp[0])
+       elif mode == 'addobjects':
+               objs.append("\t\t\t\t%s" % line)
+utilsfh.close()
+
+dojofh = open('vcl.profile.js', 'w')
+dojofh.write('dependencies = {\n')
+dojofh.write('\tlayers: [\n')
+dojofh.write('                },\n'.join(sections))
+dojofh.write('                }\n')
+dojofh.write('\t],\n')
+dojofh.write('\tprefixes: [\n')
+dojofh.write('\t\t["dijit", "../dijit"],\n')
+#dojofh.write('\t\t["dojo", "../../dojo"],\n')
+dojofh.write('\t\t["dojox", "../dojox"],\n')
+dojofh.write('\t\t["vcldojo", "../vcldojo"]\n')
+dojofh.write('\t]\n')
+dojofh.write('};\n')
+dojofh.close()

Propchange: incubator/vcl/sandbox/useful_scripts/generateDojoProfile.py
------------------------------------------------------------------------------
    svn:executable = *


Reply via email to