[Checkins] SVN: hurry.tinymce/ Initial import.

Martijn Faassen faassen at infrae.com
Thu Oct 9 12:21:03 EDT 2008


Log message for revision 91919:
  Initial import.
  

Changed:
  A   hurry.tinymce/
  A   hurry.tinymce/trunk/
  A   hurry.tinymce/trunk/MANIFEST.in
  A   hurry.tinymce/trunk/README.txt
  A   hurry.tinymce/trunk/buildout.cfg
  A   hurry.tinymce/trunk/setup.py
  A   hurry.tinymce/trunk/src/
  A   hurry.tinymce/trunk/src/hurry/
  A   hurry.tinymce/trunk/src/hurry/__init__.py
  A   hurry.tinymce/trunk/src/hurry/tinymce/
  A   hurry.tinymce/trunk/src/hurry/tinymce/README.txt
  A   hurry.tinymce/trunk/src/hurry/tinymce/__init__.py
  A   hurry.tinymce/trunk/src/hurry/tinymce/download.py
  A   hurry.tinymce/trunk/src/hurry/tinymce/prepare.py
  A   hurry.tinymce/trunk/src/hurry/tinymce/tests.py
  A   hurry.tinymce/trunk/src/hurry/tinymce/tinymce.py

-=-
Added: hurry.tinymce/trunk/MANIFEST.in
===================================================================
--- hurry.tinymce/trunk/MANIFEST.in	                        (rev 0)
+++ hurry.tinymce/trunk/MANIFEST.in	2008-10-09 16:21:01 UTC (rev 91919)
@@ -0,0 +1 @@
+recursive-include src/hurry/tinymce/tinymce-build *

Added: hurry.tinymce/trunk/README.txt
===================================================================
--- hurry.tinymce/trunk/README.txt	                        (rev 0)
+++ hurry.tinymce/trunk/README.txt	2008-10-09 16:21:01 UTC (rev 91919)
@@ -0,0 +1,13 @@
+Preparing hurry.yui before release
+==================================
+
+Follow the regular package release instructions, but before egg
+generation (``bdist_egg``) first execute ``bin/yuiprepare <version
+number>``, where version number is the version of the YUI release, such
+as ``2.6.0``. This will do two things:
+
+* download the YUI of that version and place it in the egg
+
+* download the YUI dependency structure of that YUI version and generate
+  a ``yui.py`` file in the package that reflects this.
+

Added: hurry.tinymce/trunk/buildout.cfg
===================================================================
--- hurry.tinymce/trunk/buildout.cfg	                        (rev 0)
+++ hurry.tinymce/trunk/buildout.cfg	2008-10-09 16:21:01 UTC (rev 91919)
@@ -0,0 +1,20 @@
+[buildout]
+develop = . 
+parts = scripts devpython test
+versions = versions
+
+[versions]
+
+[scripts]
+recipe = zc.recipe.egg:scripts
+eggs = hurry.tinymce
+
+[devpython]
+recipe = zc.recipe.egg
+interpreter = devpython
+eggs = hurry.tinymce
+
+[test]
+recipe = zc.recipe.testrunner
+eggs = hurry.tinymce
+defaults = ['--tests-pattern', '^f?tests$', '-v']

Added: hurry.tinymce/trunk/setup.py
===================================================================
--- hurry.tinymce/trunk/setup.py	                        (rev 0)
+++ hurry.tinymce/trunk/setup.py	2008-10-09 16:21:01 UTC (rev 91919)
@@ -0,0 +1,28 @@
+from setuptools import setup, find_packages
+
+TINYMCE_VERSION = '2.6.0'
+
+setup(
+    name='hurry.tinymce',
+    version=TINYMCE_VERSION + 'dev',
+    description="tinymce for hurry.resource.",
+    classifiers=[],
+    keywords='',
+    author='Martijn Faassen',
+    author_email='faassen at startifact.com',
+    license='ZPL 2.1',
+    packages=find_packages('src'),
+    package_dir={'': 'src'},
+    include_package_data=True,
+    zip_safe=False,
+    install_requires=[
+        'setuptools',
+        'hurry.resource',
+        ],
+    entry_points= {
+    'console_scripts': [
+      'tinymceprepare = hurry.tinymce.prepare:main',
+      ]
+    },
+
+    )

Added: hurry.tinymce/trunk/src/hurry/__init__.py
===================================================================
--- hurry.tinymce/trunk/src/hurry/__init__.py	                        (rev 0)
+++ hurry.tinymce/trunk/src/hurry/__init__.py	2008-10-09 16:21:01 UTC (rev 91919)
@@ -0,0 +1,13 @@
+# XXX awful hack to make sure we don't get a warning due to two
+# namespace packages being loaded. Why this is needed I do not know,
+# haven't seen this before :(
+import warnings
+warnings.filterwarnings("ignore", "Module (.*) was already imported (.*)")
+
+# this is a namespace package
+try:
+    import pkg_resources
+    pkg_resources.declare_namespace(__name__)
+except ImportError:
+    import pkgutil
+    __path__ = pkgutil.extend_path(__path__, __name__)

