Class: Rack::DevMark::Theme::GithubForkRibbon

Inherits:
Base
  • Object
show all
Defined in:
lib/rack/dev-mark/theme/github_fork_ribbon.rb

Instance Attribute Summary

Attributes inherited from Base

#env, #revision

Instance Method Summary collapse

Methods inherited from Base

#setup

Constructor Details

#initialize(options = {}) ⇒ GithubForkRibbon

Returns a new instance of GithubForkRibbon.



8
9
10
# File 'lib/rack/dev-mark/theme/github_fork_ribbon.rb', line 8

def initialize(options = {})
  @options = options
end

Instance Method Details

#insert_into(html) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/rack/dev-mark/theme/github_fork_ribbon.rb', line 12

def insert_into(html)
  position = @options[:position] || 'left'
  color = @options[:color] || 'red'
  fixed = @options[:fixed] ? ' fixed' : ''
  s = <<-EOS
#{stylesheet_link_tag "github-fork-ribbon-css/gh-fork-ribbon.css"}
<!--[if lt IE 9]>
#{stylesheet_link_tag "github-fork-ribbon-css/gh-fork-ribbon.ie.css"}
<![endif]-->
<div class="github-fork-ribbon-wrapper #{position}#{fixed}" onClick="this.style.display='none'" title="#{revision}"><div class="github-fork-ribbon #{color}"><span class="github-fork-ribbon-text">#{env}</span></div></div>
  EOS
  html.sub %r{(<body[^>]*>)}i, "\\1#{s.strip}"
end