shutterbug 0.5.4 → 0.5.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/README.md +3 -0
- data/lib/shutterbug.rb +1 -1
- data/lib/shutterbug/rasterize.js +49 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MmI4MzNiYzkwMWQzYmJlY2I2NmY2NmNjMWE0NmMwNjEzY2RjNzU2ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmNjNzEzYjkyNDViMDc1MzdmZmNiYTYwMWFhZTM1YmYwNzUxZTRmOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTVhN2Q1MjhjYWNmYTQ3MDI2NGJkZjI4ZjM0NjAwNDBlM2RiZWU2OWM2ZDhh
|
10
|
+
OGIxZjlhNWZjZjFlMTVkZWJkNmY0MzliYWZkY2VmMTBhYTRjMGY0NDAyZGRl
|
11
|
+
NzhlZmVlZWJiMTRjOTRiYzA4ZjkyNGI0ZGQxNWMzYjk2NWE4NWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OGUzOWNiMTllMGRlODFmOTJlOTZjMDM4OWE5OTM1MGYzNjkzNWEzN2FiMmQz
|
14
|
+
OTgzYWRkNzhlMjBkYjFjY2I3MDkzYzU1YjAxZjZiZTYyNjA1NjIyZDQ0N2Y4
|
15
|
+
Yzg3NGE3YzMwNDQ3N2Y2MzE5NjJmNGRmY2ZiOTRjZmY1YWU2ZDg=
|
data/README.md
CHANGED
@@ -91,6 +91,9 @@ And a Procfile which looks like this:
|
|
91
91
|
|
92
92
|
## Changes ##
|
93
93
|
|
94
|
+
* August 25, 2015 – v 0.5.5
|
95
|
+
* More aggressive single quote replacement in phantom_job.rb
|
96
|
+
|
94
97
|
* August 14, 2015 – v 0.5.4
|
95
98
|
* Fix single quote encoding issue in phantom_job.rb. DM:
|
96
99
|
> Phantom's html entity decoder borks on single quotes when you have an
|
data/lib/shutterbug.rb
CHANGED
data/lib/shutterbug/rasterize.js
CHANGED
@@ -51,6 +51,8 @@
|
|
51
51
|
var system = require('system'),
|
52
52
|
fs = require('fs'),
|
53
53
|
baseRegEx = /<\s*base[^>]+href\s*=\s*['"]([^'"]*)['"][^>]*>/i,
|
54
|
+
baseFixupRegEx = /(&((amp;)*)lt;\s*base\s+href\s*=\s*)(['"])([^'"]*)(['"])([^&]*&((amp;)*)gt;)/gi,
|
55
|
+
metaFixupRegEx = /(&((amp;)*)lt;\s*meta\s+content\s*=\s*)(['"])([^'"]*)(['"])(\s+http-equiv\s*=\s*)(['"])([^'"]*)(['"])([^&]*&(((amp;))*)gt;)/gi,
|
54
56
|
viewportSize = { width: 1000, height: 700 },
|
55
57
|
filename, output, quality, size, base, html;
|
56
58
|
|
@@ -71,10 +73,56 @@ if (system.args.length > 3) {
|
|
71
73
|
// let 'er rip!
|
72
74
|
renderPage();
|
73
75
|
|
76
|
+
// converts " to &quot; based on the number of already escaped amps found in the fixup regex
|
77
|
+
function escapeQuote(allAmps) {
|
78
|
+
var quote = """,
|
79
|
+
numEscapes = allAmps.split("amp").length - 1, // &('')lt; => 1 - 1 = 0 => ", &(amp;)lt; => 2 - 1 = 1 => &quot;, &(amp;amp;)lt; => 3 - 1 = 2 => &amp;quot;
|
80
|
+
i;
|
81
|
+
for (i = 0; i < numEscapes; i++) {
|
82
|
+
quote = quote.replace('&', '&');
|
83
|
+
}
|
84
|
+
return quote;
|
85
|
+
}
|
86
|
+
|
87
|
+
function fixupBase($0,$beforeQuote,$allAmps,$innerAmps,$leftQuote,$insideQuote,$rightQuote,$afterQuote) {
|
88
|
+
var escapedQuote = escapeQuote($allAmps);
|
89
|
+
return [$beforeQuote, escapedQuote, decodeURIComponent($insideQuote), escapedQuote, $afterQuote].join('');
|
90
|
+
}
|
91
|
+
|
92
|
+
function fixupMeta($0,$beforeQuotes,$allAmps,$innerAmps,$leftFirstQuote,$insideFirstQuote,$rightFirstQuote,$betweenQuotes,$leftSecondQuote,$insideSecondQuote,$rightSecondQuote,$afterQuotes) {
|
93
|
+
var escapedQuote = escapeQuote($allAmps);
|
94
|
+
return [$beforeQuotes, escapedQuote, decodeURIComponent($insideFirstQuote), escapedQuote, $betweenQuotes, escapedQuote, decodeURIComponent($insideSecondQuote), escapedQuote, $afterQuotes].join('');
|
95
|
+
}
|
96
|
+
|
97
|
+
function testFixup(regex, fixup, src, fixed) {
|
98
|
+
var result = src.replace(regex, fixup);
|
99
|
+
if (result !== fixed) {
|
100
|
+
console.log("Expected '" + fixed + "' got '" + result + "'")
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
74
104
|
// Main function, called once
|
75
105
|
function renderPage() {
|
106
|
+
var contents = fs.read(filename);
|
107
|
+
|
108
|
+
// change to true for testing
|
109
|
+
if (false) {
|
110
|
+
console.log("Testing base fixup...");
|
111
|
+
testFixup(baseFixupRegEx, fixupBase, "<base href='http://concord-consortium.github.io/lara-interactive-api/'>", "<base href="http://concord-consortium.github.io/lara-interactive-api/">");
|
112
|
+
testFixup(baseFixupRegEx, fixupBase, "&lt;base href='http://concord-consortium.github.io/lara-interactive-api/'&gt;", "&lt;base href=&quot;http://concord-consortium.github.io/lara-interactive-api/&quot;&gt;");
|
113
|
+
testFixup(baseFixupRegEx, fixupBase, "&amp;lt;base href='http://concord-consortium.github.io/lara-interactive-api/'&amp;gt;", "&amp;lt;base href=&amp;quot;http://concord-consortium.github.io/lara-interactive-api/&amp;quot;&amp;gt;");
|
114
|
+
console.log("Testing meta fixup...");
|
115
|
+
testFixup(metaFixupRegEx, fixupMeta, "<meta content='text/html;charset=utf-8' http-equiv='Content-Type'>", "<meta content="text/html;charset=utf-8" http-equiv="Content-Type">");
|
116
|
+
testFixup(metaFixupRegEx, fixupMeta, "&lt;meta content='text/html;charset=utf-8' http-equiv='Content-Type'&gt;", "&lt;meta content=&quot;text/html;charset=utf-8&quot; http-equiv=&quot;Content-Type&quot;&gt;");
|
117
|
+
testFixup(metaFixupRegEx, fixupMeta, "&amp;lt;meta content='text/html;charset=utf-8' http-equiv='Content-Type'&amp;gt;", "&amp;lt;meta content=&amp;quot;text/html;charset=utf-8&amp;quot; http-equiv=&amp;quot;Content-Type&amp;quot;&amp;gt;");
|
118
|
+
}
|
119
|
+
|
120
|
+
// fixup old clients that send single quoted escaped attributes in the metadata
|
121
|
+
// the single quoted escaped text causes phantom to incorrectly parse the html
|
122
|
+
contents = contents.replace(baseFixupRegEx, fixupBase).replace(metaFixupRegEx, fixupMeta);
|
123
|
+
|
76
124
|
// this is the initial load of the html provided by phantom_job.rb
|
77
|
-
loadPage(
|
125
|
+
loadPage(contents, function (page, base, hasChangedIframes) {
|
78
126
|
// At this point the page has been "walked", and if it includes iframes, loadPage() has been called on each iframe.
|
79
127
|
// The iframe srces have been updated to a data-uri that has an image taken of the iframe contents.
|
80
128
|
if (hasChangedIframes) {
|
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.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Noah Paessel
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-08-
|
13
|
+
date: 2015-08-25 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|