soapbox 0.1.7 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.2.0
data/app/models/page.rb CHANGED
@@ -22,7 +22,9 @@ class Page < ActiveRecord::Base
22
22
  def title_bread_crumb
23
23
  title = self.title
24
24
  page = self
25
- until page.parent.nil?
25
+ i = 0
26
+ until page.parent.nil? || page.parent_id == page.id || i > 10
27
+ i += 1
26
28
  page = page.parent
27
29
  title += " &raquo; #{page.title}".html_safe
28
30
  end
@@ -32,7 +34,9 @@ class Page < ActiveRecord::Base
32
34
  def parents
33
35
  parents = [self]
34
36
  page = self
35
- until page.nil?
37
+ i = 0
38
+ until page.nil? || page.parent_id == page.id || i > 10
39
+ i += 1
36
40
  page = page.parent
37
41
  parents << page unless page.nil?
38
42
  end
data/lib/reduceds3.rb ADDED
@@ -0,0 +1,58 @@
1
+ require 'aws/s3'
2
+ require 'paperclip'
3
+ require 'paperclip/storage/s3'
4
+
5
+ # allow us to define Amazon storage type to use on Amazon for each style, by introducing a 's3_reduced' key
6
+ #
7
+ # Example:
8
+ #
9
+ # has_attached_file :image,
10
+ # :storage => :reduceds3,
11
+ # :s3_credentials => Rails.root.join("config/s3.yml"),
12
+ # :s3_permissions => 'public-read',
13
+ # :s3_protocol => 'http',
14
+ # :path => ":id.:style.:extension"
15
+ # :styles => {
16
+ # :original => {:geometry => "500x375>", :s3_reduced => false},
17
+ # :large => {:geometry => "300x250", :format => :png, :s3_reduced => true},
18
+ # :small => {:geometry => "100x75", :format => :png, :s3_reduced => true}
19
+ # },
20
+ # :processors => [:thumbnail],
21
+ # :default_style => :original
22
+
23
+ module Paperclip
24
+ module Storage
25
+ module Reduceds3
26
+ def self.extended base
27
+ base.extend(S3)
28
+ base.class_eval do
29
+ def flush_writes #:nodoc:
30
+ @queued_for_write.each do |style, file|
31
+ begin
32
+ # FIX OLIVIER : we personnalize headers
33
+ s3_headers = @s3_headers ? @s3_headers.dup : {}
34
+ if @options[:styles][style][:s3_reduced]
35
+ s3_headers['x-amz-storage-class'] = 'REDUCED_REDUNDANCY'
36
+ end
37
+ # puts "HEADERS: #{s3_headers.inspect}"
38
+ log("saving #{path(style)}")
39
+ AWS::S3::S3Object.store(path(style),
40
+ file,
41
+ bucket_name,
42
+ {:content_type => instance_read(:content_type),
43
+ :access => @s3_permissions,
44
+ }.merge(s3_headers))
45
+ rescue AWS::S3::NoSuchBucket => e
46
+ create_bucket
47
+ retry
48
+ rescue AWS::S3::ResponseError => e
49
+ raise
50
+ end
51
+ end
52
+ @queued_for_write = {}
53
+ end
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
data/lib/soapbox.rb CHANGED
@@ -14,6 +14,7 @@ require "acts_as_list"
14
14
  require "garb"
15
15
  require "ssl_requirement"
16
16
  require 'states'
17
+ # require 'reduceds3'
17
18
 
18
19
  require 'paperclip'
19
20
  require 'soapbox/paperclip' # this adds the paperclip.yml support
data/soapbox.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{soapbox}
8
- s.version = "0.1.7"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Gabe Coyne}, %q{Killit Creative}]
12
- s.date = %q{2011-08-01}
12
+ s.date = %q{2011-08-03}
13
13
  s.description = %q{manage pages, users, permissions, settings, analytics, files, users, and extend}
14
14
  s.email = %q{gabe@killitcreative.com}
15
15
  s.extra_rdoc_files = [
@@ -153,6 +153,7 @@ Gem::Specification.new do |s|
153
153
  "lib/generators/soapbox_scaffold/templates/views/admin/index.html.erb",
154
154
  "lib/generators/soapbox_scaffold/templates/views/index.html.erb",
155
155
  "lib/generators/soapbox_scaffold/templates/views/show.html.erb",
156
+ "lib/reduceds3.rb",
156
157
  "lib/soapbox.rb",
157
158
  "lib/soapbox/engine.rb",
158
159
  "lib/soapbox/paperclip.rb",
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soapbox
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 1
9
- - 7
10
- version: 0.1.7
8
+ - 2
9
+ - 0
10
+ version: 0.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gabe Coyne
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-08-01 00:00:00 Z
19
+ date: 2011-08-03 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  type: :runtime
@@ -447,6 +447,7 @@ files:
447
447
  - lib/generators/soapbox_scaffold/templates/views/admin/index.html.erb
448
448
  - lib/generators/soapbox_scaffold/templates/views/index.html.erb
449
449
  - lib/generators/soapbox_scaffold/templates/views/show.html.erb
450
+ - lib/reduceds3.rb
450
451
  - lib/soapbox.rb
451
452
  - lib/soapbox/engine.rb
452
453
  - lib/soapbox/paperclip.rb