SlideShare a Scribd company logo
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Build single page applications using AngularJS on AEM
David Benge | Lead Computer Scientist
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
What Is a Single Page Application?
wikipedia:
“A single-page application (SPA), is a web application or web site that
fits on a single web page with the goal of providing a more fluid user
experience akin to a desktop application. In a SPA, either all necessary
code – HTML, JavaScript, and CSS – is retrieved with a single page
load, or the appropriate resources are dynamically loaded and added to
the page as necessary, usually in response to user actions. The page
does not reload at any point in the process, nor does control transfer to
another page”
2
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Single Page Application Pro’s and Con’s
Pro’s
 Use of page fragments or partials speeds up
the loading of secondary pages
 Better mobile device experience
 Reduced number of resource requests across
the network greatly speeds up the applications
page transitions
 Lack of full page refresh creates a more app
like smoothness leading to a richer user
experience
3
Con’s
 Has Search Engine Optimization issues due to
the fact that pages/views rendering is driven
via javascript.
 Components and some core libs rely on the
document Ready event to initialize
 Speed of the initial load can be slow
 Not social sharing friendly. Twitter and
Facebook and others have issues when users
try to share SPA pages.
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
The Technical Reasons Are Great But Why Did I really Choose To Do An SPA?
4
• The debate on my development team between web and native has
become a religious war. It was time to see if we could get the experience
we want on the mobile experience without building a native application.
• Mobile applications have their place, but I believe a well built site can
convey the same information.
• Informational mobile apps without shared web content create data silos
that make discoverability and interoperability difficult.
• Responsive is a nice start but we wanted to take it further. We are also
experimenting with a concept we call ReDaptive. Watch our GitHub and
YouTube channels for more information in the future on this concept.
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
 Must have native application like smoothness on everything from the
high resolution desktop to the smartphone.
 Search and social friendly
 Works with AEM authoring
 Our development pattern needed to be easy to follow and understand
 No JSP; all Sightly
 Semantic html markup. Each page should be useable as a data
record based on markup
 Javascript needed to be balanced with markup. Avoid 500 js library
include madness
5
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 6
Our Proof Of Concept
Combine sling with Angular
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 7
• Custom base page component that allows pages to be either an Angular application
entry point or rendered as a view partial
• Angular JS code to control the application/site and its view navigation
• Rewrite rule to help handle search engines by adding a selector
• Based on runmode Base Page includes content or an Angular ui-view element
• Responsive design
• Custom video component that makes use of Adobe Dynamic Media and native HTML5
video tag markup. Selects best rendition to use based on the video element size and
browser device group detected
• Use of BrowseCap for device detection
• Nearly all Sightly
• Use of Less for style
• Adobe Analytics for metrics
• Uses AdobeAtAdobe boiler plate project - Available in our GIT repo
• Creative Cloud Extract used to build site from XD comps
• Photoshop used to develop the comps
• Adobe Edge inspect used to debug on devices
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
High Level Technical Overview Of The Base Page Component
 We created a standard page component that inherits from
wcm/foundation/components/page.
 This new base page component has a content.html include in the center. This is where
our page views get loaded. We change the markup based on if the request was made on
a publish or author environment.
 If the request was on author we do a standard content include.
 If it’s a page request on publish we don’t do the include and just insert the div with the
angular ui-view
<div class="page-content" ui-view data-sly-test="${teamsitePage.isPublisher && !teamsitePage.isSearchEngine}"></div>
<div data-sly-include="content.html" class="page-content" data-sly-test="${!teamsitePage.isPublisher ||
teamsitePage.isSearchEngine}"></div>
 In the base component we also include some meta data. We use this to tell angular and
other components how to behave based on the environment.
<meta name="publisher" content="${teamsitePage.isPublisher}"/>
<meta name="wcmmode" content="${teamsitePage.metaWcmMode}">
8
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
High Level Technical Overview Of The Standard Page Component
 All the pages inherit from the
base page
 Each new page component
includes their markup in a file
named content.html
 If needed they can include a
controller like in this example
 The controller code is stored in a
client lib under the page
component
9
<div class="contact-block" ng-controller="ContactController">
<div class="hi"><span>Hi. </span>How can we help you?</div>
<div class="methods">
<div class="method">
<div class="title">Technology Questions</div>
<div class="phone">+1 613 857 9233</div>
<div class="email">adobe@adobe.com</div>
</div>
<div class="method">
<div class="title">Work with Us</div>
<div class="phone">+1 613 857 9233</div>
<div class="email">adobe@adobe.com</div>
</div>
<div class="method">
<div class="title">Everything Else</div>
<div class="phone">+1 613 857 9233</div>
<div class="email">adobe@adobe.com</div>
</div>
</div>
</div>
</div>
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
High Level Technical Overview Of The Base Page Component Partial Selector
 Under the base page component we have a file named partial.html.
This file handles any request for a page that has the partial selection
appended to it. This file simply includes content.html with No header,
No footer, No navigation, just the meaty center of the view in our case.
 The partial also includes new metatags with data to replace the
header meta data. The new tags are prefixed with partial for example
partial:title. Its contents will replace the header metatag’s content for
title. The replacement of the metadata is handled by the Angular
application.
<meta name="partial:keywords" content="${head.keywords}" id="partialKeywords"/>
10
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
High Level Technical Overview Of The Base Page Component Partial Selector
We need to tell Angular about the site hierarchy because Angular will be
handling navigation from view to view. Angular controls the view
loading on the client side via a library called router.ui so it needs to
know how map urls to view partials.
Under the base page component we have a file named routes.json.jsp.
This file provides us a endpoint for Angular’s ui.router to use to load the
router and state provider on the fly on the first page load. One thing we
do alter on the routes is the value of the templateUrl returned from our
routes.json.jsp. On our page path we include a partial selector. Thanks
to the magic that is sling when we make that request now we will get
just the center conent of the page when we navigate from view to view.
11
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
High Level Technical Overview Of The Base Page Component Angular Router
12
Example output from our routes.json.jsp file is
shown to the left.
This is an example of how we are rewriting out our
routes and re-writing the templateUrl to include the
.partial selector.
Example /content/teamsite/work.html
becomes
/content/teamsite/work.partial.html
When the application/site is loaded in the browser
any link or navigation to a url for example
/content/teamsite/work/cmo.html is handled by the
$location service. It will resolve the url to the
templateUrl which is set to
/content/teamsite/work/cmo.partial.html.
The request to
/content/teamsite/work/cmo.partial.html will be
returned as just the center of the view and injected
into the existing page.
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
So Far This Is What It Looks Like On The AEM Page Component Side
13
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
High Technical Overview Of The Proof Of Concept – Component Conclusion
So that’s it for the AEM side of the application. Once the base component pattern was
established it was easy to work with.
Its all fairly normal AEM component and page development from that point on. With a few
exceptions for stock components that make heavy use of the document ready event.
Summary
 In author runmode, it will do full page refreshes
 Search engine friendly due to the fact there is a full page request
 On social shares of a page, the path exists
 In publish run mode, the client side will do partial page refresh
Thanks to the magic of sling resolution we are able to serve full pages or partials as
needed. Every path can be an entry point to our SPA base application.
14
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 15
The Angular Bits
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
The Angular Js bits we used to round out this solution are:
 Controller – Controllers ended up being minimally used at the page
level. Router.ui – used to load and control the routes. We also use the
routing events to load page meta data
 Service – We have a service that helps with pulling and setting meta
data on the page
 Directives – We have a few to provide functionality
 Custom html5 video player directive
 Explore page directive to help with the scrolling and other ui bits on
the explore page
 Angular Carousel which drives the image carousels
16
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Whats Next?
17
• We will be adding more functionality to the proof of concept
site
• We are really liking directives and plan to do more work in that
area and investigate using polymer
• Clean up of the header libs to remove some of the
dependency on document ready event
© 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.
Code is located in out Github repo https://github.com/AdobeAtAdobe
Live site can be found at http://www.adobeatadobe.com
Twitter @AdobeAtAdobe
Video sessions on this proof of concept will be posted on
our YouTube channel https://www.youtube.com/user/AdobeAtAdobe
Ad

