golf 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -9,3 +9,4 @@ dist/*
9
9
  docs/api/*
10
10
  docs/api
11
11
  *.gem
12
+ *.lock
data/bin/golf CHANGED
File without changes
data/lib/golf/cli.rb CHANGED
@@ -13,7 +13,7 @@ module Golf
13
13
 
14
14
  desc "new [NAME]", "Creates new golf app"
15
15
  def new(name)
16
- directory("template", name)
16
+ directory("templates/new", name)
17
17
  end
18
18
 
19
19
  desc "server", "Run the golf app"
data/lib/golf/rack.rb CHANGED
@@ -4,16 +4,204 @@ module Golf
4
4
  def initialize(app = nil)
5
5
  @app = app if app
6
6
  @compiler = Golf::Compiler.new
7
+ resource_path = File.expand_path("../../../resources", __FILE__)
8
+ @resources = {}
9
+ Dir["#{resource_path}/*"].each { |x| @resources = @resources.merge({ "/#{x.split('/').last}" => File.read(x) }) }
7
10
  end
8
11
 
9
12
  def call(env)
10
- if env["REQUEST_METHOD"] == "GET" and env["PATH_INFO"] == "/components.js"
13
+ case env["PATH_INFO"]
14
+ when "/"
15
+ mime = MIME_TYPES[".html"]
16
+ result = @resources["/index.html"]
17
+ when "/components.js"
18
+ mime = MIME_TYPES[".js"]
11
19
  result = @compiler.generate_componentsjs
12
- ['200', { 'Content-Type' => 'application/javascript', 'Content-Length' => result.length.to_s}, [result]]
13
20
  else
14
- @app.call(env) if @app
21
+ mime = MIME_TYPES[".#{env["PATH_INFO"].split('.').last}"]
22
+ result = @resources[env["PATH_INFO"]]
23
+ unless result
24
+ mime = 'text/plain'
25
+ result = 'not found'
26
+ end
15
27
  end
28
+ return ['200', { 'Content-Type' => mime, 'Content-Length' => result.length.to_s}, [result]]
16
29
  end
17
30
  end
31
+
32
+ MIME_TYPES = {
33
+ ".3gp" => "video/3gpp",
34
+ ".a" => "application/octet-stream",
35
+ ".ai" => "application/postscript",
36
+ ".aif" => "audio/x-aiff",
37
+ ".aiff" => "audio/x-aiff",
38
+ ".asc" => "application/pgp-signature",
39
+ ".asf" => "video/x-ms-asf",
40
+ ".asm" => "text/x-asm",
41
+ ".asx" => "video/x-ms-asf",
42
+ ".atom" => "application/atom+xml",
43
+ ".au" => "audio/basic",
44
+ ".avi" => "video/x-msvideo",
45
+ ".bat" => "application/x-msdownload",
46
+ ".bin" => "application/octet-stream",
47
+ ".bmp" => "image/bmp",
48
+ ".bz2" => "application/x-bzip2",
49
+ ".c" => "text/x-c",
50
+ ".cab" => "application/vnd.ms-cab-compressed",
51
+ ".cc" => "text/x-c",
52
+ ".chm" => "application/vnd.ms-htmlhelp",
53
+ ".class" => "application/octet-stream",
54
+ ".com" => "application/x-msdownload",
55
+ ".conf" => "text/plain",
56
+ ".cpp" => "text/x-c",
57
+ ".crt" => "application/x-x509-ca-cert",
58
+ ".css" => "text/css",
59
+ ".csv" => "text/csv",
60
+ ".cxx" => "text/x-c",
61
+ ".deb" => "application/x-debian-package",
62
+ ".der" => "application/x-x509-ca-cert",
63
+ ".diff" => "text/x-diff",
64
+ ".djv" => "image/vnd.djvu",
65
+ ".djvu" => "image/vnd.djvu",
66
+ ".dll" => "application/x-msdownload",
67
+ ".dmg" => "application/octet-stream",
68
+ ".doc" => "application/msword",
69
+ ".dot" => "application/msword",
70
+ ".dtd" => "application/xml-dtd",
71
+ ".dvi" => "application/x-dvi",
72
+ ".ear" => "application/java-archive",
73
+ ".eml" => "message/rfc822",
74
+ ".eps" => "application/postscript",
75
+ ".exe" => "application/x-msdownload",
76
+ ".f" => "text/x-fortran",
77
+ ".f77" => "text/x-fortran",
78
+ ".f90" => "text/x-fortran",
79
+ ".flv" => "video/x-flv",
80
+ ".for" => "text/x-fortran",
81
+ ".gem" => "application/octet-stream",
82
+ ".gemspec" => "text/x-script.ruby",
83
+ ".gif" => "image/gif",
84
+ ".gz" => "application/x-gzip",
85
+ ".h" => "text/x-c",
86
+ ".htc" => "text/x-component",
87
+ ".hh" => "text/x-c",
88
+ ".htm" => "text/html",
89
+ ".html" => "text/html",
90
+ ".ico" => "image/vnd.microsoft.icon",
91
+ ".ics" => "text/calendar",
92
+ ".ifb" => "text/calendar",
93
+ ".iso" => "application/octet-stream",
94
+ ".jar" => "application/java-archive",
95
+ ".java" => "text/x-java-source",
96
+ ".jnlp" => "application/x-java-jnlp-file",
97
+ ".jpeg" => "image/jpeg",
98
+ ".jpg" => "image/jpeg",
99
+ ".js" => "application/javascript",
100
+ ".json" => "application/json",
101
+ ".log" => "text/plain",
102
+ ".m3u" => "audio/x-mpegurl",
103
+ ".m4v" => "video/mp4",
104
+ ".man" => "text/troff",
105
+ ".manifest"=> "text/cache-manifest",
106
+ ".mathml" => "application/mathml+xml",
107
+ ".mbox" => "application/mbox",
108
+ ".mdoc" => "text/troff",
109
+ ".me" => "text/troff",
110
+ ".mid" => "audio/midi",
111
+ ".midi" => "audio/midi",
112
+ ".mime" => "message/rfc822",
113
+ ".mml" => "application/mathml+xml",
114
+ ".mng" => "video/x-mng",
115
+ ".mov" => "video/quicktime",
116
+ ".mp3" => "audio/mpeg",
117
+ ".mp4" => "video/mp4",
118
+ ".mp4v" => "video/mp4",
119
+ ".mpeg" => "video/mpeg",
120
+ ".mpg" => "video/mpeg",
121
+ ".ms" => "text/troff",
122
+ ".msi" => "application/x-msdownload",
123
+ ".odp" => "application/vnd.oasis.opendocument.presentation",
124
+ ".ods" => "application/vnd.oasis.opendocument.spreadsheet",
125
+ ".odt" => "application/vnd.oasis.opendocument.text",
126
+ ".ogg" => "application/ogg",
127
+ ".ogv" => "video/ogg",
128
+ ".p" => "text/x-pascal",
129
+ ".pas" => "text/x-pascal",
130
+ ".pbm" => "image/x-portable-bitmap",
131
+ ".pdf" => "application/pdf",
132
+ ".pem" => "application/x-x509-ca-cert",
133
+ ".pgm" => "image/x-portable-graymap",
134
+ ".pgp" => "application/pgp-encrypted",
135
+ ".pkg" => "application/octet-stream",
136
+ ".pl" => "text/x-script.perl",
137
+ ".pm" => "text/x-script.perl-module",
138
+ ".png" => "image/png",
139
+ ".pnm" => "image/x-portable-anymap",
140
+ ".ppm" => "image/x-portable-pixmap",
141
+ ".pps" => "application/vnd.ms-powerpoint",
142
+ ".ppt" => "application/vnd.ms-powerpoint",
143
+ ".ps" => "application/postscript",
144
+ ".psd" => "image/vnd.adobe.photoshop",
145
+ ".py" => "text/x-script.python",
146
+ ".qt" => "video/quicktime",
147
+ ".ra" => "audio/x-pn-realaudio",
148
+ ".rake" => "text/x-script.ruby",
149
+ ".ram" => "audio/x-pn-realaudio",
150
+ ".rar" => "application/x-rar-compressed",
151
+ ".rb" => "text/x-script.ruby",
152
+ ".rdf" => "application/rdf+xml",
153
+ ".roff" => "text/troff",
154
+ ".rpm" => "application/x-redhat-package-manager",
155
+ ".rss" => "application/rss+xml",
156
+ ".rtf" => "application/rtf",
157
+ ".ru" => "text/x-script.ruby",
158
+ ".s" => "text/x-asm",
159
+ ".sgm" => "text/sgml",
160
+ ".sgml" => "text/sgml",
161
+ ".sh" => "application/x-sh",
162
+ ".sig" => "application/pgp-signature",
163
+ ".snd" => "audio/basic",
164
+ ".so" => "application/octet-stream",
165
+ ".svg" => "image/svg+xml",
166
+ ".svgz" => "image/svg+xml",
167
+ ".swf" => "application/x-shockwave-flash",
168
+ ".t" => "text/troff",
169
+ ".tar" => "application/x-tar",
170
+ ".tbz" => "application/x-bzip-compressed-tar",
171
+ ".tcl" => "application/x-tcl",
172
+ ".tex" => "application/x-tex",
173
+ ".texi" => "application/x-texinfo",
174
+ ".texinfo" => "application/x-texinfo",
175
+ ".text" => "text/plain",
176
+ ".tif" => "image/tiff",
177
+ ".tiff" => "image/tiff",
178
+ ".torrent" => "application/x-bittorrent",
179
+ ".tr" => "text/troff",
180
+ ".ttf" => "application/octet-stream",
181
+ ".txt" => "text/plain",
182
+ ".vcf" => "text/x-vcard",
183
+ ".vcs" => "text/x-vcalendar",
184
+ ".vrml" => "model/vrml",
185
+ ".war" => "application/java-archive",
186
+ ".wav" => "audio/x-wav",
187
+ ".webm" => "video/webm",
188
+ ".wma" => "audio/x-ms-wma",
189
+ ".wmv" => "video/x-ms-wmv",
190
+ ".wmx" => "video/x-ms-wmx",
191
+ ".woff" => "application/octet-stream",
192
+ ".wrl" => "model/vrml",
193
+ ".wsdl" => "application/wsdl+xml",
194
+ ".xbm" => "image/x-xbitmap",
195
+ ".xhtml" => "application/xhtml+xml",
196
+ ".xls" => "application/vnd.ms-excel",
197
+ ".xml" => "application/xml",
198
+ ".xpm" => "image/x-xpixmap",
199
+ ".xsl" => "application/xml",
200
+ ".xslt" => "application/xslt+xml",
201
+ ".yaml" => "text/yaml",
202
+ ".yml" => "text/yaml",
203
+ ".zip" => "application/zip",
204
+ }
205
+
18
206
  end
19
207
 
data/lib/golf/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Golf
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -0,0 +1,60 @@
1
+
2
+ <style type="text/css">
3
+ * {
4
+ font-family: sans-serif;
5
+ margin: 0;
6
+ padding: 0;
7
+ color: #333;
8
+ }
9
+
10
+ h1.type {
11
+ padding: .5em 20px .5em 20px;
12
+ background: orange;
13
+ margin: 2px;
14
+ }
15
+
16
+ h3.description {
17
+ padding: .5em 20px .5em 20px;
18
+ background: yellowgreen;
19
+ margin: 2px;
20
+ }
21
+
22
+ p.message {
23
+ padding: .75em 20px .75em 20px;
24
+ background: cadetblue;
25
+ margin: 2px;
26
+ }
27
+
28
+ a, a:visited {
29
+ color: darkblue;
30
+ text-decoration: none;
31
+ }
32
+
33
+ a:hover {
34
+ color: darkblue;
35
+ text-decoration: underline;
36
+ }
37
+
38
+ code {
39
+ font-family: monospace;
40
+ font-weight: bold;
41
+ font-size: 1.18em;
42
+ padding: 0 0.20em 0 0.20em;
43
+ }
44
+
45
+ .content {
46
+ position: relative;
47
+ top: 5em;
48
+ width: 35em;
49
+ margin: 0 auto;
50
+ }
51
+ </style>
52
+
53
+ <div class="content">
54
+ <h1 class="type"/>
55
+ <h3 class="description"/>
56
+ <p class="message">
57
+ Golf server documentation:
58
+ <a href="http://golf.github.com/">http://golf.github.com</a>.
59
+ </p>
60
+ </div>
File without changes
@@ -0,0 +1,61 @@
1
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
2
+ <head>
3
+ <title> </title>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
5
+ <meta name="robots" content="noindex,nofollow"/>
6
+ <script type="text/javascript">
7
+ window.serverside = false;
8
+ window.sessionid = "";
9
+ window.servletUrl = window.location.protocol+"//"+window.location.host+window.location.pathname;
10
+ window.urlHash = "";
11
+ window.devmode = false;
12
+ window.forcebot = false;
13
+ window.forceproxy = false;
14
+ window.forceclient = false;
15
+ window.restBackends = [];
16
+ window.cloudfrontDomain = "";
17
+ if (servletUrl.match("/index\.html$"))
18
+ window.location.replace(
19
+ servletUrl.substring(0, servletUrl.length - "index.html".length));
20
+ </script>
21
+ <script type="text/javascript" src="jquery.js"></script>
22
+ <script type="text/javascript">
23
+ jQuery.golf = {};
24
+ </script>
25
+ <script type="text/javascript" src="jquery.address.js"></script>
26
+ <script type="text/javascript" src="jquery.golf.js"></script>
27
+ <script type="text/javascript" src="components.js"></script>
28
+ <script type="text/javascript" src="controller.js"></script>
29
+ <style type="text/css">
30
+ a.golfproxylink,
31
+ a.golfproxylink:link,
32
+ a.golfproxylink:visited,
33
+ a.golfproxylink:hover { color:inherit; text-decoration:inherit; }
34
+ </style>
35
+ <!-- custom head section -->
36
+ <!-- end custom head section -->
37
+ </head>
38
+ <body>
39
+ <noscript>
40
+ <!-- custom noscript section -->
41
+ <div style="color:#222;width:25em;margin:2em auto;padding:2em;border:1px solid black;font-family:sans-serif;text-align:justify">
42
+ <div style="margin:0 auto;text-align:center;">
43
+ <h3>JavaScript proxying is disabled.</h3>
44
+ </div>
45
+ <p>It looks like your browser doesn't support JavaScript, or
46
+ maybe you've turned it off. Normally, the Golf server would
47
+ proxy the JavaScript for you and you'd still be able to access
48
+ the site. However this application is running in static mode
49
+ and proxying is disabled.</p>
50
+
51
+ <p>If you want to access this application you will need to
52
+ enable JavaScript in your browser. Check out
53
+ <a href="http://www.google.com/support/websearch/bin/answer.py?hl=en&answer=23852">Google's JavaScript page</a>
54
+ for more information on how to do this.</p>
55
+ </div>
56
+ <!-- end custom noscript section -->
57
+ </noscript>
58
+ <div class="golfbody">
59
+ </div>
60
+ </body>
61
+ </html>
@@ -0,0 +1,439 @@
1
+ /*
2
+ * jQuery Address Plugin v1.0
3
+ * http://www.asual.com/jquery/address/
4
+ *
5
+ * Copyright (c) 2009 Rostislav Hristov
6
+ * Dual licensed under the MIT and GPL licenses.
7
+ * http://docs.jquery.com/License
8
+ *
9
+ * Date: 2009-04-28 16:54:00 +0300 (Tue, 28 Apr 2009)
10
+ * Revision: 399
11
+ */
12
+ (function ($) {
13
+
14
+ $.address = (function () {
15
+
16
+ var _trigger = function(name) {
17
+ $(this).trigger(
18
+ $.extend($.Event(name),
19
+ (function() {
20
+ var event = {
21
+ value: this.value(),
22
+ path: this.path(),
23
+ pathNames: this.pathNames(),
24
+ parameterNames: this.parameterNames(),
25
+ parameters: {},
26
+ queryString: this.queryString()
27
+ };
28
+ for (var i = 0, l = event.parameterNames.length; i < l; i++)
29
+ event.parameters[event.parameterNames[i]] = this.parameter(event.parameterNames[i]);
30
+ return event;
31
+ }).call(this)
32
+ )
33
+ );
34
+ };
35
+
36
+ var _init = function() {
37
+ _trigger.call($.address, 'init');
38
+ };
39
+
40
+ var _change = function() {
41
+ _trigger.call($.address, 'change');
42
+ };
43
+
44
+ var _getHash = function() {
45
+ var index = _l.href.indexOf('#');
46
+ return index != -1 ? _ec(_dc(_l.href.substr(index + 1))) : '';
47
+ };
48
+
49
+ var _getWindow = function() {
50
+ try {
51
+ top.document;
52
+ return top;
53
+ } catch (e) {
54
+ return window;
55
+ }
56
+ };
57
+
58
+ var _strictCheck = function(value, force) {
59
+ if (_opts.strict)
60
+ value = force ? (value.substr(0, 1) != '/' ? '/' + value : value) : (value == '' ? '/' : value);
61
+ return value;
62
+ };
63
+
64
+ var _ieLocal = function(value, direction) {
65
+ return (_msie && _l.protocol == 'file:') ?
66
+ (direction ? _value.replace(/\?/, '%3F') : _value.replace(/%253F/, '?')) : value;
67
+ };
68
+
69
+ var _searchScript = function(el) {
70
+ for (var i = 0, l = el.childNodes.length, s; i < l; i++) {
71
+ if (el.childNodes[i].src)
72
+ _url = String(el.childNodes[i].src);
73
+ if (s = _searchScript(el.childNodes[i]))
74
+ return s;
75
+ }
76
+ };
77
+
78
+ var _listen = function() {
79
+ if (!_silent) {
80
+ var hash = _getHash();
81
+ var diff = !(_value == hash);
82
+ if (_safari && _version < 523) {
83
+ if (_length != _h.length) {
84
+ _length = _h.length;
85
+ if (typeof _stack[_length - 1] != UNDEFINED)
86
+ _value = _stack[_length - 1];
87
+ _update();
88
+ }
89
+ } else if (_msie && diff) {
90
+ if (_version < 7)
91
+ _l.reload();
92
+ else
93
+ _setters.value(hash);
94
+ } else if (diff) {
95
+ _value = hash;
96
+ _update();
97
+ }
98
+ }
99
+ };
100
+
101
+ var _update = function() {
102
+ _change();
103
+ _st(_track, 10);
104
+ };
105
+
106
+ var _track = function() {
107
+ var value = (_l.pathname + (/\/$/.test(_l.pathname) ? '' : '/') + _getters.value()).replace(/\/\//, '/').replace(/^\/$/, '');
108
+ var fn = window[_opts.tracker];
109
+ if (typeof fn == FUNCTION)
110
+ fn(value);
111
+ else if (typeof pageTracker != UNDEFINED && typeof pageTracker._trackPageview == FUNCTION)
112
+ pageTracker._trackPageview(value);
113
+ else if (typeof urchinTracker == FUNCTION)
114
+ urchinTracker(value);
115
+ };
116
+
117
+ var _htmlWrite = function() {
118
+ var doc = _iframe.contentWindow.document;
119
+ doc.open();
120
+ doc.write('<html><head><title>' + _d.title + '</title><script>var ' + ID + ' = "' + _getHash() + '";</script></head></html>');
121
+ doc.close();
122
+ };
123
+
124
+ var _load = function() {
125
+ if (!_loaded) {
126
+ _loaded = true;
127
+ $('a').attr('xref', function() {
128
+ return $(this).attr('href');
129
+ });
130
+ if (_msie && _version < 8) {
131
+ _d.body.innerHTML = '<iframe id="' + ID + '" src="javascript:false;" width="0" height="0"></iframe>' + _d.body.innerHTML;
132
+ _iframe = _d.getElementById(ID);
133
+ _st(function() {
134
+ $(_iframe).bind('load', function() {
135
+ var win = _iframe.contentWindow;
136
+ var src = win.location.href;
137
+ _value = (typeof win[ID] != UNDEFINED ? win[ID] : '');
138
+ if (_value != _getHash()) {
139
+ _update();
140
+ _l.hash = _ieLocal(_value, true);
141
+ }
142
+ });
143
+ if (typeof _iframe.contentWindow[ID] == UNDEFINED)
144
+ _htmlWrite();
145
+ }, 50);
146
+ } else if (_safari) {
147
+ if (_version < 418) {
148
+ $(_d.body).append('<form id="' + ID + '" style="position:absolute;top:-9999px;" method="get"></form>');
149
+ _form = _d.getElementById(ID);
150
+ }
151
+ if (typeof _l[ID] == UNDEFINED) _l[ID] = {};
152
+ if (typeof _l[ID][_l.pathname] != UNDEFINED) _stack = _l[ID][_l.pathname].split(',');
153
+ }
154
+
155
+ _st(function() {
156
+ _init();
157
+ _change();
158
+ _track();
159
+ }, 1);
160
+
161
+ if (_msie && _version >= 8)
162
+ _d.body.onhashchange = _listen;
163
+ else
164
+ _si(_listen, 50);
165
+
166
+ $('a').attr('href', function() {
167
+ return $(this).attr('xref');
168
+ }).removeAttr('xref');
169
+
170
+ $('a[rel*=address:]').address();
171
+ }
172
+ };
173
+
174
+ var _getters = {
175
+ baseURL: function() {
176
+ var url = _l.href;
177
+ if (url.indexOf('#') != -1)
178
+ url = url.substr(0, url.indexOf('#'));
179
+ if (url.substr(url.length - 1) == '/')
180
+ url = url.substr(0, url.length - 1);
181
+ return url;
182
+ },
183
+ strict: function() {
184
+ return _opts.strict;
185
+ },
186
+ history: function() {
187
+ return _opts.history;
188
+ },
189
+ tracker: function() {
190
+ return _opts.tracker;
191
+ },
192
+ title: function() {
193
+ return _d.title;
194
+ },
195
+ value: function() {
196
+ if (!_supported) return null;
197
+ return _dc(_strictCheck(_ieLocal(_value, false), false));
198
+ },
199
+ path: function() {
200
+ var value = this.value();
201
+ return (value.indexOf('?') != -1) ? value.split('?')[0] : value;
202
+ },
203
+ pathNames: function() {
204
+ var path = this.path();
205
+ var names = path.split('/');
206
+ if (path.substr(0, 1) == '/' || path.length == 0)
207
+ names.splice(0, 1);
208
+ if (path.substr(path.length - 1, 1) == '/')
209
+ names.splice(names.length - 1, 1);
210
+ return names;
211
+ },
212
+ queryString: function() {
213
+ var value = this.value();
214
+ var index = value.indexOf('?');
215
+ return (index != -1 && index < value.length) ? value.substr(index + 1) : '';
216
+ },
217
+ parameter: function(param) {
218
+ var value = this.value();
219
+ var index = value.indexOf('?');
220
+ if (index != -1) {
221
+ value = value.substr(index + 1);
222
+ var params = value.split('&');
223
+ var p, i = params.length;
224
+ while(i--) {
225
+ p = params[i].split('=');
226
+ if (p[0] == param)
227
+ return p[1];
228
+ }
229
+ }
230
+ },
231
+ parameterNames: function() {
232
+ var value = this.value();
233
+ var index = value.indexOf('?');
234
+ var names = [];
235
+ if (index != -1) {
236
+ value = value.substr(index + 1);
237
+ if (value != '' && value.indexOf('=') != -1) {
238
+ var params = value.split('&');
239
+ var i = 0;
240
+ while(i < params.length) {
241
+ names.push(params[i].split('=')[0]);
242
+ i++;
243
+ }
244
+ }
245
+ }
246
+ return names;
247
+ }
248
+ };
249
+
250
+ var _setters = {
251
+ strict: function(strict) {
252
+ _opts.strict = strict;
253
+ },
254
+ history: function(history) {
255
+ _opts.history = history;
256
+ },
257
+ tracker: function(tracker) {
258
+ _opts.tracker = tracker;
259
+ },
260
+ title: function(title) {
261
+ _st(function() {
262
+ _title = _d.title = title;
263
+ if (_juststart && _iframe && _iframe.contentWindow && _iframe.contentWindow.document) {
264
+ _iframe.contentWindow.document.title = title;
265
+ _juststart = false;
266
+ }
267
+ if (!_justset && _mozilla)
268
+ _l.replace(_l.href.indexOf('#') != -1 ? _l.href : _l.href + '#');
269
+ _justset = false;
270
+ }, 50);
271
+ },
272
+ value: function(value) {
273
+ value = _ec(_dc(_strictCheck(value, true)));
274
+ if (value == '/') value = '';
275
+ if (_value == value) return;
276
+ _justset = true;
277
+ _value = value;
278
+ _silent = true;
279
+ _update();
280
+ _stack[_h.length] = _value;
281
+ if (_safari) {
282
+ if (_opts.history) {
283
+ _l[ID][_l.pathname] = _stack.toString();
284
+ _length = _h.length + 1;
285
+ if (_version < 418) {
286
+ if (_l.search == '') {
287
+ _form.action = '#' + _value;
288
+ _form.submit();
289
+ }
290
+ } else if (_version < 523 || _value == '') {
291
+ var evt = _d.createEvent('MouseEvents');
292
+ evt.initEvent('click', true, true);
293
+ var anchor = _d.createElement('a');
294
+ anchor.href = '#' + _value;
295
+ anchor.dispatchEvent(evt);
296
+ } else {
297
+ _l.hash = '#' + _value;
298
+ }
299
+ } else {
300
+ _l.replace('#' + _value);
301
+ }
302
+ } else if (_value != _getHash()) {
303
+ if (_opts.history)
304
+ _l.hash = '#' + _ieLocal(_value, true);
305
+ else
306
+ _l.replace('#' + _value);
307
+ }
308
+ if ((_msie && _version < 8) && _opts.history) {
309
+ _st(_htmlWrite, 50);
310
+ }
311
+ if (_safari)
312
+ _st(function(){ _silent = false; }, 1);
313
+ else
314
+ _silent = false;
315
+ }
316
+ };
317
+
318
+ var ID = 'jQueryAddress',
319
+ FUNCTION = 'function',
320
+ UNDEFINED = 'undefined',
321
+ _browser = $.browser,
322
+ _version = parseFloat($.browser.version),
323
+ _mozilla = _browser.mozilla,
324
+ _msie = _browser.msie,
325
+ _opera = _browser.opera,
326
+ _safari = _browser.safari,
327
+ _supported = false,
328
+ _t = _getWindow(),
329
+ _d = _t.document,
330
+ _h = _t.history,
331
+ _l = _t.location,
332
+ _si = setInterval,
333
+ _st = setTimeout,
334
+ _dc = decodeURI,
335
+ _ec = encodeURI,
336
+ _agent = navigator.userAgent,
337
+ _iframe,
338
+ _form,
339
+ _url,
340
+ _title = _d.title,
341
+ _length = _h.length,
342
+ _silent = false,
343
+ _loaded = false,
344
+ _justset = true,
345
+ _juststart = true,
346
+ _stack = [],
347
+ _listeners = {},
348
+ _value = _getHash(),
349
+ _api = {},
350
+ _opts = {history: true, strict: true};
351
+
352
+ if (_msie)
353
+ _version = parseFloat(_agent.substr(_agent.indexOf('MSIE') + 4));
354
+
355
+ _supported =
356
+ (_mozilla && _version >= 1) ||
357
+ (_msie && _version >= 6) ||
358
+ (_opera && _version >= 9.5) ||
359
+ (_safari && _version >= 312);
360
+
361
+ if (_supported) {
362
+
363
+ for (var i = 1; i < _length; i++)
364
+ _stack.push('');
365
+
366
+ _stack.push(_getHash());
367
+
368
+ if (_msie && _l.hash != _getHash())
369
+ _l.hash = '#' + _ieLocal(_getHash(), true);
370
+
371
+ if (_opera)
372
+ history.navigationMode = 'compatible';
373
+
374
+ _searchScript(document);
375
+ var _qi = _url.indexOf('?');
376
+ if (_url && _qi > -1) {
377
+ var param, params = _url.substr(_qi + 1).split('&');
378
+ for (var i = 0, p; p = params[i]; i++) {
379
+ param = p.split('=');
380
+ if (/^(history|strict)$/.test(param[0])) {
381
+ _opts[param[0]] = (isNaN(param[1]) ? /^(true|yes)$/i.test(param[1]) : (parseInt(param[1]) != 0));
382
+ }
383
+ if (/^tracker$/.test(param[0]))
384
+ _opts[param[0]] = param[1];
385
+ }
386
+ }
387
+
388
+ $(_load);
389
+
390
+ } else if ((!_supported && _l.href.indexOf('#') != -1) ||
391
+ (_safari && _version < 418 && _l.href.indexOf('#') != -1 && _l.search != '')){
392
+ _d.open();
393
+ _d.write('<html><head><meta http-equiv="refresh" content="0;url=' +
394
+ _l.href.substr(0, _l.href.indexOf('#')) + '" /></head></html>');
395
+ _d.close();
396
+ } else {
397
+ _track();
398
+ }
399
+
400
+ $.each(('init,change').split(','), function(i, name){
401
+ _api[name] = function(data, fn){
402
+ $($.address).bind(name, fn || data, fn && data);
403
+ return this;
404
+ };
405
+ });
406
+
407
+ $.each(('baseURL,strict,history,tracker,title,value').split(','), function(i, name){
408
+ _api[name] = function(value){
409
+ if (typeof value != 'undefined') {
410
+ if (_supported)
411
+ _setters[name](value);
412
+ return $.address;
413
+ } else {
414
+ return _getters[name]();
415
+ }
416
+ };
417
+ });
418
+
419
+ $.each(('path,pathNames,queryString,parameter,parameterNames').split(','), function(i, name){
420
+ _api[name] = function(value){
421
+ return _getters[name](value);
422
+ };
423
+ });
424
+
425
+ return _api;
426
+
427
+ })();
428
+
429
+ $.fn.address = function (fn) {
430
+ $(this).click(function() {
431
+ var value = fn ? fn.call(this) :
432
+ /address:/.test($(this).attr('rel')) ? $(this).attr('rel').split('address:')[1].split(' ')[0] :
433
+ $(this).attr('href').replace(/^#/, '');
434
+ $.address.value(value);
435
+ return false;
436
+ });
437
+ };
438
+
439
+ }(jQuery));