crimagify 0.0.2
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.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +56 -0
- data/Rakefile +40 -0
- data/app/assets/images/crimagify/Jcrop.gif +0 -0
- data/app/assets/javascripts/crimagify/actions_cropper.js.erb +174 -0
- data/app/assets/javascripts/crimagify/application.js +15 -0
- data/app/assets/javascripts/crimagify/jquery.Jcrop.js +1694 -0
- data/app/assets/javascripts/crimagify/jquery.color.js +661 -0
- data/app/assets/stylesheets/crimagify/application.css +13 -0
- data/app/assets/stylesheets/crimagify/cropper.css.scss +75 -0
- data/app/assets/stylesheets/crimagify/jquery.Jcrop.css +165 -0
- data/app/assets/stylesheets/crimagify/mixin.css.scss +191 -0
- data/app/controllers/crimagify/application_controller.rb +4 -0
- data/app/controllers/crimagify/cropper_controller.rb +64 -0
- data/app/helpers/crimagify/application_helper.rb +28 -0
- data/app/models/crimagify/image.rb +27 -0
- data/app/uploaders/crimagify/image_uploader.rb +131 -0
- data/app/views/crimagify/crop_partials/_crop.html.erb +24 -0
- data/app/views/crimagify/crop_partials/_fields_cropper.html.erb +21 -0
- data/app/views/crimagify/crop_partials/_img_final.html.erb +11 -0
- data/app/views/crimagify/cropper/params_cropper.js.erb +22 -0
- data/app/views/crimagify/cropper/partial_cropper.js.erb +8 -0
- data/app/views/layouts/crimagify/application.html.erb +14 -0
- data/config/initializers/load_variables.rb +5 -0
- data/config/routes.rb +4 -0
- data/db/migrate/20130422223133_create_crimagify_images.rb +13 -0
- data/db/seeds.rb +6 -0
- data/lib/crimagify/dinamic_image_methods.rb +49 -0
- data/lib/crimagify/engine.rb +26 -0
- data/lib/crimagify/image_functions.rb +104 -0
- data/lib/crimagify/version.rb +3 -0
- data/lib/crimagify.rb +6 -0
- data/lib/generators/crimagify/generate_views/generate_views_generator.rb +13 -0
- data/lib/generators/crimagify/install/install_generator.rb +17 -0
- data/lib/generators/crimagify/install/templates/crimagify_settings.yml +4 -0
- data/lib/generators/crimagify/install/templates/crimagify_versions.yml +52 -0
- data/lib/tasks/crimagify_tasks.rake +4 -0
- data/test/crimagify_test.rb +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/images/rails.png +0 -0
- data/test/dummy/app/assets/images/tmps_cropper/Product/image_temporal/0/imgA/2013-04-24-Product-imgA-0.jpeg +0 -0
- data/test/dummy/app/assets/images/tmps_cropper/Product/image_temporal/7/imgA/2013-04-24-Product-imgA-7.jpeg +0 -0
- data/test/dummy/app/assets/images/tmps_cropper/Product/image_temporal/7/imgA/2013-04-24-Product-imgA-7.png +0 -0
- data/test/dummy/app/assets/images/tmps_cropper/Product/image_temporal/7/imgA/2013-04-25-Product-imgA-7.jpeg +0 -0
- data/test/dummy/app/assets/images/tmps_cropper/Product/image_temporal/7/imgB/2013-04-25-Product-imgB-7.jpeg +0 -0
- data/test/dummy/app/assets/images/tmps_cropper/Product/image_temporal/7/imgC/2013-04-25-Product-imgC-7.jpeg +0 -0
- data/test/dummy/app/assets/images/tmps_cropper/User/image_temporal/0/imgA/2013-04-24-User-imgA-0.png +0 -0
- data/test/dummy/app/assets/images/tmps_cropper/User/image_temporal/2/imgA/2013-04-24-User-imgA-2.jpeg +0 -0
- data/test/dummy/app/assets/images/tmps_cropper/User/image_temporal/2/imgA/2013-04-24-User-imgA-2.png +0 -0
- data/test/dummy/app/assets/images/tmps_cropper/User/image_temporal/2/imgB/2013-04-24-User-imgB-2.png +0 -0
- data/test/dummy/app/assets/images/tmps_cropper/User/image_temporal/3/imgA/2013-04-24-User-imgA-3.jpeg +0 -0
- data/test/dummy/app/assets/images/tmps_cropper/User/image_temporal/3/imgA/2013-04-24-User-imgA-3.png +0 -0
- data/test/dummy/app/assets/images/tmps_cropper/User/image_temporal/3/imgB/2013-04-24-User-imgB-3.jpeg +0 -0
- data/test/dummy/app/assets/javascripts/application.js +16 -0
- data/test/dummy/app/assets/javascripts/products.js +2 -0
- data/test/dummy/app/assets/javascripts/users.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +14 -0
- data/test/dummy/app/assets/stylesheets/products.css.scss +3 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/assets/stylesheets/scaffolds.css.scss +69 -0
- data/test/dummy/app/assets/stylesheets/users.css +4 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/products_controller.rb +85 -0
- data/test/dummy/app/controllers/users_controller.rb +87 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/products_helper.rb +2 -0
- data/test/dummy/app/helpers/users_helper.rb +2 -0
- data/test/dummy/app/models/product.rb +10 -0
- data/test/dummy/app/models/user.rb +12 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/products/_form.html.erb +32 -0
- data/test/dummy/app/views/products/edit.html.erb +6 -0
- data/test/dummy/app/views/products/index.html.erb +25 -0
- data/test/dummy/app/views/products/new.html.erb +5 -0
- data/test/dummy/app/views/products/show.html.erb +15 -0
- data/test/dummy/app/views/users/_form.html.erb +34 -0
- data/test/dummy/app/views/users/edit.html.erb +6 -0
- data/test/dummy/app/views/users/index.html.erb +28 -0
- data/test/dummy/app/views/users/new.html.erb +5 -0
- data/test/dummy/app/views/users/show.html.erb +20 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/crimagify_settings.yml +4 -0
- data/test/dummy/config/crimagify_versions.yml +80 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +11 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20130423160421_create_crimagify_images.crimagify.rb +14 -0
- data/test/dummy/db/migrate/20130423164431_create_users.rb +11 -0
- data/test/dummy/db/migrate/20130424155649_create_products.rb +10 -0
- data/test/dummy/db/schema.rb +43 -0
- data/test/dummy/log/development.log +22235 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/2/2013-04-24-User-imgA-2.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/2/big_2013-04-24-User-imgA-2.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/2/gigant_2013-04-24-User-imgA-2.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/2/user_2013-04-24-User-imgA-2.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/3/2013-04-24-User-imgB-2.png +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/3/big_2013-04-24-User-imgB-2.png +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/3/gigant_2013-04-24-User-imgB-2.png +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/3/user_2013-04-24-User-imgB-2.png +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/4/2013-04-24-User-imgA-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/4/big_2013-04-24-User-imgA-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/4/gigant_2013-04-24-User-imgA-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/4/user_2013-04-24-User-imgA-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/5/2013-04-24-User-imgB-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/5/big_2013-04-24-User-imgB-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/5/gigant_2013-04-24-User-imgB-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/5/user_2013-04-24-User-imgB-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/6/2013-04-24-Product-imgA-0.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/6/big_2013-04-24-Product-imgA-0.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/6/gigant_2013-04-24-Product-imgA-0.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/6/user_2013-04-24-Product-imgA-0.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/7/2013-04-24-Product-imgA-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/7/big_2013-04-24-Product-imgA-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/7/gigant_2013-04-24-Product-imgA-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image/7/user_2013-04-24-Product-imgA-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/1/2013-04-24-Product-imgA-0.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/1/big_2013-04-24-Product-imgA-0.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/1/gigant_2013-04-24-Product-imgA-0.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/1/user_2013-04-24-Product-imgA-0.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/2/2013-04-24-User-imgA-2.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/2/big_2013-04-24-User-imgA-2.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/2/gigant_2013-04-24-User-imgA-2.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/2/user_2013-04-24-User-imgA-2.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/3/2013-04-24-User-imgB-2.png +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/3/big_2013-04-24-User-imgB-2.png +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/3/gigant_2013-04-24-User-imgB-2.png +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/3/user_2013-04-24-User-imgB-2.png +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/4/2013-04-24-User-imgA-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/4/big_2013-04-24-User-imgA-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/4/gigant_2013-04-24-User-imgA-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/4/user_2013-04-24-User-imgA-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/5/2013-04-24-User-imgB-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/5/big_2013-04-24-User-imgB-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/5/gigant_2013-04-24-User-imgB-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/5/user_2013-04-24-User-imgB-3.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/7/2013-04-25-Product-imgA-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/7/big_2013-04-25-Product-imgA-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/7/gigant_2013-04-25-Product-imgA-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/7/user_2013-04-25-Product-imgA-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/8/2013-04-25-Product-imgB-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/8/big_2013-04-25-Product-imgB-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/8/gigant_2013-04-25-Product-imgB-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/8/user_2013-04-25-Product-imgB-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/9/2013-04-25-Product-imgC-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/9/big_2013-04-25-Product-imgC-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/9/gigant_2013-04-25-Product-imgC-7.jpeg +0 -0
- data/test/dummy/public/uploads/crimagify/image/image_temporal/9/user_2013-04-25-Product-imgC-7.jpeg +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/fixtures/products.yml +9 -0
- data/test/dummy/test/fixtures/users.yml +11 -0
- data/test/dummy/test/functional/products_controller_test.rb +49 -0
- data/test/dummy/test/functional/users_controller_test.rb +49 -0
- data/test/dummy/test/unit/helpers/products_helper_test.rb +4 -0
- data/test/dummy/test/unit/helpers/users_helper_test.rb +4 -0
- data/test/dummy/test/unit/product_test.rb +7 -0
- data/test/dummy/test/unit/user_test.rb +7 -0
- data/test/dummy/tmp/cache/assets/C23/400/sprockets%2F31710301f0d68b89727f5de964446610 +0 -0
- data/test/dummy/tmp/cache/assets/CB2/7F0/sprockets%2F9d79a842f086f17d3420e5cb88710c10 +0 -0
- data/test/dummy/tmp/cache/assets/CD7/6F0/sprockets%2Fbd3936370d0f952ada5774e2230046ed +0 -0
- data/test/dummy/tmp/cache/assets/CF0/DA0/sprockets%2Fd7d5b37686831d37c4dd75e645f5e016 +0 -0
- data/test/dummy/tmp/cache/assets/D15/750/sprockets%2F4cc25a6e69224dc83fed65a4242479c5 +0 -0
- data/test/dummy/tmp/cache/assets/D9C/4A0/sprockets%2Fc15750bf0161f2878cf9da9bb1a84ecb +0 -0
- data/test/dummy/tmp/cache/assets/E19/2A0/sprockets%2F10fcfbe6ebae11a40c8eac41939a1b9a +0 -0
- data/test/dummy/tmp/cache/assets/E25/4C0/sprockets%2Fde2fd9fd11c04a582cdbbe3d84a35ae6 +0 -0
- data/test/dummy/tmp/cache/sass/505fb9771aab716ad3a4fa9aa21be52c17294224/products.css.scssc +0 -0
- data/test/dummy/tmp/cache/sass/505fb9771aab716ad3a4fa9aa21be52c17294224/scaffolds.css.scssc +0 -0
- data/test/fixtures/crimagify/images.yml +13 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- data/test/unit/crimagify/image_test.rb +9 -0
- metadata +464 -0
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2013 YOURNAME
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
= Crimagify
|
|
2
|
+
|
|
3
|
+
Manage your model images with RMagick and CarrierWave.
|
|
4
|
+
|
|
5
|
+
== Installation
|
|
6
|
+
1. Add to your Gemfile: <tt>gem 'crimagify'</tt>
|
|
7
|
+
2. Run <tt>Bundle</tt>
|
|
8
|
+
3. Execute: <tt>rails generate crimagify:install</tt>
|
|
9
|
+
4. Run migrations: <tt>rake db:migrate</tt>
|
|
10
|
+
5. Run seeds: <tt>rake db:seed</tt>
|
|
11
|
+
----
|
|
12
|
+
|
|
13
|
+
== Implementation
|
|
14
|
+
Add to your routes.rb: <tt>mount Crimagify::Engine => "/crimagify", :as => "crimagify"</tt>
|
|
15
|
+
|
|
16
|
+
Add to your model:
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
...
|
|
20
|
+
extend Crimagify::DinamicImageMethods
|
|
21
|
+
has_many :crimagify_images, :as => :parent, :dependent => :destroy, :class_name => Crimagify::Image
|
|
22
|
+
build_methods_images
|
|
23
|
+
...
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
Add to your controller:
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
...
|
|
30
|
+
#For Action Create:
|
|
31
|
+
if @object.save
|
|
32
|
+
Crimagify::ImageFunctions::create_new_images(@object, params)
|
|
33
|
+
end
|
|
34
|
+
...
|
|
35
|
+
|
|
36
|
+
...
|
|
37
|
+
#For Action Update:
|
|
38
|
+
id @object.update_attributes(params[:object])
|
|
39
|
+
Crimagify::ImageFunctions::update_images(@object, params)
|
|
40
|
+
end
|
|
41
|
+
...
|
|
42
|
+
|
|
43
|
+
Add to application.js:<tt>//= require crimagify/application</tt>
|
|
44
|
+
|
|
45
|
+
Add to application.css:<tt>*= require crimagify/application</tt>
|
|
46
|
+
|
|
47
|
+
Add to your form view:
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
<%= form_for(@object) do |f| %>
|
|
51
|
+
...
|
|
52
|
+
<%= images_id(@object) %>
|
|
53
|
+
<%= image_cropper(@object, { image_name: "imgA", ratio: :big}) %>
|
|
54
|
+
<%= image_cropper(@object, { image_name: "imgB", ratio: :small}) %>
|
|
55
|
+
...
|
|
56
|
+
<% end %>
|
data/Rakefile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env rake
|
|
2
|
+
begin
|
|
3
|
+
require 'bundler/setup'
|
|
4
|
+
rescue LoadError
|
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
6
|
+
end
|
|
7
|
+
begin
|
|
8
|
+
require 'rdoc/task'
|
|
9
|
+
rescue LoadError
|
|
10
|
+
require 'rdoc/rdoc'
|
|
11
|
+
require 'rake/rdoctask'
|
|
12
|
+
RDoc::Task = Rake::RDocTask
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
17
|
+
rdoc.title = 'Crimagify'
|
|
18
|
+
rdoc.options << '--line-numbers'
|
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
|
24
|
+
load 'rails/tasks/engine.rake'
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
Bundler::GemHelper.install_tasks
|
|
29
|
+
|
|
30
|
+
require 'rake/testtask'
|
|
31
|
+
|
|
32
|
+
Rake::TestTask.new(:test) do |t|
|
|
33
|
+
t.libs << 'lib'
|
|
34
|
+
t.libs << 'test'
|
|
35
|
+
t.pattern = 'test/**/*_test.rb'
|
|
36
|
+
t.verbose = false
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
task :default => :test
|
|
Binary file
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
//section for read ENV variables
|
|
2
|
+
<%
|
|
3
|
+
array_json = CRIMAGIFY_ENV.to_json
|
|
4
|
+
%>
|
|
5
|
+
|
|
6
|
+
var ajstring = '<%= array_json %>'
|
|
7
|
+
var ajson = JSON.parse(ajstring);
|
|
8
|
+
//========================================================================================
|
|
9
|
+
var render_image = "";
|
|
10
|
+
var array_names = [];
|
|
11
|
+
|
|
12
|
+
$(function(){
|
|
13
|
+
|
|
14
|
+
$(".uploader").on("change", function(evt){
|
|
15
|
+
//this variable is used for identify on what section pu the resultant image
|
|
16
|
+
var id = $(this).parents('div.global_parent').attr("id");
|
|
17
|
+
var name_version = $(this).parents('div.global_parent').attr("name");
|
|
18
|
+
|
|
19
|
+
if (validate_image(evt) == true) {
|
|
20
|
+
var files = evt.target.files;
|
|
21
|
+
var reader = new FileReader();
|
|
22
|
+
|
|
23
|
+
reader.onloadend = function(e){
|
|
24
|
+
render_image_temporal(e.target.result, id, name_version);
|
|
25
|
+
render_image = e.target.result;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
reader.readAsDataURL(files[0]);
|
|
29
|
+
|
|
30
|
+
}else{
|
|
31
|
+
$(this).val('');
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
$(".parent_image").on("click", ".crop_image", function(){
|
|
36
|
+
//parent_element_id is filled with the value of DIV parent closest: "imgA","imgB","imgZ"
|
|
37
|
+
var parent_element_id = $(this).parents('div.global_parent').attr("id");
|
|
38
|
+
parameters(parent_element_id);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
function validate_image(evt){
|
|
43
|
+
var size = evt.target.files[0].size/1024;
|
|
44
|
+
var type = evt.target.files[0].type;
|
|
45
|
+
var max_size = '<%= ENV["MAX_SIZE"] %>'
|
|
46
|
+
if (max_size != "") {
|
|
47
|
+
max_size = max_size*1024
|
|
48
|
+
} else{
|
|
49
|
+
max_size = 2048;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
if (type == "image/jpeg" || type == "image/png") {
|
|
53
|
+
if (size <= max_size) {
|
|
54
|
+
return true;
|
|
55
|
+
} else{
|
|
56
|
+
alert("Please select an image more than small ");
|
|
57
|
+
return false;
|
|
58
|
+
};
|
|
59
|
+
} else{
|
|
60
|
+
alert("Please select an image file");
|
|
61
|
+
return false;
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
function render_image_temporal(url, parent_tag_id, name_version){
|
|
66
|
+
$.ajax({
|
|
67
|
+
url: "/crimagify/partial_cropper",
|
|
68
|
+
type: "POST",
|
|
69
|
+
data: { "image": url, "parent_element_id" : parent_tag_id },
|
|
70
|
+
dataType: "script",
|
|
71
|
+
complete: function(event){
|
|
72
|
+
load_partial(parent_tag_id, name_version);
|
|
73
|
+
},
|
|
74
|
+
error: function(x,y,z){
|
|
75
|
+
console.log(x);
|
|
76
|
+
console.log(y);
|
|
77
|
+
console.log(z);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
function update_crop(coords){
|
|
83
|
+
$("#crop_x").val(coords.x);
|
|
84
|
+
$("#crop_y").val(coords.y);
|
|
85
|
+
$("#crop_w").val(coords.w);
|
|
86
|
+
$("#crop_h").val(coords.h);
|
|
87
|
+
// updatePreview(coords);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
function updatePreview(coords){
|
|
91
|
+
$('#preview').css({
|
|
92
|
+
width: Math.round(100/coords.w * $('#cropbox').width()) + 'px',
|
|
93
|
+
height: Math.round(100/coords.h * $('#cropbox').height()) + 'px',
|
|
94
|
+
marginLeft: '-' + Math.round(100/coords.w * coords.x) + 'px',
|
|
95
|
+
marginTop: '-' + Math.round(100/coords.h * coords.y) + 'px'
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
function load_partial(parent_tag_id, name_version){
|
|
100
|
+
var select = [];
|
|
101
|
+
var ratio;
|
|
102
|
+
var parent = $("#parent").val();
|
|
103
|
+
var ratio_vals = ajson[parent][parent_tag_id][name_version]
|
|
104
|
+
var max_width_box = '<%= ENV["MAX_WIDTH_BOX_CROPPER"] %>'
|
|
105
|
+
var max_height_box = '<%= ENV["MAX_HEIGHT_BOX_CROPPER"] %>'
|
|
106
|
+
|
|
107
|
+
if (max_width_box == "") {
|
|
108
|
+
max_width_box = 500;
|
|
109
|
+
};
|
|
110
|
+
if (max_height_box == "") {
|
|
111
|
+
max_height_box = 500;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
select = [0,0,ratio_vals['width'],ratio_vals['height']]
|
|
115
|
+
ratio = ratio_vals['width']/ratio_vals['height']
|
|
116
|
+
|
|
117
|
+
if ($("#cropbox").length) {
|
|
118
|
+
$('#cropbox').Jcrop({
|
|
119
|
+
onChange: update_crop,
|
|
120
|
+
onSelect: update_crop,
|
|
121
|
+
setSelect: select,
|
|
122
|
+
aspectRatio: ratio,
|
|
123
|
+
boxWidth: max_width_box,
|
|
124
|
+
boxHeight: max_height_box
|
|
125
|
+
}, function(){
|
|
126
|
+
var api = this;
|
|
127
|
+
api.ui.holder.addClass('jcrop-dark');
|
|
128
|
+
api.setOptions({ bgColor: 'black', bgOpacity: 0.5});
|
|
129
|
+
});
|
|
130
|
+
$(".cancel_crop").on("click",function(e){
|
|
131
|
+
$("#cropper_div").hide("slow", function(){
|
|
132
|
+
$("#cropper_div").remove();
|
|
133
|
+
})
|
|
134
|
+
$(".uploader").val('');
|
|
135
|
+
});
|
|
136
|
+
} else{
|
|
137
|
+
alert("el elemento no se encuentra en la pagina")
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
function parameters(parent_tag_id){
|
|
142
|
+
array_names.push(parent_tag_id)
|
|
143
|
+
|
|
144
|
+
$.ajax({
|
|
145
|
+
url: "/crimagify/params_cropper",
|
|
146
|
+
type: "POST",
|
|
147
|
+
data: { "image": render_image,
|
|
148
|
+
"parent_id": $("#parent_id").val(),
|
|
149
|
+
"crop_x": $("#crop_x").val(),
|
|
150
|
+
"crop_y": $("#crop_y").val(),
|
|
151
|
+
"crop_w": $("#crop_w").val(),
|
|
152
|
+
"crop_h": $("#crop_h").val(),
|
|
153
|
+
"parent": $("#parent").val(),
|
|
154
|
+
"parent_element_id" : parent_tag_id
|
|
155
|
+
},
|
|
156
|
+
dataType: "script",
|
|
157
|
+
success: function(){
|
|
158
|
+
|
|
159
|
+
$("#"+parent_tag_id).find(".img_start").hide("slow", function(){});
|
|
160
|
+
$("#cropper_div").hide("slow", function(){
|
|
161
|
+
$("#cropper_div").remove();
|
|
162
|
+
})
|
|
163
|
+
$("#"+parent_tag_id).find("#uploader").val('');
|
|
164
|
+
},
|
|
165
|
+
error: function(a,b,c){
|
|
166
|
+
console.log("error a");
|
|
167
|
+
console.dir(a);
|
|
168
|
+
console.log("error b");
|
|
169
|
+
console.dir(b);
|
|
170
|
+
console.log("error c");
|
|
171
|
+
console.dir(c);
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// the compiled file.
|
|
9
|
+
//
|
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
|
12
|
+
//
|
|
13
|
+
//= require jquery
|
|
14
|
+
//= require jquery_ujs
|
|
15
|
+
//= require_tree .
|