whurl_engine 2.0.0.rc1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/app/assets/javascripts/whurl_engine/application.js +141 -0
  2. data/app/assets/javascripts/whurl_engine/{jquery-1.7.1.min.js → jquery-1-7-1-min.js} +0 -0
  3. data/app/assets/javascripts/whurl_engine/{jquery.livequery.js → jquery-livequery.js} +0 -0
  4. data/app/assets/javascripts/whurl_engine/{jquery-ui-1.8.16.min.js → jquery-ui-1-8-16-min.js} +0 -0
  5. data/app/assets/stylesheets/whurl_engine/iphone-style-checkboxes/images/ios-style-checkboxes/off.png +0 -0
  6. data/app/assets/stylesheets/whurl_engine/iphone-style-checkboxes/images/ios-style-checkboxes/on.png +0 -0
  7. data/app/assets/stylesheets/whurl_engine/iphone-style-checkboxes/images/ios-style-checkboxes/slider.png +0 -0
  8. data/app/assets/stylesheets/whurl_engine/iphone-style-checkboxes/images/ios-style-checkboxes/slider_center.png +0 -0
  9. data/app/assets/stylesheets/whurl_engine/iphone-style-checkboxes/images/ios-style-checkboxes/slider_left.png +0 -0
  10. data/app/assets/stylesheets/whurl_engine/iphone-style-checkboxes/images/ios-style-checkboxes/slider_right.png +0 -0
  11. data/app/assets/stylesheets/whurl_engine/iphone-style-checkboxes/images/iphone-style-checkboxes/off.png +0 -0
  12. data/app/assets/stylesheets/whurl_engine/iphone-style-checkboxes/images/iphone-style-checkboxes/on.png +0 -0
  13. data/app/assets/stylesheets/whurl_engine/iphone-style-checkboxes/images/iphone-style-checkboxes/slider.png +0 -0
  14. data/app/assets/stylesheets/whurl_engine/iphone-style-checkboxes/images/iphone-style-checkboxes/slider_center.png +0 -0
  15. data/app/assets/stylesheets/whurl_engine/iphone-style-checkboxes/images/iphone-style-checkboxes/slider_left.png +0 -0
  16. data/app/assets/stylesheets/whurl_engine/iphone-style-checkboxes/images/iphone-style-checkboxes/slider_right.png +0 -0
  17. data/app/controllers/whurl_engine/application_controller.rb +20 -1
  18. data/app/controllers/whurl_engine/categories_controller.rb +1 -1
  19. data/app/controllers/whurl_engine/header_definitions_controller.rb +32 -0
  20. data/app/controllers/whurl_engine/parameter_definitions_controller.rb +12 -12
  21. data/app/controllers/whurl_engine/resources_controller.rb +1 -1
  22. data/app/controllers/whurl_engine/whurls_controller.rb +1 -1
  23. data/app/helpers/whurl_engine/application_helper.rb +4 -0
  24. data/app/models/whurl_engine/header_definition.rb +7 -0
  25. data/app/models/whurl_engine/resource.rb +1 -0
  26. data/app/models/whurl_engine/whurl.rb +3 -14
  27. data/app/views/layouts/whurl_engine/application.html.haml +0 -7
  28. data/app/views/whurl_engine/categories/_category.html.haml +4 -3
  29. data/app/views/whurl_engine/categories/index.html.haml +2 -1
  30. data/app/views/whurl_engine/header_definitions/_form.html.haml +31 -0
  31. data/app/views/whurl_engine/header_definitions/_header_definition.html.haml +15 -0
  32. data/app/views/whurl_engine/header_definitions/create.js.haml +5 -0
  33. data/app/views/whurl_engine/header_definitions/destroy.js.haml +1 -0
  34. data/app/views/whurl_engine/header_definitions/edit.js.haml +3 -0
  35. data/app/views/whurl_engine/header_definitions/new.js.haml +3 -0
  36. data/app/views/whurl_engine/header_definitions/update.js.haml +6 -0
  37. data/app/views/whurl_engine/parameter_definitions/_form.html.haml +1 -1
  38. data/app/views/whurl_engine/parameter_definitions/_parameter_definition.html.haml +3 -2
  39. data/app/views/whurl_engine/parameter_definitions/update.js.haml +2 -2
  40. data/app/views/whurl_engine/resources/_resource.html.haml +3 -2
  41. data/app/views/whurl_engine/resources/show.html.haml +15 -3
  42. data/app/views/whurl_engine/whurls/_response.html.haml +3 -1
  43. data/app/views/whurl_engine/whurls/_whurl.html.haml +0 -5
  44. data/app/views/whurl_engine/whurls/show.html.haml +3 -2
  45. data/config/routes.rb +2 -1
  46. data/db/migrate/20120212182833_create_schema.rb +57 -0
  47. data/db/migrate/20120214074332_add_message_to_whurls.rb +5 -0
  48. data/lib/whurl_engine/config.rb +66 -0
  49. data/lib/whurl_engine/engine.rb +2 -0
  50. data/lib/whurl_engine/extension.rb +13 -0
  51. data/lib/whurl_engine/extensions/cancan/authorization_adapter.rb +73 -0
  52. data/lib/whurl_engine/extensions/cancan.rb +3 -0
  53. data/lib/whurl_engine/version.rb +1 -1
  54. data/lib/whurl_engine.rb +10 -1
  55. metadata +59 -50
  56. data/app/assets/flash/whurl_engine/ZeroClipboard.swf +0 -0
  57. data/app/assets/flash/whurl_engine/ZeroClipboard10.swf +0 -0
  58. data/app/assets/flash/whurl_engine/clippy.swf +0 -0
  59. data/app/assets/javascripts/whurl_engine/ZeroClipboard.js +0 -311
  60. data/app/assets/javascripts/whurl_engine/whurl.js +0 -136
  61. data/app/views/whurl_engine/whurls/edit.html.haml +0 -28
  62. data/db/migrate/20110209054322_create_whurls_table.rb +0 -14
  63. data/db/migrate/20111210192724_add_description_to_whurl.rb +0 -9
  64. data/db/migrate/20111210201607_add_custom_url_to_whurl.rb +0 -9
  65. data/db/migrate/20111211030904_rename_whurls_to_requests.rb +0 -8
  66. data/db/migrate/20111220233800_create_fields_for_whurl_requests.rb +0 -18
  67. data/db/migrate/20120106033416_create_responses.rb +0 -11
  68. data/db/migrate/20120106190508_create_categories_table.rb +0 -9
  69. data/db/migrate/20120107011500_create_resources_table.rb +0 -15
  70. data/db/migrate/20120107065652_create_parameters_table.rb +0 -12
  71. data/db/migrate/20120110205837_rename_parameters_to_parameter_definitions.rb +0 -5
  72. data/db/migrate/20120110205853_rename_requests_to_whurls.rb +0 -19
  73. data/db/migrate/20120111014928_add_raw_request_to_whurls.rb +0 -5
@@ -0,0 +1,141 @@
1
+ //= require whurl_engine/jquery-1-7-1-min
2
+ //= require whurl_engine/jquery-ui-1-8-16-min
3
+ //= require whurl_engine/jquery-ujs
4
+ //= require whurl_engine/jquery-livequery
5
+
6
+ var headers = ["Accept",
7
+ "Accept-Charset",
8
+ "Accept-Encoding",
9
+ "Accept-Language",
10
+ "Authorization",
11
+ "Cache-Control",
12
+ "Connection",
13
+ "Cookie",
14
+ "Content-Length",
15
+ "Content-MD5",
16
+ "Content-Type",
17
+ "Date",
18
+ "Expect",
19
+ "From",
20
+ "Host",
21
+ "If-Match",
22
+ "If-Modified-Since",
23
+ "If-None-Match",
24
+ "If-Range",
25
+ "If-Unmodified-Since",
26
+ "Max-Forwards",
27
+ "Pragma",
28
+ "Proxy-Authorization",
29
+ "Range",
30
+ "Referer",
31
+ "TE",
32
+ "Upgrade",
33
+ "User-Agent",
34
+ "Via",
35
+ "Warning"];
36
+
37
+
38
+ function Whurl($whurlForm) {
39
+ this.$whurlForm = $whurlForm;
40
+ var self = this;
41
+
42
+ $('.add_header', this.$whurlForm).click(function () {
43
+ self.addInputs('header');
44
+ });
45
+
46
+ $('.add_param', this.$whurlForm).click(function () {
47
+ self.addInputs('param');
48
+ });
49
+
50
+ $('.delete_header', this.$whurlForm).live('click', function (e) {
51
+ //e.currentTarget
52
+ self.deleteHeader(this);
53
+ });
54
+
55
+ $('.delete_param', this.$whurlForm).live('click', function (e) {
56
+ //e.currentTarget
57
+ self.deleteParam(this);
58
+ });
59
+
60
+ $(".trash_headers", this.$whurlForm).click(function () {
61
+ self.trashHeaders();
62
+ });
63
+
64
+ $(".trash_queries", self.$whurlForm).click(function () {
65
+ self.trashQueries();
66
+ });
67
+
68
+ $('.header_pair input.value', this.$whurlForm).live('focusin', (function () {
69
+ if ($('.header_pair:last input', self.$whurlForm).val() != "") {
70
+ self.addInputs('header');
71
+ }
72
+ }));
73
+
74
+ $('.param_pair input.value', this.$whurlForm).live('focusin', (function () {
75
+ if ($('.param_pair:last input', self.$whurlForm).val() != "") {
76
+ self.addInputs('param');
77
+ }
78
+ }));
79
+
80
+ $('.url select', this.$whurlForm).change(function () {
81
+ self.updateBodyInput();
82
+ });
83
+
84
+ $(".header_pair input.key", this.$whurlForm).livequery(function() {
85
+ $(this).autocomplete({source:headers});
86
+ });
87
+
88
+ $(".clear_fields", this.$whurlForm).click(function () {
89
+ $("input[type=text], textarea", self.$whurlForm).val("");
90
+ self.trashHeaders();
91
+ self.trashQueries();
92
+ });
93
+
94
+ this.addInputs = function (type) {
95
+ var $fields = $('.' + type + '_pair', this.$whurlForm).first().clone();
96
+ $fields.children('input').val("").attr('disabled', false);
97
+ $fields.hide().appendTo(this.$whurlForm.find('.' + type + 's')).slideDown('fast');
98
+ };
99
+
100
+ this.deleteHeader = function (element) {
101
+ var $fields = $(element).closest(".header_pair");
102
+ $fields.slideUp(function () {
103
+ $fields.remove();
104
+ });
105
+ };
106
+
107
+ this.deleteParam = function (element) {
108
+ var $fields = $(element).closest(".param_pair");
109
+ $fields.slideUp(function () {
110
+ $paramFields.remove();
111
+ });
112
+ };
113
+
114
+ this.trashHeaders = function () {
115
+ $(".header_pair:visible", self.$whurlForm).each(function (i, element) {
116
+ $(element).slideUp(function () {
117
+ $(element).remove();
118
+ });
119
+ });
120
+ this.addInputs('header');
121
+ };
122
+
123
+ this.trashQueries = function () {
124
+ $(".param_pair:visible", self.$whurlForm).each(function (i, element) {
125
+ $(element).slideUp(function () {
126
+ $(element).remove();
127
+ });
128
+ });
129
+ this.addInputs('param');
130
+ };
131
+
132
+ this.updateBodyInput = function () {
133
+ var method = $('.url select', self.$whurlForm).val();
134
+ if ($.inArray(method, ["PUT", "POST"]) > -1) {
135
+ $('#whurl_request_body', self.$whurlForm).attr('disabled', false).removeClass('textarea_disabled');
136
+ } else {
137
+ $('#whurl_request_body', self.$whurlForm).attr('disabled', true).addClass('textarea_disabled');
138
+ }
139
+ };
140
+ this.updateBodyInput();
141
+ }
@@ -1,6 +1,25 @@
1
1
  require 'rinku'
2
2
 
3
3
  module WhurlEngine
4
- class ApplicationController < ActionController::Base
4
+ class ApplicationController < ::ApplicationController
5
+ before_filter :_authorize!
6
+
7
+ helper_method :_current_user
8
+
9
+ rescue_from CanCan::AccessDenied do |e|
10
+ p "2" * 100
11
+ p e.action
12
+ p e.subject
13
+ end
14
+
15
+ private
16
+
17
+ def _authorize!
18
+ instance_eval &WhurlEngine::Config.authorize_with
19
+ end
20
+
21
+ def _current_user
22
+ instance_eval &WhurlEngine::Config.current_user_method
23
+ end
5
24
  end
6
25
  end
@@ -1,5 +1,5 @@
1
1
  module WhurlEngine
2
- class CategoriesController < ApplicationController
2
+ class CategoriesController < WhurlEngine::ApplicationController
3
3
  def index
4
4
  @categories = WhurlEngine::Category.all.sort
5
5
  end
@@ -0,0 +1,32 @@
1
+ module WhurlEngine
2
+ class HeaderDefinitionsController < WhurlEngine::ApplicationController
3
+ def new
4
+ @header_definition = WhurlEngine::HeaderDefinition.new(:resource_id => params[:resource_id])
5
+ end
6
+
7
+ def create
8
+ @header_definition = WhurlEngine::HeaderDefinition.new(params[:header_definition])
9
+ unless @header_definition.save
10
+ render :partial => 'whurl_engine/shared/error', :locals => {:object => @header_definition}
11
+ end
12
+ end
13
+
14
+ def edit
15
+ @header_definition = WhurlEngine::HeaderDefinition.find(params[:id])
16
+ end
17
+
18
+ def update
19
+ @header_definition = WhurlEngine::HeaderDefinition.find(params[:id])
20
+ unless @header_definition.update_attributes(params[:header_definition])
21
+ render :partial => 'whurl_engine/shared/error', :locals => {:object => @header_definition}
22
+ end
23
+ end
24
+
25
+ def destroy
26
+ @header_definition = WhurlEngine::HeaderDefinition.find(params[:id])
27
+ unless @header_definition.destroy
28
+ render :partial => 'whurl_engine/shared/error', :locals => {:object => @header_definition}
29
+ end
30
+ end
31
+ end
32
+ end
@@ -1,31 +1,31 @@
1
1
  module WhurlEngine
2
- class ParameterDefinitionsController < ApplicationController
2
+ class ParameterDefinitionsController < WhurlEngine::ApplicationController
3
3
  def new
4
- @parameter = WhurlEngine::ParameterDefinition.new(:resource_id => params[:resource_id])
4
+ @parameter_definition = WhurlEngine::ParameterDefinition.new(:resource_id => params[:resource_id])
5
5
  end
6
6
 
7
7
  def create
8
- @parameter = WhurlEngine::ParameterDefinition.new(params[:parameter])
9
- unless @parameter.save
10
- render :partial => 'error'
8
+ @parameter_definition = WhurlEngine::ParameterDefinition.new(params[:parameter_definition])
9
+ unless @parameter_definition.save
10
+ render :partial => 'whurl_engine/shared/error', :locals => {:object => @parameter_definition}
11
11
  end
12
12
  end
13
13
 
14
14
  def edit
15
- @parameter = WhurlEngine::ParameterDefinition.find(params[:id])
15
+ @parameter_definition = WhurlEngine::ParameterDefinition.find(params[:id])
16
16
  end
17
17
 
18
18
  def update
19
- @parameter = WhurlEngine::ParameterDefinition.find(params[:id])
20
- unless @parameter.update_attributes(params[:parameter])
21
- render :partial => 'error'
19
+ @parameter_definition = WhurlEngine::ParameterDefinition.find(params[:id])
20
+ unless @parameter_definition.update_attributes(params[:parameter_definition])
21
+ render :partial => 'whurl_engine/shared/error', :locals => {:object => @parameter_definition}
22
22
  end
23
23
  end
24
24
 
25
25
  def destroy
26
- @parameter = WhurlEngine::ParameterDefinition.find(params[:id])
27
- unless @parameter.destroy
28
- render :partial => 'error'
26
+ @parameter_definition = WhurlEngine::ParameterDefinition.find(params[:id])
27
+ unless @parameter_definition.destroy
28
+ render :partial => 'whurl_engine/shared/error', :locals => {:object => @parameter_definition}
29
29
  end
30
30
  end
31
31
  end
@@ -1,5 +1,5 @@
1
1
  module WhurlEngine
2
- class ResourcesController < ApplicationController
2
+ class ResourcesController < WhurlEngine::ApplicationController
3
3
  def show
4
4
  @resource = WhurlEngine::Resource.find(params[:id])
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module WhurlEngine
2
- class WhurlsController < ApplicationController
2
+ class WhurlsController < WhurlEngine::ApplicationController
3
3
  def new
4
4
  @whurl = Whurl.new
5
5
  end
@@ -1,5 +1,9 @@
1
1
  module WhurlEngine
2
2
  module ApplicationHelper
3
+ def authorized?(*args)
4
+ @authorization_adapter.nil? || @authorization_adapter.authorized?(*args)
5
+ end
6
+
3
7
  def clippy(text, bgcolor='#FFFFFF')
4
8
  swf_path = asset_path('whurl_engine/clippy.swf')
5
9
  html = <<-EOF
@@ -0,0 +1,7 @@
1
+ module WhurlEngine
2
+ class HeaderDefinition < ActiveRecord::Base
3
+ belongs_to :resource
4
+
5
+ validates_presence_of :name
6
+ end
7
+ end
@@ -2,6 +2,7 @@ module WhurlEngine
2
2
  class Resource < ActiveRecord::Base
3
3
  belongs_to :category
4
4
  has_many :parameter_definitions
5
+ has_many :header_definitions
5
6
  has_many :whurls
6
7
  validates_presence_of :base_uri, :relative_path
7
8
 
@@ -16,19 +16,6 @@ module WhurlEngine
16
16
  hash_key
17
17
  end
18
18
 
19
- def to_curl
20
- ret_str = "curl \"#{url}\" --include --request #{http_method.upcase}"
21
- headers.each do |k, v|
22
- ret_str << " -H #{k}:#{v}"
23
- end
24
- if ['put', 'post'].include?(http_method.downcase)
25
- ret_str << " --data \"#{body}\""
26
- end
27
-
28
- ret_str << " --head" if http_method.downcase == 'head'
29
- ret_str
30
- end
31
-
32
19
  private
33
20
 
34
21
  class AnyClient
@@ -41,8 +28,10 @@ module WhurlEngine
41
28
  request_url,
42
29
  :headers => request_headers.to_hash,
43
30
  :query => request_parameters.blank? ? nil : request_parameters,
44
- :body => request_body
31
+ :body => request_body,
32
+ :follow_redirects => false
45
33
  )
34
+ self.response_message = "HTTP/#{response.http_version} #{response.code} #{Rack::Utils::HTTP_STATUS_CODES[response.code]}"
46
35
  self.response_content_type = response.content_type
47
36
  self.response_body = response.body
48
37
  self.response_headers = response.headers
@@ -2,16 +2,9 @@
2
2
  %html
3
3
  %head
4
4
  = stylesheet_link_tag("whurl_engine/application")
5
- = javascript_include_tag("whurl_engine/jquery-1.7.1.min")
6
- = javascript_include_tag("whurl_engine/jquery-ui-1.8.16.min")
7
- = javascript_include_tag("whurl_engine/jquery-ujs")
8
- = javascript_include_tag("whurl_engine/jquery.livequery")
9
5
  = javascript_include_tag("whurl_engine/application")
10
- = javascript_include_tag("whurl_engine/whurl")
11
- = javascript_include_tag("whurl_engine/ZeroClipboard")
12
6
  :javascript
13
7
  $(function() {
14
- ZeroClipboard.setMoviePath('#{asset_path('whurl_engine/ZeroClipboard10.swf')}');
15
8
  $( "input:submit, input:reset, input:button, button, .button").livequery(function() {
16
9
  $(this).button();
17
10
  $("a.popup").button('option', 'icons', {primary: 'ui-icon-newwin'});
@@ -1,9 +1,10 @@
1
1
  %div{:id => "category_#{category.id}"}
2
2
  %h2
3
3
  = category.name
4
- = link_to('Add Resource', new_resource_path(:category_id => category.id), :remote => true, :class => 'popup button')
5
- = link_to('', edit_category_path(category), :remote => true, :class => 'edit button icon_only')
6
- = link_to( '', category, :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => 'destroy button icon_only')
4
+ -if authorized?(:manage, nil, WhurlEngine::Category)
5
+ = link_to('Add Resource', new_resource_path(:category_id => category.id), :remote => true, :class => 'popup button')
6
+ = link_to('', edit_category_path(category), :remote => true, :class => 'edit button icon_only')
7
+ = link_to( '', category, :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => 'destroy button icon_only')
7
8
  %p=category.description
8
9
  %table{:id => "category_#{category.id}"}
9
10
  %thead
@@ -1,6 +1,7 @@
1
1
  %h1
2
2
  REST API Resources
3
- = link_to('Add Category', new_category_path, :remote => true, :class => 'popup button')
3
+ -if authorized?(:manage, nil, WhurlEngine::Category)
4
+ = link_to('Add Category', new_category_path, :remote => true, :class => 'popup button')
4
5
  .categories
5
6
  - @categories.each do |category|
6
7
  = render(category)
@@ -0,0 +1,31 @@
1
+ :javascript
2
+ $(function() {
3
+ $( ".new_whurl_engine_header_definition, .edit_whurl_engine_header_definition" ).dialog(
4
+ {
5
+ modal: true,
6
+ autoOpen: false,
7
+ title: 'Manage Headers',
8
+ minWidth: 375,
9
+ minHeight: 300,
10
+ close: function(event, ui) {
11
+ $(this).remove();
12
+ }
13
+ });
14
+ });
15
+
16
+ = form_for(header_definition, :remote => true) do |f|
17
+ = f.hidden_field :resource_id
18
+ %div
19
+ = f.label :name
20
+ = f.text_field :name
21
+ %div
22
+ = f.check_box :required
23
+ = f.label :required
24
+ %div
25
+ = f.label :example_value
26
+ = f.text_field :example_value
27
+ %div
28
+ = f.label :description
29
+ %div
30
+ = f.text_area :description
31
+ = f.submit :value => 'Submit'
@@ -0,0 +1,15 @@
1
+ %tr{:id => "header_definition_#{header_definition.id}"}
2
+ %td
3
+ %strong= header_definition.name
4
+ %br
5
+ = header_definition.required? ? "required" : "optional"
6
+ %br
7
+ -if authorized?(:manage, nil, WhurlEngine::HeaderDefinition)
8
+ = link_to('', edit_header_definition_path(header_definition), :remote => true, :class => 'edit button icon_only')
9
+ = link_to( '', header_definition, :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => 'destroy button icon_only')
10
+
11
+ %td
12
+ = header_definition.description
13
+ %div
14
+ Example Value:
15
+ = header_definition.example_value
@@ -0,0 +1,5 @@
1
+ $(".new_whurl_engine_header_definition").dialog('close');
2
+
3
+ - content = escape_javascript(render(@header_definition))
4
+ $('.header_definition').append("#{content}");
5
+ $("#header_definition_#{@header_definition.id}").effect("highlight", {}, 3000);
@@ -0,0 +1 @@
1
+ $("#header_definition_#{@header_definition.id}").fadeOut()
@@ -0,0 +1,3 @@
1
+ - content = escape_javascript(render(:partial => 'form', :locals => {:header_definition => @header_definition}))
2
+ $('.content').append("#{content}");
3
+ $('.edit_whurl_engine_header_definition').dialog('open');
@@ -0,0 +1,3 @@
1
+ - content = escape_javascript(render(:partial => 'form', :locals => {:header_definition => @header_definition}))
2
+ $('.content').append("#{content}");
3
+ $('.new_whurl_engine_header_definition').dialog('open');
@@ -0,0 +1,6 @@
1
+ $(".edit_whurl_engine_header_definition").dialog('close');
2
+
3
+ - content = escape_javascript(render(@header_definition));
4
+ $targetRow = $("#header_definition_#{@header_definition.id}");
5
+ $targetRow.replaceWith("#{content}");
6
+ $("#header_definition_#{@header_definition.id}").effect("highlight", {}, 3000);
@@ -13,7 +13,7 @@
13
13
  });
14
14
  });
15
15
 
16
- = form_for(@parameter_definition, :remote => true) do |f|
16
+ = form_for(parameter_definition, :remote => true) do |f|
17
17
  = f.hidden_field :resource_id
18
18
  %div
19
19
  = f.label :name
@@ -4,8 +4,9 @@
4
4
  %br
5
5
  = parameter_definition.required? ? "required" : "optional"
6
6
  %br
7
- = link_to('', edit_parameter_definition_path(parameter_definition), :remote => true, :class => 'edit button icon_only')
8
- = link_to( '', parameter_definition, :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => 'destroy button icon_only')
7
+ -if authorized?(:manage, nil, WhurlEngine::ParameterDefinition)
8
+ = link_to('', edit_parameter_definition_path(parameter_definition), :remote => true, :class => 'edit button icon_only')
9
+ = link_to( '', parameter_definition, :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => 'destroy button icon_only')
9
10
 
10
11
  %td
11
12
  = parameter_definition.description
@@ -1,6 +1,6 @@
1
1
  $(".edit_whurl_engine_parameter_definition").dialog('close');
2
2
 
3
3
  - content = escape_javascript(render(@parameter_definition));
4
- target_row = $("#parameter_#{@parameter_definition.id}");
5
- target_row.replaceWith("#{content}");
4
+ $targetRow = $("#parameter_definition_#{@parameter_definition.id}");
5
+ $targetRow.replaceWith("#{content}");
6
6
  $("#parameter_definition_#{@parameter_definition.id}").effect("highlight", {}, 3000);
@@ -1,6 +1,7 @@
1
1
  %tr{:id => "resource_#{resource.id}"}
2
2
  %td
3
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')
4
+ -if authorized?(:manage, nil, WhurlEngine::Resource)
5
+ = link_to('', edit_resource_path(resource), :remote => true, :class => 'edit button icon_only')
6
+ = link_to( '', resource, :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => 'destroy button icon_only')
6
7
  %td=resource.description
@@ -5,9 +5,20 @@
5
5
  %h2 Resource URL
6
6
  = @resource.url
7
7
 
8
+ %h2
9
+ Headers
10
+ -if authorized?(:manage, nil, WhurlEngine::HeaderDefinition)
11
+ = link_to('Add Header', new_header_definition_path(:resource_id => @resource.id), :remote => true, :class => 'popup button')
12
+
13
+ %table
14
+ %tbody.header_definition
15
+ - @resource.header_definitions.each do |header_definition|
16
+ = render(header_definition)
17
+
8
18
  %h2
9
19
  Parameters
10
- = link_to('Add Parameter', new_parameter_definition_path(:resource_id => @resource.id), :remote => true, :class => 'popup button')
20
+ -if authorized?(:manage, nil, WhurlEngine::ParameterDefinition)
21
+ = link_to('Add Parameter', new_parameter_definition_path(:resource_id => @resource.id), :remote => true, :class => 'popup button')
11
22
 
12
23
  %table
13
24
  %tbody.parameter_definition
@@ -20,8 +31,9 @@
20
31
  %h3{:class => "whurl_#{whurl.id}"}
21
32
  %a{:href => "#whurl_#{whurl.id}"}=whurl.name
22
33
  .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')
34
+ -if authorized?(:manage, nil, WhurlEngine::Resource)
35
+ = link_to('', edit_whurl_path(whurl), :remote => true, :class => 'edit button icon_only')
36
+ = link_to( '', whurl, :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => 'destroy button icon_only')
25
37
  = whurl.description
26
38
  = render(whurl)
27
39
  %h2 Console
@@ -1,5 +1,7 @@
1
1
  -#- response_body = response.to_html(:line_numbers => :table).force_encoding(Encoding.default_external)
2
2
  %h3 Response Headers
3
- .container= find_and_preserve(whurl.response_headers.to_html)
3
+ .container
4
+ = whurl.response_message
5
+ = find_and_preserve(whurl.response_headers.to_html)
4
6
  %h3 Response Body
5
7
  .container= find_and_preserve(whurl.response_body.to_html(whurl.response_content_type))
@@ -9,10 +9,5 @@
9
9
  %a{:href => "#raw"} Raw Request
10
10
  .container
11
11
  %code= simple_format(whurl.raw_request)
12
- -#
13
- -#%h3
14
- -# %a{:href => "#curl"} cURL Request
15
- -#.container
16
- -# %pre= @request.to_curl
17
12
 
18
13
  = render(:partial => 'whurl_engine/whurls/response', :locals => {:whurl => whurl})
@@ -1,4 +1,5 @@
1
1
  =render(@whurl)
2
2
 
3
- .menu
4
- =link_to("Save this Whurl", edit_whurl_path(@whurl), :remote => true, :class => "save button")
3
+ -if authorized?(:manage, nil, WhurlEngine::Whurl)
4
+ .menu
5
+ =link_to("Save this Whurl", edit_whurl_path(@whurl), :remote => true, :class => "save button")
data/config/routes.rb CHANGED
@@ -2,7 +2,8 @@ WhurlEngine::Engine.routes.draw do
2
2
  root :to => 'categories#index'
3
3
  resources :categories, :except => :show
4
4
  resources :parameter_definitions, :except => [:index, :show]
5
- resources :whurls
5
+ resources :header_definitions, :except => [:index, :show]
6
+ resources :whurls, :except => [:index]
6
7
  resources :resources, :except => :index
7
8
  match '/:id' => 'whurls#show', :as => :short_whurl
8
9
  end