{ "info": { "author": "Ilshad Habibullin", "author_email": "astoon.net at gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Framework :: Zope3", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License (GPL)", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP :: Site Management" ], "description": "============\r\nice.adverlet\r\n============\r\n\r\n.. contents::\r\n\r\nUsage\r\n=====\r\n\r\nThis package - for Zope3 based sites - provides a simple way to edit\r\nany HTML snippet. It includes a WYSIWYG-editor, undo support and\r\nstorage for images.\r\n\r\nExamples of possible uses include: advertisement portlets,\r\nannouncements, footers, frontpages, etc.\r\n\r\nThe package provides the ZCML directive `adverlet` and TALES\r\nexpression `adverlet`.\r\n\r\nTo use the package follow these 6 simple steps:\r\n\r\n1) Include the package:\r\n\r\n <include package=\"ice.adverlet\" file=\"meta.zcml\" />\r\n <include package=\"ice.adverlet\" />\r\n\r\n2) In the ZCML configuration file define all your adverlets, for\r\nexample:\r\n\r\n <ice:adverlet name=\"top\" />\r\n\r\n <ice:adverlet\r\n name=\"bottom\"\r\n description=\"This is an advertisement at the bottom of the frontpage\"\r\n />\r\n\r\n <ice:adverlet\r\n name=\"footer\"\r\n description=\"Footer of the site\"\r\n default=\"default-footer\"\r\n wysiwyg=\"False\"\r\n />\r\n\r\nNotice:\r\n`name` - Required.\r\n`description` - Not required.\r\n`default` - Not required, it is name of browser view, registered b\r\nzcml-directives like browser:page.\r\n`wysiwyg' - Not required. Defines usage rich-text editor by default for this\r\nadverlet in management UI. User (admin) can change this in the form.\r\nDefault value is True.\r\n\r\n3) Write `adverlet` TALES expression in to your skin:\r\n\r\n <div tal:content=\"structure adverlet:top\" />\r\n\r\nwhere `top` is name of the adverlet.\r\n\r\n4) The package provides a view to manage all registered adverlets.\r\nThis view may be called by a special content provider\r\nin any page::\r\n\r\n <div tal:content=\"structure provider:ice.adverlet.manage\" />\r\n\r\n5) This content provider has the permission \"ice.adverlet.Manage\".\r\nTherefore, you need to grant this permission to a role in your\r\nproject, and allow \"undo\" for this user, for example::\r\n\r\n<grant permission=\"ice.adverlet.Manage\" role=\"foo.blah.Blah\" />\r\n<grant permission=\"zope.UndoOwnTransactions\" role=\"foo.blah.Blah\" />\r\n\r\n6) Install and register 2 local utilities:\r\n\r\n 1. Factory - ice.adverlet.storage.SourceStorage;\r\n Interface - ice.adverlet.interfaces.ISourceStorage;\r\n Name - empty.\r\n (into Local Site Manager)\r\n\r\n 2. Factory - ice.adverlet.storage.FileStorage;\r\n Interface - ice.adverlet.interfaces.IFileStorage;\r\n Name - empty.\r\n (into local site)\r\n\r\nThat's it.\r\n\r\nN.B. You can define your own templates for management UI.\r\nTo do this, take a look at ice/adverlet/browser/template\r\nand write your own adapters in your project for your own templates.\r\n\r\nYou will need to:\r\n\r\n- Change @adapter(IContentProvider, IDefaultBrowserLayer)\r\n to @adapter(IContentProvider, IMyCustomLayer)\r\n- Register this adapter with the same name\r\n (take a look at ice/adverlet/browser/configure.zcml,\r\n section <!-- templates -->.)\r\n\r\nN.B. Also, you can use default templates but not default CSS for\r\nmanagement UI. For this, look in ZMI `Settings` form for\r\nice.adverlet.storage.SourceStorage local utility or define attribute\r\n`defaultCSS=False` in your install-tool code.\r\n\r\nTests\r\n=====\r\n\r\n >>> import zope.interface\r\n >>> import zope.component\r\n\r\nLet's register a default view for one of our adverlets::\r\n\r\n >>> import os, tempfile\r\n >>> temp_dir = tempfile.mkdtemp()\r\n >>> templateFileName = os.path.join(temp_dir, 'default_footer.pt')\r\n >>> open(templateFileName, 'w').write('''\r\n ... <h1>Default Footer</h1>\r\n ... ''')\r\n\r\n >>> from zope.publisher.interfaces import browser\r\n >>> from zope.app.pagetemplate import simpleviewclass\r\n >>> DefaultViewClass = simpleviewclass.SimpleViewClass(\r\n ... templateFileName, name='default-footer')\r\n\r\n >>> zope.component.provideAdapter(\r\n ... DefaultViewClass,\r\n ... (zope.interface.Interface, browser.IDefaultBrowserLayer),\r\n ... zope.interface.Interface,\r\n ...\t name='default-footer'\r\n ...\t )\r\n\r\nLet's register a few advertlets::\r\n\r\n >>> from zope.configuration import xmlconfig\r\n >>> import ice.adverlet\r\n >>> context = xmlconfig.file('meta.zcml', ice.adverlet)\r\n\r\n >>> context = xmlconfig.string('''\r\n ... <configure\r\n ...\t xmlns=\"http://namespaces.zope.org/zope\"\r\n ...\t xmlns:ice=\"http://namespaces.zope.org/ice\"\r\n ...\t i18n_domain=\"test\">\r\n ...\r\n ...\t <ice:adverlet\r\n ...\t name=\"frontpage\"\r\n ...\t\t />\r\n ...\r\n ...\t <ice:adverlet\r\n ... name=\"footer\"\r\n ...\t\t description=\"Footer of the site\"\r\n ...\t\t default=\"default-footer\"\r\n ...\t\t />\r\n ...\r\n ... </configure>''', context)\r\n\r\nNow we can try to call these adverlets in any view::\r\n\r\n >>> templateFileName = os.path.join(temp_dir, 'template.pt')\r\n >>> open(templateFileName, 'w').write('''\r\n ... <html>\r\n ... <body>\r\n ... <div tal:content=\"structure adverlet:frontpage\" />\r\n ... <div tal:content=\"structure adverlet:footer\" />\r\n ... </body>\r\n ... </html>\r\n ... ''')\r\n\r\n >>> PageClass = simpleviewclass.SimpleViewClass(\r\n ... templateFileName, name='index.html')\r\n\r\n >>> zope.component.provideAdapter(\r\n ... PageClass,\r\n ... (zope.interface.Interface, browser.IDefaultBrowserLayer),\r\n ... zope.interface.Interface,\r\n ...\t name='index.html'\r\n ...\t )\r\n\r\n >>> from zope.publisher.browser import TestRequest\r\n >>> request = TestRequest()\r\n\r\n >>> class Content(object):\r\n ... zope.interface.implements(zope.interface.Interface)\r\n >>> content = Content()\r\n\r\n >>> view = zope.component.getMultiAdapter(\r\n ... (content, request), name='index.html')\r\n\r\n >>> print view().strip()\r\n <html>\r\n <body>\r\n <div></div>\r\n <div>\r\n <h1>Default Footer</h1>\r\n </div>\r\n </body>\r\n </html>\r\n <BLANKLINE>\r\n\r\nTo edit adverlets store HTML sources::\r\n\r\n >>> from ice.adverlet.storage import SourceStorage\r\n >>> from ice.adverlet.interfaces import ISourceStorage\r\n\r\n >>> storage = SourceStorage()\r\n >>> ISourceStorage.providedBy(storage)\r\n True\r\n\r\n >>> storage.sources['frontpage'] = u'''\r\n ... <h2><a\r\nhref=\"http://launchpad.net>Launchpad</a></h2>\r\n ...\t '''\r\n >>> storage.sources['footer'] = u'''\r\n ...\t <h3><a href=\"http://ohloh.net>OhLoh</a></h3>\r\n ...\t '''\r\n\r\nand register storage as utility::\r\n\r\n >>> zope.component.provideUtility(storage, ISourceStorage)\r\n\r\nLet's check the test view now::\r\n\r\n >>> print view().strip()\r\n <html>\r\n <body>\r\n <div>\r\n <h2><a href=\"http://launchpad.net>Launchpad</a></h2>\r\n </div>\r\n <div>\r\n <h3><a href=\"http://ohloh.net>OhLoh</a></h3>\r\n </div>\r\n </body>\r\n </html>\r\n <BLANKLINE>\r\n\r\nThen we will test image storage and image wrapper.\r\nTo do this, let's register storage for the files::\r\n\r\n >>> from ice.adverlet.storage import FileStorage\r\n >>> from ice.adverlet.interfaces import IFileStorage\r\n\r\n >>> files = FileStorage()\r\n >>> IFileStorage.providedBy(files)\r\n True\r\n\r\n >>> zope.component.provideUtility(files, IFileStorage)\r\n\r\nAnd let's try to use the image wrapper to store images in this storage::\r\n\r\n >>> from ice.adverlet.image import ImageWrapper\r\n >>> from ice.adverlet.interfaces import IImageWrapper\r\n\r\n >>> wrapper = ImageWrapper()\r\n >>> IImageWrapper.providedBy(wrapper)\r\n True\r\n\r\nRegister adapter for DublinCore::\r\n\r\n >>> from zope.dublincore.annotatableadapter import ZDCAnnotatableAdapter\r\n >>> from zope.dublincore.interfaces import IZopeDublinCore\r\n >>> from zope.annotation.interfaces import IAttributeAnnotatable\r\n >>> from zope.app.file.image import Image\r\n\r\n >>> zope.interface.classImplements(Image, IAttributeAnnotatable)\r\n\r\n >>> zope.component.provideAdapter(\r\n ... factory = ZDCAnnotatableAdapter,\r\n ...\t provides = IZopeDublinCore,\r\n ...\t adapts = (IAttributeAnnotatable,)\r\n ...\t )\r\n\r\nWe use test image::\r\n\r\n >>> from ice.adverlet.tests.tests import zptlogo\r\n >>> wrapper.data = zptlogo\r\n >>> wrapper.description = u'Logo image'\r\n\r\nNow let's check file storage::\r\n\r\n >>> [key for key in files.keys()]\r\n [u'Image']\r\n\r\n >>> [IZopeDublinCore(file).title for file in files.values()]\r\n [u'Logo image']\r\n\r\nNote that in management UI we use named global utilities IAdverlet\r\nfor store HTML instead of using the storage directly. Let's test\r\nthis feature::\r\n\r\n >>> storage.sources['frontpage']\r\n u'\\n <h2><a\r\nhref=\"http://launchpad.net>Launchpad</a></h2>\\n '\r\n\r\n >>> from ice.adverlet.interfaces import IAdverlet\r\n >>> frontpage = zope.component.getUtility(IAdverlet, 'frontpage')\r\n\r\n >>> frontpage.source = '<h2>Hi there</h2>'\r\n\r\n >>> storage.sources['frontpage']\r\n '<h2>Hi there</h2>'\r\n\r\nAnd let's check adverlet again::\r\n\r\n >>> frontpage.source\r\n '<h2>Hi there</h2>'\r\n\r\nWe provide event for modify sources::\r\n\r\n >>> events = []\r\n >>> zope.component.provideHandler(events.append, (None, ))\r\n\r\n >>> frontpage.source = '''<h2>Welcome!\r\n ... You are here.</h2>\r\n ...\t\t\t '''\r\n\r\n >>> events\r\n [<ice.adverlet.events.SourceModifiedEvent instance at ...>]\r\n\r\nThe event holds the name of the global `adverlet` utility::\r\n\r\n >>> events[0].name\r\n u'frontpage'\r\n\r\nLook up test browser class again::\r\n\r\n >>> print view().strip()\r\n <html>\r\n <body>\r\n <div><h2>Welcome!\r\n You are here.</h2>\r\n </div>\r\n <div>\r\n <h3><a href=\"http://ohloh.net>OhLoh</a></h3>\r\n </div>\r\n </body>\r\n </html>\r\n <BLANKLINE>\r\n\r\nLet's test `newlines` parameter::\r\n\r\n >>> frontpage.newlines = True\r\n\r\n >>> print view().strip()\r\n <html>\r\n <body>\r\n <div><h2>Welcome!\r\n <br /> You are here.</h2>\r\n <br /> <br /></div>\r\n <div>\r\n <h3><a href=\"http://ohloh.net>OhLoh</a></h3>\r\n </div>\r\n </body>\r\n </html>\r\n <BLANKLINE>\r\n\r\nCleanup::\r\n\r\n >>> import shutil\r\n >>> shutil.rmtree(temp_dir)\r\n\r\n\r\n=========\r\nDemo site\r\n=========\r\n\r\nTo look the demo follow these steps:\r\n\r\n1) In setup.py file your project write:\r\n\r\n install_requires = [...'ice.adverlet',..]\r\n\r\n2) In configure.zcml of your project write:\r\n\r\n <include package=\"ice.adverlet.demo\" />\r\n\r\n3) Run zope instance, add 'DEMO SITE' in ZMI, go to thi site, look 'DEMO'\r\n\r\nThe demo site has defined 4 adverlets: header, main, footer, sidebar.\r\nThere are default views for `header`, 'main' and `footer` adverlets\r\n(take a look at demo/app.zcml).\r\nAlso, there are user: login - `demo`, password - `demo`.\r\n\r\nOther way: download tar-archive from\r\nhttp://http://pypi.python.org/pypi/ice.adverlet\r\nor http://launchpad.net/ice.adverlet/\r\nand run buildout.\r\n\r\n\r\n=======\r\nCHANGES\r\n=======\r\n\r\nVersion 0.2.3 (2008-12-22)\r\n--------------------------\r\n\r\n- fixed bug in images container name chooser to work in KGS\r\n\r\n\r\nVersion 0.2.2 (2008-08-04)\r\n--------------------------\r\n\r\n- more convenience adverlets-listing\r\n- changes in default style sheets\r\n\r\nVersion 0.2.1 (2008-08-01)\r\n--------------------------\r\n\r\n- form status\r\n\r\n\r\nVersion 0.2.0 (2008-07-25)\r\n--------------------------\r\n\r\n- two modes: rich-text editor or simple textarea\r\n- 'render newlines' field for simple mode\r\n- `use default CSS for management UI` system parameter\r\n- `upload` form and listing of images now is in same URL\r\n- correct redirects in the form (not in the action handler, but\r\nin `update` method).\r\n- removed `Use Default View` column from management UI\r\n- demo principal instead zope.Anonymous for using demo\r\nin zopejroject or grokproject\r\n\r\nBackward compatibility: yes, thanks to FieldProperty.\r\n\r\n\r\nVersion 0.1.1 (2008-07-19)\r\n--------------------------\r\n\r\n- Correct egg-info\r\n\r\n\r\nVersion 0.1.0 (2008-07-19)\r\n--------------------------\r\n\r\n- Initial release", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://launchpad.net/ice.adverlet", "keywords": "zope3 ttw views", "license": "GPL v.3", "maintainer": "", "maintainer_email": "", "name": "ice.adverlet", "package_url": "https://pypi.org/project/ice.adverlet/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/ice.adverlet/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://launchpad.net/ice.adverlet" }, "release_url": "https://pypi.org/project/ice.adverlet/0.2.3/", "requires_dist": null, "requires_python": null, "summary": "Simple way to edit any HTML snippet", "version": "0.2.3" }, "last_serial": 81541, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "e3ecd36c2067818415f7871113f0aedf", "sha256": "609057141c06650e1be6abda6fb3bb48f5c0764c0c68f60db9a540caf2f9a881" }, "downloads": -1, "filename": "ice.adverlet-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e3ecd36c2067818415f7871113f0aedf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 38375, "upload_time": "2008-07-19T16:25:18", "url": "https://files.pythonhosted.org/packages/c9/ec/318cc292528780c5f56b8e75151c0832fb8fa694ad5b6753f1e4f9645015/ice.adverlet-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "5dce88f38aba468fa381c9510e43e7cb", "sha256": "b773c1fd43aa58ad4a20e144d20396cc166ea2ca6f8a8cc010e90807bc3c5812" }, "downloads": -1, "filename": "ice.adverlet-0.1.1.tar.gz", "has_sig": false, "md5_digest": "5dce88f38aba468fa381c9510e43e7cb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 38424, "upload_time": "2008-07-19T17:05:23", "url": "https://files.pythonhosted.org/packages/b3/5a/984f81186e606741a30f899d872e7874cfebc91af52c8a0198b515aeb128/ice.adverlet-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "fe96178056c47fde7c44675907a2adff", "sha256": "0377eb8a651c1f81bf6486d1f6ebf86cd427e6857f2718f9440551348ce8af5f" }, "downloads": -1, "filename": "ice.adverlet-0.2.0.tar.gz", "has_sig": false, "md5_digest": "fe96178056c47fde7c44675907a2adff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 37486, "upload_time": "2008-07-25T19:30:27", "url": "https://files.pythonhosted.org/packages/70/aa/c286cff4e6e6875a58c9f155a31cabc1b2a79254f81b5161a9e6037ccb5b/ice.adverlet-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "8c5811d502257ba1c59d9a7cba958ea9", "sha256": "7b4bb72ba556ef8e8b35d9e0b4c73f7d2b35627277907f85c3961abdfb13c714" }, "downloads": -1, "filename": "ice.adverlet-0.2.1.tar.gz", "has_sig": false, "md5_digest": "8c5811d502257ba1c59d9a7cba958ea9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 37058, "upload_time": "2008-08-01T10:14:33", "url": "https://files.pythonhosted.org/packages/c4/24/e346b9dee8e5b265eca821c1af27f247e44584949de10b27b5945b326a28/ice.adverlet-0.2.1.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "dd6968093368f143e8930c025b8546cc", "sha256": "ab2821462485ad414e4df3a7689de252226591cecf8d9829820b5d0660a92059" }, "downloads": -1, "filename": "ice.adverlet-0.2.2.tar.gz", "has_sig": false, "md5_digest": "dd6968093368f143e8930c025b8546cc", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 37668, "upload_time": "2008-08-04T09:11:16", "url": "https://files.pythonhosted.org/packages/3a/c6/cfc61b0bed914e432e478eac942683e2a3876714546dc73ed9f35f1485bc/ice.adverlet-0.2.2.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "58cbd74be0bb3ee5d5870425c5cf7f3d", "sha256": "5fbc6632a684ba861dbc851430a349353ed497777f48189124c0e55ba2ea9a5b" }, "downloads": -1, "filename": "ice.adverlet-0.2.3-py2.4.egg", "has_sig": false, "md5_digest": "58cbd74be0bb3ee5d5870425c5cf7f3d", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 70181, "upload_time": "2008-12-22T12:18:23", "url": "https://files.pythonhosted.org/packages/43/87/6d97e7fb1b574ab97a1131202bdfd6c27013949d1d4154373f12452d718b/ice.adverlet-0.2.3-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "bc4d87ac78690d04ddea93423eed860d", "sha256": "10085666a681be32f95ded3c9c5579cec2576c2f2ef560ed10460c3fbc3b65b1" }, "downloads": -1, "filename": "ice.adverlet-0.2.3.tar.gz", "has_sig": false, "md5_digest": "bc4d87ac78690d04ddea93423eed860d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 38589, "upload_time": "2008-12-22T12:18:23", "url": "https://files.pythonhosted.org/packages/bf/11/cfa3775a1ff8f4dfe241dd54105e8b5b618d1154f3016fbb6f03461b2c27/ice.adverlet-0.2.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "58cbd74be0bb3ee5d5870425c5cf7f3d", "sha256": "5fbc6632a684ba861dbc851430a349353ed497777f48189124c0e55ba2ea9a5b" }, "downloads": -1, "filename": "ice.adverlet-0.2.3-py2.4.egg", "has_sig": false, "md5_digest": "58cbd74be0bb3ee5d5870425c5cf7f3d", "packagetype": "bdist_egg", "python_version": "2.4", "requires_python": null, "size": 70181, "upload_time": "2008-12-22T12:18:23", "url": "https://files.pythonhosted.org/packages/43/87/6d97e7fb1b574ab97a1131202bdfd6c27013949d1d4154373f12452d718b/ice.adverlet-0.2.3-py2.4.egg" }, { "comment_text": "", "digests": { "md5": "bc4d87ac78690d04ddea93423eed860d", "sha256": "10085666a681be32f95ded3c9c5579cec2576c2f2ef560ed10460c3fbc3b65b1" }, "downloads": -1, "filename": "ice.adverlet-0.2.3.tar.gz", "has_sig": false, "md5_digest": "bc4d87ac78690d04ddea93423eed860d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 38589, "upload_time": "2008-12-22T12:18:23", "url": "https://files.pythonhosted.org/packages/bf/11/cfa3775a1ff8f4dfe241dd54105e8b5b618d1154f3016fbb6f03461b2c27/ice.adverlet-0.2.3.tar.gz" } ] }