app/views/superconductor/_panel.html.erb in superconductor-0.0.2 vs app/views/superconductor/_panel.html.erb in superconductor-0.0.3
- old
+ new
@@ -1,84 +1,81 @@
-<section id="superconductor_panel">
- <button class="resizer"></button>
- <details open>
- <summary>
- <%= request.request_method %> Parameters
- </summary>
+<%= stylesheet_link_tag 'superconductor.css' %>
+<%= javascript_include_tag 'superconductor.js' %>
+
+<aside id="superconductor">
+ <menu type="toolbar">
+ <button class="directory">≡</button> |
+ <button class="expander"></button><button class="closer">✕</button>
+ </menu>
+ <section class="instance-variables">
+ <h1>Statistics</h1>
<dl>
- <% params.each do |k,v| %>
- <dt><%= k %></dt>
- <dd><%= v %></dd>
- <% end %>
+ <dt>Load Time:</dt>
+ <dd><code><%= sprintf('%.3f', (Time.now.usec - @_start_time).abs / 1000000.0) %> seconds</code></dd>
</dl>
- <details>
- <summary>More...</summary>
- <dl>
- <dt>Remote IP</dt>
- <dd><%= request.remote_ip %></dd>
- <dt>User Agent</dt>
- <dd class="nowrap"><%= request.user_agent %></dd>
- <dt>Referer</dt>
- <dd><%= request.referer %></dd>
- <dt>Format</dt>
- <dd><%= request.format %></dd>
- </dl>
- <br />
- </details>
- </details>
- <details open>
- <summary>Variables</summary>
- <dl>
- <% controller.instance_variables.reject { |k| k.to_s.starts_with?('@_') }.map { |k| [k, instance_variable_get(k)] }.each do |k, v| %>
- <dt><%= k %></dt>
- <dd>
- <% if v.is_a?(ActiveRecord::Relation) %>
- <details>
- <summary><%= v.klass.name.pluralize %></summary>
- <dl>
- <dd><%= v.to_sql %>
- </dl>
- </details>
- <% elsif v.is_a?(ActiveRecord::Base) %>
- <details>
- <summary><%= "New " if v.new_record? %><%= v.class.name %></summary>
- <dl>
- <% v.attributes.each do |attribute,value| %>
- <dt><%= attribute %></dt>
- <dd><%= value %></dd>
+ <h1>Instance Variables</h1>
+ <% controller.instance_variables.reject { |k| k.to_s.starts_with?('@_') }.map { |k| [k, instance_variable_get(k)] }.each do |k, v| %>
+ <details <%='open' if controller.class.name.starts_with?(k[1..-1].pluralize.titleize) %>><summary><%= k %>: <%= v.to_s %></summary>
+ <% if v.kind_of?(ActiveModel::Naming) %>
+ <% begin %>
+ <%= render v %><hr />
+ <details><summary>Attributes</summary>
+ <dl>
+ <% v.attributes.each do |k,v| %>
+ <dt><%= k %></dt><dd><%= v.inspect %></dd>
+ <% end %>
+ </dl>
+ </details>
+ <% rescue Exception => exception %>
+ <%= content_tag :code, v.inspect %>
+ <% unless exception.is_a? ActionView::MissingTemplate %>
+ <details><summary><%= exception.class.name %></summary>
+ <%= content_tag :code, exception.message %>
+ </details>
+ <% end %>
+ <% end %>
+ <% elsif defined?(ActiveRecord) && v.kind_of?(ActiveRecord::Relation) %>
+ <%= content_tag :code, v.to_sql %>
+ <ul class="relation">
+ <% v.limit(10).each do %>
+ <% begin %>
+ <%= render v %>
+ <% rescue Exception => exception %>
+ <%= content_tag :code, v.inspect %>
+ <% unless exception.is_a? ActionView::MissingTemplate %>
+ <details><summary><%= exception.class.name %></summary>
+ <%= content_tag :code, exception.message %>
+ </details>
+ <% end %>
<% end %>
- </dl>
- </details>
+ <% end %>
+ </ul>
+ <% elsif v.kind_of?(Array) %>
+ <ul class="array">
+ <% v[0..10].each do |vv| %>
+ <li><%= content_tag :code, vv.inspect %></li>
+ <% end %>
+ </ul>
<% else %>
- <%= v %>
+ <%= content_tag :code, v.inspect %>
<% end %>
- </dd>
- <% end %>
- </dl>
- <br />
- </details>
- <details>
- <summary>Session</summary>
- <dl>
- <% session.each do |k,v| %>
- <dt><%= k %></dt>
- <dd><%= v %></dd>
- <% end %>
- </dl>
- </details>
- <% begin %>
- <details>
- <% file, lineno = controller.class.instance_method(action_name).source_location %>
- <summary>
- <%= controller.class.name %>#<%= action_name %>
- <a href="edit-source://<%= file %>?<%= lineno %>">Edit Source</a>
- <br />
- </summary>
- <%= form_tag superconductor_file_path, :method => :put do %>
- <%= hidden_field_tag :file, file %>
- <%= text_area_tag :content, File.read(file), :wrap => "off", 'data-line-no' => lineno %>
- <% end %>
- </details>
- <% rescue %>
- <% end %>
- <%= yield %>
-</section>
+ <% methods = Hash[v.public_methods.map{|m|v.method(m)}.group_by(&:owner)] %>
+ <details class="methods"><summary><%= v.class.name %> Methods</summary>
+ <ul>
+ <% methods[v.class].sort_by(&:name).each do |method| %>
+ <li><%= link_to_if method.source_location, method.name, superconductor_file_path((method.source_location||[]).join('#')), remote: true %></li>
+ <% end %>
+ </ul>
+ <% methods.except(v.class).sort_by{|m|m.first.name.to_s}.each do |owner,methods| %>
+ <details class="methods"><summary><%= owner.name || "Dynamic" %> Methods</summary>
+ <ul>
+ <% methods.sort_by(&:name).each do |method| %>
+ <li><%= link_to_if method.source_location, method.name, superconductor_file_path((method.source_location||[]).join('#')), remote: true %></li>
+ <% end %>
+ </ul>
+ </details>
+ <% end %>
+ </details>
+ </details>
+ <% end %>
+ </section>
+</aside>