Recommended

PPTX
Dynamic components using SPA concepts in AEM
Bojana Popovska
 
PDF
Build single page applications using AngularJS on AEM
connectwebex
 
PPTX
Bridging the Gap: Single-Page Apps and AEM
rbl002
 
PDF
Dynamic Components using Single-Page-Application Concepts in AEM/CQ
Netcetera
 
PDF
Sling Dynamic Include
Tomasz Rękawek
 
PDF
JCR, Sling or AEM? Which API should I use and when?
connectwebex
 
PPTX
AEM and Sling
Lo Ki
 
PDF
AEM Sightly Deep Dive
Gabriel Walt
 
PDF
AEM Best Practices for Component Development
Gabriel Walt
 
PPTX
Adobe AEM core components
Lokesh BS
 
PPTX
AEM GEMS Session Template Editor Sept 14 2016
AdobeMarketingCloud
 
PDF
Adobe Experience Manager Core Components
Gabriel Walt
 
PDF
Immerse 2016 Efficient publishing with content fragments
AdobeMarketingCloud
 
PPTX
Introduction to Sightly and Sling Models
Stefano Celentano
 
PDF
CIRCUIT 2015 - Content API's For AEM Sites
ICF CIRCUIT
 
PDF
12 hot features to engage and save time with aem 6.2
Tricode (part of Dept)
 
PPTX
IMMERSE 2016 IST Mark Szulc Keynote
AdobeMarketingCloud
 
PPTX
Ask the AEM Community Expert Feb 2016 Session: AEM + Brackets
AdobeMarketingCloud
 
PDF
User Interface customization for AEM 6
Damien Antipa
 
PDF
AEM 6.1 User Interface Customization
Christian Meyer
 
PPTX
AEM 6.0 - Author UI Customization & Features
Abhinit Bhatnagar
 
PPTX
IMMERSE'16 Introduction to AEM Tooling
AdobeMarketingCloud
 
PDF
Integrating with Adobe Marketing Cloud - Summit 2014
Paolo Mottadelli
 
PDF
Evolve13 cq-commerce-framework
Paolo Mottadelli
 
PDF
AEM GEMS Session SAML authentication in AEM
AdobeMarketingCloud
 
PDF
IMMERSE 2016 Introducing content fragments
AdobeMarketingCloud
 
PDF
Modernizing Adobe Experience Manager (AEM)
Gabriel Walt
 
PDF
10 reasons to migrate from AEM 5 to 6.1
Tricode (part of Dept)
 
PPTX
Benefits of developing single page web applications using angular js
Harbinger Systems - HRTech Builder of Choice
 
PPTX
5 single page application principles developers need to know
Chris Love
 

More Related Content

What's hot (20)

PDF
AEM Best Practices for Component Development
Gabriel Walt
 
PPTX
Adobe AEM core components
Lokesh BS
 
PPTX
AEM GEMS Session Template Editor Sept 14 2016
AdobeMarketingCloud
 
PDF
Adobe Experience Manager Core Components
Gabriel Walt
 
PDF
Immerse 2016 Efficient publishing with content fragments
AdobeMarketingCloud
 
PPTX
Introduction to Sightly and Sling Models
Stefano Celentano
 
PDF
CIRCUIT 2015 - Content API's For AEM Sites
ICF CIRCUIT
 
PDF
12 hot features to engage and save time with aem 6.2
Tricode (part of Dept)
 
PPTX
IMMERSE 2016 IST Mark Szulc Keynote
AdobeMarketingCloud
 
PPTX
Ask the AEM Community Expert Feb 2016 Session: AEM + Brackets
AdobeMarketingCloud
 
PDF
User Interface customization for AEM 6
Damien Antipa
 
PDF
AEM 6.1 User Interface Customization
Christian Meyer
 
PPTX
AEM 6.0 - Author UI Customization & Features
Abhinit Bhatnagar
 
PPTX
IMMERSE'16 Introduction to AEM Tooling
AdobeMarketingCloud
 
