rails_api_explorer 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,75 @@
|
|
1
|
+
$ ->
|
2
|
+
window.responses = {}
|
3
|
+
|
4
|
+
$(".api-explorer .hidden").hide().removeClass("hidden")
|
5
|
+
|
6
|
+
$(".api-explorer .shared-input.header").change ->
|
7
|
+
updateShareds()
|
8
|
+
|
9
|
+
updateShareds = ->
|
10
|
+
$(".shared-input.header").each ->
|
11
|
+
name = $(this).attr("data-name")
|
12
|
+
$(".shared.header[data-name=" + name + "]").val($(this).val())
|
13
|
+
|
14
|
+
setValuesFromRequest = (request) ->
|
15
|
+
$("[data-source-request='" + request + "']").each (input) ->
|
16
|
+
v = eval("responses['" + request + "']" + $(this).attr("data-source-accessor"))
|
17
|
+
$(this).val(v)
|
18
|
+
updateShareds()
|
19
|
+
|
20
|
+
# Enable / disable params
|
21
|
+
$(".param input").prop("disabled", false) # Firefox autocomplete workaround
|
22
|
+
|
23
|
+
$(".send-toggle").click (event) ->
|
24
|
+
event.preventDefault()
|
25
|
+
|
26
|
+
setState = (elements, state) ->
|
27
|
+
elements.each (i, el) ->
|
28
|
+
$(el).attr("data-send", if state then "true" else "false")
|
29
|
+
$(el).find("input").first().prop("disabled", !state)
|
30
|
+
$(el).find(".send-toggle").first().text(if state then "don't send" else "send")
|
31
|
+
$(el).find(".name").first().toggleClass("strikethrough", !state)
|
32
|
+
|
33
|
+
param = $(this).closest(".param")
|
34
|
+
send = (param.attr("data-send") != "true") # invert current state
|
35
|
+
setState(param.add(param.find(".param")), send) # enable or disable children
|
36
|
+
if send
|
37
|
+
setState(param.parents(".param"), true) # enable parents
|
38
|
+
|
39
|
+
$(".api-explorer form").submit (event) ->
|
40
|
+
event.preventDefault()
|
41
|
+
|
42
|
+
form = $(this)
|
43
|
+
req = form.serializeObject().request
|
44
|
+
form.closest(".request").find(".status").html("Requesting...")
|
45
|
+
|
46
|
+
path = req.path
|
47
|
+
if req.url_params
|
48
|
+
$.each req.url_params, (p, v) ->
|
49
|
+
path = path.replace(":" + p, v)
|
50
|
+
|
51
|
+
$.ajax(
|
52
|
+
url: path,
|
53
|
+
type: req.method,
|
54
|
+
headers: req.headers,
|
55
|
+
data: req.params,
|
56
|
+
dataType: 'json'
|
57
|
+
).always (data, status, error) ->
|
58
|
+
if status == 'success'
|
59
|
+
code = 200
|
60
|
+
key = req.method.toUpperCase() + ":" + req.path.replace(api_explorer_base_url, "")
|
61
|
+
window.responses[key] = data
|
62
|
+
setValuesFromRequest(key)
|
63
|
+
else
|
64
|
+
code = data.status
|
65
|
+
try
|
66
|
+
data = $.parseJSON(data.responseText)
|
67
|
+
catch SyntaxError
|
68
|
+
# nothing
|
69
|
+
|
70
|
+
if code == 0
|
71
|
+
form.closest(".request").find(".status").text("Can't reach server")
|
72
|
+
form.closest(".request").find(".response").hide()
|
73
|
+
else
|
74
|
+
form.closest(".request").find(".status").text(code)
|
75
|
+
form.closest(".request").find(".response").text(JSON.stringify(data, null, 4)).show()
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_self
|
14
|
+
*= require_tree ./api_explorer
|
15
|
+
*/
|
16
|
+
|
17
|
+
@import 'bootstrap-sprockets';
|
18
|
+
@import 'bootstrap';
|
@@ -0,0 +1,72 @@
|
|
1
|
+
.api-explorer {
|
2
|
+
.hidden {
|
3
|
+
display: none;
|
4
|
+
}
|
5
|
+
|
6
|
+
.params .params {
|
7
|
+
margin-left: 30px;
|
8
|
+
}
|
9
|
+
|
10
|
+
.param-inputs .param-inputs {
|
11
|
+
margin-left: 30px;
|
12
|
+
}
|
13
|
+
|
14
|
+
.param-inputs fieldset {
|
15
|
+
border: none;
|
16
|
+
padding: 0;
|
17
|
+
}
|
18
|
+
.param-inputs input {
|
19
|
+
border: none;
|
20
|
+
}
|
21
|
+
h3 input {
|
22
|
+
border: none;
|
23
|
+
width: 120px;
|
24
|
+
text-align: center;
|
25
|
+
}
|
26
|
+
|
27
|
+
legend {
|
28
|
+
margin-bottom: 5px;
|
29
|
+
}
|
30
|
+
.param-inputs legend {
|
31
|
+
font-size: 100%;
|
32
|
+
border: none;
|
33
|
+
margin-bottom: 0;
|
34
|
+
}
|
35
|
+
label {
|
36
|
+
font-weight: normal;
|
37
|
+
margin-bottom: 0;
|
38
|
+
}
|
39
|
+
|
40
|
+
.response {
|
41
|
+
border: solid 1px black;
|
42
|
+
background-color: #CCC;
|
43
|
+
padding: 20px;
|
44
|
+
max-height: 400px;
|
45
|
+
overflow: scroll;
|
46
|
+
}
|
47
|
+
|
48
|
+
.description {
|
49
|
+
font-size: 80%;
|
50
|
+
}
|
51
|
+
|
52
|
+
fieldset {
|
53
|
+
margin-bottom: 5px;
|
54
|
+
}
|
55
|
+
|
56
|
+
legend, label {
|
57
|
+
position: relative;
|
58
|
+
}
|
59
|
+
|
60
|
+
.send-toggle {
|
61
|
+
font-size: 80%;
|
62
|
+
cursor: pointer;
|
63
|
+
display: none;
|
64
|
+
}
|
65
|
+
:hover > .send-toggle {
|
66
|
+
display: inline;
|
67
|
+
}
|
68
|
+
|
69
|
+
.strikethrough {
|
70
|
+
text-decoration: line-through;
|
71
|
+
}
|
72
|
+
}
|
data/lib/api_explorer/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_api_explorer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -150,8 +150,10 @@ files:
|
|
150
150
|
- app/controllers/api_explorer/application_controller.rb
|
151
151
|
- app/helpers/api_explorer/application_helper.rb
|
152
152
|
- app/helpers/api_explorer/explorer_helper.rb
|
153
|
-
- app/assets/stylesheets/api_explorer/explorer.
|
153
|
+
- app/assets/stylesheets/api_explorer/explorer.scss
|
154
|
+
- app/assets/stylesheets/api_explorer.css.scss
|
154
155
|
- app/assets/javascripts/api_explorer/serialize_object.js
|
156
|
+
- app/assets/javascripts/api_explorer/explorer.coffee
|
155
157
|
- app/assets/javascripts/api_explorer.js
|
156
158
|
- app/views/api_explorer/explorer/_node.html.erb
|
157
159
|
- app/views/api_explorer/explorer/perform_request.html.erb
|
@@ -1,44 +0,0 @@
|
|
1
|
-
.api-explorer .hidden {
|
2
|
-
display: none; }
|
3
|
-
.api-explorer .params .params {
|
4
|
-
margin-left: 30px; }
|
5
|
-
.api-explorer .param-inputs .param-inputs {
|
6
|
-
margin-left: 30px; }
|
7
|
-
.api-explorer .param-inputs fieldset {
|
8
|
-
border: none;
|
9
|
-
padding: 0; }
|
10
|
-
.api-explorer .param-inputs input {
|
11
|
-
border: none; }
|
12
|
-
.api-explorer h3 input {
|
13
|
-
border: none;
|
14
|
-
width: 120px;
|
15
|
-
text-align: center; }
|
16
|
-
.api-explorer legend {
|
17
|
-
margin-bottom: 5px; }
|
18
|
-
.api-explorer .param-inputs legend {
|
19
|
-
font-size: 100%;
|
20
|
-
border: none;
|
21
|
-
margin-bottom: 0; }
|
22
|
-
.api-explorer label {
|
23
|
-
font-weight: normal;
|
24
|
-
margin-bottom: 0; }
|
25
|
-
.api-explorer .response {
|
26
|
-
border: solid 1px black;
|
27
|
-
background-color: #CCC;
|
28
|
-
padding: 20px;
|
29
|
-
max-height: 400px;
|
30
|
-
overflow: scroll; }
|
31
|
-
.api-explorer .description {
|
32
|
-
font-size: 80%; }
|
33
|
-
.api-explorer fieldset {
|
34
|
-
margin-bottom: 5px; }
|
35
|
-
.api-explorer legend, .api-explorer label {
|
36
|
-
position: relative; }
|
37
|
-
.api-explorer .send-toggle {
|
38
|
-
font-size: 80%;
|
39
|
-
cursor: pointer;
|
40
|
-
display: none; }
|
41
|
-
.api-explorer :hover > .send-toggle {
|
42
|
-
display: inline; }
|
43
|
-
.api-explorer .strikethrough {
|
44
|
-
text-decoration: line-through; }
|