magickly 1.2.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +6 -0
- data/Gemfile +0 -3
- data/Gemfile.lock +22 -22
- data/HISTORY.md +22 -0
- data/README.md +60 -32
- data/Rakefile +2 -3
- data/VERSION +1 -1
- data/lib/dragonfly/data_storage/remote_data_store.rb +1 -3
- data/lib/magickly.rb +3 -0
- data/lib/magickly/app.rb +44 -20
- data/lib/public/images/logo.jpg +0 -0
- data/lib/public/jquery-ui.smoothness.css +568 -0
- data/lib/public/magickly_demo.js +85 -0
- data/lib/public/style.css +83 -0
- data/lib/shortcuts.rb +6 -0
- data/lib/views/analyzers.erb +6 -0
- data/lib/views/index.erb +38 -0
- data/magickly.gemspec +10 -16
- data/spec/requests/magickly_app_spec.rb +19 -3
- data/spec/unit/shortcut_spec.rb +22 -0
- metadata +32 -62
- data/bin/magickly +0 -12
- data/lib/views/analyzers.haml +0 -3
- data/lib/views/index.haml +0 -55
data/.travis.yml
ADDED
data/Gemfile
CHANGED
@@ -4,14 +4,11 @@ gem 'sinatra', '~> 1.2', :require => 'sinatra/base'
|
|
4
4
|
gem 'dragonfly', '~> 0.9.5'
|
5
5
|
gem 'addressable', '~> 2.2', :require => 'addressable/uri'
|
6
6
|
|
7
|
-
gem 'haml', '~> 3.0'
|
8
7
|
gem 'httparty', '~> 0.8.1'
|
9
8
|
gem 'activesupport', '>= 2.0.0', :require => false
|
10
|
-
gem 'json', '~> 1.5'
|
11
9
|
|
12
10
|
group :development do
|
13
11
|
gem 'jeweler', '~> 1.5'
|
14
|
-
gem 'rcov', '>= 0'
|
15
12
|
end
|
16
13
|
|
17
14
|
group :development, :test do
|
data/Gemfile.lock
CHANGED
@@ -1,48 +1,51 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (3.
|
4
|
+
activesupport (3.2.0)
|
5
|
+
i18n (~> 0.6)
|
5
6
|
multi_json (~> 1.0)
|
6
7
|
addressable (2.2.6)
|
7
8
|
crack (0.3.1)
|
8
9
|
diff-lcs (1.1.3)
|
9
|
-
dragonfly (0.9.
|
10
|
+
dragonfly (0.9.10)
|
10
11
|
rack
|
11
12
|
git (1.2.5)
|
12
|
-
haml (3.1.4)
|
13
13
|
httparty (0.8.1)
|
14
14
|
multi_json
|
15
15
|
multi_xml
|
16
|
+
i18n (0.6.0)
|
16
17
|
imagesize (0.1.1)
|
17
|
-
jeweler (1.
|
18
|
+
jeweler (1.8.3)
|
18
19
|
bundler (~> 1.0)
|
19
20
|
git (>= 1.2.5)
|
20
21
|
rake
|
21
|
-
|
22
|
+
rdoc
|
23
|
+
json (1.6.5)
|
22
24
|
multi_json (1.0.4)
|
23
25
|
multi_xml (0.4.1)
|
24
26
|
newrelic_rpm (3.3.1)
|
25
|
-
rack (1.
|
26
|
-
rack-protection (1.
|
27
|
+
rack (1.4.1)
|
28
|
+
rack-protection (1.2.0)
|
27
29
|
rack
|
28
30
|
rack-test (0.6.1)
|
29
31
|
rack (>= 1.0)
|
30
32
|
rake (0.9.2.2)
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
rspec-
|
35
|
-
rspec-
|
36
|
-
|
37
|
-
rspec-
|
33
|
+
rdoc (3.12)
|
34
|
+
json (~> 1.4)
|
35
|
+
rspec (2.8.0)
|
36
|
+
rspec-core (~> 2.8.0)
|
37
|
+
rspec-expectations (~> 2.8.0)
|
38
|
+
rspec-mocks (~> 2.8.0)
|
39
|
+
rspec-core (2.8.0)
|
40
|
+
rspec-expectations (2.8.0)
|
38
41
|
diff-lcs (~> 1.1.2)
|
39
|
-
rspec-mocks (2.
|
40
|
-
sinatra (1.3.
|
41
|
-
rack (~> 1.3, >= 1.3.
|
42
|
-
rack-protection (~> 1.
|
42
|
+
rspec-mocks (2.8.0)
|
43
|
+
sinatra (1.3.2)
|
44
|
+
rack (~> 1.3, >= 1.3.6)
|
45
|
+
rack-protection (~> 1.2)
|
43
46
|
tilt (~> 1.3, >= 1.3.3)
|
44
47
|
tilt (1.3.3)
|
45
|
-
webmock (1.7.
|
48
|
+
webmock (1.7.10)
|
46
49
|
addressable (~> 2.2, > 2.2.5)
|
47
50
|
crack (>= 0.1.7)
|
48
51
|
|
@@ -53,14 +56,11 @@ DEPENDENCIES
|
|
53
56
|
activesupport (>= 2.0.0)
|
54
57
|
addressable (~> 2.2)
|
55
58
|
dragonfly (~> 0.9.5)
|
56
|
-
haml (~> 3.0)
|
57
59
|
httparty (~> 0.8.1)
|
58
60
|
imagesize (~> 0.1)
|
59
61
|
jeweler (~> 1.5)
|
60
|
-
json (~> 1.5)
|
61
62
|
newrelic_rpm
|
62
63
|
rack-test
|
63
|
-
rcov
|
64
64
|
rspec (~> 2.4)
|
65
65
|
sinatra (~> 1.2)
|
66
66
|
webmock (~> 1.6)
|
data/HISTORY.md
CHANGED
@@ -1,5 +1,27 @@
|
|
1
1
|
This gem respects [semantic versioning](http://semver.org/).
|
2
2
|
|
3
|
+
# 1.4.0 (1/26/12)
|
4
|
+
|
5
|
+
[commits](https://github.com/afeld/magickly/compare/v1.3.0...v1.4.0)
|
6
|
+
|
7
|
+
* SECURITY: don't pass cookies to image request (tolsen)
|
8
|
+
* removed async support (for now) - needs more extensive testing
|
9
|
+
* added /q syntax as alternative to query params (tolsen)
|
10
|
+
* added JCN effect
|
11
|
+
|
12
|
+
# 1.2.1 (12/21/11)
|
13
|
+
|
14
|
+
[commits](https://github.com/afeld/magickly/compare/v1.2.0...v1.2.1)
|
15
|
+
|
16
|
+
* made compatible w/ Dragonfly v0.9.8 (tolsen)
|
17
|
+
|
18
|
+
# 1.3.0 (9/5/11) - YANKED
|
19
|
+
|
20
|
+
[commits](https://github.com/afeld/magickly/compare/v1.2.0...v1.3.0)
|
21
|
+
|
22
|
+
* added asynchronous support when using Ruby 1.9 or JRuby
|
23
|
+
* reduced gem dependencies
|
24
|
+
|
3
25
|
# 1.2.0 (6/28/11)
|
4
26
|
|
5
27
|
[commits](https://github.com/afeld/magickly/compare/v1.1.3...v1.2.0)
|
data/README.md
CHANGED
@@ -2,27 +2,29 @@
|
|
2
2
|
|
3
3
|
A service for image manipulation - built as a simple wrapper of Imagemagick which handles caching, c/o the [Dragonfly](http://markevans.github.com/dragonfly/) gem.
|
4
4
|
|
5
|
-
Say the base URL is the hosted version of this app, [magickly.
|
5
|
+
Say the base URL is the hosted version of this app, [magickly.jux.com](http://magickly.jux.com). The image URL is appended to the query string as a `src=`, followed by any of the supported operations below. Multiple operations can be combined, and will be applied in order.
|
6
6
|
|
7
7
|
If no query params are provided, a simple sandbox page is displayed. Try it here:
|
8
8
|
|
9
|
-
[magickly.
|
9
|
+
[magickly.jux.com](http://magickly.jux.com)
|
10
10
|
|
11
11
|
## Installation
|
12
12
|
|
13
|
-
Requires Imagemagick >= v6.2.4.
|
13
|
+
Requires Ruby 1.8.7 or 1.9.2, and Imagemagick >= v6.2.4.
|
14
14
|
|
15
15
|
$ gem install magickly
|
16
16
|
|
17
17
|
## Running the App
|
18
18
|
|
19
|
-
A few options:
|
19
|
+
For Ruby 1.9.2, you will need to use an Eventmachine-compatible server, i.e. [Thin](http://code.macournoyer.com/thin/) or [Rainbows](http://rainbows.rubyforge.org/). A few options:
|
20
20
|
|
21
21
|
### A. Run the app directly
|
22
22
|
|
23
|
-
|
23
|
+
# in the app directory:
|
24
|
+
$ gem install thin
|
25
|
+
$ thin start
|
24
26
|
|
25
|
-
The app can be accessed at [http://localhost:
|
27
|
+
The app can be accessed at [http://localhost:3000](http://localhost:3000). To deploy to Heroku's Cedar stack (or another server using Foreman), see the [cedar](https://github.com/afeld/magickly/tree/cedar) branch.
|
26
28
|
|
27
29
|
### B. Use as an endpoint in another Rack app
|
28
30
|
|
@@ -48,91 +50,113 @@ The URL of the original image.
|
|
48
50
|
|
49
51
|
*brightness* and *contrast* are percentage change, between -100 and 100. For example, to increase contrast by 20% but leave brightness unchanged, use `brightness_contrast=0x20`.
|
50
52
|
|
51
|
-
![tanned imagemagick logo](http://magickly.
|
53
|
+
![tanned imagemagick logo](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&brightness_contrast=-10x50)
|
52
54
|
|
53
|
-
[http://magickly.
|
55
|
+
[http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&brightness_contrast=-10x50](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&brightness_contrast=-10x50)
|
54
56
|
|
55
57
|
### flip=true
|
56
58
|
|
57
|
-
![flipped imagemagick logo](http://magickly.
|
59
|
+
![flipped imagemagick logo](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&flip=true)
|
58
60
|
|
59
|
-
[http://magickly.
|
61
|
+
[http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&flip=true](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&flip=true)
|
60
62
|
|
61
63
|
### flop=true
|
62
64
|
|
63
|
-
![flopped imagemagick logo](http://magickly.
|
65
|
+
![flopped imagemagick logo](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&flop=true)
|
64
66
|
|
65
|
-
[http://magickly.
|
67
|
+
[http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&flop=true](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&flop=true)
|
66
68
|
|
67
69
|
### glow=*amount*,*softness*
|
68
70
|
|
69
71
|
where `amount` is a float >= 1.0, and `softness` is an int >= 0.
|
70
72
|
|
71
|
-
![glowing imagemagick logo](http://magickly.
|
73
|
+
![glowing imagemagick logo](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&glow=1.2,20)
|
72
74
|
|
73
|
-
[http://magickly.
|
75
|
+
[http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&glow=1.2,20](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&glow=1.2,20)
|
74
76
|
|
75
77
|
### greyscale=true
|
76
78
|
|
77
|
-
![flopped imagemagick logo](http://magickly.
|
79
|
+
![flopped imagemagick logo](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&greyscale=true)
|
78
80
|
|
79
|
-
[http://magickly.
|
81
|
+
[http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&greyscale=true](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&greyscale=true)
|
80
82
|
|
81
83
|
### halftone=*threshold*
|
82
84
|
|
83
85
|
where *threshold* is a value between 0 and 100.
|
84
86
|
|
85
|
-
![halftone imagemagick logo](http://magickly.
|
87
|
+
![halftone imagemagick logo](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&halftone=60)
|
86
88
|
|
87
|
-
[http://magickly.
|
89
|
+
[http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&halftone=60](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&halftone=60)
|
90
|
+
|
91
|
+
### jcn=true
|
92
|
+
|
93
|
+
![JCN imagemagick logo](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&jcn=true)
|
94
|
+
|
95
|
+
[http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&jcn=true](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&jcn=true)
|
88
96
|
|
89
97
|
### resize=*geometry*
|
90
98
|
|
91
|
-
![resized imagemagick logo](http://magickly.
|
99
|
+
![resized imagemagick logo](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&resize=100x100)
|
92
100
|
|
93
|
-
[http://magickly.
|
101
|
+
[http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&resize=100x100](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&resize=100x100)
|
94
102
|
|
95
103
|
### rotate=*degrees*
|
96
104
|
|
97
|
-
![rotated imagemagick logo](http://magickly.
|
105
|
+
![rotated imagemagick logo](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&rotate=45)
|
98
106
|
|
99
|
-
[http://magickly.
|
107
|
+
[http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&rotate=45](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&rotate=45)
|
100
108
|
|
101
109
|
### saturation=*percentage*
|
102
110
|
|
103
111
|
*percentage* is the percentage of variation: a positive integer. 100 means no change. For example, to increase saturation by 50%, use `saturation=150`.
|
104
112
|
|
105
|
-
![saturated imagemagick logo](http://magickly.
|
113
|
+
![saturated imagemagick logo](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&saturation=150)
|
106
114
|
|
107
|
-
[http://magickly.
|
115
|
+
[http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&saturation=150](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&saturation=150)
|
108
116
|
|
109
117
|
### tilt_shift=true
|
110
118
|
|
111
|
-
![tilt-shifted imagemagick logo](http://magickly.
|
119
|
+
![tilt-shifted imagemagick logo](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&tilt_shift=true)
|
112
120
|
|
113
|
-
[http://magickly.
|
121
|
+
[http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&tilt_shift=true](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&tilt_shift=true)
|
114
122
|
|
115
123
|
### thumb=*geometry*
|
116
124
|
|
117
|
-
![thumbnail of imagemagick logo](http://magickly.
|
125
|
+
![thumbnail of imagemagick logo](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&thumb=200x100%23)
|
118
126
|
|
119
|
-
[http://magickly.
|
127
|
+
[http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&thumb=200x100%23](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&thumb=200x100%23)
|
120
128
|
|
121
129
|
(note: the `%23` in the geometry string above is an encoded '`#`', which tells Dragonfly to fill the dimensions and crop)
|
122
130
|
|
123
131
|
### two_color=true
|
124
132
|
|
125
|
-
![two color imagemagick logo](http://magickly.
|
133
|
+
![two color imagemagick logo](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&two_color=true)
|
134
|
+
|
135
|
+
[http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&two_color=true](http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&two_color=true)
|
136
|
+
|
137
|
+
## Alternate Syntax
|
138
|
+
|
139
|
+
Some CDNs are jerks and don't respect query params on resources (_ahem_ CLOUDFRONT _ahem_) when caching. To use this syntax:
|
126
140
|
|
127
|
-
|
141
|
+
* replace the question mark that starts the query string (`?`) with `q/`
|
142
|
+
* replace the ampersands (`&`) and equals signs (`=`) with forward slashes (`/`)
|
143
|
+
* make sure the `src` is encoded - this can be done in Javascript with `encodeURIComponent()`
|
144
|
+
|
145
|
+
Therefore, instead of
|
146
|
+
|
147
|
+
http://magickly.jux.com/?src=http://upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Imagemagick-logo.png/200px-Imagemagick-logo.png&thumb=200x100
|
148
|
+
|
149
|
+
the new URL would be
|
150
|
+
|
151
|
+
http://magickly.jux.com/q/src/http%3A%2F%2Fupload.wikimedia.org%2Fwikipedia%2Fcommons%2Fthumb%2F0%2F0d%2FImagemagick-logo.png%2F200px-Imagemagick-logo.png/thumb/200x100
|
128
152
|
|
129
153
|
## Analyzers
|
130
154
|
|
131
155
|
Magickly v1.2.0 introduces the ability to retrieve image properties via a REST API. For example, to retrieve the number of colors in the photo, visit:
|
132
156
|
|
133
|
-
[magickly.
|
157
|
+
[magickly.jux.com/analyze/number_of_colors?src=http://upload.wikimedia.org/wikipedia/commons/0/0d/Imagemagick-logo.png](http://magickly.jux.com/analyze/number_of_colors?src=http://upload.wikimedia.org/wikipedia/commons/0/0d/Imagemagick-logo.png)
|
134
158
|
|
135
|
-
To get the list of available analyzers, visit [magickly.
|
159
|
+
To get the list of available analyzers, visit [magickly.jux.com/analyze](http://magickly.jux.com/analyze)
|
136
160
|
|
137
161
|
## Customization
|
138
162
|
|
@@ -149,6 +173,10 @@ which can then be used with the query string `?src=...&resize_with_blur=200x`.
|
|
149
173
|
|
150
174
|
See the [Dragonfly documentation](http://markevans.github.com/dragonfly/file.GeneralUsage.html#Shortcuts) for more info on "shortcuts", and the [shortcuts.rb](https://github.com/afeld/magickly/blob/master/lib/shortcuts.rb) file for examples.
|
151
175
|
|
176
|
+
## Disclaimer
|
177
|
+
|
178
|
+
The hosted version of the app ([magickly.jux.com](http://magickly.jux.com)) is a single app instance intended for demonstration purposes - if you are going to be making a large number of API calls to it or would like to use it in production, please let us know :-)
|
179
|
+
|
152
180
|
## Contributing to magickly
|
153
181
|
|
154
182
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
data/Rakefile
CHANGED
@@ -19,7 +19,6 @@ Jeweler::Tasks.new do |gem|
|
|
19
19
|
gem.description = %Q{A service for image manipulation - built as an extensible wrapper of Imagemagick which handles caching, c/o the Dragonfly gem.}
|
20
20
|
gem.email = "aidan.feldman@gmail.com"
|
21
21
|
gem.authors = ["Aidan Feldman"]
|
22
|
-
gem.executables = ['magickly']
|
23
22
|
gem.files.include '.gemtest'
|
24
23
|
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
25
24
|
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
@@ -42,8 +41,8 @@ end
|
|
42
41
|
task :default => :spec
|
43
42
|
task :test => :spec
|
44
43
|
|
45
|
-
require '
|
46
|
-
|
44
|
+
require 'rdoc/task'
|
45
|
+
RDoc::Task.new do |rdoc|
|
47
46
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
47
|
|
49
48
|
rdoc.rdoc_dir = 'rdoc'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.4.0
|
@@ -7,14 +7,12 @@ module Dragonfly
|
|
7
7
|
class RemoteDataStore
|
8
8
|
include Configurable
|
9
9
|
|
10
|
-
configurable_attr :cookie_str
|
11
|
-
|
12
10
|
def store(temp_object, opts={})
|
13
11
|
raise "Sorry friend, this datastore is read-only."
|
14
12
|
end
|
15
13
|
|
16
14
|
def retrieve(uid)
|
17
|
-
response = HTTParty.get uid, :
|
15
|
+
response = HTTParty.get uid, :timeout => 3
|
18
16
|
unless response.ok?
|
19
17
|
#raise Forbidden if response.code == 403
|
20
18
|
raise DataNotFound
|
data/lib/magickly.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'active_support/json'
|
1
2
|
require 'active_support/core_ext/object/blank'
|
2
3
|
require 'active_support/ordered_hash'
|
3
4
|
|
@@ -15,6 +16,8 @@ module Magickly
|
|
15
16
|
@dragonfly.configure do |c|
|
16
17
|
c.datastore = Dragonfly::DataStorage::RemoteDataStore.new
|
17
18
|
c.log = Logger.new($stdout)
|
19
|
+
|
20
|
+
# seems this config param was removed from Dragonfly ~v0.9.8
|
18
21
|
# c.log_commands = true
|
19
22
|
end
|
20
23
|
|
data/lib/magickly/app.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Magickly
|
2
2
|
class App < Sinatra::Base
|
3
3
|
RESERVED_PARAMS = ['src']
|
4
|
-
DEMO_IMAGE = 'http://
|
4
|
+
DEMO_IMAGE = 'http://farm4.static.flickr.com/3351/3450592233_c29fde01ef_z.jpg'
|
5
5
|
|
6
6
|
enable :logging
|
7
7
|
set :root, File.join(File.dirname(__FILE__), '..')
|
@@ -11,13 +11,15 @@ module Magickly
|
|
11
11
|
require 'newrelic_rpm' if ENV['NEW_RELIC_ID']
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
14
|
before do
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
# redirect to MAGICKLY_APP_DOMAIN, if specified
|
16
|
+
app_host = ENV['MAGICKLY_APP_DOMAIN']
|
17
|
+
if app_host && request.host != app_host
|
18
|
+
request_host_with_port = request.env['HTTP_HOST']
|
19
|
+
redirect request.url.sub(request_host_with_port, app_host), 301
|
19
20
|
end
|
20
21
|
|
22
|
+
# parse query params so they are ordered
|
21
23
|
@options = ActiveSupport::OrderedHash.new
|
22
24
|
request.query_string.split('&').each do |e|
|
23
25
|
k,v = e.split('=')
|
@@ -26,27 +28,34 @@ module Magickly
|
|
26
28
|
end
|
27
29
|
|
28
30
|
get '/' do
|
29
|
-
|
31
|
+
process_src_or_display_demo params[:src], @options
|
32
|
+
end
|
33
|
+
|
34
|
+
get '/q/*' do
|
35
|
+
src = nil
|
36
|
+
opts = ActiveSupport::OrderedHash.new
|
37
|
+
splat = request.path_info.sub /^\/q\//, ''
|
30
38
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
haml :index
|
39
|
+
splat.split('/').each_slice(2) do |k, v|
|
40
|
+
if RESERVED_PARAMS.include? k
|
41
|
+
if k == 'src'
|
42
|
+
src = URI.unescape(v)
|
43
|
+
# slashes come in double-escaped by Apache so we
|
44
|
+
# need to unescape again
|
45
|
+
src = URI.unescape(src) if src =~ /%2F/
|
46
|
+
end
|
47
|
+
else
|
48
|
+
opts[k] = URI.unescape(v)
|
49
|
+
end
|
43
50
|
end
|
51
|
+
|
52
|
+
process_src_or_display_demo src, opts
|
44
53
|
end
|
45
54
|
|
46
55
|
get '/analyze' do
|
47
56
|
@analyzers = Magickly.dragonfly.analyser_methods
|
48
57
|
@analyzers.sort!{|m1, m2| m1.to_s <=> m2.to_s }
|
49
|
-
|
58
|
+
erb :analyzers
|
50
59
|
end
|
51
60
|
|
52
61
|
get '/analyze/:name' do |method|
|
@@ -68,7 +77,22 @@ module Magickly
|
|
68
77
|
"Please provide an image URL with the src parameter."
|
69
78
|
end
|
70
79
|
end
|
71
|
-
|
80
|
+
|
81
|
+
def process_src_or_display_demo src, options
|
82
|
+
if src
|
83
|
+
# process image
|
84
|
+
url = uri_to_url src
|
85
|
+
image = Magickly.process_src(url, options)
|
86
|
+
image.to_response(env)
|
87
|
+
else
|
88
|
+
# display demo page
|
89
|
+
|
90
|
+
# get combined list of jobs and processor methods
|
91
|
+
@methods = ( Magickly.dragonfly.job_methods | Magickly.dragonfly.processor_methods )
|
92
|
+
@methods.sort!{|m1, m2| m1.to_s <=> m2.to_s }
|
93
|
+
erb :index
|
94
|
+
end
|
95
|
+
end
|
72
96
|
|
73
97
|
def uri_to_url(uri)
|
74
98
|
url = Addressable::URI.parse(uri)
|