From 21187c0fb4fc559927a2f947f909dedd85969ffb Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 21 Feb 2007 00:29:44 +0000 Subject: Apply the rest of Chads patch git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6180 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- .../templates/rescues/_request_and_response.erb | 44 ++++++++++++++ .../action_controller/templates/rescues/_trace.erb | 26 ++++++++ .../templates/rescues/diagnostics.erb | 11 ++++ .../action_controller/templates/rescues/layout.erb | 29 +++++++++ .../templates/rescues/missing_template.erb | 2 + .../templates/rescues/routing_error.erb | 10 ++++ .../templates/rescues/template_error.erb | 21 +++++++ .../templates/rescues/unknown_action.erb | 2 + .../action_controller/templates/scaffolds/edit.erb | 7 +++ .../templates/scaffolds/layout.erb | 69 ++++++++++++++++++++++ .../action_controller/templates/scaffolds/list.erb | 27 +++++++++ .../action_controller/templates/scaffolds/new.erb | 6 ++ .../action_controller/templates/scaffolds/show.erb | 9 +++ 13 files changed, 263 insertions(+) create mode 100644 actionpack/lib/action_controller/templates/rescues/_request_and_response.erb create mode 100644 actionpack/lib/action_controller/templates/rescues/_trace.erb create mode 100644 actionpack/lib/action_controller/templates/rescues/diagnostics.erb create mode 100644 actionpack/lib/action_controller/templates/rescues/layout.erb create mode 100644 actionpack/lib/action_controller/templates/rescues/missing_template.erb create mode 100644 actionpack/lib/action_controller/templates/rescues/routing_error.erb create mode 100644 actionpack/lib/action_controller/templates/rescues/template_error.erb create mode 100644 actionpack/lib/action_controller/templates/rescues/unknown_action.erb create mode 100644 actionpack/lib/action_controller/templates/scaffolds/edit.erb create mode 100644 actionpack/lib/action_controller/templates/scaffolds/layout.erb create mode 100644 actionpack/lib/action_controller/templates/scaffolds/list.erb create mode 100644 actionpack/lib/action_controller/templates/scaffolds/new.erb create mode 100644 actionpack/lib/action_controller/templates/scaffolds/show.erb (limited to 'actionpack/lib') diff --git a/actionpack/lib/action_controller/templates/rescues/_request_and_response.erb b/actionpack/lib/action_controller/templates/rescues/_request_and_response.erb new file mode 100644 index 0000000000..fe60bfdd40 --- /dev/null +++ b/actionpack/lib/action_controller/templates/rescues/_request_and_response.erb @@ -0,0 +1,44 @@ +<% unless @exception.blamed_files.blank? %> + <% if (hide = @exception.blamed_files.length > 8) %> + Show blamed files + <% end %> +
><%=h @exception.describe_blame %>
+<% end %> + +<% if false %> +

+ <% begin %> + <%= form_tag(request.request_uri, "method" => request.method) %> + + + <% for key, values in params %> + <% next if key == "BP-RETRY" %> + <% for value in Array(values) %> + + <% end %> + <% end %> + + + + <% rescue Exception => e %> + <%=h "Couldn't render breakpoint link due to #{e.class} #{e.message}" %> + <% end %> +<% end %> + +<% + clean_params = request.parameters.clone + clean_params.delete("action") + clean_params.delete("controller") + + request_dump = clean_params.empty? ? 'None' : clean_params.inspect.gsub(',', ",\n") +%> + +

Request

+

Parameters:

<%=h request_dump %>

+ +

Show session dump

+ + + +

Response

+

Headers:

<%=h response ? response.headers.inspect.gsub(',', ",\n") : 'None' %>

diff --git a/actionpack/lib/action_controller/templates/rescues/_trace.erb b/actionpack/lib/action_controller/templates/rescues/_trace.erb new file mode 100644 index 0000000000..b322b0aaae --- /dev/null +++ b/actionpack/lib/action_controller/templates/rescues/_trace.erb @@ -0,0 +1,26 @@ +<% + traces = [ + ["Application Trace", @exception.application_backtrace], + ["Framework Trace", @exception.framework_backtrace], + ["Full Trace", @exception.clean_backtrace] + ] + names = traces.collect {|name, trace| name} +%> + +

RAILS_ROOT: <%= defined?(RAILS_ROOT) ? RAILS_ROOT : "unset" %>

+ +
+ <% names.each do |name| -%> + <% + show = "document.getElementById('#{name.gsub /\s/, '-'}').style.display='block';" + hide = (names - [name]).collect {|hide_name| "document.getElementById('#{hide_name.gsub /\s/, '-'}').style.display='none';"} + %> + <%= name %> <%= '|' unless names.last == name %> + <% end -%> + + <% traces.each do |name, trace| -%> +
;"> +
<%= trace.join "\n" %>
+
+ <% end -%> +
\ No newline at end of file diff --git a/actionpack/lib/action_controller/templates/rescues/diagnostics.erb b/actionpack/lib/action_controller/templates/rescues/diagnostics.erb new file mode 100644 index 0000000000..032f945ed2 --- /dev/null +++ b/actionpack/lib/action_controller/templates/rescues/diagnostics.erb @@ -0,0 +1,11 @@ +

+ <%=h @exception.class.to_s %> + <% if request.parameters['controller'] %> + in <%=h request.parameters['controller'].humanize %>Controller<% if request.parameters['action'] %>#<%=h request.parameters['action'] %><% end %> + <% end %> +

+
<%=h @exception.clean_message %>
+ +<%= render_file(@rescues_path + "/_trace.erb", false) %> + +<%= render_file(@rescues_path + "/_request_and_response.erb", false) %> diff --git a/actionpack/lib/action_controller/templates/rescues/layout.erb b/actionpack/lib/action_controller/templates/rescues/layout.erb new file mode 100644 index 0000000000..d38f3e67f9 --- /dev/null +++ b/actionpack/lib/action_controller/templates/rescues/layout.erb @@ -0,0 +1,29 @@ + + + Action Controller: Exception caught + + + + +<%= @contents %> + + + \ No newline at end of file diff --git a/actionpack/lib/action_controller/templates/rescues/missing_template.erb b/actionpack/lib/action_controller/templates/rescues/missing_template.erb new file mode 100644 index 0000000000..dbfdf76947 --- /dev/null +++ b/actionpack/lib/action_controller/templates/rescues/missing_template.erb @@ -0,0 +1,2 @@ +

Template is missing

+

<%=h @exception.message %>

diff --git a/actionpack/lib/action_controller/templates/rescues/routing_error.erb b/actionpack/lib/action_controller/templates/rescues/routing_error.erb new file mode 100644 index 0000000000..ccfa858cce --- /dev/null +++ b/actionpack/lib/action_controller/templates/rescues/routing_error.erb @@ -0,0 +1,10 @@ +

Routing Error

+

<%=h @exception.message %>

+<% unless @exception.failures.empty? %>

+

Failure reasons:

+
    + <% @exception.failures.each do |route, reason| %> +
  1. <%=h route.inspect.gsub('\\', '') %> failed because <%=h reason.downcase %>
  2. + <% end %> +
+

<% end %> diff --git a/actionpack/lib/action_controller/templates/rescues/template_error.erb b/actionpack/lib/action_controller/templates/rescues/template_error.erb new file mode 100644 index 0000000000..eda64db3e9 --- /dev/null +++ b/actionpack/lib/action_controller/templates/rescues/template_error.erb @@ -0,0 +1,21 @@ +

+ <%=h @exception.original_exception.class.to_s %> in + <%=h request.parameters["controller"].capitalize if request.parameters["controller"]%>#<%=h request.parameters["action"] %> +

+ +

+ Showing <%=h @exception.file_name %> where line #<%=h @exception.line_number %> raised: +

<%=h @exception.message %>
+

+ +

Extracted source (around line #<%=h @exception.line_number %>): +

<%=h @exception.source_extract %>

+ +

<%=h @exception.sub_template_message %>

+ +<% @real_exception = @exception + @exception = @exception.original_exception || @exception %> +<%= render_file(@rescues_path + "/_trace.erb", false) %> +<% @exception = @real_exception %> + +<%= render_file(@rescues_path + "/_request_and_response.erb", false) %> diff --git a/actionpack/lib/action_controller/templates/rescues/unknown_action.erb b/actionpack/lib/action_controller/templates/rescues/unknown_action.erb new file mode 100644 index 0000000000..683379da10 --- /dev/null +++ b/actionpack/lib/action_controller/templates/rescues/unknown_action.erb @@ -0,0 +1,2 @@ +

Unknown action

+

<%=h @exception.message %>

diff --git a/actionpack/lib/action_controller/templates/scaffolds/edit.erb b/actionpack/lib/action_controller/templates/scaffolds/edit.erb new file mode 100644 index 0000000000..63dff602a1 --- /dev/null +++ b/actionpack/lib/action_controller/templates/scaffolds/edit.erb @@ -0,0 +1,7 @@ +

Editing <%= @scaffold_singular_name %>

+ +<%= error_messages_for(@scaffold_singular_name) %> +<%= form(@scaffold_singular_name, :action => "update#{@scaffold_suffix}") %> + +<%= link_to "Show", :action => "show#{@scaffold_suffix}", :id => instance_variable_get("@#{@scaffold_singular_name}") %> | +<%= link_to "Back", :action => "list#{@scaffold_suffix}" %> diff --git a/actionpack/lib/action_controller/templates/scaffolds/layout.erb b/actionpack/lib/action_controller/templates/scaffolds/layout.erb new file mode 100644 index 0000000000..759781e0e7 --- /dev/null +++ b/actionpack/lib/action_controller/templates/scaffolds/layout.erb @@ -0,0 +1,69 @@ + + + + Scaffolding + + + + +

<%= flash[:notice] %>

+ +<%= yield %> + + + diff --git a/actionpack/lib/action_controller/templates/scaffolds/list.erb b/actionpack/lib/action_controller/templates/scaffolds/list.erb new file mode 100644 index 0000000000..fea23dc66f --- /dev/null +++ b/actionpack/lib/action_controller/templates/scaffolds/list.erb @@ -0,0 +1,27 @@ +

Listing <%= @scaffold_plural_name %>

+ + + + <% for column in @scaffold_class.content_columns %> + + <% end %> + + +<% for entry in instance_variable_get("@#{@scaffold_plural_name}") %> + + <% for column in @scaffold_class.content_columns %> + + <% end %> + + + + +<% end %> +
<%= column.human_name %>
<%= entry.send(column.name) %><%= link_to "Show", :action => "show#{@scaffold_suffix}", :id => entry %><%= link_to "Edit", :action => "edit#{@scaffold_suffix}", :id => entry %><%= link_to "Destroy", {:action => "destroy#{@scaffold_suffix}", :id => entry}, { :confirm => "Are you sure?", :method => :post } %>
+ +<%= link_to "Previous page", { :page => instance_variable_get("@#{@scaffold_singular_name}_pages").current.previous } if instance_variable_get("@#{@scaffold_singular_name}_pages").current.previous %> +<%= link_to "Next page", { :page => instance_variable_get("@#{@scaffold_singular_name}_pages").current.next } if instance_variable_get("@#{@scaffold_singular_name}_pages").current.next %> + +
+ +<%= link_to "New #{@scaffold_singular_name}", :action => "new#{@scaffold_suffix}" %> diff --git a/actionpack/lib/action_controller/templates/scaffolds/new.erb b/actionpack/lib/action_controller/templates/scaffolds/new.erb new file mode 100644 index 0000000000..66f6626f4e --- /dev/null +++ b/actionpack/lib/action_controller/templates/scaffolds/new.erb @@ -0,0 +1,6 @@ +

New <%= @scaffold_singular_name %>

+ +<%= error_messages_for(@scaffold_singular_name) %> +<%= form(@scaffold_singular_name, :action => "create#{@scaffold_suffix}") %> + +<%= link_to "Back", :action => "list#{@scaffold_suffix}" %> diff --git a/actionpack/lib/action_controller/templates/scaffolds/show.erb b/actionpack/lib/action_controller/templates/scaffolds/show.erb new file mode 100644 index 0000000000..46cdfdb493 --- /dev/null +++ b/actionpack/lib/action_controller/templates/scaffolds/show.erb @@ -0,0 +1,9 @@ +<% for column in @scaffold_class.content_columns %> +

+ <%= column.human_name %>: + <%= instance_variable_get("@#{@scaffold_singular_name}").send(column.name) %> +

+<% end %> + +<%= link_to "Edit", :action => "edit#{@scaffold_suffix}", :id => instance_variable_get("@#{@scaffold_singular_name}") %> | +<%= link_to "Back", :action => "list#{@scaffold_suffix}" %> -- cgit v1.2.3