PDF
Integrating with Adobe Marketing Cloud - Summit 2014
Paolo Mottadelli
 
PDF
Evolve13 cq-commerce-framework
Paolo Mottadelli
 
PDF
AEM GEMS Session SAML authentication in AEM
AdobeMarketingCloud
 
PDF
IMMERSE 2016 Introducing content fragments
AdobeMarketingCloud
 
PDF
Modernizing Adobe Experience Manager (AEM)
Gabriel Walt
 
PDF
10 reasons to migrate from AEM 5 to 6.1
Tricode (part of Dept)
 
AEM Best Practices for Component Development
Gabriel Walt
 
Adobe AEM core components
Lokesh BS
 
AEM GEMS Session Template Editor Sept 14 2016
AdobeMarketingCloud
 
Adobe Experience Manager Core Components
Gabriel Walt
 
Immerse 2016 Efficient publishing with content fragments
AdobeMarketingCloud
 
Introduction to Sightly and Sling Models
Stefano Celentano
 
CIRCUIT 2015 - Content API's For AEM Sites
ICF CIRCUIT
 
12 hot features to engage and save time with aem 6.2
Tricode (part of Dept)
 
IMMERSE 2016 IST Mark Szulc Keynote
AdobeMarketingCloud
 
Ask the AEM Community Expert Feb 2016 Session: AEM + Brackets
AdobeMarketingCloud
 
User Interface customization for AEM 6
Damien Antipa
 
AEM 6.1 User Interface Customization
Christian Meyer
 
AEM 6.0 - Author UI Customization & Features
Abhinit Bhatnagar
 
IMMERSE'16 Introduction to AEM Tooling
AdobeMarketingCloud
 
Integrating with Adobe Marketing Cloud - Summit 2014
Paolo Mottadelli
 
Evolve13 cq-commerce-framework
Paolo Mottadelli
 
AEM GEMS Session SAML authentication in AEM
AdobeMarketingCloud
 
IMMERSE 2016 Introducing content fragments
AdobeMarketingCloud
 
Modernizing Adobe Experience Manager (AEM)
Gabriel Walt
 
10 reasons to migrate from AEM 5 to 6.1
Tricode (part of Dept)
 

Similar to Build single page applications using AngularJS on AEM (20)

PPTX
Benefits of developing single page web applications using angular js
Harbinger Systems - HRTech Builder of Choice
 
PPTX
5 single page application principles developers need to know
Chris Love
 
PPTX
Is AngularJS Right for Your Enterprise?
seoClarity
 
PPTX
Develop a vanilla.js spa you and your customers will love
Chris Love
 
PPTX
Single page applications the basics
Chris Love
 
PPTX
Codestrong 2012 breakout session introduction to mobile web and best practices
Axway Appcelerator
 
DOCX
Single Page Application
Prasad Narasimhan
 
PPTX
Charting your path to app nirvana with AEM Mobile
Bruce Lefebvre
 
PDF
Pablo Villalba -
.toster
 
PPTX
Summit 2015: Mobile App Dev and Content Management with Adobe Experience Manager
brucelefebvre
 
PDF
The Characteristics of a Successful SPA
Gil Fink
 
PPTX
DIGIT Noe 2016 - Overview of front end development today
Bojan Veljanovski
 
PDF
Front-End Performance Checklist 2020
Harsha MV
 
PPTX
CC 2015 Single Page Applications for the ASPNET Developer
Allen Conway
 
PPTX
Single page applications - TernopilJS #2
Andriy Deren'
 
PDF
Design Fast Websites
Nicole Sullivan
 
PPTX
Tech io spa_angularjs_20130814_v0.9.5
Ganesh Kondal
 
PDF
Angular js mobile jsday 2014 - Verona 14 may
Luciano Amodio
 
PPTX
Single Page Angular Application Presentation
Knoldus Inc.
 
PPTX
Single Page Angular Application Presentation
Knoldus Inc.
 
Benefits of developing single page web applications using angular js
Harbinger Systems - HRTech Builder of Choice
 
5 single page application principles developers need to know
Chris Love
 
Is AngularJS Right for Your Enterprise?
seoClarity
 
Develop a vanilla.js spa you and your customers will love
Chris Love
 
Single page applications the basics
Chris Love
 
Codestrong 2012 breakout session introduction to mobile web and best practices
Axway Appcelerator
 
Single Page Application
Prasad Narasimhan
 
Charting your path to app nirvana with AEM Mobile
Bruce Lefebvre
 
Pablo Villalba -
.toster
 
Summit 2015: Mobile App Dev and Content Management with Adobe Experience Manager
brucelefebvre
 
The Characteristics of a Successful SPA
Gil Fink
 
DIGIT Noe 2016 - Overview of front end development today
Bojan Veljanovski
 
Front-End Performance Checklist 2020
Harsha MV
 
CC 2015 Single Page Applications for the ASPNET Developer
Allen Conway
 
Single page applications - TernopilJS #2
Andriy Deren'
 
Design Fast Websites
Nicole Sullivan
 
Tech io spa_angularjs_20130814_v0.9.5
Ganesh Kondal
 
Angular js mobile jsday 2014 - Verona 14 may
Luciano Amodio
 
Single Page Angular Application Presentation
Knoldus Inc.
 
Single Page Angular Application Presentation
Knoldus Inc.
 
Ad

More from AdobeMarketingCloud (8)

PPTX
Adobe Ask the AEM Community Expert Session Oct 2016
AdobeMarketingCloud
 
PPTX
Ask the expert AEM Assets best practices 092016
AdobeMarketingCloud
 
PPTX
IMMERSE 2016 Cedric Huesler US Keynote
AdobeMarketingCloud
 
PPTX
AEM GEMs Session Oak Lucene Indexes
AdobeMarketingCloud
 
PPTX
IMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing Cloud
AdobeMarketingCloud
 
PPTX
Introduction to Adobe Experience Manager based e commerce
AdobeMarketingCloud
 
PDF
IMMERSE'16 Introduction to adobe experience manager back end
AdobeMarketingCloud
 
PPTX
Build single page applications using AngularJS on AEM
AdobeMarketingCloud
 
Adobe Ask the AEM Community Expert Session Oct 2016
AdobeMarketingCloud
 
Ask the expert AEM Assets best practices 092016
AdobeMarketingCloud
 
IMMERSE 2016 Cedric Huesler US Keynote
AdobeMarketingCloud
 
AEM GEMs Session Oak Lucene Indexes
AdobeMarketingCloud
 
IMMERSE'16 Intro to Adobe Experience Manager & Adobe Marketing Cloud
AdobeMarketingCloud
 
Introduction to Adobe Experience Manager based e commerce
AdobeMarketingCloud
 
IMMERSE'16 Introduction to adobe experience manager back end
AdobeMarketingCloud
 
Build single page applications using AngularJS on AEM
AdobeMarketingCloud
 
Ad

Recently uploaded (20)

PDF
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
PPTX
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
PDF
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
PPTX
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
PPTX
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
PDF
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
PDF
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
PDF
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
PDF
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
PDF
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
PPTX
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
PDF
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
PDF
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
PPTX
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
PDF
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
PPTX
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
PPTX
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
PDF
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
PDF
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
All Things Open
 
Quantum AI: Where Impossible Becomes Probable
Saikat Basu
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
10 Key Challenges for AI within the EU Data Protection Framework.pdf
Priyanka Aash
 
Enhance GitHub Copilot using MCP - Enterprise version.pdf
Nilesh Gule
 
WebdriverIO & JavaScript: The Perfect Duo for Web Automation
digitaljignect
 
9-1-1 Addressing: End-to-End Automation Using FME
Safe Software
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
"Scaling in space and time with Temporal", Andriy Lupa.pdf
Fwdays
 
UserCon Belgium: Honey, VMware increased my bill
stijn40
 
A Constitutional Quagmire - Ethical Minefields of AI, Cyber, and Privacy.pdf
Priyanka Aash
 
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
Agentic AI for Developers and Data Scientists Build an AI Agent in 10 Lines o...
All Things Open
 

