inesita 0.0.6 → 0.0.7
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/application.js.rb +1 -2
- data/lib/inesita/cli/template/app/components/navbar.rb +8 -3
- data/lib/inesita/server.rb +1 -1
- data/opal/inesita/application.rb +1 -9
- data/opal/inesita/component.rb +4 -0
- data/opal/inesita/router.rb +5 -10
- 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: 586b44f53758981d474a33605fdca12c01fbb1ab
|
4
|
+
data.tar.gz: a7e71cd60cdbb4741b08ce77aac599dc14f996f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c514f42391b811439ef6144c1f9a46096d57208a4802f0e98d30e0d58d2763da443c1f28d218a19ec602737dd1676ed0791449ee9045d7ad5ff498dce2214ef4
|
7
|
+
data.tar.gz: e41e94a6d8c82f9601e6cead98b5f406396e8af47f6238027cd742eb9071ff146abbdb2aa54af1d86e99364d20aa433adbc0416d679aaab91ff5349fac78fab2
|
data/inesita.gemspec
CHANGED
@@ -9,21 +9,26 @@ class NavBar
|
|
9
9
|
text 'Inesita'
|
10
10
|
end
|
11
11
|
ul class: 'nav navbar-nav' do
|
12
|
-
li do
|
12
|
+
li class: "#{"active" if url == '/'}" do
|
13
13
|
a href: '/' do
|
14
14
|
text 'Home'
|
15
15
|
end
|
16
16
|
end
|
17
|
-
li do
|
17
|
+
li class: "#{"active" if url == '/welcome'}" do
|
18
18
|
a href: '/welcome' do
|
19
19
|
text 'Welcome'
|
20
20
|
end
|
21
21
|
end
|
22
|
-
li do
|
22
|
+
li class: "#{"active" if url == '/goodbye'}" do
|
23
23
|
a href: '/goodbye' do
|
24
24
|
text 'Goodbye'
|
25
25
|
end
|
26
26
|
end
|
27
|
+
li class: "#{"active" if url == '/counter'}" do
|
28
|
+
a href: '/counter' do
|
29
|
+
text 'Counter'
|
30
|
+
end
|
31
|
+
end
|
27
32
|
end
|
28
33
|
end
|
29
34
|
end
|
data/lib/inesita/server.rb
CHANGED
data/opal/inesita/application.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
module Inesita
|
2
2
|
class Application
|
3
3
|
include Inesita::Component
|
4
|
-
class << self; attr_accessor :main; end
|
5
4
|
|
6
5
|
attr_reader :layout
|
7
6
|
|
8
7
|
def initialize(options)
|
9
|
-
raise 'Mount point missing' unless options[:mount]
|
10
8
|
raise 'Routes missing' unless options[:routes]
|
11
9
|
|
12
10
|
@router = Router.new(options[:routes])
|
13
|
-
@mount = options[:mount]
|
14
11
|
@layout = options[:layout]
|
15
12
|
|
16
13
|
if @layout
|
@@ -21,12 +18,7 @@ module Inesita
|
|
21
18
|
end
|
22
19
|
|
23
20
|
def render
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
def run
|
28
|
-
Application.main = self
|
29
|
-
mount(@mount)
|
21
|
+
component layout ? layout_component : router_component
|
30
22
|
end
|
31
23
|
end
|
32
24
|
end
|
data/opal/inesita/component.rb
CHANGED
data/opal/inesita/router.rb
CHANGED
@@ -7,7 +7,7 @@ module Inesita
|
|
7
7
|
default_component = routes.values.first.new
|
8
8
|
default_component.parent(self)
|
9
9
|
|
10
|
-
@routes = Hash.new(
|
10
|
+
@routes = Hash.new(default_component)
|
11
11
|
routes.map do |route, component|
|
12
12
|
@routes[route] = component.new
|
13
13
|
@routes[route].parent(self)
|
@@ -18,20 +18,15 @@ module Inesita
|
|
18
18
|
component routes[url]
|
19
19
|
end
|
20
20
|
|
21
|
-
def url
|
22
|
-
`document.location.pathname`
|
23
|
-
end
|
24
|
-
|
25
21
|
def mount
|
26
|
-
`window.onpopstate = function(){#{
|
27
|
-
`window.addEventListener("hashchange", function(){#{
|
22
|
+
`window.onpopstate = function(){#{handle_link}}`
|
23
|
+
`window.addEventListener("hashchange", function(){#{handle_link}})`
|
28
24
|
super
|
29
25
|
end
|
30
26
|
|
31
|
-
|
32
|
-
def self.handle_link(path)
|
27
|
+
def self.handle_link(path, component)
|
33
28
|
`window.history.pushState({}, null, #{path})`
|
34
|
-
|
29
|
+
component.update
|
35
30
|
false
|
36
31
|
end
|
37
32
|
|
@@ -5,7 +5,8 @@ module VirtualDOM
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def a(params, &block)
|
8
|
-
|
8
|
+
#TODO: Only if router is configured
|
9
|
+
params = { onclick: -> { Inesita::Router.handle_link(params[:href], @parent) } }.merge(params) if params[:href]
|
9
10
|
@nodes << VirtualNode.new(
|
10
11
|
'a',
|
11
12
|
process_params(params),
|
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.7
|
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-07-
|
11
|
+
date: 2015-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|