Skip to content

Commit

Permalink
Revert "refactor helpers to use content_tag/image_tag/link_to"
Browse files Browse the repository at this point in the history
This reverts commit 27a557c.
  • Loading branch information
schacon committed Jun 12, 2012
1 parent 7f760bb commit 2575264
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 39 deletions.
8 changes: 4 additions & 4 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def partial(part)
end

def random_tagline
content_tag(:em, '-' * 2) + TAGLINES.sample
"<em>--</em>#{TAGLINES.sample}"
end

def latest_version
Expand All @@ -32,8 +32,8 @@ def latest_relnote_url

# overriding this because we're not using asset pipeline for images,
# but jason is using image_tag
#def image_tag(image)
# raw "<img src=\"/images/" + image + "\"/>"
#end
def image_tag(image)
raw "<img src=\"/images/" + image + "\"/>"
end

end
5 changes: 1 addition & 4 deletions app/helpers/doc_helper.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
module DocHelper

def man(name)
link_to name.gsub('git-', ''), doc_file_path(name)
"<a href=\"/docs/#{name}\">#{name.gsub('git-', '')}</a>".html_safe
end

def linkify(content, section)
next_page = section.next_slug
prev_page = section.prev_slug
content.gsub('[[nav-next]]', next_page).gsub('[[nav-prev]]', prev_page)
end

end
61 changes: 30 additions & 31 deletions app/helpers/site_helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
module SiteHelper

def highlight_no_html(high)
strip_tags(high.to_s)
.gsub('[highlight]', '<span class="highlight">')
Expand All @@ -9,29 +8,30 @@ def highlight_no_html(high)
def rchart(title, data, extra = nil)
git = data[0][1]
svn = data[1][1]
content_tag :tr do
content_tag(:td, title, :nowrap => true) +
content_tag(:td, extra, :class => 'desc') +
content_tag(:td, sprintf("%5.2f", git), :class => "number") +
content_tag(:td, sprintf("%5.2f", svn), :class => "number") +
content_tag(:td, "#{(svn/git).floor}x", :class => "number")
end
out = "<tr>"
out += "<td nowrap>#{title}</td>"
out += "<td class='desc'>#{extra}</td>"
out += "<td class='number'>#{sprintf("%5.2f", git)}</td>"
out += "<td class='number'>#{sprintf("%5.2f", svn)}</td>"
out += "<td class='number'>#{(svn / git).floor}x</td>"
out += "</tr>"
end

def trchart(title, data, extra = nil)
git = data[1][1]
git2 = data[0][1]
svn = data[2][1]

content_tag :tr do
content = content_tag(:td, title, :nowrap => true) + content_tag(:td, extra, :class => 'desc')
if git2
content += content_tag(:td, sprintf("%5.1f", git2), :class => 'number')
else
content += content_tag(:td)
end
content + content_tag(:td, sprintf("%5.1f", git)) + content_tag(:td, sprintf("%5.1f", svn))
out = "<tr>"
out += "<td nowrap>#{title}</td>"
out += "<td class='desc'>#{extra}</td>"
if git2
out += "<td class='number'>#{sprintf("%5.1f", git2)}</td>"
else
out += "<td></td>"
end
out += "<td class='number'>#{sprintf("%5.1f", git)}</td>"
out += "<td class='number'>#{sprintf("%5.1f", svn)}</td>"
out += "</tr>"
end


Expand All @@ -43,22 +43,21 @@ def gchart(title, data)
l = labels.join('|')

scale = vals.max
chart_url = "http://chart.apis.google.com/chart?"
chart_url += "chxt=x" + "&amp;"
chart_url += "cht=bvs" + "&amp;"
chart_url += "chl=#{l}" + "&amp;"
chart_url += "chd=t:#{v}" + "&amp;"
chart_url += "chds=0,#{scale}" + "&amp;"
chart_url += "chs=100x125" + "&amp;"
c = "<img src=\"http://chart.apis.google.com/chart?"
c += "chxt=x" + "&amp;"
c += "cht=bvs" + "&amp;"
c += "chl=#{l}" + "&amp;"
c += "chd=t:#{v}" + "&amp;"
c += "chds=0,#{scale}" + "&amp;"
c += "chs=100x125" + "&amp;"
if vals.size == 3
chart_url += "chco=E09FA0|E09FA0|E05F49" + "&amp;"
c += "chco=E09FA0|E09FA0|E05F49" + "&amp;"
else
chart_url += "chco=E09FA0|E05F49" + "&amp;"
c += "chco=E09FA0|E05F49" + "&amp;"
end
chart_url += "chf=bg,s,fcfcfa&"
chart_url += "chtt=#{CGI.escape(title)}"

image_tag(chart_url.html_safe, :alt => "init benchmarks")
c += "chf=bg,s,fcfcfa&"
c += "chtt=#{title}"
c += "\" alt=\"init benchmarks\" />"
c
end

end

0 comments on commit 2575264

Please sign in to comment.