highcarb 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d9929cb6a55b1e5db242cf01b020a89a3eeda37a
4
+ data.tar.gz: 79409df9cd1ad9d993ecb9ea9dc2215daa02311c
5
+ SHA512:
6
+ metadata.gz: 4ef3b4f5ba7217d43d7d20cad4fa6660d1fe0f4b009a7e7f20ad80d1cfef74c6efa5a125305fd52e2bbce261a530c6fdff29f496dabd695fe5b72e9e53aafb30
7
+ data.tar.gz: 72c93b190216dbd6a2e61c22b1f8ec1f0cbd5242b58aeb97b5bc1124784570c48248a8916b34911b509118169e633504c2c319007bed436053d3a60da3b3bea5
data/Gemfile.lock CHANGED
@@ -1,13 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- highcarb (0.2)
5
- coffee-script
6
- em-websocket
4
+ highcarb (0.2.3)
7
5
  haml
8
6
  kramdown
9
7
  mime-types
10
8
  nokogiri
9
+ rouge
11
10
  sass
12
11
  thin
13
12
  trollop
@@ -15,33 +14,42 @@ PATH
15
14
  GEM
16
15
  remote: http://rubygems.org/
17
16
  specs:
18
- addressable (2.3.2)
19
- coffee-script (2.2.0)
20
- coffee-script-source
21
- execjs
22
- coffee-script-source (1.3.3)
23
- daemons (1.1.9)
24
- em-websocket (0.3.8)
25
- addressable (>= 2.1.1)
26
- eventmachine (>= 0.12.9)
27
- eventmachine (1.0.0)
28
- execjs (1.4.0)
29
- multi_json (~> 1.0)
30
- haml (3.1.7)
31
- kramdown (0.14.0)
32
- mime-types (1.19)
33
- multi_json (1.3.6)
34
- nokogiri (1.5.5)
35
- rack (1.4.1)
36
- sass (3.2.1)
37
- thin (1.5.0)
38
- daemons (>= 1.0.9)
39
- eventmachine (>= 0.12.6)
40
- rack (>= 1.0.0)
41
- trollop (2.0)
17
+ daemons (1.2.4)
18
+ eventmachine (1.2.3)
19
+ ffi (1.9.18)
20
+ haml (5.0.1)
21
+ temple (>= 0.8.0)
22
+ tilt
23
+ kramdown (1.14.0)
24
+ mime-types (3.1)
25
+ mime-types-data (~> 3.2015)
26
+ mime-types-data (3.2016.0521)
27
+ mini_portile2 (2.2.0)
28
+ nokogiri (1.8.0)
29
+ mini_portile2 (~> 2.2.0)
30
+ rack (2.0.3)
31
+ rb-fsevent (0.10.2)
32
+ rb-inotify (0.9.10)
33
+ ffi (>= 0.5.0, < 2)
34
+ rouge (2.1.1)
35
+ sass (3.5.1)
36
+ sass-listen (~> 4.0.0)
37
+ sass-listen (4.0.0)
38
+ rb-fsevent (~> 0.9, >= 0.9.4)
39
+ rb-inotify (~> 0.9, >= 0.9.7)
40
+ temple (0.8.0)
41
+ thin (1.7.2)
42
+ daemons (~> 1.0, >= 1.0.9)
43
+ eventmachine (~> 1.0, >= 1.0.4)
44
+ rack (>= 1, < 3)
45
+ tilt (2.0.7)
46
+ trollop (2.1.2)
42
47
 
43
48
  PLATFORMS
44
49
  ruby
45
50
 
46
51
  DEPENDENCIES
47
52
  highcarb!
53
+
54
+ BUNDLED WITH
55
+ 1.13.2
data/README.md CHANGED
@@ -1,38 +1,21 @@
1
1
  # HighCarb
2
2
 
3
- HighCarb is a framework to create presentations, and to control them remotely.
3
+ HighCarb is a framework to create presentations.
4
4
 
5
5
  The presentation is based on Deck.js
6
6
 
7
7
  ## Installation
8
8
 
9
9
  ```
10
- $ gem install highcarb
10
+ $ gem install highcarb
11
11
  ```
