appril-cli 0.2.3 → 0.2.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6fce6c027dc0c76302855dffb23a042f0bd5763
4
- data.tar.gz: 4c8fbd6935a8d4255138b19f02ea85a10254d5d2
3
+ metadata.gz: f4f003f894639dd5000c890286eee557d61ac557
4
+ data.tar.gz: 5f0240d5e5325d50795c949348b0c6eb41bc0fc1
5
5
  SHA512:
6
- metadata.gz: 3046ef4df845c82e265b35fdf0d6e83b2fed4860074848c7d2f9b4fbf9d237d176f59a6059cdb408bc218ad2486178ef581affd6523fe5a44b4ad50f2af90714
7
- data.tar.gz: de4057dc75eee1af3c25c7415d3399068cb76824fb7ec8f82ee4620f00564d5a451ef833b2a76fa00275a3b43620f5620464420eebadde720cae620e1702efd0
6
+ metadata.gz: 94416ea1fde160d5c67958797beba36756619a36556797611d47b5e2dda4be0f9a7006a1b444792465d1e34595274d6be9bc0ef6a29829e76e4a8209df0bbcb8
7
+ data.tar.gz: cc66b95a1d2eba91759224eafd6926bc80e3a6871483235b908ed5ecd15e839f2cc95a2c0eddb2564588ea38eeaed3d339dbc5c0602cf4cc5d19e57838f01fd8
data/app/Gemfile CHANGED
@@ -1,6 +1,11 @@
1
1
  source 'https://rubygems.org'
2
- # keep this line
3
- eval File.read(File.expand_path('../core/Gemfile', __FILE__))
2
+
3
+ begin # keep these gems
4
+ gem 'appril', '~> 0.2', '>= 0.2.5'
5
+ gem 'rocketio', '~> 0.4', '>= 0.4.2'
6
+ gem 'rocketio-views', '~> 0.4'
7
+ gem 'tubesock', '~> 0.2'
8
+ end
4
9
 
5
10
  # add your gems here
6
11
  gem 'liquid', '~> 3'
data/app/base/app.js CHANGED
@@ -1,33 +1,22 @@
1
- import {merge, cloneDeep} from 'lodash'
2
- import deep_freeze from 'deep-freeze-strict'
3
- import Router from 'appril/router'
4
- import Vue from 'vue/dist/vue.js'
5
- import Vuex from 'vuex'
6
- import VuexLogger from 'vuex/logger'
7
1
 
8
- import {server_url, client_url, default_api} from 'app/config.js'
2
+ const FRESH_STATE_FOR_EVERY_COMPONENT = true
3
+ const DEVELOPMENT = APP_ENV === 'development'
9
4
 
10
- import {state, mutations} from 'appril/store'
5
+ import {merge, reduce, cloneDeep} from 'lodash'
6
+ import Vue from 'vue'
7
+ import Vuex from 'vuex'
8
+ import VuexLogger from 'vuex/logger'
9
+ import Alert from 'appril-alert'
11
10
  import {vue_plugin, vuex_plugins} from 'appril/plugins'
12
- import components from 'appril/components'
13
- import async_components_loader from 'appril/components/async_loader'
14
- import ApiBuilder from 'appril/api'
15
- import Layout from 'templates/layouts/app.html'
11
+ import {state, mutations} from 'appril/store'
12
+ import {server_url, client_url, default_api} from 'app/config.json'
16
13
 
17
14
  /** delete or comment this line if your components piped through Crudle
18
15
  import {state as crudle_state, mutations as crudle_mutations} from 'crudle/store'
19
16
  merge(state, crudle_state)
20
17
  merge(mutations, crudle_mutations) /* */
21
18
 
22
- const FRESH_STATE_FOR_EVERY_COMPONENT = false
23
- const DEVELOPMENT = APP_ENV === 'development'
24
-
25
19
  Vue.use(Vuex)
