Permalink
Browse files

improved a little bit the scea template by adding tabs

  • Loading branch information...
1 parent 4d2578a commit 5ed2fa9f9e7484124786e4a95e3cd7a81232a248 @mattetti committed Feb 16, 2010
@@ -68,7 +68,8 @@ def source_change(change, filename)
end
# Prints a short report of what has been inserted into the database
- def report(output)
+ def report(output, html_options={})
+ output << "<div #{html_options.map{|k,v| '#{k}=#{v}'}.join(' ')}>"
output.title('Request database created')
output << "A database file has been created with all parsed request information.\n"
@@ -77,6 +78,7 @@ def report(output)
output << "To open a Ruby console to inspect the database, run the following command.\n"
output << output.colorize(" $ request-log-analyzer console -d #{options[:database]}\n", :bold)
output << "\n"
+ output << "</div>"
end
end
@@ -90,7 +90,7 @@ def to_yaml
# Call report on all trackers.
# <tt>output</tt> RequestLogAnalyzer::Output object to output to
- def report(output)
+ def report(output, html_options={})
report_header(output)
if source.parsed_requests > 0
@trackers.each { |tracker| output.report_tracker(tracker) }
@@ -104,6 +104,7 @@ def report(output)
# Generate report header.
# <tt>output</tt> RequestLogAnalyzer::Output object to output to
def report_header(output)
+ output << "<div class='tabbertab'>"
output.title("Request summary")
table_opts = {:id => 'request-summary'}
@@ -118,6 +119,7 @@ def report_header(output)
end
end
output << "\n"
+ output << "</div>"
end
# Generate report footer.
@@ -326,7 +326,13 @@ def run!
@aggregators.each { |agg| agg.finalize }
@output.header
- @aggregators.each { |agg| agg.report(@output) }
+ if @output.respond_to?(:wrapper)
+ @output.wrapper do |out|
+ @aggregators.each {|agg| agg.report(out) }
+ end
+ else
+ @aggregators.each { |agg| agg.report(@output) }
+ end
@output.footer
@source.finalize
@@ -0,0 +1,167 @@
+body {
+ font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+ color: #4f6b72;
+ background: #E6EAE9;
+ padding-left:20px;
+ padding-top:20px;
+ padding-bottom:20px;
+}
+
+a {
+ color: #c75f3e;
+}
+
+.color_bar {
+ border: 1px solid;
+ height:10px;
+ background: #CAE8EA;
+}
+
+#mytable {
+ width: 700px;
+ padding: 0;
+ margin: 0;
+ padding-bottom:10px;
+}
+
+caption {
+ padding: 0 0 5px 0;
+ width: 700px;
+ font: italic 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+ text-align: right;
+}
+
+th {
+ font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+ color: #4f6b72;
+ border-right: 1px solid #C1DAD7;
+ border-bottom: 1px solid #C1DAD7;
+ border-top: 1px solid #C1DAD7;
+ letter-spacing: 2px;
+ text-transform: uppercase;
+ text-align: left;
+ padding: 6px 6px 6px 12px;
+ background: #CAE8EA url(images/bg_header.jpg) no-repeat;
+}
+
+td {
+ font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
+ border-right: 1px solid #C1DAD7;
+ border-bottom: 1px solid #C1DAD7;
+ background: #fff;
+ padding: 6px 6px 6px 12px;
+ color: #4f6b72;
+}
+
+td.alt {
+ background: #F5FAFA;
+ color: #797268;
+}
+
+/*--------------------------------------------------
+ REQUIRED to hide the non-active tab content.
+ But do not hide them in the print stylesheet!
+ --------------------------------------------------*/
+.tabberlive .tabbertabhide {
+ display:none;
+}
+
+/*--------------------------------------------------
+ .tabber = before the tabber interface is set up
+ .tabberlive = after the tabber interface is set up
+ --------------------------------------------------*/
+.tabber {
+}
+.tabberlive {
+ margin-top:1em;
+}
+
+/*--------------------------------------------------
+ ul.tabbernav = the tab navigation list
+ li.tabberactive = the active tab
+ --------------------------------------------------*/
+ul.tabbernav
+{
+ margin:0;
+ padding: 3px 0;
+ border-bottom: 1px solid #778;
+ font: bold 12px Verdana, sans-serif;
+}
+
+ul.tabbernav li
+{
+ list-style: none;
+ margin: 0;
+ display: inline;
+}
+
+ul.tabbernav li a
+{
+ padding: 3px 0.5em;
+ margin-left: 3px;
+ border: 1px solid #778;
+ border-bottom: none;
+ background: #DDE;
+ text-decoration: none;
+}
+
+ul.tabbernav li a:link { color: #448; }
+ul.tabbernav li a:visited { color: #667; }
+
+ul.tabbernav li a:hover
+{
+ color: #000;
+ background: #AAE;
+ border-color: #227;
+}
+
+ul.tabbernav li.tabberactive a
+{
+ background-color: #fff;
+ border-bottom: 1px solid #fff;
+}
+
+ul.tabbernav li.tabberactive a:hover
+{
+ color: #000;
+ background: white;
+ border-bottom: 1px solid white;
+}
+
+/*--------------------------------------------------
+ .tabbertab = the tab content
+ Add style only after the tabber interface is set up (.tabberlive)
+ --------------------------------------------------*/
+.tabberlive .tabbertab {
+ padding:5px;
+ border:1px solid #aaa;
+ border-top:0;
+
+ /* If you don't want the tab size changing whenever a tab is changed
+ you can set a fixed height */
+
+ /* height:200px; */
+
+ /* If you set a fix height set overflow to auto and you will get a
+ scrollbar when necessary */
+
+ /* overflow:auto; */
+}
+
+/* If desired, hide the heading since a heading is provided by the tab */
+.tabberlive .tabbertab h2 {
+ display:none;
+}
+.tabberlive .tabbertab h3 {
+ display:none;
+}
+
+/* Example of using an ID to set different styles for the tabs on the page */
+.tabberlive#tab1 {
+}
+.tabberlive#tab2 {
+}
+.tabberlive#tab2 .tabbertab {
+ height:200px;
+ overflow:auto;
+}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -45,6 +45,12 @@ def link(text, url = nil)
url = text if url.nil?
tag(:a, text, :href => url)
end
+
+ def report_tracker(tracker)
+ @io << "<div class='tabbertab' title='#{tracker.title}'>"
+ tracker.report(self)
+ @io << '</div>'
+ end
# Generate a report table in HTML and push it into the output object.
# <tt>*colums<tt> Columns hash
@@ -81,73 +87,24 @@ def header
@io << "<html>"
@io << tag(:head) do |headers|
+ tabber_js_file = File.expand_path(File.join(File.dirname(__FILE__), 'scea', 'tabber-minimized.js'))
+ css_file = File.expand_path(File.join(File.dirname(__FILE__), 'scea', 'style.css'))
+
headers << tag(:title, 'Request-log-analyzer report')
- headers << tag(:style, '
- body {
- font: normal 11px auto "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
- color: #4f6b72;
- background: #E6EAE9;
- padding-left:20px;
- padding-top:20px;
- padding-bottom:20px;
- }
-
- a {
- color: #c75f3e;
- }
-
- .color_bar {
- border: 1px solid;
- height:10px;
- background: #CAE8EA;
- }
-
- #mytable {
- width: 700px;
- padding: 0;
- margin: 0;
- padding-bottom:10px;
- }
-
- caption {
- padding: 0 0 5px 0;
- width: 700px;
- font: italic 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
- text-align: right;
- }
-
- th {
- font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
- color: #4f6b72;
- border-right: 1px solid #C1DAD7;
- border-bottom: 1px solid #C1DAD7;
- border-top: 1px solid #C1DAD7;
- letter-spacing: 2px;
- text-transform: uppercase;
- text-align: left;
- padding: 6px 6px 6px 12px;
- background: #CAE8EA url(images/bg_header.jpg) no-repeat;
- }
-
- td {
- font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
- border-right: 1px solid #C1DAD7;
- border-bottom: 1px solid #C1DAD7;
- background: #fff;
- padding: 6px 6px 6px 12px;
- color: #4f6b72;
- }
-
- td.alt {
- background: #F5FAFA;
- color: #797268;
- }
- ', :type => "text/css")
+ headers << tag(:style, File.open(css_file).read, :type => "text/css")
+ headers << tag(:script, File.open(tabber_js_file).read, :type => 'text/javascript')
end
@io << '<body>'
- # @io << tag(:h1, 'Request-log-analyzer summary report')
+ @io << tag(:h1, 'Request-log-analyzer summary report')
# @io << tag(:p, "Version #{RequestLogAnalyzer::VERSION}")
end
+
+ # wrap the report body in this method
+ def wrapper
+ @io << "<div class='tabber'>"
+ yield(self)
+ @io << "</div>"
+ end
# Generate a footer for a report
def footer

0 comments on commit 5ed2fa9

Please sign in to comment.