flammarion 0.1.14 → 0.2.0

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.
@@ -11,7 +11,7 @@ begin
11
11
  require 'sass'
12
12
  require 'slim'
13
13
  require 'coffee-script'
14
- require 'redcarpet'
14
+ require 'kramdown' unless defined?(Redcarpet::Markdown)
15
15
  rescue LoadError
16
16
  end
17
17
 
@@ -12,7 +12,7 @@ module Flammarion
12
12
  # blank window, and then display that thing.
13
13
  class Engraving
14
14
  include Revelator
15
- attr_accessor :on_disconnect, :on_connect, :actions
15
+ attr_accessor :on_disconnect, :on_callback_exception, :on_connect, :actions
16
16
  attr_accessor :callbacks, :sockets # @api private
17
17
  include Writeable
18
18
 
@@ -21,6 +21,10 @@ module Flammarion
21
21
  # connected (i.e., displayed)
22
22
  # @option options [Proc] :on_disconnect Called when the display windows is
23
23
  # disconnected (i.e., closed)
24
+ # @option options [Proc] :on_callback_exception Called when there is an
25
+ # exception executing a provided callback. (e.g., so you can log it)
26
+ # If no handler is provided, Flammarion will attempt to pass the exception
27
+ # back to the original calling thread.
24
28
  # @option options [Boolean] :exit_on_disconnect (false) Will call +exit+
25
29
  # when the widow is closed if this option is true.
26
30
  # @option options [Boolean] :close_on_exit (false) Will close the window
@@ -39,6 +43,7 @@ module Flammarion
39
43
  @pane_name = "default"
40
44
  @on_connect = options[:on_connect]
41
45
  @on_disconnect = options[:on_disconnect]
46
+ @on_callback_exception = options[:on_callback_exception]
42
47
  @exit_on_disconnect = options.fetch(:exit_on_disconnect, false)
43
48
 
44
49
  start_server
@@ -154,6 +159,12 @@ module Flammarion
154
159
  end
155
160
  end
156
161
  @actions[m["action"]].call(m) if @actions.include?(m["action"])
162
+ rescue Exception
163
+ if @on_callback_exception then
164
+ @on_callback_exception.call($!)
165
+ else
166
+ raise
167
+ end
157
168
  end
158
169
 
159
170
  # @api private
@@ -20,11 +20,7 @@ module Flammarion
20
20
  CHROME_PATH = ENV["FLAMMARION_REVELATOR_PATH"] || 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
21
21
 
22
22
  def open_a_window(options = {})
23
- if RbConfig::CONFIG["host_os"] =~ /cygwin|mswin|mingw/
24
- development_mode = ENV["FLAMMARION_DEVELOPMENT"] == "true"
25
- else
26
- development_mode = system("lsof -i:#{4567}", out: '/dev/null') and File.exist?("#{File.dirname(__FILE__)}/../html/source/index.html.slim")
27
- end
23
+ development_mode = Flammarion.development_mode?
28
24
  host_path = File.absolute_path(File.join(File.dirname(File.absolute_path(__FILE__)), "/../html/build/index.html"))
29
25
  host_path = `cygpath -w '#{host_path}'`.strip if RbConfig::CONFIG["host_os"] == "cygwin"
30
26
  host = "file://#{host_path}"
@@ -117,4 +113,18 @@ module Flammarion
117
113
  return nil
118
114
  end
119
115
  end
116
+
117
+ private
118
+ def self.development_mode?
119
+ if RbConfig::CONFIG["host_os"] =~ /cygwin|mswin|mingw/
120
+ development_mode = ENV["FLAMMARION_DEVELOPMENT"] == "true"
121
+ else
122
+ development_mode = system("lsof -i:#{4567}", out: '/dev/null') and File.exist?("#{File.dirname(__FILE__)}/../html/source/index.html.slim")
123
+ end
124
+ end
125
+
126
+ def self.development_mode=(turnOn)
127
+ raise StandardError.new("Can't turn on development mode on unix system. (Just start the middleman server, and flammarion will detect it automatically.") unless RbConfig::CONFIG["host_os"] =~ /cygwin|mswin|mingw/
128
+ ENV["FLAMMARION_DEVELOPMENT"] = "true"
129
+ end
120
130
  end
@@ -45,7 +45,7 @@ module Flammarion
45
45
  Thread.new do
46
46
  begin
47
47
  @windows[@socket_paths[ws]].process_message(msg)
48
- rescue StandardError => e
48
+ rescue Exception
49
49
  handle_exception($!)
50
50
  end
51
51
  end
@@ -1,3 +1,3 @@
1
1
  module Flammarion
2
- VERSION = "0.1.14"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -361,14 +361,18 @@ module Flammarion
361
361
  # extensions to enable.
362
362
  # @macro add_options
363
363
  def markdown(text, options = {})
364
- markdown_html = Redcarpet::Markdown.new(Redcarpet::Render::HTML, {
365
- tables: true,
366
- fenced_code_blocks: true,
367
- autolink: true,
368
- strikethrough: true,
369
- superscript: true,
370
- }.merge(options[:markdown_extensions] || {})).render(text)
371
- send_json({action:'markdown', text: markdown_html}.merge(options))
364
+ if defined?(Redcarpet::Markdown) then
365
+ markdown_html = Redcarpet::Markdown.new(Redcarpet::Render::HTML, {
366
+ tables: true,
367
+ fenced_code_blocks: true,
368
+ autolink: true,
369
+ strikethrough: true,
370
+ superscript: true,
371
+ }.merge(options[:markdown_extensions] || {})).render(text)
372
+ else
373
+ markdown_html = Kramdown::Document.new(text, {input: 'GFM', hard_wrap: false, syntax_highlighter: nil}.merge(options)).to_html
374
+ end
375
+ send_json({action:'markdown', text: markdown_html, hard_wrap:false}.merge(options))
372
376
  end
373
377
 
374
378
  # Hides (but doesn't close) the pane. This allows the pane to be written
@@ -261,15 +261,17 @@ return"undefined"!=typeof b&&""!==b&&b in a.jsEscapeMap?(d=a.jsEscapeMap[b],e=a.
261
261
  }
262
262
  element = $("#console-" + data.target);
263
263
  element.append(this.__parent.escape(data.text, data));
264
- results = [];
265
- while (element.hasClass("pane")) {
266
- atBottom = atBottomStack.shift();
267
- if (atBottom) {
268
- element.scrollTop(element[0].scrollHeight - element.height() - marginSize);
264
+ if (data.auto_scroll !== false) {
265
+ results = [];
266
+ while (element.hasClass("pane")) {
267
+ atBottom = atBottomStack.shift();
268
+ if (atBottom) {
269
+ element.scrollTop(element[0].scrollHeight - element.height() - marginSize);
270
+ }
271
+ results.push(element = element.parent());
269
272
  }
270
- results.push(element = element.parent());
273
+ return results;
271
274
  }
272
- return results;
273
275
  },
274
276
  replace: function(data) {
275
277
  this.__parent.check_target(data);
@@ -7439,15 +7439,17 @@ window.font_awesome_list = ["glass","music","search","envelope-o","heart","star"
7439
7439
  }
7440
7440
  element = $("#console-" + data.target);
7441
7441
  element.append(this.__parent.escape(data.text, data));
7442
- results = [];
7443
- while (element.hasClass("pane")) {
7444
- atBottom = atBottomStack.shift();
7445
- if (atBottom) {
7446
- element.scrollTop(element[0].scrollHeight - element.height() - marginSize);
7442
+ if (data.auto_scroll !== false) {
7443
+ results = [];
7444
+ while (element.hasClass("pane")) {
7445
+ atBottom = atBottomStack.shift();
7446
+ if (atBottom) {
7447
+ element.scrollTop(element[0].scrollHeight - element.height() - marginSize);
7448
+ }
7449
+ results.push(element = element.parent());
7447
7450
  }
7448
- results.push(element = element.parent());
7451
+ return results;
7449
7452
  }
7450
- return results;
7451
7453
  },
7452
7454
  replace: function(data) {
7453
7455
  this.__parent.check_target(data);
@@ -432,6 +432,7 @@ Railscasts-like style (c) Visoft, Inc. (Damien White)
432
432
  color: #e6e1dc;
433
433
  -webkit-text-size-adjust: none;
434
434
  border-radius: 5px;
435
+ white-space: pre;
435
436
  }
436
437
  .hljs-comment,
437
438
  .hljs-shebang {
@@ -11,6 +11,7 @@ Railscasts-like style (c) Visoft, Inc. (Damien White)
11
11
  color: #e6e1dc;
12
12
  -webkit-text-size-adjust: none;
13
13
  border-radius: 5px;
14
+ white-space: pre;
14
15
  }
15
16
  .hljs-comment,
16
17
  .hljs-shebang {
@@ -14,10 +14,11 @@ $.extend WSClient.prototype.actions,
14
14
  element = $("#console-#{data.target}")
15
15
  element.append(@__parent.escape(data.text, data))
16
16
 
17
- while element.hasClass("pane")
18
- atBottom = atBottomStack.shift()
19
- element.scrollTop(element[0].scrollHeight - element.height() - marginSize) if atBottom
20
- element = element.parent()
17
+ unless data.auto_scroll is false
18
+ while element.hasClass("pane")
19
+ atBottom = atBottomStack.shift()
20
+ element.scrollTop(element[0].scrollHeight - element.height() - marginSize) if atBottom
21
+ element = element.parent()
21
22
 
22
23
  replace: (data) ->
23
24
  @__parent.check_target(data)
@@ -18,6 +18,7 @@ $keyword-color = #c26230
18
18
  color: $normal-text-color;
19
19
  -webkit-text-size-adjust: none;
20
20
  border-radius 5px
21
+ white-space: pre
21
22
 
22
23
 
23
24
  .hljs-comment,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flammarion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-11-24 00:00:00.000000000 Z
12
+ date: 2016-12-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubame
@@ -108,7 +108,7 @@ dependencies:
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  - !ruby/object:Gem::Dependency
111
- name: redcarpet
111
+ name: kramdown
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements: