dragonfly 0.9.15 → 1.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of dragonfly might be problematic. Click here for more details.
- checksums.yaml +7 -0
- data/.gitignore +1 -8
- data/.travis.yml +11 -0
- data/Gemfile +1 -0
- data/History.md +52 -2
- data/LICENSE +1 -1
- data/README.md +38 -95
- data/dev/grid.jpg +0 -0
- data/dev/irbrc.rb +27 -0
- data/dev/rails_template.rb +38 -0
- data/dev/test.ru +56 -0
- data/dev/test_rails +19 -0
- data/dragonfly.gemspec +3 -21
- data/lib/dragonfly.rb +45 -44
- data/lib/dragonfly/app.rb +175 -96
- data/lib/dragonfly/configurable.rb +71 -170
- data/lib/dragonfly/content.rb +211 -0
- data/lib/dragonfly/core_ext/object.rb +1 -6
- data/lib/dragonfly/file_data_store.rb +197 -0
- data/lib/dragonfly/image_magick/analysers/image_properties.rb +23 -0
- data/lib/dragonfly/image_magick/generators/convert.rb +19 -0
- data/lib/dragonfly/image_magick/generators/plain.rb +26 -0
- data/lib/dragonfly/image_magick/generators/plasma.rb +25 -0
- data/lib/dragonfly/image_magick/generators/text.rb +127 -0
- data/lib/dragonfly/image_magick/plugin.rb +83 -0
- data/lib/dragonfly/image_magick/processors/convert.rb +29 -0
- data/lib/dragonfly/image_magick/processors/encode.rb +18 -0
- data/lib/dragonfly/image_magick/processors/thumb.rb +76 -0
- data/lib/dragonfly/job.rb +118 -134
- data/lib/dragonfly/job_endpoint.rb +2 -0
- data/lib/dragonfly/memory_data_store.rb +34 -0
- data/lib/dragonfly/middleware.rb +5 -3
- data/lib/dragonfly/{active_model_extensions.rb → model.rb} +5 -3
- data/lib/dragonfly/{active_model_extensions → model}/attachment.rb +40 -35
- data/lib/dragonfly/{active_model_extensions → model}/attachment_class_methods.rb +36 -40
- data/lib/dragonfly/model/class_methods.rb +109 -0
- data/lib/dragonfly/{active_model_extensions → model}/instance_methods.rb +2 -2
- data/lib/dragonfly/{active_model_extensions → model}/validations.rb +17 -12
- data/lib/dragonfly/railtie.rb +8 -6
- data/lib/dragonfly/register.rb +27 -0
- data/lib/dragonfly/response.rb +47 -52
- data/lib/dragonfly/routed_endpoint.rb +4 -0
- data/lib/dragonfly/serializer.rb +15 -5
- data/lib/dragonfly/server.rb +56 -29
- data/lib/dragonfly/shell.rb +12 -23
- data/lib/dragonfly/spec/data_store_examples.rb +64 -0
- data/lib/dragonfly/temp_object.rb +32 -47
- data/lib/dragonfly/url_attributes.rb +19 -22
- data/lib/dragonfly/url_mapper.rb +3 -0
- data/lib/dragonfly/utils.rb +12 -0
- data/lib/dragonfly/version.rb +1 -1
- data/lib/dragonfly/whitelist.rb +19 -0
- data/lib/rails/generators/dragonfly/USAGE +8 -0
- data/lib/rails/generators/dragonfly/dragonfly_generator.rb +24 -0
- data/lib/rails/generators/dragonfly/templates/initializer.rb.erb +27 -0
- data/samples/gif.gif +0 -0
- data/spec/dragonfly/app_spec.rb +270 -64
- data/spec/dragonfly/configurable_spec.rb +142 -418
- data/spec/dragonfly/content_spec.rb +353 -0
- data/spec/dragonfly/cookie_monster_spec.rb +2 -1
- data/spec/dragonfly/file_data_store_spec.rb +301 -0
- data/spec/dragonfly/image_magick/analysers/image_properties_spec.rb +20 -0
- data/spec/dragonfly/image_magick/generators/convert_spec.rb +19 -0
- data/spec/dragonfly/image_magick/generators/plain_spec.rb +50 -0
- data/spec/dragonfly/image_magick/generators/plasma_spec.rb +32 -0
- data/spec/dragonfly/image_magick/generators/text_spec.rb +77 -0
- data/spec/dragonfly/image_magick/plugin_spec.rb +131 -0
- data/spec/dragonfly/image_magick/processors/convert_spec.rb +56 -0
- data/spec/dragonfly/image_magick/processors/thumb_spec.rb +173 -0
- data/spec/dragonfly/job_endpoint_spec.rb +30 -73
- data/spec/dragonfly/job_spec.rb +280 -608
- data/spec/dragonfly/memory_data_store_spec.rb +20 -0
- data/spec/dragonfly/middleware_spec.rb +47 -27
- data/spec/dragonfly/{active_model_extensions → model}/model_spec.rb +331 -555
- data/spec/dragonfly/model/validations_spec.rb +196 -0
- data/spec/dragonfly/register_spec.rb +35 -0
- data/spec/dragonfly/routed_endpoint_spec.rb +6 -6
- data/spec/dragonfly/serializer_spec.rb +13 -15
- data/spec/dragonfly/server_spec.rb +122 -46
- data/spec/dragonfly/shell_spec.rb +43 -24
- data/spec/dragonfly/temp_object_spec.rb +69 -94
- data/spec/dragonfly/url_attributes_spec.rb +49 -0
- data/spec/dragonfly/utils_spec.rb +32 -0
- data/spec/dragonfly/whitelist_spec.rb +30 -0
- data/spec/dragonfly_spec.rb +43 -0
- data/spec/fixtures/deprecated_stored_content/eggs.bonus +1 -0
- data/spec/fixtures/deprecated_stored_content/eggs.bonus.meta +1 -0
- data/spec/functional/configuration_spec.rb +19 -0
- data/spec/functional/model_urls_spec.rb +43 -41
- data/spec/functional/remote_on_the_fly_spec.rb +14 -16
- data/spec/functional/shell_commands_spec.rb +24 -14
- data/spec/functional/to_response_spec.rb +10 -10
- data/spec/functional/urls_spec.rb +5 -3
- data/spec/spec_helper.rb +23 -28
- data/spec/support/argument_matchers.rb +7 -8
- data/spec/support/image_matchers.rb +14 -36
- data/spec/support/model_helpers.rb +97 -0
- data/spec/support/simple_matchers.rb +12 -0
- metadata +92 -393
- data/.yardopts +0 -29
- data/Rakefile +0 -36
- data/config.ru +0 -14
- data/docs.watchr +0 -1
- data/extra_docs/Analysers.md +0 -68
- data/extra_docs/Caching.md +0 -23
- data/extra_docs/Configuration.md +0 -149
- data/extra_docs/Couch.md +0 -49
- data/extra_docs/DataStorage.md +0 -226
- data/extra_docs/Encoding.md +0 -67
- data/extra_docs/ExampleUseCases.md +0 -116
- data/extra_docs/GeneralUsage.md +0 -105
- data/extra_docs/Generators.md +0 -68
- data/extra_docs/Heroku.md +0 -50
- data/extra_docs/ImageMagick.md +0 -136
- data/extra_docs/Index.md +0 -33
- data/extra_docs/MimeTypes.md +0 -40
- data/extra_docs/Models.md +0 -441
- data/extra_docs/Mongo.md +0 -42
- data/extra_docs/Processing.md +0 -77
- data/extra_docs/Rack.md +0 -52
- data/extra_docs/Rails2.md +0 -57
- data/extra_docs/Rails3.md +0 -56
- data/extra_docs/ServingRemotely.md +0 -104
- data/extra_docs/Sinatra.md +0 -25
- data/extra_docs/URLs.md +0 -203
- data/features/images.feature +0 -47
- data/features/no_processing.feature +0 -14
- data/features/rails.feature +0 -8
- data/features/steps/common_steps.rb +0 -8
- data/features/steps/dragonfly_steps.rb +0 -66
- data/features/steps/rails_steps.rb +0 -40
- data/features/support/env.rb +0 -13
- data/features/support/setup.rb +0 -41
- data/fixtures/rails/files/app/models/album.rb +0 -6
- data/fixtures/rails/files/app/views/albums/new.html.erb +0 -7
- data/fixtures/rails/files/app/views/albums/show.html.erb +0 -6
- data/fixtures/rails/files/config/initializers/dragonfly.rb +0 -4
- data/fixtures/rails/files/features/manage_album_images.feature +0 -38
- data/fixtures/rails/files/features/step_definitions/helper_steps.rb +0 -7
- data/fixtures/rails/files/features/step_definitions/image_steps.rb +0 -25
- data/fixtures/rails/files/features/step_definitions/web_steps.rb +0 -189
- data/fixtures/rails/files/features/support/paths.rb +0 -17
- data/fixtures/rails/files/features/text_images.feature +0 -7
- data/fixtures/rails/template.rb +0 -20
- data/irbrc.rb +0 -19
- data/lib/dragonfly/active_model_extensions/class_methods.rb +0 -98
- data/lib/dragonfly/analyser.rb +0 -58
- data/lib/dragonfly/analysis/file_command_analyser.rb +0 -33
- data/lib/dragonfly/analysis/image_magick_analyser.rb +0 -6
- data/lib/dragonfly/config/heroku.rb +0 -26
- data/lib/dragonfly/config/image_magick.rb +0 -6
- data/lib/dragonfly/config/rails.rb +0 -20
- data/lib/dragonfly/data_storage.rb +0 -11
- data/lib/dragonfly/data_storage/couch_data_store.rb +0 -83
- data/lib/dragonfly/data_storage/file_data_store.rb +0 -144
- data/lib/dragonfly/data_storage/mongo_data_store.rb +0 -96
- data/lib/dragonfly/data_storage/s3data_store.rb +0 -168
- data/lib/dragonfly/encoder.rb +0 -13
- data/lib/dragonfly/encoding/image_magick_encoder.rb +0 -6
- data/lib/dragonfly/function_manager.rb +0 -67
- data/lib/dragonfly/generation/image_magick_generator.rb +0 -6
- data/lib/dragonfly/generator.rb +0 -9
- data/lib/dragonfly/image_magick/analyser.rb +0 -53
- data/lib/dragonfly/image_magick/config.rb +0 -44
- data/lib/dragonfly/image_magick/encoder.rb +0 -57
- data/lib/dragonfly/image_magick/generator.rb +0 -147
- data/lib/dragonfly/image_magick/processor.rb +0 -114
- data/lib/dragonfly/image_magick/utils.rb +0 -46
- data/lib/dragonfly/image_magick_utils.rb +0 -4
- data/lib/dragonfly/job_builder.rb +0 -39
- data/lib/dragonfly/job_definitions.rb +0 -30
- data/lib/dragonfly/loggable.rb +0 -28
- data/lib/dragonfly/processing/image_magick_processor.rb +0 -6
- data/lib/dragonfly/processor.rb +0 -9
- data/lib/dragonfly/rails/images.rb +0 -32
- data/lib/dragonfly/simple_cache.rb +0 -23
- data/spec/dragonfly/active_model_extensions/spec_helper.rb +0 -95
- data/spec/dragonfly/analyser_spec.rb +0 -123
- data/spec/dragonfly/analysis/file_command_analyser_spec.rb +0 -49
- data/spec/dragonfly/data_storage/couch_data_store_spec.rb +0 -84
- data/spec/dragonfly/data_storage/file_data_store_spec.rb +0 -308
- data/spec/dragonfly/data_storage/mongo_data_store_spec.rb +0 -81
- data/spec/dragonfly/data_storage/s3_data_store_spec.rb +0 -277
- data/spec/dragonfly/data_storage/shared_data_store_examples.rb +0 -77
- data/spec/dragonfly/function_manager_spec.rb +0 -154
- data/spec/dragonfly/image_magick/analyser_spec.rb +0 -73
- data/spec/dragonfly/image_magick/encoder_spec.rb +0 -46
- data/spec/dragonfly/image_magick/generator_spec.rb +0 -178
- data/spec/dragonfly/image_magick/processor_spec.rb +0 -293
- data/spec/dragonfly/job_builder_spec.rb +0 -37
- data/spec/dragonfly/job_definitions_spec.rb +0 -57
- data/spec/dragonfly/loggable_spec.rb +0 -80
- data/spec/dragonfly/simple_cache_spec.rb +0 -27
- data/spec/dragonfly/url_attributes.rb +0 -47
- data/spec/functional/deprecations_spec.rb +0 -51
- data/spec/functional/image_magick_app_spec.rb +0 -27
- data/spec/test_imagemagick.ru +0 -49
- data/yard/handlers/configurable_attr_handler.rb +0 -38
- data/yard/setup.rb +0 -15
- data/yard/templates/default/fulldoc/html/css/common.css +0 -109
- data/yard/templates/default/layout/html/layout.erb +0 -93
- data/yard/templates/default/module/html/configuration_summary.erb +0 -31
- data/yard/templates/default/module/setup.rb +0 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e67b985fbe6f3f97fc92af0803738713e5dcabae
|
4
|
+
data.tar.gz: 2f2587a40ef4dd9a431e20760cf8ec94530836d0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ada62ec2fad0a91f4a8131d8b3ea53ee38631f5bde95f02e3eb30a094895ed744d4e8a861e40a1ea9fa31a9d3cbd7f7ed4ba0e87c9ed68c407363f391cb7cb65
|
7
|
+
data.tar.gz: 90753f8280e3f8e29e4c6de826b5f5d0dc20d2f71df6a239bb05e6e75ac00f23dfeb6c4985140ef319bfba4913a7975292dc65a1910b481b64de03b61dc05650
|
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/History.md
CHANGED
@@ -1,3 +1,53 @@
|
|
1
|
+
1.0.0 (2013-11-24)
|
2
|
+
===================
|
3
|
+
Changes
|
4
|
+
-------
|
5
|
+
- configuration
|
6
|
+
- `Dragonfly[:images]` -> `Dragonfly.app` and `Dragonfly.app(:named_app)`
|
7
|
+
- configuration block DSL overhaul
|
8
|
+
- Rails is set up using a generator, not by requiring the file "dragonfly/rails/images"
|
9
|
+
- Rack::Cache is not inserted by Dragonfly - this is up to the user
|
10
|
+
- data store spec
|
11
|
+
- `store`/`retrieve` -> `read`/`write`
|
12
|
+
- `write` takes a `Content`, not a `TempObject` (though the interface is much the same)
|
13
|
+
- return nil on `read` to signify not found instead of raising
|
14
|
+
- S3, Couch and Mongo data stores extracted into separate gems
|
15
|
+
- models
|
16
|
+
- easier and simpler to include in custom models using `Dragonfly::Model`
|
17
|
+
- `image_accessor`, `asset_accessor`, `xxx_accessor`, etc. -> single `dragonfly_accessor`
|
18
|
+
- user needs to extend `Dragonfly::Model::Validations` manually to use dragonfly validations
|
19
|
+
- Custom processors, datastores, generators and analysers are made easier by `Content` object which has convenience methods
|
20
|
+
- Removed "encoders" - these are covered by processors now
|
21
|
+
- Removed "job" shortcuts - they are not needed as processors can invoke other processors
|
22
|
+
- No "smart" determination of mime-type - just use file extension (anything more than that can be done by the user)
|
23
|
+
- metadata is required to be serializable to/from JSON
|
24
|
+
- removed `allow_fetch_file` and `allow_fetch_url` in favour of more fine-control with `fetch_file_whitelist` and `fetch_url_whitelist`
|
25
|
+
- switch off dealing with legacy urls by default
|
26
|
+
- proper requires throughout the code instead of autoloading
|
27
|
+
- simple 500 response for unknown errors
|
28
|
+
|
29
|
+
Features
|
30
|
+
--------
|
31
|
+
- model attachment default (by specifying a path to a e.g. a default image)
|
32
|
+
- `convert` and `thumb` processors take a `'frame'` option
|
33
|
+
- `thumb` takes a `'format'` option
|
34
|
+
- `fetch_file` and `model.attachment_url=` accept a data uri string
|
35
|
+
- `Attachment#xxx_stored`, e.g. `my_model.my_attachment_stored?` (`my_attachment` here being the attachment name)
|
36
|
+
- `define` for creating custom methods on `Job`/`Attachment` objects
|
37
|
+
- `url_path_prefix` for when mounted in Rack with a "SCRIPT_NAME"
|
38
|
+
- when customizing response headers, ability to remove headers by setting to `nil`
|
39
|
+
- better logging
|
40
|
+
- for each response
|
41
|
+
- for shell commands
|
42
|
+
|
43
|
+
Fixes
|
44
|
+
-----
|
45
|
+
- inserting CookieMonster doesn't depend on existence of `ActionDispatch::Cookies`
|
46
|
+
- `image?` returns false for pdfs
|
47
|
+
- `fetch_url` raises more useful `ErrorResponse` on error
|
48
|
+
- shell commands don't print warnings to stderr
|
49
|
+
- ability to assign attachment/job from other app
|
50
|
+
|
1
51
|
0.9.15 (2013-05-04)
|
2
52
|
===================
|
3
53
|
Features
|
@@ -171,7 +221,7 @@ Fixes
|
|
171
221
|
- Improved performance of `resize_and_crop` method, using imagemagick built-in '^' operator
|
172
222
|
- Improved server security validations
|
173
223
|
- Deal with Excon::Errors::SocketError: EOFError errors which get thrown sometimes from S3 connection
|
174
|
-
- Allow files with '..' (but not '../') in the middle of their name in file data store
|
224
|
+
- Allow files with '..' (but not '../') in the middle of their name in file data store
|
175
225
|
|
176
226
|
0.9.0 (2011-04-27)
|
177
227
|
==================
|
@@ -258,7 +308,7 @@ Features
|
|
258
308
|
--------
|
259
309
|
- New ImageMagick generator, processor, encoder and analyser, which are now defaults
|
260
310
|
(thanks to Henry Phan for work on this)
|
261
|
-
|
311
|
+
|
262
312
|
Fixes
|
263
313
|
-----
|
264
314
|
- Works with Rails 3.0.2 uploaded files (which has a changed API)
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,119 +1,65 @@
|
|
1
1
|
Dragonfly
|
2
2
|
===========
|
3
|
+
Hello!!
|
4
|
+
Dragonfly is a highly customizable ruby gem for handling images and other attachments and is already in use on thousands of websites.
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
Ideal for using with Ruby on Rails (2.3 and 3), Sinatra and all that gubbins.
|
7
|
-
|
8
|
-
However, Dragonfly is NOT JUST FOR RAILS, and NOT JUST FOR IMAGES!!
|
9
|
-
|
10
|
-
**IMPORTANT: if you're running a version between 0.7.0 and 0.9.12, please update to at least 0.9.14 for a security update [details here](https://groups.google.com/forum/?fromgroups=#!topic/dragonfly-users/3c3WIU3VQTo)**
|
11
|
-
|
12
|
-
For the lazy Rails user...
|
13
|
-
--------------------------
|
14
|
-
**Gemfile**:
|
15
|
-
|
6
|
+
If you want to generate image thumbnails in Rails ...
|
16
7
|
```ruby
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
**Initializer** (e.g. config/initializers/dragonfly.rb):
|
22
|
-
|
23
|
-
```ruby
|
24
|
-
require 'dragonfly/rails/images'
|
8
|
+
class User < ActiveRecord::Base # model
|
9
|
+
dragonfly_accessor :photo
|
10
|
+
end
|
25
11
|
```
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
```ruby
|
30
|
-
add_column :albums, :cover_image_uid, :string
|
31
|
-
add_column :albums, :cover_image_name, :string # Optional - only if you want urls
|
32
|
-
# to end with the original filename
|
12
|
+
```erb
|
13
|
+
<%= image_tag @user.photo.thumb('300x200#') # view %>
|
33
14
|
```
|
34
15
|
|
35
|
-
|
36
|
-
|
16
|
+
... or generate text images on-demand in Sinatra ...
|
37
17
|
```ruby
|
38
|
-
|
39
|
-
|
40
|
-
# this defines a reader/writer for cover_image
|
41
|
-
# ...
|
18
|
+
get "/:text" do |text|
|
19
|
+
Dragonfly.app.generate(:text, text, "font-size" => 32).to_response(env)
|
42
20
|
end
|
43
21
|
```
|
44
22
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
<%= f.file_field :cover_image %>
|
51
|
-
...
|
52
|
-
<% end %>
|
53
|
-
```
|
54
|
-
|
55
|
-
NB: REMEMBER THE MULTIPART BIT!!!
|
56
|
-
|
57
|
-
You can avoid having to re-upload when validations fail with
|
23
|
+
... or just generally manage attachments in your web app ...
|
24
|
+
```ruby
|
25
|
+
wav = Dragonfly.app.fetch_url("http://free.music/lard.wav") # GET from t'interwebs
|
26
|
+
mp3 = wav.to_mp3 # to_mp3 is a custom processor
|
27
|
+
uid = mp3.store # store in the configured datastore, e.g. S3
|
58
28
|
|
59
|
-
|
60
|
-
<%= f.hidden_field :retained_cover_image %>
|
29
|
+
url = Dragonfly.app.remote_url_for(uid) # ===> http://s3.amazon.com/my-stuff/lard.mp3
|
61
30
|
```
|
62
31
|
|
63
|
-
|
64
|
-
|
65
|
-
```erb
|
66
|
-
<%= f.check_box :remove_cover_image %>
|
67
|
-
```
|
32
|
+
... then Dragonfly is for you! See [the documentation](http://markevans.github.io/dragonfly) to get started!
|
68
33
|
|
69
|
-
|
34
|
+
Documentation
|
35
|
+
=============
|
36
|
+
<a href="http://markevans.github.io/dragonfly"><big><strong>THE MAIN DOCUMENTATION IS HERE!!!</strong></big></a>
|
70
37
|
|
71
|
-
|
72
|
-
<%= f.text_field :cover_image_url %>
|
73
|
-
```
|
38
|
+
<a href="http://rubydoc.info/github/markevans/dragonfly/frames">RDoc documentation is here</a>
|
74
39
|
|
75
|
-
|
40
|
+
Dragonfly has changed somewhat since version 0.9 - if for whatever reason you can't upgrade, then
|
41
|
+
<a href="http://markevans.github.io/dragonfly/v0.9.15">the docs for version 0.9.x are here</a>.
|
76
42
|
|
77
|
-
|
78
|
-
|
79
|
-
```
|
43
|
+
Installation
|
44
|
+
============
|
80
45
|
|
81
|
-
|
46
|
+
gem install dragonfly
|
82
47
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
<%= image_tag @album.cover_image.jpg.url %>
|
87
|
-
<%= image_tag @album.cover_image.process(:greyscale).encode(:tiff).url %>
|
88
|
-
...etc.
|
48
|
+
or in your Gemfile
|
49
|
+
```ruby
|
50
|
+
gem 'dragonfly', '~> 1.0.0'
|
89
51
|
```
|
90
52
|
|
91
|
-
|
92
|
-
uses it. For alternative configurations, see below.
|
93
|
-
|
94
|
-
If using Capistrano with the above, you probably will want to keep the cache between deploys, so in deploy.rb:
|
95
|
-
|
53
|
+
Require with
|
96
54
|
```ruby
|
97
|
-
|
98
|
-
desc "Symlink the Rack::Cache files"
|
99
|
-
task :symlink, :roles => [:app] do
|
100
|
-
run "mkdir -p #{shared_path}/tmp/dragonfly && ln -nfs #{shared_path}/tmp/dragonfly #{release_path}/tmp/dragonfly"
|
101
|
-
end
|
102
|
-
end
|
103
|
-
after 'deploy:update_code', 'dragonfly:symlink'
|
55
|
+
require 'dragonfly'
|
104
56
|
```
|
105
57
|
|
106
|
-
|
107
|
-
|
108
|
-
|
58
|
+
Plugins and Add-ons
|
59
|
+
===================
|
60
|
+
See [the Add-ons wiki](http://github.com/markevans/dragonfly/wiki/Dragonfly-add-ons).
|
109
61
|
|
110
|
-
|
111
|
-
|
112
|
-
For more info, consult the <a href="http://markevans.github.com/dragonfly"><big><strong>DOCUMENTATION</strong></big></a>
|
113
|
-
|
114
|
-
Add-ons
|
115
|
-
=======
|
116
|
-
For third-party add-ons, see [the Add-ons wiki](http://github.com/markevans/dragonfly/wiki/Dragonfly-add-ons)
|
62
|
+
Please feel free to contribute!!
|
117
63
|
|
118
64
|
Issues
|
119
65
|
======
|
@@ -125,8 +71,5 @@ Suggestions/Questions
|
|
125
71
|
|
126
72
|
Credits
|
127
73
|
=======
|
128
|
-
|
129
|
-
|
130
|
-
Copyright
|
131
|
-
========
|
132
|
-
Copyright (c) 2009-2010 Mark Evans. See LICENSE for details.
|
74
|
+
[Mark Evans](http://github.com/markevans) (author) with awesome contributions from
|
75
|
+
<a href="https://github.com/markevans/dragonfly/graphs/contributors">these guys</a>
|
data/dev/grid.jpg
ADDED
Binary file
|
data/dev/irbrc.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
$:.unshift(File.expand_path('../../lib', __FILE__))
|
4
|
+
require 'dragonfly'
|
5
|
+
include Dragonfly::Serializer
|
6
|
+
|
7
|
+
APP = Dragonfly.app.configure do
|
8
|
+
plugin :imagemagick
|
9
|
+
datastore :memory
|
10
|
+
end
|
11
|
+
|
12
|
+
class Model
|
13
|
+
extend Dragonfly::Model
|
14
|
+
attr_accessor :image_uid, :image_name, :image_width, :small_image_uid
|
15
|
+
dragonfly_accessor :image
|
16
|
+
dragonfly_accessor :small_image
|
17
|
+
end
|
18
|
+
|
19
|
+
puts "Loaded stuff from dragonfly irbrc"
|
20
|
+
puts "\nAvailable sample images:\n"
|
21
|
+
puts Dir['samples/*']
|
22
|
+
puts "\nAvailable constants:\n"
|
23
|
+
puts "APP"
|
24
|
+
puts "\nModel:\n"
|
25
|
+
puts "dragonfly_accessor :image with image_name, image_width"
|
26
|
+
puts
|
27
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
gem 'dragonfly', :path => File.expand_path('../..', __FILE__)
|
2
|
+
generate "dragonfly"
|
3
|
+
generate "scaffold", "photo image_uid:string image_name:string"
|
4
|
+
rake "db:migrate"
|
5
|
+
route %(
|
6
|
+
get "text/:text" => Dragonfly.app.endpoint { |params, app|
|
7
|
+
app.generate(:text, params[:text])
|
8
|
+
}
|
9
|
+
)
|
10
|
+
route "root :to => 'photos#index'"
|
11
|
+
run "rm -rf public/index.html"
|
12
|
+
|
13
|
+
inject_into_file 'app/models/photo.rb', :after => "class Photo < ActiveRecord::Base\n" do
|
14
|
+
%(
|
15
|
+
attr_accessible :image rescue nil
|
16
|
+
dragonfly_accessor :image
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
gsub_file 'app/views/photos/_form.html.erb', /^.*:image_.*$/, ''
|
21
|
+
|
22
|
+
inject_into_file 'app/views/photos/_form.html.erb', :before => %(<div class="actions">\n) do
|
23
|
+
%(
|
24
|
+
<div class="field">
|
25
|
+
<%= f.label :image %><br>
|
26
|
+
<%= f.file_field :image %>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<%= image_tag @photo.image.thumb('100x100').url if @photo.image_uid %>
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
gsub_file "app/controllers/photos_controller.rb", "permit(", "permit(:image, "
|
34
|
+
|
35
|
+
append_file 'app/views/photos/show.html.erb', %(
|
36
|
+
<%= image_tag @photo.image.thumb('300x300').url if @photo.image_uid? %>
|
37
|
+
)
|
38
|
+
|
data/dev/test.ru
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "bundler/setup"
|
3
|
+
$:.unshift(File.expand_path('../../lib', __FILE__))
|
4
|
+
require 'dragonfly'
|
5
|
+
|
6
|
+
Dragonfly.logger = Logger.new(STDOUT)
|
7
|
+
Dragonfly.app.configure do
|
8
|
+
plugin :imagemagick
|
9
|
+
url_format '/images/:job'
|
10
|
+
fetch_file_whitelist [String]
|
11
|
+
end
|
12
|
+
|
13
|
+
class App
|
14
|
+
def call(env)
|
15
|
+
image = Dragonfly.app.fetch_file('grid.jpg')
|
16
|
+
request = Rack::Request.new(env)
|
17
|
+
error = nil
|
18
|
+
if request['code']
|
19
|
+
begin
|
20
|
+
img_src = eval("image.#{request['code']}").url
|
21
|
+
rescue StandardError => e
|
22
|
+
error = e
|
23
|
+
end
|
24
|
+
end
|
25
|
+
[
|
26
|
+
200,
|
27
|
+
{'Content-Type' => 'text/html'},
|
28
|
+
[%(
|
29
|
+
<style>
|
30
|
+
form, input {
|
31
|
+
font-size: 32px;
|
32
|
+
}
|
33
|
+
p.error {
|
34
|
+
color: red;
|
35
|
+
font-size: 24px;
|
36
|
+
}
|
37
|
+
</style>
|
38
|
+
<p class="error">#{error}</p>
|
39
|
+
<table>
|
40
|
+
<tr>
|
41
|
+
<th>Original (#{image.width}x#{image.height})</th>
|
42
|
+
<td><img src="#{image.url}" /></td>
|
43
|
+
</tr>
|
44
|
+
<tr>
|
45
|
+
<th><form>image.<input size="40" autofocus placeholder="thumb('200x100')" name="code" value="#{request['code']}" /></form></th>
|
46
|
+
<td><img src="#{img_src}" /></td>
|
47
|
+
</tr>
|
48
|
+
</table>
|
49
|
+
)]
|
50
|
+
]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
use Dragonfly::Middleware
|
55
|
+
run App.new
|
56
|
+
|
data/dev/test_rails
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!env ruby
|
2
|
+
dir = ARGV[0]
|
3
|
+
|
4
|
+
unless dir
|
5
|
+
puts "Usage:"
|
6
|
+
puts "\t#{$0} DESTINATION"
|
7
|
+
exit
|
8
|
+
end
|
9
|
+
|
10
|
+
run = proc{|command|
|
11
|
+
puts "\n*** Running: #{command} ***\n"
|
12
|
+
system command
|
13
|
+
}
|
14
|
+
|
15
|
+
template_path = File.expand_path('../rails_template.rb', __FILE__)
|
16
|
+
|
17
|
+
run["rm -rf #{dir}"]
|
18
|
+
run["rails new #{dir} -m #{template_path} -J -T"]
|
19
|
+
|
data/dragonfly.gemspec
CHANGED
@@ -24,28 +24,10 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_runtime_dependency("rack", [">= 0"])
|
25
25
|
spec.add_runtime_dependency("multi_json", ["~> 1.0"])
|
26
26
|
|
27
|
-
spec.add_development_dependency("
|
28
|
-
spec.add_development_dependency("cucumber", ["~> 1.2.1"])
|
29
|
-
spec.add_development_dependency("cucumber-rails", ["~> 1.3.0"])
|
30
|
-
spec.add_development_dependency("database_cleaner", [">= 0"])
|
31
|
-
spec.add_development_dependency("fog", [">= 0"])
|
32
|
-
spec.add_development_dependency("github-markup", [">= 0"])
|
33
|
-
spec.add_development_dependency("mongo", [">= 0"])
|
34
|
-
spec.add_development_dependency("couchrest", ["~> 1.0"])
|
35
|
-
spec.add_development_dependency("rack-cache", [">= 0"])
|
36
|
-
spec.add_development_dependency("rails", ["~> 3.2.0"])
|
27
|
+
spec.add_development_dependency("activemodel")
|
37
28
|
spec.add_development_dependency("rspec", ["~> 2.5"])
|
38
|
-
spec.add_development_dependency("webmock"
|
39
|
-
spec.add_development_dependency("yard", [">= 0"])
|
29
|
+
spec.add_development_dependency("webmock")
|
40
30
|
if RUBY_PLATFORM == "java"
|
41
|
-
spec.add_development_dependency("
|
42
|
-
spec.add_development_dependency("activerecord-jdbcsqlite3-adapter", [">= 0"])
|
43
|
-
spec.add_development_dependency("jruby-openssl", [">= 0"])
|
44
|
-
else
|
45
|
-
spec.add_development_dependency("redcarpet", ["~> 1.0"])
|
46
|
-
spec.add_development_dependency("bluecloth", [">= 0"])
|
47
|
-
spec.add_development_dependency("bson_ext", [">= 0"])
|
48
|
-
spec.add_development_dependency("sqlite3", [">= 0"])
|
31
|
+
spec.add_development_dependency("jruby-openssl")
|
49
32
|
end
|
50
|
-
|
51
33
|
end
|