All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Production Reference: 1100510
Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-847197-66-5 www.packtpub.com
Cover Image by Filippo Sarthi ()
www.it-ebooks.info
Credits Author Tom Gross Reviewers Vincent Fretin Eric Steele Acquisition Editor Rashmi Phadnis Development Editor Rakesh Shejwal Technical Editor Kavita Iyer Copy Editor Sneha Kulkarni Indexer Rekha Nair
Editorial Team Leader Mithun Sehgal Project Team Leader Lata Basantani Project Coordinator Srimoyee Ghoshal Proofreader Chris Smith Graphics Geetanjali Sawant Production Coordinator Adline Swetha Jesuthas Avinish Kumar Cover Work Adline Swetha Jesuthas
www.it-ebooks.info
About the Author Tom Gross is a longtime Zope and Plone user and developer. Since Plone 4.0, he
has been a core contributor, and he took responsibility for the rewrite of the reference browser widget. Besides his development and consultant work in Australia, Germany, and Switzerland, he writes technical and philosophical (audio) books. Tom lives in Zurich and is currently working as a Zope/Plone consultant for the University of Applied Sciences Northwestern Switzerland. Casually, he is doing some other Python, GAE, and repoze.bfg projects. Tom wrote the German audiobook Können Maschinen denken? Searles moderne
Interpretation des Körper-Geist-Problems.
I'd like to thank Anne for her support and patience while writing this book. Furthermore, I'd like to thank Tom D. for showing me some really cool Python techniques.
www.it-ebooks.info
About the Reviewers Vincent Fretin has been developing enterprise collaborative portals from Plone
since 2008. He participates in the Grok and Plone communities, and has helped to integrate the Grok technology into Plone since early 2009. He's one of the maintainers of ArchGenXML and contributes to AGX 3 development. Vincent also takes an active role in Plone itself as the internationalization team leader since Plone 3.2. He also contributed new functionalities to Plone 4, including Amberjack to create interactive guided tours. He works for the Ecréall company at Lille in France, and can be found daily on the #plone, #grok, and #dolmen IRC channels. Ecréall develops portals that follow the customer business process (the way BPM does).
Eric Steele has been using Zope since 2002 and Plone since 2005. He currently works as a developer for Penn State University's WebLion group. He is the author of several widely used Plone products, including GloWorm and FacultyStaffDirectory. Eric serves as the Plone 4 release manager and is a member of the Plone Foundation.
www.it-ebooks.info
www.it-ebooks.info
Table of Contents Preface Chapter 1: Plone and Multimedia Some definitions CMS ZCA WWW Buildout What is multimedia? Why Plone? Plone Content How do they fit? Plone4Artists Summary
Chapter 2: Managing Image Content
The Image content type Adding images with an unmodified Plone Working with sizes Dimension Limiting sizes
1 7
7 7 8 9 9 10 12 13 14 15 16
17 18 18 20 20 20
Accessing images
23
Workflow The thumbnail view Using images in pages and news items
26 26 28
URL access Page template access Python code access Field access
www.it-ebooks.info
23 23 24 25
Table of Contents
Customizing Kupu's image features Styling images Use different sizes for presentation Generating a package boilerplate Adding functionality to the boilerplate
29 30 31 31 33
Enhancing images with p4a.ploneimage The Exchangeable Image Format (Exif)
Removing p4a.ploneimage Image-enhanced folders Gallery products for Plone Creating galleries with collective.plonetruegallery
35 38 38 38 39 40
The Slideshowfolder product Choosing a slideshow product Manipulating Images Summary
46 48 48 51
Advanced settings for the gallery Accessing Flickr Accessing Picasa Accessing external services
Chapter 3: Managing Audio Content
Uploading audio files with an unmodified Plone installation
Accessing audio content in Plone Kupu access Page template access Python script access Field access
43 44 45 46
53 54 55 55 55 56 56
Audio formats Choosing the right audio format Converting audio formats
57 59 60
Audio metadata ID3 tag: The metadata format for MP3 Metadata of other audio formats
Editing audio metadata Audio enhancements with p4a.ploneaudio Enhancing files Enhancing containers The XML Shareable Playlist Format: XSPF p4a.ploneaudio and the Plone catalog
61 61 61 62 63 63 67 68 69
Converting audio with VLC
Accessing audio metadata in Collections
ATAudio migration Extracting metadata with AudioDataAccessors p4a.ploneaudio and FLAC [ ii ]
www.it-ebooks.info
60
70
71 71 72
Table of Contents
Including audio into HTML Including audio with plugin elements A custom view with an embedded audio player Using Flowplayer
75 75 76 78
Technology preview: HTML5 A player view with HTML5 Summary
81 82 83
Standalone Flowplayer for audio files Playlist Flowplayer for audio containers Audio Flowplayer as a portlet
Inline audio player with Flowplayer
Chapter 4: Managing Video Content
Managing videos the Plone way Accessing video content Accessing video content through the Web Downloading content Streaming content
79 80 80 80
85 86 87 88 88 89
Streaming the content using Flash Streaming video content with Plone
90 91
A custom view for streaming videos Enhancing Plone's video features
The p4a.plonevideo product
94 97 97
Embedding videos with Kupu
Converting standalone file content into videos Enhancing containers with video features Migrating ATVideo content to p4a.plonevideo content Embedding external videos with p4a.plonevideoembed Adding a custom provider to p4a.plonevideoembed
91
98 100 102 102 104
Adding collective.flowplayer The Flash video format
107 107
Plumi: A complete video solution Installing Plumi
Preview: HTML5 A custom view with HTML5 Summary
117 119 120 121 122
Using the collective.flowplayer product Enhancing files and links Enhancing containers Showing videos in portlets Inline inclusion of videos Visual editor integration Setting options Removing Flowplayer
109 109 110 110 112 113 113 115
[ iii ]
www.it-ebooks.info
Table of Contents
Chapter 5: Managing Flash Content
What is Flash? Including Flash in HTML Flash and HTML5 Flash in Kupu The Flash 10 issue Working around the Flash 10 issue Products targeting Flash Using ATFlashMovie to include Flash applets in Plone A Flash portlet Flash in a Collage view
Extracting Flash metadata with hexagonit.swfheader The basic components of a custom Flash content type A view for the custom Flash content type
123 124 125 127 127 128 129 131
131
134 135
136
137 138
Silverlight Installing Silverlight
140 140
Including Silverlight content pyswftools: Manipulating Flash with Python Installing pyswftools Using pyswftools Summary
141 143 143 144 147
Installing Moonlight on Linux
Chapter 6: Content Control
Categorization Folder categorization The Dublin Core metadata Managing keywords in Plone Categorization methods
Using Collections for structuring content Automated content actions with Content Rules
Categorization products
Products.PloneGlossary Other categorization solutions for Plone
140
149 150 150 152 153 155
155 161
165
165 167
Tagging and rating with Plone Tagging content with the p4a.plonetagging product Using Tag Clouds with Plone Rating content with the plone.contentratings product
168 168 170 171
Other means of content control Geolocation of content with Google Maps
175 176
Creating a custom rating category with a view
Installing and configuring Maps Using the Maps product Extending the Maps product
[ iv ]
www.it-ebooks.info
173
177 178 180
Table of Contents
Licensing content in Plone Summary
182 185
Chapter 7: Content Syndication
187
What is Syndication? Syndication formats
188 188
The RSS syndication format The Atom syndication format Other syndication formats
189 192
193
Autodiscovery Syndication clients Syndication features of Plone Using Collections for syndication Feeding a search Syndication products for Plone The fatsyndication product bundle
197 198 198 200 202 203 203
The basesyndication product The fatsyndication product
203 207
Syndication with Vice
207
Extending Vice
Syndication of Plone4Artists products Summary
Chapter 8: Advanced Upload Techniques
Uploading strategies Web-driven bulk uploads Using collective.uploadify for web-based multiupload Web-based multiuploads with PloneFlashUpload Doing multiuploads of ZIP structures with atreal.massloader atreal.massloader on Mac OS X
Web uploaders compared Alternative protocols for uploading files Using the File Transfer Protocol (FTP) with Plone Choosing an FTP client
Content manipulation with WebDAV Finding a WebDAV client
Using the Enfold Desktop as a Plone client with Windows Summary
Chapter 9: Advanced Storage
Default storage in Plone Archetypes storage Outsourcing multimedia content Optimized data storage in Plone
212
217 222
223 223 224 224 228 230
232
233 234 234
235
237
238
241 242
243 244 245
247 248
[v]
www.it-ebooks.info
Table of Contents
Using ExternalStorage as an Archetype storage backend Using FileSystemStorage as an Archetype storage backend
248 250
Storing binary data as BLOBs
260
Storage strategies of FSS Using FSS Important things to know about FSS BLOB images Migrating existing content
252 256 260 264
265
Accessing filesystem content with Reflecto Publisher hooks The Tramline publisher hook product
266 268 269
Summary
277
Tramline setup preparations Configuring Apache for Tramline Configuring Plone for Tramline
Chapter 10: Serving and Caching
The caching server Varnish Using Varnish Setting caching headers with CacheFu Configuring CacheFu Red5: A video-on-demand Flash server Requirements for setting up a Red5 server A Red5 buildout Using Red5 The temporary URL The Red5Stream content type
Visual editor integration
Troubleshooting Red5
Java version issues Checking the logs Network and time issues Running Red5 server in the foreground mode
Summary
Appendix A: Multimedia Formats and Licenses Audio formats Lossless codecs
The Free Lossless Audio Codec Other lossless audio codecs
269 270 271
279 280 281 284 284 288 288 289
292
293 294 295
296
296 296 296 298
299
301 302 303
303 303
Lossy codecs
304
MPEG-1 Audio Layer 3 Ogg Vorbis Other lossy codecs
305 305 305
[ vi ]
www.it-ebooks.info
Table of Contents
Video formats Lossless codecs MPEG-4 Part 2 codecs H.264/MPEG-4 AVC codecs Microsoft codecs Creative Commons Licenses License conditions
306 306 307 307 308 308 309
Attribution Share Alike Noncommercial
No Derivative Works
The Main Creative Commons Licenses Attribution License Attribution Share Alike license Attribution No Derivatives Attribution Non-commercial Attribution Non-Commercial Share Alike Attribution Non-Commercial No Derivatives
Getting Plone help Documentation on plone.org Google and blogs Mailing lists/forums IRC (Online support) Commercial support Finding Plone add-ons The PyPi Python egg index Plone products on plone.org The Plone Collective Links for selected multimedia topics
Image links Audio links Video encoding and conversion resources Flash and Silverlight
Preface Multimedia is the dominant aspect of the Internet today. There is almost no site with no pictures, videos, Flash animations, or audio content. The integration of multimedia content is the daily mission of web editors and site integrators.
Plone is a mature, stable, and flexible content management system. With the batteries included it provides a complete and user friendly system for managing web content. Completely object-oriented, it is well suited for extensions written in Python. In this book you will learn to bring these two topics together. It will show you how you can prepare multimedia data for the Web and turn it into valuable content using Plone. With step-by-step examples you will learn how to use Plone and add-ons to provide an appealing multimedia web experience.
What this book covers
Chapter 1, Plone and Multimedia, tells you what multimedia is all about and what you can expect from Plone. It also shows some reasons why we can, and should, use our favorite Open Source CMS Plone for some additional multimedia candy. Chapter 2, Managing Image Content, shows how we can add images, organize them in folders with thumbnail view, and how to access them. It also discusses two gallery products. Chapter 3, Managing Audio Content, shows how to add audio content to Plone and enhance its features with Plone4Artists products. It also shows how to include audio data in HTML with plugins and Flash. Chapter 4, Managing Video Content, discusses how to add video content to Plone. It also discusses the difference between downloading and streaming, and various products used for enhancing videos in Plone.
www.it-ebooks.info
Preface
Chapter 5, Managing Flash Content, shows how to include Flash and Silverlight in
Plone. It discusses two products that help in improving the inclusion of Flash content in Plone. Chapter 6, Content Control, investigates classic categorization methods. It glances at some products that ease or extend the categorization methods of the default Plone CMS. It also looks at the important techniques of tagging and rating, and few more techniques of content control. Chapter 7, Content Syndication, talks about syndication. It shows how to use RSS syndication with an unmodified Plone installation with collections and searches. It also shows how to enhance syndication with add-on products. Chapter 8, Advanced Upload Techniques, shows how to get content into Plone. It shows various approaches to upload multiple files. It also shows how to upload files using alternative protocols such as FTP and WebDAV. Chapter 9, Advanced Storage, shows some storage mechanisms in Plone. It also investigates publisher hooks. Chapter 10, Serving and Caching, looks at applications other than Plone such as reverse proxy cache Varnish and Red5, and how to use use CacheFu and also to set cache headers. Appendix A, Multimedia Formats and Licenses, looks at details of formats and codecs used for the storage and transmission of audio and video content. It also looks at the Creative Commons licenses, which can be used to license open (multimedia) content. Appendix B, Syndication Formats, looks at specifications of RSS 2.0, Atom, and the MediaRSS syndication format extension. Appendix C, Links and Further Information, discusses how to use different sources such as the Web, e-mails, and so on to find Plone add-ons and links to selected multimedia topics.
What you need for this book
To run the examples included with the book, you will need Python version 2.4 compiled from the sources or installed from an installer available from
All the examples contain the full application stack including Zope version 2.10.9 and Plone 3.3.3 in the form of a buildout configuration. You can use a Plone from the UnifiedInstaller available at />products/plone and change the buildout configuration accordingly.
[2]
www.it-ebooks.info
Preface
The examples are intended to work on Windows, Mac OS X, and Linux, if not indicated otherwise. This book is for Plone integrators who want to extend the core of Plone with multimedia features. It gives no introduction to Plone and readers should know how to set up a Plone site using a buildout. The book can be read and understood well without being a Python developer, though some examples have Python code included.
Who this book is for
This book is for Plone integrators who want to extend the core of Plone with multimedia features. It gives no introduction to Plone and readers should know how to set up a Plone site using a buildout. The book can be read and understood well even if the reader is not a Python developer, though some examples have Python code included.
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an
explanation of their meaning. Code words in text are shown as follows: "We can include other contexts through the use of the include directive." A block of code is set as follows: <archetype ATImage> # maximum file size in byte, kb or mb max_file_size no # maximum image dimension (w, h) # 0,0 means no rescaling of the original image
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold: install_requires=[ 'setuptools', # -*- Extra requirements: -*'p4a.common', 'p4a.ploneimage', ],
[3]
www.it-ebooks.info
Preface
Any command-line input or output is written as follows: $ paster create -t plone3_theme
New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "In the
Transform tab, we find a selection of tools for limited image manipulation support."
Warnings or important notes appear in a box like this.
Tips and tricks appear like this.
Reader feedback
Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of. To send us general feedback, simply send an e-mail to , and mention the book title via the subject of your message. If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or e-mail
If there is a topic that you have expertise in and you are interested in either writing or contributing to a book on, see our author guide on www.packtpub.com/authors.
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.
[4]
www.it-ebooks.info
Preface
Downloading the example code for the book Visit />to directly download the example code. The downloadable files contain instructions on how to use them.
Errata
Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded on our website, or added to any list of existing errata, under the Errata section of that title. Any existing errata can be viewed by selecting your title from /> Piracy
Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy. Please contact us at with a link to the suspected pirated material. We appreciate your help in protecting our authors, and our ability to bring you valuable content.
Questions
You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.
[5]
www.it-ebooks.info
www.it-ebooks.info
Plone and Multimedia Multimedia is the dominant part of the World Wide Web as we face it today. Every site has at least some images to give the site visitor a better "picture" of the presented content. Web-based multimedia services such as YouTube, Flickr, and Picasa are growing rapidly and there seems to be no end in sight. Plone is a Web Content Management System written to serve big amounts of web content in a secure and professional manner. Do these two concepts go together? Can Plone meet the requirements of a shiny multimedia web? This book will show you how to turn your multimedia data into valuable web content with Plone. It will show you how to utilize third-party products to make the most out of your favorite CMS. Let's start with some general discussion about the topics that this book will cover.
Some definitions
Before we can dig into the topic, we need some definitions of the key terms. These terms will follow us through the book.
CMS
CMS stands for Content Management System. It is a general term covering several types of software intended to store, manage, and provide digital data. Digital data that is managed by a CMS is referred to as content. There are several types of content management systems: Document management systems, Digital Records Management systems, Electronic Content Management systems, web-based content management systems, and others.
www.it-ebooks.info
Plone and Multimedia
Plone is a classic web-based CMS. Editing and viewing of the content is completely done through the Web. Although there are other means of feeding Plone with data and getting it in and out again, the web browser is the main interface for the interaction of humans with Plone. In the book, we will see alternative methods for interacting with Plone.
ZCA
The ZCA is the Zope Component Architecture. It was introduced with Zope 3 and is now part of Zope 2, and therefore of Plone with the help of the Five product (2+3). This strategy, which shares many ideas with the Mozilla Component Architecture, allows us the use of adapters and utilities. With adapters, we can do so-called aspect oriented programming. An adapter represents a certain aspect of a context object. A simple example of an adapter is a size adapter that calculates the size of an object. How this is done depends on the
nature of the context. It can be as simple as calling the len method on the context, or there can be a complex function behind it. A simple adapter call (without the definition and the registration) looks like this: >>> ISize(context) >>> 587
Adapters can have more than one context. These adapters are called multi-adapters. One example is a BrowserView, which takes a content object and the request as context. BrowserViews are certain aspects of the content in a publishing situation. Utilities are methods or classes (Callables) stored in a registry and, therefore, easy to acquire. An example of a utility is a vocabulary. The underlying method returns an iterator of term objects. These term objects may be used for choice or selection widgets. A good introduction to the ZCA can be found in Philipp von Weitershausen's book Web Component Development with Zope 3. The book is slightly outdated, but still a good source for learning the ZCA with examples.
In this book we will focus on products utilizing the ZCA, if possible. These products are more flexible, and overriding an adapter for custom purposes is easier and better than monkey patching.
[8]
www.it-ebooks.info
Chapter 1
WWW
The WWW (World Wide Web) is the playground of Plone. Many web pages use the domain name "www", but this is not meant here. What is meant here is the sum of all web pages and portals that are reachable with a web browser. Technically speaking, this is everything with an URL. Usually URLs accessible with a web browser utilize HTTP (HyperText Transfer Protocol) or FTP (File Transfer Protocol).
Buildout
The term buildout is used for two things: a piece of software, correctly spelled as zc.buildout, and a concept for configuring software using zc.buildout. Since version 3.0, Plone is distributed with a buildout. In the common use of the term, buildout refers to one or more files used for configuration. This file is usually called buildout.cfg and contains all the necessary bits and pieces for fetching the Plone application from online resources and configuring it. This file can be extended to install and configure arbitrary add-on products. There are ready available buildouts for special use cases such as publication management with Plone, a video suite for Plone, and a newsletter application with Plone; or they can be put together with ZopeSkel templates. Possibly, the shortest buildout for setting up Plone 3.3.3 is this: [buildout] parts = zope2 instance extends = />versions = versions [zope2] recipe = plone.recipe.zope2install url = ${versions:zope2-url}
The code examples in this book are available together with readymade buildouts, which set up Plone and the necessary multimedia parts.
What is multimedia? According to Wikipedia, multimedia is:
... media and content that uses a combination of different content forms. The term can be used as a noun (a medium with multiple content forms) or as an adjective describing a medium as having multiple content forms. The term is used in contrast to media, which only use traditional forms of printed or hand-produced material. Multimedia includes a combination of text, audio, still images, animation, video, and interactivity content forms. This is a very formal definition. In common language use, "multimedia" is simply images, audio, video, and animations (including interactive ones). Today, we face multimedia in many aspects of our daily life. Probably most of us have a digital camera. We play with interactive multimedia terminals when we go to the museum.
We watch DVD movies now and then, and last but not least we use the World Wide Web to enjoy and share multimedia of all different forms. The Web did not always have the multimedia capabilities that it has today. It started merely as a text and image platform with the brilliant idea of hyperlinks. With the growth of the Web, the requirements followed. People wanted to publish other forms of media. The browser companies reacted and Netscape, the leading browser manufacturer at that time, introduced the embed element and Microsoft the object element to include arbitrary multimedia contents into a web page. Embedding a multimedia object (a MIDI soundfile) in Netscape looks like this: <embed src="beatles.mid" />
Including a sound file in Microsoft looks like this: classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95">