radiant-images-extension 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -4,48 +4,85 @@ Radiant Images is an IMAGE management tool, meant only to be useful to pages and
4
4
 
5
5
  ## Primary (only) Goals
6
6
 
7
- ### Light Weight
7
+ **Light Weight ::** We're not replacing paperclipped, we're just building a simple image manager extension.
8
8
 
9
- > We're not replacing paperclipped, we're just building a simple image manager extension.
9
+ **Uncomplicated ::** People need to be able to look at the model and instantly know what it's doing, being able to do so means they can easily extend it
10
10
 
11
- ### Uncomplicated
11
+ **Flexible ::** Images works with the local filesystem or S3 cloud storage.
12
12
 
13
- > People need to be able to look at the model and instantly know what it's doing, being able to do so means they can easily extend it
13
+ **Easily Extendable ::** Images is a base for things like galleries and shop, where they don't need additional assets
14
14
 
15
- ### Easily Extendable
15
+ **Migrate from paperclipped easily ::** Paperclipped is freakin' awesome, we use it and we need to be able to migrate the images over
16
16
 
17
- > Images is a base for things like galleries and shop, where they don't need additional assets
17
+ rake radiant:extensions:images:migrate_from_paperclipped
18
18
 
19
- ### Strictly aws and paperclip
19
+ ## Installation
20
20
 
21
- > We don't work with images locally because we use Heroku. So we're not going to give you the option to start locally
21
+ gem install radiant-images-extension
22
+
23
+ Add the following line to your config/environment.rb:
24
+ `config.gem 'radiant-images-extension', :lib => false`
25
+
26
+ rake radiant:extensions:images:update
27
+ rake radiant:extensions:images:migrate
22
28
 
23
- ### Migrate from paperclipped easily
29
+ ## S3 Storage
24
30
 
25
- > paperclipped is freakin' awesome, we use it and we need to be able to migrate the images over
31
+ By default images will use your local file storage. If you wish to use s3 to store your image, change the `images.storage` config key to `s3`.
26
32
 
27
- rake radiant:extensions:images:migrate_from_paperclipped
33
+ Radiant::Config['images.storage'] = 's3'
28
34
 
29
- ## Installation
35
+ You will also need to set the related S3 config items to match your account:
30
36
 
31
- The recommended way to install the radiant images extension is by installing the gem and configuring it in your radiant app, here are the instructions:
37
+ Radiant::Config['s3.bucket'] = 'bucket'
38
+ Radiant::Config['s3.host_alias'] = 'alias' # Optional! Used for aliased hostnames
39
+ Radiant::Config['s3.key'] = 'key'
40
+ Radiant::Config['s3.secret'] = 'secret'
32
41
 
33
- gem install radiant-images-extension
34
- # add the following line to your config/environment.rb: config.gem 'radiant-images-extension', :lib => false
35
- rake radiant:extensions:images:update
36
- rake radiant:extensions:images:migrate
42
+ The URL and path values will need to be altered from their default values to work correctly with S3 storage, see the section below for examples.
43
+
44
+ ## URL and Path Settings
45
+
46
+ The URL and Path settings for images out of the box will work fine for local storage, if you are using S3 then checkout the examples below:
47
+
48
+ You can find a list of symbols that can be used in the URL/Path [at the paperclip wiki](http://github.com/thoughtbot/paperclip/wiki/interpolations). There are more symbols which you may be able to find by searching online also.
49
+
50
+ Here are some base values and their explanation of use:
51
+
52
+ #### Local file storage
53
+
54
+ produces a URL such as: /images/original_file-icon.png
55
+
56
+ Radiant::Config['images.path'] = ':rails_root/public/:class/:basename-:style.:extension'
57
+ Radiant::Config['images.url'] = '/:class/:basename-:style.:extension'
58
+
59
+ #### Amazon S3 storage
60
+
61
+ produces a URL such as: http://s3.amazonaws.com/bucketname/images/original_file-icon.png
62
+
63
+ Radiant::Config['images.path'] = ':class/:basename-:style.:extension'
64
+ Radiant::Config['images.url'] = ':s3_path_url'
65
+
66
+ #### Amazon S3 with FQDN (Requires a CNAME pointing to s3.amazonaws.com)
67
+
68
+ produces a URL such as: http://host.alias/images/original_file-icon.png
69
+
70
+ Radiant::Config['images.path'] = ':class/:basename-:style.:extension'
71
+ Radiant::Config['images.url'] = ':s3_alias_url'
37
72
 
38
- If you want to run a development copy of images simply clone a copy into radiant's vendor/extensions folder and then run a update/migrate on the extension.
73
+ ## Passenger and ImageMagick
39
74
 
40
- ## Host Alias Settings
75
+ They don't always play nicely, if you're having strange errors such as
41
76
 
42
- By default the images extension uses the following url for images:
77
+ /tmp/stream20101025-12485-nx6sdr-0 is not recognized by the 'identify' command.
78
+
79
+ Then ensure that you have set the config to match the location of imagemagick on your machine
43
80
 
44
- http://s3.amazonaws.com/bucketname/images/name_of_image-style.(png|jpg|gif)
81
+ images.image_magick_path = /usr/local/bin
45
82
 
46
- There is a radiant configuration option called s3.host_alias. By default it is blank, if you give it a value, the images extension will use the FQDN method to access your images. Setting your host alias to domain.name.com for example would produce a URL like this:
83
+ ## Contributors
47
84
 
48
- http://domain.name.com/images/name_of_image-style.(png|jpg|gif)
85
+ Dirk Kelly, Mario Visic
49
86
 
50
87
  ## License
51
88
 
data/Rakefile CHANGED
@@ -7,7 +7,8 @@ begin
7
7
  gem.email = "info@squaretalent.com"
8
8
  gem.homepage = "http://github.com/squaretalent/radiant-images-extension"
9
9
  gem.authors = ['squaretalent']
10
- gem.add_dependency 'paperclip', '~> 2.3.1.1'
10
+ gem.add_dependency 'radiant', '>= 0.9.1'
11
+ gem.add_dependency 'paperclip', '~> 2.3.5'
11
12
  gem.add_dependency 'aws-s3', '>= 0.6.2'
12
13
  gem.add_dependency 'acts_as_list', '>= 0.1.2'
13
14
  gem.add_development_dependency 'rspec', '>= 1.3.0'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
@@ -1,34 +1,20 @@
1
1
  class Admin::ImagesController < Admin::ResourceController
2
2
 
3
- before_filter :index_assets, :only => [ :index ]
4
- before_filter :edit_assets, :only => [ :show, :edit ]
5
- around_filter :rescue_s3_exceptions, :only => [:create, :edit, :destroy]
3
+ before_filter :index_assets, :only => [ :index ]
4
+ before_filter :edit_assets, :only => [ :show, :edit ]
5
+ around_filter :rescue_s3_exceptions, :only => [ :create, :update, :destroy ]
6
6
 
7
7
  def index
8
- @images = Image.paginate :page => params[:page], :per_page => 20
8
+ @images = Image.paginate :page => params[:page], :per_page => params[:pp] || 25
9
9
  end
10
10
 
11
-
12
- def search
13
- @images = Image.search params[:search], params[:p]
14
-
15
- respond_to do |format|
16
- format.html { render }
17
- format.js { render @images }
18
- format.xml { render :xml => @images.to_xml }
19
- format.json { render :json => @images.to_json }
20
- end
21
- end
22
-
23
- private
11
+ protected
24
12
 
25
13
  def index_assets
26
- include_javascript 'admin/extensions/images/index'
27
14
  include_stylesheet 'admin/extensions/images/index'
28
15
  end
29
16
 
30
17
  def edit_assets
31
- include_javascript 'admin/extensions/images/edit'
32
18
  include_stylesheet 'admin/extensions/images/edit'
33
19
  end
34
20
 
data/app/models/image.rb CHANGED
@@ -14,15 +14,16 @@ class Image < ActiveRecord::Base
14
14
  :styles => lambda { Image.config_styles },
15
15
  :whiny_thumbnails => false,
16
16
  :default_url => '/images/extensions/images/missing_:style.png',
17
-
18
- :storage => :s3,
17
+ :storage => Radiant::Config['images.storage'] == 's3' ? :s3 : :filesystem,
19
18
  :s3_credentials => {
20
19
  :access_key_id => Radiant::Config['s3.key'],
21
20
  :secret_access_key => Radiant::Config['s3.secret']
22
21
  },
22
+ :s3_host_alias => Radiant::Config['s3.host_alias'],
23
23
  :bucket => Radiant::Config['s3.bucket'],
24
- :path => Radiant::Config['s3.path']
25
-
24
+ :url => Radiant::Config['images.url'],
25
+ :path => Radiant::Config['images.path']
26
+
26
27
  validates_attachment_presence :asset
27
28
  validates_attachment_content_type :asset, :content_type => ['image/jpeg', 'image/png', 'image/gif']
28
29
 
@@ -30,65 +31,19 @@ class Image < ActiveRecord::Base
30
31
  self.title = self.asset_file_name if title.blank?
31
32
  end
32
33
 
33
- def url(style = :original, include_updated_timestamp = true, secure = false)
34
- self.asset.url(style, include_updated_timestamp, secure)
34
+ def url(style = Radiant::Config['images.default'], include_updated_timestamp = true)
35
+ self.asset.url(style, include_updated_timestamp)
35
36
  end
36
37
 
37
- # We need to overide the url method for our attachment so
38
- # we can dynamically swap between aliased and non aliased domain names
39
- module ::Paperclip
40
- class Attachment
41
-
42
- def url(style = :original, include_updated_timestamp = true, secure = false)
43
- style = style.to_s
44
- prefix = secure ? 'https://' : 'http://'
45
- domain = Radiant::Config['s3.host_alias'].present? ? Radiant::Config['s3.host_alias'] : 's3.amazonaws.com'
46
- bucket = Radiant::Config['s3.host_alias'].present? ? '' : "/#{Radiant::Config['s3.bucket']}"
47
-
48
- url = prefix + domain + bucket + '/images/' + basename + '-' + style + '.' + extension
49
- include_updated_timestamp && updated_at ? [url, updated_at].compact.join(url.include?("?") ? "&" : "?") : url
50
- end
51
-
52
- def basename
53
- File.basename(instance.asset_file_name, ".*") if instance.asset_file_name
54
- end
55
-
56
- def extension
57
- instance.asset_file_name.split('.').last.downcase if instance.asset_file_name
58
- end
59
-
60
- end
61
- end
38
+ private
62
39
 
63
- private
64
-
65
- class << self
66
- def search(search, page)
67
- unless search.blank?
68
- queries = []
69
- queries << 'LOWER(title) LIKE (:term)'
70
- queries << 'LOWER(caption) LIKE (:term)'
71
- queries << 'LOWER(asset_file_name) LIKE (:term)'
72
-
73
- sql = queries.join(' OR ')
74
- @conditions = [sql, {:term => "%#{search.downcase}%" }]
75
- else
76
- @conditions = []
77
- end
78
-
79
- self.all :conditions => @conditions
80
-
81
- end
82
-
83
- def config_styles
84
- styles = []
85
-
86
- if Radiant::Config['images.styles']
87
- styles = Radiant::Config['images.styles'].gsub(/\s+/,'').split(',')
88
- styles = styles.collect{|s| s.split('=')}.inject({}) {|ha, (k, v)| ha[k.to_sym] = v; ha}
89
- end
90
- styles
40
+ def self.config_styles
41
+ styles = []
42
+ if Radiant::Config['images.styles']
43
+ styles = Radiant::Config['images.styles'].gsub(/\s+/,'').split(',')
44
+ styles = styles.collect{|s| s.split('=')}.inject({}) {|ha, (k, v)| ha[k.to_sym] = v; ha}
91
45
  end
46
+ styles
92
47
  end
93
-
48
+
94
49
  end
@@ -1,13 +1,8 @@
1
- %ul{ :style =>'float: left'}
1
+ %ul
2
2
  - render_region :bottom do |bottom|
3
3
  - bottom.create do
4
4
  %li
5
5
  = link_to image('plus') + " " + t("new_image"), new_admin_image_path
6
- - bottom.search do
7
- %li
8
- - form_tag nil, :method => 'get' do
9
- = text_field_tag 'search', params[:search], :type => 'search'
10
- = observe_field 'search', :frequency => 2, :update => 'images', :url => { :controller => 'images', :action=> 'index' }, :method => 'get', :with => "'search=' + escape(value)"
11
6
  - render_region :paginate do |paginate|
12
7
  - paginate.pagination do
13
8
  = pagination_for(@images)
data/config/routes.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  ActionController::Routing::Routes.draw do |map|
2
2
 
3
3
  map.namespace :admin, :member => { :remove => :get } do |admin|
4
- admin.resources :images, :collection => { :search => :get }
4
+ admin.resources :images
5
5
  end
6
6
 
7
7
  end
data/images_extension.rb CHANGED
@@ -10,7 +10,7 @@ class ImagesExtension < Radiant::Extension
10
10
  url "http://github.com/squaretalent/radiant-images-extension"
11
11
 
12
12
  extension_config do |config|
13
- config.gem 'paperclip', :version => '~> 2.3.1.1'
13
+ config.gem 'paperclip', :version => '~> 2.3.5'
14
14
  config.gem 'aws-s3', :version => '>= 0.6.2', :lib => 'aws/s3'
15
15
  config.gem 'acts_as_list', :version => '>= 0.1.2'
16
16
 
@@ -22,18 +22,12 @@ class ImagesExtension < Radiant::Extension
22
22
 
23
23
  def activate
24
24
 
25
- # require the settings extension to be loaded
26
- unless Radiant::Extension.descendants.any? { |extension| extension.extension_name == 'Settings' }
27
- warn 'Error: The Images extension requires the Settings extension to be installed.'
28
- warn 'Either install the Settings extension or remove Images.'
29
- exit(1)
30
- end
31
-
32
25
  unless defined? admin.image
33
26
  Radiant::AdminUI.send :include, Images::Interface::Admin::Images
34
27
  admin.image = Radiant::AdminUI.load_default_image_regions
35
28
  end
36
29
 
30
+ Paperclip::Railtie.insert
37
31
 
38
32
  Page.send :include, Images::Tags::Core
39
33
 
@@ -43,14 +37,16 @@ class ImagesExtension < Radiant::Extension
43
37
  add_item 'Images', '/admin/images', :after => 'Pages'
44
38
  end
45
39
 
46
- Radiant::Config['images.styles'] ||= "icon=45x45#,preview=200x200#,normal=640x640#"
47
40
  Radiant::Config['images.default'] ||= "original"
41
+ Radiant::Config['images.path'] ||= ":rails_root/public/:class/:basename-:style.:extension"
42
+ Radiant::Config['images.storage'] ||= "local"
43
+ Radiant::Config['images.styles'] ||= "icon=45x45#,preview=200x200#,normal=640x640#"
44
+ Radiant::Config['images.url'] ||= "/:class/:basename-:style.:extension"
48
45
 
49
- Radiant::Config['s3.host_alias'] ||= ""
46
+ Radiant::Config['s3.bucket'] ||= "set"
47
+ Radiant::Config['s3.host_alias'] ||= "set"
50
48
  Radiant::Config['s3.key'] ||= "set"
51
49
  Radiant::Config['s3.secret'] ||= "set"
52
- Radiant::Config['s3.bucket'] ||= "fs.domain.com"
53
- Radiant::Config['s3.path'] ||= ":class/:basename-:style.:extension"
54
50
 
55
51
 
56
52
  unless Radiant::Config["images.image_magick_path"].nil?
@@ -22,10 +22,9 @@ module Images
22
22
  image.new = image.edit
23
23
  image.index = Radiant::AdminUI::RegionSet.new do |index|
24
24
  index.attributes.concat %w{thumbnail title modify }
25
- index.bottom.concat %w{ create search }
25
+ index.bottom.concat %w{ create }
26
26
  index.paginate.concat %w{ pagination }
27
27
  end
28
- image.searchearch = image.index
29
28
  image.remove = image.index
30
29
  end
31
30
  end
@@ -14,7 +14,6 @@ module Images
14
14
  }
