SlideShare a Scribd company logo
1 of 50
Download to read offline
APACHE SLING & FRIENDS TECH MEETUP
BERLIN, 23-25 SEPTEMBER 2013
DEVICE DETECTION WITH APACHE DEVICEMAP
ANDREW SAVORY, CONRAD WOELTGE
adaptTo() 2013 2
Device Detection
adaptTo() 2013 3
I want to know, what device I run my code on.
I want to know, what device I run my code on.
adaptTo() 2013 4
 Really?
I have no idea what to do
with a T-Mobile G2x
adaptTo() 2013 5
I want to know, what the browser can do.
I want to know, what the browser can do.
adaptTo() 2013 6
adaptTo() 2013 7
Well, let’s start with a device group.
Device Groups
adaptTo() 2013 8
 smartphone
 feature phone
 touch
 tablet
 game console
 high resolution display
 modern browser
 old browser
adaptTo() 2013 9
Detection
Detect Device: I want to ...
adaptTo() 2013 10
On server side:
 Send to an optimized version of my site
 Deliver an optimized version of my site
Client Side
 Send to an optimized version of my site
 Optimize the version loaded
Detect Device
adaptTo() 2013 11
On server side:
 Deliver an optimized version of my site
RESS: “Responsive Design + Server Side
Components”
Client Side
 Optimize the version loaded
“Progressive enhancement”
adaptTo() 2013 12
Device Detection Server Side
HTTP: Device Detection Server Side
adaptTo() 2013 13
HTTP Request
GET / HTTP/1.1
Host: www.adaptto.org
User-Agent: User-Agent:Mozilla/5.0 (Linux; U; Android
4.1.2; en-gb; GT-I9305 Build/JZO54K)
AppleWebKit/534.30 (KHTML, like Gecko)
Version/4.0 Mobile Safari/534.30
Accept:
text/html,application/xhtml+xml,application/xml;q
=0.9,*/*;q=0.8
Accept-Language: en-us
Accept-Encoding: gzip, deflate
HTTP: Device Detection Server Side
adaptTo() 2013 14
User-Agent:Mozilla/5.0 (Linux; U; Android 4.1.2; en-gb;
GT-I9305 Build/JZO54K) AppleWebKit/534.30 (KHTML, like
Gecko) Version/4.0 Mobile Safari/534.30
Device Description Repository
adaptTo() 2013 15
User-Agent:Mozilla/5.0 (Linux; U;
Android 4.1.2; en-gb; GT-I9305
Build/JZO54K) AppleWebKit/534.30
(KHTML, like Gecko) Version/4.0 Mobile
Safari/534.30
Device Description Repository
(DDR)
DDR
Device Description Repository
adaptTo() 2013 16
 WURFL (commercial license since 2011, ~30k
records)
 Device Atlas
 51 Degree
 OpenDDR (Open Source)
 ...
 Various offers based on repositories
Device Description Repository
adaptTo() 2013 17
 Keep it up to date needs effort that requires a
business model as paid subscriptions
 Offers include
 Direct install
 Cloud Service calls
 Can run on each layer on your server
infrastructure
RegEx based groups
adaptTo() 2013 18
User-Agent:Mozilla/5.0 (Linux; U;
Android 4.1.2; en-gb; GT-I9305
Build/JZO54K) AppleWebKit/534.30
(KHTML, like Gecko) Version/4.0 Mobile
Safari/534.30
RewriteCond %{HTTP_USER_AGENT}
(android|bbd+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge
|maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm(
os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino
[NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s-
)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s
)|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-
|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-
7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-
c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-
|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg(
g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-
| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-
|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn-
2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i-
)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-
|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-
|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|-
v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-) [NC]
RewriteRule ^$ http://detectmobilebrowser.com/mobile [R,L]
RegEx
 mobile phone
 tablet
 modern browser
 old browser
 desktop
http://detectmobilebrowsers.com
Device Detection Server Side
adaptTo() 2013 19
Advantages
 minimize bandwidth usage
 can run effectively on each
layer on your server
infrastructure
 redirect or deliver w/in the first
request
 no requirements on client side
Disadvantages
 Might require vary-headers
caching (REST?)
 needs recent updates on DDR or
might not be precise
 performance impact if run on
every request
adaptTo() 2013 20
Device Detection Client Side
Device Capability Detection Client Side
adaptTo() 2013 21
http://tests.caniuse.com
Capability Detection Client Side
adaptTo() 2013 22
 Primarily based on JavaScript/Modernizr
 Runs on client browser
 Fundamental to “progressive enhancement”
Client Side Capability Detection
adaptTo() 2013 23
Advantages
 detects effective capabilities
(e.g. incl. current window size)
 can load resources only if a
feature is supported
 fully cacheable
Disadvantages
 needs to run on client, esp. for
redirect scenario additional
round trips
 requires JavaScript enabled and
standard compliant browsers
adaptTo() 2013 24
Client Side Or Server Side?
Client Side Or Server Side?
adaptTo() 2013 25
 It’s not one or the other – pick what fits best!
Example
adaptTo() 2013 26
 http://www.dhl.co.uk
 Server Side Detect and Redirect:
 Mobile  m.dhl.co.uk
 anything else  www.dhl.co.uk
 Client Side:
 Responsive image handling
 Image size by effective slot size
 Image size by device-pixel-ratio
 Image quality by effective bandwidth
adaptTo() 2013 28
Practical Example
Apache DeviceMap
adaptTo() 2013 29
Apache DeviceMap
Device Description
Repository + Log Capture
Server-side device
detection (DeviceMap)
Client-side device
detection (BrowserMap)
http://www.w3.org/TR/DDR-Simple-API/
adaptTo() 2013 30
BrowserMap
BrowserMap
adaptTo() 2013 31
 YABFDL - yet another browser features
detection library
 modular probes and code snippets that detect
specific features of the client
 detect the client's type and optimize page
rendering or provide the client with alternate
website versions
 detect the device groups a client belongs to
BrowserMap Device Groups
adaptTo() 2013 32
 The following groups are provided by default:
 smartphone - feature phones / smartphones
 tablet - various tablets, based on screen size and
the presence of touch capabilities
 highResolutionDisplay - devices with pixel ratio
greater than or equal to 2
 browser - desktop browsers capable of CSS 3D
transitions
 oldBrowser - less modern desktop browsers
adaptTo() 2013 33
Implementing Multichannel
Generate from Archetype
adaptTo() 2013 34
mvn archetype:generate
-DarchetypeGroupId=org.apache.sling
-DarchetypeArtifactId=sling-initial-content-archetype
-DarchetypeVersion=1.0.1-SNAPSHOT
groupID: org.adaptto
artifactId: multichannel
version: <default>
package: <default>
http://www.andrewsavory.com/presentations/CQCon_2013_CQ_Maven_Methods/
Aside: Yak Shaving
adaptTo() 2013 35
Yak Shaving by snapperwolf
http://www.flickr.com/photos/snapperwolf/6952219933/
Archetype fixes
adaptTo() 2013 36
[asavory@waif initial-content]$ pwd
svn-apache/sling/tooling/maven/archetypes/initial-content
[asavory@waif initial-content]$ svn status
M src/main/resources/META-INF/maven/archetype-metadata.xml
M src/main/resources/META-INF/maven/archetype.xml
A + src/main/resources/archetype-resources/src/main/resources/SLING-CONTENT
A + src/main/resources/archetype-resources/src/main/resources/SLING-CONTENT/apps
M + src/main/resources/archetype-resources/src/main/resources/SLING-CONTENT/apps/html.esp
D src/main/resources/archetype-resources/src/main/resources/SLING-CONTENT/scripts
D src/main/resources/archetype-resources/src/main/resources/SLING-CONTENT/scripts/html.esp
A src/main/resources/archetype-resources/src/main/resources/SLING-CONTENT/content/my-first-node.json
D src/main/resources/archetype-resources/src/main/resources/SLING-CONTENT/content/my-first-node.xml
D src/main/resources/archetype-resources/src/main/resources/SLING-INF
D src/main/resources/archetype-resources/src/main/resources/SLING-INF/scripts
D src/main/resources/archetype-resources/src/main/resources/SLING-INF/scripts/html.esp
D src/main/resources/archetype-resources/src/main/resources/SLING-INF/content
D src/main/resources/archetype-resources/src/main/resources/SLING-INF/content/my-first-node.xml
D src/main/resources/archetype-resources/src/main/resources/SLING-INF/nodetypes
D src/main/resources/archetype-resources/src/main/resources/SLING-INF/nodetypes/nodetypes.cnd
M src/main/resources/archetype-resources/pom.xml
Files
adaptTo() 2013 37
multichannel
|-src
|---main
|-----resources
|-------SLING-CONTENT
|---------apps
|-----------multichannel
|---------content
mvn -PautoInstallBundle install
adaptTo() 2013 38
Demo
adaptTo() 2013 39
Adding BrowserMap
Adding BrowserMap
adaptTo() 2013 40
<!-- BrowserMap feature detection library and dependencies -->
<script [..] src="/content/demo/js/browsermap/bmaputil.js"></script>
< [..] src="/content/demo/js/browsermap/bmap.js"></script>
< [..] src="/content/demo/js/externals/modernizr/modernizr.custom.js"></script>
< [..] src="/content/demo/js/externals/matchMedia/matchMedia.js"></script>
< [..] src="/content/demo/js/browsermap/probes.js"></script>
< [..] src="/content/demo/js/browsermap/devicegroups.js"></script>
<!-- Decide if the client should be forwarded to the best matching alternate link, depending on the detected
device group. -->
<script language="javascript">
BrowserMap.forwardRequest();
</script>
adaptTo() 2013 41
Demo
adaptTo() 2013 42
Controlling alternates
rel=“alternate”
adaptTo() 2013 43
 The keyword creates a hyperlink referencing an
alternate representation of the current document.
 When used with the media attribute, it means a link
to a version of the current document, especially for
the specified device or medium indicated by the
media attribute.
 A way of determining the correct URL to which a
client should be forwarded, depending on its device
group
rel=“alternate”
adaptTo() 2013 44
<link rel="alternate" hreflang="en" data-bmap-devgroups="smartphone"
href="index.smartphone.html" />
<link rel="alternate" hreflang="fr" data-bmap-devgroups="tablet"
href="/fr/index.tablet.html" />
<link rel="alternate" hreflang="de" data-bmap-
devgroups="highResolutionDisplay"
href="de/index.highResolutionDisplay.html" />
Why is “alternate” important?
adaptTo() 2013 45
Controlling BrowserMap #1
adaptTo() 2013 46
<link rel="alternate" data-bmap-devgroups="tablet" href="index.tablet.html" />
<[..] data-bmap-devgroups="smartphone" href="index.smartphone.html" />
<[..] data-bmap-devgroups="browser" href="index.browser.html" />
<[..] data-bmap-devgroups="oldBrowser" href="index.oldBrowser.html" />
{
"jcr:primaryType" : "nt:unstructured",
"sling:resourceType" : "/apps/multichannel/components/page",
"jcr:title" : "Hello World",
"title" : "Hello World",
"description" : "This node is a demo node.”,
"data-bmap-devgroups" : ["browser", "oldBrowser”, "smartphone"]
}
(+= highResolutionDisplay)
Controlling BrowserMap #2
adaptTo() 2013 47
<%
final ValueMap attributes = ResourceUtil.getValueMap(resource);
final String[] bmapDevGroups = attributes.get("data-bmap-devgroups",
String[].class);
for (String bmapDevGroup : bmapDevGroups) { %>
<link rel="alternate"
hreflang="en”
data-bmap-devgroups="<%= bmapDevGroup %>"
href="index.<%= bmapDevGroup %>-adaptTo.html" />
<%
}
%>
adaptTo() 2013 48
Demo
What’s next?
adaptTo() 2013 49
 Network speed detection (foresight.js)
 Minification / bundling of resources
 Server-side capability detection with DeviceMap
 …
References & links
adaptTo() 2013 50
 http://radu.cotescu.com/talks/2013.06.27_
BJUG13/#/
 http://incubator.apache.org/devicemap/
 https://github.com/savs/multichannel-demo
 https://github.com/raducotescu/devicemap-
demo
adaptTo() 2013 51
Thank You.
Questions?

More Related Content

Similar to AdaptTo 2013 Device Detection with Apache DeviceMap

The Magic of flutter Comex oman 2019
The Magic of flutter Comex oman 2019The Magic of flutter Comex oman 2019
The Magic of flutter Comex oman 2019Ahmed Abu Eldahab
 
Programming objects with android
Programming objects with androidProgramming objects with android
Programming objects with androidfirenze-gtug
 
Android – As a tool of innovation
Android – As a tool of innovation Android – As a tool of innovation
Android – As a tool of innovation Pallab Sarkar
 
Unit 1-android-and-its-tools-ass
Unit 1-android-and-its-tools-assUnit 1-android-and-its-tools-ass
Unit 1-android-and-its-tools-assARVIND SARDAR
 
Android Meetup, Илья Лёвин
Android Meetup, Илья ЛёвинAndroid Meetup, Илья Лёвин
Android Meetup, Илья ЛёвинGDG Saint Petersburg
 
Chrysler Smart Screen
Chrysler Smart ScreenChrysler Smart Screen
Chrysler Smart ScreenMostafa Sameh
 
TK2323 Lecture 1 - Introduction to Mobile Application.pdf
TK2323 Lecture 1 - Introduction to Mobile Application.pdfTK2323 Lecture 1 - Introduction to Mobile Application.pdf
TK2323 Lecture 1 - Introduction to Mobile Application.pdfLam Chun
 
Android Development Overview
Android Development OverviewAndroid Development Overview
Android Development OverviewIgor Birman
 
Android 3.0 Portland Java User Group 2011-03-15
Android 3.0 Portland Java User Group 2011-03-15Android 3.0 Portland Java User Group 2011-03-15
Android 3.0 Portland Java User Group 2011-03-15sullis
 
[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android TipsKenichi Kambara
 
Using the Presentation API and external screens on Android
Using the Presentation API and external screens on AndroidUsing the Presentation API and external screens on Android
Using the Presentation API and external screens on AndroidXavier Hallade
 
Android– forensics and security testing
Android– forensics and security testingAndroid– forensics and security testing
Android– forensics and security testingSanthosh Kumar
 
Presentation on android
Presentation on androidPresentation on android
Presentation on androidsonyhontok
 
Introduction to Android
Introduction to Android Introduction to Android
Introduction to Android Ranjith Kumar
 
1 introduction of android
1 introduction of android1 introduction of android
1 introduction of androidakila_mano
 
Golden Gekko presentation Google I/O 2014
Golden Gekko presentation Google I/O 2014Golden Gekko presentation Google I/O 2014
Golden Gekko presentation Google I/O 2014DMI
 
Android word or phrases
Android word or phrasesAndroid word or phrases
Android word or phraseschael_boy
 

Similar to AdaptTo 2013 Device Detection with Apache DeviceMap (20)

The Magic of flutter Comex oman 2019
The Magic of flutter Comex oman 2019The Magic of flutter Comex oman 2019
The Magic of flutter Comex oman 2019
 
Programming objects with android
Programming objects with androidProgramming objects with android
Programming objects with android
 
Android – As a tool of innovation
Android – As a tool of innovation Android – As a tool of innovation
Android – As a tool of innovation
 
Unit 1-android-and-its-tools-ass
Unit 1-android-and-its-tools-assUnit 1-android-and-its-tools-ass
Unit 1-android-and-its-tools-ass
 
Android Meetup, Илья Лёвин
Android Meetup, Илья ЛёвинAndroid Meetup, Илья Лёвин
Android Meetup, Илья Лёвин
 
Chrysler Smart Screen
Chrysler Smart ScreenChrysler Smart Screen
Chrysler Smart Screen
 
TK2323 Lecture 1 - Introduction to Mobile Application.pdf
TK2323 Lecture 1 - Introduction to Mobile Application.pdfTK2323 Lecture 1 - Introduction to Mobile Application.pdf
TK2323 Lecture 1 - Introduction to Mobile Application.pdf
 
Android
AndroidAndroid
Android
 
Android Development Overview
Android Development OverviewAndroid Development Overview
Android Development Overview
 
Designing Apps for the Motorola XOOM
Designing Apps for the Motorola XOOM Designing Apps for the Motorola XOOM
Designing Apps for the Motorola XOOM
 
Android 3.0 Portland Java User Group 2011-03-15
Android 3.0 Portland Java User Group 2011-03-15Android 3.0 Portland Java User Group 2011-03-15
Android 3.0 Portland Java User Group 2011-03-15
 
[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips[Droidcon Paris 2013]Multi-Versioning Android Tips
[Droidcon Paris 2013]Multi-Versioning Android Tips
 
Using the Presentation API and external screens on Android
Using the Presentation API and external screens on AndroidUsing the Presentation API and external screens on Android
Using the Presentation API and external screens on Android
 
Android– forensics and security testing
Android– forensics and security testingAndroid– forensics and security testing
Android– forensics and security testing
 
Presentation on android
Presentation on androidPresentation on android
Presentation on android
 
Introduction to Android
Introduction to Android Introduction to Android
Introduction to Android
 
Mind the gap
Mind the gapMind the gap
Mind the gap
 
1 introduction of android
1 introduction of android1 introduction of android
1 introduction of android
 
Golden Gekko presentation Google I/O 2014
Golden Gekko presentation Google I/O 2014Golden Gekko presentation Google I/O 2014
Golden Gekko presentation Google I/O 2014
 
Android word or phrases
Android word or phrasesAndroid word or phrases
Android word or phrases
 

Recently uploaded

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 

Recently uploaded (20)

Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 

AdaptTo 2013 Device Detection with Apache DeviceMap

  • 1. APACHE SLING & FRIENDS TECH MEETUP BERLIN, 23-25 SEPTEMBER 2013 DEVICE DETECTION WITH APACHE DEVICEMAP ANDREW SAVORY, CONRAD WOELTGE
  • 3. adaptTo() 2013 3 I want to know, what device I run my code on.
  • 4. I want to know, what device I run my code on. adaptTo() 2013 4  Really? I have no idea what to do with a T-Mobile G2x
  • 5. adaptTo() 2013 5 I want to know, what the browser can do.
  • 6. I want to know, what the browser can do. adaptTo() 2013 6
  • 7. adaptTo() 2013 7 Well, let’s start with a device group.
  • 8. Device Groups adaptTo() 2013 8  smartphone  feature phone  touch  tablet  game console  high resolution display  modern browser  old browser
  • 10. Detect Device: I want to ... adaptTo() 2013 10 On server side:  Send to an optimized version of my site  Deliver an optimized version of my site Client Side  Send to an optimized version of my site  Optimize the version loaded
  • 11. Detect Device adaptTo() 2013 11 On server side:  Deliver an optimized version of my site RESS: “Responsive Design + Server Side Components” Client Side  Optimize the version loaded “Progressive enhancement”
  • 12. adaptTo() 2013 12 Device Detection Server Side
  • 13. HTTP: Device Detection Server Side adaptTo() 2013 13 HTTP Request GET / HTTP/1.1 Host: www.adaptto.org User-Agent: User-Agent:Mozilla/5.0 (Linux; U; Android 4.1.2; en-gb; GT-I9305 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 Accept: text/html,application/xhtml+xml,application/xml;q =0.9,*/*;q=0.8 Accept-Language: en-us Accept-Encoding: gzip, deflate
  • 14. HTTP: Device Detection Server Side adaptTo() 2013 14 User-Agent:Mozilla/5.0 (Linux; U; Android 4.1.2; en-gb; GT-I9305 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
  • 15. Device Description Repository adaptTo() 2013 15 User-Agent:Mozilla/5.0 (Linux; U; Android 4.1.2; en-gb; GT-I9305 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 Device Description Repository (DDR) DDR
  • 16. Device Description Repository adaptTo() 2013 16  WURFL (commercial license since 2011, ~30k records)  Device Atlas  51 Degree  OpenDDR (Open Source)  ...  Various offers based on repositories
  • 17. Device Description Repository adaptTo() 2013 17  Keep it up to date needs effort that requires a business model as paid subscriptions  Offers include  Direct install  Cloud Service calls  Can run on each layer on your server infrastructure
  • 18. RegEx based groups adaptTo() 2013 18 User-Agent:Mozilla/5.0 (Linux; U; Android 4.1.2; en-gb; GT-I9305 Build/JZO54K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30 RewriteCond %{HTTP_USER_AGENT} (android|bbd+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s- )|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd- |co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4- 7]0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs- c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |- |/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|-[a-w])|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(- | |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)- |on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-([1-8]|c))|phil|pire|pl(ay|uc)|pn- 2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-[2-7]|i- )|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(- |m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg- |tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|- v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-) [NC] RewriteRule ^$ http://detectmobilebrowser.com/mobile [R,L] RegEx  mobile phone  tablet  modern browser  old browser  desktop http://detectmobilebrowsers.com
  • 19. Device Detection Server Side adaptTo() 2013 19 Advantages  minimize bandwidth usage  can run effectively on each layer on your server infrastructure  redirect or deliver w/in the first request  no requirements on client side Disadvantages  Might require vary-headers caching (REST?)  needs recent updates on DDR or might not be precise  performance impact if run on every request
  • 20. adaptTo() 2013 20 Device Detection Client Side
  • 21. Device Capability Detection Client Side adaptTo() 2013 21 http://tests.caniuse.com
  • 22. Capability Detection Client Side adaptTo() 2013 22  Primarily based on JavaScript/Modernizr  Runs on client browser  Fundamental to “progressive enhancement”
  • 23. Client Side Capability Detection adaptTo() 2013 23 Advantages  detects effective capabilities (e.g. incl. current window size)  can load resources only if a feature is supported  fully cacheable Disadvantages  needs to run on client, esp. for redirect scenario additional round trips  requires JavaScript enabled and standard compliant browsers
  • 24. adaptTo() 2013 24 Client Side Or Server Side?
  • 25. Client Side Or Server Side? adaptTo() 2013 25  It’s not one or the other – pick what fits best!
  • 26. Example adaptTo() 2013 26  http://www.dhl.co.uk  Server Side Detect and Redirect:  Mobile  m.dhl.co.uk  anything else  www.dhl.co.uk  Client Side:  Responsive image handling  Image size by effective slot size  Image size by device-pixel-ratio  Image quality by effective bandwidth
  • 28. Apache DeviceMap adaptTo() 2013 29 Apache DeviceMap Device Description Repository + Log Capture Server-side device detection (DeviceMap) Client-side device detection (BrowserMap) http://www.w3.org/TR/DDR-Simple-API/
  • 30. BrowserMap adaptTo() 2013 31  YABFDL - yet another browser features detection library  modular probes and code snippets that detect specific features of the client  detect the client's type and optimize page rendering or provide the client with alternate website versions  detect the device groups a client belongs to
  • 31. BrowserMap Device Groups adaptTo() 2013 32  The following groups are provided by default:  smartphone - feature phones / smartphones  tablet - various tablets, based on screen size and the presence of touch capabilities  highResolutionDisplay - devices with pixel ratio greater than or equal to 2  browser - desktop browsers capable of CSS 3D transitions  oldBrowser - less modern desktop browsers
  • 33. Generate from Archetype adaptTo() 2013 34 mvn archetype:generate -DarchetypeGroupId=org.apache.sling -DarchetypeArtifactId=sling-initial-content-archetype -DarchetypeVersion=1.0.1-SNAPSHOT groupID: org.adaptto artifactId: multichannel version: <default> package: <default> http://www.andrewsavory.com/presentations/CQCon_2013_CQ_Maven_Methods/
  • 34. Aside: Yak Shaving adaptTo() 2013 35 Yak Shaving by snapperwolf http://www.flickr.com/photos/snapperwolf/6952219933/
  • 35. Archetype fixes adaptTo() 2013 36 [asavory@waif initial-content]$ pwd svn-apache/sling/tooling/maven/archetypes/initial-content [asavory@waif initial-content]$ svn status M src/main/resources/META-INF/maven/archetype-metadata.xml M src/main/resources/META-INF/maven/archetype.xml A + src/main/resources/archetype-resources/src/main/resources/SLING-CONTENT A + src/main/resources/archetype-resources/src/main/resources/SLING-CONTENT/apps M + src/main/resources/archetype-resources/src/main/resources/SLING-CONTENT/apps/html.esp D src/main/resources/archetype-resources/src/main/resources/SLING-CONTENT/scripts D src/main/resources/archetype-resources/src/main/resources/SLING-CONTENT/scripts/html.esp A src/main/resources/archetype-resources/src/main/resources/SLING-CONTENT/content/my-first-node.json D src/main/resources/archetype-resources/src/main/resources/SLING-CONTENT/content/my-first-node.xml D src/main/resources/archetype-resources/src/main/resources/SLING-INF D src/main/resources/archetype-resources/src/main/resources/SLING-INF/scripts D src/main/resources/archetype-resources/src/main/resources/SLING-INF/scripts/html.esp D src/main/resources/archetype-resources/src/main/resources/SLING-INF/content D src/main/resources/archetype-resources/src/main/resources/SLING-INF/content/my-first-node.xml D src/main/resources/archetype-resources/src/main/resources/SLING-INF/nodetypes D src/main/resources/archetype-resources/src/main/resources/SLING-INF/nodetypes/nodetypes.cnd M src/main/resources/archetype-resources/pom.xml
  • 39. Adding BrowserMap adaptTo() 2013 40 <!-- BrowserMap feature detection library and dependencies --> <script [..] src="/content/demo/js/browsermap/bmaputil.js"></script> < [..] src="/content/demo/js/browsermap/bmap.js"></script> < [..] src="/content/demo/js/externals/modernizr/modernizr.custom.js"></script> < [..] src="/content/demo/js/externals/matchMedia/matchMedia.js"></script> < [..] src="/content/demo/js/browsermap/probes.js"></script> < [..] src="/content/demo/js/browsermap/devicegroups.js"></script> <!-- Decide if the client should be forwarded to the best matching alternate link, depending on the detected device group. --> <script language="javascript"> BrowserMap.forwardRequest(); </script>
  • 42. rel=“alternate” adaptTo() 2013 43  The keyword creates a hyperlink referencing an alternate representation of the current document.  When used with the media attribute, it means a link to a version of the current document, especially for the specified device or medium indicated by the media attribute.  A way of determining the correct URL to which a client should be forwarded, depending on its device group
  • 43. rel=“alternate” adaptTo() 2013 44 <link rel="alternate" hreflang="en" data-bmap-devgroups="smartphone" href="index.smartphone.html" /> <link rel="alternate" hreflang="fr" data-bmap-devgroups="tablet" href="/fr/index.tablet.html" /> <link rel="alternate" hreflang="de" data-bmap- devgroups="highResolutionDisplay" href="de/index.highResolutionDisplay.html" />
  • 44. Why is “alternate” important? adaptTo() 2013 45
  • 45. Controlling BrowserMap #1 adaptTo() 2013 46 <link rel="alternate" data-bmap-devgroups="tablet" href="index.tablet.html" /> <[..] data-bmap-devgroups="smartphone" href="index.smartphone.html" /> <[..] data-bmap-devgroups="browser" href="index.browser.html" /> <[..] data-bmap-devgroups="oldBrowser" href="index.oldBrowser.html" /> { "jcr:primaryType" : "nt:unstructured", "sling:resourceType" : "/apps/multichannel/components/page", "jcr:title" : "Hello World", "title" : "Hello World", "description" : "This node is a demo node.”, "data-bmap-devgroups" : ["browser", "oldBrowser”, "smartphone"] } (+= highResolutionDisplay)
  • 46. Controlling BrowserMap #2 adaptTo() 2013 47 <% final ValueMap attributes = ResourceUtil.getValueMap(resource); final String[] bmapDevGroups = attributes.get("data-bmap-devgroups", String[].class); for (String bmapDevGroup : bmapDevGroups) { %> <link rel="alternate" hreflang="en” data-bmap-devgroups="<%= bmapDevGroup %>" href="index.<%= bmapDevGroup %>-adaptTo.html" /> <% } %>
  • 48. What’s next? adaptTo() 2013 49  Network speed detection (foresight.js)  Minification / bundling of resources  Server-side capability detection with DeviceMap  …
  • 49. References & links adaptTo() 2013 50  http://radu.cotescu.com/talks/2013.06.27_ BJUG13/#/  http://incubator.apache.org/devicemap/  https://github.com/savs/multichannel-demo  https://github.com/raducotescu/devicemap- demo
  • 50. adaptTo() 2013 51 Thank You. Questions?