appril-cli 0.2.6 → 0.2.7

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: f4f003f894639dd5000c890286eee557d61ac557
4
- data.tar.gz: 5f0240d5e5325d50795c949348b0c6eb41bc0fc1
3
+ metadata.gz: aaf51693e976f3705b533a067f6c78f7fd9e6c20
4
+ data.tar.gz: 7c0f82b8545055cc268cba2ec510cac3a9611441
5
5
  SHA512:
6
- metadata.gz: 94416ea1fde160d5c67958797beba36756619a36556797611d47b5e2dda4be0f9a7006a1b444792465d1e34595274d6be9bc0ef6a29829e76e4a8209df0bbcb8
7
- data.tar.gz: cc66b95a1d2eba91759224eafd6926bc80e3a6871483235b908ed5ecd15e839f2cc95a2c0eddb2564588ea38eeaed3d339dbc5c0602cf4cc5d19e57838f01fd8
6
+ metadata.gz: 5ef58942e1a8397f0ffbffa97f0a32598beec89c67558ebdbc7fde090e60e794a5e371d2d4ca09665533c14161251351244f203c1c8229ded95e649bcfc3f142
7
+ data.tar.gz: d8598cb33bd2bb245e744225b1edca5e2adb46e32e03f6d14e077a9a57e7f09ccda4a08af4260b042e97b5c896612c0a5a153110474d93c2729419fb8929a923
data/app/Gemfile CHANGED
@@ -2,7 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  begin # keep these gems
4
4
  gem 'appril', '~> 0.2', '>= 0.2.5'
5
- gem 'rocketio', '~> 0.4', '>= 0.4.2'
5
+ gem 'rocketio', '~> 0.4', '>= 0.4.3'
6
6
  gem 'rocketio-views', '~> 0.4'
7
7
  gem 'tubesock', '~> 0.2'
8
8
  end
data/app/base/app.js CHANGED
@@ -1,22 +1,29 @@
1
1
 
2
- const FRESH_STATE_FOR_EVERY_COMPONENT = true
3
2
  const DEVELOPMENT = APP_ENV === 'development'
4
3
 
5
- import {merge, reduce, cloneDeep} from 'lodash'
4
+ import {merge, map, reduce, filter, cloneDeep} from 'lodash'
6
5
  import Vue from 'vue'
6
+ import VueRouter from 'vue-router'
7
7
  import Vuex from 'vuex'
8
8
  import VuexLogger from 'vuex/logger'
9
9
  import Alert from 'appril-alert'
10
10
  import {vue_plugin, vuex_plugins} from 'appril/plugins'
11
11
  import {state, mutations} from 'appril/store'
12
- import {server_url, client_url, default_api} from 'app/config.json'
12
+ import config from 'app/appril.json'
13
13
 
14
14
  /** delete or comment this line if your components piped through Crudle
15
15
  import {state as crudle_state, mutations as crudle_mutations} from 'crudle/store'
16
16
  merge(state, crudle_state)
17
17
  merge(mutations, crudle_mutations) /* */
18
18
 
19
+ Vue.use(VueRouter)
19
20
  Vue.use(Vuex)
