maglove 2.0.8 → 2.0.9

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: bda73faf8f3fe97f7f7ed94374ccfe14ef7096d8
4
- data.tar.gz: 4e7f532e6662320a32709cb4332f0e3ca4c4751d
3
+ metadata.gz: bb9a74c6d12317c688511fe427f1db0983bf6a77
4
+ data.tar.gz: b403b95686753d58e9637e0ae561003f1da3fad1
5
5
  SHA512:
6
- metadata.gz: 440ecafc205e2581df3bf50e77fffeb3d0b94619b7ca1e95d965ad1e464af7395bef8c7130cfd0f3529f152d4e16f366c57836c24fbc671aa7616bc0450414a4
7
- data.tar.gz: fe92a2b72815731c87df85ee0e80a9b9e63d00b2afdd9f02e0abab5ac104cae25486281bae6d8360f0cbb7a0b84428a373603a708be399f34ed89e4c69deec15
6
+ metadata.gz: d4e362c92484ef2a6f9ed9208312994ee04d1b084a46fb5d911955153d45ac37ebfc8aec1e05c84dd589b39869f837faccff88e6cfbb9285940c75dd079c67a9
7
+ data.tar.gz: fb3aae4209b275aee756d9f9fc675b8abd430208ccb68cbcffe271553658de037f38aa8890edf39ed1e35cf99721aec5037c51e67f0afd3d392564247a698be9
data/assets/maglove.haml CHANGED
@@ -5,21 +5,15 @@
5
5
  %title= "#{theme} - #{template}"
6
6
  %meta{ name: "viewport", content: "width=device-width, initial-scale=1.0" }
7
7
  %meta{ name: "pageid", content: "0" }
8
+ %link{ href: "/fonts/fonts.css", media: "screen", rel: "stylesheet" }
9
+ %link{ href: "/maglove.css", media: "screen", rel: "stylesheet" }
8
10
  %style{ type: "text/css", id: "theme-css" }
9
11
  = css_contents
10
- %link{ href: "/fonts/fonts.css", media: "screen", rel: "stylesheet" }
11
12
  %script{ type: "text/javascript", id: "theme-js" }
12
13
  = js_contents
13
- %script{ src: "/maglove.js", type: "text/javascript" }
14
- -# %script{ src: "/maglove-widgets.js", type: "text/javascript" }
15
- %link{ href: "/maglove.css", media: "screen", rel: "stylesheet" }
16
- %link{ href: "/maglove-widgets.css", media: "screen", rel: "stylesheet" }
17
14
  %script{ type: "module" }
18
15
  :plain
19
- import widgets from './maglove-widgets.js'
20
- widgets.ready().then(() => {
21
- widgets.mount(document.querySelector('page-widget'))
22
- })
23
- new MagLove("#{template}", "127.0.0.1", "#{port}")
16
+ import MagLove from './maglove.js'
17
+ window.maglove = new MagLove("#{template}", "127.0.0.1", #{port})
24
18
  %body
25
19
  = contents
data/assets/maglove.js CHANGED
@@ -1,5 +1,7 @@
1
- class MagLove {
2
-
1
+ import widgets from './maglove-widgets.js'
2
+ window.widgets = widgets
3
+
4
+ export default class MagLove {
3
5
  constructor(template, host="127.0.0.1", port="3000", endpoint="maglove") {
4
6
  this.template = template
5
7
  this.templates = []
@@ -14,26 +16,26 @@ class MagLove {
14
16
  this.socket.onmessage = this.onSocketMessage.bind(this)
15
17
  this.socket.onclose = this.onSocketClose.bind(this)
16
18
  }
17
-
19
+
18
20
  onSocketOpen(event) {
19
21
  console.log("MagLove Opened")
20
22
  this.send("init")
21
23
  }
22
-
24
+
23
25
  onSocketMessage(event) {
24
26
  const message = JSON.parse(event.data)
25
27
  this[message.command](message)
26
28
  }
27
-
29
+
28
30
  onSocketClose(event) {
29
31
  console.log("MagLove Closed")
30
32
  }
31
-
33
+
32
34
  send(command, data={}) {
33
35
  data.command = command
34
36
  this.socket.send(JSON.stringify(data))
35
37
  }
36
-
38
+
37
39
  init(message) {
38
40
  console.log("MagLove Initialized")
39
41
  this.templates = message.templates
@@ -41,31 +43,37 @@ class MagLove {
41
43
  if(window.ThemeApi) {
42
44
  window.ThemeApi.init({deviceId: 'AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE', appId: 'com.magloft.maglove', apiHost: 'www.magloft.com'})
43
45
  }
46
+ this.mount()
44
47
  }
45
-
48
+
46
49
  html(message) {
50
+ console.log("html")
47
51
  if(message.template === this.template) {
48
52
  document.body.innerHTML = message.contents
49
53
  }
50
54
  if (window.$) {
51
55
  $(window.document).trigger("typeloftWidgetChanged")
52
56
  }
53
- if (window.riot) {
54
- riot.mount("*")
55
- }
57
+ this.mount()
58
+ }
59
+
60
+ mount() {
61
+ widgets.ready().then(() => {
62
+ widgets.mount(document.querySelector('page-widget'))
63
+ })
56
64
  }
57
-
65
+
58
66
  css(message) {
59
67
  document.getElementById("theme-css").textContent = message.contents
60
68
  }
61
-
69
+
62
70
  js(message) {
63
71
  document.getElementById("theme-js").remove()
64
72
  let script = document.createElement('script')
65
73
  script.id = "theme-js"
66
74
  script.textContent = message.contents
67
75
  document.getElementsByTagName('head')[0].appendChild(script)
68
-
76
+
69
77
  if(window.ThemeApi) {
70
78
  window.ThemeApi.init({deviceId: 'AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE', appId: 'com.magloft.maglove', apiHost: 'www.magloft.com'})
71
79
  }
@@ -77,7 +77,7 @@ module MagLove
77
77
  elsif filename =~ %r{^src/themes/#{@theme}/.*\.coffee}
78
78
  path = "theme.coffee"
79
79
  elsif filename =~ %r{^src/themes/#{@theme}/.*\.js}
80
- path = "theme.coffee"
80
+ path = "theme.js"
81
81
  elsif filename =~ %r{^src/themes/#{@theme}/blocks/.*\.haml}
82
82
  path = "templates/#{current_template}.haml"
83
83
  else
@@ -1,3 +1,3 @@
1
1
  module MagLove
2
- VERSION = "2.0.8"
2
+ VERSION = "2.0.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maglove
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.8
4
+ version: 2.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Strebitzer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-17 00:00:00.000000000 Z
11
+ date: 2018-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler