flammarion 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -78,7 +78,7 @@ f.button("Click Here!!!") {f.puts "You clicked the button!"}
78
78
  f.input("Placeholder > ") {|msg| f.puts "You wrote: #{msg['text'].light_magenta}"}
79
79
  ```
80
80
 
81
- The [api documetaion](http://zach-capalbo.github.io/flammarion/doc/Flammarion.html)
81
+ The [api documentation](http://zach-capalbo.github.io/flammarion/doc/Flammarion.html)
82
82
  is available at <http://zach-capalbo.github.io/flammarion/doc/Flammarion.html>.
83
83
 
84
84
  ## Screenshots / Samples
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ electron .
data/electron/main.coffee CHANGED
@@ -1,14 +1,18 @@
1
1
  app = require 'app'
2
2
  BrowserWindow = require('browser-window')
3
- require('crash-reporter').start()
4
3
  path = require('path')
4
+ shell = require('electron').shell
5
5
 
6
6
  app.on 'ready', ->
7
7
  preload = path.resolve(path.join(__dirname, 'preload.js'))
8
8
  main_window = new BrowserWindow
9
- width:800
10
- height: 600
9
+ width: parseInt(process.argv[3]) || 800
10
+ height: parseInt(process.argv[4]) || 600
11
11
  "node-integration": false
12
12
  "web-security":false
13
+ icon:"icon.png"
13
14
  preload:preload
14
- main_window.loadUrl(process.argv[2])
15
+ main_window.loadURL(process.argv[2])
16
+ main_window.webContents.on 'new-window', (event, url) ->
17
+ event.preventDefault()
18
+ shell.openExternal(url)
data/electron/main.js CHANGED
@@ -1,26 +1,31 @@
1
1
  // Generated by CoffeeScript 1.9.0
2
2
  (function() {
3
- var BrowserWindow, app, path;
3
+ var BrowserWindow, app, path, shell;
4
4
 
5
5
  app = require('app');
6
6
 
7
7
  BrowserWindow = require('browser-window');
8
8
 
9
- require('crash-reporter').start();
10
-
11
9
  path = require('path');
12
10
 
11
+ shell = require('electron').shell;
12
+
13
13
  app.on('ready', function() {
14
14
  var main_window, preload;
15
15
  preload = path.resolve(path.join(__dirname, 'preload.js'));
16
16
  main_window = new BrowserWindow({
17
- width: 800,
18
- height: 600,
17
+ width: parseInt(process.argv[3]) || 800,
18
+ height: parseInt(process.argv[4]) || 600,
19
19
  "node-integration": false,
20
20
  "web-security": false,
21
+ icon: "icon.png",
21
22
  preload: preload
22
23
  });
23
- return main_window.loadUrl(process.argv[2]);
24
+ main_window.loadURL(process.argv[2]);
25
+ return main_window.webContents.on('new-window', function(event, url) {
26
+ event.preventDefault();
27
+ return shell.openExternal(url);
28
+ });
24
29
  });
25
30
 
26
31
  }).call(this);
@@ -1,5 +1,13 @@
1
1
  {
2
2
  "name" : "flammarion",
3
3
  "version" : "0.1.0",
4
- "main" : "main.js"
4
+ "main" : "main.js",
5
+ "dependencies": {
6
+ "spellchecker": "^3.2.1",
7
+ "nan": "^2.0.0"
8
+ },
9
+ "packageDependencies": {
10
+ "spellchecker": "^3.2.1",
11
+ "nan": "^2.0.0"
12
+ }
5
13
  }
@@ -1,5 +1,17 @@
1
1
  window.$remote = require('remote')
2
2
 
3
+ webFrame = require('web-frame')
4
+
5
+ try
6
+ spellcheck = require('spellchecker')
7
+
8
+ webFrame.setSpellCheckProvider("en-US", true, {
9
+ spellCheck: (text) ->
10
+ return !spellcheck.isMisspelled(text)
11
+ })
12
+ catch error
13
+ console.log("Could not load spellchecker: #{error}")
14
+
3
15
  window.onkeyup = (e) ->
4
16
  if e.ctrlKey and e.keyCode is 70
5
17
  window.show_search_bar()
data/electron/preload.js CHANGED
@@ -1,7 +1,23 @@
1
1
  // Generated by CoffeeScript 1.9.0
2
2
  (function() {
3
+ var error, spellcheck, webFrame;
4
+
3
5
  window.$remote = require('remote');
4
6
 
7
+ webFrame = require('web-frame');
8
+
9
+ try {
10
+ spellcheck = require('spellchecker');
11
+ webFrame.setSpellCheckProvider("en-US", true, {
12
+ spellCheck: function(text) {
13
+ return !spellcheck.isMisspelled(text);
14
+ }
15
+ });
16
+ } catch (_error) {
17
+ error = _error;
18
+ console.log("Could not load spellchecker: " + error);
19
+ }
20
+
5
21
  window.onkeyup = function(e) {
6
22
  if (e.ctrlKey && e.keyCode === 70) {
7
23
  return window.show_search_bar();
@@ -72,7 +72,7 @@ module Flammarion
72
72
 
73
73
  browser :electron do |options|
74
74
  if which('electron') then
75
- Process.detach(spawn("electron #{File.dirname(File.absolute_path(__FILE__))}/../../electron '#{options[:url]}'"))
75
+ Process.detach(spawn("electron #{File.dirname(File.absolute_path(__FILE__))}/../../electron '#{options[:url]}' #{options[:width]} #{options[:height]}"))
76
76
  return true
77
77
  end
78
78
  false
@@ -1,3 +1,3 @@
1
1
  module Flammarion
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -311,13 +311,24 @@ module Flammarion
311
311
  send_json({action:'script', data:data}.merge(options))
312
312
  end
313
313
 
314
- # Sets a CSS styles attribute on the current pane.
315
- # @param attribute [String] The css attribute to set. Currently does not
316
- # support selectors or anything.
317
- # @param value [#to_s] The value to set the attribute to. (Don't forget
318
- # units!)
319
- def style(attribute, value)
320
- send_json({action: 'style', attribute: attribute, value: value})
314
+ # Sets CSS styles attributes on the current pane.
315
+ # @overload style(attribute, value)
316
+ # @param attribute [String] The css attribute to set. Currently does not
317
+ # support selectors or anything.
318
+ # @param value [#to_s] The value to set the attribute to. (Don't forget
319
+ # units!)
320
+ # @overload style(attributes)
321
+ # @param attributes [Hash] Table of css attribute to value mapping to set.
322
+ def style(*args)
323
+ case args.length
324
+ when 1
325
+ # @todo Pass this as a whole hash, rather than individually.
326
+ args[0].each{|a,v| send_json({action: 'style', attribute: a, value: v})}
327
+ when 2
328
+ send_json({action: 'style', attribute: args[0], value: args[1]})
329
+ else
330
+ raise ArgumentError.new("Invalid number of arguments (Expected 1 or 2)")
331
+ end
321
332
  end
322
333
 
323
334
  # Will render the given Slim template into the Writeable area. This is
@@ -152,6 +152,12 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
152
152
  return results;
153
153
  };
154
154
 
155
+ WSClient.prototype.relink = function(text) {
156
+ return text.replace(/\<a href=['"](https?:\/\/[^\s]+)["']>/gm, function(str, l) {
157
+ return "<a href=\"" + l + "\" target='_blank'>";
158
+ });
159
+ };
160
+
155
161
  WSClient.prototype.escape = function(text, input_options) {
156
162
  var options;
157
163
  options = {
@@ -178,11 +184,14 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
178
184
  return "<i class='fa fa-" + match.slice(1, -1) + "'></i>";
179
185
  });
180
186
  }
181
- return text;
187
+ text = $("<div>" + text + "</div>");
188
+ text.find("a[href^='http']").attr('target', '_blank');
189
+ return text.html();
182
190
  };
183
191
 
184
192
  WSClient.prototype.add = function(object, target, data) {
185
193
  var key, ref, val;
194
+ object.find("a[href^='http']").attr('target', '_blank');
186
195
  if (data.style) {
187
196
  ref = data.style;
188
197
  for (key in ref) {
@@ -6773,6 +6773,12 @@ if (typeof module !== 'undefined') {
6773
6773
  return results;
6774
6774
  };
6775
6775
 
6776
+ WSClient.prototype.relink = function(text) {
6777
+ return text.replace(/\<a href=['"](https?:\/\/[^\s]+)["']>/gm, function(str, l) {
6778
+ return "<a href=\"" + l + "\" target='_blank'>";
6779
+ });
6780
+ };
6781
+
6776
6782
  WSClient.prototype.escape = function(text, input_options) {
6777
6783
  var options;
6778
6784
  options = {
@@ -6799,11 +6805,14 @@ if (typeof module !== 'undefined') {
6799
6805
  return "<i class='fa fa-" + match.slice(1, -1) + "'></i>";
6800
6806
  });
6801
6807
  }
6802
- return text;
6808
+ text = $("<div>" + text + "</div>");
6809
+ text.find("a[href^='http']").attr('target', '_blank');
6810
+ return text.html();
6803
6811
  };
6804
6812
 
6805
6813
  WSClient.prototype.add = function(object, target, data) {
6806
6814
  var key, ref, val;
6815
+ object.find("a[href^='http']").attr('target', '_blank');
6807
6816
  if (data.style) {
6808
6817
  ref = data.style;
6809
6818
  for (key in ref) {
@@ -152,6 +152,12 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
152
152
  return results;
153
153
  };
154
154
 
155
+ WSClient.prototype.relink = function(text) {
156
+ return text.replace(/\<a href=['"](https?:\/\/[^\s]+)["']>/gm, function(str, l) {
157
+ return "<a href=\"" + l + "\" target='_blank'>";
158
+ });
159
+ };
160
+
155
161
  WSClient.prototype.escape = function(text, input_options) {
156
162
  var options;
157
163
  options = {
@@ -178,11 +184,14 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
178
184
  return "<i class='fa fa-" + match.slice(1, -1) + "'></i>";
179
185
  });
180
186
  }
181
- return text;
187
+ text = $("<div>" + text + "</div>");
188
+ text.find("a[href^='http']").attr('target', '_blank');
189
+ return text.html();
182
190
  };
183
191
 
184
192
  WSClient.prototype.add = function(object, target, data) {
185
193
  var key, ref, val;
194
+ object.find("a[href^='http']").attr('target', '_blank');
186
195
  if (data.style) {
187
196
  ref = data.style;
188
197
  for (key in ref) {
@@ -152,6 +152,12 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
152
152
  return results;
153
153
  };
154
154
 
155
+ WSClient.prototype.relink = function(text) {
156
+ return text.replace(/\<a href=['"](https?:\/\/[^\s]+)["']>/gm, function(str, l) {
157
+ return "<a href=\"" + l + "\" target='_blank'>";
158
+ });
159
+ };
160
+
155
161
  WSClient.prototype.escape = function(text, input_options) {
156
162
  var options;
157
163
  options = {
@@ -178,11 +184,14 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
178
184
  return "<i class='fa fa-" + match.slice(1, -1) + "'></i>";
179
185
  });
180
186
  }
181
- return text;
187
+ text = $("<div>" + text + "</div>");
188
+ text.find("a[href^='http']").attr('target', '_blank');
189
+ return text.html();
182
190
  };
183
191
 
184
192
  WSClient.prototype.add = function(object, target, data) {
185
193
  var key, ref, val;
194
+ object.find("a[href^='http']").attr('target', '_blank');
186
195
  if (data.style) {
187
196
  ref = data.style;
188
197
  for (key in ref) {
@@ -152,6 +152,12 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
152
152
  return results;
153
153
  };
154
154
 
155
+ WSClient.prototype.relink = function(text) {
156
+ return text.replace(/\<a href=['"](https?:\/\/[^\s]+)["']>/gm, function(str, l) {
157
+ return "<a href=\"" + l + "\" target='_blank'>";
158
+ });
159
+ };
160
+
155
161
  WSClient.prototype.escape = function(text, input_options) {
156
162
  var options;
157
163
  options = {
@@ -178,11 +184,14 @@ void 0===c?d&&"get"in d&&null!==(e=d.get(a,b))?e:(e=n.find.attr(a,b),null==e?voi
178
184
  return "<i class='fa fa-" + match.slice(1, -1) + "'></i>";
179
185
  });
180
186
  }
181
- return text;
187
+ text = $("<div>" + text + "</div>");
188
+ text.find("a[href^='http']").attr('target', '_blank');
189
+ return text.html();
182
190
  };
183
191
 
184
192
  WSClient.prototype.add = function(object, target, data) {
185
193
  var key, ref, val;
194
+ object.find("a[href^='http']").attr('target', '_blank');
186
195
  if (data.style) {
187
196
  ref = data.style;
188
197
  for (key in ref) {
@@ -677,6 +677,7 @@ p a,
677
677
  -ms-user-select: text;
678
678
  user-select: text;
679
679
  font-family: monospace;
680
+ white-space: pre-wrap;
680
681
  }
681
682
  .pane > .pane {
682
683
  width: calc(100% + 16px);
@@ -55,6 +55,7 @@ p a,
55
55
  -ms-user-select: text;
56
56
  user-select: text;
57
57
  font-family: monospace;
58
+ white-space: pre-wrap;
58
59
  }
59
60
  .pane > .pane {
60
61
  width: calc(100% + 16px);
@@ -59,6 +59,11 @@ class WSClient
59
59
  $(pane).css "height", p_height(pane)
60
60
  $(pane).css "width", '100%'
61
61
 
62
+ relink: (text) ->
63
+ text.replace(/\<a href=['"](https?:\/\/[^\s]+)["']>/gm, (str, l) ->
64
+ "<a href=\"#{l}\" target='_blank'>"
65
+ )
66
+
62
67
  escape: (text, input_options) ->
63
68
  options =
64
69
  raw: false
@@ -70,11 +75,15 @@ class WSClient
70
75
  text = "#{text}"
71
76
  text = ansi_up.escape_for_html(text) if options.escape_html
72
77
  text = ansi_up.ansi_to_html(text, {use_classes:true}) if options.colorize
78
+ # text = @relink(text)
73
79
  text = text.replace(/:[\w-]+:/g, (match) ->
74
80
  "<i class='fa fa-#{match[1..-2]}'></i>") if options.escape_icons
75
- return text
81
+ text = $("<div>#{text}</div>")
82
+ text.find("a[href^='http']").attr('target','_blank')
83
+ return text.html()
76
84
 
77
85
  add: (object, target, data) ->
86
+ object.find("a[href^='http']").attr('target','_blank')
78
87
  if data.style
79
88
  object.css(key, val) for own key, val of data.style
80
89
  if data.replace
@@ -47,6 +47,7 @@ a
47
47
  position relative
48
48
  user-select text
49
49
  font-family $main-font
50
+ white-space pre-wrap
50
51
 
51
52
  .pane > .pane
52
53
  width calc(100% + 16px)
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.5
4
+ version: 0.1.6
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-02-01 00:00:00.000000000 Z
12
+ date: 2016-04-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rubame
@@ -366,6 +366,7 @@ files:
366
366
  - LICENSE
367
367
  - Readme.md
368
368
  - electron/package.json
369
+ - electron/flammarion-window.sh
369
370
  - electron/main.js
370
371
  - electron/icon.png
371
372
  - electron/preload.coffee