radiant-images-extension 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.2
1
+ 0.3.3
data/app/models/image.rb CHANGED
@@ -42,8 +42,8 @@ class Image < ActiveRecord::Base
42
42
  def url(style = :original, include_updated_timestamp = true, secure = false)
43
43
  style = style.to_s
44
44
  prefix = secure ? 'https://' : 'http://'
45
- domain = Radiant::Config['s3.host_alias'].empty? ? 's3.amazonaws.com' : Radiant::Config['s3.host_alias']
46
- bucket = Radiant::Config['s3.host_alias'].empty? ? '/' + Radiant::Config['s3.bucket'] : ''
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
47
 
48
48
  url = prefix + domain + bucket + '/images/' + basename + '-' + style + '.' + extension
49
49
  include_updated_timestamp && updated_at ? [url, updated_at].compact.join(url.include?("?") ? "&" : "?") : url
data/images_extension.rb CHANGED
@@ -2,6 +2,7 @@
2
2
  # require_dependency 'application_controller'
3
3
 
4
4
  require 'paperclip'
5
+ require 'aws/s3'
5
6
 
6
7
  class ImagesExtension < Radiant::Extension
7
8
  version "0.1"
@@ -27,7 +28,7 @@ class ImagesExtension < Radiant::Extension
27
28
  warn 'Either install the Settings extension or remove Images.'
28
29
  exit(1)
29
30
  end
30
-
31
+
31
32
  unless defined? admin.image
32
33
  Radiant::AdminUI.send :include, Images::Interface::Admin::Images
33
34
  admin.image = Radiant::AdminUI.load_default_image_regions
@@ -60,7 +60,7 @@ module Images
60
60
  tag 'image' do |tag|
61
61
  tag.locals.image = Helpers.current_image(tag)
62
62
 
63
- tag.expand if tag.locals.image.present?
63
+ tag.expand
64
64
  end
65
65
 
66
66
  desc %{
@@ -71,20 +71,45 @@ module Images
71
71
  <pre><code><r:image title='image'><r:url [style="preview|original"] /></r:image></code></pre>
72
72
  }
73
73
  tag 'image:url' do |tag|
74
- style = tag.attr['style'] || :original
74
+ result = nil
75
+
76
+ if tag.locals.image ||= Helpers.current_image(tag)
77
+ style = tag.attr['style'] || :original
78
+ result = tag.locals.image.url(style, false)
79
+ end
75
80
 
76
- tag.locals.image.url(style, false)
81
+ result
82
+ end
83
+
84
+ desc %{
85
+ Outputs a very simple image tag
86
+ }
87
+ tag 'image:tag' do |tag|
88
+ result = nil
89
+
90
+ if tag.locals.image ||= Helpers.current_image(tag)
91
+ style = tag.attr['style'] || :original
92
+ result = %{<img src="#{tag.locals.image.url(style, false)}" />}
93
+ end
94
+
95
+ result
77
96
  end
78
97
 
79
98
  [:id, :title].each do |method|
80
99
  desc %{
81
100
  Outputs the title of the current image
82
-
101
+
83
102
  *Usage:*
84
103
  <pre><code><r:image title='image'><r:#{method} /></code></pre>
85
104
  }
86
105
  tag "image:#{method}" do |tag|
87
- tag.locals.image.send(method)
106
+ result = nil
107
+
108
+ if tag.locals.image ||= Helpers.current_image(tag)
109
+ result = tag.locals.image.send(method)
110
+ end
111
+
112
+ result
88
113
  end
89
114
  end
90
115
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{radiant-images-extension}
8
- s.version = "0.3.2"
8
+ s.version = "0.3.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["squaretalent"]
12
- s.date = %q{2010-10-09}
12
+ s.date = %q{2010-10-23}
13
13
  s.description = %q{Image Radiant Extension management tool, meant only to be useful to pages and extensions that need to require images.}
14
14
  s.email = %q{info@squaretalent.com}
15
15
  s.extra_rdoc_files = [
@@ -9,10 +9,7 @@ describe Images::Tags::Core do
9
9
  'images:if_images',
10
10
  'images:unless_images',
11
11
  'images:each',
12
- 'images:first',
13
12
  'image',
14
- 'image:if_first',
15
- 'image:unless_first',
16
13
  'image:url',
17
14
  'image:id',
18
15
  'image:title'].sort
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-images-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 2
10
- version: 0.3.2
9
+ - 3
10
+ version: 0.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - squaretalent
@@ -15,13 +15,13 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-09 00:00:00 +08:00
18
+ date: 2010-10-23 00:00:00 +08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: paperclip
22
+ type: :runtime
23
23
  prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
24
+ version_requirements: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
27
  - - ~>
@@ -33,12 +33,12 @@ dependencies:
33
33
  - 1
34
34
  - 1
35
35
  version: 2.3.1.1
36
- type: :runtime
37
- version_requirements: *id001
36
+ name: paperclip
37
+ requirement: *id001
38
38
  - !ruby/object:Gem::Dependency
39
- name: aws-s3
39
+ type: :runtime
40
40
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
41
+ version_requirements: &id002 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ">="
@@ -49,12 +49,12 @@ dependencies:
49
49
  - 6
50
50
  - 2
51
51
  version: 0.6.2
52
- type: :runtime
53
- version_requirements: *id002
52
+ name: aws-s3
53
+ requirement: *id002
54
54
  - !ruby/object:Gem::Dependency
55
- name: acts_as_list
55
+ type: :runtime
56
56
  prerelease: false
57
- requirement: &id003 !ruby/object:Gem::Requirement
57
+ version_requirements: &id003 !ruby/object:Gem::Requirement
58
58
  none: false
59
59
  requirements:
60
60
  - - ">="
@@ -65,12 +65,12 @@ dependencies:
65
65
  - 1
66
66
  - 2
67
67
  version: 0.1.2
68
- type: :runtime
69
- version_requirements: *id003
68
+ name: acts_as_list
69
+ requirement: *id003
70
70
  - !ruby/object:Gem::Dependency
71
- name: rspec
71
+ type: :development
72
72
  prerelease: false
73
- requirement: &id004 !ruby/object:Gem::Requirement
73
+ version_requirements: &id004 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ">="
@@ -81,12 +81,12 @@ dependencies:
81
81
  - 3
82
82
  - 0
83
83
  version: 1.3.0
84
- type: :development
85
- version_requirements: *id004
84
+ name: rspec
85
+ requirement: *id004
86
86
  - !ruby/object:Gem::Dependency
87
- name: rr
87
+ type: :development
88
88
  prerelease: false
89
- requirement: &id005 !ruby/object:Gem::Requirement
89
+ version_requirements: &id005 !ruby/object:Gem::Requirement
90
90
  none: false
91
91
  requirements:
92
92
  - - ">="
@@ -97,8 +97,8 @@ dependencies:
97
97
  - 0
98
98
  - 0
99
99
  version: 1.0.0
100
- type: :development
101
- version_requirements: *id005
100
+ name: rr
101
+ requirement: *id005
102
102
  description: Image Radiant Extension management tool, meant only to be useful to pages and extensions that need to require images.
103
103
  email: info@squaretalent.com
104
104
  executables: []