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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bcd66252288b01b5288ce873b305ea83b45a13eb
4
- data.tar.gz: 609b032f8021f62302a18cb0f09d12d5384b7627
3
+ metadata.gz: 586b44f53758981d474a33605fdca12c01fbb1ab
4
+ data.tar.gz: a7e71cd60cdbb4741b08ce77aac599dc14f996f9
5
5
  SHA512:
6
- metadata.gz: 700729fe540f023f63894d452ed28ced8e9912dacb7c2c910bebc052de386a7f6e8b8149ce971993d4cb8b3cdc4a02a5ea1ff177a8ed05f1c862575497702e55
7
- data.tar.gz: 36b8e82c1c306d42c90f2790b88b782b36e1c4b836f1d329282ff9f60ec0e34181b649b931769b9fadd02307c41f18a1e6f5e03f42b55276f56cea06c5794770
6
+ metadata.gz: c514f42391b811439ef6144c1f9a46096d57208a4802f0e98d30e0d58d2763da443c1f28d218a19ec602737dd1676ed0791449ee9045d7ad5ff498dce2214ef4
7
+ data.tar.gz: e41e94a6d8c82f9601e6cead98b5f406396e8af47f6238027cd742eb9071ff146abbdb2aa54af1d86e99364d20aa433adbc0416d679aaab91ff5349fac78fab2
data/inesita.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'inesita'
3
- s.version = '0.0.6'
3
+ s.version = '0.0.7'
4
4
  s.authors = [ 'Michał Kalbarczyk' ]
5
5
  s.email = 'fazibear@gmail.com'
6
6
  s.homepage = 'http://github.com/fazibear/inesita'
@@ -16,7 +16,6 @@ $document.ready do
16
16
  '/welcome' => Welcome,
17
17
  '/goodbye' => Goodbye
18
18
  },
19
- mount: $document.body,
20
19
  layout: Layout
21
- ).run
20
+ ).mount($document.body)
22
21
  end
@@ -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
@@ -24,7 +24,7 @@ module Inesita
24
24
  # add paths from rails-assets
25
25
  RailsAssets.load_paths.each do |p|
26
26
  s.append_path p
27
- end
27
+ end if defined?(RailsAssets)
28
28
 
29
29
  s.context_class.class_eval do
30
30
  def asset_path(path, options = {})
@@ -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
- component layout ? layout_component : router_component
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
@@ -23,6 +23,10 @@ module Inesita
23
23
  end
24
24
  end
25
25
 
26
+ def url
27
+ `document.location.pathname`
28
+ end
29
+
26
30
  def self.included(base)
27
31
  base.extend(ClassMethods)
28
32
  end
@@ -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(routes['/'].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(){#{self.handle_link}}`
27
- `window.addEventListener("hashchange", function(){#{self.handle_link}})`
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
- Application.main.update
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
- params = { onclick: -> { Inesita::Router.handle_link(params[:href]) } }.merge(params) if params[:href]
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.6
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-26 00:00:00.000000000 Z
11
+ date: 2015-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal