Sha256: efc9e193f3c886f20ef4366ffb7fe08359336972aa910a211248b3f2c31149f9

Contents?: true

Size: 793 Bytes

Versions: 2

Compression:

Stored size: 793 Bytes

Contents

module Flakey
  module Buffer
    include Base

    SHARE_URL = "https://bufferapp.com/add"

    def buffer_button(options = {})
      defaults = {
        url: default_url,
        label: "Buffer",
        target: '_blank',
        class: 'buffer-add-button'
      }
      settings = defaults.merge(options)

      url = "#{SHARE_URL}?url=#{CGI.escape(settings[:url])}"

      if settings.has_key?(:text) && settings[:text] != ''
        url += "&text=#{CGI.escape(settings[:text])}"
      end

      # Delete these so we can pass the settings directly into link_to
      %w[url text].each { |url_key| settings.delete(url_key.to_sym) }

      if block_given?
        link_to(url, settings, &block)
      else
        link_to settings.delete(:label), url, settings
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
flakey-0.6.0 lib/flakey/buffer.rb
flakey-0.5.0 lib/flakey/buffer.rb