breezy 0.5.6 → 0.6.0
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 180ec22718cca06ce353a6b67d975c7f7f7a3633
|
4
|
+
data.tar.gz: 7650ea18f750cb26180a388f0ff151d552282def
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08465297490eb25c96f3c88ae2388eb70e49e1528a4f40ed2053a3fcdbc26767ef4282dd9e5cbcdd2214a21695acf50ecaffa312894e9875d371bcf80a7d94d0'
|
7
|
+
data.tar.gz: cb3cb587d99b46ae64038439dd87d2642d137eec7f80326d886c0e57cc0c97e4b0045275d8f13bec2b7fd24b71c81fd77f5188612bd95d0b533c319537e3e8b6
|
data/lib/breezy/render.rb
CHANGED
@@ -1,11 +1,5 @@
|
|
1
1
|
module Breezy
|
2
2
|
module Render
|
3
|
-
DEFAULT_ACTIONS_FOR_VERBS = {
|
4
|
-
:post => 'new',
|
5
|
-
:patch => 'edit',
|
6
|
-
:put => 'edit'
|
7
|
-
}
|
8
|
-
|
9
3
|
def default_render(*args)
|
10
4
|
if @_use_breezy_html
|
11
5
|
render(*args)
|
@@ -27,11 +21,6 @@ module Breezy
|
|
27
21
|
end
|
28
22
|
|
29
23
|
if breezy
|
30
|
-
action = render_options[action] || DEFAULT_ACTIONS_FOR_VERBS[request.request_method_symbol] || action_name
|
31
|
-
view_parts = _prefixes.reverse.push(action)[1..-1]
|
32
|
-
view_name = view_parts.map(&:camelize).join.gsub('::', '')
|
33
|
-
|
34
|
-
breezy[:screen] ||= view_name
|
35
24
|
render_options[:locals] ||= {}
|
36
25
|
render_options[:locals][:breezy] = breezy
|
37
26
|
end
|
@@ -42,17 +42,14 @@ module Rails
|
|
42
42
|
def append_mapping(action)
|
43
43
|
app_js = 'app/javascript/packs/application.js'
|
44
44
|
|
45
|
-
|
46
|
-
destination = File.join("views", base_parts)
|
47
|
-
|
48
|
-
@js_filename = [plural_table_name, action].map(&:camelcase).join
|
45
|
+
component_name = [plural_table_name, action].map(&:camelcase).join
|
49
46
|
|
50
47
|
inject_into_file app_js, after: "from '@jho406/breezy'" do
|
51
|
-
"\nimport #{
|
48
|
+
"\nimport #{component_name} from 'views/#{controller_file_path}/#{action}'"
|
52
49
|
end
|
53
50
|
|
54
|
-
inject_into_file app_js, after: 'const
|
55
|
-
"\n #{
|
51
|
+
inject_into_file app_js, after: 'const screenToComponentMapping = {' do
|
52
|
+
"\n '#{[controller_file_path, action].join('/')}': #{component_name},"
|
56
53
|
end
|
57
54
|
end
|
58
55
|
|
@@ -39,7 +39,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
39
39
|
<%- end -%>
|
40
40
|
else
|
41
41
|
response.set_header("content-location", new_<%= singular_table_name %>_path)
|
42
|
-
render :new
|
42
|
+
render :new
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
@@ -53,7 +53,7 @@ class <%= controller_class_name %>Controller < ApplicationController
|
|
53
53
|
<%- end -%>
|
54
54
|
else
|
55
55
|
response.set_header("content-location", edit_<%= singular_table_name %>_path(@<%= singular_table_name %>))
|
56
|
-
render :edit
|
56
|
+
render :edit
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -1,15 +1,14 @@
|
|
1
1
|
import React from 'react'
|
2
|
-
import {combineReducers, createStore, applyMiddleware} from 'redux'
|
2
|
+
import {combineReducers, createStore, applyMiddleware, compose} from 'redux'
|
3
3
|
import thunk from 'redux-thunk'
|
4
4
|
import { Provider } from 'react-redux'
|
5
5
|
import { render } from 'react-dom'
|
6
6
|
import createHistory from 'history/createBrowserHistory'
|
7
7
|
import Breezy from '@jho406/breezy'
|
8
8
|
|
9
|
-
//
|
10
|
-
//
|
11
|
-
|
12
|
-
const mapping = {
|
9
|
+
// Mapping between your props template to Component
|
10
|
+
// e.g {'posts/new': PostNew}
|
11
|
+
const screenToComponentMapping = {
|
13
12
|
}
|
14
13
|
|
15
14
|
const history = createHistory({})
|
@@ -25,12 +24,15 @@ const {reducer, initialState, Nav, connect} = Breezy.start({
|
|
25
24
|
history
|
26
25
|
})
|
27
26
|
|
27
|
+
|
28
|
+
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
|
29
|
+
|
28
30
|
const store = createStore(
|
29
31
|
combineReducers({
|
30
32
|
...reducer,
|
31
33
|
}),
|
32
34
|
initialState,
|
33
|
-
applyMiddleware(thunk)
|
35
|
+
composeEnhancers(applyMiddleware(thunk))
|
34
36
|
)
|
35
37
|
|
36
38
|
connect(store)
|
@@ -38,11 +40,11 @@ connect(store)
|
|
38
40
|
class App extends React.Component {
|
39
41
|
render() {
|
40
42
|
return <Provider store={store}>
|
41
|
-
<Nav mapping={mapping}/>
|
43
|
+
<Nav mapping={this.props.mapping}/>
|
42
44
|
</Provider>
|
43
45
|
}
|
44
46
|
}
|
45
47
|
|
46
48
|
document.addEventListener("DOMContentLoaded", function() {
|
47
|
-
render(<App mapping={
|
49
|
+
render(<App mapping={screenToComponentMapping}/>, document.getElementById('app'))
|
48
50
|
})
|
data/test/render_test.rb
CHANGED
@@ -60,12 +60,12 @@ class RenderTest < ActionController::TestCase
|
|
60
60
|
|
61
61
|
test "simple render with breezy" do
|
62
62
|
get :simple_render_with_breezy
|
63
|
-
assert_breezy_html({author: "john smith"})
|
63
|
+
assert_breezy_html({author: "john smith"}, screen: :action)
|
64
64
|
end
|
65
65
|
|
66
66
|
test "implied render with breezy" do
|
67
67
|
get :implied_render_with_breezy
|
68
|
-
assert_breezy_html({author: "john smith"})
|
68
|
+
assert_breezy_html({author: "john smith"}, screen: :implied_render_with_breezy)
|
69
69
|
end
|
70
70
|
|
71
71
|
test "simple render with breezy via get js" do
|
@@ -99,16 +99,16 @@ class RenderTest < ActionController::TestCase
|
|
99
99
|
|
100
100
|
private
|
101
101
|
|
102
|
-
def assert_breezy_html(content)
|
102
|
+
def assert_breezy_html(content, opts={})
|
103
103
|
assert_response 200
|
104
|
-
|
105
|
-
assert_equal "<html><head><script type='text/javascript'>Breezy.replace((function(){var joints={};var cache={};var defers=[];return ({\"data\":#{content.to_json},\"screen\":\"
|
104
|
+
|
105
|
+
assert_equal "<html><head><script type='text/javascript'>Breezy.replace((function(){var joints={};var cache={};var defers=[];return ({\"data\":#{content.to_json},\"screen\":\"render/#{opts[:screen].to_s}\",\"csrf_token\":\"secret\",\"assets\":[\"/app.js\"],\"joints\":joints,\"defers\":defers});})());</script></head><body></body></html>", @response.body
|
106
106
|
assert_equal 'text/html', @response.content_type
|
107
107
|
end
|
108
108
|
|
109
109
|
def assert_breezy_js(content)
|
110
110
|
assert_response 200
|
111
|
-
assert_equal '(function(){var joints={};var cache={};var defers=[];return ({"data":' + content.to_json + ',"screen":"
|
111
|
+
assert_equal '(function(){var joints={};var cache={};var defers=[];return ({"data":' + content.to_json + ',"screen":"render/action","csrf_token":"secret","assets":["/app.js"],"joints":joints,"defers":defers});})()', @response.body
|
112
112
|
assert_equal 'text/javascript', @response.content_type
|
113
113
|
end
|
114
114
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: breezy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johny Ho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 0.6.0
|
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: 0.
|
40
|
+
version: 0.6.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: webpacker
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|