Added: hurry.tinymce/trunk/src/hurry/tinymce/README.txt
===================================================================
--- hurry.tinymce/trunk/src/hurry/tinymce/README.txt	                        (rev 0)
+++ hurry.tinymce/trunk/src/hurry/tinymce/README.txt	2008-10-09 16:21:01 UTC (rev 91919)
@@ -0,0 +1,31 @@
+hurry.yui
+=========
+
+Introduction
+------------
+
+This library packages tinymce for ``hurry.resource``. 
+
+Let's set up a way to render URLs; typically the framework has already
+done this::
+
+  >>> def get_library_url(library):
+  ...    return 'http://localhost/static/%s' % (
+  ...      library.name)
+  >>> from hurry.resource import Library
+  >>> from hurry.resource.interfaces import ILibraryUrl
+  >>> from zope import component
+  >>> component.provideAdapter(
+  ...     factory=get_library_url, 
+  ...     adapts=(Library,),
+  ...     provides=ILibraryUrl)
+
+Let's now check whether we can need tinymce::
+
+  >>> from hurry import tinymce
+  >>> from hurry.resource import NeededInclusions
+  >>> needed = NeededInclusions()
+  >>> needed.need(tinymce.tinymce)
+  >>> print needed.render()
+  <script type="text/javascript" src="http://localhost/static/tinymce/tiny_mce_src.js"></script>
+

Added: hurry.tinymce/trunk/src/hurry/tinymce/__init__.py
===================================================================
--- hurry.tinymce/trunk/src/hurry/tinymce/__init__.py	                        (rev 0)
+++ hurry.tinymce/trunk/src/hurry/tinymce/__init__.py	2008-10-09 16:21:01 UTC (rev 91919)
@@ -0,0 +1 @@
+from hurry.tinymce.tinymce import *

Added: hurry.tinymce/trunk/src/hurry/tinymce/download.py
===================================================================
--- hurry.tinymce/trunk/src/hurry/tinymce/download.py	                        (rev 0)
+++ hurry.tinymce/trunk/src/hurry/tinymce/download.py	2008-10-09 16:21:01 UTC (rev 91919)
@@ -0,0 +1,45 @@
+import urllib2
+import tempfile, shutil
+import os
+
+SF_URL_TEMPLATE = 'http://sourceforge.net/project/downloading.php?groupname=tinymce&filename=tinymce_%s.zip'
+
+def download(version, callback):
+    """Download a tinymce of version.
+
+    When downloaded, call callback with path to directory
+    with an extracted tinymce. The callback will then be able to copy
+    this to the appropriate location.
+    """
+    url = SF_URL_TEMPLATE % version.replace('.', '_')
+    f = urllib2.urlopen(url)
+    data = f.read()
+    f.close()
+
+    download_url = find_a_href(data, 'direct link')
+
+    f = urllib2.urlopen(download_url)
+    file_data = f.read()
+    f.close()
+
+    dirpath = tempfile.mkdtemp()
+    try:
+        tinymce_path = os.path.join(dirpath, 'tinymce.zip')
+        ex_path = os.path.join(dirpath, 'tinymce_ex')
+        g = open(tinymce_path, 'wb')
+        g.write(file_data)
+        g.close()
+        os.system('unzip -qq "%s" -d "%s"' % (tinymce_path, ex_path))
+        callback(ex_path)
+    finally:
+        shutil.rmtree(dirpath, ignore_errors=True)
+
+def find_a_href(data, content):
+    """Given start of content of the <a href="">content</a> find href.
+    """
+    i = data.find(content)
+    a = '<a href="'
+    href_start = data.rfind(a, 0, i)
+    href_start += len(a)
+    href_end = data.find('"', href_start)
+    return data[href_start:href_end]

Added: hurry.tinymce/trunk/src/hurry/tinymce/prepare.py
===================================================================
--- hurry.tinymce/trunk/src/hurry/tinymce/prepare.py	                        (rev 0)
+++ hurry.tinymce/trunk/src/hurry/tinymce/prepare.py	2008-10-09 16:21:01 UTC (rev 91919)
@@ -0,0 +1,25 @@
+import os, sys
+import shutil
+
+from hurry.tinymce.download import download
+
+def main():
+    try:
+        version = sys.argv[1]
+    except IndexError:
+        print "Usage: tinymceprepare <YUI version>"
+        return
+
+    # download tinymce library into package
+    package_dir = os.path.dirname(__file__)
+    dest_path = os.path.join(package_dir, 'tinymce-build')
+
+    # remove previous tinymce
+    shutil.rmtree(dest_path, ignore_errors=True)
+
+    def copy_tinymce(ex_path):
+        """Copy to location 'tinymce-build' in package."""
+        build_path = os.path.join(ex_path, 'tinymce', 'jscripts', 'tiny_mce')
+        shutil.copytree(build_path, dest_path)
+
+    download(version, copy_tinymce)

Added: hurry.tinymce/trunk/src/hurry/tinymce/tests.py
===================================================================
--- hurry.tinymce/trunk/src/hurry/tinymce/tests.py	                        (rev 0)
+++ hurry.tinymce/trunk/src/hurry/tinymce/tests.py	2008-10-09 16:21:01 UTC (rev 91919)
@@ -0,0 +1,14 @@
+import unittest, doctest
+
+def test_suite():
+    globs = {}
+    optionflags = doctest.NORMALIZE_WHITESPACE | doctest.ELLIPSIS
+
+    suite = unittest.TestSuite()
+    
+    suite.addTest(doctest.DocFileSuite(
+        'README.txt',
+        globs=globs,
+        optionflags=optionflags))
+    return suite
+

Added: hurry.tinymce/trunk/src/hurry/tinymce/tinymce.py
===================================================================
--- hurry.tinymce/trunk/src/hurry/tinymce/tinymce.py	                        (rev 0)
+++ hurry.tinymce/trunk/src/hurry/tinymce/tinymce.py	2008-10-09 16:21:01 UTC (rev 91919)
@@ -0,0 +1,7 @@
+from hurry.resource import Library, ResourceInclusion
+
+tinymce_lib = Library('tinymce')
+
+tinymce = ResourceInclusion(tinymce_lib, 'tiny_mce_src.js',
+                            minified='tiny_mce.js')
+



More information about the Checkins mailing list