whurl_engine 1.2.2 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (162) hide show
  1. data/README.markdown +2 -0
  2. data/Rakefile +2 -12
  3. data/app/assets/javascripts/whurl_engine/application.js +0 -159
  4. data/app/assets/javascripts/whurl_engine/jquery-ujs.js +315 -0
  5. data/app/assets/javascripts/whurl_engine/jquery.livequery.js +226 -0
  6. data/app/assets/javascripts/whurl_engine/whurl.js +136 -0
  7. data/app/assets/stylesheets/whurl_engine/application.css.scss +88 -1
  8. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-bg_flat_100_ffffff_40x100.png +0 -0
  9. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-bg_flat_10_000000_40x100.png +0 -0
  10. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-bg_flat_18_f6ecd5_40x100.png +0 -0
  11. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-bg_flat_20_666666_40x100.png +0 -0
  12. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  13. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-bg_highlight-hard_100_dddddd_1x100.png +0 -0
  14. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-bg_highlight-hard_100_eeeeee_1x100.png +0 -0
  15. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-bg_highlight-hard_40_f6a828_1x100.png +0 -0
  16. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-bg_highlight-soft_75_f1fbe5_1x100.png +0 -0
  17. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-icons_1c94c4_256x240.png +0 -0
  18. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-icons_222222_256x240.png +0 -0
  19. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-icons_8cce3b_256x240.png +0 -0
  20. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-icons_cd0a0a_256x240.png +0 -0
  21. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-icons_ef8c08_256x240.png +0 -0
  22. data/app/assets/stylesheets/whurl_engine/custom-theme/images/ui-icons_ffffff_256x240.png +0 -0
  23. data/app/assets/stylesheets/whurl_engine/custom-theme/jquery-ui-1.8.16.custom.css +562 -0
  24. data/app/assets/stylesheets/whurl_engine/whurl.css.scss +128 -0
  25. data/app/controllers/whurl_engine/application_controller.rb +2 -0
  26. data/app/controllers/whurl_engine/categories_controller.rb +36 -0
  27. data/app/controllers/whurl_engine/parameter_definitions_controller.rb +32 -0
  28. data/app/controllers/whurl_engine/resources_controller.rb +36 -0
  29. data/app/controllers/whurl_engine/whurls_controller.rb +42 -0
  30. data/app/models/whurl_engine/category.rb +7 -0
  31. data/app/models/whurl_engine/parameter_definition.rb +7 -0
  32. data/app/models/whurl_engine/resource.rb +12 -0
  33. data/app/models/whurl_engine/whurl.rb +66 -0
  34. data/app/views/layouts/whurl_engine/application.html.haml +41 -44
  35. data/app/views/whurl_engine/categories/_category.html.haml +15 -0
  36. data/app/views/whurl_engine/categories/_form.html.haml +24 -0
  37. data/app/views/whurl_engine/categories/create.js.haml +5 -0
  38. data/app/views/whurl_engine/categories/destroy.js.haml +1 -0
  39. data/app/views/whurl_engine/categories/edit.js.haml +3 -0
  40. data/app/views/whurl_engine/categories/index.html.haml +6 -0
  41. data/app/views/whurl_engine/categories/new.js.haml +3 -0
  42. data/app/views/whurl_engine/categories/update.js.haml +6 -0
  43. data/app/views/whurl_engine/parameter_definitions/_form.html.haml +31 -0
  44. data/app/views/whurl_engine/parameter_definitions/_parameter_definition.html.haml +14 -0
  45. data/app/views/whurl_engine/parameter_definitions/create.js.haml +5 -0
  46. data/app/views/whurl_engine/parameter_definitions/destroy.js.haml +1 -0
  47. data/app/views/whurl_engine/parameter_definitions/edit.js.haml +3 -0
  48. data/app/views/whurl_engine/parameter_definitions/new.js.haml +3 -0
  49. data/app/views/whurl_engine/parameter_definitions/update.js.haml +6 -0
  50. data/app/views/whurl_engine/resources/_form.html.haml +40 -0
  51. data/app/views/whurl_engine/resources/_resource.html.haml +6 -0
  52. data/app/views/whurl_engine/resources/create.js.haml +5 -0
  53. data/app/views/whurl_engine/resources/destroy.js.haml +1 -0
  54. data/app/views/whurl_engine/resources/edit.js.haml +3 -0
  55. data/app/views/whurl_engine/resources/new.js.haml +3 -0
  56. data/app/views/whurl_engine/resources/show.html.haml +29 -0
  57. data/app/views/whurl_engine/resources/update.js.haml +6 -0
  58. data/app/views/whurl_engine/shared/_error.js.haml +2 -0
  59. data/app/views/whurl_engine/whurls/_edit_form.html.haml +29 -0
  60. data/app/views/whurl_engine/whurls/_form.html.haml +42 -0
  61. data/app/views/whurl_engine/{whurl_requests → whurls}/_input_set.html.haml +1 -1
  62. data/app/views/whurl_engine/whurls/_response.html.haml +5 -0
  63. data/app/views/whurl_engine/whurls/_whurl.html.haml +18 -0
  64. data/app/views/whurl_engine/whurls/destroy.js.haml +2 -0
  65. data/app/views/whurl_engine/{whurl_requests → whurls}/edit.html.haml +3 -4
  66. data/app/views/whurl_engine/whurls/edit.js.haml +3 -0
  67. data/app/views/whurl_engine/whurls/show.html.haml +4 -0
  68. data/config/initializers/httparty/request.rb +9 -0
  69. data/config/initializers/httparty/response.rb +7 -25
  70. data/config/initializers/net/http_generic_request.rb +9 -0
  71. data/config/initializers/nilclass.rb +5 -0
  72. data/config/initializers/string.rb +32 -0
  73. data/config/routes.rb +6 -3
  74. data/db/migrate/20110209054322_create_whurls_table.rb +14 -0
  75. data/db/migrate/20111210192724_add_description_to_whurl.rb +9 -0
  76. data/db/migrate/20111210201607_add_custom_url_to_whurl.rb +9 -0
  77. data/db/migrate/20111211030904_rename_whurls_to_requests.rb +8 -0
  78. data/db/migrate/20111220233800_create_fields_for_whurl_requests.rb +10 -10
  79. data/db/migrate/20120106033416_create_responses.rb +11 -0
  80. data/db/migrate/20120106190508_create_categories_table.rb +9 -0
  81. data/db/migrate/20120107011500_create_resources_table.rb +15 -0
  82. data/db/migrate/20120107065652_create_parameters_table.rb +12 -0
  83. data/db/migrate/20120110205837_rename_parameters_to_parameter_definitions.rb +5 -0
  84. data/db/migrate/20120110205853_rename_requests_to_whurls.rb +19 -0
  85. data/db/migrate/20120111014928_add_raw_request_to_whurls.rb +5 -0
  86. data/lib/whurl_engine/version.rb +1 -1
  87. metadata +140 -177
  88. data/app/assets/stylesheets/whurl_engine/code.css.scss +0 -13
  89. data/app/assets/stylesheets/whurl_engine/jquery.ui.autocomplete.css.scss +0 -55
  90. data/app/assets/stylesheets/whurl_engine/whurls.css.scss +0 -358
  91. data/app/controllers/whurl_engine/whurl_requests_controller.rb +0 -52
  92. data/app/models/whurl_engine/any_client.rb +0 -7
  93. data/app/models/whurl_engine/whurl_request.rb +0 -37
  94. data/app/views/whurl_engine/whurl_requests/_form.html.haml +0 -51
  95. data/app/views/whurl_engine/whurl_requests/show.html.haml +0 -1
  96. data/db/migrate/20110209054322_create_whurl_requests_table.rb +0 -14
  97. data/db/migrate/20111210192724_add_description_to_whurl_requests.rb +0 -9
  98. data/db/migrate/20111210201607_add_custom_url_to_whurl_requests.rb +0 -9
  99. data/db/migrate/20111221010348_copy_data_to_new_fields.rb +0 -39
  100. data/db/migrate/20111221011145_drop_data_from_whurl_requestss.rb +0 -9
  101. data/test/dummy/Rakefile +0 -7
  102. data/test/dummy/app/assets/javascripts/application.js +0 -9
  103. data/test/dummy/app/assets/stylesheets/application.css +0 -7
  104. data/test/dummy/app/controllers/application_controller.rb +0 -3
  105. data/test/dummy/app/helpers/application_helper.rb +0 -2
  106. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  107. data/test/dummy/app/views/layouts/whurl_engine/application.html.haml +0 -56
  108. data/test/dummy/config/application.rb +0 -45
  109. data/test/dummy/config/boot.rb +0 -10
  110. data/test/dummy/config/database.sample.yml +0 -17
  111. data/test/dummy/config/database.yml +0 -17
  112. data/test/dummy/config/environment.rb +0 -5
  113. data/test/dummy/config/environments/development.rb +0 -30
  114. data/test/dummy/config/environments/production.rb +0 -60
  115. data/test/dummy/config/environments/test.rb +0 -39
  116. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  117. data/test/dummy/config/initializers/inflections.rb +0 -10
  118. data/test/dummy/config/initializers/mime_types.rb +0 -5
  119. data/test/dummy/config/initializers/secret_token.rb +0 -7
  120. data/test/dummy/config/initializers/session_store.rb +0 -8
  121. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  122. data/test/dummy/config/locales/en.yml +0 -5
  123. data/test/dummy/config/routes.rb +0 -4
  124. data/test/dummy/config.ru +0 -4
  125. data/test/dummy/db/schema.rb +0 -31
  126. data/test/dummy/log/development.log +0 -80
  127. data/test/dummy/public/404.html +0 -26
  128. data/test/dummy/public/422.html +0 -26
  129. data/test/dummy/public/500.html +0 -26
  130. data/test/dummy/public/favicon.ico +0 -0
  131. data/test/dummy/script/rails +0 -6
  132. data/test/dummy/tmp/cache/assets/C6D/500/sprockets%2Fa60a126c749b135b047d47c9116f7010 +0 -0
  133. data/test/dummy/tmp/cache/assets/C85/760/sprockets%2F67d86b8948de011684953a4b2d30c280 +0 -0
  134. data/test/dummy/tmp/cache/assets/CB8/FF0/sprockets%2F789d641670bfe15510034f63eb635ff8 +0 -0
  135. data/test/dummy/tmp/cache/assets/CB9/340/sprockets%2Fc383855f31a6f96cfad737d462029019 +0 -0
  136. data/test/dummy/tmp/cache/assets/CBD/A60/sprockets%2F8e7fec8543052565b343a93c7b174d78 +0 -0
  137. data/test/dummy/tmp/cache/assets/CE6/140/sprockets%2F97da5e07430aa9249a9633e88c5073ea +0 -0
  138. data/test/dummy/tmp/cache/assets/D01/6E0/sprockets%2F3974f4fd239fc76f2d9700899609da7e +0 -0
  139. data/test/dummy/tmp/cache/assets/D09/700/sprockets%2F68ca75710cc64126df7d1a6638ca16d1 +0 -0
  140. data/test/dummy/tmp/cache/assets/D18/6A0/sprockets%2Fdf8266a6da92a42ce29b771318176dc9 +0 -0
  141. data/test/dummy/tmp/cache/assets/D1C/440/sprockets%2Fd5f5cd99df7e614581ec5f2256403e33 +0 -0
  142. data/test/dummy/tmp/cache/assets/D2C/DB0/sprockets%2F802a914bb4d275c8c34a3aa5ec134d54 +0 -0
  143. data/test/dummy/tmp/cache/assets/D39/780/sprockets%2F0da3fdc5af08e2938cc21829334b1d48 +0 -0
  144. data/test/dummy/tmp/cache/assets/D3D/010/sprockets%2F389924c72fa75b369a0e61aacfa230e8 +0 -0
  145. data/test/dummy/tmp/cache/assets/D4C/8D0/sprockets%2F024e6456c9877ae45cdb28d7d16e06fe +0 -0
  146. data/test/dummy/tmp/cache/assets/D66/D70/sprockets%2Ffdf1533f584b1ba62ce0ca92848b14d3 +0 -0
  147. data/test/dummy/tmp/cache/assets/D6F/A10/sprockets%2F3fa8ede522a279bfc12817267d1ca57e +0 -0
  148. data/test/dummy/tmp/cache/assets/D9D/AC0/sprockets%2F082b6d491d42f3a4febe3cb4d0983e6d +0 -0
  149. data/test/dummy/tmp/cache/assets/DA4/180/sprockets%2F118a85fd98ac4bda49f6485fd41aca44 +0 -0
  150. data/test/dummy/tmp/cache/assets/DB4/C60/sprockets%2F6ee1d0983f6518ba5dc089797bfc6ffa +0 -0
  151. data/test/dummy/tmp/cache/assets/DBD/7A0/sprockets%2F872f84e976ebe7654383dfdc7cfec1c6 +0 -0
  152. data/test/dummy/tmp/cache/assets/DD7/420/sprockets%2F11c951f1c4e2bfc0d7c1b10e0bb1b2be +0 -0
  153. data/test/dummy/tmp/cache/assets/E29/F00/sprockets%2F5b6ee8619eacc15eaf00c329cedff60a +0 -0
  154. data/test/dummy/tmp/cache/assets/E5D/680/sprockets%2F5ef33ecefc8e09aafd4d2725c0ef0a9c +0 -0
  155. data/test/fixtures/whurl_engine/whurl_requests.yml +0 -11
  156. data/test/functional/whurl_engine/api_call_controller_test.rb +0 -21
  157. data/test/integration/navigation_test.rb +0 -10
  158. data/test/test_helper.rb +0 -10
  159. data/test/unit/helpers/whurl_engine/api_call_helper_test.rb +0 -6
  160. data/test/unit/whurl_engine/whurl_request_test.rb +0 -9
  161. data/test/whurl_engine_test.rb +0 -7
  162. /data/app/views/whurl_engine/{whurl_requests → whurls}/new.html.haml +0 -0
@@ -1,358 +0,0 @@
1
- $dark: #2B2F38;
2
- $highlight: #F1CB31;
3
-
4
- @mixin rounded-corners($topleft, $topright: $topleft, $bottomright: $topleft, $bottomleft: $topleft) {
5
- border-radius: $topleft $topright $bottomright $bottomleft;
6
- -moz-border-radius: $topleft $topright $bottomright $bottomleft;
7
- -webkit-border-radius: $topleft $topright $bottomright $bottomleft;
8
- }
9
-
10
- @mixin rotate($degrees) {
11
- transform: rotate($degrees);
12
- -ms-transform: rotate($degrees); /* IE 9 */
13
- -webkit-transform: rotate($degrees); /* Safari and Chrome */
14
- -o-transform: rotate($degrees); /* Opera */
15
- -moz-transform: rotate($degrees); /* Firefox */
16
- }
17
-
18
- #footer {
19
- text-align: right;
20
- font-size: small;
21
- margin-top: 20px;
22
- }
23
-
24
- #headers, #params {
25
- margin-left: 162px;
26
- min-height: 31px;
27
- margin-bottom: 10px;
28
- }
29
-
30
- .header_pair, .param_pair {
31
- padding: 4px 0;
32
- }
33
-
34
- #errors {
35
- background: white;
36
- }
37
-
38
- .key {
39
- width: 200px;
40
- }
41
-
42
- .value {
43
- width: 400px;
44
- }
45
-
46
- .long {
47
- width: 525px;
48
- }
49
-
50
- html, div, span, a, p, img, h1, h2, h3, h4 {
51
- font-family: Arial, Helvetica, sans-serif;
52
- }
53
-
54
- img {
55
- border: 0 solid #000;
56
- }
57
-
58
- a {
59
- text-decoration: none;
60
- color: $dark;
61
- font-weight: bold;
62
- }
63
-
64
- a:hover {
65
- color: lighten($dark, 20%);
66
- }
67
-
68
- input.one {
69
- width: 480px;
70
- }
71
-
72
- input.two {
73
- width: 225px;
74
- }
75
-
76
- input.three {
77
- width: 350px;
78
- margin-left: 10px;
79
- }
80
-
81
- input.four {
82
- width: 350px;
83
- }
84
-
85
- textarea#whurl_request_body {
86
- width: 610px;
87
- height: 55px;
88
- margin-bottom: 10px;
89
- }
90
-
91
- textarea#whurl_request_description {
92
- width: 610px;
93
- height: 55px;
94
- margin-bottom: 10px;
95
- }
96
-
97
- .textarea_disabled {
98
- background-color: lightgray;
99
- }
100
-
101
- #whurl_request_custom_url {
102
- width: 610px;
103
- }
104
-
105
- body {
106
- background-color: #B2B5BE;
107
- background-image:url('bg_new.png');
108
- background-position: top center;
109
- background-repeat:no-repeat;
110
- }
111
-
112
- .containerTop {
113
- width: 980px;
114
- height: 55px;
115
- background: url('container_top.png') no-repeat 0 0;
116
- }
117
-
118
- .logo {
119
- float: left;
120
- margin: -15px 0 0 0;
121
- }
122
-
123
- .tagline {
124
- float: right;
125
- color: #fff;
126
- font-size: 18px;
127
- width: 350px;
128
- margin: -30px 292px 0 0;
129
- }
130
-
131
- #wrapper {
132
- width: 980px;
133
- margin: 0 auto;
134
- margin-top: 25px;
135
- }
136
-
137
- #container {
138
- width: 100%;
139
- background: url('container_bg.png') repeat-y 0 0;
140
- padding-top: 105px;
141
- }
142
-
143
- .top {
144
- height: 100%;
145
- background-color: #919c9d;
146
- margin: 30px 0 0 ;
147
- padding: 20px;
148
- }
149
-
150
- .content {
151
- padding: 0 15px 0 50px;
152
- }
153
-
154
- /*titles*/
155
- .row {
156
- clear: both;
157
- margin: 0;
158
- padding-bottom: 20px;
159
- }
160
-
161
- .hTitle {
162
- font-size: 24px;
163
- color: $highlight;
164
- text-align: right;
165
- }
166
-
167
- .section_title {
168
- width: 150px;
169
- margin: 0 10px 0 0;
170
- float: left;
171
- text-align: right;
172
- }
173
-
174
- .response_section_title {
175
- color:$highlight;
176
- font-size:24px;
177
- }
178
-
179
- .response_section_title img {
180
- vertical-align: text-top;
181
- }
182
- .response_section {
183
- margin-top: 20px;
184
- }
185
-
186
- #whurl_request_description {
187
- background-color: white;
188
- overflow-x: auto;
189
- }
190
-
191
- #edit_description {
192
- padding: 0 20px;
193
- background-color: white;
194
- overflow-x: auto;
195
- }
196
-
197
- .action_button {
198
- vertical-align: middle;
199
- }
200
-
201
- .titleRESPONSE {
202
- width: 150px;
203
- float: left;
204
- }
205
-
206
- .delete_button {
207
- vertical-align:middle;
208
- }
209
-
210
- a.delete:hover {
211
- background: url("delete.png") no-repeat -20px 0;
212
- }
213
-
214
- .paramButton {
215
- width: 154px;
216
- height: 32px;
217
- background: url('param_button.png') no-repeat 0 0;
218
- }
219
-
220
- .paramButton a {
221
- float: left;
222
- margin: 8px 0 0 20px;
223
- }
224
-
225
- .headerButton {
226
- width: 129px;
227
- height: 31px;
228
- background: url('header_button.png') no-repeat 0 0;
229
- font-family: Verdana, Geneva, Kalimati, sans-serif;
230
- margin: 5px 0 0 25px;
231
- }
232
-
233
- .headerButton a {
234
- float: left;
235
- margin: 8px 0 0 20px;
236
- }
237
-
238
- .submit {
239
- float: right;
240
- margin: -10px 60px 0 0;
241
- color: $dark;
242
- background-color:$highlight;
243
- font-weight: bold;
244
- font-size: 16px;
245
- }
246
- .reset {
247
- float: right;
248
- margin: -10px 10px 0 0;
249
- color: $dark;
250
- background-color: $highlight;
251
- font-weight: bold;
252
- font-size: 16px;
253
- }
254
- .submit:hover {
255
- background-position: -91.5px 0;
256
- }
257
-
258
- a.copy_link {
259
- width: 115.5px;
260
- height: 44px;
261
- background: url('copyURL.png') no-repeat 0 0;
262
- margin: 30px 0 0 45px;
263
- display: block;
264
- }
265
-
266
- a.copy_link:hover {
267
- background-position: -116px 0;
268
- }
269
-
270
- .footer {
271
- background-color: lighten($highlight, 20%);
272
- width: 942px;
273
- height: 48px;
274
- margin: 25px 0 0 36px;
275
- padding: 15px 0 0 0;
276
- color: $dark;
277
- font-size: 15px;
278
- line-height: 1em;
279
- }
280
-
281
- .response_container {
282
- background-color: white;
283
- overflow-x: auto;
284
- }
285
-
286
- #response_header {
287
- padding: 0 20px;
288
- background-color: white;
289
- overflow-x: auto;
290
- }
291
-
292
- .footer p {
293
- float: right;
294
- text-align: right;
295
- margin: 0 20px 0 0;
296
- }
297
-
298
- a.contact {
299
- font-weight: bold;
300
- }
301
-
302
- .meadowfete {
303
- font-size: 12px;
304
- color: darken($highlight, 30%);
305
- }
306
-
307
- #permalink_container {
308
- color: $dark;
309
- position: fixed;
310
- bottom: 5px;
311
- left: 0;
312
- padding: 5px 15px 5px 10px;
313
- background-color: lighten($highlight, 20%);
314
- border: 2px solid $dark;
315
- border-left: none;
316
- -moz-border-radius-topright: 20px;
317
- -moz-border-radius-bottomright: 20px;
318
- border-top-right-radius: 20px;
319
- border-bottom-right-radius: 20px;
320
- }
321
- #permalink_text_box {
322
- width: 200px;
323
- vertical-align: bottom;
324
- }
325
-
326
- .param_pair:first-child,
327
- .header_pair:first-child
328
- {
329
- display: none;
330
- }
331
- ol#saved_whurls {
332
- overflow-y: auto;
333
- position: fixed;
334
- margin: 0 0 0 -400px;
335
- padding: 0px;
336
- top: 10px;
337
- left: 0px;
338
- list-style: none;
339
- z-index:9999;
340
- border: 2px solid lighten($highlight, 20%);
341
- @include rounded-corners(0, 10px, 10px, 0);
342
- opacity: 0.9;
343
- background-color: lightgray;
344
-
345
- li {
346
- display: block;
347
- padding: 5px;
348
- width: 415px;
349
- border:1px solid #AFAFAF;
350
-
351
- &:first-child {
352
- @include rounded-corners(0, 10px, 0, 0);
353
- }
354
- &:last-child {
355
- @include rounded-corners(0, 0, 10px, 0);
356
- }
357
- }
358
- }
@@ -1,52 +0,0 @@
1
- require "whurl_engine/version"
2
-
3
- module WhurlEngine
4
- class WhurlRequestsController < ApplicationController
5
- def new
6
- @whurl = WhurlRequest.new
7
- end
8
-
9
- def create
10
- whurl = params[:whurl_request]
11
- whurl[:headers] = Hash[params[:header_keys].zip(params[:header_values])].delete_if { |k, _| k.blank? }
12
- whurl[:query] = Hash[params[:param_keys].zip(params[:param_values])].delete_if { |k, _| k.blank? }
13
- @whurl = WhurlRequest.new(whurl)
14
-
15
- if @whurl.save
16
- redirect_to short_path(:slug => @whurl.slug) and return
17
- else
18
- render :action => "new"
19
- end
20
- end
21
-
22
- def edit
23
- @whurl = WhurlRequest.find_by_hash_key(params[:slug])
24
- if @whurl.nil?
25
- @whurl = WhurlRequest.find_by_custom_url(params[:slug])
26
- end
27
-
28
- client_headers = {'User-Agent' => "Whurl/#{WhurlEngine::VERSION} (https://github.com/tildewill/whurl_engine)"}.merge(@whurl.headers)
29
-
30
- client_response = AnyClient.send(@whurl.http_method.downcase,
31
- @whurl.url,
32
- :headers => client_headers,
33
- :query => @whurl.query,
34
- :body => @whurl.body
35
- )
36
-
37
- @response_headers = client_response.headers.to_html.html_safe
38
-
39
- respond_to do |format|
40
- format.html do
41
- @api_response = client_response.to_html(:line_numbers => :table).html_safe
42
- end
43
- #format.iphone do
44
- # @api_response = client_response.to_html(:line_numbers => nil).html_safe
45
- #end
46
- end
47
-
48
- rescue Exception => e
49
- @api_response = ("<pre>" + e.message + "\n\n" + e.backtrace.join("\n") + "</pre>").html_safe
50
- end
51
- end
52
- end
@@ -1,7 +0,0 @@
1
- require 'httmultiparty'
2
-
3
- module WhurlEngine
4
- class AnyClient
5
- include HTTMultiParty
6
- end
7
- end
@@ -1,37 +0,0 @@
1
- module WhurlEngine
2
- class WhurlRequest < ActiveRecord::Base
3
- serialize :data
4
- serialize :query, Hash
5
- serialize :headers, Hash
6
-
7
- after_initialize {
8
- default_values
9
- generate_hash_key if new_record?
10
- }
11
-
12
- validates_uniqueness_of :custom_url, :if => Proc.new { |model| !model.custom_url.blank? }
13
- validates_format_of :custom_url, :allow_blank => true, :allow_nil => true, :with => /^[\w\-]+$/i, :message => "can only contain letters, numbers, hyphens and underscores."
14
-
15
- scope :saved, where("custom_url IS NOT NULL AND custom_url <> ''").order(:custom_url)
16
-
17
- def slug
18
- hash_key || custom_url
19
- end
20
-
21
- private
22
- def default_values
23
- self.query ||= {}
24
- self.headers ||= {}
25
- end
26
-
27
- def generate_hash_key
28
- upper_bound = 36**6 -1 #max 6 characters
29
- new_hash_key = rand(upper_bound).to_s(36)
30
- if new_hash_key.match(/^whurl/)
31
- generate_hash_key
32
- else
33
- self.hash_key = new_hash_key
34
- end
35
- end
36
- end
37
- end
@@ -1,51 +0,0 @@
1
- - if @whurl.errors.any?
2
- %ul#errors
3
- - @whurl.errors.full_messages.each do |msg|
4
- %li= msg
5
- .top
6
- = form_for(@whurl, :method => :post, :url => {:action => :create}) do |f|
7
- .row
8
- .section_title
9
- %span.hTitle URL
10
- = f.select(:http_method, options_for_select(["GET", "POST", "PUT", "DELETE"], @whurl.http_method))
11
- \/
12
- \#{f.text_field(:url, :class => "long")}
13
- .row
14
- .section_title
15
- .hTitle
16
- %a#trashheaders= image_tag('whurl_engine/delete.png', :class => 'action_button', :title => "trash all headers")
17
- %a#add_header= image_tag('whurl_engine/add.png', :class => 'action_button', :title => "add another header")
18
- Headers
19
- #headers
20
- = render :partial => 'input_set', :locals => {:set_name => 'header', :f => f, :key => nil, :value => nil, :disabled => true}
21
- - @whurl.headers.each do |key, value|
22
- = render :partial => 'input_set', :locals => {:set_name => 'header', :f => f, :key => key, :value => value, :disabled => false}
23
- = render :partial => 'input_set', :locals => {:set_name => 'header', :f => f, :key => nil, :value => nil, :disabled => false}
24
- .row
25
- .section_title
26
- .hTitle
27
- %a#trashqueries= image_tag('whurl_engine/delete.png', :class => 'action_button', :title => "trash all parameters")
28
- %a#add_param= image_tag('whurl_engine/add.png', :class => 'action_button', :title => "add another parameter")
29
- Query
30
- #params
31
- = render :partial => 'input_set', :locals => {:set_name => 'param', :f => f, :key => nil, :value => nil, :disabled => true}
32
- - @whurl.query.each do |key, value|
33
- = render :partial => 'input_set', :locals => {:set_name => 'param', :f => f, :key => key, :value => value, :disabled => false}
34
- = render :partial => 'input_set', :locals => {:set_name => 'param', :f => f, :key => nil, :value => nil, :disabled => false}
35
- .row
36
- .section_title
37
- .hTitle Body
38
- #post_body
39
- = f.text_area(:body)
40
- .row
41
- .section_title
42
- %span.hTitle Description (optional)
43
- #post_description
44
- = f.text_area(:description)
45
- .row
46
- .section_title
47
- %span.hTitle Custom URL (optional)
48
- #custom_url
49
- = f.text_field(:custom_url, :value => nil)
50
- %input.submit{:type => "submit", :value => "Give it a Whurl!"}/
51
- %input#clearFields.reset{:type => "button", :value => "Reset"}/
@@ -1 +0,0 @@
1
- = @api_response
@@ -1,14 +0,0 @@
1
- class CreateWhurlRequestsTable < ActiveRecord::Migration
2
- def self.up
3
- create_table :whurl_engine_whurl_requests do |t|
4
- t.string :hash_key, :limit => 6, :null => false
5
- t.text :data
6
- t.timestamps
7
- end
8
- add_index :whurl_engine_whurl_requests, :hash_key, :unique => true
9
- end
10
-
11
- def self.down
12
- drop_table :whurl_engine_whurl_requests
13
- end
14
- end
@@ -1,9 +0,0 @@
1
- class AddDescriptionToWhurlRequests < ActiveRecord::Migration
2
- def self.up
3
- add_column :whurl_engine_whurl_requests, :description, :string
4
- end
5
-
6
- def self.down
7
- remove_column :whurl_engine_whurl_requests, :description
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class AddCustomUrlToWhurlRequests < ActiveRecord::Migration
2
- def self.up
3
- add_column :whurl_engine_whurl_requests, :custom_url, :string
4
- end
5
-
6
- def self.down
7
- remove_column :whurl_engine_whurl_requests, :custom_url
8
- end
9
- end
@@ -1,39 +0,0 @@
1
- class CopyDataToNewFields < ActiveRecord::Migration
2
- def self.up
3
- WhurlEngine::WhurlRequest.all.each do |whurl|
4
- return if whurl.data.nil?
5
- whurl.http_method = whurl.data[:http_method]
6
- whurl.query = whurl.data[:query]
7
- whurl.url = whurl.data[:url]
8
- whurl.body = whurl.data[:body]
9
- whurl.headers = whurl.data[:headers]
10
- unless whurl.save
11
- puts "-" * 100
12
- p whurl.id
13
- pp whurl.errors
14
- puts "-" * 100
15
- else
16
- p "Updated #{whurl.id}"
17
- end
18
- end
19
- end
20
-
21
- def self.down
22
- WhurlEngine::WhurlRequest.all.each do |whurl|
23
- whurl.data ||= {}
24
- whurl.data[:http_method] = whurl.http_method
25
- whurl.data[:query] = whurl.query
26
- whurl.data[:url] = whurl.url
27
- whurl.data[:body] = whurl.body
28
- whurl.data[:headers] = whurl.headers
29
- unless whurl.save
30
- puts "-" * 100
31
- p whurl.id
32
- pp whurl.errors
33
- puts "-" * 100
34
- else
35
- p "Updated #{whurl.id}"
36
- end
37
- end
38
- end
39
- end
@@ -1,9 +0,0 @@
1
- class DropDataFromWhurlRequestss < ActiveRecord::Migration
2
- def self.up
3
- remove_column :whurl_engine_whurl_requests, :data
4
- end
5
-
6
- def self.down
7
- add_column :whurl_engine_whurl_requests, :data, :text
8
- end
9
- end
data/test/dummy/Rakefile DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env rake
2
- # Add your own tasks in files placed in lib/tasks ending in .rake,
3
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
-
5
- require File.expand_path('../config/application', __FILE__)
6
-
7
- Dummy::Application.load_tasks
@@ -1,9 +0,0 @@
1
- // This is a manifest file that'll be compiled into including all the files listed below.
2
- // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
- // be included in the compiled file accessible from http://example.com/assets/application.js
4
- // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
- // the compiled file.
6
- //
7
- //= require jquery
8
- //= require jquery_ujs
9
- //= require_tree .
@@ -1,7 +0,0 @@
1
- /*
2
- * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
- * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
- * the top of the compiled file, but it's generally better to create a new file per style scope.
5
- *= require_self
6
- *= require_tree .
7
- */
@@ -1,3 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- protect_from_forgery
3
- end
@@ -1,2 +0,0 @@
1
- module ApplicationHelper
2
- end
@@ -1,14 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= stylesheet_link_tag "application" %>
6
- <%= javascript_include_tag "application" %>
7
- <%= csrf_meta_tags %>
8
- </head>
9
- <body>
10
-
11
- <%= yield %>
12
-
13
- </body>
14
- </html>