12
12
 
13
- ### Dependencies
14
-
15
- * You have to install Pygmentize if you want to highlight the code snippets.
16
- * A JavaScript interpreter is needed to compile the CoffeeScript source. Rhino or JavaScript can be used with no problems.
17
-
18
- In Debian (and derived) everything can be installed with
19
-
20
- ```
21
- $ sudo apt-get install nodejs python-pygments
22
- ```
23
-
24
- Mac OSX
25
-
26
- ```
27
- $ brew install node.js
28
- $ sudo easy_install Pygments
29
- ```
30
13
  ## Generate a presentation project
31
14
 
32
15
  The `-g` flag generate a new tree with the base for the presentation
33
16
 
34
17
  ```
35
- $ highcarb -g /my/slides/foobar
18
+ $ highcarb -g /my/slides/foobar
36
19
  ```
37
20
 
38
21
  ## Adding content
@@ -44,9 +27,7 @@ The generated tree is something like
44
27
  ├── assets
45
28
  │   ├── README
46
29
  │   ├── base.scss
47
- │   ├── remote.scss
48
- │   ├── custom.coffee
49
- │   ├── custom-remote.coffee
30
+ │   ├── custom.js
50
31
  │   └── vendor
51
32
  │   └── deck.js
52
33
  │   ├── ...
@@ -65,9 +46,9 @@ The generator will concatenate all the files when the presentation is shown.
65
46
 
66
47
  #### Special tags
67
48
 
68
- `%snippet` is used to load a file from the `snippets` directory. If Pygmentize is found, the code will be highlighted. If not, the content will be shown in a monospace font.
49
+ `%snippet` is used to load a file from the `snippets` directory.
69
50
 
70
- `%asset` load a file from the `assets` directory. If the file is an image, an `img` will be created. If it is a CSS file (or SCSS), a `link` tag will be used. And, for JavaScript (or CoffeeScript) files, a `script` tag is used.
51
+ `%asset` load a file from the `assets` directory. If the file is an image, an `img` will be created. If it is a CSS file (or SCSS), a `link` tag will be used. And, for JavaScript files, a `script` tag is used.
71
52
 
72
53
  If type asset type can not be determined by the MIME type, a CSS class can be added to the `asset` tag to force the type. The class can be `image`, `style` or `javascript`
73
54
 
@@ -75,16 +56,10 @@ If the asset is something else, a link will be added with an anchor.
75
56
 
76
57
  `%external` can be used to create link to external pages. The shown text is shorted to be less noisy.
77
58
 
78
- #### Notes
79
-
80
- Everything with the `note` CSS class will be removed from the slide. This content is accessible in the `remote` view.
81
-
82
59
  ## Assets
83
60
 
84
61
  Every file from the `asset` directory is accessible from the `http://domain/asset/` URL.
85
62
 
86
- If the file is a CoffeeScript source, it will be compiled as JavaScript before be sent. Same for SCSS.
87
-
88
63
  ## Example
89
64
 
90
65
  With this files
@@ -92,7 +67,7 @@ With this files
92
67
  ```
93
68
  /slide
94
69
  ├── assets
95
- │   ├── hacks.coffee
70
+ │   ├── hacks.js
96
71
  └── first.png
97
72
  └── snippets
98
73
  └── README
@@ -102,7 +77,7 @@ We could write
102
77
 
103
78
  ```haml
104
79
 
105
- %asset hacks.coffee
80
+ %asset hacks.js
106
81
 
107
82
  .slide
108
83
  %h1 First slide
@@ -133,10 +108,6 @@ Some options are available with the `--help` flag.
133
108
  With the defaults options the web server will listen on 9090, so the presentation can
134
109
  be see at http://localhost:9090/
135
110
 
136
- To control it from another browser go to http://localhost:9090/remote. The remote view
137
- show the full slides, so you can see everything. Left and right keys can be used to move
138
- the slide of the remote browser.
139
-
140
111
  There is no need to restart the server if the content is changed. Everything will be regenerated
141
112
  when reload the page in the browser. The HTML generated for the snippets is cached. The cached key
