dynamic_image 2.0.0.beta2 → 2.0.0.beta3
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.
- checksums.yaml +4 -4
- data/lib/dynamic_image/controller.rb +11 -6
- data/lib/dynamic_image/templates/show.html.erb +140 -0
- data/lib/dynamic_image/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fda7766cb4f27ea3a545fedc1511506ce251416
|
4
|
+
data.tar.gz: dcf8f6fc77d44368aed414bfc070659524f008e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5357d8a288398957c9788935d2857e65b948d114b41aaebbe0113578b3ceeb6dd5e96828ac3faf82068461f8c775cb92a5c8a63f85dcec8d195f1e13dda68b89
|
7
|
+
data.tar.gz: 35477212f286f9a4ba39b5dbc6cc6b8e056fbd691c8a69541db3016d8f99ad93b24cd604bdeaf13fd0ed3bab2e81da25a55af5f0c06f6e0f4f63a9c0cf229cf1
|
@@ -14,7 +14,8 @@ module DynamicImage
|
|
14
14
|
before_action :verify_signed_params
|
15
15
|
before_action :find_record
|
16
16
|
after_action :cache_expiration_header
|
17
|
-
respond_to :gif, :jpeg, :png, :tiff
|
17
|
+
respond_to :html, :gif, :jpeg, :png, :tiff
|
18
|
+
helper_method :requested_size
|
18
19
|
end
|
19
20
|
|
20
21
|
# Renders the image.
|
@@ -42,6 +43,10 @@ module DynamicImage
|
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
46
|
+
def requested_size
|
47
|
+
Vector2d.parse(params[:size])
|
48
|
+
end
|
49
|
+
|
45
50
|
private
|
46
51
|
|
47
52
|
def cache_expiration_header
|
@@ -56,6 +61,10 @@ module DynamicImage
|
|
56
61
|
processed_image = DynamicImage::ProcessedImage.new(@record, options)
|
57
62
|
if stale?(@record)
|
58
63
|
respond_with(@record) do |format|
|
64
|
+
format.html do
|
65
|
+
render(file: File.join(File.dirname(__FILE__), 'templates/show'),
|
66
|
+
layout: false, locals: {options: options})
|
67
|
+
end
|
59
68
|
format.any(:gif, :jpeg, :png, :tiff) do
|
60
69
|
send_data(
|
61
70
|
processed_image.cropped_and_resized(requested_size),
|
@@ -71,10 +80,6 @@ module DynamicImage
|
|
71
80
|
params[:format]
|
72
81
|
end
|
73
82
|
|
74
|
-
def requested_size
|
75
|
-
Vector2d.parse(params[:size])
|
76
|
-
end
|
77
|
-
|
78
83
|
def signed_params
|
79
84
|
case request[:action]
|
80
85
|
when "show", "uncropped"
|
@@ -91,4 +96,4 @@ module DynamicImage
|
|
91
96
|
DynamicImage.digest_verifier.verify(key, params[:digest])
|
92
97
|
end
|
93
98
|
end
|
94
|
-
end
|
99
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>
|
5
|
+
<%= @record.filename %>
|
6
|
+
</title>
|
7
|
+
<style type="text/css">
|
8
|
+
body {
|
9
|
+
background: #fff;
|
10
|
+
color: #1a1a1a;
|
11
|
+
border: 0px;
|
12
|
+
margin: 0px;
|
13
|
+
padding: 30px;
|
14
|
+
font-family: Helvetica, Arial, sans-serif;
|
15
|
+
font-size: 15px;
|
16
|
+
}
|
17
|
+
h1 {
|
18
|
+
font-size: 36px;
|
19
|
+
}
|
20
|
+
.buttons {
|
21
|
+
margin-bottom: 20px;
|
22
|
+
}
|
23
|
+
.buttons a,
|
24
|
+
.buttons a:visited {
|
25
|
+
text-decoration: none;
|
26
|
+
display: inline-block;
|
27
|
+
color: #fff;
|
28
|
+
background: #333;
|
29
|
+
line-height: 28px;
|
30
|
+
padding: 0px 8px;
|
31
|
+
}
|
32
|
+
.buttons a:hover,
|
33
|
+
.buttons a:focus {
|
34
|
+
background: #111;
|
35
|
+
}
|
36
|
+
table {
|
37
|
+
border-collapse: collapse;
|
38
|
+
}
|
39
|
+
th, td {
|
40
|
+
text-align: left;
|
41
|
+
border: 1px solid #ccc;
|
42
|
+
padding: 4px 20px 4px 4px;
|
43
|
+
}
|
44
|
+
figure {
|
45
|
+
margin: 0px;
|
46
|
+
padding: 0px;
|
47
|
+
margin-bottom: 20px;
|
48
|
+
img {
|
49
|
+
max-width: 100%;
|
50
|
+
height: auto;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
</style>
|
54
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
55
|
+
</head>
|
56
|
+
<body>
|
57
|
+
<h1>
|
58
|
+
<%= @record.filename %>
|
59
|
+
(<%= requested_size.to_i_vector.to_s %>)
|
60
|
+
</h1>
|
61
|
+
<figure class="image">
|
62
|
+
<% if options[:cropped] %>
|
63
|
+
<%= uncropped_dynamic_image_tag(@record, size: requested_size) %>
|
64
|
+
<% else %>
|
65
|
+
<%= dynamic_image_tag(@record, size: requested_size, crop: true) %>
|
66
|
+
<% end %>
|
67
|
+
</figure>
|
68
|
+
|
69
|
+
<div class="buttons">
|
70
|
+
<%= link_to("#{requested_size.to_i_vector}",
|
71
|
+
dynamic_image_path(@record,
|
72
|
+
size: requested_size,
|
73
|
+
crop: true)) %>
|
74
|
+
<%= link_to("#{requested_size.to_i_vector} (uncropped)",
|
75
|
+
uncropped_dynamic_image_path(@record,
|
76
|
+
size: requested_size,
|
77
|
+
crop: true)) %>
|
78
|
+
<%= link_to "Original", original_dynamic_image_path(@record, format: 'html') %>
|
79
|
+
</div>
|
80
|
+
|
81
|
+
<table class="metadata">
|
82
|
+
<tr>
|
83
|
+
<th>
|
84
|
+
Content-Type
|
85
|
+
</th>
|
86
|
+
<td>
|
87
|
+
<%= @record.content_type %>
|
88
|
+
</td>
|
89
|
+
</tr>
|
90
|
+
<tr>
|
91
|
+
<th>
|
92
|
+
Colorspace
|
93
|
+
</th>
|
94
|
+
<td>
|
95
|
+
<%= @record.colorspace %>
|
96
|
+
</td>
|
97
|
+
</tr>
|
98
|
+
<tr>
|
99
|
+
<th>
|
100
|
+
Original Filesize
|
101
|
+
</th>
|
102
|
+
<td>
|
103
|
+
<%= number_to_human_size(@record.content_length) %>
|
104
|
+
</td>
|
105
|
+
</tr>
|
106
|
+
<tr>
|
107
|
+
<th>
|
108
|
+
Cropped size
|
109
|
+
</th>
|
110
|
+
<td>
|
111
|
+
<%= @record.size.to_s %>
|
112
|
+
</td>
|
113
|
+
</tr>
|
114
|
+
<tr>
|
115
|
+
<th>
|
116
|
+
Original size
|
117
|
+
</th>
|
118
|
+
<td>
|
119
|
+
<%= @record.real_size.to_s %>
|
120
|
+
</td>
|
121
|
+
</tr>
|
122
|
+
<tr>
|
123
|
+
<th>
|
124
|
+
Created at
|
125
|
+
</th>
|
126
|
+
<td>
|
127
|
+
<%= @record.created_at %>
|
128
|
+
</td>
|
129
|
+
</tr>
|
130
|
+
<tr>
|
131
|
+
<th>
|
132
|
+
Updated at
|
133
|
+
</th>
|
134
|
+
<td>
|
135
|
+
<%= @record.updated_at %>
|
136
|
+
</td>
|
137
|
+
</tr>
|
138
|
+
</table>
|
139
|
+
</body>
|
140
|
+
</html>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_image
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Inge Jørgensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -124,6 +124,7 @@ files:
|
|
124
124
|
- lib/dynamic_image/processed_image.rb
|
125
125
|
- lib/dynamic_image/railtie.rb
|
126
126
|
- lib/dynamic_image/routing.rb
|
127
|
+
- lib/dynamic_image/templates/show.html.erb
|
127
128
|
- lib/dynamic_image/version.rb
|
128
129
|
- lib/rails/generators/dynamic_image/resource/resource_generator.rb
|
129
130
|
homepage: https://github.com/elektronaut/dynamic_image
|