[Checkins] SVN: hurry.jqueryui/trunk/ Expand so we also include the themes.
Martijn Faassen
faassen at startifact.com
Sun Nov 8 05:47:58 EST 2009
Log message for revision 105515:
Expand so we also include the themes.
Changed:
_U hurry.jqueryui/trunk/
U hurry.jqueryui/trunk/MANIFEST.in
U hurry.jqueryui/trunk/buildout.cfg
U hurry.jqueryui/trunk/setup.py
_U hurry.jqueryui/trunk/src/hurry/jqueryui/
U hurry.jqueryui/trunk/src/hurry/jqueryui/__init__.py
U hurry.jqueryui/trunk/src/hurry/jqueryui/configure.zcml
U hurry.jqueryui/trunk/src/hurry/jqueryui/jqueryui.txt
U hurry.jqueryui/trunk/src/hurry/jqueryui/prepare.py
-=-
Property changes on: hurry.jqueryui/trunk
___________________________________________________________________
Added: svn:ignore
+ develop-eggs
bin
.installed.cfg
parts
Modified: hurry.jqueryui/trunk/MANIFEST.in
===================================================================
--- hurry.jqueryui/trunk/MANIFEST.in 2009-11-08 10:42:18 UTC (rev 105514)
+++ hurry.jqueryui/trunk/MANIFEST.in 2009-11-08 10:47:58 UTC (rev 105515)
@@ -1 +1,4 @@
recursive-include src/hurry/jqueryui/jqueryui-build *
+recursive-include src/hurry/jqueryui/jqueryui-themes *
+include src/hurry/jqueryui/_themes.py
+
Modified: hurry.jqueryui/trunk/buildout.cfg
===================================================================
--- hurry.jqueryui/trunk/buildout.cfg 2009-11-08 10:42:18 UTC (rev 105514)
+++ hurry.jqueryui/trunk/buildout.cfg 2009-11-08 10:47:58 UTC (rev 105515)
@@ -7,7 +7,7 @@
[scripts]
recipe = zc.recipe.egg
-eggs = hurry.jqueryui
+eggs = hurry.jqueryui [prepare]
[test]
recipe = zc.recipe.testrunner
Modified: hurry.jqueryui/trunk/setup.py
===================================================================
--- hurry.jqueryui/trunk/setup.py 2009-11-08 10:42:18 UTC (rev 105514)
+++ hurry.jqueryui/trunk/setup.py 2009-11-08 10:47:58 UTC (rev 105515)
@@ -43,5 +43,6 @@
},
extras_require={
'zopesupport': ['hurry.zoperesource'],
+ 'prepare': ['py'],
},
)
Property changes on: hurry.jqueryui/trunk/src/hurry/jqueryui
___________________________________________________________________
Added: svn:ignore
+ jqueryui-build
jqueryui-themes
_themes.py
Modified: hurry.jqueryui/trunk/src/hurry/jqueryui/__init__.py
===================================================================
--- hurry.jqueryui/trunk/src/hurry/jqueryui/__init__.py 2009-11-08 10:42:18 UTC (rev 105514)
+++ hurry.jqueryui/trunk/src/hurry/jqueryui/__init__.py 2009-11-08 10:47:58 UTC (rev 105515)
@@ -1,7 +1,9 @@
from hurry.resource import Library, ResourceInclusion
from hurry.jquery import jquery
+from hurry.jqueryui._themes import *
jqueryui = Library('jqueryui')
jqueryui = ResourceInclusion(jqueryui, 'jquery-ui.js', depends=[jquery],
minified='jquery-ui.min.js')
+
Modified: hurry.jqueryui/trunk/src/hurry/jqueryui/configure.zcml
===================================================================
--- hurry.jqueryui/trunk/src/hurry/jqueryui/configure.zcml 2009-11-08 10:42:18 UTC (rev 105514)
+++ hurry.jqueryui/trunk/src/hurry/jqueryui/configure.zcml 2009-11-08 10:47:58 UTC (rev 105515)
@@ -5,5 +5,7 @@
<browser:resourceDirectory
name="jqueryui"
directory="jqueryui-build" />
-
+ <browser:resourceDirectory
+ name="jqueryui_themes"
+ directory="jqueryui-themes" />
</configure>
Modified: hurry.jqueryui/trunk/src/hurry/jqueryui/jqueryui.txt
===================================================================
--- hurry.jqueryui/trunk/src/hurry/jqueryui/jqueryui.txt 2009-11-08 10:42:18 UTC (rev 105514)
+++ hurry.jqueryui/trunk/src/hurry/jqueryui/jqueryui.txt 2009-11-08 10:47:58 UTC (rev 105515)
@@ -29,3 +29,17 @@
>>> print needed.render()
<script type="text/javascript" src="http://localhost/static/jquery/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="http://localhost/static/jqueryui/jquery-ui.min.js"></script>
+
+Let's also try a theme::
+
+ >>> from hurry.jqueryui import base
+ >>> needed = NeededInclusions()
+ >>> needed.need(base)
+ >>> print needed.render()
+ <link rel="stylesheet" type="text/css" href="http://localhost/static/jqueryui_themes/base/jquery-ui.css" />
+
+ >>> needed.mode('minified')
+ >>> print needed.render()
+ <link rel="stylesheet" type="text/css" href="http://localhost/static/jqueryui_themes/base/jquery-ui.css" />
+
+
Modified: hurry.jqueryui/trunk/src/hurry/jqueryui/prepare.py
===================================================================
--- hurry.jqueryui/trunk/src/hurry/jqueryui/prepare.py 2009-11-08 10:42:18 UTC (rev 105514)
+++ hurry.jqueryui/trunk/src/hurry/jqueryui/prepare.py 2009-11-08 10:47:58 UTC (rev 105515)
@@ -1,8 +1,9 @@
+import py
import os
-import shutil
import sys
import urllib2
import urlparse
+import tempfile
from hurry.resource import generate_code, ResourceInclusion, Library
from hurry.jquery import jquery
@@ -10,6 +11,7 @@
BASEURL = 'http://ajax.googleapis.com/ajax/libs/jqueryui/'
MINIFIED = "jquery-ui.min.js"
FULL = "jquery-ui.js"
+THEME_URL = 'http://jquery-ui.googlecode.com/files/jquery-ui-themes-%s.0.zip'
def main():
try:
@@ -18,23 +20,76 @@
print "Usage: jqueryuiprepare <jQuery UI version>"
return
- package_dir = os.path.dirname(__file__)
- jquery_dest_path = os.path.join(package_dir, 'jqueryui-build')
+ package_dir = py.path.local(os.path.dirname(__file__))
+ jquery_dest_path = package_dir.join('jqueryui-build')
# remove previous jquery library build
print 'recursively removing "%s"' % jquery_dest_path
- shutil.rmtree(jquery_dest_path, ignore_errors=True)
+ if jquery_dest_path.check():
+ jquery_dest_path.remove()
print 'create new "%s"' % jquery_dest_path
- os.mkdir(jquery_dest_path)
-
+ jquery_dest_path.ensure(dir=True)
+
for filename in [MINIFIED, FULL]:
url = urlparse.urljoin(BASEURL + version + '/', filename)
print 'downloading "%s"' % url
f = urllib2.urlopen(url)
file_data = f.read()
f.close()
- dest_filename = os.path.join(jquery_dest_path, filename)
- dest = open(dest_filename, 'wb')
- print 'writing data to "%s"' % dest_filename
- dest.write(file_data)
- dest.close()
+ dest_file = jquery_dest_path.join(filename)
+ print 'writing data to "%s"' % dest_file
+ dest_file.write(file_data)
+
+ # now set up themes
+ print "remove previous themes"
+ themes_dest_path = package_dir.join('jqueryui-themes')
+ if themes_dest_path.check():
+ themes_dest_path.remove()
+
+ print "downloading themes"
+ theme_url = THEME_URL % version
+ f = urllib2.urlopen(theme_url)
+ file_data = f.read()
+ f.close()
+
+ temp_dir = py.path.local.mkdtemp()
+
+ zip_file = temp_dir.join('zipfile.zip')
+ zip_file.write(file_data)
+
+ print "unzipping themes"
+ unzip_dir = temp_dir.join('unzipped')
+ os.system('unzip -qq "%s" -d "%s"' % (zip_file, unzip_dir.strpath))
+
+
+ print "copying themes"
+ try:
+ for dir in unzip_dir.listdir():
+ if dir.check(dir=True):
+ themes_dir = dir.join('themes')
+ break
+ themes_dir.copy(themes_dest_path)
+ finally:
+ temp_dir.remove()
+
+ print "generating theme information"
+ py_path = package_dir.join('_themes.py')
+ print 'Generating inclusion module "%s"' % py_path
+
+ library = Library('jqueryui_themes')
+ inclusion_map = {}
+ for theme in themes_dest_path.listdir():
+ if not theme.check(dir=True):
+ continue
+ if theme.basename.startswith('.'):
+ continue
+ theme_name = str(theme.basename)
+ python_theme_name = theme_name.replace('-', '_')
+ inclusion = inclusion_map[python_theme_name] = ResourceInclusion(
+ library, '%s/jquery-ui.css' % theme_name)
+
+ code = generate_code(**inclusion_map)
+ module = py_path.open('w')
+ module.write(code)
+ module.close()
+
More information about the checkins
mailing list