wiselinks 0.6.4 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +58 -72
- data/README.md +38 -6
- data/build/{wiselinks-0.6.4.js → wiselinks-0.7.0.js} +56 -25
- data/build/{wiselinks-0.6.4.min.js → wiselinks-0.7.0.min.js} +10 -9
- data/build/wiselinks-0.7.0.min.js.gz +0 -0
- data/lib/assets/javascripts/_form.js.coffee +36 -13
- data/lib/assets/javascripts/_link.js.coffee +3 -3
- data/lib/assets/javascripts/_page.js.coffee +5 -5
- data/lib/assets/javascripts/_request_manager.js.coffee +11 -11
- data/lib/wiselinks.rb +1 -1
- data/lib/wiselinks/builder.rb +5 -5
- data/lib/wiselinks/controller_methods.rb +7 -8
- data/lib/wiselinks/helpers.rb +3 -3
- data/lib/wiselinks/logger.rb +1 -1
- data/lib/wiselinks/rails.rb +3 -3
- data/lib/wiselinks/rendering.rb +7 -7
- data/lib/wiselinks/request.rb +2 -2
- data/lib/wiselinks/version.rb +3 -3
- data/spec/dummy/app/controllers/application_controller.rb +5 -4
- data/spec/dummy/app/views/application/no_slash.html.erb +0 -0
- data/spec/dummy/app/views/application/trailing_slash.html.erb +0 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/helper.rb +6 -7
- data/spec/requests/trailing_slash_spec.rb +17 -0
- data/wiselinks.gemspec +1 -1
- metadata +17 -13
- data/build/wiselinks-0.6.4.min.js.gz +0 -0
data/Gemfile.lock
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
wiselinks (0.
|
4
|
+
wiselinks (0.7.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
actionmailer (3.2.
|
10
|
-
actionpack (= 3.2.
|
11
|
-
mail (~> 2.
|
12
|
-
actionpack (3.2.
|
13
|
-
activemodel (= 3.2.
|
14
|
-
activesupport (= 3.2.
|
9
|
+
actionmailer (3.2.13)
|
10
|
+
actionpack (= 3.2.13)
|
11
|
+
mail (~> 2.5.3)
|
12
|
+
actionpack (3.2.13)
|
13
|
+
activemodel (= 3.2.13)
|
14
|
+
activesupport (= 3.2.13)
|
15
15
|
builder (~> 3.0.0)
|
16
16
|
erubis (~> 2.7.0)
|
17
17
|
journey (~> 1.0.4)
|
@@ -19,42 +19,37 @@ GEM
|
|
19
19
|
rack-cache (~> 1.2)
|
20
20
|
rack-test (~> 0.6.1)
|
21
21
|
sprockets (~> 2.2.1)
|
22
|
-
activemodel (3.2.
|
23
|
-
activesupport (= 3.2.
|
22
|
+
activemodel (3.2.13)
|
23
|
+
activesupport (= 3.2.13)
|
24
24
|
builder (~> 3.0.0)
|
25
|
-
activerecord (3.2.
|
26
|
-
activemodel (= 3.2.
|
27
|
-
activesupport (= 3.2.
|
25
|
+
activerecord (3.2.13)
|
26
|
+
activemodel (= 3.2.13)
|
27
|
+
activesupport (= 3.2.13)
|
28
28
|
arel (~> 3.0.2)
|
29
29
|
tzinfo (~> 0.3.29)
|
30
|
-
activeresource (3.2.
|
31
|
-
activemodel (= 3.2.
|
32
|
-
activesupport (= 3.2.
|
33
|
-
activesupport (3.2.
|
34
|
-
i18n (
|
30
|
+
activeresource (3.2.13)
|
31
|
+
activemodel (= 3.2.13)
|
32
|
+
activesupport (= 3.2.13)
|
33
|
+
activesupport (3.2.13)
|
34
|
+
i18n (= 0.6.1)
|
35
35
|
multi_json (~> 1.0)
|
36
36
|
addressable (2.3.4)
|
37
37
|
arel (3.0.2)
|
38
|
-
bourne (1.1.2)
|
39
|
-
mocha (= 0.10.5)
|
40
38
|
builder (3.0.4)
|
41
|
-
capybara (2.0
|
39
|
+
capybara (2.1.0)
|
42
40
|
mime-types (>= 1.16)
|
43
41
|
nokogiri (>= 1.3.3)
|
44
42
|
rack (>= 1.0.0)
|
45
43
|
rack-test (>= 0.5.4)
|
46
|
-
|
47
|
-
|
48
|
-
childprocess (0.3.9)
|
49
|
-
ffi (~> 1.0, >= 1.0.11)
|
50
|
-
closure-compiler (1.1.8)
|
44
|
+
xpath (~> 2.0)
|
45
|
+
closure-compiler (1.1.10)
|
51
46
|
coffee-rails (3.2.2)
|
52
47
|
coffee-script (>= 2.2.0)
|
53
48
|
railties (~> 3.2.0)
|
54
49
|
coffee-script (2.2.0)
|
55
50
|
coffee-script-source
|
56
51
|
execjs
|
57
|
-
coffee-script-source (1.
|
52
|
+
coffee-script-source (1.6.2)
|
58
53
|
coffeelint (0.0.6)
|
59
54
|
coffee-script
|
60
55
|
colorize (0.5.8)
|
@@ -64,8 +59,9 @@ GEM
|
|
64
59
|
rest-client
|
65
60
|
simplecov (>= 0.7)
|
66
61
|
thor
|
67
|
-
crack (0.
|
68
|
-
|
62
|
+
crack (0.4.0)
|
63
|
+
safe_yaml (~> 0.9.0)
|
64
|
+
diff-lcs (1.2.4)
|
69
65
|
erubis (2.7.0)
|
70
66
|
execjs (1.4.0)
|
71
67
|
multi_json (~> 1.0)
|
@@ -73,21 +69,18 @@ GEM
|
|
73
69
|
activesupport (>= 3.0.0)
|
74
70
|
faker (1.1.2)
|
75
71
|
i18n (~> 0.5)
|
76
|
-
|
77
|
-
|
78
|
-
i18n (0.6.4)
|
72
|
+
hike (1.2.3)
|
73
|
+
i18n (0.6.1)
|
79
74
|
journey (1.0.4)
|
80
|
-
json (1.
|
81
|
-
mail (2.
|
82
|
-
i18n (>= 0.4.0)
|
75
|
+
json (1.8.0)
|
76
|
+
mail (2.5.4)
|
83
77
|
mime-types (~> 1.16)
|
84
78
|
treetop (~> 1.4.8)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
nokogiri (1.5.6)
|
79
|
+
mime-types (1.23)
|
80
|
+
mini_portile (0.5.0)
|
81
|
+
multi_json (1.7.7)
|
82
|
+
nokogiri (1.6.0)
|
83
|
+
mini_portile (~> 0.5.0)
|
91
84
|
polyglot (0.3.3)
|
92
85
|
rack (1.4.5)
|
93
86
|
rack-cache (1.2)
|
@@ -96,22 +89,22 @@ GEM
|
|
96
89
|
rack
|
97
90
|
rack-test (0.6.2)
|
98
91
|
rack (>= 1.0)
|
99
|
-
rails (3.2.
|
100
|
-
actionmailer (= 3.2.
|
101
|
-
actionpack (= 3.2.
|
102
|
-
activerecord (= 3.2.
|
103
|
-
activeresource (= 3.2.
|
104
|
-
activesupport (= 3.2.
|
92
|
+
rails (3.2.13)
|
93
|
+
actionmailer (= 3.2.13)
|
94
|
+
actionpack (= 3.2.13)
|
95
|
+
activerecord (= 3.2.13)
|
96
|
+
activeresource (= 3.2.13)
|
97
|
+
activesupport (= 3.2.13)
|
105
98
|
bundler (~> 1.0)
|
106
|
-
railties (= 3.2.
|
107
|
-
railties (3.2.
|
108
|
-
actionpack (= 3.2.
|
109
|
-
activesupport (= 3.2.
|
99
|
+
railties (= 3.2.13)
|
100
|
+
railties (3.2.13)
|
101
|
+
actionpack (= 3.2.13)
|
102
|
+
activesupport (= 3.2.13)
|
110
103
|
rack-ssl (~> 1.3.2)
|
111
104
|
rake (>= 0.8.7)
|
112
105
|
rdoc (~> 3.4)
|
113
106
|
thor (>= 0.14.6, < 2.0)
|
114
|
-
rake (10.0
|
107
|
+
rake (10.1.0)
|
115
108
|
rdoc (3.12.2)
|
116
109
|
json (~> 1.4)
|
117
110
|
rest-client (1.6.7)
|
@@ -120,30 +113,24 @@ GEM
|
|
120
113
|
rspec-core (~> 2.13.0)
|
121
114
|
rspec-expectations (~> 2.13.0)
|
122
115
|
rspec-mocks (~> 2.13.0)
|
123
|
-
rspec-core (2.13.
|
116
|
+
rspec-core (2.13.1)
|
124
117
|
rspec-expectations (2.13.0)
|
125
118
|
diff-lcs (>= 1.1.3, < 2.0)
|
126
|
-
rspec-mocks (2.13.
|
127
|
-
rspec-rails (2.13.
|
119
|
+
rspec-mocks (2.13.1)
|
120
|
+
rspec-rails (2.13.2)
|
128
121
|
actionpack (>= 3.0)
|
129
122
|
activesupport (>= 3.0)
|
130
123
|
railties (>= 3.0)
|
131
124
|
rspec-core (~> 2.13.0)
|
132
125
|
rspec-expectations (~> 2.13.0)
|
133
126
|
rspec-mocks (~> 2.13.0)
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
shoulda (3.3.2)
|
141
|
-
shoulda-context (~> 1.0.1)
|
142
|
-
shoulda-matchers (~> 1.4.1)
|
143
|
-
shoulda-context (1.0.2)
|
144
|
-
shoulda-matchers (1.4.2)
|
127
|
+
safe_yaml (0.9.3)
|
128
|
+
shoulda (3.5.0)
|
129
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
130
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
131
|
+
shoulda-context (1.1.4)
|
132
|
+
shoulda-matchers (2.2.0)
|
145
133
|
activesupport (>= 3.0.0)
|
146
|
-
bourne (~> 1.1.2)
|
147
134
|
simplecov (0.7.1)
|
148
135
|
multi_json (~> 1.0)
|
149
136
|
simplecov-html (~> 0.7.1)
|
@@ -154,17 +141,16 @@ GEM
|
|
154
141
|
rack (~> 1.0)
|
155
142
|
tilt (~> 1.1, != 1.3.0)
|
156
143
|
sqlite3 (1.3.7)
|
157
|
-
thor (0.
|
158
|
-
tilt (1.
|
159
|
-
treetop (1.4.
|
144
|
+
thor (0.18.1)
|
145
|
+
tilt (1.4.1)
|
146
|
+
treetop (1.4.14)
|
160
147
|
polyglot
|
161
148
|
polyglot (>= 0.3.1)
|
162
149
|
tzinfo (0.3.37)
|
163
150
|
webmock (1.9.3)
|
164
151
|
addressable (>= 2.2.7)
|
165
152
|
crack (>= 0.3.2)
|
166
|
-
|
167
|
-
xpath (1.0.0)
|
153
|
+
xpath (2.0.0)
|
168
154
|
nokogiri (~> 1.3)
|
169
155
|
|
170
156
|
PLATFORMS
|
@@ -179,7 +165,7 @@ DEPENDENCIES
|
|
179
165
|
coveralls
|
180
166
|
factory_girl
|
181
167
|
faker
|
182
|
-
rails (
|
168
|
+
rails (~> 3.2.13)
|
183
169
|
rake
|
184
170
|
rspec
|
185
171
|
rspec-rails
|
data/README.md
CHANGED
@@ -60,7 +60,13 @@ Wiselinks works in all major browsers including browsers that do not support HTM
|
|
60
60
|
<td>Yes (experimental feature)</td>
|
61
61
|
</tr>
|
62
62
|
<tr>
|
63
|
-
<td>Form
|
63
|
+
<td>Form blank values exclusion</td>
|
64
|
+
<td><strong>Yes</strong> (optional)</td>
|
65
|
+
<td>No</td>
|
66
|
+
<td>No</td>
|
67
|
+
</tr>
|
68
|
+
<tr>
|
69
|
+
<td>Form values optimization</td>
|
64
70
|
<td><strong>Yes</strong></td>
|
65
71
|
<td>No</td>
|
66
72
|
<td>No</td>
|
@@ -235,7 +241,7 @@ Data from the request will be pasted into `<div id="catalog">`. This configurati
|
|
235
241
|
|
236
242
|
Wiselinks can process forms. After submit button is clicked, Wiselinks will perform a request to form url with form attributes serialized to a string. Wiselinks always performs a HTTP GET request.
|
237
243
|
|
238
|
-
```html
|
244
|
+
```html
|
239
245
|
<div class="filter">
|
240
246
|
<form action="/" method="get" data-push="true" data-target="@catalog">
|
241
247
|
<input type="text" size="30" name="title" id="title">
|
@@ -248,15 +254,41 @@ Wiselinks can process forms. After submit button is clicked, Wiselinks will perf
|
|
248
254
|
<option value="trashed">Trash</option>
|
249
255
|
</select>
|
250
256
|
|
251
|
-
<input type="submit" value="Find" name="commit">
|
257
|
+
<input type="submit" value="Find" name="commit">
|
252
258
|
</form>
|
253
|
-
</div>
|
259
|
+
</div>
|
254
260
|
|
255
261
|
<div role="catalog">
|
256
262
|
<!-- the list of your items -->
|
257
|
-
...
|
263
|
+
...
|
258
264
|
</div>
|
259
|
-
```
|
265
|
+
```
|
266
|
+
**data-include-blank-url-params**
|
267
|
+
|
268
|
+
During form submit Wiselinks excludes blank parameters to make your URLs cleaner. You can disable this behaviour with ```data-include-blank-url-params``` attribute.
|
269
|
+
|
270
|
+
```html
|
271
|
+
<div class="filter">
|
272
|
+
<form action="/" method="get" data-push="true" data-target="@catalog" data-include-blank-url-params="true">
|
273
|
+
<input type="text" size="30" name="title" id="title">
|
274
|
+
<input type="submit" value="Find" name="commit">
|
275
|
+
</form>
|
276
|
+
</div>
|
277
|
+
```
|
278
|
+
|
279
|
+
**data-optimize-url-params**
|
280
|
+
|
281
|
+
Array parameters ```category_ids[]=1&category_ids[]=2&category_ids[]=3``` are optimized to more human readable ```category_ids=1,2,3```. To changed this behaviour use ```data-optimize-url-params``` attribute.
|
282
|
+
|
283
|
+
```html
|
284
|
+
<div class="filter">
|
285
|
+
<form action="/" method="get" data-push="true" data-target="@catalog" data-optimize-url-params="false">
|
286
|
+
<input type="text" size="30" name="title" id="title">
|
287
|
+
<input type="submit" value="Find" name="commit">
|
288
|
+
</form>
|
289
|
+
</div>
|
290
|
+
```
|
291
|
+
|
260
292
|
|
261
293
|
### Server processing
|
262
294
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
/**
|
2
|
-
* Wiselinks-0.
|
2
|
+
* Wiselinks-0.7.0
|
3
3
|
* @copyright 2012-2013 Igor Alexandrov, Alexey Solilin, Julia Egorova, Alexandr Borisov
|
4
4
|
* @preserve https://github.com/igor-alexandrov/wiselinks
|
5
|
-
*/
|
5
|
+
*/
|
6
6
|
|
7
7
|
// Generated by CoffeeScript 1.6.3
|
8
8
|
(function() {
|
@@ -15,15 +15,26 @@
|
|
15
15
|
}
|
16
16
|
|
17
17
|
Form.prototype.process = function() {
|
18
|
-
var
|
18
|
+
var self;
|
19
|
+
self = this;
|
20
|
+
if (self._include_blank_url_params()) {
|
21
|
+
return self.page.load(self._url(), self._target(), self._type());
|
22
|
+
} else {
|
23
|
+
return self._without_blank_url_params(function() {
|
24
|
+
return self.page.load(self._url(), self._target(), self._type());
|
25
|
+
});
|
26
|
+
}
|
27
|
+
};
|
28
|
+
|
29
|
+
Form.prototype._without_blank_url_params = function(callback) {
|
30
|
+
var $disable, selector;
|
19
31
|
selector = 'select:not(:disabled),input:not(:disabled)';
|
20
32
|
$disable = this.$form.find(selector).filter(function() {
|
21
33
|
return !$(this).val();
|
22
34
|
});
|
23
35
|
$disable.attr('disabled', true);
|
24
|
-
|
25
|
-
$disable.attr('disabled', false);
|
26
|
-
return this.page.load(url, this.$form.attr("data-target"), this._type());
|
36
|
+
callback();
|
37
|
+
return $disable.attr('disabled', false);
|
27
38
|
};
|
28
39
|
|
29
40
|
Form.prototype._params = function() {
|
@@ -44,23 +55,43 @@
|
|
44
55
|
return hash;
|
45
56
|
};
|
46
57
|
|
58
|
+
Form.prototype._include_blank_url_params = function() {
|
59
|
+
return this.$form.data('include-blank-url-params') === true;
|
60
|
+
};
|
61
|
+
|
62
|
+
Form.prototype._optimize_url_params = function() {
|
63
|
+
return this.$form.data('optimize-url-params') !== false;
|
64
|
+
};
|
65
|
+
|
47
66
|
Form.prototype._type = function() {
|
48
|
-
if (this.$form.
|
67
|
+
if (this.$form.data('push') === 'partial') {
|
49
68
|
return 'partial';
|
50
69
|
} else {
|
51
70
|
return 'template';
|
52
71
|
}
|
53
72
|
};
|
54
73
|
|
74
|
+
Form.prototype._target = function() {
|
75
|
+
return this.$form.data('target');
|
76
|
+
};
|
77
|
+
|
55
78
|
Form.prototype._url = function() {
|
56
|
-
var key, serialized, url, value
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
79
|
+
var key, params, self, serialized, url, value;
|
80
|
+
self = this;
|
81
|
+
serialized = (function() {
|
82
|
+
var _ref;
|
83
|
+
if (self._optimize_url_params()) {
|
84
|
+
params = [];
|
85
|
+
_ref = this._params();
|
86
|
+
for (key in _ref) {
|
87
|
+
value = _ref[key];
|
88
|
+
params.push("" + key + "=" + (encodeURIComponent(value)));
|
89
|
+
}
|
90
|
+
return params.join('&');
|
91
|
+
} else {
|
92
|
+
return this.$form.serialize();
|
93
|
+
}
|
94
|
+
}).call(this);
|
64
95
|
url = this.$form.attr("action");
|
65
96
|
if (serialized.length > 0) {
|
66
97
|
url += "?" + serialized;
|
@@ -72,7 +103,7 @@
|
|
72
103
|
|
73
104
|
})();
|
74
105
|
|
75
|
-
if (window._Wiselinks
|
106
|
+
if (window._Wiselinks == null) {
|
76
107
|
window._Wiselinks = {};
|
77
108
|
}
|
78
109
|
|
@@ -90,8 +121,8 @@
|
|
90
121
|
|
91
122
|
Link.prototype.process = function() {
|
92
123
|
var type;
|
93
|
-
type = this.$link.
|
94
|
-
return this.page.load(this.$link.attr("href"), this.$link.
|
124
|
+
type = this.$link.data('push') === 'partial' ? 'partial' : 'template';
|
125
|
+
return this.page.load(this.$link.attr("href"), this.$link.data('target'), type);
|
95
126
|
};
|
96
127
|
|
97
128
|
Link.prototype._cross_origin_link = function(link) {
|
@@ -261,7 +292,7 @@
|
|
261
292
|
return window.location.reload(true);
|
262
293
|
} else {
|
263
294
|
state = History.getState();
|
264
|
-
if ((url != null) && url !== state.url) {
|
295
|
+
if ((url != null) && url !== encodeURI(state.url)) {
|
265
296
|
self._redirect_to(url, $target, state, xhr);
|
266
297
|
}
|
267
298
|
$target.html(data);
|
@@ -293,16 +324,16 @@
|
|
293
324
|
return $(document).trigger('page:loading', [$target, state.data.render, state.url]);
|
294
325
|
};
|
295
326
|
|
296
|
-
RequestManager.prototype._done = function($target, status,
|
297
|
-
return $(document).trigger('page:done', [$target, status,
|
327
|
+
RequestManager.prototype._done = function($target, status, url, data) {
|
328
|
+
return $(document).trigger('page:done', [$target, status, url, data]);
|
298
329
|
};
|
299
330
|
|
300
|
-
RequestManager.prototype._fail = function($target, status,
|
301
|
-
return $(document).trigger('page:fail', [$target, status,
|
331
|
+
RequestManager.prototype._fail = function($target, status, url, error) {
|
332
|
+
return $(document).trigger('page:fail', [$target, status, url, error]);
|
302
333
|
};
|
303
334
|
|
304
|
-
RequestManager.prototype._always = function($target, status,
|
305
|
-
return $(document).trigger('page:always', [$target, status,
|
335
|
+
RequestManager.prototype._always = function($target, status, url) {
|
336
|
+
return $(document).trigger('page:always', [$target, status, url]);
|
306
337
|
};
|
307
338
|
|
308
339
|
RequestManager.prototype._title = function(value) {
|
@@ -13,18 +13,19 @@
|
|
13
13
|
2010-2011 Benjamin Arthur Lupton <contact@balupton.com>
|
14
14
|
@license New BSD License <http://creativecommons.org/licenses/BSD/>
|
15
15
|
*/
|
16
|
-
(function(){var c;c=function(){function c(d,e){this.page=d;this.$form=e}c.prototype.process=function(){var d
|
17
|
-
e.name.length-2)?e.name.substr(0,e.name.length-2):e.name,d[b]=null!=d[b]?d[b]+(","+e.value):e.value);return d};c.prototype.
|
18
|
-
|
19
|
-
d.
|
20
|
-
(
|
21
|
-
|
16
|
+
(function(){var c;c=function(){function c(d,e){this.page=d;this.$form=e}c.prototype.process=function(){var d;d=this;return d._include_blank_url_params()?d.page.load(d._url(),d._target(),d._type()):d._without_blank_url_params(function(){return d.page.load(d._url(),d._target(),d._type())})};c.prototype._without_blank_url_params=function(d){var e;e=this.$form.find("select:not(:disabled),input:not(:disabled)").filter(function(){return!$(this).val()});e.attr("disabled",!0);d();return e.attr("disabled",
|
17
|
+
!1)};c.prototype._params=function(){var d,e,b,f,c,q;d={};q=this.$form.serializeArray();f=0;for(c=q.length;f<c;f++)e=q[f],"utf8"!==e.name&&(b=-1!==e.name.indexOf("[]",e.name.length-2)?e.name.substr(0,e.name.length-2):e.name,d[b]=null!=d[b]?d[b]+(","+e.value):e.value);return d};c.prototype._include_blank_url_params=function(){return!0===this.$form.data("include-blank-url-params")};c.prototype._optimize_url_params=function(){return!1!==this.$form.data("optimize-url-params")};c.prototype._type=function(){return"partial"===
|
18
|
+
this.$form.data("push")?"partial":"template"};c.prototype._target=function(){return this.$form.data("target")};c.prototype._url=function(){var d,e,b;var f;if(this._optimize_url_params()){e=[];f=this._params();for(d in f)b=f[d],e.push(""+d+"="+encodeURIComponent(b));d=e.join("&")}else d=this.$form.serialize();e=this.$form.attr("action");0<d.length&&(e+="?"+d);return e};return c}();null==window._Wiselinks&&(window._Wiselinks={});window._Wiselinks.Form=c;c=function(){function c(d,e){this.page=d;this.$link=
|
19
|
+
e}c.prototype.allows_process=function(d){return!(this._cross_origin_link(d.currentTarget)||this._non_standard_click(d))};c.prototype.process=function(){var d;d="partial"===this.$link.data("push")?"partial":"template";return this.page.load(this.$link.attr("href"),this.$link.data("target"),d)};c.prototype._cross_origin_link=function(d){return location.protocol!==d.protocol||location.host.split(":")[0]!==d.host.split(":")[0]};c.prototype._non_standard_click=function(d){return d.metaKey||d.ctrlKey||d.shiftKey||
|
20
|
+
d.altKey};return c}();void 0===window._Wiselinks&&(window._Wiselinks={});window._Wiselinks.Link=c;c=function(){function c(d,e){var b;this.$target=d;this.options=e;b=this;this.template_id=(new Date).getTime();this.request_manager=new _Wiselinks.RequestManager(this.options);b._try_target(this.$target);History.emulated.pushState&&!0===this.options.html4&&(-1===window.location.href.indexOf("#!")&&(!0===this.options.html4_normalize_path&&window.location.pathname!==this.options.html4_root_path)&&(window.location.href=
|
21
|
+
""+window.location.protocol+"// "+window.location.host+" "+this.options.html4_root_path+"#! "+window.location.pathname),-1!==window.location.hash.indexOf("#!")&&b._call(b._make_state(window.location.hash.substring(2))));History.Adapter.bind(window,"statechange",function(d,e){var c;c=History.getState();return b._template_id_changed(c)?b._call(b._reset_state(c)):b._call(c)});$(document).on("click","a[data-push], a[data-replace]",function(d){var e;if((e=new _Wiselinks.Link(b,
|
22
|
+
$(this))).allows_process(d))return d.preventDefault(),e.process(),!1});$(document).on("submit","form[data-push], form[data-replace]",function(d){var e;if(e=new _Wiselinks.Form(b,$(this)))return d.preventDefault(),e.process(),!1})}c.prototype.load=function(d,e,b){null==b&&(b="template");"partial"!==b&&(this.template_id=(new Date).getTime());null!=e&&this._try_target($(e));return History.pushState({timestamp:(new Date).getTime(),template_id:this.template_id,render:b,target:e,referer:window.location.href},
|
22
23
|
document.title,d)};c.prototype.reload=function(){return History.replaceState({timestamp:(new Date).getTime(),template_id:this.template_id,render:"template",referer:window.location.href},document.title,History.getState().url)};c.prototype._call=function(d){var e;e=null!=d.data.target?$(d.data.target):this.$target;return this.request_manager.call(e,d)};c.prototype._template_id_changed=function(d){return null==d.data.template_id||d.data.template_id!==this.template_id};c.prototype._make_state=function(d,
|
23
24
|
e,b,f){null==b&&(b="template");return{url:d,data:{target:e,render:b,referer:f}}};c.prototype._reset_state=function(d){null==d.data&&(d.data={});d.data.target=null;d.data.render="template";return d};c.prototype._try_target=function(d){if(0===d.length&&"exception"===this.options.target_missing)throw Error("[Wiselinks] Target missing: `"+d.selector+"`");};return c}();void 0===window._Wiselinks&&(window._Wiselinks={});window._Wiselinks.Page=c;c=function(){function c(d){this.options=null!=d?d:{}}c.prototype.call=
|
24
|
-
function(d,c){var b;b=this;if(null!=this.redirected)this.redirected=null;else return b._loading(d,c),$.ajax({url:c.url,headers:{"X-Wiselinks":c.data.render,"X-Wiselinks-Referer":c.data.referer},dataType:"html"}).done(function(f,g,k){var l,h;h=k.getResponseHeader("X-Wiselinks-Url");l=k.getResponseHeader("X-Wiselinks-Assets-Digest");if(b._assets_changed(l))return window.location.reload(!0);c=History.getState();null!=h&&h!==c.url&&b._redirect_to(h,d,c,k);d.html(f);b._title(k.getResponseHeader("X-Wiselinks-Title"));
|
25
|
+
function(d,c){var b;b=this;if(null!=this.redirected)this.redirected=null;else return b._loading(d,c),$.ajax({url:c.url,headers:{"X-Wiselinks":c.data.render,"X-Wiselinks-Referer":c.data.referer},dataType:"html"}).done(function(f,g,k){var l,h;h=k.getResponseHeader("X-Wiselinks-Url");l=k.getResponseHeader("X-Wiselinks-Assets-Digest");if(b._assets_changed(l))return window.location.reload(!0);c=History.getState();null!=h&&h!==encodeURI(c.url)&&b._redirect_to(h,d,c,k);d.html(f);b._title(k.getResponseHeader("X-Wiselinks-Title"));
|
25
26
|
return b._done(d,g,c.url,f)}).fail(function(f,g,k){return b._fail(d,g,c.url,k)}).always(function(f,g,k){return b._always(d,g,c.url)})};c.prototype._assets_changed=function(d){return null!=this.options.assets_digest&&this.options.assets_digest!==d};c.prototype._redirect_to=function(d,c,b,f){f&&4>f.readyState&&(f.onreadystatechange=$.noop,f.abort());this.redirected=!0;$(document).trigger("page:redirected",[c,b.data.render,d]);return History.replaceState(b.data,document.title,d)};c.prototype._loading=
|
26
|
-
function(d,c){return $(document).trigger("page:loading",[d,c.data.render,c.url])};c.prototype._done=function(d,c,b,f){return $(document).trigger("page:done",[d,c,b
|
27
|
-
|
27
|
+
function(d,c){return $(document).trigger("page:loading",[d,c.data.render,c.url])};c.prototype._done=function(d,c,b,f){return $(document).trigger("page:done",[d,c,b,f])};c.prototype._fail=function(d,c,b,f){return $(document).trigger("page:fail",[d,c,b,f])};c.prototype._always=function(d,c,b){return $(document).trigger("page:always",[d,c,b])};c.prototype._title=function(d){if(null!=d)return $(document).trigger("page:title",decodeURI(d)),document.title=decodeURI(d)};return c}();void 0===window._Wiselinks&&
|
28
|
+
(window._Wiselinks={});window._Wiselinks.RequestManager=c;c=function(){function c(d,e){null==d&&(d=$("body"));this.options=null!=e?e:{};this._try_jquery();this.options=$.extend(this._defaults(),this.options);this.enabled()&&(this.page=new _Wiselinks.Page(d,this.options))}c.prototype.enabled=function(){return!History.emulated.pushState||!0===this.options.html4};c.prototype.load=function(c,e,b){null==b&&(b="template");return this.page.load(c,e,b)};c.prototype.reload=function(){return this.page.reload()};
|
28
29
|
c.prototype._defaults=function(){return{html4:!0,html4_root_path:"/",html4_normalize_path:!0,target_missing:null,assets_digest:$("meta[name='assets-digest']").attr("content")}};c.prototype._try_jquery=function(){if(null==window.jQuery)throw Error("[Wiselinks] jQuery is not loaded");};return c}();window.Wiselinks=c}).call(this);
|
29
30
|
(function(c,q){var d=c.History=c.History||{},e=c.jQuery;if("undefined"!==typeof d.Adapter)throw Error("History.js Adapter has already been loaded...");d.Adapter={bind:function(b,c,d){e(b).bind(c,d)},trigger:function(b,c,d){e(b).trigger(c,d)},extractEventData:function(b,c,d){return c&&c.originalEvent&&c.originalEvent[b]||d&&d[b]||q},onDomLoad:function(b){e(b)}};"undefined"!==typeof d.init&&d.init()})(window);
|
30
31
|
(function(c,q){var d=c.document,e=c.setInterval||e,b=c.History=c.History||{};if("undefined"!==typeof b.initHtml4)throw Error("History.js HTML4 Support has already been loaded...");b.initHtml4=function(){if("undefined"!==typeof b.initHtml4.initialized)return!1;b.initHtml4.initialized=!0;b.enabled=!0;b.savedHashes=[];b.isLastHash=function(c){var d=b.getHashByIndex();return c===d};b.saveHash=function(c){if(b.isLastHash(c))return!1;b.savedHashes.push(c);return!0};b.getHashByIndex=function(c){var d=null;
|
Binary file
|
@@ -2,15 +2,24 @@ class Form
|
|
2
2
|
constructor: (@page, @$form) ->
|
3
3
|
|
4
4
|
process: ->
|
5
|
+
self = this
|
6
|
+
|
7
|
+
if self._include_blank_url_params()
|
8
|
+
self.page.load(self._url(), self._target(), self._type())
|
9
|
+
else
|
10
|
+
self._without_blank_url_params(
|
11
|
+
->
|
12
|
+
self.page.load(self._url(), self._target(), self._type())
|
13
|
+
)
|
14
|
+
|
15
|
+
_without_blank_url_params: (callback) ->
|
5
16
|
selector = 'select:not(:disabled),input:not(:disabled)'
|
6
17
|
$disable = @$form.find(selector).filter(-> !$(this).val())
|
7
18
|
|
8
19
|
$disable.attr('disabled', true)
|
9
|
-
|
20
|
+
callback()
|
10
21
|
$disable.attr('disabled', false)
|
11
22
|
|
12
|
-
@page.load(url, @$form.attr("data-target"), this._type())
|
13
|
-
|
14
23
|
_params: ->
|
15
24
|
hash = {}
|
16
25
|
|
@@ -29,23 +38,37 @@ class Form
|
|
29
38
|
|
30
39
|
hash
|
31
40
|
|
41
|
+
_include_blank_url_params: ->
|
42
|
+
@$form.data('include-blank-url-params') == true
|
43
|
+
|
44
|
+
_optimize_url_params: ->
|
45
|
+
@$form.data('optimize-url-params') != false
|
46
|
+
|
32
47
|
_type: ->
|
33
|
-
if (@$form.
|
48
|
+
if (@$form.data('push') == 'partial') then 'partial' else 'template'
|
49
|
+
|
50
|
+
_target: ->
|
51
|
+
@$form.data('target')
|
34
52
|
|
35
53
|
_url: ->
|
36
|
-
|
54
|
+
self = this
|
55
|
+
|
56
|
+
serialized = if self._optimize_url_params()
|
57
|
+
params = []
|
58
|
+
|
59
|
+
# To find out why encodeURIComponent should be used, follow the link:
|
60
|
+
# http://stackoverflow.com/questions/75980/best-practice-escape-or-encodeuri-encodeuricomponent
|
61
|
+
#
|
62
|
+
for key, value of this._params()
|
63
|
+
params.push("#{key}=#{encodeURIComponent(value)}")
|
37
64
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
for key, value of this._params()
|
42
|
-
serialized.push("#{key}=#{encodeURIComponent(value)}")
|
65
|
+
params.join('&')
|
66
|
+
else
|
67
|
+
@$form.serialize()
|
43
68
|
|
44
|
-
serialized = serialized.join('&')
|
45
|
-
|
46
69
|
url = @$form.attr("action")
|
47
70
|
url += "?#{serialized}" if serialized.length > 0
|
48
71
|
url
|
49
72
|
|
50
|
-
window._Wiselinks
|
73
|
+
window._Wiselinks ?= {}
|
51
74
|
window._Wiselinks.Form = Form
|
@@ -1,17 +1,17 @@
|
|
1
1
|
class Link
|
2
2
|
constructor: (@page, @$link) ->
|
3
|
-
|
3
|
+
|
4
4
|
allows_process: (event) ->
|
5
5
|
!(this._cross_origin_link(event.currentTarget) ||
|
6
6
|
this._non_standard_click(event))
|
7
7
|
|
8
8
|
process: ->
|
9
|
-
type = if (@$link.
|
9
|
+
type = if (@$link.data('push') == 'partial')
|
10
10
|
'partial'
|
11
11
|
else
|
12
12
|
'template'
|
13
13
|
|
14
|
-
@page.load(@$link.attr("href"), @$link.
|
14
|
+
@page.load(@$link.attr("href"), @$link.data('target'), type)
|
15
15
|
|
16
16
|
# We split host because IE returns host with port and other browsers not
|
17
17
|
#
|
@@ -18,7 +18,7 @@ class Page
|
|
18
18
|
#{window.location.host}
|
19
19
|
#{@options.html4_root_path}#!
|
20
20
|
#{window.location.pathname}"
|
21
|
-
|
21
|
+
|
22
22
|
if window.location.hash.indexOf('#!') != -1
|
23
23
|
self._call(self._make_state(window.location.hash.substring(2)))
|
24
24
|
|
@@ -27,7 +27,7 @@ class Page
|
|
27
27
|
"statechange"
|
28
28
|
(event, data) ->
|
29
29
|
state = History.getState()
|
30
|
-
|
30
|
+
|
31
31
|
if self._template_id_changed(state)
|
32
32
|
self._call(self._reset_state(state))
|
33
33
|
else
|
@@ -74,7 +74,7 @@ class Page
|
|
74
74
|
render: 'template',
|
75
75
|
referer: window.location.href
|
76
76
|
}, document.title, History.getState().url )
|
77
|
-
|
77
|
+
|
78
78
|
_call: (state) ->
|
79
79
|
$target = if state.data.target? then $(state.data.target) else @$target
|
80
80
|
this.request_manager.call($target, state)
|
@@ -90,13 +90,13 @@ class Page
|
|
90
90
|
render: render
|
91
91
|
referer: referer
|
92
92
|
}
|
93
|
-
|
93
|
+
|
94
94
|
_reset_state: (state) ->
|
95
95
|
state.data = {} unless state.data?
|
96
96
|
state.data.target = null
|
97
97
|
state.data.render = 'template'
|
98
98
|
state
|
99
|
-
|
99
|
+
|
100
100
|
_try_target: ($target) ->
|
101
101
|
if $target.length == 0 && @options.target_missing == 'exception'
|
102
102
|
throw new Error("[Wiselinks] Target missing: `#{$target.selector}`")
|
@@ -21,7 +21,7 @@ class RequestManager
|
|
21
21
|
headers:
|
22
22
|
'X-Wiselinks': state.data.render
|
23
23
|
'X-Wiselinks-Referer': state.data.referer
|
24
|
-
|
24
|
+
|
25
25
|
dataType: "html"
|
26
26
|
).done(
|
27
27
|
(data, status, xhr) ->
|
@@ -32,9 +32,9 @@ class RequestManager
|
|
32
32
|
window.location.reload(true)
|
33
33
|
else
|
34
34
|
state = History.getState()
|
35
|
-
if url? && url != state.url
|
35
|
+
if url? && url != encodeURI(state.url)
|
36
36
|
self._redirect_to(url, $target, state, xhr)
|
37
|
-
|
37
|
+
|
38
38
|
$target.html(data)
|
39
39
|
|
40
40
|
self._title(xhr.getResponseHeader('X-Wiselinks-Title'))
|
@@ -54,7 +54,7 @@ class RequestManager
|
|
54
54
|
if ( xhr && xhr.readyState < 4)
|
55
55
|
xhr.onreadystatechange = $.noop
|
56
56
|
xhr.abort()
|
57
|
-
|
57
|
+
|
58
58
|
@redirected = true
|
59
59
|
$(document).trigger('page:redirected', [$target, state.data.render, url])
|
60
60
|
History.replaceState(state.data, document.title, url)
|
@@ -62,20 +62,20 @@ class RequestManager
|
|
62
62
|
_loading: ($target, state) ->
|
63
63
|
$(document).trigger('page:loading', [$target, state.data.render, state.url])
|
64
64
|
|
65
|
-
_done: ($target, status,
|
66
|
-
$(document).trigger('page:done', [$target, status,
|
65
|
+
_done: ($target, status, url, data) ->
|
66
|
+
$(document).trigger('page:done', [$target, status, url, data])
|
67
67
|
|
68
|
-
_fail: ($target, status,
|
69
|
-
$(document).trigger('page:fail', [$target, status,
|
68
|
+
_fail: ($target, status, url, error) ->
|
69
|
+
$(document).trigger('page:fail', [$target, status, url, error])
|
70
70
|
|
71
|
-
_always: ($target, status,
|
72
|
-
$(document).trigger('page:always', [$target, status,
|
71
|
+
_always: ($target, status, url) ->
|
72
|
+
$(document).trigger('page:always', [$target, status, url])
|
73
73
|
|
74
74
|
_title: (value) ->
|
75
75
|
if value?
|
76
76
|
$(document).trigger('page:title', decodeURI(value))
|
77
77
|
document.title = decodeURI(value)
|
78
|
-
|
78
|
+
|
79
79
|
|
80
80
|
window._Wiselinks = {} if window._Wiselinks == undefined
|
81
81
|
window._Wiselinks.RequestManager = RequestManager
|
data/lib/wiselinks.rb
CHANGED
data/lib/wiselinks/builder.rb
CHANGED
@@ -5,16 +5,16 @@ require 'coffeelint'
|
|
5
5
|
|
6
6
|
require 'wiselinks/version'
|
7
7
|
|
8
|
-
module Wiselinks
|
8
|
+
module Wiselinks
|
9
9
|
class Builder
|
10
10
|
include Rake::DSL if defined? Rake::DSL
|
11
11
|
|
12
|
-
class << self
|
12
|
+
class << self
|
13
13
|
attr_accessor :instance
|
14
14
|
|
15
15
|
def install
|
16
16
|
self.new.install
|
17
|
-
end
|
17
|
+
end
|
18
18
|
end
|
19
19
|
|
20
20
|
|
@@ -38,7 +38,7 @@ module Wiselinks
|
|
38
38
|
system("rm ./build/*")
|
39
39
|
|
40
40
|
system("echo '#{self.declaration}' > ./build/#{self.name_with_version}.js")
|
41
|
-
system("coffee -o ./build -j temp.js -c #{self.coffee_sources.join(' ')}")
|
41
|
+
system("coffee -o ./build -j temp.js -c #{self.coffee_sources.join(' ')}")
|
42
42
|
system("cat ./build/temp.js >> ./build/#{self.name_with_version}.js")
|
43
43
|
|
44
44
|
self.js_sources.each do |file|
|
@@ -83,7 +83,7 @@ module Wiselinks
|
|
83
83
|
* #{self.name.capitalize}-#{self.version}
|
84
84
|
* @copyright 2012-#{Date.today.year} #{self.specification.authors.join(', ')}
|
85
85
|
* @preserve https://github.com/igor-alexandrov/wiselinks
|
86
|
-
*/
|
86
|
+
*/
|
87
87
|
EOS
|
88
88
|
end
|
89
89
|
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module Wiselinks
|
2
|
-
module ControllerMethods
|
3
|
-
|
4
|
-
def self.included(base)
|
5
|
-
base.helper_method :wiselinks_title
|
2
|
+
module ControllerMethods
|
6
3
|
|
4
|
+
def self.included(base)
|
5
|
+
base.helper_method :wiselinks_title
|
7
6
|
base.before_filter :set_wiselinks_url
|
8
7
|
end
|
9
8
|
|
@@ -15,13 +14,13 @@ module Wiselinks
|
|
15
14
|
|
16
15
|
def wiselinks_title(value)
|
17
16
|
if self.request.wiselinks? && value.present?
|
18
|
-
Wiselinks.log("title: #{value}")
|
17
|
+
Wiselinks.log("title: #{value}")
|
19
18
|
self.response.headers['X-Wiselinks-Title'] = URI.encode(value)
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
|
-
def set_wiselinks_url
|
24
|
-
self.response.headers['X-Wiselinks-Url'] = request.
|
22
|
+
def set_wiselinks_url
|
23
|
+
self.response.headers['X-Wiselinks-Url'] = request.env['REQUEST_URI'] if self.request.wiselinks?
|
25
24
|
end
|
26
25
|
end
|
27
|
-
end
|
26
|
+
end
|
data/lib/wiselinks/helpers.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Wiselinks
|
2
|
-
module Helpers
|
2
|
+
module Helpers
|
3
3
|
def wiselinks_meta_tag
|
4
|
-
if Wiselinks.options[:assets_digest].present?
|
4
|
+
if Wiselinks.options[:assets_digest].present?
|
5
5
|
tag('meta', :name => 'assets-digest', :content => Wiselinks.options[:assets_digest])
|
6
6
|
end
|
7
|
-
end
|
7
|
+
end
|
8
8
|
end
|
9
9
|
end
|
data/lib/wiselinks/logger.rb
CHANGED
data/lib/wiselinks/rails.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Wiselinks
|
2
2
|
module Rails
|
3
3
|
class Engine < ::Rails::Engine
|
4
|
-
initializer 'wiselinks.register_logger' do
|
4
|
+
initializer 'wiselinks.register_logger' do
|
5
5
|
Wiselinks.options[:logger] = ::Rails.logger
|
6
6
|
end
|
7
7
|
|
@@ -9,8 +9,8 @@ module Wiselinks
|
|
9
9
|
ActionDispatch::Request.send :include, Request
|
10
10
|
ActionController::Base.send :include, ControllerMethods
|
11
11
|
ActionController::Base.send :include, Rendering
|
12
|
-
ActionView::Base.send :include, Helpers
|
13
|
-
end
|
12
|
+
ActionView::Base.send :include, Helpers
|
13
|
+
end
|
14
14
|
|
15
15
|
initializer "wiselinks.register_assets_digest" do
|
16
16
|
if ::Rails.application.config.assets.digest && ::Rails.application.config.assets.digests.present?
|
data/lib/wiselinks/rendering.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Wiselinks
|
2
|
-
module Rendering
|
3
|
-
|
4
|
-
def self.included(base)
|
2
|
+
module Rendering
|
3
|
+
|
4
|
+
def self.included(base)
|
5
5
|
base.alias_method_chain :render, :wiselinks
|
6
6
|
end
|
7
7
|
|
@@ -10,7 +10,7 @@ module Wiselinks
|
|
10
10
|
def render_with_wiselinks(*args, &block)
|
11
11
|
options = _normalize_args(*args)
|
12
12
|
|
13
|
-
if self.request.wiselinks?
|
13
|
+
if self.request.wiselinks?
|
14
14
|
self.headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
|
15
15
|
self.headers['Pragma'] = 'no-cache'
|
16
16
|
|
@@ -20,15 +20,15 @@ module Wiselinks
|
|
20
20
|
else
|
21
21
|
Wiselinks.log("Processing template request")
|
22
22
|
if Wiselinks.options[:layout] != false
|
23
|
-
options[:layout] = self.wiselinks_layout
|
23
|
+
options[:layout] = self.wiselinks_layout
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
27
|
if Wiselinks.options[:assets_digest].present?
|
28
28
|
Wiselinks.log("Assets digest #{Wiselinks.options[:assets_digest]}")
|
29
29
|
|
30
|
-
self.headers['X-Wiselinks-Assets-Digest'] = Wiselinks.options[:assets_digest]
|
31
|
-
end
|
30
|
+
self.headers['X-Wiselinks-Assets-Digest'] = Wiselinks.options[:assets_digest]
|
31
|
+
end
|
32
32
|
end
|
33
33
|
|
34
34
|
self.render_without_wiselinks(options, &block)
|
data/lib/wiselinks/request.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Wiselinks
|
2
2
|
module Request
|
3
|
-
def self.included(base)
|
3
|
+
def self.included(base)
|
4
4
|
base.alias_method_chain :referer, :wiselinks
|
5
5
|
base.alias_method_chain :referrer, :wiselinks
|
6
6
|
end
|
@@ -10,7 +10,7 @@ module Wiselinks
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def referrer_with_wiselinks
|
13
|
-
self.referer_with_wiselinks
|
13
|
+
self.referer_with_wiselinks
|
14
14
|
end
|
15
15
|
|
16
16
|
def wiselinks?
|
data/lib/wiselinks/version.rb
CHANGED
File without changes
|
File without changes
|
data/spec/dummy/config/routes.rb
CHANGED
data/spec/helper.rb
CHANGED
@@ -1,20 +1,19 @@
|
|
1
1
|
$:.unshift File.expand_path('..', __FILE__)
|
2
2
|
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
|
4
|
-
|
5
|
-
require
|
6
|
-
|
4
|
+
ENV['RAILS_ENV'] = 'test'
|
5
|
+
require "dummy/config/environment"
|
6
|
+
|
7
|
+
require 'rspec/rails'
|
7
8
|
require 'webmock/rspec'
|
9
|
+
require 'wiselinks'
|
8
10
|
|
9
11
|
require 'coveralls'
|
10
12
|
Coveralls.wear!
|
11
13
|
|
12
|
-
ENV['RAILS_ENV'] = 'test'
|
13
|
-
require "dummy/config/environment"
|
14
|
-
|
15
14
|
require 'capybara/rspec'
|
16
15
|
require 'capybara/rails'
|
17
16
|
Capybara.app = Dummy::Application
|
18
17
|
|
19
18
|
require 'factory_girl'
|
20
|
-
FactoryGirl.find_definitions
|
19
|
+
FactoryGirl.find_definitions
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "helper"
|
2
|
+
|
3
|
+
describe 'Requests' do
|
4
|
+
context 'w/ trailing slash' do
|
5
|
+
it 'sets X-Wiselinks header field correctly' do
|
6
|
+
get('trailing-slash/', {}, {"X-Wiselinks" => 'template'})
|
7
|
+
response.headers['X-Wiselinks-Url'].last.should == '/'
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'w/out slash' do
|
12
|
+
it 'sets X-Wiselinks header field correctly' do
|
13
|
+
get('no-slash', {}, {"X-Wiselinks" => 'template'})
|
14
|
+
response.headers['X-Wiselinks-Url'].last.should_not == '/'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/wiselinks.gemspec
CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |gem|
|
|
33
33
|
gem.add_development_dependency 'faker'
|
34
34
|
gem.add_development_dependency 'capybara'
|
35
35
|
|
36
|
-
gem.add_development_dependency 'rails', '
|
36
|
+
gem.add_development_dependency 'rails', '~> 3.2.13'
|
37
37
|
gem.add_development_dependency 'coffee-rails'
|
38
38
|
|
39
39
|
gem.add_development_dependency 'closure-compiler'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wiselinks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2013-06-
|
15
|
+
date: 2013-06-27 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rspec
|
@@ -227,17 +227,17 @@ dependencies:
|
|
227
227
|
requirement: !ruby/object:Gem::Requirement
|
228
228
|
none: false
|
229
229
|
requirements:
|
230
|
-
- -
|
230
|
+
- - ~>
|
231
231
|
- !ruby/object:Gem::Version
|
232
|
-
version: 3.2.
|
232
|
+
version: 3.2.13
|
233
233
|
type: :development
|
234
234
|
prerelease: false
|
235
235
|
version_requirements: !ruby/object:Gem::Requirement
|
236
236
|
none: false
|
237
237
|
requirements:
|
238
|
-
- -
|
238
|
+
- - ~>
|
239
239
|
- !ruby/object:Gem::Version
|
240
|
-
version: 3.2.
|
240
|
+
version: 3.2.13
|
241
241
|
- !ruby/object:Gem::Dependency
|
242
242
|
name: coffee-rails
|
243
243
|
requirement: !ruby/object:Gem::Requirement
|
@@ -302,9 +302,9 @@ files:
|
|
302
302
|
- README.md
|
303
303
|
- Rakefile
|
304
304
|
- app/views/layouts/wiselinks.html.erb
|
305
|
-
- build/wiselinks-0.
|
306
|
-
- build/wiselinks-0.
|
307
|
-
- build/wiselinks-0.
|
305
|
+
- build/wiselinks-0.7.0.js
|
306
|
+
- build/wiselinks-0.7.0.min.js
|
307
|
+
- build/wiselinks-0.7.0.min.js.gz
|
308
308
|
- compiler.jar
|
309
309
|
- lib/assets/javascripts/_form.js.coffee
|
310
310
|
- lib/assets/javascripts/_link.js.coffee
|
@@ -335,6 +335,8 @@ files:
|
|
335
335
|
- spec/dummy/app/mailers/.gitkeep
|
336
336
|
- spec/dummy/app/models/.gitkeep
|
337
337
|
- spec/dummy/app/views/application/index.html.erb
|
338
|
+
- spec/dummy/app/views/application/no_slash.html.erb
|
339
|
+
- spec/dummy/app/views/application/trailing_slash.html.erb
|
338
340
|
- spec/dummy/app/views/layouts/application.html.erb
|
339
341
|
- spec/dummy/config.ru
|
340
342
|
- spec/dummy/config/application.rb
|
@@ -355,7 +357,6 @@ files:
|
|
355
357
|
- spec/dummy/lib/assets/.gitkeep
|
356
358
|
- spec/dummy/log/.gitkeep
|
357
359
|
- spec/dummy/log/development.log
|
358
|
-
- spec/dummy/log/test.log
|
359
360
|
- spec/dummy/public/404.html
|
360
361
|
- spec/dummy/public/422.html
|
361
362
|
- spec/dummy/public/500.html
|
@@ -388,6 +389,7 @@ files:
|
|
388
389
|
- spec/dummy/tmp/cache/assets/E11/4E0/sprockets%2F86e145a39f85cceeaffdff91ebb61449
|
389
390
|
- spec/factories/requests.rb
|
390
391
|
- spec/helper.rb
|
392
|
+
- spec/requests/trailing_slash_spec.rb
|
391
393
|
- wiselinks.gemspec
|
392
394
|
homepage: http://github.com/igor-alexandrov/wiselinks
|
393
395
|
licenses:
|
@@ -404,7 +406,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
404
406
|
version: '0'
|
405
407
|
segments:
|
406
408
|
- 0
|
407
|
-
hash:
|
409
|
+
hash: 2776055283966944450
|
408
410
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
409
411
|
none: false
|
410
412
|
requirements:
|
@@ -413,7 +415,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
413
415
|
version: '0'
|
414
416
|
segments:
|
415
417
|
- 0
|
416
|
-
hash:
|
418
|
+
hash: 2776055283966944450
|
417
419
|
requirements: []
|
418
420
|
rubyforge_project:
|
419
421
|
rubygems_version: 1.8.24
|
@@ -433,6 +435,8 @@ test_files:
|
|
433
435
|
- spec/dummy/app/mailers/.gitkeep
|
434
436
|
- spec/dummy/app/models/.gitkeep
|
435
437
|
- spec/dummy/app/views/application/index.html.erb
|
438
|
+
- spec/dummy/app/views/application/no_slash.html.erb
|
439
|
+
- spec/dummy/app/views/application/trailing_slash.html.erb
|
436
440
|
- spec/dummy/app/views/layouts/application.html.erb
|
437
441
|
- spec/dummy/config.ru
|
438
442
|
- spec/dummy/config/application.rb
|
@@ -453,7 +457,6 @@ test_files:
|
|
453
457
|
- spec/dummy/lib/assets/.gitkeep
|
454
458
|
- spec/dummy/log/.gitkeep
|
455
459
|
- spec/dummy/log/development.log
|
456
|
-
- spec/dummy/log/test.log
|
457
460
|
- spec/dummy/public/404.html
|
458
461
|
- spec/dummy/public/422.html
|
459
462
|
- spec/dummy/public/500.html
|
@@ -486,3 +489,4 @@ test_files:
|
|
486
489
|
- spec/dummy/tmp/cache/assets/E11/4E0/sprockets%2F86e145a39f85cceeaffdff91ebb61449
|
487
490
|
- spec/factories/requests.rb
|
488
491
|
- spec/helper.rb
|
492
|
+
- spec/requests/trailing_slash_spec.rb
|
Binary file
|