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
@@ -0,0 +1,6 @@
1
+ %tr{:id => "resource_#{resource.id}"}
2
+ %td
3
+ = link_to("#{resource.http_method.upcase} #{resource.relative_path}", resource)
4
+ = link_to('', edit_resource_path(resource), :remote => true, :class => 'edit button icon_only')
5
+ = link_to( '', resource, :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => 'destroy button icon_only')
6
+ %td=resource.description
@@ -0,0 +1,5 @@
1
+ $(".new_whurl_engine_resource").dialog('close');
2
+
3
+ - content = escape_javascript(render(@resource))
4
+ $('#category_#{@resource.category_id} .resources').append("#{content}");
5
+ $("#resource_#{@resource.id}").effect("highlight", {}, 3000);
@@ -0,0 +1 @@
1
+ $("#resource_#{@resource.id}").fadeOut()
@@ -0,0 +1,3 @@
1
+ - content = escape_javascript(render(:partial => 'form', :locals => {:resource => @resource}))
2
+ $('.content').append("#{content}");
3
+ $('.edit_whurl_engine_resource').dialog('open');
@@ -0,0 +1,3 @@
1
+ - content = escape_javascript(render(:partial => 'form', :locals => {:resource => @resource}))
2
+ $('.content').append("#{content}");
3
+ $('.new_whurl_engine_resource').dialog('open');
@@ -0,0 +1,29 @@
1
+ %h1= "#{@resource.http_method.upcase} #{@resource.relative_path}"
2
+ %p= "Updated on #{@resource.updated_at}"
3
+ %p= Rinku.auto_link(@resource.description, :all, 'target=_blank').html_safe
4
+
5
+ %h2 Resource URL
6
+ = @resource.url
7
+
8
+ %h2
9
+ Parameters
10
+ = link_to('Add Parameter', new_parameter_definition_path(:resource_id => @resource.id), :remote => true, :class => 'popup button')
11
+
12
+ %table
13
+ %tbody.parameter_definition
14
+ - @resource.parameter_definitions.each do |parameter_definition|
15
+ = render(parameter_definition)
16
+
17
+ %h2= "Example Request".pluralize(@resource.whurls.count)
18
+ .accordion
19
+ - @resource.whurls.each do |whurl|
20
+ %h3{:class => "whurl_#{whurl.id}"}
21
+ %a{:href => "#whurl_#{whurl.id}"}=whurl.name
22
+ .container{:class => "whurl_#{whurl.id}"}
23
+ = link_to('', edit_whurl_path(whurl), :remote => true, :class => 'edit button icon_only')
24
+ = link_to( '', whurl, :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => 'destroy button icon_only')
25
+ = whurl.description
26
+ = render(whurl)
27
+ %h2 Console
28
+ - whurl = WhurlEngine::Whurl.new(:request_method => @resource.http_method, :request_url => @resource.url)
29
+ = render(:partial => 'whurl_engine/whurls/form', :locals => {:whurl => whurl})
@@ -0,0 +1,6 @@
1
+ $(".edit_whurl_engine_resource").dialog('close');
2
+
3
+ - content = escape_javascript(render(@resource));
4
+ target_row = $("#resource_#{@resource.id}");
5
+ target_row.replaceWith("#{content}");
6
+ $("#resource_#{@resource.id}").effect("highlight", {}, 3000);
@@ -0,0 +1,2 @@
1
+ - msg = object.errors.map {|k,v| "#{k.to_s.titleize} #{v}"}.join('\n')
2
+ alert("#{msg}")
@@ -0,0 +1,29 @@
1
+ :javascript
2
+ $(function() {
3
+ $(".edit_whurl_engine_whurl").dialog(
4
+ {
5
+ modal: true,
6
+ autoOpen: false,
7
+ title: 'Save this Whurl',
8
+ minWidth: 375,
9
+ minHeight: 300,
10
+ close: function(event, ui) {
11
+ $(this).remove();
12
+ }
13
+ });
14
+ });
15
+
16
+ = form_for(whurl) do |f|
17
+ %div
18
+ = f.label :name
19
+ = f.text_field :name, :value => whurl.name || whurl.response_headers['Status']
20
+
21
+ %div
22
+ = f.label :resource_id
23
+ = f.select(:resource_id, option_groups_from_collection_for_select(WhurlEngine::Category.all, :resources, :name, :id, :relative_path))
24
+
25
+ %div
26
+ = f.label :description
27
+ %div
28
+ = f.text_area :description
29
+ = f.submit :value => 'Submit'
@@ -0,0 +1,42 @@
1
+ :javascript
2
+ $(function() {
3
+ var $whurlForm = $('#whurl_form_#{whurl.to_param}');
4
+ new Whurl($whurlForm);
5
+ });
6
+ .whurl_form{:id => "whurl_form_#{whurl.to_param}"}
7
+ = form_for(whurl, :as => :whurl, :url => whurls_path, :method => :post) do |f|
8
+ .row
9
+ .section_title
10
+ URL
11
+ .url
12
+ = f.select(:request_method, options_for_select(["GET", "POST", "PUT", "DELETE", "HEAD"], whurl.request_method))
13
+ \/
14
+ \#{f.text_field(:request_url)}
15
+ .row
16
+ .section_title
17
+ %a.trash_headers{:class => 'trash button icon_only', :title => "trash all headers"}
18
+ %a.add_header{:class => 'add button icon_only', :title => "add another header"}
19
+ Headers
20
+ .headers
21
+ = render :partial => 'whurl_engine/whurls/input_set', :locals => {:set_name => 'header', :f => f, :key => nil, :value => nil, :disabled => true}
22
+ - whurl.request_headers.to_hash.each do |key, value|
23
+ = render :partial => 'whurl_engine/whurls/input_set', :locals => {:set_name => 'header', :f => f, :key => key, :value => value, :disabled => false}
24
+ = render :partial => 'whurl_engine/whurls/input_set', :locals => {:set_name => 'header', :f => f, :key => nil, :value => nil, :disabled => false}
25
+ .row
26
+ .section_title
27
+ %a.trash_queries{:class => 'trash button icon_only', :title => "trash all parameters"}
28
+ %a.add_param{:class => 'add button icon_only', :title => "add another parameter"}
29
+ Query
30
+ .params
31
+ = render :partial => 'whurl_engine/whurls/input_set', :locals => {:set_name => 'param', :f => f, :key => nil, :value => nil, :disabled => true}
32
+ - whurl.request_parameters.each do |key, value|
33
+ = render :partial => 'whurl_engine/whurls/input_set', :locals => {:set_name => 'param', :f => f, :key => key, :value => value, :disabled => false}
34
+ = render :partial => 'whurl_engine/whurls/input_set', :locals => {:set_name => 'param', :f => f, :key => nil, :value => nil, :disabled => false}
35
+ .row
36
+ .section_title
37
+ Body
38
+ .post_body
39
+ = f.text_area(:request_body)
40
+ .button_row
41
+ %input{:type => 'submit', :value => "Give it a Whurl!"}/
42
+ %input#clear_fields{:type => 'button', :value => "Clear", :class => 'clear_fields'}
@@ -1,4 +1,4 @@
1
1
  %div{:class => "#{set_name}_pair"}
