radiant-assets-extension 0.0.2 → 0.0.3
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/app/controllers/admin/assets_controller.rb +1 -0
- data/app/models/asset_tags.rb +74 -16
- data/app/views/admin/assets/edit.html.erb +4 -1
- data/app/views/admin/assets/index.html.erb +20 -20
- data/db/migrate/20110225021327_add_caption.rb +9 -0
- data/lib/radiant-assets-extension/version.rb +1 -1
- data/public/stylesheets/admin/extensions/assets/assets.css +62 -0
- metadata +6 -5
data/app/models/asset_tags.rb
CHANGED
@@ -1,36 +1,94 @@
|
|
1
1
|
module AssetTags
|
2
2
|
include Radiant::Taggable
|
3
3
|
|
4
|
+
class TagError < StandardError;end
|
5
|
+
|
4
6
|
desc %{
|
5
7
|
Renders an image tag
|
6
8
|
|
7
|
-
Examples of possible values for the size attribute
|
9
|
+
Examples of possible values for the @size@ attribute
|
8
10
|
|
9
|
-
'400x300'
|
10
|
-
'400x300!'
|
11
|
-
'400x'
|
12
|
-
'x300'
|
13
|
-
'400x300>'
|
14
|
-
'400x300<'
|
15
|
-
'50x50%'
|
16
|
-
'400x300^'
|
17
|
-
'2000@'
|
18
|
-
'400x300#'
|
19
|
-
'400x300#ne'
|
20
|
-
'400x300se'
|
21
|
-
'400x300+50+100'
|
11
|
+
'400x300' resize, maintain aspect ratio
|
12
|
+
'400x300!' force resize, don't maintain aspect ratio
|
13
|
+
'400x' resize width, maintain aspect ratio
|
14
|
+
'x300' resize height, maintain aspect ratio
|
15
|
+
'400x300>' resize only if the image is larger than this
|
16
|
+
'400x300<' resize only if the image is smaller than this
|
17
|
+
'50x50%' resize width and height to 50%
|
18
|
+
'400x300^' resize width, height to minimum 400,300, maintain aspect ratio
|
19
|
+
'2000@' resize so max area in pixels is 2000
|
20
|
+
'400x300#' resize, crop if necessary to maintain aspect ratio (centre gravity)
|
21
|
+
'400x300#ne' as above, north-east gravity
|
22
|
+
'400x300se' crop, with south-east gravity
|
23
|
+
'400x300+50+100' crop from the point 50,100 with width, height 400,300
|
22
24
|
|
23
25
|
<r:image id="2" [size="400x200"] />
|
24
26
|
}
|
25
27
|
# TODO: accept width/height attributes and do something sensible like
|
26
28
|
# resizing proportionally
|
27
29
|
tag 'image' do |tag|
|
30
|
+
assert_id_given(tag)
|
31
|
+
image = find_image(tag)
|
32
|
+
%{<img src="#{image.url}" width="#{image.width}" height="#{image.height}">}
|
33
|
+
end
|
34
|
+
|
35
|
+
desc %{
|
36
|
+
Selects an asset. Does not render anything itself but gives access to the
|
37
|
+
asset's attributes such as size
|
38
|
+
|
39
|
+
Accepts optional @size@ attribute, see documentation for r:image
|
40
|
+
|
41
|
+
<r:asset id="22" [size="200"]><r:url /></r:asset>
|
42
|
+
}
|
43
|
+
tag 'asset' do |tag|
|
44
|
+
assert_id_given(tag)
|
45
|
+
tag.locals.asset = find_image(tag)
|
46
|
+
tag.expand
|
47
|
+
end
|
48
|
+
|
49
|
+
%w[url width height].each do |attribute|
|
50
|
+
desc %{
|
51
|
+
Renders the #{attribute} of the current asset
|
52
|
+
}
|
53
|
+
tag "asset:#{attribute}" do |tag|
|
54
|
+
tag.locals.asset && tag.locals.asset.send(attribute.to_sym)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
desc %{
|
59
|
+
Renders the caption of the current
|
60
|
+
}
|
61
|
+
tag 'asset:caption' do |tag|
|
62
|
+
tag.locals.asset && tag.locals.asset.caption
|
63
|
+
end
|
64
|
+
|
65
|
+
%w[landscape portrait].each do |orientation|
|
66
|
+
desc %{
|
67
|
+
Renders contents if the current image is in #{orientation} orientation
|
68
|
+
}
|
69
|
+
tag "asset:if_#{orientation}" do |tag|
|
70
|
+
tag.expand if tag.locals.asset.send "#{orientation}?".to_sym
|
71
|
+
end
|
72
|
+
|
73
|
+
desc %{
|
74
|
+
Renders contents if the current image isn't in #{orientation} orientation
|
75
|
+
}
|
76
|
+
tag "asset:unless_#{orientation}" do |tag|
|
77
|
+
tag.expand unless tag.locals.asset.send "#{orientation}?".to_sym
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
def assert_id_given(tag)
|
83
|
+
raise TagError, 'Please supply an id attribute' unless tag.attr['id']
|
84
|
+
end
|
85
|
+
|
86
|
+
def find_image(tag)
|
28
87
|
image = Image.find(tag.attr['id'])
|
29
|
-
|
88
|
+
if(tag.attr['size'])
|
30
89
|
image.upload.process(:resize, tag.attr['size'])
|
31
90
|
else
|
32
91
|
image.upload
|
33
92
|
end
|
34
|
-
%{<img src="#{job.url}" width="#{job.width}" height="#{job.height}">}
|
35
93
|
end
|
36
94
|
end
|
@@ -5,14 +5,17 @@
|
|
5
5
|
<% form_for @image, :url => admin_asset_path(@image), :html => {'data-onsubmit_status' => onsubmit_status(@image)} do |f| %>
|
6
6
|
<div class="form_area">
|
7
7
|
<p class="title">
|
8
|
-
|
8
|
+
Caption: <%= f.text_field :caption %>
|
9
9
|
</p>
|
10
10
|
<table>
|
11
11
|
<tbody>
|
12
|
+
<tr><th>Name</th><td><%= @image.upload_uid %></td></tr>
|
12
13
|
<tr><th>Width</th><td><%= @image.upload.width %></td></tr>
|
13
14
|
<tr><th>Height</th><td><%= @image.upload.height %></td></tr>
|
14
15
|
</tbody>
|
15
16
|
</table>
|
17
|
+
<!-- FIXME: doesn't work at the moment -->
|
18
|
+
<!-- <%= f.file_field :upload %> -->
|
16
19
|
<div class="frame">
|
17
20
|
<%= image_tag @image %>
|
18
21
|
</div>
|
@@ -1,27 +1,27 @@
|
|
1
|
+
<% include_stylesheet 'admin/extensions/assets/assets' %>
|
2
|
+
|
1
3
|
<div class="outset">
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
<td class="name"><%= image_listing(image) %></td>
|
14
|
-
<td class="actions"><%= link_to 'Remove', remove_admin_asset_path(image), :class => 'action remove' %></td>
|
15
|
-
</tr>
|
16
|
-
<% end %>
|
17
|
-
<% else %>
|
18
|
-
<tr><td class='empty' colspan='2'>No Assets</td></tr>
|
4
|
+
<ul id="assets">
|
5
|
+
<% unless @images.empty? %>
|
6
|
+
<% @images.each do |image| %>
|
7
|
+
<li>
|
8
|
+
<% link_to edit_admin_asset_path(image) do %>
|
9
|
+
<%= square_thumb(image, 120) %>
|
10
|
+
<span class="id">ID: <%= image.id %></span>
|
11
|
+
<span class="caption"><%= image.caption %></span>
|
12
|
+
<% end %>
|
13
|
+
<%= link_to 'Remove', remove_admin_asset_path(image), :class => 'action remove', :title => 'Remove Asset' %>
|
14
|
+
</li>
|
19
15
|
<% end %>
|
20
|
-
|
21
|
-
|
16
|
+
<% else %>
|
17
|
+
<li class='empty'>No Assets</li>
|
18
|
+
<% end %>
|
19
|
+
</ul>
|
22
20
|
</div>
|
21
|
+
|
23
22
|
<div id="actions">
|
23
|
+
<%= pagination_for(@images) %>
|
24
24
|
<ul>
|
25
|
-
<li><%= link_to 'Upload New Asset', new_admin_asset_path %></li>
|
25
|
+
<li class="new"><%= link_to 'Upload New Asset', new_admin_asset_path %></li>
|
26
26
|
</ul>
|
27
27
|
</div>
|
@@ -2,3 +2,65 @@
|
|
2
2
|
max-width: 100%;
|
3
3
|
overflow: auto;
|
4
4
|
}
|
5
|
+
|
6
|
+
#assets, #assets li {
|
7
|
+
display: block;
|
8
|
+
list-style: none;
|
9
|
+
margin: 0;
|
10
|
+
padding: 0;
|
11
|
+
}
|
12
|
+
|
13
|
+
#assets li {
|
14
|
+
float: left;
|
15
|
+
margin-right: 1px;
|
16
|
+
margin-bottom: 1px;
|
17
|
+
position: relative;
|
18
|
+
}
|
19
|
+
|
20
|
+
#assets li .id,
|
21
|
+
#assets li .caption,
|
22
|
+
#assets li .action {
|
23
|
+
position: absolute;
|
24
|
+
top: 2px;
|
25
|
+
display: none;
|
26
|
+
}
|
27
|
+
|
28
|
+
#assets li:hover .id,
|
29
|
+
#assets li:hover .caption,
|
30
|
+
#assets li:hover .action {
|
31
|
+
display: block;
|
32
|
+
}
|
33
|
+
|
34
|
+
#assets li .caption {
|
35
|
+
top: auto;
|
36
|
+
bottom: 0;
|
37
|
+
color: white;
|
38
|
+
background: black;
|
39
|
+
}
|
40
|
+
|
41
|
+
#assets li .id {
|
42
|
+
left: 2px;
|
43
|
+
color: white;
|
44
|
+
font-weight: bold;
|
45
|
+
}
|
46
|
+
|
47
|
+
#assets li .remove {
|
48
|
+
right: 2px;
|
49
|
+
background: url('/images/admin/minus.png') no-repeat top left;
|
50
|
+
width: 12px;
|
51
|
+
height: 12px;
|
52
|
+
text-indent: -1000em;
|
53
|
+
overflow: hidden;
|
54
|
+
}
|
55
|
+
|
56
|
+
#actions .new a::before {
|
57
|
+
content: '';
|
58
|
+
width: 12px;
|
59
|
+
height: 12px;
|
60
|
+
padding-right: 3px;
|
61
|
+
position: relative;
|
62
|
+
top: 2px;
|
63
|
+
display: block;
|
64
|
+
display: inline-block;
|
65
|
+
background: url('/images/admin/plus.png') no-repeat left bottom;
|
66
|
+
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-assets-extension
|
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
|
- Gerrit Kaiser
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-02-
|
18
|
+
date: 2011-02-25 00:00:00 +00:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- config/routes.rb
|
79
79
|
- cucumber.yml
|
80
80
|
- db/migrate/20110224001246_add_images_table.rb
|
81
|
+
- db/migrate/20110225021327_add_caption.rb
|
81
82
|
- features/support/env.rb
|
82
83
|
- features/support/paths.rb
|
83
84
|
- lib/radiant-assets-extension.rb
|
@@ -92,7 +93,7 @@ has_rdoc: true
|
|
92
93
|
homepage: http://ext.radiantcms.org/extensions/269-assets
|
93
94
|
licenses: []
|
94
95
|
|
95
|
-
post_install_message: "\n Add this to your radiant project with:\n config.gem 'radiant-assets-extension', :version => '0.0.
|
96
|
+
post_install_message: "\n Add this to your radiant project with:\n config.gem 'radiant-assets-extension', :version => '0.0.3'\n "
|
96
97
|
rdoc_options: []
|
97
98
|
|
98
99
|
require_paths:
|