15
15
  tag 'images' do |tag|
16
16
  tag.locals.images = Helpers.current_images(tag)
17
-
18
17
  tag.expand
19
18
  end
20
19
 
@@ -42,279 +41,73 @@ module Images
42
41
  }
43
42
  tag 'images:each' do |tag|
44
43
  context = ''
45
-
46
44
  tag.locals.images.each do |image|
47
45
  tag.locals.image = image
48
46
  context << tag.expand
49
47
  end
50
-
51
- content
48
+ context
52
49
  end
53
50
 
54
51
  desc %{
55
- Expands the current image context
52
+ Expands the current image context.
53
+ Images can be obtained by passing a ID, title or position attribute.
56
54
 
57
55
  *Usage:*
58
- <pre><code><r:image>...</r:image></code></pre>
56
+ <pre><code><r:image [id=] [title=""] [position=]>...</r:image></code></pre>
59
57
  }
60
58
  tag 'image' do |tag|
61
59
  tag.locals.image = Helpers.current_image(tag)
62
-
63
60
  tag.expand
64
61
  end
65
62
 
66
63
  desc %{
67
- Outputs the full URL of the image including the filename. Specify the style
68
- using the style option.
64
+ Outputs the full URL of the image including the filename.
65
+ The style of the image can be specified by passing the style attribute.
69
66
 
70
67
  *Usage:*
71
68
  <pre><code><r:image title='image'><r:url [style="preview|original"] /></r:image></code></pre>
72
69
  }