142
113
  is the MD5 sum of the content.
data/highcarb.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.email = ["ayosec@gmail.com"]
11
11
  s.homepage = "https://github.com/ayosec/highcarb"
12
12
  s.summary = %q{Slides manager based on Deck.js }
13
- s.description = %q{HighCarb can build a presentation based on HAML, Markdown or raw HTML, and let to control them from another browser, via WebSockets.}
13
+ s.description = %q{HighCarb can build a presentation based on HAML, Markdown or raw HTML}
14
14
 
15
15
  # Manifest
16
16
  s.files = `git ls-files`.split("\n")
@@ -20,12 +20,11 @@ Gem::Specification.new do |s|
20
20
 
21
21
  s.add_runtime_dependency "thin"
22
22
  s.add_runtime_dependency "mime-types"
23
- s.add_runtime_dependency "em-websocket"
24
23
  s.add_runtime_dependency "trollop"
25
24
  s.add_runtime_dependency "nokogiri"
26
25
  s.add_runtime_dependency "haml"
27
26
  s.add_runtime_dependency "sass"
28
27
  s.add_runtime_dependency "kramdown"
29
- s.add_runtime_dependency "coffee-script"
28
+ s.add_runtime_dependency "rouge"
30
29
  end
31
30
 
@@ -26,12 +26,6 @@ module HighCarb
26
26
  mime_type = "text/css"
27
27
  end
28
28
 
29
- # Process CoffeeScript
30
- if asset_path.extname == ".coffee"
31
- output = CoffeeScript.compile(asset_path.read)
32
- mime_type = "application/javascript"
33
- end
34
-
35
29
  if output == nil
36
30
  mime_type = MIME::Types.type_for(asset_path.to_s).first || "application/octet-stream"
37
31
  output = asset_path.read
@@ -27,8 +27,6 @@ module HighCarb
27
27
  opt "server", "Start the servers (default action). See --http-port and --ws-port"
28
28
 
29
29
  opt "http-port", "HTTP server port", default: 9090
30
- opt "ws-port", "WebSockets port", default: 9091
31
- opt "ws", "Enable/Disable WebSockets", default: true
32
30
 
33
31
  opt "skip-libs", "Don't download vendor libraries, like Deck.js and jQuery"
34
32
 
@@ -29,7 +29,6 @@ module HighCarb
29
29
 
30
30
  create_file path.join("assets/README"),
31
31
  "Put in this directory any file that you want to use in your presentation (images, et al)\n\n" +
32
- "Files ending with .coffee will be compiled with CoffeeScript.\n" +
33
32
  "Files ending with .scss will be compiled with SASS. Compass is available."
34
33
 
35
34
  create_file path.join("assets/base.scss"),
@@ -47,12 +46,10 @@ module HighCarb
47
46
 
48
47
 
49
48
  create_file path.join("assets/remote.scss"), "/* Add here your styles for the /remote view */"
50
- create_file path.join("assets/custom-remote.coffee"), "# Add here your own code for the /remote view"
51
- create_file path.join("assets/custom.coffee"), "# Add here your own code for the views"
49
+ create_file path.join("assets/custom.js"), "// Add here your own code for the views"
52
50
 
53
51
  create_file path.join("snippets/README"),
54
52
  "Put in this directory any snippet of code that you want to include in your presentation.\n" +
55
- "You need to install Pygmentize if you want to format the code.\n" +
56
53
  "The snippets are loaded with a <snippet>name.rb</snippet> tag.\n" +
57
54
  "With Haml, you can use %snippet name.rb\n"
58
55
 
@@ -1,9 +1,6 @@
1
1
 
2
2
  require "thin"
3
- require "em-websocket"
4
-
5
3
  require "highcarb/rack_app"
6
- require "highcarb/sockets"
7
4
 
8
5
  module HighCarb
9
6
  module Services
@@ -1,6 +1,6 @@
1
-
2
1
  require "digest/md5"
3
2
  require "nokogiri"
3
+ require "rouge"
4
4
 
5
5
  module HighCarb
6
6
  module SlidesController
