-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
159 lines (149 loc) · 6.77 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<title>Woothee: User-Agent parser/classifier for multi languages by woothee</title>
<link rel="stylesheet" href="stylesheets/styles.css">
<link rel="stylesheet" href="stylesheets/pygment_trac.css">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="wrapper">
<header>
<h1>Woothee</h1>
<p>User-Agent parser/classifier for multi languages</p>
<p class="view"><a href="https://github.com/woothee/woothee">GitHub Repository</a></p>
</header>
<section>
<h3><a name="whats-this" class="anchor" href="#whats-this"><span class="octicon octicon-link"></span></a>What's this?</h3>
User-agent string parser for many languages, which does:
<ul>
<li>parse user-agent strings and returns name/category/version/os/os_version/vendor</li>
<li>works reasonably fast</li>
<li>returns just same results between language implementations</li>
<li>share a test case between language implementations</li>
</ul>
Woothee implementations are:
<ul>
<li>Java (and Hive UDF)</li>
<li>Ruby</li>
<li>Perl</li>
<li>Python</li>
<li>PHP</li>
<li>Node.js (browser / node)</li>
<li>Go</li>
<li>Rust</li>
<li>Lua</li>
</ul>
<h3><a name="why-new-project" class="anchor" href="#why-new-project"><span class="octicon octicon-link"></span></a>Why new project?</h3>
<p>
We needs just same logic over 2 or more programming languages, for use on various frameworks, middlewares and environments.<br />
Most important data of this project is only single set of return values, and set of test cases, for equality of results of another languages implementations.
</p>
<h3><a name="demo" class="anchor" href="#demo"><span class="octicon octicon-link"></span></a>Demo</h3>
<div>
<h4>User-Agent String:</h4>
<input type="text" id="useragent" size="80" />
<button id="update">Update</button>
<br />
</div>
<div>
<h4>Parse result:</h4>
<table>
<tr><th>lang</th><th>name</th><th>category</th><th>os</th><th>version</th><th>os_version</th><th>vendor</th></tr>
<tr id="js">
<th class="lib" data-lang="js">js</th>
<td class="name"></td><td class="category"></td><td class="os"></td><td class="version"></td><td class="os_version"></td><td class="vendor"></td>
</tr>
<tr id="java">
<th class="lib" data-lang="java">java</th>
<td class="name"></td><td class="category"></td><td class="os"></td><td class="version"></td><td class="os_version"></td><td class="vendor"></td>
</tr>
<tr id="ruby">
<th class="lib" data-lang="ruby">ruby</th>
<td class="name"></td><td class="category"></td><td class="os"></td><td class="version"></td><td class="os_version"></td><td class="vendor"></td>
</tr>
<tr id="node">
<th class="lib" data-lang="node">node</th>
<td class="name"></td><td class="category"></td><td class="os"></td><td class="version"></td><td class="os_version"></td><td class="vendor"></td>
</tr>
<tr id="python">
<th class="lib" data-lang="python">python</th>
<td class="name"></td><td class="category"></td><td class="os"></td><td class="version"></td><td class="os_version"></td><td class="vendor"></td>
</tr>
<tr id="php">
<th class="lib" data-lang="php">php</th>
<td class="name"></td><td class="category"></td><td class="os"></td><td class="version"></td><td class="os_version"></td><td class="vendor"></td>
</tr>
<tr id="go">
<th class="lib" data-lang="go">go</th>
<td class="name"></td><td class="category"></td><td class="os"></td><td class="version"></td><td class="os_version"></td><td class="vendor"></td>
</tr>
</table>
</div>
<h3><a name="feedback" class="anchor" href="#feedback"><span class="octicon octicon-link"></span></a>Feedback</h3>
<div>
Please add issues <a href="https://github.com/woothee/woothee/issues">here</a> if you found wrong result for any user-agents.
<br />
Or, tell <a href="https://twitter.com/tagomoris">@tagomoris</a> simply.
</div>
</section>
<footer>
<p><small>Hosted on GitHub Pages — Theme by <a href="https://github.com/orderedlist">orderedlist</a></small></p>
</footer>
</div>
<script src="javascripts/scale.fix.js"></script>
<script src="javascripts/jquery-2.1.0.min.js"></script>
<script src="javascripts/woothee.js"></script>
<script>
function update(useragent){
updateJavascript(useragent);
updateAppEngineLang(useragent, 'java');
updateLangGAE(useragent, 'ruby');
updateLangGAE(useragent, 'node');
updateLangGAE(useragent, 'python');
updateLangGAE(useragent, 'php');
updateLangGAE(useragent, 'go');
}
function updateRow(id, r, v){
var row = $(id);
['name','category','os','version','os_version','vendor'].forEach(function(attr){ row.find('.' + attr).text(r[attr]); });
var version = '?.?.?';
if (v)
version = v;
row.find('th.lib').text( row.find('th.lib').data('lang') + ' (' + version + ')' );
}
function updateJavascript(useragent){
var r = woothee.parse(useragent);
updateRow('tr#js', r, woothee.VERSION);
}
function fetch(useragent, url, lang){
$.getJSON(url + "/api", {ua: useragent}, function(data){
updateRow('tr#' + lang, data.result, data.version);
})
.fail(function() {
$.getJSON(url + "/parse", {ua: useragent}, function(data){
updateRow('tr#' + lang, data);
});
})
}
function updateAppEngineLang(useragent, lang){
var url = "https://" + lang + "-dot-default-dot-woothee-demo.appspot.com";
fetch(useragent, url, lang);
}
function updateLangGAE(useragent, lang){
var url = "https://" + lang + "-demo-dot-woothee-demo.appspot.com";
fetch(useragent, url, lang);
}
$(function(){
$('#useragent').val(navigator.userAgent);
updateJavascript(navigator.userAgent);
$('#update').click(function(e){ e.preventDefault(); update($('#useragent').val()); });
});
</script>
</body>
</html>