editables 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  source "http://rubygems.org"
2
+
2
3
  # Add dependencies required to use your gem here.
3
4
  # Example:
4
5
  # gem "activesupport", ">= 2.3.5"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.1.0
@@ -16,6 +16,7 @@ module Editables
16
16
  else
17
17
  @image = Editables::EditableImage.create(params[:editable_image])
18
18
  end
19
+ @image.image.reprocess!
19
20
  redirect_to :back
20
21
  end
21
22
  end
@@ -66,7 +66,9 @@ module Editables
66
66
  form_id = "editable-image-#{name.gsub(" ","-")}"
67
67
  image = Editables::EditableImage.find_by_name(name)
68
68
  if image.present?
69
- if width >= 1200
69
+ if image.image(:cropped).present? && (open(image.image(:cropped)) rescue false)
70
+ src = image.image(:cropped)
71
+ elsif width >= 1200
70
72
  src = image.image(:original)
71
73
  elsif width < 1200 && width >= 600
72
74
  src = image.image(:large)
@@ -85,6 +87,8 @@ module Editables
85
87
  "<form action='/editables/image' method='post' enctype='multipart/form-data' id='#{form_id}' style='display:none' >",
86
88
  "<input type='file' name='editable_image[image]' onchange='$(\"##{form_id}\").submit()' style='border:none;padding0' />",
87
89
  "<input type='hidden' name='editable_image[name]' value='#{name}'/>",
90
+ "<input type='hidden' name='editable_image[width]' value='#{width}'/>",
91
+ "<input type='hidden' name='editable_image[height]' value='#{height}'/>",
88
92
  "<input type='hidden' name='authenticity_token' value='#{form_authenticity_token}'/>",
89
93
  "</form>"
90
94
  ].join(" ")
@@ -1,15 +1,17 @@
1
1
  module Editables
2
2
  class EditableImage < ActiveRecord::Base
3
- set_table_name "editable_images"
3
+ set_table_name "editable_images"
4
+ attr_accessor :width, :height
4
5
 
5
6
  if FileTest.exists?(Rails.root.join('config', 's3.yml'))
6
7
  config = YAML.load(File.read('config/s3.yml'))[Rails.env]
7
- has_attached_file :image,
8
- :styles => {
8
+ has_attached_file :image,
9
+ :styles => lambda { |a| {
9
10
  :large => "1200x1200>",
10
11
  :medium => "600X600>",
11
- :small => "300X300>"
12
- },
12
+ :small => "300X300>",
13
+ :cropped => "#{a.instance.width}x#{a.instance.height}#"
14
+ }},
13
15
  :storage => :s3,
14
16
  :s3_credentials => "#{Rails.root}/config/s3.yml",
15
17
  :s3_host_alias => config["s3_host_alias"],
@@ -17,11 +19,12 @@ module Editables
17
19
  :path => "/paperclip/:class/:id/:style/:filename"
18
20
  else
19
21
  has_attached_file :image,
20
- :styles => {
21
- :large => "1200x1200>",
22
- :medium => "600X600>",
23
- :small => "300X300>"
24
- },
22
+ :styles => lambda { |a| {
23
+ :large => "1200x1200>",
24
+ :medium => "600X600>",
25
+ :small => "300X300>",
26
+ :cropped => "#{a.instance.width}x#{a.instance.height}#"
27
+ }},
25
28
  :path => ":rails_root/public/editable_images/:id/:style/:basename.:extension",
26
29
  :url => "/editable_images/:id/:style/:filename"
27
30
  end
data/editables.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "editables"
8
- s.version = "0.0.7"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Gabe Coyne"]
12
- s.date = "2013-05-21"
12
+ s.date = "2013-06-19"
13
13
  s.description = "Easy wysiwyg editing of website content and images"
14
14
  s.email = "gabe@killitcreative.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: editables
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
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-05-21 00:00:00.000000000 Z
12
+ date: 2013-06-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
@@ -143,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
143
143
  version: '0'
144
144
  segments:
145
145
  - 0
146
- hash: 2958318681057866174
146
+ hash: -1362831002386609110
147
147
  required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  none: false
149
149
  requirements: