inesita 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/inesita.gemspec +1 -1
- data/lib/inesita/cli/template/app/components/layout.rb +3 -1
- data/lib/inesita/cli/template/app/components/welcome.rb +1 -0
- data/opal/inesita/application.rb +5 -3
- data/opal/inesita/component.rb +21 -9
- data/opal/inesita/layout.rb +7 -3
- data/opal/inesita/router.rb +5 -4
- data/opal/virtual_dom_extension.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e1ab35a96ca0e0be0d5e6b5f673c0d4d4d41aa2
|
4
|
+
data.tar.gz: e6631eb22bf44f14f912cd424deb9bea2b6b1db0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 012401b46fcb01f87440465e4ee08ae6de69d4fb4a481a467b1373b9d5a2b7344d4c25c0cf1dc2c3a620f612e05bd7d2531a17a399f78447e2297478035591d5
|
7
|
+
data.tar.gz: 542547268bc1bf4eca309993a3c60fd01bc0ce95e0c9e8891bb5027b4dc1d23adac1aaeefb4af5607369b5a88e435b006ba7ff936114bc18cf5698113ade6db3
|
data/inesita.gemspec
CHANGED
data/opal/inesita/application.rb
CHANGED
@@ -2,7 +2,7 @@ module Inesita
|
|
2
2
|
class Application
|
3
3
|
include Inesita::Component
|
4
4
|
|
5
|
-
|
5
|
+
components :parent
|
6
6
|
|
7
7
|
def initialize(options)
|
8
8
|
raise 'Routes missing' unless options[:routes]
|
@@ -10,11 +10,13 @@ module Inesita
|
|
10
10
|
@router = Router.new(options[:routes])
|
11
11
|
@layout = options[:layout]
|
12
12
|
|
13
|
-
|
13
|
+
@parent = @layout ? @layout.create(@router) : @router
|
14
14
|
end
|
15
15
|
|
16
16
|
def render
|
17
|
-
|
17
|
+
dom do
|
18
|
+
component parent
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
data/opal/inesita/component.rb
CHANGED
@@ -2,19 +2,24 @@ module Inesita
|
|
2
2
|
module Component
|
3
3
|
include VirtualDOM
|
4
4
|
|
5
|
-
def
|
5
|
+
def with_parent(component)
|
6
6
|
@parent = component
|
7
|
+
self
|
8
|
+
end
|
9
|
+
|
10
|
+
def dom(&block)
|
11
|
+
NodeFactory.new(block, self).nodes.first
|
7
12
|
end
|
8
13
|
|
9
14
|
def mount(element)
|
10
|
-
@virtual_dom =
|
15
|
+
@virtual_dom = render
|
11
16
|
@mount_point = VirtualDOM.create(@virtual_dom)
|
12
17
|
element.inner_dom = @mount_point
|
13
18
|
end
|
14
19
|
|
15
20
|
def update
|
16
21
|
if @virtual_dom && @mount_point
|
17
|
-
new_virtual_dom =
|
22
|
+
new_virtual_dom = render
|
18
23
|
diff = VirtualDOM.diff(@virtual_dom, new_virtual_dom)
|
19
24
|
VirtualDOM.patch(@mount_point, diff)
|
20
25
|
@virtual_dom = new_virtual_dom
|
@@ -27,13 +32,20 @@ module Inesita
|
|
27
32
|
`document.location.pathname`
|
28
33
|
end
|
29
34
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
+
def self.included(base)
|
36
|
+
base.extend(ClassMethods)
|
37
|
+
end
|
38
|
+
|
39
|
+
module ClassMethods
|
40
|
+
def components(*attrs)
|
41
|
+
attrs.flatten.each do |component|
|
42
|
+
if VirtualDOM::NodeFactory::HTML_TAGS.include?(component)
|
43
|
+
fail "Forbidden component name '#{component}' in #{self} component"
|
44
|
+
else
|
45
|
+
attr_reader component
|
46
|
+
end
|
35
47
|
end
|
36
|
-
|
48
|
+
attr_reader *attrs.flatten
|
37
49
|
end
|
38
50
|
end
|
39
51
|
end
|
data/opal/inesita/layout.rb
CHANGED
@@ -3,13 +3,17 @@ module Inesita
|
|
3
3
|
def self.included(base)
|
4
4
|
base.include(Component)
|
5
5
|
base.extend(ClassMethods)
|
6
|
+
base.components :outlet
|
7
|
+
end
|
8
|
+
|
9
|
+
def with_outlet(outlet)
|
10
|
+
@outlet = outlet
|
11
|
+
self
|
6
12
|
end
|
7
13
|
|
8
14
|
module ClassMethods
|
9
15
|
def create(outlet)
|
10
|
-
new.
|
11
|
-
l.component :outlet, outlet
|
12
|
-
end
|
16
|
+
new.with_outlet(outlet)
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
data/opal/inesita/router.rb
CHANGED
@@ -2,23 +2,24 @@ module Inesita
|
|
2
2
|
class Router
|
3
3
|
include Inesita::Component
|
4
4
|
class << self; attr_accessor :handle_browser_history; end
|
5
|
-
|
5
|
+
|
6
|
+
components :routes
|
6
7
|
|
7
8
|
def initialize(routes)
|
8
9
|
default_component = routes.values.first.new
|
9
|
-
default_component.parent(self)
|
10
10
|
|
11
11
|
@routes = Hash.new(default_component)
|
12
12
|
routes.map do |route, component|
|
13
13
|
@routes[route] = component.new
|
14
|
-
@routes[route].parent(self)
|
15
14
|
end
|
16
15
|
|
17
16
|
handle_browser_history
|
18
17
|
end
|
19
18
|
|
20
19
|
def render
|
21
|
-
|
20
|
+
dom do
|
21
|
+
component routes[url]
|
22
|
+
end
|
22
23
|
end
|
23
24
|
|
24
25
|
def handle_browser_history
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module VirtualDOM
|
2
2
|
class NodeFactory
|
3
3
|
def component(comp)
|
4
|
-
|
4
|
+
fail "Component is nil in #{@parent.class} class" if comp.nil?
|
5
|
+
@nodes << comp.with_parent(@parent).render
|
5
6
|
end
|
6
7
|
|
7
8
|
def a(params, &block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inesita
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michał Kalbarczyk
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|