SlideShare a Scribd company logo
1 of 34
Download to read offline
Asko Soukka, asko.soukka@iki.fi
github.com/datakurre
Instant features with
advanced Plone themes
What if. . .
Case of the day: Wall of images
– Resource bundles
– Folderish content type
– Custom view template
for Wall of images with
Masonry.js layout
– Workflow for accepting
anonymous submissions
– Image content type for
anonymous submissions
– Add permission for
restricting anonymous
visitor submission
– Content rule for
thanking about
submission
– Review portlet for listing
the pending submissions
– i18n with l10n message
catalog
Python packages vs. theme?
Python packages
– One package for new JS
– Another for new types
– Customer specific
theming of components
in theme package
– Configuring everything in
policy package
– Restarting Plone
Advanced theme
– Everything in a single
zipped Plone theme
package
– Upload through Plone
control panel or using
npm package
plonetheme-upload
Plone customization features
– Configurable registry
– Structured content types
– Content type behaviors
– State based workflows
– Roles and permissions
– All types of portlets
– Content rules on events
– Restricted templates
– Restricted Python scripts
– Static frontend resources
– Diazo transform rules
– . . .
Plone customization features
– Configurable registry
– Structured content types
– Content type behaviors
– State based workflows
– Roles and permissions
– All types of portlets
– Content rules on events
– Restricted templates
– Restricted Python scripts
– Static frontend resources
– Diazo transform rules
– . . .
Restricted Python?
”Restricted Python provides a safety net for
programmers who don’t know the details of
the Zope/Plone security model.
It is important that you understand that the
safety net is not perfect: it is not adequate to
protect your site from coding by an untrusted
user.”
– Steve McMahon, collectice.ambidexterity README
Issues with Restricted Python
Not only ponies and unicorns...
– API is restrictedTraversed, not imported
– API is not always complete
– API is not always up-to-date
– API is scattered around the ecosystem
– plone.api is not currently designed or available by default
to be called from Restricted Python
Products.DocFinderTab
”through-the-web”
=
technical debt
Advanced Plone themes
– Theme with any supported customizations
– Editable using Plone theme editor
– Rollbacks with Zope2 undo form
– Zip-exportable and importable from theme editor
– Supports ”TTW” and ”file system" development
– Exports can be version controlled
– Exports can be acceptance tested
collective.themesitesetup
Theme activation or update
– Imports GS profile steps
– Updates DX models
– Registers permissions
– Registers l10m messages
– Copies resources into
portal_resources
Theme deactivation
– Imports GS profile steps
– Unregisters added
custom permissions
– Unregisters added
custom l10n messages
After ”TTW” development
– @@export-site-setup
collective.themefragments
View templates: ./fragments/foobar.pt
– Can be injected as fragments using Diazo rules
– Can be configured as a default view for any content type
– Can be used as a local view by setting layout attribute
Python scripts: ./fragments/foobar.py
– Can provide view methods for view templates with
matching base name (tal:define="data view/getData")
Faster iterations
=
More iterations
Let’s get our hands dirty. . .
Creating Wall of images
– Initial configuration was made through Plone site setup
– Configuration was exported into a new theme using the
export view ++theme++.../@@export-site-setup
– Theme was zip-exported from theming control panel
– Content type schemas were exported from Dexterity editor
– Development was completed on a regular file system
buildout using file system resources directory
Structure of Wall of images
./bundles/
./fragments/
./install/types/
./install/workflows/
./install/
./locales/LC_MESSAGES/*/
./models/
./index.html
./manifest.cfg
./preview.png
./rules.xml
./scripts.js
./styles.css
Custom frontend bundles 1/2
./bundles/imagesloaded.pkgd.min.css
./bundles/imagesloaded.pkgd.min.js
./bundles/masonry.pkgd.min.css
./bundles/masonry.pkgd.min.js
(function() { var require, define;
// ...
// AMD packaged JS distributions must be wrapped
// so that Plone require.js define is undefined
// during their load
// ...
})();
Custom frontend bundles 2/2
./install/registry.xml
<records prefix="plone.bundles/imagesloaded-js"
interface="...interfaces.IBundleRegistry">
<value key="depends">plone</value>
<value key="jscompilation">++theme++...js</value>
<value key="csscompilation">++theme++...css</value>
<value key="last_compilation">2017-10-06 00:00:00
</value>
<value key="compile">False</value>
<value key="enabled">True</value>
</records>
Custom content types 1/2
./install/types/wall_of_images.xml
./install/types/wall_of_images_image.xml
./install/types.xml
<object name="portal_types">
<object name="wall_of_images"
meta_type="Dexterity FTI"/>
<object name="wall_of_images_image"
meta_type="Dexterity FTI"/>
</object>
./models/wall_of_images.xml
./models/wall_of_images_image.xml
Custom content types 2/2
<model xmlns:...="..." i18n:domain="plone">
<schema>
<field
name="title" type="zope.schema.TextLine">
<title i18n:translate="">Title</title>
</field>
<field
name="image"
type="plone.namedfile.field.NamedBlobImage">
<title i18n:translate="">Image</title>
</field>
</schema>
</model>
Custom views 1/3
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:...="..."
lang="en"
metal:use-macro=".../macros/master"
i18n:domain="plone">
<body>
<metal:main fill-slot="main">
<metal:content-core define-macro="content-core">
</metal:content-core>
</metal:main>
</body>
</html>
Custom views 2/3
./fragments/wall-of-images.pt
<div class="wall-of-images container-fluid"
tal:define="items context/@@contentlisting">
<tal:image tal:repeat="item items">
<img tal:define="obj item/getObject;
scale_func obj/@@images;
scaled_image python:scale_func.scale('image',
scale='preview')"→
tal:replace="structure
python:scaled_image.tag()"→
tal:on-error="string:error" />
</tal:image>
</div>
Custom views 3/3
./install/types/wall_of_images.xml
...
<property name="default_view">
++themefragment++wall-of-images</property>
<property name="view_methods">
<element value="++themefragment++wall-of-images"/>
</property>
...
Any themefragment can be configured as content object view
by manually setting layout property of the content object.
Custom l10n messages
./locales/fi/LC_MESSAGES/plone.po
./locales/en/LC_MESSAGES/plone.po
msgid "Close from submissions"
msgstr "Sulje osallistuminen"
msgid "Open for submissions"
msgstr "Avaa osallistumiselle"
When theme is developed on file system, normal i18n tools
can be used for messages extraction and catalog
synchronization (e.g. i18ndude).
Custom permissions
./manifest.cfg
[theme:genericsetup]
permissions =
demotheme.addImage Wall of Images: Add Image
./install/types/wall_of_images_image.xml
<object name="wall_of_images_image" ...="..">
...
<property name="add_permission">
demotheme.addImage</property>
...
</object>
Custom workflows
./install/workflows.xml
./install/simple_publication_with_submission_workflow/
./install/wall_of_images_workflow/
<type type_id="wall_of_images">
<bound-workflow workflow_id="..."/>
</type>
<dc-workflow workflow_id="...">
...
<permission>Wall of Images: Add Image</permission>
...
</dc-workflow>
Custom content rules
./install/contentrules.xml
<contentrules>
<rule name="rule-image-thank-you"
title="Thank visitor from submission"
cascading="False"
description="Thanks visitor after submission"
event="...IObjectAddedEvent"
stop-after="False"
enabled="True">...</rule>
<assignment
name="rule-image-thank-you" bubbles="True"
enabled="True" location=""/>
</contentrules>
Final touch with Diazo-bundles
./manifest.cfg
production-css = /++theme++demotheme/styles.css
production-js = /++theme++demotheme/scripts.js
./scripts.js
jQuery(function($) {
$('.wall-of-images').imagesLoaded(function() {
$('.wall-of-images').masonry({
itemSelector: 'img',
percentPosition: true
});
});
});
Questions?Questions?
github.com/datakurre/ploneconf2017github.com/datakurre/ploneconf2017
What about Mosaic?
– Theme site setup can populate Mosaic site and content
layout resource directories from theme
– Theme fragment tile for Plone Mosaic can render selected
fragment with
– fragment-specific readable title
– fragment-specific XML schema based configuration form
– fragment-specific view permission
– fragment-specific caching rule
What about Webpack?
– Bundles in theme can be built with Webpack
– Diazo bundle in theme can be built with Webpack
– All frontend resources can be built with Webpack
– plonetheme.webpacktemplate
– plonetheme-webpack-plugin
– plonetheme-upload
Bonus: Custom JS widgets
./models/my_content_type.xml
...
<field name="focuspoint"
type="zope.schema.BytesLine">
<form:widget
type="z3c.form.browser.text.TextFieldWidget">
<klass>text-widget pat-focuspoint-widget</klass>
</form:widget>
<title i18n:translate="">Image focus point</title>
<required>false</required>
</field>
...

More Related Content

What's hot

HTML5 Server Sent Events/JSF JAX 2011 Conference
HTML5 Server Sent Events/JSF  JAX 2011 ConferenceHTML5 Server Sent Events/JSF  JAX 2011 Conference
HTML5 Server Sent Events/JSF JAX 2011 Conference
Roger Kitain
 
Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022
NAVER D2
 

What's hot (12)

HTML5 Server Sent Events/JSF JAX 2011 Conference
HTML5 Server Sent Events/JSF  JAX 2011 ConferenceHTML5 Server Sent Events/JSF  JAX 2011 Conference
HTML5 Server Sent Events/JSF JAX 2011 Conference
 
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry PiGrâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
Grâce aux tags Varnish, j'ai switché ma prod sur Raspberry Pi
 
Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022Deview 2013 mobile browser internals and trends_20131022
Deview 2013 mobile browser internals and trends_20131022
 
JWT - Sécurisez vos APIs
JWT - Sécurisez vos APIsJWT - Sécurisez vos APIs
JWT - Sécurisez vos APIs
 
Rendering engine
Rendering engineRendering engine
Rendering engine
 
What is new in Notes & Domino Deleopment V10.x
What is new in Notes & Domino Deleopment V10.xWhat is new in Notes & Domino Deleopment V10.x
What is new in Notes & Domino Deleopment V10.x
 
JEE Programming - 01 Introduction
JEE Programming - 01 IntroductionJEE Programming - 01 Introduction
JEE Programming - 01 Introduction
 
Spring5 hibernate5 security5 lab step by step
Spring5 hibernate5 security5 lab step by stepSpring5 hibernate5 security5 lab step by step
Spring5 hibernate5 security5 lab step by step
 
Utiliser Webpack dans une application Symfony
Utiliser Webpack dans une application SymfonyUtiliser Webpack dans une application Symfony
Utiliser Webpack dans une application Symfony
 
Zend_Tool: Practical use and Extending
Zend_Tool: Practical use and ExtendingZend_Tool: Practical use and Extending
Zend_Tool: Practical use and Extending
 
WebKit and Blink: open development powering the HTML5 revolution
WebKit and Blink: open development powering the HTML5 revolutionWebKit and Blink: open development powering the HTML5 revolution
WebKit and Blink: open development powering the HTML5 revolution
 
Dandelion 0.10.0
Dandelion 0.10.0Dandelion 0.10.0
Dandelion 0.10.0
 

Similar to Building instant features with advanced Plone themes

Similar to Building instant features with advanced Plone themes (20)

Speed up your asset imports for big projects - Unite Copenhagen 2019
Speed up your asset imports for big projects - Unite Copenhagen 2019Speed up your asset imports for big projects - Unite Copenhagen 2019
Speed up your asset imports for big projects - Unite Copenhagen 2019
 
Présentation du générateur de site statique eleventy
Présentation du générateur de site statique eleventyPrésentation du générateur de site statique eleventy
Présentation du générateur de site statique eleventy
 
Spring Roo Add-On Development & Distribution
Spring Roo Add-On Development & DistributionSpring Roo Add-On Development & Distribution
Spring Roo Add-On Development & Distribution
 
Pragmatische Plone Projekte
Pragmatische Plone ProjektePragmatische Plone Projekte
Pragmatische Plone Projekte
 
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
[Patel] SPFx: An ISV Insight into latest Microsoft's customization model
 
New in Plone 3.3. What to expect from Plone 4
New in Plone 3.3. What to expect from Plone 4New in Plone 3.3. What to expect from Plone 4
New in Plone 3.3. What to expect from Plone 4
 
Pragmatic plone projects
Pragmatic plone projectsPragmatic plone projects
Pragmatic plone projects
 
Phing
PhingPhing
Phing
 
Build Automation of PHP Applications
Build Automation of PHP ApplicationsBuild Automation of PHP Applications
Build Automation of PHP Applications
 
World Plone Day 2012 Taipei
World Plone Day 2012 TaipeiWorld Plone Day 2012 Taipei
World Plone Day 2012 Taipei
 
Resource registries plone conf 2014
Resource registries plone conf 2014Resource registries plone conf 2014
Resource registries plone conf 2014
 
itPage LDC 09 Presentation
itPage LDC 09 PresentationitPage LDC 09 Presentation
itPage LDC 09 Presentation
 
Magento2 Basics for Frontend Development
Magento2 Basics for Frontend DevelopmentMagento2 Basics for Frontend Development
Magento2 Basics for Frontend Development
 
Magento2 frontend development
Magento2   frontend developmentMagento2   frontend development
Magento2 frontend development
 
Magento 2 View Layer Evolution
Magento 2 View Layer EvolutionMagento 2 View Layer Evolution
Magento 2 View Layer Evolution
 
ADF in action 1.2
ADF in action 1.2ADF in action 1.2
ADF in action 1.2
 
Magento 1.x to Magento 2 Code Migration Tools
Magento 1.x to Magento 2 Code Migration ToolsMagento 1.x to Magento 2 Code Migration Tools
Magento 1.x to Magento 2 Code Migration Tools
 
Social Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes DemystifiedSocial Connections VI — IBM Connections Extensions and Themes Demystified
Social Connections VI — IBM Connections Extensions and Themes Demystified
 
Build Python CMS The Plone Way
Build Python CMS The Plone WayBuild Python CMS The Plone Way
Build Python CMS The Plone Way
 
KubeCon 2017: Kubernetes from Dev to Prod
KubeCon 2017: Kubernetes from Dev to ProdKubeCon 2017: Kubernetes from Dev to Prod
KubeCon 2017: Kubernetes from Dev to Prod
 

More from Asko Soukka

Plone, rabbit mq and messaging that just works
Plone, rabbit mq and messaging that just worksPlone, rabbit mq and messaging that just works
Plone, rabbit mq and messaging that just works
Asko Soukka
 

More from Asko Soukka (9)

Bird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystemBird eye's view on Camunda open source ecosystem
Bird eye's view on Camunda open source ecosystem
 
Embedding BPMN-driven business processes into Plone
Embedding BPMN-driven business processes into PloneEmbedding BPMN-driven business processes into Plone
Embedding BPMN-driven business processes into Plone
 
Plone and Volto in a Jamstack project
Plone and Volto in a Jamstack projectPlone and Volto in a Jamstack project
Plone and Volto in a Jamstack project
 
Deploying Plone and Volto, the Hard Way
Deploying Plone and Volto, the Hard WayDeploying Plone and Volto, the Hard Way
Deploying Plone and Volto, the Hard Way
 
How Plone Excels in GatsbyJS Content Mesh
How Plone Excels in GatsbyJS Content MeshHow Plone Excels in GatsbyJS Content Mesh
How Plone Excels in GatsbyJS Content Mesh
 
ZServer Reloaded with HTTP/2 and WebSocket Support
ZServer Reloaded with HTTP/2 and WebSocket SupportZServer Reloaded with HTTP/2 and WebSocket Support
ZServer Reloaded with HTTP/2 and WebSocket Support
 
Nix for Python developers
Nix for Python developersNix for Python developers
Nix for Python developers
 
Acceptance testing plone sites and add ons with robot framework and selenium
Acceptance testing plone sites and add ons with robot framework and seleniumAcceptance testing plone sites and add ons with robot framework and selenium
Acceptance testing plone sites and add ons with robot framework and selenium
 
Plone, rabbit mq and messaging that just works
Plone, rabbit mq and messaging that just worksPlone, rabbit mq and messaging that just works
Plone, rabbit mq and messaging that just works
 

Recently uploaded

%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Recently uploaded (20)

Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdfThe Top App Development Trends Shaping the Industry in 2024-25 .pdf
The Top App Development Trends Shaping the Industry in 2024-25 .pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 

Building instant features with advanced Plone themes

  • 3. Case of the day: Wall of images – Resource bundles – Folderish content type – Custom view template for Wall of images with Masonry.js layout – Workflow for accepting anonymous submissions – Image content type for anonymous submissions – Add permission for restricting anonymous visitor submission – Content rule for thanking about submission – Review portlet for listing the pending submissions – i18n with l10n message catalog
  • 4. Python packages vs. theme? Python packages – One package for new JS – Another for new types – Customer specific theming of components in theme package – Configuring everything in policy package – Restarting Plone Advanced theme – Everything in a single zipped Plone theme package – Upload through Plone control panel or using npm package plonetheme-upload
  • 5. Plone customization features – Configurable registry – Structured content types – Content type behaviors – State based workflows – Roles and permissions – All types of portlets – Content rules on events – Restricted templates – Restricted Python scripts – Static frontend resources – Diazo transform rules – . . .
  • 6. Plone customization features – Configurable registry – Structured content types – Content type behaviors – State based workflows – Roles and permissions – All types of portlets – Content rules on events – Restricted templates – Restricted Python scripts – Static frontend resources – Diazo transform rules – . . .
  • 7. Restricted Python? ”Restricted Python provides a safety net for programmers who don’t know the details of the Zope/Plone security model. It is important that you understand that the safety net is not perfect: it is not adequate to protect your site from coding by an untrusted user.” – Steve McMahon, collectice.ambidexterity README
  • 8. Issues with Restricted Python Not only ponies and unicorns... – API is restrictedTraversed, not imported – API is not always complete – API is not always up-to-date – API is scattered around the ecosystem – plone.api is not currently designed or available by default to be called from Restricted Python
  • 9.
  • 12. Advanced Plone themes – Theme with any supported customizations – Editable using Plone theme editor – Rollbacks with Zope2 undo form – Zip-exportable and importable from theme editor – Supports ”TTW” and ”file system" development – Exports can be version controlled – Exports can be acceptance tested
  • 13. collective.themesitesetup Theme activation or update – Imports GS profile steps – Updates DX models – Registers permissions – Registers l10m messages – Copies resources into portal_resources Theme deactivation – Imports GS profile steps – Unregisters added custom permissions – Unregisters added custom l10n messages After ”TTW” development – @@export-site-setup
  • 14. collective.themefragments View templates: ./fragments/foobar.pt – Can be injected as fragments using Diazo rules – Can be configured as a default view for any content type – Can be used as a local view by setting layout attribute Python scripts: ./fragments/foobar.py – Can provide view methods for view templates with matching base name (tal:define="data view/getData")
  • 16. Let’s get our hands dirty. . .
  • 17. Creating Wall of images – Initial configuration was made through Plone site setup – Configuration was exported into a new theme using the export view ++theme++.../@@export-site-setup – Theme was zip-exported from theming control panel – Content type schemas were exported from Dexterity editor – Development was completed on a regular file system buildout using file system resources directory
  • 18. Structure of Wall of images ./bundles/ ./fragments/ ./install/types/ ./install/workflows/ ./install/ ./locales/LC_MESSAGES/*/ ./models/ ./index.html ./manifest.cfg ./preview.png ./rules.xml ./scripts.js ./styles.css
  • 19. Custom frontend bundles 1/2 ./bundles/imagesloaded.pkgd.min.css ./bundles/imagesloaded.pkgd.min.js ./bundles/masonry.pkgd.min.css ./bundles/masonry.pkgd.min.js (function() { var require, define; // ... // AMD packaged JS distributions must be wrapped // so that Plone require.js define is undefined // during their load // ... })();
  • 20. Custom frontend bundles 2/2 ./install/registry.xml <records prefix="plone.bundles/imagesloaded-js" interface="...interfaces.IBundleRegistry"> <value key="depends">plone</value> <value key="jscompilation">++theme++...js</value> <value key="csscompilation">++theme++...css</value> <value key="last_compilation">2017-10-06 00:00:00 </value> <value key="compile">False</value> <value key="enabled">True</value> </records>
  • 21. Custom content types 1/2 ./install/types/wall_of_images.xml ./install/types/wall_of_images_image.xml ./install/types.xml <object name="portal_types"> <object name="wall_of_images" meta_type="Dexterity FTI"/> <object name="wall_of_images_image" meta_type="Dexterity FTI"/> </object> ./models/wall_of_images.xml ./models/wall_of_images_image.xml
  • 22. Custom content types 2/2 <model xmlns:...="..." i18n:domain="plone"> <schema> <field name="title" type="zope.schema.TextLine"> <title i18n:translate="">Title</title> </field> <field name="image" type="plone.namedfile.field.NamedBlobImage"> <title i18n:translate="">Image</title> </field> </schema> </model>
  • 23. Custom views 1/3 <html xmlns="http://www.w3.org/1999/xhtml" xmlns:...="..." lang="en" metal:use-macro=".../macros/master" i18n:domain="plone"> <body> <metal:main fill-slot="main"> <metal:content-core define-macro="content-core"> </metal:content-core> </metal:main> </body> </html>
  • 24. Custom views 2/3 ./fragments/wall-of-images.pt <div class="wall-of-images container-fluid" tal:define="items context/@@contentlisting"> <tal:image tal:repeat="item items"> <img tal:define="obj item/getObject; scale_func obj/@@images; scaled_image python:scale_func.scale('image', scale='preview')"→ tal:replace="structure python:scaled_image.tag()"→ tal:on-error="string:error" /> </tal:image> </div>
  • 25. Custom views 3/3 ./install/types/wall_of_images.xml ... <property name="default_view"> ++themefragment++wall-of-images</property> <property name="view_methods"> <element value="++themefragment++wall-of-images"/> </property> ... Any themefragment can be configured as content object view by manually setting layout property of the content object.
  • 26. Custom l10n messages ./locales/fi/LC_MESSAGES/plone.po ./locales/en/LC_MESSAGES/plone.po msgid "Close from submissions" msgstr "Sulje osallistuminen" msgid "Open for submissions" msgstr "Avaa osallistumiselle" When theme is developed on file system, normal i18n tools can be used for messages extraction and catalog synchronization (e.g. i18ndude).
  • 27. Custom permissions ./manifest.cfg [theme:genericsetup] permissions = demotheme.addImage Wall of Images: Add Image ./install/types/wall_of_images_image.xml <object name="wall_of_images_image" ...=".."> ... <property name="add_permission"> demotheme.addImage</property> ... </object>
  • 28. Custom workflows ./install/workflows.xml ./install/simple_publication_with_submission_workflow/ ./install/wall_of_images_workflow/ <type type_id="wall_of_images"> <bound-workflow workflow_id="..."/> </type> <dc-workflow workflow_id="..."> ... <permission>Wall of Images: Add Image</permission> ... </dc-workflow>
  • 29. Custom content rules ./install/contentrules.xml <contentrules> <rule name="rule-image-thank-you" title="Thank visitor from submission" cascading="False" description="Thanks visitor after submission" event="...IObjectAddedEvent" stop-after="False" enabled="True">...</rule> <assignment name="rule-image-thank-you" bubbles="True" enabled="True" location=""/> </contentrules>
  • 30. Final touch with Diazo-bundles ./manifest.cfg production-css = /++theme++demotheme/styles.css production-js = /++theme++demotheme/scripts.js ./scripts.js jQuery(function($) { $('.wall-of-images').imagesLoaded(function() { $('.wall-of-images').masonry({ itemSelector: 'img', percentPosition: true }); }); });
  • 32. What about Mosaic? – Theme site setup can populate Mosaic site and content layout resource directories from theme – Theme fragment tile for Plone Mosaic can render selected fragment with – fragment-specific readable title – fragment-specific XML schema based configuration form – fragment-specific view permission – fragment-specific caching rule
  • 33. What about Webpack? – Bundles in theme can be built with Webpack – Diazo bundle in theme can be built with Webpack – All frontend resources can be built with Webpack – plonetheme.webpacktemplate – plonetheme-webpack-plugin – plonetheme-upload
  • 34. Bonus: Custom JS widgets ./models/my_content_type.xml ... <field name="focuspoint" type="zope.schema.BytesLine"> <form:widget type="z3c.form.browser.text.TextFieldWidget"> <klass>text-widget pat-focuspoint-widget</klass> </form:widget> <title i18n:translate="">Image focus point</title> <required>false</required> </field> ...