vue_rails 0.1.1

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.
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 1.17.2
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at jiyr@wfl-ischool.cn. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in vue_rails.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,137 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ vue_rails (0.1.1)
5
+ execjs
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (5.2.2)
11
+ actionpack (= 5.2.2)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailer (5.2.2)
15
+ actionpack (= 5.2.2)
16
+ actionview (= 5.2.2)
17
+ activejob (= 5.2.2)
18
+ mail (~> 2.5, >= 2.5.4)
19
+ rails-dom-testing (~> 2.0)
20
+ actionpack (5.2.2)
21
+ actionview (= 5.2.2)
22
+ activesupport (= 5.2.2)
23
+ rack (~> 2.0)
24
+ rack-test (>= 0.6.3)
25
+ rails-dom-testing (~> 2.0)
26
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
27
+ actionview (5.2.2)
28
+ activesupport (= 5.2.2)
29
+ builder (~> 3.1)
30
+ erubi (~> 1.4)
31
+ rails-dom-testing (~> 2.0)
32
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
33
+ activejob (5.2.2)
34
+ activesupport (= 5.2.2)
35
+ globalid (>= 0.3.6)
36
+ activemodel (5.2.2)
37
+ activesupport (= 5.2.2)
38
+ activerecord (5.2.2)
39
+ activemodel (= 5.2.2)
40
+ activesupport (= 5.2.2)
41
+ arel (>= 9.0)
42
+ activestorage (5.2.2)
43
+ actionpack (= 5.2.2)
44
+ activerecord (= 5.2.2)
45
+ marcel (~> 0.3.1)
46
+ activesupport (5.2.2)
47
+ concurrent-ruby (~> 1.0, >= 1.0.2)
48
+ i18n (>= 0.7, < 2)
49
+ minitest (~> 5.1)
50
+ tzinfo (~> 1.1)
51
+ arel (9.0.0)
52
+ builder (3.2.3)
53
+ concurrent-ruby (1.1.4)
54
+ crass (1.0.4)
55
+ erubi (1.8.0)
56
+ execjs (2.7.0)
57
+ globalid (0.4.2)
58
+ activesupport (>= 4.2.0)
59
+ i18n (1.5.3)
60
+ concurrent-ruby (~> 1.0)
61
+ loofah (2.2.3)
62
+ crass (~> 1.0.2)
63
+ nokogiri (>= 1.5.9)
64
+ mail (2.7.1)
65
+ mini_mime (>= 0.1.1)
66
+ marcel (0.3.3)
67
+ mimemagic (~> 0.3.2)
68
+ method_source (0.9.2)
69
+ mimemagic (0.3.3)
70
+ mini_mime (1.0.1)
71
+ mini_portile2 (2.4.0)
72
+ minitest (5.11.3)
73
+ nio4r (2.3.1)
74
+ nokogiri (1.10.1)
75
+ mini_portile2 (~> 2.4.0)
76
+ rack (2.0.6)
77
+ rack-proxy (0.6.5)
78
+ rack
79
+ rack-test (1.1.0)
80
+ rack (>= 1.0, < 3)
81
+ rails (5.2.2)
82
+ actioncable (= 5.2.2)
83
+ actionmailer (= 5.2.2)
84
+ actionpack (= 5.2.2)
85
+ actionview (= 5.2.2)
86
+ activejob (= 5.2.2)
87
+ activemodel (= 5.2.2)
88
+ activerecord (= 5.2.2)
89
+ activestorage (= 5.2.2)
90
+ activesupport (= 5.2.2)
91
+ bundler (>= 1.3.0)
92
+ railties (= 5.2.2)
93
+ sprockets-rails (>= 2.0.0)
94
+ rails-dom-testing (2.0.3)
95
+ activesupport (>= 4.2.0)
96
+ nokogiri (>= 1.6)
97
+ rails-html-sanitizer (1.0.4)
98
+ loofah (~> 2.2, >= 2.2.2)
99
+ railties (5.2.2)
100
+ actionpack (= 5.2.2)
101
+ activesupport (= 5.2.2)
102
+ method_source
103
+ rake (>= 0.8.7)
104
+ thor (>= 0.19.0, < 2.0)
105
+ rake (10.5.0)
106
+ sprockets (3.7.2)
107
+ concurrent-ruby (~> 1.0)
108
+ rack (> 1, < 3)
109
+ sprockets-rails (3.2.1)
110
+ actionpack (>= 4.0)
111
+ activesupport (>= 4.0)
112
+ sprockets (>= 3.0.0)
113
+ thor (0.20.3)
114
+ thread_safe (0.3.6)
115
+ tzinfo (1.2.5)
116
+ thread_safe (~> 0.1)
117
+ webpacker (3.5.5)
118
+ activesupport (>= 4.2)
119
+ rack-proxy (>= 0.6.1)
120
+ railties (>= 4.2)
121
+ websocket-driver (0.7.0)
122
+ websocket-extensions (>= 0.1.0)
123
+ websocket-extensions (0.1.3)
124
+
125
+ PLATFORMS
126
+ ruby
127
+
128
+ DEPENDENCIES
129
+ bundler (>= 1.2.2)
130
+ minitest (~> 5.0)
131
+ rails (>= 5.1)
132
+ rake (~> 10.0)
133
+ vue_rails!
134
+ webpacker
135
+
136
+ BUNDLED WITH
137
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 纪亚荣
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,279 @@
1
+ # VueRails
2
+
3
+ ## Get started with Webpacker
4
+ #### add webpacker and vue_rails to your gemfile
5
+ ```ruby
6
+ gem 'webpacker'
7
+ gem 'vue_rails'
8
+ ```
9
+
10
+ #### run installers
11
+ ```shell
12
+ $ bundle install
13
+ $ rails webpacker:install
14
+ $ rails webpacker:install:vue
15
+ $ rails generate vue:install
16
+ ```
17
+
18
+ #### confirm your webpacker source_entry path
19
+ ```
20
+ |-- app
21
+ |-- javascript
22
+ |-- packs
23
+ |-- application.js
24
+ |-- vue_server_render.js
25
+ |-- vue_components
26
+ |-- hello.vue
27
+ |-- rails_vue_ujs.js
28
+ ```
29
+ #### all the vue components should be initialized in `vue_componects`
30
+
31
+ ## Basic Usage
32
+
33
+ **1. add javascript_pack_tag to application.html**
34
+ ```ruby
35
+ <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
36
+ ```
37
+ **2. generate a controller and view**
38
+
39
+ example:
40
+ ```shell
41
+ $ rails generate controller home index
42
+ ```
43
+ and don't forget the router config!
44
+
45
+ **3. add vue_components in your home/index.html**
46
+ ```ruby
47
+ <%= vue_component("hello") %>
48
+ ```
49
+
50
+ multiple components render is also work!
51
+ ```
52
+ <%= vue_component("hello") %>
53
+ <%= vue_component("hello") %>
54
+ <%= vue_component("hello") %>
55
+ ```
56
+
57
+ **4. open the browser and check it, it should been works!**
58
+
59
+ ## Advanced Usage
60
+
61
+ ### pass props to your components
62
+ ```ruby
63
+ <%= vue_component("hello", {foo: 'bar'}) %>
64
+ ```
65
+ in your component hello.vue:
66
+ ```vue
67
+ <template>
68
+ <div id="app">
69
+ <p>{{ outside.foo }}</p>
70
+ </div>
71
+ </template>
72
+
73
+ <script>
74
+ export default {
75
+ props: ['outside'],
76
+ data: function () {
77
+ return {
78
+ message: "Hello Vue!"
79
+ }
80
+ }
81
+ }
82
+ </script>
83
+ ```
84
+
85
+ hash or array is also works
86
+ ```ruby
87
+ <%= vue_component("hello", {foo: {name: 'Peter'}}) %>
88
+ ```
89
+
90
+ ```vue
91
+ <template>
92
+ <div id="app">
93
+ <p>{{ outside.foo.name }}</p>
94
+ </div>
95
+ </template>
96
+
97
+ <script>
98
+ export default {
99
+ props: ['outside'],
100
+ data: function () {
101
+ return {
102
+ message: "Hello Vue!"
103
+ }
104
+ }
105
+ }
106
+ </script>
107
+ ```
108
+
109
+ ```ruby
110
+ <%= vue_component("hello", {foo: [1,2,3]}) %>
111
+ ```
112
+
113
+ ```vue
114
+ <template>
115
+ <div id="app">
116
+ <template v-for="i in outside.foo">
117
+ <div>{{i}}</div>
118
+ </template>
119
+ <p>{{ outside.foo.name }}</p>
120
+ </div>
121
+ </template>
122
+
123
+ <script>
124
+ export default {
125
+ props: ['outside'],
126
+ data: function () {
127
+ return {
128
+ message: "Hello Vue!"
129
+ }
130
+ }
131
+ }
132
+ </script>
133
+ ```
134
+
135
+ ### server side render
136
+ **If you're just a component for rendering small parts, you should not use server side render!**
137
+
138
+ with options `prerender`, server side will prerender a dom before vue components initialize in client side
139
+
140
+ ```
141
+ <%= vue_component("hello", {foo: [1,2,3]}, {prerender: true}) %>
142
+ ```
143
+
144
+
145
+ ### server side render with vue-router
146
+ ```shell
147
+ $ yarn add vue-router
148
+ ```
149
+ in both application.js and vue_server_render.js
150
+ ```js
151
+ import VueRouter from 'vue-router';
152
+
153
+ RailsVueUJS.use(VueRouter);
154
+
155
+ ```
156
+
157
+ and your vue component
158
+
159
+ ```html
160
+ <template>
161
+ <div class="container">
162
+ <div class="content">
163
+ <router-view :outside="outside"></router-view>
164
+ </div>
165
+ </div>
166
+ </template>
167
+
168
+ <script>
169
+ import VueRouter from 'vue-router';
170
+ import PostList from './posts/index';
171
+ import PostDetail from './posts/show';
172
+ import newPost from './posts/new';
173
+ import EditPost from './posts/edit';
174
+
175
+ const routes = [
176
+ {
177
+ path: '/',
178
+ component: PostList,
179
+ name: 'post_index',
180
+ props: true
181
+ },
182
+ {
183
+ path: '/posts/new',
184
+ component: newPost,
185
+ name: 'new_post'
186
+ },
187
+ {
188
+ path: '/posts/edit/:id',
189
+ component: EditPost,
190
+ name: 'edit_post'
191
+ },
192
+ {
193
+ path: '/posts/:id',
194
+ component: PostDetail,
195
+ name: 'post_detail'
196
+ }
197
+ ];
198
+
199
+ const router = new VueRouter({
200
+ mode: 'history',
201
+ routes
202
+ });
203
+
204
+ export default {
205
+ props: ['outside'],
206
+ router
207
+ };
208
+ </script>
209
+ ```
210
+
211
+ option prerender can receive a path for vue router
212
+ ```html
213
+ <%= vue_component("hello", {foo: [1,2,3]}, {prerender: request.path}) %>
214
+ ```
215
+
216
+ in your routes.rb
217
+ ```ruby
218
+ get '*path', to: 'home#index'
219
+ ```
220
+
221
+ ### server side render with vuex
222
+ ```shell
223
+ $ yarn add vuex
224
+ ```
225
+
226
+ initialize a store
227
+
228
+ ```js
229
+ import Vue from 'vue'
230
+ import Vuex from 'vuex';
231
+
232
+ Vue.use(Vuex);
233
+ const store = new Vuex.Store({
234
+ state: {
235
+ currentUser: {},
236
+ hasLogin: false
237
+ }
238
+ });
239
+
240
+ export default store;
241
+ ```
242
+
243
+ in both application.js and vue_server_render.js
244
+ ```js
245
+ import VueRouter from 'vue-router';
246
+ import Vuex from 'vuex';
247
+ import store from "../vue_components/store";
248
+
249
+ RailsVueUJS.use(VueRouter, Vuex);
250
+ RailsVueUJS.initializeVuexStore(store);
251
+ ...
252
+ ```
253
+
254
+ in your html file
255
+ ```html
256
+ <%= vue_component("hello", {foo: [1,2,3]}, {prerender: true, state: {
257
+ hasLogin: true
258
+ }}) %>
259
+ ```
260
+
261
+ with option `state`, it will replace your vuex state, for more information see the doc with vuex
262
+
263
+ in your component
264
+ ```html
265
+ ...
266
+ <div v-if="$store.state.hasLogin">
267
+ <a href="/users/logout">logout</a>
268
+ </div>
269
+ ...
270
+ ```
271
+
272
+
273
+ ## License
274
+
275
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
276
+
277
+ ## Code of Conduct
278
+
279
+ Everyone interacting in the VueRails project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/vue_rails/blob/master/CODE_OF_CONDUCT.md).