dynamic_paperclip 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
@@ -19,7 +19,11 @@ module DynamicPaperclip
|
|
19
19
|
id = params[:id] || id_from_partition(params[:id_partition])
|
20
20
|
|
21
21
|
attachment = klass.find(id).send(attachment_name)
|
22
|
-
|
22
|
+
|
23
|
+
# The definition will be escaped twice in the URL, Rails will unescape it once for us,
|
24
|
+
# so it will already be escaped once, so we don't need to escape it again. We should always
|
25
|
+
# reference dynamic style names after escaping once - that's how they reside on the FS.
|
26
|
+
style_name = StyleNaming.dynamic_style_name_from_definition(params[:definition], false)
|
23
27
|
|
24
28
|
# Validate URL hash against requested style name
|
25
29
|
raise Errors::InvalidHash unless DynamicPaperclip::UrlSecurity.valid_hash?(params[:s], style_name)
|
@@ -27,7 +31,7 @@ module DynamicPaperclip
|
|
27
31
|
# Only process style if it doesn't exist,
|
28
32
|
# otherwise we may just be fielding a request for
|
29
33
|
# an existing style (i.e. serve_static_assets is true)
|
30
|
-
attachment.process_dynamic_style
|
34
|
+
attachment.process_dynamic_style style_name unless attachment.exists?(style_name)
|
31
35
|
|
32
36
|
send_file attachment.path(style_name), :disposition => 'inline', :type => attachment.content_type
|
33
37
|
end
|
@@ -22,9 +22,7 @@ module DynamicPaperclip
|
|
22
22
|
super.merge dynamic_styles
|
23
23
|
end
|
24
24
|
|
25
|
-
def process_dynamic_style(
|
26
|
-
style_name = StyleNaming.dynamic_style_name_from_definition(definition)
|
27
|
-
|
25
|
+
def process_dynamic_style(style_name)
|
28
26
|
add_dynamic_style! style_name
|
29
27
|
reprocess! style_name
|
30
28
|
end
|
@@ -32,14 +30,13 @@ module DynamicPaperclip
|
|
32
30
|
def dynamic_url(definition)
|
33
31
|
raise DynamicPaperclip::Errors::SecretNotSet, "No secret has been configured. Please run the dynamic_paperclip:install generator." unless DynamicPaperclip.config.secret.present?
|
34
32
|
|
35
|
-
|
36
|
-
unescaped_style_name = StyleNaming.dynamic_style_name_from_definition(definition, false)
|
33
|
+
style_name = StyleNaming.dynamic_style_name_from_definition(definition)
|
37
34
|
|
38
|
-
url = url(
|
35
|
+
url = url(style_name)
|
39
36
|
|
40
37
|
delimiter_char = url.match(/\?.+=/) ? '&' : '?'
|
41
38
|
|
42
|
-
"#{url}#{delimiter_char}s=#{UrlSecurity.generate_hash(
|
39
|
+
"#{url}#{delimiter_char}s=#{UrlSecurity.generate_hash(style_name)}"
|
43
40
|
end
|
44
41
|
|
45
42
|
private
|