flammarion_rails 0.2.0 → 0.2.1

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: 82f678ee45aa83dc6f693ddecaf234234bd8b88b
4
- data.tar.gz: 4f9cc9687450d7a2b97e4385e3f4915926b959a5
3
+ metadata.gz: 71625fc08d749a8dfe8dfc6f7b5ef770e5700f23
4
+ data.tar.gz: d6208f1d93881a2ceb3622abede691f9a9380ef9
5
5
  SHA512:
6
- metadata.gz: 2ce96110cd29735488158aed429a3a69bb6fab4374f0dd84c7746591ffd9d2aed5786b22c69202e2c358f110a7c51fc148cdfde16fa984ff19dd17b2d42e5c4c
7
- data.tar.gz: c8a5537202c493f4e09a261dd081b3787e32d19e9680eecee18c108c80c679cabb7e872de216f5bed5c4a8ef11a5339bddca38719f05e101e539408b760ffbcc
6
+ metadata.gz: d6cdb11f7de83f5b5770854eac952a2bc2a6670c3e474e2e25947910782d2be9a67465d08ab5236a7c22d309c1617113864eeab68b773f5282ce1bfdeba5a130
7
+ data.tar.gz: 79321714b0fca0ebf85470889d5b77609affb4de5bb6636e4f5d1b72e91aa8b0614eee8d9b98520c3d0de8d625096833faa10696be61dfdb98b98bb6060259f3
data/README.md CHANGED
@@ -14,14 +14,12 @@
14
14
 
15
15
  * TODO: disable refresh / reload (disable left click)
16
16
 
17
- * TODO: rack integration --> railties-5.0.0.1/lib/rails/engine.rb
17
+ * TODO: all 'action_dispatch.request....' or rack integration --> railties-5.0.0.1/lib/rails/engine.rb
18
18
 
19
19
  * TODO: 404 and errors (rotate log files)
20
20
 
21
21
  * TODO: settings/preferences
22
22
 
23
- * TODO: try if 'action_dispatch.request.path_parameters' filled could prevent rails_admin to crash in index_path
24
-
25
23
  * TODO: non-blocking download
26
24
 
27
25
  * TODO: use pjax layout instead of full layout
@@ -34,7 +34,7 @@ if $.pjax?
34
34
 
35
35
  ws.onmessage_actions.pjax = (event) ->
36
36
  new_page = $("<div>")
37
- new_page.html(ws_data.html)
37
+ new_page.html(ws_data.body)
38
38
  container = new_page.find('[data-pjax-container]')
39
39
  $('[data-pjax-container]').html(container.html())
40
40
  $(document).trigger('rails_admin.dom_ready')
@@ -12,10 +12,7 @@ module Flammarion
12
12
  # disconnected (i.e., closed)
13
13
  # @option options [Boolean] :exit_on_disconnect (false) Will call +exit+
14
14
  # when the widow is closed if this option is true.
15
- # @option options [Boolean] :close_on_exit (false) Will close the window
16
- # when the process exits if this is true. Otherwise, it will just stay
17
- # around, but not actually be interactive.
18
- # @raise {SetupError} if neither chrome is set up correctly and
15
+ # @raise {SetupError} if chrome is not set up correctly and
19
16
  # and Flammarion is unable to display the engraving.
20
17
  def initialize(**options)
21
18
  @chrome = OpenStruct.new
@@ -28,8 +25,6 @@ module Flammarion
28
25
  @window_id = @@server.register_window(self)
29
26
  open_a_window(options) unless options[:no_window]
30
27
  wait_for_a_connection unless options[:no_wait]
31
-
32
- at_exit {close if window_open?} if options.fetch(:close_on_exit, true)
33
28
  end
34
29
 
35
30
  # Blocks the current thread until the window has been closed. All user
@@ -38,11 +33,6 @@ module Flammarion
38
33
  sleep 1 until @sockets.empty?
39
34
  end
40
35
 
41
- # Is this Engraving displayed on the screen.
42
- def window_open?
43
- !@sockets.empty?
44
- end
45
-
46
36
  def disconnect(ws)
47
37
  @sockets.delete ws
48
38
  exit 0 if @exit_on_disconnect
@@ -55,18 +45,14 @@ module Flammarion
55
45
  dispatch(params)
56
46
 
57
47
  if status == 302
58
- params = {
59
- url: headers['Location'].sub(/^.*:\/{2}(:\d{0,4})?/i, ''),
60
- session: response.request.session
61
- }.with_indifferent_access
62
- dispatch(params)
63
- render(action: 'page', html: response.body)
48
+ dispatch(url: headers['Location'].sub(/^.*:\/{2}(:\d{0,4})?/i, ''), session: response.request.session)
49
+ render(action: 'page', body: response.body)
64
50
  elsif headers['Content-Transfer-Encoding'] == 'binary'
65
51
  filename = headers['Content-Disposition'].sub(/.*filename=/, '').gsub(/(^"|"$)/, '')
66
52
  render(action: 'file', name: filename)
67
53
  render(response.body)
68
54
  else
69
- render(action: action, html: response.body)
55
+ render(action: action, body: response.body)
70
56
  end
71
57
 
72
58
  rescue => e
@@ -90,11 +76,11 @@ module Flammarion
90
76
  if params.key?(:_method)
91
77
  params[:method] = params[:_method]
92
78
  end
93
- params[:method] ||= :get
79
+ http_method = (params[:method] ||= :get).to_s.upcase!
94
80
 
95
- path_params = recognize_path(url, params)
81
+ path_params = recognize_path(uri.path, params.merge!(query_params))
96
82
  unless path_params.key?(:controller)
97
- raise ActionController::RoutingError, "No route matches [#{url}]#{params.inspect}"
83
+ raise ActionController::RoutingError, "No route matches [#{http_method}] #{url}"
98
84
  end
99
85
 
100
86
  controller_name = "#{path_params[:controller].underscore.camelize}Controller"
@@ -102,8 +88,9 @@ module Flammarion
102
88
  action = path_params[:action] || 'index'
103
89
  request_env = {
104
90
  'rack.input' => '',
105
- 'REQUEST_METHOD' => params[:method].to_s.upcase,
106
- 'action_dispatch.request.parameters' => path_params.merge!(params).merge!(query_params),
91
+ 'REQUEST_METHOD' => http_method,
92
+ 'action_dispatch.request.parameters' => params.merge!(path_params),
93
+ 'action_dispatch.request.path_parameters' => path_params,
107
94
  }
108
95
  request_env['rack.session'] = session if session
109
96
  self.request = ActionDispatch::Request.new(request_env)
@@ -1,3 +1,3 @@
1
1
  module FlammarionRails
2
- VERSION = '0.2.0'
2
+ VERSION = '0.2.1'
3
3
  end
data/public/index.js CHANGED
@@ -81,7 +81,7 @@ ws.onmessage_skip_action = false;
81
81
  ws.onmessage_actions = {
82
82
  page: function (event) {
83
83
  var page = document.open("text/html", "replace");
84
- page.write(ws_data.html);
84
+ page.write(ws_data.body);
85
85
  page.close();
86
86
  },
87
87
  error: function (event) {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flammarion_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrice Lebel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-10 00:00:00.000000000 Z
11
+ date: 2016-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails