Customizing Share Document Previews Will Abson Senior Integrations Engineer and Share Extras Project Lead

Slides:



Advertisements
Similar presentations
Samsung Smart TV is a web-based application running on an application engine installed on digital TVs connected to the Internet.
Advertisements

ASP.NET Intro An introduction to the languages and communication of an ASP.NET system.
Extreme User Interfaces for Alfresco Kevin Dorr Sr. Solutions Engineer Americas Channel.
HTML 5 and CSS 3, Illustrated Complete Unit L: Programming Web Pages with JavaScript.
XHTML & CSS 2 By Trevor Adams. Last week XHTML eXtensible HyperText Mark-up Language The beginning – HTML Web Standards Concept and syntax Elements (tags)
HTML 5 and CSS 3, Illustrated Complete Unit K: Incorporating Video and Audio.
The Web Warrior Guide to Web Design Technologies
HTML5 and CSS3 Illustrated Unit B: Getting Started with HTML
1 Chapter 12 Working With Access 2000 on the Internet.
1 Frameworks. 2 Framework Set of cooperating classes/interfaces –Structure essential mechanisms of a problem domain –Programmer can extend framework classes,
Agenda What is BIRT? BIRT Features and Report Gallery Scripting BIRT
DT228/3 Web Development JSP: Directives and Scripting elements.
Python and Web Programming
Russell Taylor Lecturer in Computing & Business Studies.
COMPUTER TERMS PART 1. COOKIE A cookie is a small amount of data generated by a website and saved by your web browser. Its purpose is to remember information.
Copyright © 2004 ProsoftTraining, All Rights Reserved. Lesson 9: HTML Frames.
ITM352 Javascript and Dynamic Web Pages: Client Side Processing.
(C) 2013 Logrus International Practical Visualization of ITS 2.0 Categories for Real World Localization Process Part of the Multilingual Web-LT Program.
UNIT-V The MVC architecture and Struts Framework.
Forms, Validation Week 7 INFM 603. Announcements Try placing today’s example in htdocs (XAMPP). This will allow you to execute examples that rely on PHP.
© 2011 Delmar, Cengage Learning Chapter 11 Adding Media and Interactivity with Flash and Spry.
4.1 JavaScript Introduction
Pittsburgh Java User Group– Dec Java PureFaces: A JSF Framework Extension.
CS346 - Javascript 1, 21 Module 1 Introduction to JavaScript CS346.
Learning Alfresco Forms Service By Examples
Building a UI with Zen Pat McGibbon –Sales Engineer.
Introduction to Silverlight. Slide 2 What is Silverlight? It’s part of a Microsoft Web platform called Rich Internet Applications (RIA) There is a service.
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
© 2005 by IBM; made available under the EPL v1.0 | March 1, 2005 Tim deBoer Gorkem Ercan Extend WTP Server Tools for your.
XML and XSL Institutional Web Management 2001: Organising Chaos.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Lesson 19. JavaScript errors Since JavaScript is an interpreted language, syntax errors will usually cause the script to fail. Both browsers will provide.
Chapter 17: Applets, Images, and Sound. Objectives Learn about applets Write an HTML document to host an applet Use the init() method Work with JApplet.
Tutorial 7 Working with Multimedia
Tutorial 7 Designing a Multimedia Web Site
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Tutorial 7 Working with Multimedia. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Explore various multimedia applications.
© 2006 by «Author»; made available under the EPL v1.0 | Date | Other Information, if necessary Jason Weathersby BIRT Evangelist, Actuate Corp. Leveraging.
ECA 228 Internet/Intranet Design I Intro to Markup.
Building Rich Web Applications with Ajax Linda Dailey Paulson IEEE – Computer, October 05 (Vol.38, No.10) Presented by Jingming Zhang.
Session: 1. © Aptech Ltd. 2Introduction to the Web / Session 1  Explain the evolution of HTML  Explain the page structure used by HTML  List the drawbacks.
Developing Great Dashlets Will Abson About Me Project Lead, Share Extras Alfresco Developer and previously Solutions Engineer DevCon 2011 –
Plug-in Architectures Presented by Truc Nguyen. What’s a plug-in? “a type of program that tightly integrates with a larger application to add a special.
ICM – API Server & Forms Gary Ratcliffe.
HTML A brief introduction HTML1. HTML, what is? HTML is a markup language for describing web documents (web pages). HTML stands for Hyper Text Markup.
Microsoft Expression Web 3 – Illustrated Unit D: Structuring and Styling Text.
INTRODUCTION JavaScript can make websites more interactive, interesting, and user-friendly.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
: Information Retrieval อาจารย์ ธีภากรณ์ นฤมาณนลิณี
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Flux & React Web Application Development Mark Repka, Rich McNeary, Steve Mueller.
Leveraging Web Content Management in SharePoint 2013 Christina Wheeler.
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
Tutorial 6 Creating a Web Form
Wes Preston DEV 202. Audience: Info Workers, Dev A deeper dive into use-cases where client-side rendering (CSR) and SharePoint’s JS Link property can.
Hyper Text Markup Language.  My First Heading My first paragraph. Example Explained The DOCTYPE declaration defines the document type The text between.
#SummitNow The Share Widget Library 13 th November 2013 Dave Draper
Developing Great Dashlets Will Abson About Me Project Lead, Share Extras Alfresco Developer and previously Solutions Engineer DevCon 2011 –
#SummitNow Lessons Learnt From Share Extras Alfresco Summit 2013 Will Abson
Developing Great Dashlets Will Abson About Me Project Lead, Share Extras Alfresco Developer and previously Solutions Engineer DevCon 2011 –
Extreme User Interfaces for Alfresco Kevin Dorr Sr. Solutions Engineer Americas Channel.
The Share Widget Library
Introduction to Silverlight
Part of the Multilingual Web-LT Program
Modern web applications
Modern web applications
Intro to PHP.
Plug-In Architecture Pattern
Presentation transcript:

Customizing Share Document Previews Will Abson Senior Integrations Engineer and Share Extras Project Lead

Upfront Notes These examples will work against Alfresco Community 4.0+ It is assumed you are familiar with Web Scripts and basic Share Development Defining, building and deploying your own projects as a JAR

Agenda Background on Document Previews Web Preview implementation Hands-on customization examples from Share Extras Media Viewers project

What are Document Previews? Rich view of the (document) content Found on the Document Details page May render the content itself or a rendition

Changes in Alfresco 4 More screen space for previews Support for more formats Configure and extend the previewers

The web-preview Component

web-preview Implementation Just a web script web-preview.get.desc.xml web-preview.get.config.xml web-preview.get.js web-preview.get.html.ftl web-preview.get.head.ftl (removed in 4.2) web-preview.get.properties (and localized variants) See the code in webapps/share/WEB- INF/classes/alfresco/site- webscripts/org/alfresco/components/preview

web-preview Implementation Client-side components Main Component Alfresco.WebPreview in web-preview.js web-preview.css Plugin implementations (4.0+)

web-preview Implementation From web-preview.get.html.ftl (v4.0) //<![CDATA[ new Alfresco.WebPreview("${el}").setOptions( { nodeRef: "${nodeRef}", name: "${node.name?js_string}", mimeType: "${node.mimeType}", size: "${node.size}", thumbnails: [ "${t}", ], pluginConditions: ${pluginConditionsJSON} }).setMessages(${messages}); //]]> ${msg("label.preparingPreviewer")}

web-preview Implementation From web-preview.get.html.ftl (v4.2.b)

web-preview Implementation As it was in Alfresco 3 Web Scripts / Spring Surf document-details YUI2 / Share JS Framework Alfresco.WebPrevi ew Web Tier Client-side (Web Browser) web- preview.get

web-preview Implementation New implementation in Alfresco 4 Web Scripts / Spring Surf document-details YUI2 / Share JS Framework Alfresco.WebPrev iew Plugins Web TierClient-side (Web Browser) web- preview.get Extend via client-side Plugin classes

OOTB WebPreview Plugins Flash FlashFox StrobeMediaPlayback WebPreviewer Non-Flash Audio Image Video See the code in directory webapps/share/components/preview

Question If we have multiple plugins which can render a particular file, how does Share decide which one to use?

Plugin Applicability and Ordering Plugin Applicability o Which plugins can be used in these circumstances? Plugin Ordering o Out of those plugins, which one should have preference over the others?

Plugin Applicability Statically configured o Via component configuration in web- preview.get.config.xml o Based on MIME type or renditions available o Results in a list of plugins to be tried for a content item

Sample Component Configuration StrobeMediaPlayback FlashFox Video Plugin applicability determined by element attributes Plugin configuration determined by element attributes

Plugin Applicability Statically configured o Via component configuration in web- preview.get.config.xml o Based on MIME type or renditions available o Results in a list of plugins to be tried for a content item Dynamically determined at run time o Plugins are given the opportunity to 'test' a content item o Based on any Javascript-testable condition, e.g. browser type/version, content properties o Plugins can return a ‘yes’ or a ‘no’ (plus a reason)

Plugin Applicability See the code in webapps/share/components/preview/w eb-preview.js

Plugin Ordering Taken from component configuration in web- preview.get.config.xml The first plugin which matches the static conditions and the dynamic test(s) is used. If an error occurs this is logged, then the next plugin is used

Plugin Configuration Also held in web-preview.get.config.xml Allows setting of plugin configuration attributes Change the behaviour of the plugin