Build single page applications using AngularJS on AEM

  • 1. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Build single page applications using AngularJS on AEM David Benge | Lead Computer Scientist
  • 2. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. What Is a Single Page Application? wikipedia: “A single-page application (SPA), is a web application or web site that fits on a single web page with the goal of providing a more fluid user experience akin to a desktop application. In a SPA, either all necessary code – HTML, JavaScript, and CSS – is retrieved with a single page load, or the appropriate resources are dynamically loaded and added to the page as necessary, usually in response to user actions. The page does not reload at any point in the process, nor does control transfer to another page” 2
  • 3. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Single Page Application Pro’s and Con’s Pro’s  Use of page fragments or partials speeds up the loading of secondary pages  Better mobile device experience  Reduced number of resource requests across the network greatly speeds up the applications page transitions  Lack of full page refresh creates a more app like smoothness leading to a richer user experience 3 Con’s  Has Search Engine Optimization issues due to the fact that pages/views rendering is driven via javascript.  Components and some core libs rely on the document Ready event to initialize  Speed of the initial load can be slow  Not social sharing friendly. Twitter and Facebook and others have issues when users try to share SPA pages.
  • 4. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. The Technical Reasons Are Great But Why Did I really Choose To Do An SPA? 4 • The debate on my development team between web and native has become a religious war. It was time to see if we could get the experience we want on the mobile experience without building a native application. • Mobile applications have their place, but I believe a well built site can convey the same information. • Informational mobile apps without shared web content create data silos that make discoverability and interoperability difficult. • Responsive is a nice start but we wanted to take it further. We are also experimenting with a concept we call ReDaptive. Watch our GitHub and YouTube channels for more information in the future on this concept.
  • 5. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential.  Must have native application like smoothness on everything from the high resolution desktop to the smartphone.  Search and social friendly  Works with AEM authoring  Our development pattern needed to be easy to follow and understand  No JSP; all Sightly  Semantic html markup. Each page should be useable as a data record based on markup  Javascript needed to be balanced with markup. Avoid 500 js library include madness 5
  • 6. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 6 Our Proof Of Concept Combine sling with Angular
  • 7. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 7 • Custom base page component that allows pages to be either an Angular application entry point or rendered as a view partial • Angular JS code to control the application/site and its view navigation • Rewrite rule to help handle search engines by adding a selector • Based on runmode Base Page includes content or an Angular ui-view element • Responsive design • Custom video component that makes use of Adobe Dynamic Media and native HTML5 video tag markup. Selects best rendition to use based on the video element size and browser device group detected • Use of BrowseCap for device detection • Nearly all Sightly • Use of Less for style • Adobe Analytics for metrics • Uses AdobeAtAdobe boiler plate project - Available in our GIT repo • Creative Cloud Extract used to build site from XD comps • Photoshop used to develop the comps • Adobe Edge inspect used to debug on devices
  • 8. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. High Level Technical Overview Of The Base Page Component  We created a standard page component that inherits from wcm/foundation/components/page.  This new base page component has a content.html include in the center. This is where our page views get loaded. We change the markup based on if the request was made on a publish or author environment.  If the request was on author we do a standard content include.  If it’s a page request on publish we don’t do the include and just insert the div with the angular ui-view <div class="page-content" ui-view data-sly-test="${teamsitePage.isPublisher && !teamsitePage.isSearchEngine}"></div> <div data-sly-include="content.html" class="page-content" data-sly-test="${!teamsitePage.isPublisher || teamsitePage.isSearchEngine}"></div>  In the base component we also include some meta data. We use this to tell angular and other components how to behave based on the environment. <meta name="publisher" content="${teamsitePage.isPublisher}"/> <meta name="wcmmode" content="${teamsitePage.metaWcmMode}"> 8
  • 9. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. High Level Technical Overview Of The Standard Page Component  All the pages inherit from the base page  Each new page component includes their markup in a file named content.html  If needed they can include a controller like in this example  The controller code is stored in a client lib under the page component 9 <div class="contact-block" ng-controller="ContactController"> <div class="hi"><span>Hi. </span>How can we help you?</div> <div class="methods"> <div class="method"> <div class="title">Technology Questions</div> <div class="phone">+1 613 857 9233</div> <div class="email">[email protected]</div> </div> <div class="method"> <div class="title">Work with Us</div> <div class="phone">+1 613 857 9233</div> <div class="email">[email protected]</div> </div> <div class="method"> <div class="title">Everything Else</div> <div class="phone">+1 613 857 9233</div> <div class="email">[email protected]</div> </div> </div> </div> </div>
  • 10. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. High Level Technical Overview Of The Base Page Component Partial Selector  Under the base page component we have a file named partial.html. This file handles any request for a page that has the partial selection appended to it. This file simply includes content.html with No header, No footer, No navigation, just the meaty center of the view in our case.  The partial also includes new metatags with data to replace the header meta data. The new tags are prefixed with partial for example partial:title. Its contents will replace the header metatag’s content for title. The replacement of the metadata is handled by the Angular application. <meta name="partial:keywords" content="${head.keywords}" id="partialKeywords"/> 10
  • 11. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. High Level Technical Overview Of The Base Page Component Partial Selector We need to tell Angular about the site hierarchy because Angular will be handling navigation from view to view. Angular controls the view loading on the client side via a library called router.ui so it needs to know how map urls to view partials. Under the base page component we have a file named routes.json.jsp. This file provides us a endpoint for Angular’s ui.router to use to load the router and state provider on the fly on the first page load. One thing we do alter on the routes is the value of the templateUrl returned from our routes.json.jsp. On our page path we include a partial selector. Thanks to the magic that is sling when we make that request now we will get just the center conent of the page when we navigate from view to view. 11
  • 12. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. High Level Technical Overview Of The Base Page Component Angular Router 12 Example output from our routes.json.jsp file is shown to the left. This is an example of how we are rewriting out our routes and re-writing the templateUrl to include the .partial selector. Example /content/teamsite/work.html becomes /content/teamsite/work.partial.html When the application/site is loaded in the browser any link or navigation to a url for example /content/teamsite/work/cmo.html is handled by the $location service. It will resolve the url to the templateUrl which is set to /content/teamsite/work/cmo.partial.html. The request to /content/teamsite/work/cmo.partial.html will be returned as just the center of the view and injected into the existing page.
  • 13. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. So Far This Is What It Looks Like On The AEM Page Component Side 13
  • 14. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. High Technical Overview Of The Proof Of Concept – Component Conclusion So that’s it for the AEM side of the application. Once the base component pattern was established it was easy to work with. Its all fairly normal AEM component and page development from that point on. With a few exceptions for stock components that make heavy use of the document ready event. Summary  In author runmode, it will do full page refreshes  Search engine friendly due to the fact there is a full page request  On social shares of a page, the path exists  In publish run mode, the client side will do partial page refresh Thanks to the magic of sling resolution we are able to serve full pages or partials as needed. Every path can be an entry point to our SPA base application. 14
  • 15. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. 15 The Angular Bits
  • 16. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. The Angular Js bits we used to round out this solution are:  Controller – Controllers ended up being minimally used at the page level. Router.ui – used to load and control the routes. We also use the routing events to load page meta data  Service – We have a service that helps with pulling and setting meta data on the page  Directives – We have a few to provide functionality  Custom html5 video player directive  Explore page directive to help with the scrolling and other ui bits on the explore page  Angular Carousel which drives the image carousels 16
  • 17. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Whats Next? 17 • We will be adding more functionality to the proof of concept site • We are really liking directives and plan to do more work in that area and investigate using polymer • Clean up of the header libs to remove some of the dependency on document ready event
  • 18. © 2015 Adobe Systems Incorporated. All Rights Reserved. Adobe Confidential. Code is located in out Github repo https://github.com/AdobeAtAdobe Live site can be found at http://www.adobeatadobe.com Twitter @AdobeAtAdobe Video sessions on this proof of concept will be posted on our YouTube channel https://www.youtube.com/user/AdobeAtAdobe