smartthumbs 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +9 -7
- data/app/controllers/thumbs_controller.rb +12 -3
- data/lib/smartthumbs.rb +5 -0
- data/lib/smartthumbs/thumbable.rb +1 -1
- data/lib/smartthumbs/version.rb +1 -1
- metadata +3 -3
data/README.markdown
CHANGED
@@ -11,19 +11,21 @@ This Gem helps you create any kind of thumbnails on-the-fly.
|
|
11
11
|
|
12
12
|
## Install
|
13
13
|
Add the Gem to your Gemfile:
|
14
|
-
|
14
|
+
|
15
|
+
gem "smartthumbs"
|
15
16
|
|
16
17
|
and run
|
17
|
-
|
18
|
+
|
19
|
+
bundle install
|
18
20
|
|
19
21
|
|
20
22
|
Afterwards you should create an initializer-script in config/initializers:
|
21
23
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
Smartthumbs::Config.run do |config|
|
25
|
+
config[:valid_classes] = ["Image"]
|
26
|
+
|
27
|
+
config[:assume_klass] = "Image" # optional
|
28
|
+
end
|
27
29
|
|
28
30
|
Smartthumbs needs to know all classes that you want to use smartthumbs with.
|
29
31
|
Pass them as an array of strings via :valid_classes .
|
@@ -16,15 +16,24 @@ private
|
|
16
16
|
def parse_params
|
17
17
|
parsed = params[:path].split(".")[0..-2].first.split("/")
|
18
18
|
|
19
|
-
if parsed.length < 3 && Smartthumbs::Config.
|
19
|
+
if parsed.length < 3 && Smartthumbs::Config.get_option(:assume_klass).present?
|
20
20
|
parsed.unshift(
|
21
|
-
Smartthumbs::Config.
|
21
|
+
Smartthumbs::Config.get_option(:assume_klass)
|
22
22
|
)
|
23
23
|
else
|
24
24
|
parsed[0] = parsed.first.gsub("-", "/").classify
|
25
25
|
end
|
26
26
|
|
27
|
-
|
27
|
+
if Smartthumbs::Config.get_option(:valid_classes).blank?
|
28
|
+
msg = <<-INIT_DOC
|
29
|
+
Smartthumbs::Config.run do |config|
|
30
|
+
config[:valid_classes] = ["Image"]
|
31
|
+
end
|
32
|
+
INIT_DOC
|
33
|
+
raise "You need to define all valid_classes inside of an initializer script:\n\n#{msg}"
|
34
|
+
end
|
35
|
+
|
36
|
+
unless Smartthumbs::Config.get_option(:valid_classes).include?(parsed[0])
|
28
37
|
raise "Bad Request"
|
29
38
|
else
|
30
39
|
parsed[0] = parsed.first.constantize
|
data/lib/smartthumbs.rb
CHANGED
@@ -90,7 +90,7 @@ module Smartthumbs
|
|
90
90
|
# this one has to be route from which the image is
|
91
91
|
# availabe - otherwise the caching benefit is gone
|
92
92
|
def thumb_url_for(format)
|
93
|
-
if Smartthumbs::Config.
|
93
|
+
if Smartthumbs::Config.get_option(:assume_klass).to_s == self.class.to_s
|
94
94
|
"/th/#{format.to_s}/#{self.id}.#{st_extension}"
|
95
95
|
else
|
96
96
|
"/th/#{self.class.to_s.underscore.parameterize}/#{format.to_s}/#{self.id}.#{st_extension}"
|
data/lib/smartthumbs/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smartthumbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Alexander Pauly
|