wiselinks 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,31 +1,31 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- actionmailer (3.2.11)
5
- actionpack (= 3.2.11)
4
+ actionmailer (3.2.12)
5
+ actionpack (= 3.2.12)
6
6
  mail (~> 2.4.4)
7
- actionpack (3.2.11)
8
- activemodel (= 3.2.11)
9
- activesupport (= 3.2.11)
7
+ actionpack (3.2.12)
8
+ activemodel (= 3.2.12)
9
+ activesupport (= 3.2.12)
10
10
  builder (~> 3.0.0)
11
11
  erubis (~> 2.7.0)
12
12
  journey (~> 1.0.4)
13
- rack (~> 1.4.0)
13
+ rack (~> 1.4.5)
14
14
  rack-cache (~> 1.2)
15
15
  rack-test (~> 0.6.1)
16
16
  sprockets (~> 2.2.1)
17
- activemodel (3.2.11)
18
- activesupport (= 3.2.11)
17
+ activemodel (3.2.12)
18
+ activesupport (= 3.2.12)
19
19
  builder (~> 3.0.0)
20
- activerecord (3.2.11)
21
- activemodel (= 3.2.11)
22
- activesupport (= 3.2.11)
20
+ activerecord (3.2.12)
21
+ activemodel (= 3.2.12)
22
+ activesupport (= 3.2.12)
23
23
  arel (~> 3.0.2)
24
24
  tzinfo (~> 0.3.29)
25
- activeresource (3.2.11)
26
- activemodel (= 3.2.11)
27
- activesupport (= 3.2.11)
28
- activesupport (3.2.11)
25
+ activeresource (3.2.12)
26
+ activemodel (= 3.2.12)
27
+ activesupport (= 3.2.12)
28
+ activesupport (3.2.12)
29
29
  i18n (~> 0.6)
30
30
  multi_json (~> 1.0)
31
31
  arel (3.0.2)
@@ -39,8 +39,8 @@ GEM
39
39
  rack-test (>= 0.5.4)
40
40
  selenium-webdriver (~> 2.0)
41
41
  xpath (~> 1.0.0)
42
- childprocess (0.3.7)
43
- ffi (~> 1.0, >= 1.0.6)
42
+ childprocess (0.3.8)
43
+ ffi (~> 1.0, >= 1.0.11)
44
44
  coffee-rails (3.2.2)
45
45
  coffee-script (>= 2.2.0)
46
46
  railties (~> 3.2.0)
@@ -56,7 +56,7 @@ GEM
56
56
  activesupport (>= 3.0.0)
57
57
  faker (1.1.2)
58
58
  i18n (~> 0.5)
59
- ffi (1.3.1)
59
+ ffi (1.4.0)
60
60
  git (1.2.5)
61
61
  hike (1.2.1)
62
62
  i18n (0.6.1)
@@ -66,42 +66,42 @@ GEM
66
66
  rake
67
67
  rdoc
68
68
  journey (1.0.4)
69
- json (1.7.6)
69
+ json (1.7.7)
70
70
  mail (2.4.4)
71
71
  i18n (>= 0.4.0)
72
72
  mime-types (~> 1.16)
73
73
  treetop (~> 1.4.8)
74
74
  metaclass (0.0.1)
75
- mime-types (1.19)
75
+ mime-types (1.21)
76
76
  mocha (0.10.5)
77
77
  metaclass (~> 0.0.1)
78
- multi_json (1.5.0)
78
+ multi_json (1.6.1)
79
79
  nokogiri (1.5.6)
80
80
  polyglot (0.3.3)
81
- rack (1.4.4)
81
+ rack (1.4.5)
82
82
  rack-cache (1.2)
83
83
  rack (>= 0.4)
84
- rack-ssl (1.3.2)
84
+ rack-ssl (1.3.3)
85
85
  rack
86
86
  rack-test (0.6.2)
87
87
  rack (>= 1.0)
88
- rails (3.2.11)
89
- actionmailer (= 3.2.11)
90
- actionpack (= 3.2.11)
91
- activerecord (= 3.2.11)
92
- activeresource (= 3.2.11)
93
- activesupport (= 3.2.11)
88
+ rails (3.2.12)
89
+ actionmailer (= 3.2.12)
90
+ actionpack (= 3.2.12)
91
+ activerecord (= 3.2.12)
92
+ activeresource (= 3.2.12)
93
+ activesupport (= 3.2.12)
94
94
  bundler (~> 1.0)
95
- railties (= 3.2.11)
96
- railties (3.2.11)
97
- actionpack (= 3.2.11)
98
- activesupport (= 3.2.11)
95
+ railties (= 3.2.12)
96
+ railties (3.2.12)
97
+ actionpack (= 3.2.12)
98
+ activesupport (= 3.2.12)
99
99
  rack-ssl (~> 1.3.2)
100
100
  rake (>= 0.8.7)
101
101
  rdoc (~> 3.4)
102
102
  thor (>= 0.14.6, < 2.0)
103
103
  rake (10.0.3)
104
- rdoc (3.12)
104
+ rdoc (3.12.1)
105
105
  json (~> 1.4)
106
106
  rspec (2.12.0)
107
107
  rspec-core (~> 2.12.0)
@@ -119,7 +119,7 @@ GEM
119
119
  rspec-expectations (~> 2.12.0)
120
120
  rspec-mocks (~> 2.12.0)
121
121
  rubyzip (0.9.9)
122
- selenium-webdriver (2.29.0)
122
+ selenium-webdriver (2.30.0)
123
123
  childprocess (>= 0.2.5)
124
124
  multi_json (~> 1.0)
125
125
  rubyzip
data/README.md CHANGED
@@ -1,7 +1,10 @@
1
+ [![Gem Version](https://badge.fury.io/rb/wiselinks.png)](http://badge.fury.io/rb/wiselinks)
1
2
  [![Build Status](https://travis-ci.org/igor-alexandrov/wiselinks.png?branch=master)](https://travis-ci.org/igor-alexandrov/wiselinks)
2
- [![Dependency Status](https://gemnasium.com/igor-alexandrov/wiselinks.png)](https://gemnasium.com/igor-alexandrov/wiselinks)
3
3
  [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/igor-alexandrov/wiselinks)
4
4
 
5
+
6
+ [![Dependency Status](https://gemnasium.com/igor-alexandrov/wiselinks.png)](https://gemnasium.com/igor-alexandrov/wiselinks)
7
+
5
8
  #Wiselinks
6
9
 
7
10
  Wiselinks makes following links and submitting some forms in your web application faster.
@@ -10,6 +13,8 @@ You may find Wiselinks similar to [Turbolinks](https://github.com/rails/turbolin
10
13
 
11
14
  ## Compatibility
12
15
 
16
+ **Please be advised that Javascript events in wiselinks-0.5.0 are not backward compatible.**
17
+
13
18
  Wiselinks uses [History.js](https://github.com/balupton/History.js/) library to perform requests.
14
19
 
15
20
  Wiselinks works in all major browsers including browsers that do not support HTML History API out of the box.
@@ -62,6 +67,12 @@ Wiselinks works in all major browsers including browsers that do not support HTM
62
67
  <td>Yes, by parsing document head on every request</td>
63
68
  <td>No</td>
64
69
  </tr>
70
+ <tr>
71
+ <td>30x HTTP redirects processing</td>
72
+ <td><strong>Yes</strong></td>
73
+ <td>No</td>
74
+ <td>Yes</td>
75
+ </tr>
65
76
  </tbody>
66
77
  </table>
67
78
 
@@ -83,7 +94,7 @@ Restart your server and you're now using wiselinks!
83
94
 
84
95
  ### CoffeeScript
85
96
 
86
- Modify your `application.js.coffee` file to use Wiselinks object:
97
+ Create Wiselinks object in your `application.js.coffee`:
87
98
 
88
99
  ```coffeescript
89
100
  #= require jquery
@@ -112,45 +123,48 @@ Or you can add some more options, if you want:
112
123
  #= require wiselinks
113
124
 
114
125
  $(document).ready ->
115
- # DOM element with role = "content" will be replaced after data load.
116
- window.wiselinks = new Wiselinks($('@content'))
117
-
118
- # Of course you can use more traditional jQuery selectors.
119
- # window.wiselinks = new Wiselinks($('#content'))
120
- # window.wiselinks = new Wiselinks($('.content:first'))
121
-
126
+ # DOM element with id = "content" will be replaced after data load.
127
+ window.wiselinks = new Wiselinks($('#content'))
128
+
122
129
  $(document).off('page:loading').on(
123
130
  'page:loading'
124
- (event, url, target, render) ->
125
- console.log("Wiselinks loading: #{url} to #{target} within '#{render}'")
126
- # start loading animation
131
+ (event, $target, render, url) ->
132
+ console.log("Loading: #{url} to #{$target.selector} within '#{render}'")
133
+ # code to start loading animation
134
+ )
135
+
136
+ $(document).off('page:redirected').on(
137
+ 'page:redirected'
138
+ (event, $target, render, url) ->
139
+ console.log("Redirected to: #{url}")
140
+ # code to start loading animation
127
141
  )
128
142
 
129
- $(document).off('page:complete').on(
130
- 'page:complete'
143
+ $(document).off('page:always').on(
144
+ 'page:always'
131
145
  (event, xhr, settings) ->
132
146
  console.log("Wiselinks page loading completed")
133
- # stop loading animation
147
+ # code to stop loading animation
134
148
  )
135
149
 
136
- $(document).off('page:success').on(
137
- 'page:success'
138
- (event, $target, status) ->
150
+ $(document).off('page:done').on(
151
+ 'page:done'
152
+ (event, $target, status, url, data) ->
139
153
  console.log("Wiselinks status: '#{status}'")
140
154
  )
141
155
 
142
- $(document).off('page:error').on(
143
- 'page:error'
144
- (event, data, status) ->
156
+ $(document).off('page:fail').on(
157
+ 'page:fail'
158
+ (event, $target, status, url, error) ->
145
159
  console.log("Wiselinks status: '#{status}'")
146
- # show error message
160
+ # code to show error message
147
161
  )
148
162
  ```
149
163
 
150
- ### HTML templates
164
+ ### HTML
151
165
 
152
- Links with `data-push` attribute will fire History.pushState() event.
153
- Data from the request will replace content of the container that was passed to Wiselinks (default is "body")
166
+ Click on links with `data-push` attribute will fire History.pushState() event.
167
+ Data from the request will replace content of the container that was passed to Wiselinks (default is `$('body')`)
154
168
 
155
169
 
156
170
  ```html
@@ -164,7 +178,7 @@ Data from the request will replace content of the container that was passed to W
164
178
  </ul>
165
179
  ```
166
180
 
167
- Link will fire History.replaceState() event.
181
+ Click on links with `data-replace` will fire History.replaceState() event.
168
182
  Data from the request will replace content of the container that was passed to Wiselinks (default is "body")
169
183
 
170
184
  ```html
@@ -173,8 +187,8 @@ Data from the request will replace content of the container that was passed to W
173
187
  </div>
174
188
  ```
175
189
 
176
- Links will fire History.pushState() event.
177
- Data from the request will be pasted into `<div role="catalog">`. This configuration is widely when you have list of items that are paginated, sorted or maybe grouped by some attributes and you want to update only these items and nothing more on page.
190
+ Click on following links will fire History.pushState() event.
191
+ Data from the request will be pasted into `<div id="catalog">`. This configuration is widely when you have list of items that are paginated, sorted or maybe grouped by some attributes and you want to update only these items and nothing more on page.
178
192
 
179
193
  ```html
180
194
  <ul class="pagination">
@@ -182,31 +196,34 @@ Data from the request will be pasted into `<div role="catalog">`. This configura
182
196
  <span>1</span>
183
197
  </li>
184
198
  <li>
185
- <a href="/?page=2" data-push="true" data-target="@catalog">2</a>
199
+ <a href="/?page=2" data-push="true" data-target="#catalog">2</a>
186
200
  </li>
187
201
  <li>
188
- <a href="/?page=3" data-push="true" data-target="@catalog">3</a>
202
+ <a href="/?page=3" data-push="true" data-target="#catalog">3</a>
189
203
  </li>
190
204
  <li>
191
- <a href="/?page=4" data-push="true" data-target="@catalog">4</a>
205
+ <a href="/?page=4" data-push="true" data-target="#catalog">4</a>
192
206
  </li>
193
207
  </ul>
208
+
194
209
  <ul class="sort">
195
210
  <li>
196
- <a href="/?sort=title" data-push="true" data-target="@catalog">Sort by Title</a>
211
+ <a href="/?sort=title" data-push="true" data-target="#catalog">Sort by Title</a>
197
212
  </li>
198
213
  <li>
199
- <a href="/?sort=price" data-push="true" data-target="@catalog">Sort by Price</a>
214
+ <a href="/?sort=price" data-push="true" data-target="#catalog">Sort by Price</a>
200
215
  </li>
201
216
  </ul>
202
217
 
203
- <div role="catalog">
218
+ <div id="catalog">
204
219
  <!-- the list of your items -->
205
220
  ...
206
221
  </div>
207
222
  ```
208
223
 
209
- **You can use Wiselinks with forms**! As easy and clear as with links. After submit button is clicked, Wiselinks will perform a request to "/" with serialized form attributes. The result of this request will be pasted into `<div role="catalog">`.
224
+ **Form processing**
225
+
226
+ 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.
210
227
 
211
228
  ```html
212
229
  <div class="filter">
@@ -239,30 +256,58 @@ The idea of Wiselinks is that you should render only content that you need in cu
239
256
 
240
257
  While using Wiselinks you **can rely** on `DOMContentLoaded` or `jQuery.ready()` to trigger your JavaScript code, but Wiselinks gives you some additional useful event to deal with the lifecycle of the page:
241
258
 
242
- **page:loading (url, target, render = 'template')**
259
+ **page:loading ($target, render, url)**
243
260
 
244
261
  Event is triggered before the `XMLHttpRequest` is initialised and performed.
262
+ * *$target* – JQuery object in which result of the request will be inserted;
263
+
245
264
  * *url* - URL of the request that will be performed;
246
265
 
247
- * *target* – element of the page where result of the request will be loaded into;
266
+ * *render* – what should be rendered; can be 'template' or 'partial';
248
267
 
249
- * *render = 'template'* – what should be rendered; can be 'template' or 'partial';
268
+ **page:redirected ($target, render, url)**
250
269
 
251
- **page:success ($target, status)**
270
+ Event is triggered when you were redirected during `XMLHttpRequest` (with HTTP 30x status).
271
+ * *$target* – jQuery object in which result of the request will be inserted;
272
+
273
+ * *url* - URL where you have been redirected to;
274
+
275
+ * *render* – what should be rendered; can be 'template' or 'partial';
276
+
277
+ **page:done ($target, status, url, data)**
252
278
 
253
279
  Event is triggered if the request succeeds.
254
- * *$target* – JQuery object that was updated by request;
280
+ * *$target* – jQuery object that was updated with the request;
255
281
 
256
282
  * *status* – a string describing the status;
257
283
 
258
- **page:error (status, error)**
284
+ * *url* – url of the request;
285
+
286
+ * *data* – content of the request;
287
+
288
+ **page:fail ($target, status, url, error)**
259
289
 
260
290
  Event is triggered if the request fails.
261
291
 
262
- * *status*a string describing the type of error that occurred;
263
- * *error* – optional exception object, if one occurred;
292
+ * *$target* – jQuery object that had to be updated with the request;
293
+
294
+ * *status* – a string describing the status;
295
+
296
+ * *url* – url of the request;
297
+
298
+ * *error* – a string describing the type of error that occurred;
264
299
 
265
- So if you wanted to have a client-side spinner, you could listen for `page:loading` to start it and `page:success` or `page:error` to stop it.
300
+ **page:always ($target, status, url)**
301
+
302
+ Event is triggered after each request.
303
+
304
+ * *$target* – jQuery object that had to be updated with the request;
305
+
306
+ * *status* – a string describing the status;
307
+
308
+ * *url* – url of the request;
309
+
310
+ So if you want to show a client-side loading spinner, you could listen for `page:loading` to start it and `page:always` to stop it.
266
311
 
267
312
  ### ActionDispatch::Request extensions
268
313
 
@@ -295,7 +340,7 @@ Now Wiselinks will track changes of your assets and if anything will change, you
295
340
 
296
341
  ### Title handling
297
342
 
298
- Wiselinks handles page titles by passing `X-Title` header with response. To do this you can use `wiselinks_title` helper.
343
+ Wiselinks handles page titles by passing `X-Wiselinks-Title` header with response. To set this header you can use `wiselinks_title` helper (in Rails).
299
344
 
300
345
  ```html
301
346
  <% wiselinks_title("Wiselinks is awesome") %>
@@ -308,18 +353,22 @@ Wiselinks handles page titles by passing `X-Title` header with response. To do t
308
353
 
309
354
  Of course you can use `wiselinks_title` helper in your own helpers too.
310
355
 
356
+ ### Redirect handling
357
+
358
+ Wiselinks follows 30x HTTP redirects. Location is updated in browser with `X-Wiselinks-Url` header that is setting up automatically (in Rails) on every wiselinks request.
359
+
311
360
  ### Google Analytics and Yandex Metrika
312
361
 
313
- If you want to handle these analytics tools, then you should add handler to `page:success` event.
362
+ If you want to handle these analytics tools, then you should add handler to `page:done` event.
314
363
 
315
364
  Let's say, that you have two objects, first is `_gaq` – instance of Google Analytics, second is `_metrika` – instance of Yandex Metrika. Then you have to add the following code somewhere in your `application.js.coffee`.
316
365
 
317
366
  ```coffeescript
318
- $(document).off('page:success').on(
319
- 'page:success'
320
- (event, data, status) ->
321
- _gaq.push(['_trackPageview', location.pathname])
322
- _metrika.hit(location.pathname)
367
+ $(document).off('page:done').on(
368
+ 'page:done'
369
+ (event, $target, status, url, data) ->
370
+ _gaq.push(['_trackPageview', url])
371
+ _metrika.hit(url)
323
372
  )
324
373
  ```
325
374
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.5.0
@@ -71,29 +71,40 @@ class Wiselinks
71
71
 
72
72
  $target = if target? then $(target) else self.$target
73
73
 
74
- $document = $(document).trigger('page:loading', [url, $target.selector, render])
75
-
74
+ $document = $(document).trigger('page:loading', [$target, render, url])
75
+
76
76
  $.ajax(
77
77
  url: url
78
78
  headers:
79
- 'X-Render': render
80
- complete: (xhr, status) ->
81
- $document.trigger('page:complete', [xhr, status])
82
- success: (data, status, xhr) ->
83
- if self._assets_changed(xhr.getResponseHeader('X-Assets-Digest'))
79
+ 'X-Wiselinks': render
80
+
81
+ dataType: "html"
82
+ ).done(
83
+ (data, status, xhr) ->
84
+ url = xhr.getResponseHeader('X-Wiselinks-Url')
85
+
86
+ if self._assets_changed(xhr.getResponseHeader('X-Wiselinks-Assets-Digest'))
84
87
  window.location.reload(true)
88
+ else if url? && url != window.location.href
89
+ $document.trigger('page:redirected', [$target, render, url])
90
+ if ( xhr && xhr.readyState < 4)
91
+ xhr.onreadystatechange = $.noop
92
+ xhr.abort()
93
+ History.replaceState(History.getState().data, document.title, url )
85
94
  else
86
95
  self._set_title(xhr)
87
96
 
88
97
  $target.html(data)
89
98
 
90
- $document.trigger('page:success', [$target, status])
91
- error: (xhr, status, error)->
92
- $document.trigger('page:error', [status, error])
93
-
94
- dataType: "html"
99
+ $document.trigger('page:done', [$target, status, url, data])
100
+ ).fail(
101
+ (xhr, status, error) ->
102
+ $document.trigger('page:fail', [$target, status, url, error])
103
+ ).always(
104
+ (data_or_xhr, status, xhr_or_error)->
105
+ $document.trigger('page:always', [$target, status, url])
95
106
  )
96
-
107
+
97
108
  _process_form: ($form) ->
98
109
  self = this
99
110
 
@@ -147,7 +158,7 @@ class Wiselinks
147
158
  @assets_digest? && @assets_digest != digest
148
159
 
149
160
  _set_title: (xhr) ->
150
- value = xhr.getResponseHeader('X-Title')
161
+ value = xhr.getResponseHeader('X-Wiselinks-Title')
151
162
  document.title = decodeURI(value) if value?
152
163
 
153
164
  window.Wiselinks = Wiselinks
@@ -0,0 +1,27 @@
1
+ module Wiselinks
2
+ module ControllerMethods
3
+
4
+ def self.included(base)
5
+ base.helper_method :wiselinks_title
6
+
7
+ base.before_filter :set_wiselinks_url
8
+ end
9
+
10
+ protected
11
+
12
+ def wiselinks_layout
13
+ 'wiselinks'
14
+ end
15
+
16
+ def wiselinks_title(value)
17
+ if self.request.wiselinks? && value.present?
18
+ Wiselinks.log("title: #{value}")
19
+ self.response.headers['X-Wiselinks-Title'] = URI.encode(value)
20
+ end
21
+ end
22
+
23
+ def set_wiselinks_url
24
+ self.response.headers['X-Wiselinks-Url'] = request.url if self.request.wiselinks?
25
+ end
26
+ end
27
+ end
@@ -5,7 +5,7 @@ module Wiselinks
5
5
  end
6
6
 
7
7
  def log(message)
8
- self.logger.info("[wiselinks] #{message}")
8
+ self.logger.info(" [wiselinks] #{message}")
9
9
  end
10
10
  end
11
11
  end
@@ -7,7 +7,8 @@ module Wiselinks
7
7
 
8
8
  initializer "wiselinks.register_extensions" do
9
9
  ActionDispatch::Request.send :include, Request
10
- ActionController::Base.send :include, Headers
10
+ ActionController::Base.send :include, ControllerMethods
11
+ ActionController::Base.send :include, Rendering
11
12
  ActionView::Base.send :include, Helpers
12
13
  end
13
14
 
@@ -0,0 +1,35 @@
1
+ module Wiselinks
2
+ module Rendering
3
+
4
+ def self.included(base)
5
+ base.alias_method_chain :render, :wiselinks
6
+ end
7
+
8
+ protected
9
+
10
+ def render_with_wiselinks(options = {}, *args, &block)
11
+ if self.request.wiselinks?
12
+ self.headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
13
+ self.headers['Pragma'] = 'no-cache'
14
+
15
+ if self.request.wiselinks_partial?
16
+ Wiselinks.log("Processing partial request")
17
+ options[:partial] ||= action_name
18
+ else
19
+ Wiselinks.log("Processing template request")
20
+ if Wiselinks.options[:layout] != false
21
+ options[:layout] = self.wiselinks_layout
22
+ end
23
+ end
24
+
25
+ if Wiselinks.options[:assets_digest].present?
26
+ Wiselinks.log("Assets digest #{Wiselinks.options[:assets_digest]}")
27
+
28
+ self.headers['X-Wiselinks-Assets-Digest'] = Wiselinks.options[:assets_digest]
29
+ end
30
+ end
31
+
32
+ self.render_without_wiselinks(options, args, &block)
33
+ end
34
+ end
35
+ end
@@ -1,15 +1,15 @@
1
1
  module Wiselinks
2
2
  module Request
3
3
  def wiselinks?
4
- self.headers['X-Render'].present?
4
+ self.headers['X-Wiselinks'].present?
5
5
  end
6
6
 
7
7
  def wiselinks_template?
8
- self.wiselinks? && self.headers['X-Render'] != 'partial'
8
+ self.wiselinks? && self.headers['X-Wiselinks'] != 'partial'
9
9
  end
10
10
 
11
11
  def wiselinks_partial?
12
- self.wiselinks? && self.headers['X-Render'] == 'partial'
12
+ self.wiselinks? && self.headers['X-Wiselinks'] == 'partial'
13
13
  end
14
14
  end
15
15
  end
data/lib/wiselinks.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  require 'wiselinks/request'
2
- require 'wiselinks/headers'
2
+
3
+ require 'wiselinks/controller_methods'
4
+ require 'wiselinks/rendering'
5
+
3
6
  require 'wiselinks/helpers'
4
7
 
5
8
  require 'wiselinks/logger'
data/wiselinks.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "wiselinks"
8
- s.version = "0.4.2"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Igor Alexandrov", "Alexey Solilin", "Julia Egorova"]
12
- s.date = "2013-02-10"
12
+ s.date = "2013-02-22"
13
13
  s.email = "igor.alexandrov@gmail.com"
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -31,10 +31,11 @@ Gem::Specification.new do |s|
31
31
  "lib/assets/javascripts/_json2.js",
32
32
  "lib/assets/javascripts/wiselinks.js.coffee",
33
33
  "lib/wiselinks.rb",
34
- "lib/wiselinks/headers.rb",
34
+ "lib/wiselinks/controller_methods.rb",
35
35
  "lib/wiselinks/helpers.rb",
36
36
  "lib/wiselinks/logger.rb",
37
37
  "lib/wiselinks/rails.rb",
38
+ "lib/wiselinks/rendering.rb",
38
39
  "lib/wiselinks/request.rb",
39
40
  "spec/cases/helpers_spec.rb",
40
41
  "spec/cases/request_spec.rb",
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.2
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2013-02-10 00:00:00.000000000 Z
14
+ date: 2013-02-22 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: shoulda
@@ -100,10 +100,11 @@ files:
100
100
  - lib/assets/javascripts/_json2.js
101
101
  - lib/assets/javascripts/wiselinks.js.coffee
102
102
  - lib/wiselinks.rb
103
- - lib/wiselinks/headers.rb
103
+ - lib/wiselinks/controller_methods.rb
104
104
  - lib/wiselinks/helpers.rb
105
105
  - lib/wiselinks/logger.rb
106
106
  - lib/wiselinks/rails.rb
107
+ - lib/wiselinks/rendering.rb
107
108
  - lib/wiselinks/request.rb
108
109
  - spec/cases/helpers_spec.rb
109
110
  - spec/cases/request_spec.rb
@@ -186,7 +187,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
186
187
  version: '0'
187
188
  segments:
188
189
  - 0
189
- hash: -4012645802697447930
190
+ hash: -4377294623170466604
190
191
  required_rubygems_version: !ruby/object:Gem::Requirement
191
192
  none: false
192
193
  requirements:
@@ -1,65 +0,0 @@
1
- module Wiselinks
2
- module Headers
3
-
4
- def self.included(base)
5
- base.helper_method :wiselinks_title
6
- end
7
-
8
- protected
9
-
10
- def wiselinks_layout
11
- 'wiselinks'
12
- end
13
-
14
- def render(options = {}, *args, &block)
15
- if self.request.wiselinks?
16
- self.headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
17
- self.headers['Pragma'] = 'no-cache'
18
-
19
- if self.request.wiselinks_partial?
20
- Wiselinks.log("processing partial request")
21
- options[:partial] ||= action_name
22
- else
23
- Wiselinks.log("processing template request")
24
-
25
- if Wiselinks.options[:layout] != false
26
- options[:layout] = self.wiselinks_layout
27
- end
28
- end
29
-
30
- if Wiselinks.options[:assets_digest].present?
31
- Wiselinks.log("assets digest #{Wiselinks.options[:assets_digest]}")
32
-
33
- self.headers['X-Assets-Digest'] = Wiselinks.options[:assets_digest]
34
- end
35
- end
36
-
37
- super
38
- end
39
-
40
- def wiselinks_title(value)
41
- if self.request.wiselinks? && value.present?
42
- Wiselinks.log("title: #{value}")
43
- response.headers['X-Title'] = URI.encode(value)
44
- end
45
- end
46
-
47
- def wiselinks_request?
48
- Wiselinks::Logger.log "DEPRECATION WARNING: Method `wiselinks_request?` is deprecated. Please use `request.wiselinks?` instead."
49
-
50
- self.request.wiselinks?
51
- end
52
-
53
- def wiselinks_template_request?
54
- Wiselinks::Logger.log "DEPRECATION WARNING: Method `wiselinks_template_request?` is deprecated. Please use `request.wiselinks_template?` instead."
55
-
56
- self.request.wiselinks_template?
57
- end
58
-
59
- def wiselinks_partial_request?
60
- Wiselinks::Logger.log "DEPRECATION WARNING: Method `wiselinks_partial_request?` is deprecated. Please use `request.wiselinks_partial?` instead."
61
-
62
- self.request.wiselinks_partial?
63
- end
64
- end
65
- end