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, #stylesheet_link_tag

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 = "\#{stylesheet_link_tag \"github-fork-ribbon-css/gh-fork-ribbon.css\"}\n<!--[if lt IE 9]>\n\#{stylesheet_link_tag \"github-fork-ribbon-css/gh-fork-ribbon.ie.css\"}\n<![endif]-->\n<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>\n  EOS\n  html.sub %r{(<body[^>]*>)}i, \"\\\\1\#{s.strip}\"\nend\n"