inesita 0.0.4 → 0.0.5
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/README.md +5 -3
- data/inesita.gemspec +2 -1
- data/lib/inesita/cli/new.rb +5 -12
- data/lib/inesita/cli/template/app/application.css.sass +3 -0
- data/lib/inesita/cli/template/app/application.js.rb +14 -2
- data/lib/inesita/cli/template/app/components/goodbye.rb +13 -0
- data/lib/inesita/cli/template/app/components/home.rb +13 -0
- data/lib/inesita/cli/template/app/components/layout.rb +14 -0
- data/lib/inesita/cli/template/app/components/navbar.rb +32 -0
- data/lib/inesita/cli/template/app/components/{welcome_component.rb → welcome.rb} +1 -1
- data/lib/inesita/cli/template/app/index.html.slim +4 -8
- data/lib/inesita/server.rb +15 -3
- data/opal/inesita.rb +3 -0
- data/opal/inesita/application.rb +32 -0
- data/opal/inesita/layout.rb +13 -0
- data/opal/inesita/router.rb +39 -0
- data/opal/virtual_dom_extension.rb +9 -0
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a100bdbff9cff050c8c7d021a19b8b88c283ae9
|
4
|
+
data.tar.gz: c78e1c5b340878e330c44a147d1a519f7866b62f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db700496d73df68d26fd7a1cd540e7dad97846cf08af992fd89d184e0d2244b41a652aef7a2ad9e5cf0c81153d10644ce76cdd484b922a5936f89b268e7fed79
|
7
|
+
data.tar.gz: fae967b5907aefbe7c28832b5658a5a2529ff5914eef9a0d3a8a7ab94392017989948bf42f523d9966f5f2f2abd6ffa1992b89320eeee6b4620d9c2791f89b57
|
data/README.md
CHANGED
@@ -11,22 +11,24 @@ Install Inesita
|
|
11
11
|
```sh
|
12
12
|
$ gem install inesita
|
13
13
|
```
|
14
|
-
|
15
14
|
Generate Inesita new app
|
16
15
|
|
17
16
|
```sh
|
18
17
|
$ inesita new my_app
|
19
18
|
```
|
20
|
-
|
21
19
|
Launch Inesita server
|
22
20
|
|
23
21
|
```sh
|
24
22
|
$ cd my_app
|
25
23
|
$ bundle exec inesita server
|
26
24
|
```
|
27
|
-
|
28
25
|
Go to [http://localhost:9292/](http://localhost:9292/)
|
29
26
|
|
27
|
+
To build your application to `public` dir
|
28
|
+
|
29
|
+
```sh
|
30
|
+
$ bundle exec inesita build
|
31
|
+
```
|
30
32
|
## examples
|
31
33
|
|
32
34
|
[More detailed example](https://github.com/fazibear/inesita-example)
|
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.
|
3
|
+
s.version = '0.0.5'
|
4
4
|
s.authors = [ 'Michał Kalbarczyk' ]
|
5
5
|
s.email = 'fazibear@gmail.com'
|
6
6
|
s.homepage = 'http://github.com/fazibear/inesita'
|
@@ -17,5 +17,6 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.add_dependency 'slim'
|
18
18
|
s.add_dependency 'sass'
|
19
19
|
s.add_dependency 'thor'
|
20
|
+
s.add_dependency 'rack-rewrite'
|
20
21
|
s.add_development_dependency 'rake'
|
21
22
|
end
|
data/lib/inesita/cli/new.rb
CHANGED
@@ -13,18 +13,11 @@ class InesitaCLI < Thor
|
|
13
13
|
desc: 'force overwrite'
|
14
14
|
|
15
15
|
def new(project_dir)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
empty_directory File.join(project_dir, 'app'), force: options[:force]
|
22
|
-
copy_file 'template/app/index.html.slim', File.join(project_dir, 'app', 'index.html.slim'), force: options[:force]
|
23
|
-
copy_file 'template/app/application.js.rb', File.join(project_dir, 'app', 'application.js.rb'), force: options[:force]
|
24
|
-
copy_file 'template/app/application.css.sass', File.join(project_dir, 'app', 'application.css.sass'), force: options[:force]
|
25
|
-
|
26
|
-
empty_directory File.join(project_dir, 'app', 'components'), force: options[:force]
|
27
|
-
copy_file 'template/app/components/welcome_component.rb', File.join(project_dir, 'app', 'components', 'welcome_controller.rb'), force: options[:force]
|
16
|
+
Dir.glob("#{File.dirname(__FILE__)}/template/**/*", File::FNM_DOTMATCH).each do |file|
|
17
|
+
next if File.directory?(file)
|
18
|
+
path = file.split('/')
|
19
|
+
copy_file file, File.join(project_dir, path[path.index('template')+1..-1].join('/')), force: options[:force]
|
20
|
+
end
|
28
21
|
|
29
22
|
inside project_dir do
|
30
23
|
run 'bundle install'
|
@@ -3,8 +3,20 @@ require 'opal'
|
|
3
3
|
require 'browser'
|
4
4
|
require 'inesita'
|
5
5
|
|
6
|
-
|
6
|
+
require 'components/navbar'
|
7
|
+
require 'components/layout'
|
8
|
+
require 'components/home'
|
9
|
+
require 'components/welcome'
|
10
|
+
require 'components/goodbye'
|
7
11
|
|
8
12
|
$document.ready do
|
9
|
-
|
13
|
+
Inesita::Application.new(
|
14
|
+
routes: {
|
15
|
+
'/' => Home,
|
16
|
+
'/welcome' => Welcome,
|
17
|
+
'/goodbye' => Goodbye
|
18
|
+
},
|
19
|
+
mount: $document.body,
|
20
|
+
layout: Layout
|
21
|
+
).run
|
10
22
|
end
|
@@ -0,0 +1,32 @@
|
|
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 do
|
13
|
+
a href: '/' do
|
14
|
+
text 'Home'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
li do
|
18
|
+
a href: '/welcome' do
|
19
|
+
text 'Welcome'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
li 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
|
@@ -2,17 +2,13 @@ doctype html
|
|
2
2
|
html
|
3
3
|
head
|
4
4
|
title Inesita
|
5
|
-
|
6
|
-
|
5
|
+
- if $DEVELOPMENT_MODE
|
6
|
+
link href=asset_path('application.css') rel='stylesheet' type='text/css'
|
7
7
|
- $SCRIPT_FILES.each do |file|
|
8
|
-
script src=file
|
8
|
+
script src=asset_path(file)
|
9
9
|
- else
|
10
|
+
link href='application.css' rel='stylesheet' type='text/css'
|
10
11
|
script src='application.js'
|
11
12
|
javascript:
|
12
13
|
#{{$LOAD_ASSETS_CODE}}
|
13
14
|
body
|
14
|
-
nav.navbar.navbar-inverse
|
15
|
-
.container
|
16
|
-
.navbar-header
|
17
|
-
a.navbar-brand Project Name
|
18
|
-
#app.container
|
data/lib/inesita/server.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
require 'rack/rewrite'
|
2
|
+
|
1
3
|
module Inesita
|
2
4
|
module Server
|
3
5
|
SOURCE_MAP_PREFIX = '/__OPAL_MAPS__'
|
6
|
+
ASSETS_PREFIX = '/__ASSETS__'
|
4
7
|
|
5
8
|
module_function
|
6
9
|
|
@@ -25,7 +28,7 @@ module Inesita
|
|
25
28
|
|
26
29
|
s.context_class.class_eval do
|
27
30
|
def asset_path(path, options = {})
|
28
|
-
"#{path}"
|
31
|
+
$DEVELOPMENT_MODE ? "#{ASSETS_PREFIX}/#{path}" : path
|
29
32
|
end
|
30
33
|
end
|
31
34
|
end
|
@@ -33,7 +36,7 @@ module Inesita
|
|
33
36
|
|
34
37
|
def set_global_vars(assets, debug = false)
|
35
38
|
$LOAD_ASSETS_CODE = Opal::Processor.load_asset_code(assets, 'application.js')
|
36
|
-
if
|
39
|
+
if $DEVELOPMENT_MODE
|
37
40
|
$SCRIPT_FILES = (assets['application.js'].dependencies + [assets['application.self.js']]).map(&:logical_path)
|
38
41
|
end
|
39
42
|
end
|
@@ -43,13 +46,22 @@ module Inesita
|
|
43
46
|
Opal::SourceMapServer.new(sprockets, SOURCE_MAP_PREFIX)
|
44
47
|
end
|
45
48
|
|
49
|
+
def development_mode
|
50
|
+
$DEVELOPMENT_MODE = ENV['DEVELOPMENT_MODE'] || true
|
51
|
+
end
|
52
|
+
|
46
53
|
def create
|
54
|
+
development_mode
|
47
55
|
assets_app = assets
|
48
56
|
source_maps_app = source_maps(assets_app)
|
49
57
|
set_global_vars(assets_app, true)
|
50
58
|
|
51
59
|
Rack::Builder.new do
|
52
|
-
|
60
|
+
use Rack::Rewrite do
|
61
|
+
rewrite %r[^(?!#{ASSETS_PREFIX}|#{SOURCE_MAP_PREFIX}).*], ASSETS_PREFIX
|
62
|
+
end
|
63
|
+
|
64
|
+
map ASSETS_PREFIX do
|
53
65
|
run assets_app
|
54
66
|
end
|
55
67
|
|
data/opal/inesita.rb
CHANGED
@@ -0,0 +1,32 @@
|
|
1
|
+
module Inesita
|
2
|
+
class Application
|
3
|
+
include Inesita::Component
|
4
|
+
class << self; attr_accessor :main; end
|
5
|
+
|
6
|
+
attr_reader :layout
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
raise 'Mount point missing' unless options[:mount]
|
10
|
+
raise 'Routes missing' unless options[:routes]
|
11
|
+
|
12
|
+
@router = Router.new(options[:routes])
|
13
|
+
@mount = options[:mount]
|
14
|
+
@layout = options[:layout]
|
15
|
+
|
16
|
+
if @layout
|
17
|
+
self.class.component :layout_component, @layout.new(@router)
|
18
|
+
else
|
19
|
+
self.class.component :router_component, @router
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def render
|
24
|
+
component layout ? layout_component : router_component
|
25
|
+
end
|
26
|
+
|
27
|
+
def run
|
28
|
+
Application.main = self
|
29
|
+
mount(@mount)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Inesita
|
2
|
+
class Router
|
3
|
+
include Inesita::Component
|
4
|
+
attr_reader :routes
|
5
|
+
|
6
|
+
def initialize(routes)
|
7
|
+
default_component = routes.values.first.new
|
8
|
+
default_component.parent(self)
|
9
|
+
|
10
|
+
@routes = Hash.new(routes['/'].new)
|
11
|
+
routes.map do |route, component|
|
12
|
+
@routes[route] = component.new
|
13
|
+
@routes[route].parent(self)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def render
|
18
|
+
component routes[url]
|
19
|
+
end
|
20
|
+
|
21
|
+
def url
|
22
|
+
`document.location.pathname`
|
23
|
+
end
|
24
|
+
|
25
|
+
def mount
|
26
|
+
`window.onpopstate = function(){#{self.handle_link}}`
|
27
|
+
`window.addEventListener("hashchange", function(){#{self.handle_link}})`
|
28
|
+
super
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def self.handle_link(path)
|
33
|
+
`window.history.pushState({}, null, #{path})`
|
34
|
+
Application.main.update
|
35
|
+
false
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -3,5 +3,14 @@ module VirtualDOM
|
|
3
3
|
def component(comp)
|
4
4
|
@nodes << NodeFactory.new(comp.method(:render), comp).nodes.first
|
5
5
|
end
|
6
|
+
|
7
|
+
def a(params, &block)
|
8
|
+
params = { onclick: -> { Inesita::Router.handle_link(params[:href]) } }.merge(params) if params[:href]
|
9
|
+
@nodes << VirtualNode.new(
|
10
|
+
'a',
|
11
|
+
process_params(params),
|
12
|
+
block ? NodeFactory.new(block, @parent).nodes : []
|
13
|
+
).vnode
|
14
|
+
end
|
6
15
|
end
|
7
16
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michał Kalbarczyk
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rack-rewrite
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: rake
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -116,12 +130,19 @@ files:
|
|
116
130
|
- lib/inesita/cli/template/Gemfile
|
117
131
|
- lib/inesita/cli/template/app/application.css.sass
|
118
132
|
- lib/inesita/cli/template/app/application.js.rb
|
119
|
-
- lib/inesita/cli/template/app/components/
|
133
|
+
- lib/inesita/cli/template/app/components/goodbye.rb
|
134
|
+
- lib/inesita/cli/template/app/components/home.rb
|
135
|
+
- lib/inesita/cli/template/app/components/layout.rb
|
136
|
+
- lib/inesita/cli/template/app/components/navbar.rb
|
137
|
+
- lib/inesita/cli/template/app/components/welcome.rb
|
120
138
|
- lib/inesita/cli/template/app/index.html.slim
|
121
139
|
- lib/inesita/cli/template/config.ru
|
122
140
|
- lib/inesita/server.rb
|
123
141
|
- opal/inesita.rb
|
142
|
+
- opal/inesita/application.rb
|
124
143
|
- opal/inesita/component.rb
|
144
|
+
- opal/inesita/layout.rb
|
145
|
+
- opal/inesita/router.rb
|
125
146
|
- opal/virtual_dom_extension.rb
|
126
147
|
homepage: http://github.com/fazibear/inesita
|
127
148
|
licenses: []
|