volt 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +35 -10
- data/VERSION +1 -1
- data/app/volt/controllers/notices_controller.rb +4 -0
- data/app/volt/views/notices/index.html +4 -2
- data/lib/volt/models.rb +1 -0
- data/lib/volt/models/array_model.rb +1 -1
- data/lib/volt/models/model.rb +1 -1
- data/lib/volt/models/persistors/base.rb +1 -1
- data/lib/volt/models/persistors/flash.rb +32 -0
- data/lib/volt/page/page.rb +22 -1
- data/lib/volt/page/tasks.rb +9 -0
- data/spec/models/persistors/store_spec.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2390fa6b2d27296a6a761e1bbf575bd07cebc42d
|
4
|
+
data.tar.gz: a9520a04804d30eca3619a436918e81987eb7b41
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66c6eea2b57285e84f61480db89912df81dbcc82f204e36df68e1bd512a0d716249ee89bda9fab91900909d76e6d48daa4e218c47c77b93b43b3b987b47d6a6a
|
7
|
+
data.tar.gz: c59669709786b49c15976d09f9895d1d8952c08bfd6d7b3604fd6f364493ecea0ea5aa0bcf7ee270470c6424584785c122f050d2dd7e373f3c733b6a6396dfc1
|
data/Readme.md
CHANGED
@@ -69,14 +69,19 @@ You can access the volt console with:
|
|
69
69
|
3. [Each Binding](#each-binding)
|
70
70
|
4. [Attribute Bindings](#attribute-bindings)
|
71
71
|
2. [Models](#models)
|
72
|
-
1. [
|
73
|
-
2. [
|
74
|
-
3. [
|
75
|
-
|
72
|
+
1. [Provided Collections](#provided-collections)
|
73
|
+
2. [Reactive Models](#reactive-models)
|
74
|
+
3. [Model Events](#model-events)
|
75
|
+
4. [Automatic Model Conversion](#automatic-model-conversion)
|
76
|
+
3. [Controllers](#controllers)
|
77
|
+
4. [Components](#components)
|
76
78
|
1. [Assets](#assets)
|
77
79
|
2. [Component Generator](#component-generator)
|
78
|
-
|
79
|
-
|
80
|
+
3. [Provided Components](#provided-components)
|
81
|
+
1. [Notices](#notices)
|
82
|
+
2. [Flash](#flash)
|
83
|
+
5. [Controls](#controls)
|
84
|
+
6. [Routes](#routes)
|
80
85
|
1. [Routes file](#routes-file)
|
81
86
|
|
82
87
|
|
@@ -525,6 +530,30 @@ Once the gem is ready, you can release it to ruby gems with:
|
|
525
530
|
|
526
531
|
Remove the path: option in the gemfile if you wish to use the rubygems version.
|
527
532
|
|
533
|
+
## Provided Components
|
534
|
+
|
535
|
+
Volt provides a few components to make web developers lives easier.
|
536
|
+
|
537
|
+
### Notices
|
538
|
+
|
539
|
+
Volt automatically places ```<:volt:notices />``` into views. This shows notices for the following:
|
540
|
+
|
541
|
+
1. flash messages
|
542
|
+
2. connection status (when a disconnect happens, lets the user know why and when a reconnect will be attempted)
|
543
|
+
3. page reloading notices (in development)
|
544
|
+
|
545
|
+
### Flash
|
546
|
+
|
547
|
+
As part of the notices component explained above, you can append messages to any collection on the flash model.
|
548
|
+
|
549
|
+
Each collection represents a different type of "flash". Common examples are ```_notices, _warnings, and _errors``` Using different collections allows you to change how you want the flash displayed. For example, you might want ```_notices``` and ```_errors``` to show with different colors.
|
550
|
+
|
551
|
+
```ruby
|
552
|
+
flash._notices << "message to flash"
|
553
|
+
```
|
554
|
+
|
555
|
+
These messages will show for 5 seconds, then disappear (both from the screen and the collection).
|
556
|
+
|
528
557
|
# Controls
|
529
558
|
|
530
559
|
Everyone wishes that we could predict the scope and required features for each part of our application, but in the real world, things we don't expect to grow large often do and things we think will be large don't end up that way. Controls let you quickly setup reusable code/views. The location of the control's code can be moved as it grows without changing the way controls are invoked.
|
@@ -639,7 +668,3 @@ Controllers provide a .channel method, that you can use to get the status of the
|
|
639
668
|
| retry_count | the number of reconnection attempts that have been made without a successful connection |
|
640
669
|
| reconnect_interval | the time until the next reconnection attempt (in seconds) |
|
641
670
|
|
642
|
-
|
643
|
-
## Notices
|
644
|
-
|
645
|
-
Volt ships with a component that provies notices for things like dropped backend connections, flash messages, etc...
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.4
|
@@ -2,7 +2,7 @@
|
|
2
2
|
{#if page._reloading}
|
3
3
|
<div class="notices alert alert-info">Reloading...</div>
|
4
4
|
{/}
|
5
|
-
{#if
|
5
|
+
{#if channel.status == :reconnecting}
|
6
6
|
<div class="notices alert alert-info">
|
7
7
|
Connection Lost... {channel.error}...
|
8
8
|
{#if channel.reconnect_interval} Reconnecting in {(channel.reconnect_interval / 1000.0).round} sec{/}
|
@@ -10,7 +10,9 @@
|
|
10
10
|
{/}
|
11
11
|
{#if !flash.empty?}
|
12
12
|
<div class="notices alert alert-info">
|
13
|
-
|
13
|
+
{#each flash._notices as notice}
|
14
|
+
<p>{notice}</p>
|
15
|
+
{/}
|
14
16
|
</div>
|
15
17
|
{/}
|
16
18
|
</:body>
|
data/lib/volt/models.rb
CHANGED
data/lib/volt/models/model.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'volt/models/persistors/base'
|
2
|
+
|
3
|
+
module Persistors
|
4
|
+
class Flash < Base
|
5
|
+
def initialize(model)
|
6
|
+
@model = model
|
7
|
+
end
|
8
|
+
|
9
|
+
def added(model, index)
|
10
|
+
if Volt.client?
|
11
|
+
# Setup a new timer for clearing the flash.
|
12
|
+
%x{
|
13
|
+
setTimeout(function() {
|
14
|
+
self.$clear_model(model);
|
15
|
+
}, 5000);
|
16
|
+
}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def clear_model(model)
|
21
|
+
@model.delete(model)
|
22
|
+
|
23
|
+
# Clear out the parent collection (usually the main flash)
|
24
|
+
# Makes it so flash.empty? reflects if there is any outstanding
|
25
|
+
# flashes.
|
26
|
+
if @model.size == 0
|
27
|
+
collection_name = @model.path[-1]
|
28
|
+
@model.parent.delete(collection_name)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/volt/page/page.rb
CHANGED
@@ -42,7 +42,7 @@ class Page
|
|
42
42
|
|
43
43
|
# Run the code to setup the page
|
44
44
|
@page = ReactiveValue.new(Model.new)
|
45
|
-
@flash = ReactiveValue.new(Model.new)
|
45
|
+
@flash = ReactiveValue.new(Model.new({}, persistor: Persistors::Flash))
|
46
46
|
@store = ReactiveValue.new(Model.new({}, persistor: Persistors::StoreFactory.new(tasks)))
|
47
47
|
|
48
48
|
@url = ReactiveValue.new(URL.new)
|
@@ -134,6 +134,8 @@ class Page
|
|
134
134
|
# Setup to render template
|
135
135
|
Element.find('body').html = "<!-- $CONTENT --><!-- $/CONTENT -->"
|
136
136
|
|
137
|
+
load_stored_page
|
138
|
+
|
137
139
|
# Do the initial url params parse
|
138
140
|
@url_tracker.url_updated(true)
|
139
141
|
|
@@ -150,6 +152,25 @@ class Page
|
|
150
152
|
end
|
151
153
|
TemplateRenderer.new(title_target, main_controller, "main", "home/index/index/title")
|
152
154
|
end
|
155
|
+
|
156
|
+
# When the page is reloaded from the backend, we store the $page.page, so we
|
157
|
+
# can reload the page in the exact same state. Speeds up development.
|
158
|
+
def load_stored_page
|
159
|
+
if Volt.client?
|
160
|
+
if `sessionStorage`
|
161
|
+
page_obj_str = nil
|
162
|
+
|
163
|
+
`page_obj_str = sessionStorage.getItem('___page');`
|
164
|
+
`if (page_obj_str) {`
|
165
|
+
`sessionStorage.removeItem('___page');`
|
166
|
+
|
167
|
+
JSON.parse(page_obj_str).each_pair do |key, value|
|
168
|
+
self.page.send(:"#{key}=", value)
|
169
|
+
end
|
170
|
+
`}`
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
153
174
|
end
|
154
175
|
|
155
176
|
if Volt.client?
|
data/lib/volt/page/tasks.rb
CHANGED
@@ -93,6 +93,15 @@ class Tasks
|
|
93
93
|
|
94
94
|
def reload
|
95
95
|
puts "RELOAD"
|
96
|
+
# Stash the current page value
|
97
|
+
value = JSON.dump($page.page.cur.to_h)
|
98
|
+
|
99
|
+
# If this browser supports session storage, store the page, so it will
|
100
|
+
# be in the same state when we reload.
|
101
|
+
if `sessionStorage`
|
102
|
+
`sessionStorage.setItem('___page', value);`
|
103
|
+
end
|
104
|
+
|
96
105
|
$page.page._reloading = true
|
97
106
|
`window.location.reload(false);`
|
98
107
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: volt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Stout
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01
|
11
|
+
date: 2014-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -326,6 +326,7 @@ files:
|
|
326
326
|
- app/volt/assets/js/jquery-2.0.3.js
|
327
327
|
- app/volt/assets/js/sockjs-0.2.1.min.js
|
328
328
|
- app/volt/config/dependencies.rb
|
329
|
+
- app/volt/controllers/notices_controller.rb
|
329
330
|
- app/volt/tasks/channel_tasks.rb
|
330
331
|
- app/volt/tasks/store_tasks.rb
|
331
332
|
- app/volt/views/notices/index.html
|
@@ -357,6 +358,7 @@ files:
|
|
357
358
|
- lib/volt/models/model_wrapper.rb
|
358
359
|
- lib/volt/models/persistors/array_store.rb
|
359
360
|
- lib/volt/models/persistors/base.rb
|
361
|
+
- lib/volt/models/persistors/flash.rb
|
360
362
|
- lib/volt/models/persistors/model_store.rb
|
361
363
|
- lib/volt/models/persistors/params.rb
|
362
364
|
- lib/volt/models/persistors/store.rb
|