2
2
  = text_field_tag("#{set_name}_keys[]", key, :class => "key", :disabled => disabled)
3
3
  = text_field_tag("#{set_name}_values[]", value, :class => "value", :disabled => disabled)
4
- %a{:class => "delete_#{set_name}"}= image_tag("whurl_engine/delete.png", :class => 'delete_button')
4
+ %a{:class => "delete_#{set_name} destroy button icon_only"}
@@ -0,0 +1,5 @@
1
+ -#- response_body = response.to_html(:line_numbers => :table).force_encoding(Encoding.default_external)
2
+ %h3 Response Headers
3
+ .container= find_and_preserve(whurl.response_headers.to_html)
4
+ %h3 Response Body
5
+ .container= find_and_preserve(whurl.response_body.to_html(whurl.response_content_type))
@@ -0,0 +1,18 @@
1
+ .whurl
2
+ .accordion
3
+ %h3
4
+ %a{:href => "#console"} Console
5
+ .container
6
+ = render(:partial => 'whurl_engine/whurls/form', :locals => {:whurl => whurl})
7
+
8
+ %h3
9
+ %a{:href => "#raw"} Raw Request
10
+ .container
11
+ %code= simple_format(whurl.raw_request)
12
+ -#
13
+ -#%h3
14
+ -# %a{:href => "#curl"} cURL Request
15
+ -#.container
16
+ -# %pre= @request.to_curl
17
+
18
+ = render(:partial => 'whurl_engine/whurls/response', :locals => {:whurl => whurl})
@@ -0,0 +1,2 @@
1
+ $(".whurl_#{@whurl.id}").fadeOut();
2
+ $(".accordion").accordion({ autoHeight: false, navigation: true, collapsible: true, active: false });
@@ -1,10 +1,9 @@
1
1
  = javascript_include_tag("whurl_engine/ZeroClipboard")
