gibier 0.8.8 → 0.8.9

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: eaa4122a847c17707fe41faa5102caf81c29b806
4
- data.tar.gz: 06b7879985defd6be84fc2d42bf6e69dae9d7939
3
+ metadata.gz: 54ee7db66d7a6a0f8b0ea96ed4c6a3946c0b3fde
4
+ data.tar.gz: c626e010bb1c7c8f5d0eef18c43b75ce3e6f3aac
5
5
  SHA512:
6
- metadata.gz: 1a67bc2f4752d1dc6e822866e61640dc7436c7cfa6e8ab37b3cf2450d8bdbed16dee5fbda43f546b0d5bb545d14f24550e09fb5d3edc822b584c2bdac3a730af
7
- data.tar.gz: fb2d1f34ac4188dbc747bbc2a64f62186702d8f5a7fb201651d105fe96bebf8022ac77262189bfd74567632b7203b75fadc6a1e24828478caa1d3baaeeb1ea40
6
+ metadata.gz: 1d5bf74ef88f413cb9cd3ed26e1b0aebaa2d9f811ed11c632637f0325855a08e908456b5ba42d3acd1a8ff70b7daf043b0fde6a388b69c26b2331d1498839a69
7
+ data.tar.gz: ef1c644cc1d0fbc71bc95c0c789f0de856de7230c098994bc5eddf703f9560ee57495c084562921bb703cd749e0bb4423ae01af19e10cdaa90b67531026f6f37
@@ -41,13 +41,12 @@ module Gibier
41
41
  def build(name, filename)
42
42
  builder = Opal::Builder.new
43
43
 
44
- use_gem(builder, 'opal-browser', 'opal')
45
44
  use_gem(builder, 'opal-router', 'opal')
46
- use_gem(builder, 'hyalite', 'client')
47
45
 
48
46
  builder.append_paths './app'
47
+ builder.use_gem 'hyalite'
48
+ builder.use_gem 'opal-websocket'
49
49
  builder.use_gem 'gibier'
50
- builder.use_gem 'paggio'
51
50
  builder.build "./app/slides/#{name}/app.rb"
52
51
 
53
52
  File.open(filename, 'w') do |file|
@@ -1,3 +1,3 @@
1
1
  module Gibier
2
- VERSION = "0.8.8"
2
+ VERSION = "0.8.9"
3
3
  end
data/template/app.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  require 'slide'
2
2
  require 'page_base'
3
3
  require 'slides/#{name}/pages'
4
- require 'browser/socket'
5
- require 'browser/location'
4
+ require 'opal/websocket'
6
5
 
7
6
  Gibier.slide_name = '#{name}'
8
7
  Gibier.gh_pages = `window.ghPages`
@@ -15,7 +14,7 @@ module App
15
14
  end
16
15
 
17
16
  $document.ready do
18
- ws = Browser::Socket.new("ws://\#{$window.location.host}/push_notification/start/slide/#{name}") unless Gibier.gh_pages
17
+ ws = Opal::WebSocket.new("ws://\#{`window.location.host`}/push_notification/start/slide/#{name}") unless Gibier.gh_pages
19
18
 
20
19
  $window.on(:resize) do
21
20
  App.render(ws)
@@ -1,8 +1,8 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gem 'gibier'
4
- gem 'opal-browser'
5
4
  gem 'opal-router', github: 'adambeynon/opal-router'
6
5
  gem 'opal-haml', github: 'opal/opal-haml'
7
- gem 'hyalite', '0.1.0'
6
+ gem 'opal-websocket', github: 'youchan/opal-websocket'
7
+ gem 'hyalite'
8
8
 
@@ -1,8 +1,5 @@
1
1
  require 'hyalite'
2
2
  require 'opal-router'
3
- require 'browser'
4
- require 'browser/interval'
5
- require 'browser/location'
6
3
  require 'track_field'
7
4
 
8
5
  module Gibier
@@ -51,7 +48,6 @@ module Gibier
51
48
 
52
49
  class Slide
53
50
  include Hyalite::Component
54
- include Hyalite::Component::ShortHand
55
51
 
56
52
  def pages(height)
57
53
  case @state[:mode]
@@ -67,7 +63,8 @@ module Gibier
67
63
  end
68
64
 
69
65
  def initial_state
70
- page_num = $window.location.uri.sub(/.*#([0-9]+)/, '\1').to_i
66
+ uri = $window.location.toString
67
+ page_num = uri.sub(/.*#([0-9]+)/, '\1').to_i
71
68
 
72
69
  {
73
70
  page_number: page_num,
@@ -83,7 +80,7 @@ module Gibier
83
80
  end
84
81
 
85
82
  unless Gibier.gh_pages
86
- @props[:ws].on(:message) do |msg|
83
+ @props[:ws].onmessage do |msg|
87
84
  (event, value) = msg.data.split(':')
88
85
  case event
89
86
  when 'keydown'
@@ -98,35 +95,43 @@ module Gibier
98
95
  end
99
96
 
100
97
  def page_to(num)
101
- $window.location.assign("#{$window.location.to_s.sub(/#\d+$/, '')}##{num}")
98
+ $window.location.assign("#{$window.location.toString.sub(/#\d+$/, '')}##{num}")
99
+ end
100
+
101
+ def page_back
102
+ page_to(@state[:page_number] - 1) if @state[:page_number] > 0
103
+ end
104
+
105
+ def page_forward
106
+ page_to(@state[:page_number] + 1) if @state[:page_number] < Gibier.page_count
102
107
  end
103
108
 
104
109
  def handle_key_down(event)
105
110
  keycode = event.code
106
111
  case keycode
107
- when 39,34
108
- page_to(@state[:page_number] + 1) if @state[:page_number] < Gibier.page_count
109
- when 37,33
110
- page_to(@state[:page_number] - 1) if @state[:page_number] > 0
111
- when 83,66
112
+ when :Space, :ArrowRight, :ArrowUp
113
+ page_forward
114
+ when :Backspace, :ArrowLeft, :ArrowDown
115
+ page_back
116
+ when :KeyS, :KeyB
112
117
  unless @state[:start]
113
118
  set_state(start: Time.now)
114
119
  else
115
120
  set_state(start: nil)
116
121
  end
117
- when 80
122
+ when :KeyP
118
123
  if @state[:mode] == :slide
119
124
  set_state(mode: :print)
120
125
  else
121
126
  set_state(mode: :slide)
122
127
  end
123
- when 70
128
+ when :KeyF
124
129
  set_state(footer_visible: !@state[:footer_visible])
125
- if `event.native.ctrlKey`
130
+ if event.ctrl_key
126
131
  fullscreen
127
132
  end
128
- when 116
129
- if `event.native.shiftKey`
133
+ when :F5
134
+ if event.shift_key
130
135
  fullscreen
131
136
  end
132
137
  else
@@ -158,15 +163,15 @@ module Gibier
158
163
  end
159
164
 
160
165
  def render
161
- follow_height = $window.view.height / $window.view.width < SLIDE_HEIGHT / SLIDE_WIDTH
166
+ follow_height = $window.height / $window.width < SLIDE_HEIGHT / SLIDE_WIDTH
162
167
  if follow_height
163
- zoom = $window.view.height.to_f / SLIDE_HEIGHT * 0.98
168
+ zoom = $window.height.to_f / SLIDE_HEIGHT * 0.98
164
169
  else
165
- zoom = $window.view.width.to_f / SLIDE_WIDTH * 0.98
170
+ zoom = $window.width.to_f / SLIDE_WIDTH * 0.98
166
171
  end
167
172
 
168
- top = ($window.view.height / zoom - SLIDE_HEIGHT) / 2
169
- left = ($window.view.width / zoom - SLIDE_WIDTH) / 2
173
+ top = ($window.height / zoom - SLIDE_HEIGHT) / 2
174
+ left = ($window.width / zoom - SLIDE_WIDTH) / 2
170
175
 
171
176
  footer_style = @state[:page_number] == 1 || !@state[:footer_visible] ? {style: {display: 'none'}} : {}
172
177
 
@@ -174,17 +179,21 @@ module Gibier
174
179
  when :slide
175
180
  div({className: 'background'},
176
181
  div({className: 'background-filter'},
177
- div({
178
- className: 'slide',
179
- style: {zoom: zoom, top: "#{top}px", left: "#{left}px"},
180
- onKeyDown: -> (event) { handle_key_down(event) }
181
- },
182
- pages(SLIDE_HEIGHT * zoom)
183
- ),
184
- Gibier::TrackField.el({total_time: duration, start: @state[:start], page_number: @state[:page_number], page_count: Gibier.page_count}),
185
- section({className: 'footer'}.merge(footer_style),
186
- p({className: 'title'}, Gibier.title),
187
- p({className: 'powered-by'}, "Powered by ", span({className: "hyalite"}, "Hyalite"))
182
+ div({class: 'slide-controll'},
183
+ div({class: 'page-back', onClick: -> { page_back }}),
184
+ div({class: 'page-forward', onClick: -> { page_forward }}),
185
+ div({
186
+ className: 'slide',
187
+ style: {zoom: zoom, top: "#{top}px", left: "#{left}px"},
188
+ onKeyDown: -> (event) { handle_key_down(event) }
189
+ },
190
+ pages(SLIDE_HEIGHT * zoom)
191
+ ),
192
+ Gibier::TrackField.el({total_time: duration, start: @state[:start], page_number: @state[:page_number], page_count: Gibier.page_count}),
193
+ section({className: 'footer'}.merge(footer_style),
194
+ p({className: 'title'}, Gibier.title),
195
+ p({className: 'powered-by'}, "Powered by ", span({className: "hyalite"}, "Hyalite"))
196
+ )
188
197
  )
189
198
  )
190
199
  )
@@ -1,9 +1,6 @@
1
- require 'browser/interval'
2
-
3
1
  module Gibier
4
2
  class TrackField
5
3
  include Hyalite::Component
6
- include Hyalite::Component::ShortHand
7
4
 
8
5
  def initialize
9
6
  super
@@ -15,15 +12,17 @@ module Gibier
15
12
  end
16
13
 
17
14
  def component_did_mount
18
- every(1) do
15
+ func = Proc.new do
19
16
  set_state(tic: !@state[:tic])
20
- if el = $document.css(".track-field")[0]
17
+ if el = $document[".track-field"].first
21
18
  @width = el.width.to_i
22
19
  spend_time = @props[:start] ? Time.now - @props[:start] : 0
23
20
  rabbit_pos = [(spend_time / @props[:total_time]), 1].min * (@width - 40) * 0.96 + @width * 0.02
24
21
  set_state(rabbit_pos: rabbit_pos)
25
22
  end
26
23
  end
24
+
25
+ `setInterval(func, 1000)`
27
26
  end
28
27
 
29
28
  def render
@@ -61,6 +61,29 @@ body {
61
61
  width: 100%;
62
62
  }
63
63
 
64
+ .slide-controll {
65
+ position: absolute;
66
+ height: 100%;
67
+ width: 100%;
68
+ }
69
+
70
+ .slide-controll .page-back {
71
+ position: absolute;
72
+ width: 25%;
73
+ height: 100%;
74
+ z-index: 10;
75
+ background-color: rgba(0, 0, 0, 0);
76
+ }
77
+
78
+ .slide-controll .page-forward {
79
+ position: absolute;
80
+ width: 25%;
81
+ height: 100%;
82
+ left: 75%;
83
+ z-index: 10;
84
+ background-color: rgba(0, 0, 0, 0);
85
+ }
86
+
64
87
  .page p.icon {
65
88
  margin: 0;
66
89
  position: absolute;
@@ -20,6 +20,7 @@ class Server < Sinatra::Base
20
20
  server.append_path 'assets'
21
21
 
22
22
  Opal.use_gem 'opal-router'
23
+ Opal.use_gem 'opal-websocket'
23
24
  Opal.use_gem 'hyalite'
24
25
  Opal.use_gem 'gibier'
25
26
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gibier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.8
4
+ version: 0.8.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - youchan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-20 00:00:00.000000000 Z
11
+ date: 2017-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -315,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
315
315
  version: '0'
316
316
  requirements: []
317
317
  rubyforge_project:
318
- rubygems_version: 2.6.11
318
+ rubygems_version: 2.6.13
319
319
  signing_key:
320
320
  specification_version: 4
321
321
  summary: A slide tool inspired by Rabbit