[Checkins] SVN: zc.resourcelibrary/trunk/ Add support for a marker comment, specifying where to insert resourcelibrary inclusion HTML.
Dan Korostelev
nadako at gmail.com
Tue Jan 27 16:50:51 EST 2009
Log message for revision 95261:
Add support for a marker comment, specifying where to insert resourcelibrary inclusion HTML.
Changed:
U zc.resourcelibrary/trunk/CHANGES.txt
U zc.resourcelibrary/trunk/setup.py
U zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt
U zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py
U zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests/ftesting.zcml
A zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests/test_template_6.pt
-=-
Modified: zc.resourcelibrary/trunk/CHANGES.txt
===================================================================
--- zc.resourcelibrary/trunk/CHANGES.txt 2009-01-27 20:17:13 UTC (rev 95260)
+++ zc.resourcelibrary/trunk/CHANGES.txt 2009-01-27 21:50:50 UTC (rev 95261)
@@ -2,11 +2,14 @@
CHANGES
=======
-1.0.3 (unreleased)
+1.1.0 (unreleased)
------------------
-- ...
+New features:
+- You can now explicitly specify where resource links should be
+ inserted using the special marker comment '<!-- zc.resourcelibrary -->'.
+
1.0.2 (2009-01-27)
------------------
Modified: zc.resourcelibrary/trunk/setup.py
===================================================================
--- zc.resourcelibrary/trunk/setup.py 2009-01-27 20:17:13 UTC (rev 95260)
+++ zc.resourcelibrary/trunk/setup.py 2009-01-27 21:50:50 UTC (rev 95261)
@@ -22,7 +22,7 @@
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
setup(name='zc.resourcelibrary',
- version = '1.0.3dev',
+ version = '1.1.0dev',
author='Zope Corporation and Contributors',
author_email='zope-dev at zope.org',
description='Post-rendering Resource Inclusion',
Modified: zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt
===================================================================
--- zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt 2009-01-27 20:17:13 UTC (rev 95260)
+++ zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt 2009-01-27 21:50:50 UTC (rev 95261)
@@ -361,7 +361,31 @@
>>> print browser.contents,
foo = 1;
+Library insertion place marker
+------------------------------
+You can explicitly mark where to insert HTML. Do do that, add the
+special comment "<!-- zc.resourcelibrary -->" (exact string, w/o quotes)
+to the template. It will be replaced by resource libraries HTML on
+processing.
+
+ >>> browser.open('http://localhost/zc.resourcelibrary.test_template_6')
+
+A reference to the JavaScript is inserted into the HTML.
+
+ >>> print browser.contents
+ <html>
+ <head>
+ <title>Marker test</title>
+ <BLANKLINE>
+ <!-- Libraries will be included below -->
+ <script src="http://localhost/@@/my-lib/foo.js"
+ type="text/javascript">
+ </script>
+ </head>
+ ...
+ </html>
+
Future Work
-----------
Modified: zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py
===================================================================
--- zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py 2009-01-27 20:17:13 UTC (rev 95260)
+++ zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py 2009-01-27 21:50:50 UTC (rev 95261)
@@ -86,8 +86,12 @@
if html:
# This is a pretty low-rent way of adding things to the head.
# We should probably use a real HTML parser instead.
- body = body.replace('<head>', '<head>\n %s\n' %
- html, 1)
+ marker = body.find('<!-- zc.resourcelibrary -->')
+ if marker != -1:
+ body = body[:marker] + html + body[marker+27:]
+ else:
+ body = body.replace('<head>', '<head>\n %s\n' %
+ html, 1)
return super(Response, self)._implicitResult(body)
Modified: zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests/ftesting.zcml
===================================================================
--- zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests/ftesting.zcml 2009-01-27 20:17:13 UTC (rev 95260)
+++ zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests/ftesting.zcml 2009-01-27 21:50:50 UTC (rev 95261)
@@ -70,4 +70,11 @@
template="test_template_5.pt"
/>
+ <browser:page
+ for="zope.app.folder.interfaces.IFolder"
+ name="zc.resourcelibrary.test_template_6"
+ permission="zope.View"
+ template="test_template_6.pt"
+ />
+
</configure>
Added: zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests/test_template_6.pt
===================================================================
--- zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests/test_template_6.pt (rev 0)
+++ zc.resourcelibrary/trunk/src/zc/resourcelibrary/tests/test_template_6.pt 2009-01-27 21:50:50 UTC (rev 95261)
@@ -0,0 +1,11 @@
+<html>
+ <head>
+ <title>Marker test</title>
+
+ <!-- Libraries will be included below -->
+ <!-- zc.resourcelibrary -->
+ </head>
+ <body>
+ <tal:block replace="structure resource_library:my-lib"/>
+ </body>
+</html>
More information about the Checkins
mailing list