try_api 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/try_api/application.js.coffee +6 -9
- data/app/assets/javascripts/try_api/image.directive.js +1 -3
- data/app/assets/javascripts/try_api/param.directive.js.coffee +1 -2
- data/app/assets/javascripts/try_api/params.directive.js.coffee +2 -2
- data/app/assets/javascripts/try_api/paramsarray.directive.js.coffee +1 -2
- data/app/assets/javascripts/try_api/url.directive.js.coffee +40 -0
- data/app/models/try_api/base.rb +6 -3
- data/app/views/try_api/pages/index.html +2 -2
- data/lib/try_api/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2ecbc0b9fe2f833f16c373593fd4b7d3082d30e
|
4
|
+
data.tar.gz: ae4f6997359ec3c60ffbdb2f4dc882ae8452a567
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4673b1f0d0df87785799af919b2a7982038b6313ec6489096992e6bb426408c2b18285d57ceda82c34d355cd4051ca29e36a050a33529c8c760d6f97ec88ef91
|
7
|
+
data.tar.gz: 282f6fdbdcefcdb69b3ef7eaec7ce7649bb247f517b5376771e3a0c1b2f3542c4b07a90051328f14c029c5301c14e1e3207e448cfffea8ef06a05e50783fc847
|
@@ -9,6 +9,7 @@
|
|
9
9
|
#= require try_api/param.directive
|
10
10
|
#= require try_api/paramsarray.directive
|
11
11
|
#= require try_api/image.directive
|
12
|
+
#= require try_api/url.directive
|
12
13
|
|
13
14
|
$ ->
|
14
15
|
$('pre code').each (i, block) ->
|
@@ -34,11 +35,8 @@ $ ->
|
|
34
35
|
TryApiApp = angular.module('TryApiApp', [
|
35
36
|
'ui.bootstrap'
|
36
37
|
'ngAnimate'
|
37
|
-
'
|
38
|
+
'TryApi'
|
38
39
|
'angular-ladda'
|
39
|
-
'param'
|
40
|
-
'params'
|
41
|
-
'paramsarray'
|
42
40
|
'hljs'
|
43
41
|
])
|
44
42
|
TryApiApp.config [
|
@@ -128,7 +126,6 @@ TryApiApp.controller 'HomeController', [
|
|
128
126
|
method.submit = ->
|
129
127
|
method.pending = true
|
130
128
|
headers = {'Content-Type': undefined}
|
131
|
-
path = data.project.api_prefix + method.path
|
132
129
|
|
133
130
|
$.each method.headers, (i)->
|
134
131
|
header = this
|
@@ -141,13 +138,13 @@ TryApiApp.controller 'HomeController', [
|
|
141
138
|
$.each method.parameters, (i) ->
|
142
139
|
$scope.addParameterToForm fd, this
|
143
140
|
|
144
|
-
$http.post
|
141
|
+
$http.post method.submit_path, fd,
|
145
142
|
transformRequest: angular.identity
|
146
143
|
headers: headers
|
147
144
|
.success method.response_handler
|
148
145
|
.error method.response_handler
|
149
146
|
when 'delete'
|
150
|
-
$http.delete
|
147
|
+
$http.delete method.submit_path,
|
151
148
|
transformRequest: angular.identity
|
152
149
|
headers: headers
|
153
150
|
.success method.response_handler
|
@@ -159,7 +156,7 @@ TryApiApp.controller 'HomeController', [
|
|
159
156
|
parameter = this
|
160
157
|
fd = fd + parameter.name + '=' + (parameter.value || '') + '&'
|
161
158
|
|
162
|
-
$http.get
|
159
|
+
$http.get method.submit_path + '?' + fd,
|
163
160
|
transformRequest: angular.identity
|
164
161
|
headers: headers
|
165
162
|
.success method.response_handler
|
@@ -170,7 +167,7 @@ TryApiApp.controller 'HomeController', [
|
|
170
167
|
$.each method.parameters, (i) ->
|
171
168
|
$scope.addParameterToForm fd, this
|
172
169
|
|
173
|
-
$http.put
|
170
|
+
$http.put method.submit_path, fd,
|
174
171
|
transformRequest: angular.identity
|
175
172
|
headers: headers
|
176
173
|
.success method.response_handler
|
@@ -1,8 +1,6 @@
|
|
1
1
|
'use strict';
|
2
2
|
|
3
|
-
angular.module('
|
4
|
-
|
5
|
-
angular.module('formInput.image').directive('image', ['$filter', function($filter) {
|
3
|
+
angular.module('TryApi').directive('image', ['$filter', function($filter) {
|
6
4
|
|
7
5
|
function link(scope, element, attributes, ctrl) {
|
8
6
|
|
@@ -0,0 +1,40 @@
|
|
1
|
+
angular.module('TryApi').directive 'url', [
|
2
|
+
'$filter',
|
3
|
+
'$sce'
|
4
|
+
($filter, $sce) ->
|
5
|
+
|
6
|
+
link = (scope, element, attrs, ctrl) ->
|
7
|
+
|
8
|
+
scope.isParameter = (value) ->
|
9
|
+
if value
|
10
|
+
return value.indexOf(':') != -1
|
11
|
+
else
|
12
|
+
return false
|
13
|
+
|
14
|
+
scope.parts = scope.pattern.split('/').filter(Boolean).map (i)->
|
15
|
+
value = if scope.isParameter(i) then '' else i
|
16
|
+
{
|
17
|
+
value: value,
|
18
|
+
placeholder: i
|
19
|
+
}
|
20
|
+
|
21
|
+
scope.$watch 'parts', ->
|
22
|
+
scope.url = scope.parts.map((i)->
|
23
|
+
i.value
|
24
|
+
).join('/')
|
25
|
+
, true
|
26
|
+
|
27
|
+
return {
|
28
|
+
link: link
|
29
|
+
restrict: 'A'
|
30
|
+
require: 'ngModel'
|
31
|
+
scope:
|
32
|
+
url: '=ngModel'
|
33
|
+
pattern: '=pattern'
|
34
|
+
template: '<span ng-repeat="part in parts track by $index">' +
|
35
|
+
'/' +
|
36
|
+
'<span ng-if="!isParameter(part.placeholder)">{{ part.value }}</span>' +
|
37
|
+
'<input ng-if="isParameter(part.placeholder)" ng-model="part.value" placeholder="{{ part.placeholder }}"/>' +
|
38
|
+
'</span>'
|
39
|
+
}
|
40
|
+
]
|
data/app/models/try_api/base.rb
CHANGED
@@ -40,10 +40,13 @@ module TryApi
|
|
40
40
|
result.with_indifferent_access
|
41
41
|
end
|
42
42
|
|
43
|
-
@@
|
43
|
+
@@instances_count = 0
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
attr_accessor :id
|
46
|
+
|
47
|
+
def initialize()
|
48
|
+
super
|
49
|
+
self.id = @@instances_count += 1
|
47
50
|
end
|
48
51
|
end
|
49
52
|
end
|
@@ -36,7 +36,7 @@
|
|
36
36
|
<div class="col-md-6 method-try"><h4>{{ method.title }}</h4>
|
37
37
|
<h4>
|
38
38
|
<div class="label label-info">{{ method.method }}</div>
|
39
|
-
|
39
|
+
<span url=true ng-model="method.submit_path" pattern="method.local_path"></span>
|
40
40
|
</h4>
|
41
41
|
<div ng-if="method.headers.length > 0"><label>Headers:</label>
|
42
42
|
<div class="row parameter" ng-repeat="header in method.headers">
|
@@ -65,7 +65,7 @@
|
|
65
65
|
</div>
|
66
66
|
<br/>
|
67
67
|
<div class="label">Data:</div>
|
68
|
-
<div hljs="" hljs-language="
|
68
|
+
<div hljs="" hljs-language="" hljs-source="method.response.data"></div>
|
69
69
|
<br/>
|
70
70
|
<div class="label">Headers:</div>
|
71
71
|
<div hljs="" hljs-language="json" hljs-source="method.response.headers"></div>
|
data/lib/try_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: try_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mykhaylo Skubenych
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -253,6 +253,7 @@ files:
|
|
253
253
|
- app/assets/javascripts/try_api/param.directive.js.coffee
|
254
254
|
- app/assets/javascripts/try_api/params.directive.js.coffee
|
255
255
|
- app/assets/javascripts/try_api/paramsarray.directive.js.coffee
|
256
|
+
- app/assets/javascripts/try_api/url.directive.js.coffee
|
256
257
|
- app/assets/stylesheets/try_api/application.css.sass
|
257
258
|
- app/controllers/try_api/application_controller.rb
|
258
259
|
- app/controllers/try_api/pages_controller.rb
|