73
70
  tag 'image:url' do |tag|
74
71
  result = nil
75
-
76
72
  if tag.locals.image ||= Helpers.current_image(tag)
77
- style = tag.attr['style'] || :original
73
+ style = tag.attr['style'] || Radiant::Config['images.default'].to_sym
78
74
  result = tag.locals.image.url(style, false)
79
75
  end
80
-
81
76
  result
82
77
  end
83
78
 
84
79
  desc %{
85
- Outputs a very simple image tag
80
+ Outputs a very simple image tag.
81
+ The style of the image can be specified by passing the style attribute.
82
+
83
+ *Usage:*
84
+ <pre><code><r:image title='image'><r:tag [style="preview|original"] /></r:image></code></pre>
86
85
  }
87
86
  tag 'image:tag' do |tag|
88
87
  result = nil
89
-
90
88
  if tag.locals.image ||= Helpers.current_image(tag)
91
- style = tag.attr['style'] || :original
89
+ style = tag.attr['style'] || Radiant::Config['images.default'].to_sym
92
90
  result = %{<img src="#{tag.locals.image.url(style, false)}" />}
93
91
  end
94
-
95
92
  result
96
93
  end
97
94
 
98
- [:id, :title].each do |method|
95
+ [:id, :title, :position].each do |method|
99
96
  desc %{
100
- Outputs the title of the current image
97
+ Outputs the #{method} of the current image
101
98
 
102
99
  *Usage:*
103
100
  <pre><code><r:image title='image'><r:#{method} /></code></pre>
104
101
  }
105
102
  tag "image:#{method}" do |tag|
106
103
  result = nil
107
-
108
104
  if tag.locals.image ||= Helpers.current_image(tag)
109
105
  result = tag.locals.image.send(method)
110
106
  end
111
-
112
107
  result
113
108
  end
114
109
  end
115
110
 
116
111
  end
117
112
  end
118
- end
119
-
120
-
121
-
122
- # describe '<r:images:each>' do
123
- #
124
- # it 'should expand on all images' do
125
- # content = '<r:images:each>test!</r:images:each>'
126
- # expected = ''
127
- # @images.length.times { expected += 'test!' }
128
- # pages(:home).should render(content).as(expected)
129
- # end
130
- #
131
- # it 'should be running through the image objects' do
132
- # content = '<r:images:each><r:images:url/></r:images:each>'
133
- # expected = ''
134
- # @images.each { |image| expected += image.asset.url }
135
- # pages(:home).should render(content).as(expected)
136
- # end
137
- #
138
- # it 'should only run through however many images we specify with limit' do
139
- # content = '<r:images:each limit="2"><r:images:url/></r:images:each>'
140
- # expected = ''
141
- # @images[0..1].each { |image| expected += image.asset.url }
142
- # pages(:home).should render(content).as(expected)
143
- # end
144
- #
145
- # it 'should start at the image number we give it using offset' do
146
- # content = '<r:images:each limit="2" offset="1"><r:images:url/></r:images:each>'
147
- # expected = ''
148
- # @images[1..2].each { |image| expected += image.asset.url }
149
- # pages(:home).should render(content).as(expected)
150
- # end
151
- #
152
- # it 'should display images in the order we give' do
153
- # # asc
154
- # content = '<r:images:each order="asc" by="position"><r:images:url/></r:images:each>'
155
- # expected = ''
156
- # @images.each { |image| expected += image.asset.url }
157
- # pages(:home).should render(content).as(expected)
158
- #
159
- # #desc
160
- # content = '<r:images:each order="desc" by="position"><r:images:url/></r:images:each>'
161
- # expected = ''
162
- # @images.reverse.each { |image| expected += image.asset.url }
163
- # pages(:home).should render(content).as(expected)
164
- # end
165
- #
166
- # it 'should allow us to order images by title' do
167
- # content = '<r:images:each order="asc" by="title"><r:images:url/></r:images:each>'
168
- # expected = ''
169
- # @images.sort! { |a,b| a.title <=> b.title }
170
- # @images.each { |image| expected += image.asset.url }
171
- # pages(:home).should render(content).as(expected)
172
- # end
173
- #
174
- # end
175
- #
176
- # describe '<r:images:first>' do
177
- #
178
- # it 'should render the first image' do
179
- # content = '<r:images:first><r:images:url/></r:images:first>'
180
- # expected = @images.first.asset.url
181
- # pages(:home).should render(content).as(expected)
182
- # end
183
- #
184
- # end
185
- #
186
- # describe '<r:images:if_first>' do
187
- #
188
- # it 'should expand the tag if the image is the first' do
189
- # content = '<r:images><r:each><r:if_first><r:url /></r:if_first></r:each></r:images>'
190
- # expected = @images.first.asset.url
191
- # pages(:home).should render(content).as(expected)
192
- # end
193
- #
194
- # end
195
- #
196
- # describe '<r:images:unless_first>' do
197
- #
198
- # it 'should expand the tag if the image is not the first' do
199
- # content = '<r:images><r:each><r:unless_first><r:url /></r:unless_first></r:each></r:images>'
200
- # expected = ''
201
- #
202
- # @images.each do |image|
203
- # expected += image.asset.url unless image == @images.first
204
- # end
205
- #
206
- # pages(:home).should render(content).as(expected)
207
- # end
208
- #
209
- # end
210
- #
211
- # describe '<r:if_images>' do
212
- #
213
- # it 'should expand the contents if there are images' do
214
- # content = '<r:images:if_images>test text</r:images:if_images>'
215
- # expected = 'test text'
216
- # pages(:home).should render(content).as(expected)
217
- # end
218
- #
219
- # it 'should not expand the contents if there are no images' do
220
- # Image.delete_all
221
- # content = '<r:images:if_images>test text</r:images:if_images>'
222
- # expected = ''
223
- # pages(:home).should render(content).as(expected)
224
- # end
225
- #
226
- # it 'should expand if the min count is equal to the image count' do
227
- # min_count = Image.count
228
- # content = '<r:images:if_images min_count="' + min_count.to_s + '">test text</r:images:if_images>'
229
- # expected = 'test text'
230
- # pages(:home).should render(content).as(expected)
231
- # end
232
- #
233
- # it 'should not expand if the min count is greater than the image count' do
234
- # min_count = Image.count + 1
235
- # content = '<r:images:if_images min_count="' + min_count.to_s + '">test text</r:images:if_images>'
236
- # expected = ''
237
- # pages(:home).should render(content).as(expected)
238
- # end
239
- #
240
- # end
241
- #
242
- # describe '<r:unless_images>' do
243
- #
244
- # it 'should not the contents if there are images' do
245
- # content = '<r:images:unless_images>test text</r:images:unless_images>'
246
- # expected = ''
247
- # pages(:home).should render(content).as(expected)
248
- # end
249
- #
250
- # it 'should expand the contents if there are no images' do
251
- # Image.delete_all
252
- # content = '<r:images:unless_images>test text</r:images:unless_images>'
253
- # expected = 'test text'
254
- # pages(:home).should render(content).as(expected)
255
- # end
256
- #
257
- # it 'should not expand if the min count is equal to the image count' do
258
- # min_count = Image.count
259
- # content = '<r:images:unless_images min_count="' + min_count.to_s + '">test text</r:images:unless_images>'
260
- # expected = ''
261
- # pages(:home).should render(content).as(expected)
262
- # end
263
- #
264
- # it 'should expand if the min count is greater than the image count' do
265
- # min_count = Image.count + 1
266
- # content = '<r:images:unless_images min_count="' + min_count.to_s + '">test text</r:images:unless_images>'
267
- # expected = 'test text'
268
- # pages(:home).should render(content).as(expected)
269
- # end
270
- #
271
- # end
272
- #
273
- # describe '<r:images:url/>' do
274
- #
275
- # it 'should output the url for a valid image' do
276
- # content = '<r:images title="' + @images.first.title + '"><r:images:url/></r:images>'
277
- # expected = @images.first.asset.url
278
- # pages(:home).should render(content).as(expected)
279
- # end
280
- #
281
- # end
282
- #
283
- # describe '<r:images:title/>' do
284
- #
285
- # it 'should output the title for a valid image' do
286
- # content = '<r:images title="' + @images.first.title + '"><r:images:title/></r:images>'
287
- # expected = @images.first.title
288
- # pages(:home).should render(content).as(expected)
289
- # end
290
- #
291
- # end
292
- #
293
- # describe '<r:images:tag/>' do
294
- #
295
- # it 'should output a valid image tag when given a valid image' do
296
- # content = '<r:images title="' + @images.first.title + '"><r:images:tag /></r:images>'
297
- # expected = '<img src="' + @images.first.asset.url + '" alt="' + @images.first.title + '" />'
298
- # pages(:home).should render(content).as(expected)
299
- # end
300
- #
301
- # it 'should output a valid image tag when specifying an image by title' do
302
- # content = '<r:images:tag title="' + @images.first.title + '" />'
303
- # expected = '<img src="' + @images.first.asset.url + '" alt="' + @images.first.title + '" />'
304
- # pages(:home).should render(content).as(expected)
305
- # end
306
- #
307
- # it 'should output an image tag with the specified size' do
308
- # content = '<r:images:tag title="' + @images.first.title + '" size="icon" />'
309
- # expected = '<img src="' + @images.first.asset.url(:icon) + '" alt="' + @images.first.title + '" />'
310
- # pages(:home).should render(content).as(expected)
311
- # end
312
- #
313
- # it 'should use the given alt text specified' do
314
- # content = '<r:images:tag title="' + @images.first.title + '" alt="new alt text" />'
315
- # expected = '<img src="' + @images.first.asset.url + '" alt="new alt text" />'
316
- # pages(:home).should render(content).as(expected)
317
- # end
318
- #
319
- # end
320
- #
113
+ end