2
-
3
- - unless @description.blank?
2
+ - unless request.description.blank?
4
3
  .response_section
5
4
  .response_section_title Description
6
5
  #edit_description
7
- = @description
6
+ = request.description
8
7
  .response_section
9
8
  .response_section_title Response Headers
10
9
  #response_header
@@ -13,7 +12,7 @@
13
12
  .response_section_title
14
13
  Response Body #{image_tag("whurl_engine/clipboard.png", :id => "copy_to_clipboard")}
15
14
  .response_container
16
- = find_and_preserve(@api_response)#.force_encoding(WhurlEngine::Application.config.encoding))
15
+ = find_and_preserve(@response_body)
17
16
  = render :partial => 'form'
18
17
  #permalink_container
19
18
  Share this Whurl:
@@ -0,0 +1,3 @@
1
+ - content = escape_javascript(render(:partial => 'edit_form', :locals => {:whurl => @whurl}))
2
+ $('.content').append("#{content}");
3
+ $('.edit_whurl_engine_whurl').dialog('open');
@@ -0,0 +1,4 @@
1
+ =render(@whurl)
2
+
3
+ .menu
4
+ =link_to("Save this Whurl", edit_whurl_path(@whurl), :remote => true, :class => "save button")
@@ -0,0 +1,9 @@
1
+ require 'httparty'
2
+
3
+ module HTTParty
4
+ class Request
5
+ def to_s
6
+ @raw_request.to_s
7
+ end
8
+ end
9
+ end
@@ -1,36 +1,18 @@
1
- require 'json'
2
- require 'coderay'
3
1
  require 'httparty'
4
2
 
5
3
  module HTTParty
6
4
  class Response < HTTParty::BasicObject
7
5
  class Headers
8
- def to_s
9
- headers = []
10
- each_capitalized do |name, value|
11
- headers << "#{name}: #{value}"
12
- end
13
- headers.join("\n")
6
+ def initialize(header = {})
7
+ @header = header
14
8
  end
15
9
 
16
10
  def to_html(options = {:line_numbers => nil})
17
- ::CodeRay.scan(to_s, :txt).div(options)
18
- end
19
- end
20
-
21
- def to_html(options = {:line_numbers => :table})
22
- return "<pre>(Empty)</pre>" unless body.present?
23
- case content_type
24
- when /xml/
25
- ::CodeRay.scan(body, :xml).div(options)
26
- when /html/
27
- ::CodeRay.scan(body, :html).div(options)
28
- when /json|javascript/
29
- ::CodeRay.scan(::JSON.pretty_generate(::JSON.parse(body)), :json).div(options)
30
- when /image|jpg|jpeg|gif|png|bmp|binary/
31
- "<img src=\"data:binary/octet;base64,#{Base64.encode64(response.body)}\" />"
32
- else
33
- body
11
+ headers = []
12
+ each_capitalized do |name, value|
13
+ headers << "<span style='color: #808'>#{name}</span>: <span style='color: #088'>#{value}</span>"
14
+ end
15
+ "<pre>#{headers.join("\n")}</pre>".html_safe
34
16
  end
35
17
  end
36
18
  end
@@ -0,0 +1,9 @@
1
+ require 'stringio'
2
+
3
+ class Net::HTTPGenericRequest
4
+ def to_s
5
+ io = StringIO.new
6
+ exec(io, ::Net::HTTP::HTTPVersion, path)
7
+ io.string
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class NilClass < Object
2
+ def to_html(content_type, options = {})
3
+ ""
4
+ end
5
+ end
@@ -0,0 +1,32 @@
1
+ require 'coderay'
2
+ require 'json'
3
+
4
+ class String
5
+ #this implementation should be coming in Rails 3.2
6
+ def pluralize(count = nil)
7
+ if count == 1
8
+ self
9
+ else
10
+ ActiveSupport::Inflector.pluralize(self)
11
+ end
12
+ end
13
+
14
+ def headerize
15
+ split(/-/).map {|s| s.capitalize }.join('-')
16
+ end
17
+
18
+ def to_html(content_type, options = {:line_numbers => :table})
19
+ case content_type
20
+ when /xml/
21
+ ::CodeRay.scan(self, :xml).div(options)
22
+ when /html/
23
+ ::CodeRay.scan(self, :html).div(options)
24
+ when /json|javascript/
25
+ ::CodeRay.scan(::JSON.pretty_generate(::JSON.parse(self)), :json).div(options)
26
+ when /image|jpg|jpeg|gif|png|bmp|binary/
27
+ "<img src=\"data:binary/octet;base64,#{Base64.encode64(response.body)}\" />"
28
+ else
29
+ self
30
+ end
31
+ end
32
+ end
data/config/routes.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  WhurlEngine::Engine.routes.draw do
2
- root :to => 'whurl_requests#new'
3
- resources :whurl_requests
4
- match '/:slug' => 'whurl_requests#edit', :as => :short
2
+ root :to => 'categories#index'
3
+ resources :categories, :except => :show
4
+ resources :parameter_definitions, :except => [:index, :show]
5
+ resources :whurls
6
+ resources :resources, :except => :index
7
+ match '/:id' => 'whurls#show', :as => :short_whurl
5
8
  end
@@ -0,0 +1,14 @@
1
+ class CreateWhurlsTable < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :whurls do |t|
4
+ t.string :hash_key, :limit => 6, :null => false
5
+ t.text :data
6
+ t.timestamps
7
+ end
8
+ add_index :whurls, :hash_key, :unique => true
9
+ end
10
+
11
+ def self.down
12
+ drop_table :whurls
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ class AddDescriptionToWhurl < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :whurls, :description, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :whurls, :description
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class AddCustomUrlToWhurl < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :whurls, :custom_url, :string
4
+ end
5
+
6
+ def self.down
7
+ remove_column :whurls, :custom_url
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ class RenameWhurlsToRequests < ActiveRecord::Migration
2
+ def change
3
+ rename_table :whurls, :whurl_engine_requests
4
+ end
5
+
6
+ def down
7
+ end
8
+ end
@@ -1,18 +1,18 @@
1
1
  class CreateFieldsForWhurlRequests < ActiveRecord::Migration
2
2
  def self.up