21
+
22
+ if (DEVELOPMENT) {
23
+ Vue.config.devtools = true
24
+ vuex_plugins.push(VuexLogger())
25
+ }
26
+
20
27
  const store = new Vuex.Store({
21
28
  state: cloneDeep(state),
22
29
  mutations,
@@ -25,18 +32,11 @@ const store = new Vuex.Store({
25
32
  })
26
33
 
27
34
  const api_callbacks = {
28
-
29
35
  // 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
- },
36
+ on_request(params) {},
35
37
 
36
38
  // 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
- },
39
+ on_response(response) {},
40
40
 
41
41
  // to be used for requests that does not define a error handler
42
42
  on_error(error) {
@@ -50,76 +50,55 @@ const rtcp = new RTCP(api_callbacks)
50
50
 
51
51
  rtcp.connect({
52
52
  // make sure this URL is matching RTCPController URL
53
- path: server_url + '__rtcp__',
53
+ path: config.server_url + '__rtcp__',
54
54
  // disconnect if user is idle for N seconds (it will reconnect on user activity)
55
55
  disconnect_after: 60
56
56
  })
57
57
 
58
58
  import {urlify} from 'appril-utils'
59
59
  import api_builder from 'appril/api'
60
- const components = reduce(require('app/components.json'), function(map,component) {
60
+
61
+ const components = reduce(config.components, function(map,component) {
61
62
  component.url = urlify(component.url)
62
63
  component.xhr = api_builder.xhr(component, api_callbacks)
63
64
  component.rtcp = api_builder.rtcp(component, rtcp)
64
- Object.defineProperty(component, 'api', {get() {return component[default_api]}})
65
+ Object.defineProperty(component, 'api', {get() {return component[config.default_api]}})
65
66
  map[component.name] = component
66
67
  return map
67
68
  }, {})
68
69
 
69
- const handle_state = function(component, env) {
70
-
71
- if (!store.state.__ROOT_COMPONENT__)
72
- return store.replaceState(merge(cloneDeep(state), {__ROOT_COMPONENT__: component.name, __ENV__: env}))
73
-
74
- if (store.state.__ROOT_COMPONENT__ === component.name)
75
- return // do nothing if component did not change
76
-
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)
82
- }
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
70
  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
71
 
108
- document.addEventListener('DOMContentLoaded', function() {
72
+ const router = new VueRouter({
73
+ mode: 'history',
74
+ base: __dirname,
75
+ routes: map(filter(components, 'entry_path'), function(component) {
76
+ return {
77
+ name: component.name,
78
+ path: component.url_pattern,
79
+ component: (resolve) => System.import(`components/${component.entry_path}/index.js`).then(function(constructor) {
80
+ if (component.api._env) {
81
+ component.api._env().get({
82
+ success(env) {
83
+ store.commit('__SET_ENV__', {component: component.name, env})
84
+ resolve(deploy_component(components, component, constructor.default))
85
+ }
86
+ })
87
+ } else {
88
+ resolve(deploy_component(components, component, constructor.default))
89
+ }
90
+ })
91
+ }
92
+ })
93
+ })
109
94
 
95
+ document.addEventListener('DOMContentLoaded', function() {
110
96
  Vue.use(vue_plugin({components, rtcp}))
111
97
 
112
- if (DEVELOPMENT) {
113
- Vue.config.devtools = true
114
- vuex_plugins.push(VuexLogger())
115
- }
116
-
117
98
  new Vue({
99
+ router,
118
100
  store,
119
101
  el: '#app',
120
- template: require('templates/layouts/app.html'),
121
- components: component_loaders
102
+ template: require('templates/layouts/app.html')
122
103
  })
123
-
124
- router.start()
125
104
  })
@@ -1,7 +1,5 @@
1
1
  import {find} from 'lodash'
2
- import Vue from 'vue'
3
-
4
- import 'assets/styles'
2
+ import 'assets/app'
5
3
 
6
4
  // /** default deployer
7
5
  export default function(components, component, constructor) {
@@ -1,5 +1,6 @@
1
1
  class BaseController < Appril::BaseController
2
2
  include Helpers
3
+ include UserHelpers
3
4
 
4
5
  map Cfg.server_url
5
6
 
@@ -1,4 +1,7 @@
1
1
  class RTCPController < Appril::RTCPController
2
+ include Helpers
3
+ include UserHelpers
4
+
2
5
  map BaseController.url('__rtcp__')
3
6
  import :error_handlers, from: BaseController
4
7
 
@@ -0,0 +1,7 @@
1
+ module UserHelpers
2
+
3
+ def user?
4
+ return unless authorization_token = params[:__authorization_token__] || cookies[:__authorization_token__]
5
+ # fetch user using authorization_token
6
+ end
7
+ end
@@ -1,7 +1,4 @@
1
- export function __ROOT_COMPONENT__(state, component) {
2
- state.__ROOT_COMPONENT__ = component
3
- }
4
1
 
5
- export function __ENV__(state, env) {
6
- state.__ENV__ = env
2
+ export function __SET_ENV__({__ENV__}, {component, env}) {
3
+ __ENV__[component] = env
7
4
  }
@@ -1,4 +1,3 @@
1
1
  export default {
2
- __ROOT_COMPONENT__: null,
3
2
  __ENV__: {}
4
3
  }
@@ -1,3 +1,3 @@
1
1
  <div>
2
- <component :is="$store.state.__ROOT_COMPONENT__"></component>
2
+ <router-view></router-view>
3
3
  </div>
data/app/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "version": "0.0.0",
4
4
  "description": "...",
5
5
  "devDependencies": {
6
- "appril": ">= 0.5.1",
6
+ "appril": ">= 0.5.4",
7
7
  "appril-alert": ">= 0.0.5",
8
8
  "appril-polyfills": ">= 0.0.2",
9
9
  "appril-url": ">= 0.0.5",
data/app/webpack/entry.js CHANGED
@@ -1,3 +1,8 @@
1
- const config = require('../config.json')
1
+ const reduce = require('lodash/reduce')
2
+ const filter = require('lodash/filter')
3
+ const config = require('../appril.json')
2
4
 
3
- module.exports = config.webpack_entries
5
+ module.exports = reduce(filter(config.components, 'entry_path'), function(entries,component) {
6
+ entries[component.name] = 'base/components/' + component.entry_path + '/index.js'
7
+ return entries
8
+ }, {app: 'base/app.js'})
@@ -1,5 +1,5 @@
1
1
  const path = require('path')
2
- const config = require('../config.json')
2
+ const config = require('../appril.json')
3
3
 
4
4
  module.exports = {
5
5
  path: path.join(config.build_path, config.client_url, APP_ENV),
@@ -1,5 +1,5 @@
1
1
  module Appril
2
2
  class CLI
3
- VERSION = '0.2.6'.freeze
3
+ VERSION = '0.2.7'.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.6
4
+ version: 0.2.7
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-10 00:00:00.000000000 Z
11
+ date: 2016-08-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Appril CLI
14
14
  email:
@@ -25,7 +25,7 @@ files:
25
25
  - app/Gemfile
26
26
  - app/Rakefile
27
27
  - app/base/app.js
28
- - app/base/assets/styles.css
28
+ - app/base/assets/app.css
29
29
  - app/base/boot.rb
30
30
  - app/base/component.js
31
31
  - app/base/components/base_controller.rb
@@ -35,6 +35,7 @@ files:
35
35
  - app/base/components/rtcp_controller.rb
36
36
  - app/base/helpers/application_helpers.rb
37
37
  - app/base/helpers/index.js
38
+ - app/base/helpers/user.rb
38
39
  - app/base/load.rb
39
40
  - app/base/models/base_model.rb
40
41
  - app/base/store/modules.js
@@ -113,5 +114,5 @@ rubyforge_project:
113
114
  rubygems_version: 2.5.1
114
115
  signing_key:
115
116
  specification_version: 4
116
- summary: '["appril-cli-0.2.6", "Appril CLI"]'
117
+ summary: '["appril-cli-0.2.7", "Appril CLI"]'
117
118
  test_files: []
File without changes