browser_detect 0.0.1 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,38 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html>
4
+ <head>
5
+ <meta name="Content-Type" content="text/html; charset=utf-8" />
6
+ <link rel="stylesheet" href="css/full_list.css" type="text/css" media="screen" charset="utf-8" />
7
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
8
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
9
+ <script type="text/javascript" charset="utf-8" src="js/full_list.js"></script>
10
+ <base id="base_target" target="_parent" />
11
+ </head>
12
+ <body>
13
+ <script type="text/javascript" charset="utf-8">
14
+ if (window.top.frames.main) {
15
+ document.getElementById('base_target').target = 'main';
16
+ document.body.className = 'frames';
17
+ }
18
+ </script>
19
+ <div id="content">
20
+ <h1 id="full_list_header">File List</h1>
21
+ <div id="nav">
22
+ <a target="_self" href="class_list.html">Classes</a> |
23
+ <a target="_self" href="method_list.html">Methods</a> |
24
+ <a target="_self" href="file_list.html">Files</a>
25
+ </div>
26
+ <div id="search">Search: <input type="text" /></div>
27
+
28
+ <ul id="full_list" class="files">
29
+
30
+
31
+ <li class="r1"><a href="index.html" title="README">README</a></li>
32
+
33
+
34
+ </ul>
35
+ </div>
36
+ </body>
37
+ </html>
38
+
data/doc/frames.html ADDED
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
3
+
4
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5
+ <head>
6
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
7
+ <title>BrowserDetect Documentation</title>
8
+ </head>
9
+ <frameset cols="20%,*">
10
+ <frame name="list" src="class_list.html" />
11
+ <frame name="main" src="index.html" />
12
+ </frameset>
13
+ </html>
data/doc/index.html ADDED
@@ -0,0 +1,144 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <meta name="Content-Type" content="text/html; charset=utf-8" />
6
+ <title>BrowserDetect Documentation</title>
7
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
8
+ <link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
9
+
10
+ <script type="text/javascript" charset="utf-8">
11
+ relpath = '';
12
+ if (relpath != '') relpath += '/';
13
+ </script>
14
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
15
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
16
+
17
+ </head>
18
+ <body>
19
+ <script type="text/javascript" charset="utf-8">
20
+ if (window.top.frames.main) document.body.className = 'frames';
21
+ </script>
22
+
23
+ <div id="header">
24
+ <div id="menu">
25
+
26
+ <a href="_index.html" title="Index">Index</a> &raquo;
27
+ <span class="title">File: README</span>
28
+
29
+
30
+ <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
31
+ </div>
32
+
33
+ <div id="search">
34
+ <a id="class_list_link" href="#">Class List</a>
35
+ <a id="method_list_link" href="#">Method List</a>
36
+ <a id ="file_list_link" href="#">File List</a>
37
+ </div>
38
+
39
+ <div class="clear"></div>
40
+ </div>
41
+
42
+ <iframe id="search_frame"></iframe>
43
+
44
+ <div id="content"><div id='filecontents'><h1>Browser Detect</h1>
45
+
46
+ <p><em>It's like a crystal ball for user agents.</em></p>
47
+
48
+ <h2>Detect it.</h2>
49
+
50
+ <p>Detects the client browser using the user agent string that was used to make the page request.</p>
51
+
52
+ <p>Browser Detect currently supports the following browsers and platforms:</p>
53
+
54
+ <p>Browsers:</p>
55
+
56
+ <ul>
57
+ <li>ie</li>
58
+ <li>gecko</li>
59
+ <li>konqueror</li>
60
+ <li>opera</li>
61
+ <li>ipad</li>
62
+ <li>ipod</li>
63
+ <li>iphone</li>
64
+ <li>chrome</li>
65
+ <li>safari</li>
66
+ </ul>
67
+
68
+
69
+ <p>Robots:</p>
70
+
71
+ <ul>
72
+ <li>googlebot</li>
73
+ <li>msnbot</li>
74
+ <li>yahoo!</li>
75
+ </ul>
76
+
77
+
78
+ <p>Operating Systems:</p>
79
+
80
+ <ul>
81
+ <li>TODO</li>
82
+ </ul>
83
+
84
+
85
+ <h2>Use it.</h2>
86
+
87
+ <p>Using Bundler, all you need to do is add the source to your Gemfile:</p>
88
+
89
+ <pre class="code"><span class='id gem'>gem</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>browser_detect</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='symbol'>:git</span> <span class='op'>=&gt;</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>git://github.com/traction/browser_detect.git</span><span class='tstring_end'>&quot;</span></span>
90
+ </pre>
91
+
92
+ <h2>Install it:</h2>
93
+
94
+ <p>Then run:</p>
95
+
96
+ <pre class="code"><span class='id bundle'>bundle</span> <span class='id install'>install</span>
97
+ </pre>
98
+
99
+ <p>or, install it as a plugin:</p>
100
+
101
+ <pre class="code">script/plugin install git://github.com/traction/browser_detect.git
102
+ </pre>
103
+
104
+ <h2>Wield it.</h2>
105
+
106
+ <p>To check the type of browser, use browser_name
107
+ @browser_name will return either 'ie', 'gecko', 'opera', 'konqueror', 'ipod', 'ipad', 'iphone', 'chrome', 'safari', 'googlebot', 'msnbot', 'yahoobot'</p>
108
+
109
+ <pre class="code"><span class='kw'>def</span> <span class='id index'>index</span>
110
+ <span class='ivar'>@browser_name</span> <span class='op'>=</span> <span class='id browser_name'>browser_name</span>
111
+ <span class='kw'>end</span>
112
+ </pre>
113
+
114
+ <p>To check if a particular browser made the request, use browser_name?(name)
115
+ If the browser used is chrome, it will return True</p>
116
+
117
+ <pre class="code"><span class='kw'>def</span> <span class='id index'>index</span>
118
+ <span class='ivar'>@browser_type</span> <span class='op'>=</span> <span class='id browser_is?'>browser_is?</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>chrome</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
119
+ <span class='kw'>end</span>
120
+ </pre>
121
+
122
+ <p>or in a view using ERB:</p>
123
+
124
+ <pre class="code">&lt;%= browser_is?(:chrome) ? &quot;secrets&quot; : &quot;buzz off&quot; %&gt;
125
+ </pre>
126
+
127
+ <p>Or choose from the following groupings:</p>
128
+
129
+ <ul>
130
+ <li>mozilla</li>
131
+ <li>ie</li>
132
+ <li>webkit</li>
133
+ <li>robots</li>
134
+ </ul>
135
+ </div></div>
136
+
137
+ <div id="footer">
138
+ Generated on Wed Nov 3 16:31:07 2010 by
139
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
140
+ 0.6.1 (ruby-1.9.2).
141
+ </div>
142
+
143
+ </body>
144
+ </html>
data/doc/init_rb.html ADDED
@@ -0,0 +1,54 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
3
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
4
+
5
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6
+ <head>
7
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
8
+
9
+ <title>File: init.rb [RDoc Documentation]</title>
10
+
11
+ <link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet" />
12
+
13
+ <script src="./js/jquery.js" type="text/javascript"
14
+ charset="utf-8"></script>
15
+ <script src="./js/thickbox-compressed.js" type="text/javascript"
16
+ charset="utf-8"></script>
17
+ <script src="./js/quicksearch.js" type="text/javascript"
18
+ charset="utf-8"></script>
19
+ <script src="./js/darkfish.js" type="text/javascript"
20
+ charset="utf-8"></script>
21
+ </head>
22
+
23
+ <body class="file file-popup">
24
+ <div id="metadata">
25
+ <dl>
26
+ <dt class="modified-date">Last Modified</dt>
27
+ <dd class="modified-date">2010-11-03 14:58:55 -0700</dd>
28
+
29
+
30
+ <dt class="requires">Requires</dt>
31
+ <dd class="requires">
32
+ <ul>
33
+
34
+ <li>browser_detect</li>
35
+
36
+ </ul>
37
+ </dd>
38
+
39
+
40
+
41
+ </dl>
42
+ </div>
43
+
44
+ <div id="documentation">
45
+
46
+ <div class="description">
47
+ <h2>Description</h2>
48
+
49
+ </div>
50
+
51
+ </div>
52
+ </body>
53
+ </html>
54
+
data/doc/js/app.js ADDED
@@ -0,0 +1,202 @@
1
+ function createSourceLinks() {
2
+ $('.method_details_list .source_code').
3
+ before("<span class='showSource'>[<a href='#' class='toggleSource'>View source</a>]</span>");
4
+ $('.toggleSource').toggle(function() {
5
+ $(this).parent().next().slideDown(100);
6
+ $(this).text("Hide source");
7
+ },
8
+ function() {
9
+ $(this).parent().next().slideUp(100);
10
+ $(this).text("View source");
11
+ });
12
+ }
13
+
14
+ function createDefineLinks() {
15
+ var tHeight = 0;
16
+ $('.defines').after(" <a href='#' class='toggleDefines'>more...</a>");
17
+ $('.toggleDefines').toggle(function() {
18
+ tHeight = $(this).parent().prev().height();
19
+ $(this).prev().show();
20
+ $(this).parent().prev().height($(this).parent().height());
21
+ $(this).text("(less)");
22
+ },
23
+ function() {
24
+ $(this).prev().hide();
25
+ $(this).parent().prev().height(tHeight);
26
+ $(this).text("more...")
27
+ });
28
+ }
29
+
30
+ function createFullTreeLinks() {
31
+ var tHeight = 0;
32
+ $('.inheritanceTree').toggle(function() {
33
+ tHeight = $(this).parent().prev().height();
34
+ $(this).parent().toggleClass('showAll');
35
+ $(this).text("(hide)");
36
+ $(this).parent().prev().height($(this).parent().height());
37
+ },
38
+ function() {
39
+ $(this).parent().toggleClass('showAll');
40
+ $(this).parent().prev().height(tHeight);
41
+ $(this).text("show all")
42
+ });
43
+ }
44
+
45
+ function fixBoxInfoHeights() {
46
+ $('dl.box dd.r1, dl.box dd.r2').each(function() {
47
+ $(this).prev().height($(this).height());
48
+ });
49
+ }
50
+
51
+ function searchFrameLinks() {
52
+ $('#method_list_link').click(function() {
53
+ toggleSearchFrame(this, relpath + 'method_list.html');
54
+ });
55
+
56
+ $('#class_list_link').click(function() {
57
+ toggleSearchFrame(this, relpath + 'class_list.html');
58
+ });
59
+
60
+ $('#file_list_link').click(function() {
61
+ toggleSearchFrame(this, relpath + 'file_list.html');
62
+ });
63
+ }
64
+
65
+ function toggleSearchFrame(id, link) {
66
+ var frame = $('#search_frame');
67
+ $('#search a').removeClass('active').addClass('inactive');
68
+ if (frame.attr('src') == link && frame.css('display') != "none") {
69
+ frame.slideUp(100);
70
+ $('#search a').removeClass('active inactive');
71
+ }
72
+ else {
73
+ $(id).addClass('active').removeClass('inactive');
74
+ frame.attr('src', link).slideDown(100);
75
+ }
76
+ }
77
+
78
+ function linkSummaries() {
79
+ $('.summary_signature').click(function() {
80
+ document.location = $(this).find('a').attr('href');
81
+ });
82
+ }
83
+
84
+ function framesInit() {
85
+ if (window.top.frames.main) {
86
+ document.body.className = 'frames';
87
+ $('#menu .noframes a').attr('href', document.location);
88
+ $('html head title', window.parent.document).text($('html head title').text());
89
+ }
90
+ }
91
+
92
+ function keyboardShortcuts() {
93
+ if (window.top.frames.main) return;
94
+ $(document).keypress(function(evt) {
95
+ if (evt.altKey || evt.ctrlKey || evt.metaKey || evt.shiftKey) return;
96
+ if (evt.originalTarget.nodeName == "INPUT" ||
97
+ evt.originalTarget.nodeName == "TEXTAREA") return;
98
+ switch (evt.charCode) {
99
+ case 67: case 99: $('#class_list_link').click(); break; // 'c'
100
+ case 77: case 109: $('#method_list_link').click(); break; // 'm'
101
+ case 70: case 102: $('#file_list_link').click(); break; // 'f'
102
+ }
103
+ });
104
+ }
105
+
106
+ function summaryToggle() {
107
+ $('.summary_toggle').click(function() {
108
+ localStorage.summaryCollapsed = $(this).text();
109
+ $(this).text($(this).text() == "collapse" ? "expand" : "collapse");
110
+ var next = $(this).parent().parent().next();
111
+ if (next.hasClass('compact')) {
112
+ next.toggle();
113
+ next.next().toggle();
114
+ }
115
+ else if (next.hasClass('summary')) {
116
+ var list = $('<ul class="summary compact" />');
117
+ list.html(next.html());
118
+ list.find('.summary_desc, .note').remove();
119
+ list.find('a').each(function() {
120
+ $(this).html($(this).find('strong').html());
121
+ $(this).parent().html($(this)[0].outerHTML);
122
+ });
123
+ next.before(list);
124
+ next.toggle();
125
+ }
126
+ return false;
127
+ });
128
+ if (localStorage) {
129
+ if (localStorage.summaryCollapsed == "collapse") $('.summary_toggle').click();
130
+ else localStorage.summaryCollapsed = "expand";
131
+ }
132
+ }
133
+
134
+ function fixOutsideWorldLinks() {
135
+ $('a').each(function() {
136
+ if (window.location.host != this.host) this.target = '_parent';
137
+ });
138
+ }
139
+
140
+ function generateTOC() {
141
+ if ($('#filecontents').length == 0) return;
142
+ var _toc = $('<ol class="top"></ol>');
143
+ var show = false;
144
+ var toc = _toc;
145
+ var counter = 0;
146
+ var tags = ['h2', 'h3', 'h4', 'h5', 'h6'];
147
+ if ($('#filecontents h1').length > 1) tags.unshift('h1');
148
+ for (i in tags) { tags[i] = '#filecontents ' + tags[i] }
149
+ var lastTag = parseInt(tags[0][1]);
150
+ $(tags.join(', ')).each(function() {
151
+ if (this.id == "filecontents") return;
152
+ show = true;
153
+ var thisTag = parseInt(this.tagName[1]);
154
+ if (this.id.length == 0) {
155
+ var proposedId = $(this).text().replace(/[^a-z0-9:'"\.()=-]/ig, '_');
156
+ if ($('#' + proposedId).length > 0) proposedId += counter++;
157
+ this.id = proposedId;
158
+ }
159
+ if (thisTag > lastTag) {
160
+ for (var i = 0; i < thisTag - lastTag; i++) {
161
+ var tmp = $('<ol/>'); toc.append(tmp); toc = tmp;
162
+ }
163
+ }
164
+ if (thisTag < lastTag) {
165
+ for (var i = 0; i < lastTag - thisTag; i++) toc = toc.parent();
166
+ }
167
+ toc.append('<li><a href="#' + this.id + '">' + $(this).text() + '</a></li>');
168
+ lastTag = thisTag;
169
+ });
170
+ if (!show) return;
171
+ html = '<div id="toc"><p class="title"><a class="hide_toc" href="#"><strong>Table of Contents</strong></a> <small>(<a href="#" class="float_toc">left</a>)</small></p></div>';
172
+ $('#content').prepend(html);
173
+ $('#toc').append(_toc);
174
+ $('#toc .hide_toc').toggle(function() {
175
+ $('#toc .top').slideUp('fast');
176
+ $('#toc').toggleClass('hidden');
177
+ $('#toc .title small').toggle();
178
+ }, function() {
179
+ $('#toc .top').slideDown('fast');
180
+ $('#toc').toggleClass('hidden');
181
+ $('#toc .title small').toggle();
182
+ });
183
+ $('#toc .float_toc').toggle(function() {
184
+ $(this).text('float');
185
+ $('#toc').toggleClass('nofloat');
186
+ }, function() {
187
+ $(this).text('left')
188
+ $('#toc').toggleClass('nofloat');
189
+ });
190
+ }
191
+
192
+ $(framesInit);
193
+ $(createSourceLinks);
194
+ $(createDefineLinks);
195
+ $(createFullTreeLinks);
196
+ $(fixBoxInfoHeights);
197
+ $(searchFrameLinks);
198
+ $(linkSummaries);
199
+ $(keyboardShortcuts);
200
+ $(summaryToggle);
201
+ $(fixOutsideWorldLinks);
202
+ $(generateTOC);