26
- if (DEVELOPMENT) {
27
- Vue.config.devtools = true
28
- vuex_plugins.push(VuexLogger())
29
- }
30
-
31
20
  const store = new Vuex.Store({
32
21
  state: cloneDeep(state),
33
22
  mutations,
@@ -35,62 +24,102 @@ const store = new Vuex.Store({
35
24
  plugins: vuex_plugins
36
25
  })
37
26
 
38
- const api = ApiBuilder(default_api, store)
27
+ const api_callbacks = {
28
+
29
+ // do whatever with params Object just before sending to server
30
+ on_request(params) {
31
+ // if (store.state.__ENV__.user && store.state.__ENV__.user.authorization_token) {
32
+ // params.__authorization_token__ = store.state.__ENV__.user.authorization_token
33
+ // }
34
+ },
39
35
 
40
- const initialize = function(data) {
41
- deep_freeze(data)
36
+ // do whatever with data received from server just before entering success callback
37
+ on_response(response) {
38
+ // it is possible only to update the response content, not the type
39
+ },
42
40
 
43
- if (data.user) {
44
- store.commit('__USER__', data.user)
41
+ // to be used for requests that does not define a error handler
42
+ on_error(error) {
43
+ Alert.error(error)
45
44
  }
45
+ }
46
46
 
47
- // /* uncomment this line to disable RealTime Communication Protocol
48
- api.rtcp.connect({
49
- // make sure this url to match RTCPController url
50
- path: server_url + '__rtcp__',
51
- // disconnect if user is idle for N seconds
52
- disconnect_after: 60
53
- }) /* */
47
+ // RealTime Communication Protocol
48
+ import RTCP from 'appril/rtcp'
49
+ const rtcp = new RTCP(api_callbacks)
54
50
 
55
- Vue.use(vue_plugin({
56
- ...data,
57
- api,
58
- components
59
- }))
51
+ rtcp.connect({
52
+ // make sure this URL is matching RTCPController URL
53
+ path: server_url + '__rtcp__',
54
+ // disconnect if user is idle for N seconds (it will reconnect on user activity)
55
+ disconnect_after: 60
56
+ })
60
57
 
61
- const router = new Router(components)
58
+ import {urlify} from 'appril-utils'
59
+ import api_builder from 'appril/api'
60
+ const components = reduce(require('app/components.json'), function(map,component) {
61
+ component.url = urlify(component.url)
62
+ component.xhr = api_builder.xhr(component, api_callbacks)
63
+ component.rtcp = api_builder.rtcp(component, rtcp)
64
+ Object.defineProperty(component, 'api', {get() {return component[default_api]}})
65
+ map[component.name] = component
66
+ return map
67
+ }, {})
62
68
 
63
- new Vue({
64
- store,
65
- el: '#app',
66
- template: Layout,
67
- components: async_components_loader(components, client_url + APP_ENV, api[default_api])
68
- })
69
+ const handle_state = function(component, env) {
69
70
 
70
- router.component_matched = function(component) {
71
-
72
- if (store.state.__ROOT_COMPONENT__) {
73
- if (store.state.__ROOT_COMPONENT__ !== component.name) {
74
- // component switched
75
- if (FRESH_STATE_FOR_EVERY_COMPONENT) {
76
- // start with a fresh state
77
- store.replaceState(merge(cloneDeep(state), {__ROOT_COMPONENT__: component.name}))
78
- } else {
79
- // just update __ROOT_COMPONENT__
80
- store.commit('__ROOT_COMPONENT__', component.name)
81
- }
82
- }
83
- } else {
84
- store.replaceState(merge(cloneDeep(state), {__ROOT_COMPONENT__: component.name}))
85
- }
71
+ if (!store.state.__ROOT_COMPONENT__)
72
+ return store.replaceState(merge(cloneDeep(state), {__ROOT_COMPONENT__: component.name, __ENV__: env}))
86
73
 
87
- }
74
+ if (store.state.__ROOT_COMPONENT__ === component.name)
75
+ return // do nothing if component did not change
88
76
 
89
- router.start()
77
+ if (FRESH_STATE_FOR_EVERY_COMPONENT)
78
+ return store.replaceState(merge(cloneDeep(state), {__ROOT_COMPONENT__: component.name, __ENV__: env}))
79
+
80
+ store.commit('__ROOT_COMPONENT__', component.name)
81
+ store.commit('__ENV__', env)
90
82
  }
91
83
 
84
+ import Router from 'appril/router'
85
+ const router = new Router(components)
86
+
87
+ router.component_matched = function(component) {
88
+ if (component.api._env) {
89
+ component.api._env().get({
90
+ success(env) { handle_state(component, env) }
91
+ })
92
+ } else {
93
+ handle_state(component)
94
+ }
95
+ }
96
+
97
+ import load_component from 'appril/load-component'
98
+ import deploy_component from './component'
99
+ const component_loaders = reduce(components, function(map, component) {
100
+ map[component.name] = function(resolve, reject) {
101
+ load_component(component, client_url + APP_ENV, function(constructor) {
102
+ resolve(deploy_component(components, component, constructor))
103
+ }, reject)
104
+ }
105
+ return map
106
+ }, {})
107
+
92
108
  document.addEventListener('DOMContentLoaded', function() {
93
- api.Index._env().get({
94
- success: initialize
109
+
110
+ Vue.use(vue_plugin({components, rtcp}))
111
+
112
+ if (DEVELOPMENT) {
113
+ Vue.config.devtools = true
114
+ vuex_plugins.push(VuexLogger())
115
+ }
116
+
117
+ new Vue({
118
+ store,
119
+ el: '#app',
120
+ template: require('templates/layouts/app.html'),
121
+ components: component_loaders
95
122
  })
123
+
124
+ router.start()
96
125
  })
@@ -1,10 +1,9 @@
1
1
  import {find} from 'lodash'
2
- import Vue from 'vue/dist/vue.js'
2
+ import Vue from 'vue'
3
3
 
4
4
  import 'assets/styles'
5
- // import 'appril-polyfills'
6
5
 
7
- /** default deployer */
6
+ // /** default deployer
8
7
  export default function(components, component, constructor) {
9
8
  return constructor
10
9
  } /* */
@@ -14,12 +13,10 @@ import Crudle from 'crudle'
14
13
  export default function(components, component, constructor) {
15
14
  Crudle.Menu = {
16
15
  template: require('templates/menu'),
17
- data() {
18
- return {
19
- ...components,
20
- is_active(...a) {return find(a, (c) => c.url == component.url) ? true : false}
21
- }
22
- }
16
+ data() {return {
17
+ ...components,
18
+ is_active(...a) {return find(a, (c) => c.url == component.url) ? true : false}
19
+ }}
23
20
  }
24
21
  return Crudle(constructor)
25
22
  } /* */
@@ -1,16 +1,3 @@
1
1
  class Index < BaseController
2
2
  map Cfg.server_url
3
-
4
- # environmental data to be sent to client at App initialization
5
- def _env
6
- user = user? # see BaseController#user?
7
- {
8
- user: user
9
- }
10
- end
11
-
12
- # data to be sent to client at Component initialization
13
- def _options
14
- {}
15
- end
16
3
  end
@@ -0,0 +1 @@
1
+ // auto-generated file, do not edit
@@ -0,0 +1,7 @@
1
+ export function __ROOT_COMPONENT__(state, component) {
2
+ state.__ROOT_COMPONENT__ = component
3
+ }
4
+
5
+ export function __ENV__(state, env) {
6
+ state.__ENV__ = env
7
+ }
@@ -0,0 +1,4 @@
1
+ export default {
2
+ __ROOT_COMPONENT__: null,
3
+ __ENV__: {}
4
+ }
data/app/package.json CHANGED
@@ -3,7 +3,8 @@
3
3
  "version": "0.0.0",
4
4
  "description": "...",
5
5
  "devDependencies": {
6
- "appril": ">= 0.4.1",
6
+ "appril": ">= 0.5.1",
7
+ "appril-alert": ">= 0.0.5",
7
8
  "appril-polyfills": ">= 0.0.2",
8
9
  "appril-url": ">= 0.0.5",
9
10
  "appril-utils": ">= 0.1.5",
data/app/webpack/alias.js CHANGED
@@ -6,5 +6,6 @@ module.exports = {
6
6
  assets: 'base/assets',
7
7
  components: 'base/components',
8
8
  helpers: 'base/helpers',
9
- templates: 'base/templates'
9
+ templates: 'base/templates',
10
+ vue: 'vue/dist/vue.js'
10
11
  }
data/app/webpack/entry.js CHANGED
@@ -1,3 +1,3 @@
1
- const config = require('../config.js')
1
+ const config = require('../config.json')
2
2
 
3
3
  module.exports = config.webpack_entries
@@ -1,5 +1,5 @@
1
1
  const path = require('path')
2
- const config = require('../config.js')
2
+ const config = require('../config.json')
3
3
 
4
4
  module.exports = {
5
5
  path: path.join(config.build_path, config.client_url, APP_ENV),
@@ -21,18 +21,15 @@ const plugins = [
21
21
  ]
22
22
 
23
23
  if (APP_ENV === 'production') {
24
- plugins.push(
25
- new webpack.optimize.UglifyJsPlugin({
26
- compress: { warnings: false },
27
- screwIE8: true,
28
- sourceMap: false,
29
- mangle: true
30
- })
31
- ),
32
-
33
- plugins.push(
34
- new OptimizeCssAssetsPlugin
35
- )
24
+
25
+ plugins.push(new webpack.optimize.UglifyJsPlugin({
26
+ compress: { warnings: false },
27
+ screwIE8: true,
28
+ sourceMap: false,
29
+ mangle: true
30
+ }))
31
+
32
+ plugins.push(new OptimizeCssAssetsPlugin)
36
33
  }
37
34
 
38
35
  module.exports = plugins
@@ -1,5 +1,5 @@
1
1
  module Appril
2
2
  class CLI
3
- VERSION = '0.2.3'.freeze
3
+ VERSION = '0.2.6'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appril-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Slee Woo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-05 00:00:00.000000000 Z
11
+ date: 2016-08-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Appril CLI
14
14
  email:
@@ -27,8 +27,8 @@ files:
27
27
  - app/base/app.js
28
28
  - app/base/assets/styles.css
29
29
  - app/base/boot.rb
30
+ - app/base/component.js
30
31
  - app/base/components/base_controller.rb
31
- - app/base/components/deploy.js
32
32
  - app/base/components/index/index.js
33
33
  - app/base/components/index/server.rb
34
34
  - app/base/components/index/template.html
@@ -37,6 +37,9 @@ files:
37
37
  - app/base/helpers/index.js
38
38
  - app/base/load.rb
39
39
  - app/base/models/base_model.rb
40
+ - app/base/store/modules.js
41
+ - app/base/store/mutations.js
42
+ - app/base/store/state.js
40
43
  - app/base/templates/layout.liquid
41
44
  - app/base/templates/layouts/app.html
42
45
  - app/compiled/.ignore
@@ -47,7 +50,6 @@ files:
47
50
  - app/config/env/production.yml
48
51
  - app/config/env/stage.yml
49
52
  - app/config/env/test.yml
50
- - app/core/Gemfile
51
53
  - app/core/boot.rb
52
54
  - app/core/generate_configs.rb
53
55
  - app/core/load.rb
@@ -111,5 +113,5 @@ rubyforge_project:
111
113
  rubygems_version: 2.5.1
112
114
  signing_key:
113
115
  specification_version: 4
114
- summary: '["appril-cli-0.2.3", "Appril CLI"]'
116
+ summary: '["appril-cli-0.2.6", "Appril CLI"]'
115
117
  test_files: []
data/app/core/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- # do NOT edit this file, edit ../Gemfile instead
2
- gem 'appril', '>= 0.2.2'
3
- gem 'rocketio', '>= 0.4.1'
4
- gem 'rocketio-views', '>= 0.4'
5
- gem 'tubesock', '>= 0.2.7'