No commit activity in last 3 years
No release in over 3 years
Sinatra integration for ZeroClipboard
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
~> 0.9.12.1
~> 1.5.2
~> 0.6.2
~> 2.13.0
~> 0.7.1
~> 1.3.8

Runtime

~> 1.4.2
 Project Readme

Gem Version

Sinatra::ZeroClipboard

Sinatra::ZeroClipboard is a sinatra plugin to access ZeroClipboard, a Flash-based cross-browser clipboard library. Accessing the clipboard from pure Javascript is still disabled on most browser due to security concerns, but sometimes needed in a project to improve user experience. This gem should mitigate this nuisance until better options are broadly available.

Requirements:

server-side:

  • sinatra >= 1.4.2

client-side:

  • Javascript & Flash-enabled Browser

Usage:

Add gem to your Gemfile

gem "sinatra-zero_clipboard"

Require the gem

require 'sinatra/zero_clipboard'

Register helper for asset routes

class SampleApplication < Sinatra::Base
  # ...
  register Sinatra::ZeroClipboard::Assets
  # ...
end

Add asset links to HTML head

%html
  %head
    = zero_clipboard_assets

Add a button

%button{ id: "clip_button", data-clipboard-text: "Default text", data-clipboard-target: "text_to_copy" }
  %span Copy to Clipboard

Add a target

%textarea{ id: "text_to_copy", rows: "3" cols: "40"} I'm getting copied, Yeah!

Add ZeroClipboard Javascript binding

var clip = new ZeroClipboard(document.getElementById("clip_button"), {
  moviePath: "swf/ZeroClipboard.swf"
});

More Information

For more ZeroClipboard Javascript options look here