shutterbug 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +0 -1
- data/README.md +25 -10
- data/lib/shutterbug.rb +1 -1
- data/lib/shutterbug/handlers/shutterbug.js +5 -0
- metadata +4 -4
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
## Overview ##
|
8
8
|
|
9
|
-
A rack utility using phantomjs that will create and save images (pngs) from parts of your html's documents current dom. These images become available as public png resources in the rack application. Currently shutterbug supports HTML, SVG and Canvas elements. Here is a
|
9
|
+
A rack utility using phantomjs that will create and save images (pngs) from parts of your html's documents current dom. These images become available as public png resources in the rack application. Currently shutterbug supports HTML, SVG and Canvas elements. Here is a sample config.ru file:
|
10
10
|
|
11
11
|
|
12
12
|
use Shutterbug::Rackapp do |config|
|
@@ -22,6 +22,12 @@ Shutterbug is distributed as a Ruby Gem. The rack service delivers a javascript
|
|
22
22
|
|
23
23
|
![System Overview](images/shutterbug.jpg)
|
24
24
|
|
25
|
+
## Requirements & Dependencies
|
26
|
+
|
27
|
+
* shutterbug.js requires [JQuery](http://jquery.com/), and expects JQuery to be found via window.$ . Note that shutterbug will allow you to pass in JQuery through its constructor too, in the event that its not at window.$
|
28
|
+
* Ruby 1.9x or greater is required to run the Rack application.
|
29
|
+
* [PhantomJS](http://phantomjs.org/) is requird to run the Rack application.
|
30
|
+
|
25
31
|
## Installation
|
26
32
|
|
27
33
|
Add this line to your application's Gemfile:
|
@@ -48,7 +54,7 @@ See [LICENSE.md](LICENSE.md) for more information.
|
|
48
54
|
|
49
55
|
After adding `use Shutterbug::Rackapp` to your config.ru file, you can convert pieces of your web-page into png images. Just follow these steps:
|
50
56
|
|
51
|
-
|
57
|
+
Include the following javascript in your pages:
|
52
58
|
|
53
59
|
<script src='http://<yourhost:port>/shutterbug/shutterbug.js' type='text/javascript'></script>
|
54
60
|
|
@@ -59,9 +65,12 @@ Elsewhere in your javascript, something like this:
|
|
59
65
|
shutterbug.getDomSnapshot();
|
60
66
|
});
|
61
67
|
|
62
|
-
This will replace the contents of `$("#outselector")` with an `<img src="http://<yourhost:port>/gete_png/sha1hash>` tag which will magically spring into existance. `optCallbackFn` is an optional callback function which will be invoked
|
68
|
+
This will replace the contents of `$("#outselector")` with an `<img src="http://<yourhost:port>/gete_png/sha1hash>` tag which will magically spring into existance. `optCallbackFn` is an optional callback function which will be invoked with the `<img src=..>` tag. `optIdentifier` is useful when there are multiple snapshot buttons targetting multiple iframes, and you need to verify the destination for various snapshot window message events.
|
69
|
+
|
70
|
+
## Advanced usage
|
63
71
|
|
64
|
-
|
72
|
+
|
73
|
+
### IFrame support
|
65
74
|
|
66
75
|
If the element being snapshot'd is an iframe then the iframe needs to handle a postMessage API.
|
67
76
|
Shutterbug will run something like the following JS to get the html of the iframe
|
@@ -95,7 +104,15 @@ Additionally the `#outselector` in the iframe is not used.
|
|
95
104
|
You could also reimplement this API in the html of the iframe if you'd like. However the shutterbug implementation includes
|
96
105
|
some useful things like finding and including all the css on the page, and 'serializing' canvas elements into images.
|
97
106
|
|
98
|
-
|
107
|
+
### Shutterbug JQuery custom events ###
|
108
|
+
|
109
|
+
Shutterbug emits a jQuery custom event called 'shutterbug-saycheese' just prior to copying styles, elements, and canvas contents to the document fragment. This allows applications to do any preparation required before they are ready to be snapshotted.
|
110
|
+
|
111
|
+
After all elements are copied, emits a 'shutterbug-asyouwere' event, so that any customized preperations can be torn down again.
|
112
|
+
|
113
|
+
After all elements are copied, emits a 'shutterbug-asyouwere' event.
|
114
|
+
|
115
|
+
### Deploying on Heroku ###
|
99
116
|
|
100
117
|
To deploy on heroku, you are going to want to modify your stack following [these instructions](http://nerdery.crowdmob.com/post/33143120111/heroku-ruby-on-rails-and-phantomjs).
|
101
118
|
|
@@ -114,7 +131,7 @@ Your app should have a config.ru that looks something like this:
|
|
114
131
|
|
115
132
|
# Without a complete set of S3 credentials, Shutterbug
|
116
133
|
# Places images in a temporary directory where
|
117
|
-
# you will
|
134
|
+
# you will LOSE your images...
|
118
135
|
use Shutterbug::Rackapp do |config|
|
119
136
|
config.uri_prefix = "http://<your app name>.herokuapp.com/"
|
120
137
|
config.path_prefix = "/shutterbug"
|
@@ -143,17 +160,15 @@ And a Procfile which looks like this:
|
|
143
160
|
* Better abstraction phantomjs command line invocation. Use phantomjs.rb ?
|
144
161
|
* Use [sprockets](https://github.com/sstephenson/sprockets) for and coffee.erb for shutterbug.js
|
145
162
|
* Write Tests.
|
146
|
-
* Write Documentation.
|
147
163
|
|
148
|
-
## Contributing
|
149
164
|
|
165
|
+
## Contributing
|
150
166
|
|
151
167
|
2. Join the mailing list: [email](mailto:shutterbug-dev+subscribe@googlegroups.com) or [web](https://groups.google.com/forum/?hl=en#!forum/shutterbug-dev)
|
152
168
|
2. Fork this project.
|
153
|
-
com/forum/#!forum/shutterbug-dev)
|
154
169
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
155
170
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
156
171
|
4. Push to the branch (`git push origin my-new-feature`)
|
157
172
|
5. Create new Pull Request
|
158
173
|
|
159
|
-
© 2013 The
|
174
|
+
© 2013 The Concord Consortium.
|
data/lib/shutterbug.rb
CHANGED
@@ -23,6 +23,8 @@
|
|
23
23
|
var getHtmlFragment = function() {
|
24
24
|
var $element = $(this.element);
|
25
25
|
|
26
|
+
$element.trigger('shutterbug-saycheese');
|
27
|
+
|
26
28
|
var css = $('<div>').append($('link[rel="stylesheet"]').clone()).append($('style').clone()).html();
|
27
29
|
var width = $element.width();
|
28
30
|
var height = $element.height();
|
@@ -59,6 +61,9 @@
|
|
59
61
|
height: height,
|
60
62
|
base_url: getBaseUrl()
|
61
63
|
};
|
64
|
+
|
65
|
+
$element.trigger('shutterbug-asyouwere');
|
66
|
+
|
62
67
|
return html_content;
|
63
68
|
};
|
64
69
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shutterbug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-11-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -234,7 +234,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
234
234
|
version: '0'
|
235
235
|
segments:
|
236
236
|
- 0
|
237
|
-
hash:
|
237
|
+
hash: 2889769158720153016
|
238
238
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
239
239
|
none: false
|
240
240
|
requirements:
|
@@ -243,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
243
243
|
version: '0'
|
244
244
|
segments:
|
245
245
|
- 0
|
246
|
-
hash:
|
246
|
+
hash: 2889769158720153016
|
247
247
|
requirements: []
|
248
248
|
rubyforge_project:
|
249
249
|
rubygems_version: 1.8.25
|