rails-web-console 0.0.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.
- data/README +12 -0
- data/app/controllers/console_controller.rb +20 -0
- data/app/views/console/index.html.erb +3 -0
- data/app/views/layouts/console.html.erb +14 -0
- data/config/routes.rb +4 -0
- data/lib/console.rb +7 -0
- data/public/javascripts/console.js +8 -0
- data/public/stylesheets/console.css +10 -0
- metadata +71 -0
data/README
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
Console
|
2
|
+
=======
|
3
|
+
|
4
|
+
A Rails 3 plugin for running Ruby scripts on the browser in the context of a controller action.
|
5
|
+
|
6
|
+
Just put it in your vendor/plugins/console. For instance:
|
7
|
+
|
8
|
+
git submodule add git://github.com/rosenfeld/rails-web-console.git vendor/plugins/console
|
9
|
+
|
10
|
+
Then, access "/console" in your browser.
|
11
|
+
|
12
|
+
Copyright (c) 2010 [Rodrigo Rosenfeld Rosas], released under the MIT license
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'stringio'
|
2
|
+
class ConsoleController < ApplicationController
|
3
|
+
def index
|
4
|
+
end
|
5
|
+
|
6
|
+
def run
|
7
|
+
session[:script] = params[:script]
|
8
|
+
stdout_orig = $stdout
|
9
|
+
$stdout = StringIO.new
|
10
|
+
begin
|
11
|
+
result_eval = eval params[:script], binding
|
12
|
+
$stdout.rewind
|
13
|
+
result = %Q{<div class="stdout">#{$stdout.read}</div><div class="return">#{result_eval.inspect}</div>}
|
14
|
+
rescue Exception => e
|
15
|
+
result = e.to_s
|
16
|
+
end
|
17
|
+
$stdout = stdout_orig
|
18
|
+
render text: result.gsub("\n", "<br />\n")
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Console</title>
|
5
|
+
<%= javascript_include_tag 'http://code.jquery.com/jquery-1.4.2.min.js' %>
|
6
|
+
<%= javascript_include_tag 'console' %>
|
7
|
+
<%= stylesheet_link_tag 'console' %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
data/lib/console.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
jQuery(function($) {
|
2
|
+
$('#clearResults').click(function() { $('#results').empty() })
|
3
|
+
$('#runScript').click(function() {
|
4
|
+
$.post('/console/run', {script: $('#script').val()}, function(data) {
|
5
|
+
$('<div/>').attr('class', 'console_result').html(data).appendTo('#results')
|
6
|
+
})
|
7
|
+
})
|
8
|
+
})
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rails-web-console
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Rodrigo Rosenfeld Rosas
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-11-06 00:00:00 -02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description:
|
22
|
+
email: rr_rosas@yahoo.com.br
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README
|
29
|
+
files:
|
30
|
+
- app/controllers/console_controller.rb
|
31
|
+
- app/views/console/index.html.erb
|
32
|
+
- app/views/layouts/console.html.erb
|
33
|
+
- config/routes.rb
|
34
|
+
- lib/console.rb
|
35
|
+
- public/javascripts/console.js
|
36
|
+
- public/stylesheets/console.css
|
37
|
+
- README
|
38
|
+
has_rdoc: true
|
39
|
+
homepage:
|
40
|
+
licenses: []
|
41
|
+
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options:
|
44
|
+
- --charset=UTF-8
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
none: false
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
version: "0"
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
requirements: []
|
64
|
+
|
65
|
+
rubyforge_project:
|
66
|
+
rubygems_version: 1.3.7
|
67
|
+
signing_key:
|
68
|
+
specification_version: 3
|
69
|
+
summary: A web console for Rails
|
70
|
+
test_files: []
|
71
|
+
|