3
- add_column :whurl_engine_whurl_requests, :http_method, :string, :limit => 10
4
- add_column :whurl_engine_whurl_requests, :body, :text
5
- add_column :whurl_engine_whurl_requests, :query, :text
6
- add_column :whurl_engine_whurl_requests, :headers, :text
7
- add_column :whurl_engine_whurl_requests, :url, :text
3
+ add_column :whurl_engine_requests, :http_method, :string, :limit => 10
4
+ add_column :whurl_engine_requests, :body, :text
5
+ add_column :whurl_engine_requests, :query, :text
6
+ add_column :whurl_engine_requests, :headers, :text
7
+ add_column :whurl_engine_requests, :url, :text
8
8
 
9
9
  end
10
10
 
11
11
  def self.down
12
- remove_column :whurl_engine_whurl_requests, :http_method
13
- remove_column :whurl_engine_whurl_requests, :body
14
- remove_column :whurl_engine_whurl_requests, :query
15
- remove_column :whurl_engine_whurl_requests, :headers
16
- remove_column :whurl_engine_whurl_requests, :url
12
+ remove_column :whurl_engine_requests, :http_method
13
+ remove_column :whurl_engine_requests, :body
14
+ remove_column :whurl_engine_requests, :query
15
+ remove_column :whurl_engine_requests, :headers
16
+ remove_column :whurl_engine_requests, :url
17
17
  end
18
18
  end
@@ -0,0 +1,11 @@
1
+ class CreateResponses < ActiveRecord::Migration
2
+ def change
3
+ create_table :whurl_engine_responses do |t|
4
+ t.integer :request_id
5
+ t.string :content_type
6
+ t.text :body
7
+ t.text :headers
8
+ t.timestamps
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class CreateCategoriesTable < ActiveRecord::Migration
2
+ def change
3
+ create_table :whurl_engine_categories do |t|
4
+ t.string :name
5
+ t.text :description
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ class CreateResourcesTable < ActiveRecord::Migration
2
+ def change
3
+ create_table :whurl_engine_resources do |t|
4
+ t.integer :category_id
5
+ t.string :base_uri
6
+ t.string :relative_path
7
+ t.string :http_method
8
+ t.text :description
9
+ t.boolean :rate_limited
10
+ t.boolean :requires_authentication
11
+ t.text :response_formats
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ class CreateParametersTable < ActiveRecord::Migration
2
+ def change
3
+ create_table :whurl_engine_parameters do |t|
4
+ t.integer :resource_id
5
+ t.string :name
6
+ t.string :example_value
7
+ t.text :description
8
+ t.boolean :required
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ class RenameParametersToParameterDefinitions < ActiveRecord::Migration
2
+ def change
3
+ rename_table :whurl_engine_parameters, :whurl_engine_parameter_definitions
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ class RenameRequestsToWhurls < ActiveRecord::Migration
2
+ def up
3
+ rename_table :whurl_engine_requests, :whurl_engine_whurls
4
+ drop_table :whurl_engine_responses
5
+ rename_column :whurl_engine_whurls, :custom_url, :name
6
+ rename_column :whurl_engine_whurls, :query, :request_parameters
7
+ rename_column :whurl_engine_whurls, :body, :request_body
8
+ rename_column :whurl_engine_whurls, :headers, :request_headers
9
+ rename_column :whurl_engine_whurls, :http_method, :request_method
10
+ rename_column :whurl_engine_whurls, :url, :request_url
11
+ add_column :whurl_engine_whurls, :resource_id, :integer
12
+ add_column :whurl_engine_whurls, :response_body, :text
13
+ add_column :whurl_engine_whurls, :response_content_type, :string
14
+ add_column :whurl_engine_whurls, :response_headers, :text
15
+ end
16
+
17
+ def down
18
+ end
19
+ end
@@ -0,0 +1,5 @@
1
+ class AddRawRequestToWhurls < ActiveRecord::Migration
2
+ def change
3
+ add_column :whurl_engine_whurls, :raw_request, :text
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module WhurlEngine
2
- VERSION = "1.2.2"
2
+ VERSION = "2.0.0.rc1"
3
3
  end