@@ -76,18 +76,16 @@ module HighCarb
76
76
 
77
77
  else
78
78
 
79
- content = begin
80
- IO.popen(["pygmentize", "-f", "html", "-O", "noclasses=true", snippet_path.to_s]).read
81
- rescue Errno::ENOENT
82
- if not @pygmentize_error_shown
83
- STDERR.puts "\033[31mpygmentize could not be used. You have to install it if you want to highlight the snippets."
84
- STDERR.puts "The snippets will be included with no format\033[m"
85
- @pygmentize_error_shown = true
79
+ content =
80
+ begin
81
+ formatter = Rouge::Formatters::HTMLInline.new(Rouge::Themes::Github)
82
+ lexer = Rouge::Lexer.guess_by_filename(snippet_name)
83
+ "<pre>" + formatter.format(lexer.lex(File.read(snippet_path))) + "</pre>"
84
+ rescue => e
85
+ STDERR.puts "\033[31mCould not render snippet #{snippet_name}: #{e}\033[m"
86
+ %[<pre class="raw-snippet">#{ERB::Util.h snippet_path.read}</pre>]
86
87
  end
87
88
 
88
- %[<pre class="raw-snippet">#{ERB::Util.h snippet_path.read}</pre>]
89
- end
90
-
91
89
  snippet_html_cached.dirname.mkpath
92
90
  snippet_html_cached.open("w") {|f| f.write content }
93
91
  content
@@ -112,7 +110,7 @@ module HighCarb
112
110
  "image"
113
111
  elsif mime_type.to_s == "text/css"
114
112
  "style"
115
- elsif mime_type.to_s == "application/javascript" or asset_path.extname == "coffee"
113
+ elsif mime_type.to_s == "application/javascript"
116
114
  "javascript"
117
115
  end
118
116
  end
@@ -1,3 +1,3 @@
1
1
  module HighCarb
2
- Version = "0.2.3"
2
+ Version = "0.2.4"
3
3
  end
@@ -1,6 +1,5 @@
1
1
 
2
2
  require "json"
3
- require "coffee-script"
4
3
 
5
4
  module HighCarb
6
5
  module ViewsController
@@ -15,10 +14,6 @@ module HighCarb
15
14
  @root = root
16
15
  end
17
16
 
18
- def load_coffe(source)
19
- "<script>//<![CDATA[\n" + CoffeeScript.compile(root.join(source + ".coffee").read) + "\n//]]></script>"
20
- end
21
-
22
17
  def jquery_path
23
18
  Dir.chdir(root) { Dir["assets/vendor/deck.js/jquery-*.js"].first }
24
19
  end
@@ -14,9 +14,14 @@
14
14
  %script{ src: "/assets/vendor/deck.js/extensions/status/deck.status.js" }
15
15
  %script{ src: "/assets/vendor/deck.js/extensions/hash/deck.hash.js" }
16
16
 
17
+ %script{ src: "/assets/custom.js" }
18
+
17
19
  :javascript
18
- window.EnableWebSocketsURL = #{!!options["ws"]};
19
- window.WebSocketsURL = "ws://" + location.hostname + ":#{options["ws-port"].to_json}/";
20
+ $(function() {
21
+ $.get("/slides", function(data) {
22
+ $(".slides").replaceWith(data);
23
+ $(".slides").find(".note").remove();
24
+ $.deck(".slide");
25
+ })
26
+ });
20
27
 
21
- = load_coffe "index"
22
- %script{ src: "/assets/custom.coffee" }
metadata CHANGED
@@ -1,117 +1,128 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: highcarb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
5
- prerelease:
4
+ version: 0.2.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Ayose Cazorla
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-10-28 00:00:00.000000000 Z
11
+ date: 2017-07-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: thin
16
- requirement: &22024620 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
- version_requirements: *22024620
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
28
  name: mime-types
27
- requirement: &22024000 !ruby/object:Gem::Requirement
28
- none: false
29
+ requirement: !ruby/object:Gem::Requirement
29
30
  requirements:
30
- - - ! '>='
31
+ - - ">="
31
32
  - !ruby/object:Gem::Version
32
33
  version: '0'
33
34
  type: :runtime
34
35
  prerelease: false
35
- version_requirements: *22024000
36
- - !ruby/object:Gem::Dependency
37
- name: em-websocket
38
- requirement: &22023340 !ruby/object:Gem::Requirement
39
- none: false
36
+ version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - ! '>='
38
+ - - ">="
42
39
  - !ruby/object:Gem::Version
43
40
  version: '0'
44
- type: :runtime
45
- prerelease: false
46
- version_requirements: *22023340
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: trollop
49
- requirement: &22022420 !ruby/object:Gem::Requirement
50
- none: false
43
+ requirement: !ruby/object:Gem::Requirement
51
44
  requirements:
52
- - - ! '>='
45
+ - - ">="
53
46
  - !ruby/object:Gem::Version
54
47
  version: '0'
55
48
  type: :runtime
56
49
  prerelease: false
57
- version_requirements: *22022420
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
58
55
  - !ruby/object:Gem::Dependency
59
56
  name: nokogiri
60
- requirement: &22020620 !ruby/object:Gem::Requirement
61
- none: false
57
+ requirement: !ruby/object:Gem::Requirement
62
58
  requirements:
63
- - - ! '>='
59
+ - - ">="
64
60
  - !ruby/object:Gem::Version
65
61
  version: '0'
66
62
  type: :runtime
67
63
  prerelease: false
68
- version_requirements: *22020620
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: haml
71
- requirement: &22019140 !ruby/object:Gem::Requirement
72
- none: false
71
+ requirement: !ruby/object:Gem::Requirement
73
72
  requirements:
74
- - - ! '>='
73
+ - - ">="
75
74
  - !ruby/object:Gem::Version
76
75
  version: '0'
77
76
  type: :runtime
78
77
  prerelease: false
79
- version_requirements: *22019140
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
80
83
  - !ruby/object:Gem::Dependency
81
84
  name: sass
82
- requirement: &22018460 !ruby/object:Gem::Requirement
83
- none: false
85
+ requirement: !ruby/object:Gem::Requirement
84
86
  requirements:
85
- - - ! '>='
87
+ - - ">="
86
88
  - !ruby/object:Gem::Version
87
89
  version: '0'
88
90
  type: :runtime
89
91
  prerelease: false
90
- version_requirements: *22018460
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
91
97
  - !ruby/object:Gem::Dependency
92
98
  name: kramdown
93
- requirement: &21966520 !ruby/object:Gem::Requirement
94
- none: false
99
+ requirement: !ruby/object:Gem::Requirement
95
100
  requirements:
96
- - - ! '>='
101
+ - - ">="
97
102
  - !ruby/object:Gem::Version
98
103
  version: '0'
99
104
  type: :runtime
100
105
  prerelease: false
101
- version_requirements: *21966520
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
102
111
  - !ruby/object:Gem::Dependency
103
- name: coffee-script
104
- requirement: &21964700 !ruby/object:Gem::Requirement
105
- none: false
112
+ name: rouge
113
+ requirement: !ruby/object:Gem::Requirement
106
114
  requirements:
107
- - - ! '>='
115
+ - - ">="
108
116
  - !ruby/object:Gem::Version
109
117
  version: '0'
110
118
  type: :runtime
111
119
  prerelease: false
112
- version_requirements: *21964700
113
- description: HighCarb can build a presentation based on HAML, Markdown or raw HTML,
114
- and let to control them from another browser, via WebSockets.
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: HighCarb can build a presentation based on HAML, Markdown or raw HTML
115
126
  email:
116
127
  - ayosec@gmail.com
117
128
  executables:
@@ -119,8 +130,8 @@ executables:
119
130
  extensions: []
120
131
  extra_rdoc_files: []
121
132
  files:
122
- - .gitignore
123
- - .rvmrc
133
+ - ".gitignore"
134
+ - ".rvmrc"
124
135
  - Gemfile
125
136
  - Gemfile.lock
126
137
  - README.md
@@ -133,35 +144,30 @@ files:
133
144
  - lib/highcarb/rack_app.rb
134
145
  - lib/highcarb/services.rb
135
146
  - lib/highcarb/slides_controller.rb
136
- - lib/highcarb/sockets.rb
137
147
  - lib/highcarb/version.rb
138
148
  - lib/highcarb/views_controller.rb
139
- - resources/views/index.coffee
140
149
  - resources/views/index.haml
141
- - resources/views/remote.coffee
142
- - resources/views/remote.haml
143
150
  homepage: https://github.com/ayosec/highcarb
144
151
  licenses: []
152
+ metadata: {}
145
153
  post_install_message:
146
154
  rdoc_options: []
147
155
  require_paths:
148
156
  - lib
149
157
  required_ruby_version: !ruby/object:Gem::Requirement
150
- none: false
151
158
  requirements:
152
- - - ! '>='
159
+ - - ">="
153
160
  - !ruby/object:Gem::Version
154
161
  version: '0'
155
162
  required_rubygems_version: !ruby/object:Gem::Requirement
156
- none: false
157
163
  requirements:
158
- - - ! '>='
164
+ - - ">="
159
165
  - !ruby/object:Gem::Version
160
166
  version: '0'
161
167
  requirements: []
162
168
  rubyforge_project:
163
- rubygems_version: 1.8.10
169
+ rubygems_version: 2.6.7
164
170
  signing_key:
165
- specification_version: 3
171
+ specification_version: 4
166
172
  summary: Slides manager based on Deck.js
167
173
  test_files: []
@@ -1,47 +0,0 @@
1
-
2
- module HighCarb
3
- class WSConnection
4
-
5
- class <<self
6
- attr_accessor :connected_clients
7
- attr_accessor :last_client_id
8
- end
9
-
10
- self.connected_clients = []
11
- self.last_client_id = 0
12
-
13
- attr_reader :client_id
14
- attr_reader :websocket
15
- attr_reader :logger
16
-
17
- def initialize(websocket, logger)
18
- @logger = logger
19
- @client_id = (self.class.last_client_id += 1)
20
-
21
- @websocket = websocket
22
- websocket.onopen &method(:on_open)
23
- websocket.onclose &method(:on_close)
24
- websocket.onmessage &method(:on_msg)
25
- end
26
-
27
- def on_open
28
- logger.info { "[WS] Open client: #{client_id}" }
29
- self.class.connected_clients << self
30
- end
31
-
32
- def on_close
33
- logger.info { "[WS] Closed client: #{client_id}" }
34
- self.class.connected_clients.delete self
35
- end
36
-
37
- def on_msg(msg)
38
- logger.info { "[WS] Message from #{client_id}: #{msg}" }
39
-
40
- self.class.connected_clients.each do |client|
41
- if client != self
42
- client.websocket.send msg
43
- end
44
- end
45
- end
46
- end
47
- end
@@ -1,48 +0,0 @@
1
-
2
- window.WebSocket = MozWebSocket if MozWebSocket?
3
-
4
- $ ->
5
-
6
- # Load slides and initialize Deck.js
7
- $.get "/slides",
8
- (data) ->
9
- $(".slides").replaceWith data
10
- $(".slides").find(".note").remove()
11
- $.deck ".slide"
12
-
13
- # Open a permanent connection to the server. With this channel
14
- # we can receive commands to change the current slide
15
- toJson = JSON.stringify
16
-
17
-
18
- # Don't initialize the websocket if we don't have any URL
19
- return unless EnableWebSocketsURL
20
-
21
-
22
- channel = new WebSocket WebSocketsURL
23
- channel.onmessage = (msgEvent) ->
24
- msg = JSON.parse(msgEvent.data)
25
-
26
- switch msg.action
27
- when "next-slide" then $.deck('next')
28
- when "prev-slide" then $.deck('prev')
29
- when "go-to"
30
- for slide, index in $.deck('getSlides')
31
- if slide.data("slide-id") == msg.slideId
32
- $.deck("go", index)
33
- break
34
-
35
- channel.onopen = ->
36
- channel.send toJson(ack: true)
37
-
38
- # Send a notification to every other client when the current slide has changed
39
- lastSlideSelectedEvent = -1
40
- $(document).bind 'deck.change', (event, from, to) ->
41
- if lastSlideSelectedEvent != -1
42
- clearTimeout lastSlideSelectedEvent
43
-
44
- lastSlideSelectedEvent = \
45
- setTimeout ->
46
- lastSlideSelectedEvent = -1
47
- channel.send toJson(action: "slide-selected", slideId: $.deck('getSlide').data("slide-id"))
48
- 100
@@ -1,59 +0,0 @@
1
-
2
- window.WebSocket = MozWebSocket if MozWebSocket?
3
-
4
- $ ->
5
- # Don't initialize the websocket if we don't have any URL
6
- return unless EnableWebSocketsURL
7
-
8
- $(".slides").
9
- load("/slides").
10
- delegate(".slide", "click", (event) ->
11
- node = event.target
12
- while node
13
- slideId = $(node).data("slide-id")
14
- if slideId
15
- event.preventDefault()
16
- channel.send toJson(action: "go-to", slideId: slideId)
17
- return false
18
-
19
- node = node.parentNode
20
-
21
- true
22
- )
23
-
24
- toJson = JSON.stringify
25
-
26
- channel = new WebSocket WebSocketsURL
27
- channel.onmessage = (msgEvent) ->
28
- msg = JSON.parse(msgEvent.data)
29
-
30
- # Set the remote-selected class to the new slide
31
- $(".remote-selected").removeClass "remote-selected"
32
- item = $(".slide[data-slide-id=#{msg.slideId}]").
33
- addClass("remote-selected")
34
-
35
- # Keep the selected item always in the center
36
- offset = item.offset()
37
- if offset
38
- newTop = offset.top - ($(window).height() - item.height()) / 2
39
- #$("html").scrollTop newTop
40
- $("html").animate(scrollTop: newTop, 300)
41
-
42
- channel.onopen = ->
43
- channel.send toJson(ack: true)
44
-
45
- # Send commands to the presenter
46
- nextSlide = -> channel.send toJson(action: "next-slide")
47
- prevSlide = -> channel.send toJson(action: "prev-slide")
48
- $(".actions .next").click nextSlide
49
- $(".actions .prev").click prevSlide
50
-
51
- $(document).keypress (event) ->
52
- switch(event.keyCode)
53
- when 37 then prevSlide()
54
- when 39 then nextSlide()
55
- else return
56
-
57
- event.preventDefault()
58
-
59
-
@@ -1,61 +0,0 @@
1
- !!! 5
2
- %html
3
- %head
4
- %title Remote control
5
- %script{ src: app.config["jquery"] }
6
- %script{ src: "/assets/custom.coffee" }
7
- %script{ src: "/assets/custom-remote.coffee" }
8
-
9
- %style
10
- :erb
11
- body {
12
- background: black;
13
- color: white;
14
- }
15
-
16
- .slides > .slide {
17
- background: white;
18
- color: black;
19
- border: 1px solid black;
20
- padding: 1em;
21
- margin: 1em;
22
- }
23
-
24
- .slide:hover {
25
- cursor: pointer;
26
- border: 1px solid black;
27
- }
28
-
29
- .remote-selected { background: #ffc !important; }
30
-
31
- .actions {
32
- position: fixed;
33
- right: 1em;
34
- top: 1em;
35
- }
36
-
37
- .actions span {
38
- color: black;
39
- background: gray;
40
- display: inline-block;
41
- font-size: 120%;
42
- cursor: pointer;
43
- margin: 0.1ex;
44
- padding: 0.5ex;
45
- }
46
-
47
- %link{rel: "stylesheet", href: "/assets/remote.scss"}
48
-
49
- %body.remote
50
- .actions
51
- %span.prev Prev
52
- %span.next Next
53
-
54
- .slides Loading ...
55
-
56
- :javascript
57
- window.EnableWebSocketsURL = #{!!options["ws"]};
58
- window.WebSocketsURL = "ws://" + location.hostname + ":#{options["ws-port"].to_json}/";
59
-
60
- = load_coffe "remote"
61
-