Sha256: 7e7eb03ca9c48bf6e3f808bf8fd224d9f17103c68e4ed6852e886772863effab

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

# Thanks to https://github.com/simonwhitaker/github-fork-ribbon-css
require 'rack/dev-mark/theme/base'

module Rack
  module DevMark
    module Theme
      class GithubForkRibbon < Base
        def insert_into(html, env, params = {})
          revision = params[:revision]
          timestamp = params[:timestamp]

          position = @options[:position] || 'left'
          color = @options[:color] || 'red'
          fixed = @options[:fixed] ? ' fixed' : ''
          title = []
          title << revision if revision.to_s != ''
          title << timestamp if timestamp.to_s != ''
          title = title.join("&#10;")

          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="#{title}"><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
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rack-dev-mark-0.7.4 lib/rack/dev-mark/theme/github_fork_ribbon.rb
rack-dev-mark-0.7.3 lib/rack/dev-mark/theme/github_fork_ribbon.rb
rack-dev-mark-0.7.1 lib/rack/dev-mark/theme/github_fork_ribbon.rb
rack-dev-mark-0.7.0 lib/rack/dev-mark/theme/github_fork_ribbon.rb