You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devicemap.apache.org by bd...@apache.org on 2012/03/06 14:21:42 UTC

svn commit: r1297464 - in /incubator/devicemap/trunk/prototypes: ./ logcapture/ logcapture/devicemap.png logcapture/httpd.conf logcapture/index.html

Author: bdelacretaz
Date: Tue Mar  6 13:21:42 2012
New Revision: 1297464

URL: http://svn.apache.org/viewvc?rev=1297464&view=rev
Log:
logcapture prototype

Added:
    incubator/devicemap/trunk/prototypes/
    incubator/devicemap/trunk/prototypes/logcapture/
    incubator/devicemap/trunk/prototypes/logcapture/devicemap.png   (with props)
    incubator/devicemap/trunk/prototypes/logcapture/httpd.conf
    incubator/devicemap/trunk/prototypes/logcapture/index.html

Added: incubator/devicemap/trunk/prototypes/logcapture/devicemap.png
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/prototypes/logcapture/devicemap.png?rev=1297464&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/devicemap/trunk/prototypes/logcapture/devicemap.png
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: incubator/devicemap/trunk/prototypes/logcapture/httpd.conf
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/prototypes/logcapture/httpd.conf?rev=1297464&view=auto
==============================================================================
--- incubator/devicemap/trunk/prototypes/logcapture/httpd.conf (added)
+++ incubator/devicemap/trunk/prototypes/logcapture/httpd.conf Tue Mar  6 13:21:42 2012
@@ -0,0 +1,52 @@
+# DeviceMap logcapture prototype httpd config file
+# meant to use as an example to configure server logs
+#
+# To test this, run
+# 
+#   export BASE=/usr (adapt for your environment)
+#   httpd -d $BASE -f $PWD/httpd.conf -C "DocumentRoot $PWD" -k start
+#  
+# and visit http://localhost:9362 with your mobile device to capture 
+# device info at /tmp/devicemap_access.log
+#
+# The log file should look like
+#
+#   "GET /devicemap.png?dmap=1&screen.width=1286&screen.height=1929 HTTP/1.1" 
+#   _DMAP: 
+#   x-wap-profile="http://www.htcmms.com.tw/Android/Common/DesireZ/ua-profile.xml" 
+#   UA="Mozilla/5.0 (Linux; U; Android 2.3.3...)"
+#
+# which provide basic info about the client device
+#
+
+Listen 9362
+
+# Load a minimal set of modules
+LoadModule dir_module libexec/apache2/mod_dir.so
+LoadModule log_config_module libexec/apache2/mod_log_config.so
+LoadModule mime_magic_module libexec/apache2/mod_mime_magic.so
+LoadModule mime_module libexec/apache2/mod_mime.so
+
+# Serve current folder
+<Directory ".">
+    Options Indexes FollowSymLinks MultiViews
+</Directory>
+
+<IfModule dir_module>
+    DirectoryIndex index.html
+</IfModule>
+
+# Minimal httpd setup
+ServerName localhost
+ServerRoot /tmp
+LockFile devicemap_accept.lock
+PidFile devicemap_httpd.pid
+ErrorLog devicemap_error.log
+
+# Log request path and some useful HTTP headers - the request to
+# the dummy image will provide device information
+<IfModule log_config_module>
+    LogLevel info
+    LogFormat "\"%r\" _DMAP: x-wap-profile=\"%{x-wap-profile}i\" UA=\"%{User-Agent}i\""  combined
+    CustomLog "devicemap_access.log" combined
+</IfModule>

Added: incubator/devicemap/trunk/prototypes/logcapture/index.html
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/prototypes/logcapture/index.html?rev=1297464&view=auto
==============================================================================
--- incubator/devicemap/trunk/prototypes/logcapture/index.html (added)
+++ incubator/devicemap/trunk/prototypes/logcapture/index.html Tue Mar  6 13:21:42 2012
@@ -0,0 +1,96 @@
+<html>
+
+<head>
+<title>DeviceMap logcapture prototype</title>
+
+<style type="text/css">
+body {
+    font-family: Georgia, Verdana, Arial, serif;
+}
+h1 {
+    border-bottom: solid grey 1px;
+}
+.imgurl {
+    font-size:80%;
+    font-family: Courier New, Courier, monospace;
+}
+.title {
+    font-weight:bold;
+}
+</style>
+</head>
+
+<body>
+
+<h1>
+DeviceMap logcapture prototype
+</h1>
+
+<p>
+Visiting this page makes a request to the devicemap.png image,
+with request parameters that describe the client device.
+</p>
+
+<p>
+Combined with User-Agent and x-wap-profile HTTP headers, this provides
+basic device information that the server can save in its access log file.
+</p>
+
+<p>
+See example httpd.conf in this folder for how to log those values.  
+</p>
+
+<p>
+
+<script>
+
+// return expr, suitably formatted as an URL parameter,
+// invalid expr outputs NOVALUE.
+function getExpr(expr) {
+    var result = "NOVALUE";
+    try {
+        result = eval(expr);
+    } catch(e) {
+    }
+    return "&" + expr + "=" + escape(result);
+}
+
+// return prefix.name.propertyName=true if creating an element
+// called "name" returns an object that has a "propertyName"
+// property. Used to check for html5 audio/video support
+// by checking for audio.play and video.play.
+function getElementSupport(prefix, name, propertyName) {
+    var e = document.createElement(name);
+    var result = eval("e." + propertyName) ? "true" : "false";
+    return "&" + prefix + "." + name + "." + propertyName + "=" + result;
+}
+
+// build devicemap image URL, adding useful device values
+var img="devicemap.png?dmap=1";
+var expr = [ 
+    "screen.width", 
+    "screen.height",
+    "screen.availHeight", 
+    "screen.availWidth", 
+    "screen.colorDepth", 
+    "screen.pixelDepth", 
+    "this.gives.no.value" 
+];
+for(i in expr) {
+    img += getExpr(expr[i]);
+}
+
+// detect some HTML5 features
+img += getElementSupport("html5","audio", "play");
+img += getElementSupport("html5","video", "play");
+img += getElementSupport("dummy","video", "foo");
+
+// add img element with computed path + parameters, so
+// that server log provides device information
+document.write("<img src=\"" + img + "\"/>");
+document.write("<div class='imgurl'><span class='title'>Image URL: </span>" + img + "</div>");
+</script>
+</p>
+
+</body>
+</html>
\ No newline at end of file