Implementing Custom Plugins We need to define 1.Custom plugin class (JavaScript) 2.Localized strings for the UI 3.Presentation resources (images, CSS, etc.) We need to configure 1.Registration in component configuration web- preview.get.config.xml

Implementing Custom Plugins We need to define 1.Custom plugin class (JavaScript) 2.Localized strings for the UI 3.Presentation resources (images, CSS, etc.) We need to configure 1.Registration in component configuration web- preview.get.config.xml

Example: Inline PDF Viewer Displays a PDF directly in the browser within an iFrame Note: Not included in Media Viewers add-on, but 'Embed' plugin does a similar job Code: github.com/wabson/sample-preview-plugingithub.com/wabson/sample-preview-plugin File source/web/someco/components/preview/ PDF.js

Custom Plugin Class Pattern (function() { Alfresco.WebPreview.prototype.Plugins.PDF = function(wp, attributes) { this.wp = wp; this.attributes = YAHOO.lang.merge(Alfresco.util.deepCopy(this.attributes), attributes); return this; }; Alfresco.WebPreview.prototype.Plugins.PDF.prototype = { attributes: { }, report: function PDF_report() { }, display: function PDF_display() { return " My preview "’; } }; })();

Custom Plugin attributes Just an object literal All values are simple string values Default values should be specified in the prototype o Overrides in the component configuration XML will be merged in Don't forget the JSDoc!

Custom Plugin report() method Allows the plugin to dynamically test the document properties, system characteristics and plugin attributes, to test if it can be used Return null if it CAN be used Return a non-empty string value if it can't o Value should give the reason why it can't be used, e.g. "File is too big, only files < 2MB are supported"

Custom Plugin display() method Render the content display Return a String value to be used as the HTML mark-up, OR Return null you want to directly build the display using.innerHTML or DOM manipulation

Example: Inline PDF Viewer The usual Share object prototype approach is used Property attributes can be used to customize behaviour Function report() returns null if the plugin can be used or a string if not indicating the reason Function display() returns a string containing HTML markup or null if Dom manipulation has already been used

Example: Inline PDF Viewer To include the JavaScript file in the HTML document, we can use an extensibility module See file config/alfresco/site- webscripts/com/someco/customization/sample- preview-plugin/web-preview.get.head.ftl Note: in 4.2,.head.ftl webscript templates are deprecated, use directive in.html.ftl template instead. See v4- 2-config branch for new code.

Example: Inline PDF Viewer To include the JavaScript file in the HTML document, we can use an extensibility module See file config/alfresco/site- webscripts/com/someco/customization/sample- preview-plugin/web-preview.get.head.ftl Note: in 4.2,.head.ftl webscript templates are deprecated, use directive in.html.ftl template instead. See v4- 2-config branch for new code.

Implementing Custom Plugins We need to define 1.Custom plugin class (JavaScript) 2.Localized strings for the UI 3.Presentation resources (images, CSS, etc.) We need to configure 1.Registration in component configuration web- preview.get.config.xml

Example: Inline PDF Viewer We can also use our extensibility module to add additional message labels See file config/alfresco/site- webscripts/com/someco/customization/sample- preview-plugin/web-preview.get.properties # Error messages PDF.tooLargeFile=The PDF was too large to display. File {0} was {1}, but must be less than {2}.

Implementing Custom Plugins We need to define 1.Custom plugin class (JavaScript) 2.Localized strings for the UI 3.Presentation resources (images, CSS, etc.) We need to configure 1.Registration in component configuration web- preview.get.config.xml

Example: Inline PDF Viewer To include the a custom CSS file in the HTML document, we can use re-use the extensibility module See file config/alfresco/site- webscripts/com/someco/customization/sample- preview-plugin/web-preview.get.head.ftl Note: in 4.2,.head.ftl webscript templates are deprecated, use directive in.html.ftl template instead

Implementing Custom Plugins We need to define 1.Custom plugin class (JavaScript) 2.Localized strings for the UI 3.Presentation resources (images, CSS, etc.) We need to configure 1.Registration in component configuration web- preview.get.config.xml

Example: Inline PDF Viewer Lastly we must tell the web-preview.get component to use the PDF plugin! To do this add the following to the element in your overidden web-preview.get.config.xml PDF But instead we’re going to use a second extensibility module to add the configuration automatically This can be done by the developer (4.2+)! See file config/alfresco/site- webscripts/com/someco/customization/sample-preview-plugin- config/web-preview.get.js

Demo

Example: pdf.js Viewer

Summary The Web Preview component is an important part of Share Alfresco 4 allows us to display our content in new and interesting ways o Or, display content that is not supported OOTB We can re-use our existing Share customization skills to bring in powerful tools such as pdf.js

More Information extras/wiki/MediaViewers hare-document-previews-in-alfresco-4/ edia-previews-is-dead-long-live-media-viewers/

Questions?