Sha256: 4e9f532287441b62a3228c1b0d8b903a59321a0e2cbf9a97905f30c2414c61ae

Contents?: true

Size: 1.18 KB

Versions: 1

Compression:

Stored size: 1.18 KB

Contents

require "#{File.dirname(__FILE__)}/abstract_note"
require "#{File.dirname(__FILE__)}/../view_subscriber"

module Footnotes
  module Notes
    class RenderNote < AbstractNote

      def initialize(controller)
        super
        @controller = controller
        @page = Footnotes.view_subscriber.page
      end

      def title
        "<span style=\"background-color:#{color(@page.duration)}\">Rendered (#{"%.3f" % @page.duration}ms)</span>"
      end

      def content
        html = ''

        if @page
          view = Footnotes.view_subscriber.view_name
          layout = Footnotes.view_subscriber.layout_name
          partial_time = Footnotes.view_subscriber.partial_time

          rows = [["View", "Layout", "View Render", "Partial Render", "Total Render"],
                  [escape(view), escape(layout), "#{'%.3f' % (@page.duration - partial_time)}ms",
                   "<a href=\"#\" onclick=\"Footnotes.hideAllAndToggle('partials_debug_info');return false;\">#{'%.3f' % partial_time}ms</a>",
                   "#{'%.3f' % @page.duration}ms"]]
          mount_table(rows)
        end
      end

      def color(value)
        value > 500.0 ? "#f00" : "#aaa"
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails3-footnotes-4.0.0.pre.4 lib/rails-footnotes/notes/render_note.rb