inesita 0.0.12 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/README.md +3 -2
- data/TODO.md +6 -0
- data/inesita.gemspec +9 -9
- data/lib/inesita/cli/new.rb +4 -5
- data/lib/inesita/cli/template/{Gemfile → Gemfile.tt} +2 -3
- data/lib/inesita/cli/template/README.md.tt +1 -0
- data/lib/inesita/cli/template/app/application.js.rb.tt +17 -0
- data/lib/inesita/cli/template/app/components/description.rb.tt +18 -0
- data/lib/inesita/cli/template/app/components/home.rb.tt +17 -0
- data/lib/inesita/cli/template/app/components/{layout.rb → layout.rb.tt} +2 -8
- data/lib/inesita/cli/template/app/components/navbar.rb.tt +29 -0
- data/lib/inesita/cli/template/app/{index.html.slim → index.html.slim.tt} +1 -1
- data/lib/inesita/cli/template/app/router.rb.tt +8 -0
- data/lib/inesita/cli/template/app/store.rb.tt +15 -0
- data/lib/inesita/cli/template/app/{stylesheet.css.sass → stylesheet.css.sass.tt} +0 -0
- data/lib/inesita/cli/template/{config.ru → config.ru.tt} +0 -0
- data/opal/inesita.rb +4 -0
- data/opal/inesita/application.rb +14 -6
- data/opal/inesita/component.rb +24 -40
- data/opal/inesita/component_withs.rb +27 -0
- data/opal/inesita/js_helpers.rb +27 -0
- data/opal/inesita/layout.rb +2 -11
- data/opal/inesita/router.rb +53 -19
- data/opal/inesita/routes.rb +61 -0
- data/opal/inesita/store.rb +17 -0
- data/opal/virtual_dom_extension.rb +8 -3
- metadata +49 -43
- data/lib/inesita/cli/template/.gitignore +0 -1
- data/lib/inesita/cli/template/app/application.js.rb +0 -17
- data/lib/inesita/cli/template/app/components/goodbye.rb +0 -14
- data/lib/inesita/cli/template/app/components/home.rb +0 -14
- data/lib/inesita/cli/template/app/components/navbar.rb +0 -32
- data/lib/inesita/cli/template/app/components/welcome.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 64d2e0eb42676d12536c5751ef8896a2b60ed123
|
4
|
+
data.tar.gz: dc4a4619b78c7405d54a0a80383996c6df724433
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e008afb399d387e09fce2aaf3ca81503fd5618e4d9bb0949a3aa81993b930f43515acc12d5b0451030c1252c361703b22d4d1aaf2b3a3989dde70a66378addb
|
7
|
+
data.tar.gz: 98301a71c7490a38f673ed625152379071b5cf31c4309b1051e1723ad7e416852798bec825faf9bf286c76d481d344ebae24a7abdda130110fe0fdb2d518f24e
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
!!! WORK IN PROGRESS !!!
|
2
2
|
|
3
|
-
# Inesita [](http://badge.fury.io/rb/inesita) [](http://badge.fury.io/rb/inesita) [](https://codeclimate.com/github/inesita-rb/inesita)
|
4
4
|
|
5
5
|
Frontend web framework for Opal
|
6
6
|
|
@@ -31,4 +31,5 @@ $ bundle exec inesita build
|
|
31
31
|
```
|
32
32
|
## examples
|
33
33
|
|
34
|
-
[
|
34
|
+
- [My own playground](https://github.com/inesita-rb/playground)
|
35
|
+
- [TodoMVC example](https://github.com/inesita-rb/todomvc)
|
data/TODO.md
ADDED
data/inesita.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'inesita'
|
3
|
-
s.version = '0.0
|
3
|
+
s.version = '0.1.0'
|
4
4
|
s.authors = [ 'Michał Kalbarczyk' ]
|
5
5
|
s.email = 'fazibear@gmail.com'
|
6
|
-
s.homepage = 'http://github.com/
|
6
|
+
s.homepage = 'http://github.com/inesita-rb/inesita'
|
7
7
|
s.summary = 'Frontend web framework for Opal'
|
8
8
|
s.description = 'Frontent web framework for Opal'
|
9
9
|
|
@@ -12,11 +12,11 @@ Gem::Specification.new do |s|
|
|
12
12
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
13
13
|
s.require_paths = ['lib']
|
14
14
|
|
15
|
-
s.add_dependency 'opal'
|
16
|
-
s.add_dependency 'opal-virtual-dom'
|
17
|
-
s.add_dependency 'slim'
|
18
|
-
s.add_dependency 'sass'
|
19
|
-
s.add_dependency 'thor'
|
20
|
-
s.add_dependency 'rack-rewrite'
|
21
|
-
s.add_development_dependency 'rake'
|
15
|
+
s.add_dependency 'opal', '~> 0.8'
|
16
|
+
s.add_dependency 'opal-virtual-dom', '~> 0.0.5'
|
17
|
+
s.add_dependency 'slim', '~> 3.0'
|
18
|
+
s.add_dependency 'sass', '~> 3.4'
|
19
|
+
s.add_dependency 'thor', '~> 0.19'
|
20
|
+
s.add_dependency 'rack-rewrite', '~> 1.5'
|
21
|
+
s.add_development_dependency 'rake', '~> 10.4'
|
22
22
|
end
|
data/lib/inesita/cli/new.rb
CHANGED
@@ -13,11 +13,10 @@ class InesitaCLI < Thor
|
|
13
13
|
desc: 'force overwrite'
|
14
14
|
|
15
15
|
def new(project_dir)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
16
|
+
puts 'x'
|
17
|
+
directory('template', project_dir, {
|
18
|
+
project_name: project_dir
|
19
|
+
})
|
21
20
|
|
22
21
|
inside project_dir do
|
23
22
|
run 'bundle install'
|
@@ -0,0 +1 @@
|
|
1
|
+
# <%= config[:project_name] %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'virtual-dom'
|
2
|
+
require 'opal'
|
3
|
+
require 'browser'
|
4
|
+
require 'browser/interval'
|
5
|
+
require 'inesita'
|
6
|
+
|
7
|
+
require 'router'
|
8
|
+
require 'store'
|
9
|
+
require_tree './components'
|
10
|
+
|
11
|
+
$document.ready do
|
12
|
+
App = Inesita::Application.new(
|
13
|
+
router: Router,
|
14
|
+
store: Store,
|
15
|
+
layout: Layout
|
16
|
+
).mount_to($document.body)
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Description
|
2
|
+
include Inesita::Component
|
3
|
+
|
4
|
+
def render
|
5
|
+
dom do
|
6
|
+
div class: 'jumbotron text-center' do
|
7
|
+
p do
|
8
|
+
text %{
|
9
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
10
|
+
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
|
11
|
+
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
|
12
|
+
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class Home
|
2
|
+
include Inesita::Component
|
3
|
+
|
4
|
+
def render
|
5
|
+
dom do
|
6
|
+
div class: 'jumbotron text-center' do
|
7
|
+
img src: 'http://avatars.githubusercontent.com/inesita-rb'
|
8
|
+
h1 do
|
9
|
+
text "Hello I'm Inesita"
|
10
|
+
end
|
11
|
+
h4 do
|
12
|
+
text 'This is a sample component'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -1,16 +1,10 @@
|
|
1
1
|
class Layout
|
2
2
|
include Inesita::Layout
|
3
3
|
|
4
|
-
components :navbar
|
5
|
-
|
6
|
-
def initialize
|
7
|
-
@navbar ||= NavBar.new
|
8
|
-
end
|
9
|
-
|
10
4
|
def render
|
11
|
-
|
5
|
+
dom do
|
12
6
|
div class: 'container' do
|
13
|
-
component
|
7
|
+
component NavBar
|
14
8
|
component outlet
|
15
9
|
end
|
16
10
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class NavBar
|
2
|
+
include Inesita::Component
|
3
|
+
|
4
|
+
def render
|
5
|
+
dom do
|
6
|
+
nav class: 'navbar navbar-default' do
|
7
|
+
div class: 'container' do
|
8
|
+
div class: 'navbar-header' do
|
9
|
+
span class: 'navbar-brand' do
|
10
|
+
text '<%= config[:project_name] %>'
|
11
|
+
end
|
12
|
+
ul class: 'nav navbar-nav' do
|
13
|
+
li class: "#{"active" if router.current_url?(:home)}" do
|
14
|
+
a href: router.url_for(:home) do
|
15
|
+
text 'Home'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
li class: "#{"active" if router.current_url?(:description)}" do
|
19
|
+
a href: router.url_for(:description) do
|
20
|
+
text 'Description'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
File without changes
|
File without changes
|
data/opal/inesita.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
require 'virtual_dom'
|
2
2
|
require 'virtual_dom_extension'
|
3
|
+
require 'inesita/js_helpers'
|
4
|
+
require 'inesita/component_withs'
|
3
5
|
require 'inesita/component'
|
6
|
+
require 'inesita/routes'
|
4
7
|
require 'inesita/router'
|
8
|
+
require 'inesita/store'
|
5
9
|
require 'inesita/application'
|
6
10
|
require 'inesita/layout'
|
data/opal/inesita/application.rb
CHANGED
@@ -2,20 +2,28 @@ module Inesita
|
|
2
2
|
class Application
|
3
3
|
include Inesita::Component
|
4
4
|
|
5
|
-
|
5
|
+
attr_reader :root
|
6
6
|
|
7
7
|
def initialize(options)
|
8
|
-
|
8
|
+
router = options[:router]
|
9
|
+
layout = options[:layout]
|
10
|
+
store = options[:store]
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
+
raise 'Router missing' unless router
|
13
|
+
raise "Invalid #{router} class, should mixin Inesita::Router" unless router.include?(Inesita::Router)
|
14
|
+
raise "Invalid #{layout} class, should mixin Inesita::Layout" unless layout.include?(Inesita::Layout)
|
15
|
+
raise "Invalid #{store} class, should mixin Inesita::Store" unless store.include?(Inesita::Store)
|
12
16
|
|
13
|
-
@
|
17
|
+
@router = router.new
|
18
|
+
@layout = layout.new if layout
|
19
|
+
|
20
|
+
@root = @layout ? @layout : @router
|
21
|
+
@store = store.new.with_root_component(@root).store if store
|
14
22
|
end
|
15
23
|
|
16
24
|
def render
|
17
25
|
dom do
|
18
|
-
component
|
26
|
+
component root
|
19
27
|
end
|
20
28
|
end
|
21
29
|
end
|
data/opal/inesita/component.rb
CHANGED
@@ -1,59 +1,43 @@
|
|
1
1
|
module Inesita
|
2
2
|
module Component
|
3
3
|
include VirtualDOM
|
4
|
-
|
5
|
-
def with_parent(component)
|
6
|
-
@parent = component
|
7
|
-
self
|
8
|
-
end
|
4
|
+
include ComponentWiths
|
9
5
|
|
10
6
|
def dom(&block)
|
11
|
-
NodeFactory.new(block, self).nodes
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
render
|
7
|
+
nodes = NodeFactory.new(block, self).nodes
|
8
|
+
@cache_component_counter = nil
|
9
|
+
if nodes.length == 1
|
10
|
+
nodes.first
|
11
|
+
else
|
12
|
+
VirtualNode.new('div', {}, nodes).vnode
|
13
|
+
end
|
19
14
|
end
|
20
15
|
|
21
|
-
def
|
22
|
-
@
|
23
|
-
@
|
24
|
-
|
16
|
+
def mount_to(element)
|
17
|
+
@root_component = self
|
18
|
+
@virtual_dom = render
|
19
|
+
@root_node = VirtualDOM.create(@virtual_dom)
|
20
|
+
element.inner_dom = @root_node
|
25
21
|
end
|
26
22
|
|
27
|
-
def
|
28
|
-
if @virtual_dom && @
|
29
|
-
new_virtual_dom =
|
23
|
+
def render_if_root
|
24
|
+
if @virtual_dom && @root_node
|
25
|
+
new_virtual_dom = render
|
30
26
|
diff = VirtualDOM.diff(@virtual_dom, new_virtual_dom)
|
31
|
-
VirtualDOM.patch(@
|
27
|
+
VirtualDOM.patch(@root_node, diff)
|
32
28
|
@virtual_dom = new_virtual_dom
|
33
|
-
else
|
34
|
-
@parent.update_dom!
|
35
29
|
end
|
36
30
|
end
|
37
31
|
|
38
|
-
def
|
39
|
-
|
32
|
+
def update_dom
|
33
|
+
@root_component.render_if_root
|
40
34
|
end
|
41
35
|
|
42
|
-
def
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
def components(*attrs)
|
48
|
-
attrs.flatten.each do |component|
|
49
|
-
if VirtualDOM::NodeFactory::HTML_TAGS.include?(component)
|
50
|
-
fail "Forbidden component name '#{component}' in #{self} component"
|
51
|
-
else
|
52
|
-
attr_reader component
|
53
|
-
end
|
54
|
-
end
|
55
|
-
attr_reader *attrs.flatten
|
56
|
-
end
|
36
|
+
def cache_component(component, &block)
|
37
|
+
@cache_component ||= {}
|
38
|
+
@cache_component_counter ||= 0
|
39
|
+
@cache_component_counter += 1
|
40
|
+
@cache_component["#{component}-#{@cache_component_counter}"] || @cache_component["#{component}-#{@cache_component_counter}"] = block.call
|
57
41
|
end
|
58
42
|
end
|
59
43
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Inesita
|
2
|
+
module ComponentWiths
|
3
|
+
attr_reader :root_component
|
4
|
+
def with_root_component(component)
|
5
|
+
@root_component = component
|
6
|
+
self
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :router
|
10
|
+
def with_router(router)
|
11
|
+
@router = router
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :store
|
16
|
+
def with_store(store)
|
17
|
+
@store = store
|
18
|
+
self
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_reader :props
|
22
|
+
def with_props(props)
|
23
|
+
@props = props
|
24
|
+
self
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Inesita
|
2
|
+
module JSHelpers
|
3
|
+
def on_popstate(fn)
|
4
|
+
`window.onpopstate = function(){#{fn}}`
|
5
|
+
end
|
6
|
+
|
7
|
+
def on_hashchange(fn)
|
8
|
+
`window.addEventListener("hashchange", function(){#{fn}})`
|
9
|
+
end
|
10
|
+
|
11
|
+
def push_state(path)
|
12
|
+
`window.history.pushState({}, null, #{path})`
|
13
|
+
end
|
14
|
+
|
15
|
+
def path
|
16
|
+
`document.location.pathname`
|
17
|
+
end
|
18
|
+
|
19
|
+
def decode_uri(string)
|
20
|
+
`decodeURIComponent(#{string})`
|
21
|
+
end
|
22
|
+
|
23
|
+
def url_query
|
24
|
+
`location.search`
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/opal/inesita/layout.rb
CHANGED
@@ -2,19 +2,10 @@ module Inesita
|
|
2
2
|
module Layout
|
3
3
|
def self.included(base)
|
4
4
|
base.include(Component)
|
5
|
-
base.extend(ClassMethods)
|
6
|
-
base.components :outlet
|
7
5
|
end
|
8
6
|
|
9
|
-
def
|
10
|
-
@
|
11
|
-
self
|
12
|
-
end
|
13
|
-
|
14
|
-
module ClassMethods
|
15
|
-
def create(outlet)
|
16
|
-
new.with_outlet(outlet)
|
17
|
-
end
|
7
|
+
def outlet
|
8
|
+
@router
|
18
9
|
end
|
19
10
|
end
|
20
11
|
end
|
data/opal/inesita/router.rb
CHANGED
@@ -1,38 +1,72 @@
|
|
1
1
|
module Inesita
|
2
|
-
|
2
|
+
module Router
|
3
|
+
include Inesita::JSHelpers
|
3
4
|
include Inesita::Component
|
4
|
-
class << self; attr_accessor :handle_browser_history; end
|
5
5
|
|
6
|
-
|
6
|
+
attr_reader :params
|
7
7
|
|
8
|
-
def initialize
|
9
|
-
|
8
|
+
def initialize
|
9
|
+
on_popstate method(:update_dom)
|
10
|
+
on_hashchange method(:update_dom)
|
11
|
+
@routes = Routes.new
|
12
|
+
@url_params = parse_url_params
|
13
|
+
routes
|
14
|
+
end
|
10
15
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
16
|
+
def routes; end
|
17
|
+
|
18
|
+
def route(*params, &block)
|
19
|
+
@routes.route(*params, &block)
|
20
|
+
end
|
15
21
|
|
16
|
-
|
22
|
+
def find_component
|
23
|
+
@routes.routes.each do |route|
|
24
|
+
if params = path.match(route[:regex])
|
25
|
+
@params = @url_params.merge(Hash[route[:params].zip(params[1..-1])])
|
26
|
+
@component_props = route[:component_props]
|
27
|
+
return route[:component]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
fail 'not_found'
|
17
31
|
end
|
18
32
|
|
19
33
|
def render
|
20
34
|
dom do
|
21
|
-
component
|
35
|
+
component find_component, props: @component_props
|
22
36
|
end
|
23
37
|
end
|
24
38
|
|
25
|
-
def
|
26
|
-
|
27
|
-
|
28
|
-
|
39
|
+
def handle_link(path)
|
40
|
+
push_state path
|
41
|
+
update_dom
|
42
|
+
false
|
29
43
|
end
|
30
44
|
|
31
|
-
def
|
32
|
-
|
33
|
-
|
34
|
-
|
45
|
+
def parse_url_params
|
46
|
+
params = {}
|
47
|
+
url_query[1..-1].split('&').each do |param|
|
48
|
+
key, value = param.split('=')
|
49
|
+
params[decode_uri(key)] = decode_uri(value)
|
50
|
+
end unless url_query.length == 0
|
51
|
+
params
|
35
52
|
end
|
36
53
|
|
54
|
+
def url_for(name)
|
55
|
+
route = case name
|
56
|
+
when String
|
57
|
+
@routes.routes.find { |route| route[:name] == name }
|
58
|
+
when Object
|
59
|
+
@routes.routes.find { |route| route[:component] == name }
|
60
|
+
end
|
61
|
+
if route
|
62
|
+
route[:path]
|
63
|
+
else
|
64
|
+
raise "Route '#{name}' not found."
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def current_url?(name)
|
69
|
+
path == url_for(name)
|
70
|
+
end
|
37
71
|
end
|
38
72
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module Inesita
|
2
|
+
class Routes
|
3
|
+
attr_reader :routes, :route_names
|
4
|
+
|
5
|
+
def initialize(parent = nil)
|
6
|
+
@parent = parent
|
7
|
+
@routes = []
|
8
|
+
end
|
9
|
+
|
10
|
+
def route(*params, &block)
|
11
|
+
path = params.first.delete('/')
|
12
|
+
path = @parent ? "#{@parent}/#{path}" : "/#{path}"
|
13
|
+
component = params.last[:to]
|
14
|
+
name = params.last[:as]
|
15
|
+
component_props = params.last[:props]
|
16
|
+
|
17
|
+
add_subroutes(path, &block) if block_given?
|
18
|
+
add_route(name, path, component, component_props) if component
|
19
|
+
end
|
20
|
+
|
21
|
+
def add_route(name, path, component, component_props)
|
22
|
+
@routes << {
|
23
|
+
path: path,
|
24
|
+
component: component,
|
25
|
+
component_props: component_props,
|
26
|
+
name: name || component.to_s.downcase
|
27
|
+
}.merge(params_and_regex(path))
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_subroutes(path, &block)
|
31
|
+
subroutes = Routes.new(path)
|
32
|
+
subroutes.instance_exec(&block)
|
33
|
+
@routes += subroutes.routes
|
34
|
+
end
|
35
|
+
|
36
|
+
def params_and_regex(path)
|
37
|
+
regex = ['^']
|
38
|
+
params = []
|
39
|
+
parts = path.split('/')
|
40
|
+
if parts.empty?
|
41
|
+
regex << '\/'
|
42
|
+
else
|
43
|
+
parts.each do |part|
|
44
|
+
next if part.empty?
|
45
|
+
regex << '\/'
|
46
|
+
if part[0] == ':'
|
47
|
+
params << part[1..-1]
|
48
|
+
regex << '([^\/]+)'
|
49
|
+
else
|
50
|
+
regex << part
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
regex << '$'
|
55
|
+
{
|
56
|
+
regex: Regexp.new(regex.join),
|
57
|
+
params: params
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -1,12 +1,17 @@
|
|
1
1
|
module VirtualDOM
|
2
2
|
class NodeFactory
|
3
|
-
def component(comp)
|
3
|
+
def component(comp, opts = {})
|
4
4
|
fail "Component is nil in #{@parent.class} class" if comp.nil?
|
5
|
-
@nodes <<
|
5
|
+
@nodes << @parent.cache_component(comp) do
|
6
|
+
(comp.is_a?(Class) ? comp.new : comp)
|
7
|
+
.with_root_component(@parent.root_component)
|
8
|
+
.with_router(@parent.router)
|
9
|
+
.with_store(@parent.store)
|
10
|
+
end.with_props(opts[:props] || {}).render
|
6
11
|
end
|
7
12
|
|
8
13
|
def a(params, &block)
|
9
|
-
params = { onclick: -> {
|
14
|
+
params = { onclick: -> { @parent.router.handle_link(params[:href]) } }.merge(params) if params[:href] && @parent.router
|
10
15
|
@nodes << VirtualNode.new(
|
11
16
|
'a',
|
12
17
|
process_params(params),
|
metadata
CHANGED
@@ -1,113 +1,113 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inesita
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
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-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '0.8'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '0.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: opal-virtual-dom
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.0.5
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.0.5
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: slim
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '3.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: sass
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '3.4'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '3.4'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: thor
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
75
|
+
version: '0.19'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
82
|
+
version: '0.19'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: rack-rewrite
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '1.5'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '1.5'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: rake
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
|
-
- - "
|
101
|
+
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '10.4'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- - "
|
108
|
+
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '10.4'
|
111
111
|
description: Frontent web framework for Opal
|
112
112
|
email: fazibear@gmail.com
|
113
113
|
executables:
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- Gemfile
|
120
120
|
- README.md
|
121
121
|
- Rakefile
|
122
|
+
- TODO.md
|
122
123
|
- bin/inesita
|
123
124
|
- inesita.gemspec
|
124
125
|
- lib/inesita.rb
|
@@ -126,25 +127,30 @@ files:
|
|
126
127
|
- lib/inesita/cli/build.rb
|
127
128
|
- lib/inesita/cli/new.rb
|
128
129
|
- lib/inesita/cli/server.rb
|
129
|
-
- lib/inesita/cli/template
|
130
|
-
- lib/inesita/cli/template/
|
131
|
-
- lib/inesita/cli/template/app/application.js.rb
|
132
|
-
- lib/inesita/cli/template/app/components/
|
133
|
-
- lib/inesita/cli/template/app/components/home.rb
|
134
|
-
- lib/inesita/cli/template/app/components/layout.rb
|
135
|
-
- lib/inesita/cli/template/app/components/navbar.rb
|
136
|
-
- lib/inesita/cli/template/app/
|
137
|
-
- lib/inesita/cli/template/app/
|
138
|
-
- lib/inesita/cli/template/app/
|
139
|
-
- lib/inesita/cli/template/
|
130
|
+
- lib/inesita/cli/template/Gemfile.tt
|
131
|
+
- lib/inesita/cli/template/README.md.tt
|
132
|
+
- lib/inesita/cli/template/app/application.js.rb.tt
|
133
|
+
- lib/inesita/cli/template/app/components/description.rb.tt
|
134
|
+
- lib/inesita/cli/template/app/components/home.rb.tt
|
135
|
+
- lib/inesita/cli/template/app/components/layout.rb.tt
|
136
|
+
- lib/inesita/cli/template/app/components/navbar.rb.tt
|
137
|
+
- lib/inesita/cli/template/app/index.html.slim.tt
|
138
|
+
- lib/inesita/cli/template/app/router.rb.tt
|
139
|
+
- lib/inesita/cli/template/app/store.rb.tt
|
140
|
+
- lib/inesita/cli/template/app/stylesheet.css.sass.tt
|
141
|
+
- lib/inesita/cli/template/config.ru.tt
|
140
142
|
- lib/inesita/server.rb
|
141
143
|
- opal/inesita.rb
|
142
144
|
- opal/inesita/application.rb
|
143
145
|
- opal/inesita/component.rb
|
146
|
+
- opal/inesita/component_withs.rb
|
147
|
+
- opal/inesita/js_helpers.rb
|
144
148
|
- opal/inesita/layout.rb
|
145
149
|
- opal/inesita/router.rb
|
150
|
+
- opal/inesita/routes.rb
|
151
|
+
- opal/inesita/store.rb
|
146
152
|
- opal/virtual_dom_extension.rb
|
147
|
-
homepage: http://github.com/
|
153
|
+
homepage: http://github.com/inesita-rb/inesita
|
148
154
|
licenses: []
|
149
155
|
metadata: {}
|
150
156
|
post_install_message:
|
@@ -163,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
169
|
version: '0'
|
164
170
|
requirements: []
|
165
171
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.4.
|
172
|
+
rubygems_version: 2.4.8
|
167
173
|
signing_key:
|
168
174
|
specification_version: 4
|
169
175
|
summary: Frontend web framework for Opal
|
@@ -1 +0,0 @@
|
|
1
|
-
/public
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'virtual-dom'
|
2
|
-
require 'opal'
|
3
|
-
require 'browser'
|
4
|
-
require 'inesita'
|
5
|
-
|
6
|
-
require_tree './components'
|
7
|
-
|
8
|
-
$document.ready do
|
9
|
-
Inesita::Application.new(
|
10
|
-
routes: {
|
11
|
-
'/' => Home,
|
12
|
-
'/welcome' => Welcome,
|
13
|
-
'/goodbye' => Goodbye
|
14
|
-
},
|
15
|
-
layout: Layout
|
16
|
-
).mount($document.body)
|
17
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
class NavBar
|
2
|
-
include Inesita::Component
|
3
|
-
|
4
|
-
def render
|
5
|
-
nav class: 'navbar navbar-default' do
|
6
|
-
div class: 'container' do
|
7
|
-
div class: 'navbar-header' do
|
8
|
-
span class: 'navbar-brand' do
|
9
|
-
text 'Inesita'
|
10
|
-
end
|
11
|
-
ul class: 'nav navbar-nav' do
|
12
|
-
li class: "#{"active" if url == '/'}" do
|
13
|
-
a href: '/' do
|
14
|
-
text 'Home'
|
15
|
-
end
|
16
|
-
end
|
17
|
-
li class: "#{"active" if url == '/welcome'}" do
|
18
|
-
a href: '/welcome' do
|
19
|
-
text 'Welcome'
|
20
|
-
end
|
21
|
-
end
|
22
|
-
li class: "#{"active" if url == '/goodbye'}" do
|
23
|
-
a href: '/goodbye' do
|
24
|
-
text 'Goodbye'
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|