… it would be Bagger 288.
[yframe url=’http://www.youtube.com/watch?v=azEvfD4C6ow&feature=player_embedded’]
The use cases are almost the same.
Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+
… it would be Bagger 288.
[yframe url=’http://www.youtube.com/watch?v=azEvfD4C6ow&feature=player_embedded’]
The use cases are almost the same.
Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+
Here is described a way to include Javascript for certain widgets or certain pages only in Plone CMS
Dexterity content types can use Dexterity behaviors control panel to add new behaviors on your content types. One such a behavior is to include certain Javascript files when these content types are viewed or edited.
The example here shows how to include a Javascript if the following conditions are met
Note: There is no easy way currently directly check whether a certain widget and widget mode is active on a particular view. Thus, we do some assumptions and checks manually if we are on “edit” view.
Plone portal_javascripts is a site specific registry. Available javascripts are kept in the site database, so that you can fine-tune their settings on-line, through-the-web through Zope application server management interface. When Plone add-on is installed, a subsystem called GenericSetup can import database setting changes on XML based profiles. There is a tool called portal_setup which allows you easily to export, import or put parts of this setting updates to your add-on installer.
We import Javascript files to portal_javascripts using GenericSetup file jsregistry.xml:
<?xml version="1.0"?> <object name="portal_javascripts"> <!-- View mode javascript --> <javascript id="++resource++yourcompany.app/integration.js" authenticated="False" cacheable="True" compression="safe" cookable="True" enabled="True" expression="context/@@integration_javascript" inline="False" /> <!-- Edit mode javascript --> <javascript id="++resource++yourcompany.app/integration.edit.js" authenticated="False" cacheable="True" compression="safe" cookable="True" enabled="True" expression="context/@@edit_integration_javascript" inline="False" /> </object>
Then we create the special conditions using Grok views and Python code. This code would go to yourcompany/app/browser/views.py Python module:
# Zope imports from Acquisition import aq_inner from zope.interface import Interface from five import grok from zope.component import getMultiAdapter from yourcompany.app.behavior.lsmintegration import IYourWidgetIntegration class IntegrationJavascriptHelper(grok.CodeView): """ Used by portal_javascripts to determine when to include our custom Javascript integration code. This view is referred from the expression in jsregistry.xml. """ # The view is available on every content item type grok.context(Interface) grok.name("integration_javascript") def render(self): """ Check if we are in a specific content type. Check that the Dexerity content type has a certain behavior set on it through Dexterity settings panel. Alternative, just check for a marker interface here. """ # render() methot is a the only traversable # Grok CodeView method. It can be used for rendering # HTML code, but also for utility views # to return raw Python data try: # Check if a Dexterity behavior is available on the current context object # - if it is not, behavior adapter will raise TypeError avail = IYourWidgetIntegration(self.context) except TypeError: return False # If called directly from the browser like # http://localhost:8080/Plone/integration_javascript # will return HTTP 204 No Content return True class EditModeIntegrationJavascriptHelper(IntegrationJavascriptHelper): """ Used by portal_javascripts to determine when to include our custom Javascript integration code *on edit pages* only. Subclass the existing checked and add more limiting conditions. """ grok.name("edit_integration_javascript") def render(self): """ @return True: If this template is rendered "Edit view" of the item """ if not IntegrationJavascriptHelper.render(self): # We are not even on the correct content type return False # This is a hacked together as Plone does not provide a real # mechanism to separate edit views to other views. # We simply check if the current view URI ends with "edit" path = self.request.get("PATH_INFO", "") if path.endswith("/edit") or path.endswith("/@@edit"): return True return False
Question: how much Grok is included with Plone 4.1: at least parts of its are, but would this example work with vanilla Plone 4.01 without including five.grok manually as a dependency?
Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+
This is a short tutorial how to mobilize your Plone web site using Web and Mobile CMS and apply some custom theming on it. Web and Mobile 1.0 has now been independently deployed by various organizations in Switzerland, Netherlands, USA and German.
If you get stuck in a point please ask questions on the gomobile-dev discussion forum.
This tutorial is little rough on details, but links to authoritative sources for more in-depth information. I hope to further polish this tutorial based on the user comments.
Note: currently the installation process does not work from China, as the local access to code.google.com and appspot.com servers is limited.
Install Web and Mobile to your buildout.
Possibly fight with lxml to get it running.
Create a Plone site (if you don’t already have an existing site).
Then install following add-ons, in this order in the site control panel
Now your website should have a basic mobile experience with a default Web and Mobile theme.
You can visit the mobile version of your site by putting a m.localhost domain in your /etc/hosts file. You don’t need a mobile browser, as the mobile site is detected by a domain name by default. Your mobile site should be available from http://m.localhost:8080/Plone
Install the ZopeSkel based mobile theme template to your buildout.cfg.
parts = ... paster [paster] recipe = zc.recipe.egg eggs = PasteScript gomobile.templates ${instance:eggs}
Rerun buildout to enable bin/paster command:
bin/buildout
Create a theme skeleton using paster. We use a Python package named gomobiletheme.yourcompanyname here as an example name for the theme package. If it asks for “override files” answer yes:
cd src ../bin/paster create -t gomobile_theme gomobiletheme.yourcompanyname
List your new theme egg in buildout in develop-eggs. (Alternatively: use mr.developer if you indent to put it directly under version control.)
eggs = gomobiletheme.yourcompany develop = src/gomobiletheme.yourcompan
Rerun buildout.
Test the theme installs and works. Restart Plone and install your theme add-on in the add-on installer.
Navigate to m.localhost again and see that the mobile site still opens.
The generated mobile theme includes five.grok based viewlets.py and view.py files where you are to place
All visual code registered against gomobiletheme.yourcompany.interfaces.IThemeLayer is available and used when your site is browser in mobile mode.
Change the generated gomobile.yourcompany.viewlets.Logo class. In the example below we set it to use logo image file from our web theme.
class Logo(base.Logo): # Change logo URI here def getLogoPath(self): return "++resource++plonetheme.yourwebtheme.images/logo.png"
If you are using logo from the web theme resource directory, make sure <resourceDirectory> in theme browser/configure.zcml does not have <resourceDirectory layer=””> set. If it’s set the resource directory is not activate for the mobile theme and the mobile theme cannot access the logo file.
The logo image is resized automatically by gomobiletheme.basic.viewlets.Logo base class for different mobile screen resolutions.
In viewlets.py add:
class FooterText(base.FooterText): """ Free-form HTML text at the end of the page """ # the presence of this viewlet includes a new page template # and overrides default footertext
Then include the page template itself. Add new file to the your theme package templates/footertext.pt:
<div id="footer-text" i18n:domain="isleofback.app"> Your text goes here. </div>
Mobile theme static CSS and Javascript resources are provided by five.grok static folder mechanism. Transformations document provides some in-sight for different CSS files used by different handsets: common.css is served to all mobile phones, highend.css for Webkit and Firefox based browsers, lowend.css for limited browsers.
The default gomobiletheme.basic CSS resources are included by default with the theme skeleton. You need override only the CSS rules you specifically want to change for your own theme. This can be done by adding rules to common.css, lowend.css and highend.css files which you can find from the generated theme package.
Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+
-*- macyet takes the stick and beats base_edit -*- MJ hands macyet a baseball bat. -*- lewellyn hands macyet an I-beam -*- moo-_- hands macyet a catepillar -*- macyet tries with a babynuke
Subscribe to RSS feed Follow me on Twitter Follow me on Facebook Follow me Google+