caboose-cms 0.8.53 → 0.8.54

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d6a292c4ac56159808f11b271e2bc5073831023
4
- data.tar.gz: c355716895d3d3a83ca03bc785c9e6282bad97b8
3
+ metadata.gz: 52aaaaf1b36fe04e4a238a7eb012bf091ea70dcf
4
+ data.tar.gz: d144b7f4c53b1e545faf238011a8b05bd76a7496
5
5
  SHA512:
6
- metadata.gz: bb48e2823390fc25b92f46793fc8c547c434e9cb309724f523abd08d58f1a7ccc58ec07a496c8a35b873810eaec31e760b3e3ac1c336cc600088e623b89a1c7e
7
- data.tar.gz: 5403811fd11bd1a05ce3d300fcd27ef97dfca99b0f7c84bc37d556e75cc394f2dbc2dddbef9cd88f0ec80406371d2efeb555d16cd2745361123f1d258ca1532b
6
+ metadata.gz: 477fb721643da72cb55421bb70444863a708ca51cb30ce5ce8e542e1e261db551fcaeb119c2ba550d8bde5638c9fff85dcd6673054c7147bfae1bc71733c2e11
7
+ data.tar.gz: 677d0f114bfd8591062f6a3a8dd4d57768e056fa2f3e18bb832921f527ee08bbebebdd486cc419a8399b01ce69a1d87110d9b32787838178a74197c7a9efc962
@@ -2,76 +2,62 @@ module Caboose
2
2
  class AssetsController < Caboose::ApplicationController
3
3
  layout 'caboose/admin'
4
4
 
5
- # @route GET /admin/assets/ace
6
- def admin_ace
7
- return if !user_is_allowed('assets', 'edit')
8
- end
9
-
10
- # @route GET /admin/assets
11
- def admin_index
12
- return if !user_is_allowed('assets', 'edit')
13
- config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
14
- bucket = config['bucket']
15
- @assets_path = "http://#{bucket}.s3.amazonaws.com/assets"
16
- end
17
-
18
- # @route GET /admin/assets/manifest
19
- def admin_manifest
20
- return if !user_is_allowed('assets', 'edit')
21
-
22
- config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
23
- bucket = config['bucket']
24
- resp = HTTParty.get("http://#{bucket}.s3.amazonaws.com/assets/manifest.yml")
25
- str = resp.body
26
- manifest = self.parse_manifest(str, true)
27
-
28
- render :json => manifest
29
- end
30
-
31
- def parse_manifest(str, exclude_images = true)
32
- lines = str.split("\n")
33
- h = {}
34
- lines.each_with_index do |line, i|
35
- next if i == 0
36
- path = line.split(": ").first.split('/')
37
-
38
- if exclude_images
39
- ext = line.split('.')
40
- next if ext.count > 0 && ['png','jpg','gif','ico'].include?(ext.last.downcase)
41
- end
42
- self.verify_path_exists(path, h)
43
- end
44
- return h
45
- end
46
-
47
- def verify_path_exists(path, h, i = 0)
48
- return if i >= path.count
49
- h[path[i]] = i == (path.count - 1) ? true : {} if h[path[i]].nil?
50
- self.verify_path_exists(path, h[path[i]], i+1)
51
- end
52
-
53
- # @route PUT /admin/assets
54
- #def admin_update
5
+ ## @route GET /admin/assets/ace
6
+ #def admin_ace
7
+ # return if !user_is_allowed('assets', 'edit')
8
+ #end
9
+ #
10
+ ## @route GET /admin/assets
11
+ #def admin_index
12
+ # return if !user_is_allowed('assets', 'edit')
13
+ # config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
14
+ # bucket = config['bucket']
15
+ # @assets_path = "http://#{bucket}.s3.amazonaws.com/assets"
16
+ #end
17
+ #
18
+ ## @route GET /admin/assets/manifest
19
+ #def admin_manifest
55
20
  # return if !user_is_allowed('assets', 'edit')
56
21
  #
57
- # resp = Caboose::StdClass.new
58
- # path = params[:path]
59
- # value = parasm[:value]
60
- #
61
- #
62
- # config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
63
- # AWS.config({ :access_key_id => config['access_key_id'], :secret_access_key => config['secret_access_key'] })
64
- # bucket = AWS::S3::Bucket.new(config['bucket'])
65
- # obj = bucket.objects[path]
22
+ # config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
23
+ # bucket = config['bucket']
24
+ # resp = HTTParty.get("http://#{bucket}.s3.amazonaws.com/assets/manifest.yml")
25
+ # str = resp.body
26
+ # manifest = self.parse_manifest(str, true)
66
27
  #
67
- # if obj.nil?
68
- # resp.error = "Can't find file."
69
- # #elsif !obj.write(value)
70
- # # resp.error = "Can't write to file."
71
- # else
72
- # resp.success = true
28
+ # render :json => manifest
29
+ #end
30
+ #
31
+ #def parse_manifest(str, exclude_images = true)
32
+ # lines = str.split("\n")
33
+ # h = {}
34
+ # lines.each_with_index do |line, i|
35
+ # next if i == 0
36
+ # path = line.split(": ").first.split('/')
37
+ #
38
+ # if exclude_images
39
+ # ext = line.split('.')
40
+ # next if ext.count > 0 && ['png','jpg','gif','ico'].include?(ext.last.downcase)
41
+ # end
42
+ # self.verify_path_exists(path, h)
73
43
  # end
44
+ # return h
45
+ #end
46
+ #
47
+ #def verify_path_exists(path, h, i = 0)
48
+ # return if i >= path.count
49
+ # h[path[i]] = i == (path.count - 1) ? true : {} if h[path[i]].nil?
50
+ # self.verify_path_exists(path, h[path[i]], i+1)
51
+ #end
52
+ #
53
+ ## @route PUT /admin/assets
54
+ #def admin_update
55
+ # return if !user_is_allowed('assets', 'edit')
56
+ #
57
+ # path = params[:path]
58
+ # value = params[:value]
74
59
  #
60
+ # resp = AssetManifest.save_asset(path, value)
75
61
  # render :json => resp
76
62
  #end
77
63
 
@@ -140,11 +140,18 @@ module Caboose
140
140
  end
141
141
 
142
142
  if c.nil?
143
- c = Stripe::Customer.create(
144
- :source => params[:token],
145
- :email => u.email,
146
- :metadata => { :user_id => u.id }
147
- )
143
+ begin
144
+ c = Stripe::Customer.create(
145
+ :source => params[:token],
146
+ :email => u.email,
147
+ :metadata => { :user_id => u.id }
148
+ )
149
+ rescue Stripe::CardError => e
150
+ render :json => {
151
+ :error => e.message
152
+ }
153
+ return
154
+ end
148
155
  end
149
156
 
150
157
  u.stripe_customer_id = c.id
@@ -1,27 +1,75 @@
1
1
  module Caboose
2
- class AssetManifest < ActiveRecord::Base
3
- self.table_name = "asset_manifests"
4
- attr_accessible :id, :name
2
+ class AssetManifest
5
3
 
6
- #def save_asset(path, value)
7
- # resp = StdClass.new
4
+ #def AssetManifest.bucket
5
+ # if @@bucket.nil?
6
+ # config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
7
+ # AWS.config({ :access_key_id => config['access_key_id'], :secret_access_key => config['secret_access_key'] })
8
+ # @@bucket = AWS::S3::Bucket.new(config['bucket'])
9
+ # end
10
+ # return @@bucket
11
+ #end
12
+ #
13
+ #def AssetManifest.save_asset(path, str, reset = true)
14
+ #
15
+ # file = self.bucket.objects[path]
16
+ # return { :error => "Can't find file." } if file.nil?
17
+ #
18
+ # # Save the contents into the source file
19
+ # return { :error => "Can't write to file." } if !file.write(str)
20
+ #
21
+ # # Compile the file
22
+ # str_compiled = Uglifier.compile(str)
23
+ #
24
+ # # Compute the digest for the compiled file
25
+ # digest = Digest::SHA2.hexdigest(str_compiled)
8
26
  #
9
- # config = YAML.load(File.read(Rails.root.join('config', 'aws.yml')))[Rails.env]
10
- # AWS.config({ :access_key_id => config['access_key_id'], :secret_access_key => config['secret_access_key'] })
11
- # bucket = AWS::S3::Bucket.new(config['bucket'])
12
- # obj = bucket.objects[path]
27
+ # # See if the digest file for the compiled file exists
28
+ # digest_path = self.path_with_digest(path, digest)
29
+ # if self.bucket.objects[digest_path].exists?
30
+ # digest_file = bucket.objects[digest_path]
31
+ # digest_file.write(str_compiled)
32
+ # end
13
33
  #
14
- # return { :error => "Can't find file." } if obj.nil?
15
- # return { :error => "Can't write to file." } if !obj.write(value)
34
+ # # See if the digest is in the manifest
35
+ # manifest = self.bucket.objects['assets/manifest.yml']
36
+ # changed = false
37
+ # new_lines = []
38
+ # manifest.read.split("\n").each do|line|
39
+ # if line.starts_with?("#{path}: ") && line != "#{path}: #{digest_path}"
40
+ # new_lines << "#{path}: #{digest_path}"
41
+ # changed = true
42
+ # else
43
+ # new_lines << line
44
+ # end
45
+ # end
16
46
  #
17
- # # Compile the new file
18
- # dest = "#{Rails.root}/vendor/assets/javascripts/compiled/"
19
- # filename = path.split('/').pop
20
- # ext = filename.split('.').pop
21
- # File.write(dest + js_asset, Uglifier.compile(Rails.application.assets.find_asset(js_asset).to_s))
47
+ # # If the digest has changed, update the manifest and set the app asset digests
48
+ # if changed
49
+ # manifest.write(new_lines.join("\n"))
50
+ # self.reset_asset_digests(new_lines) if reset
51
+ # end
52
+ #
53
+ # return { :sucess => true }
54
+ #end
55
+ #
56
+ #def AssetManifest.reset_asset_digests(lines = nil)
57
+ # lines = self.bucket.objects['assets/manifest.yml'].read.split("\n") if lines.nil?
58
+ # lines.each do|line|
59
+ # arr = line.split(": ")
60
+ # Rails.application.config.assets.digests[arr[0]] = arr[1]
61
+ # end
62
+ #end
22
63
  #
64
+ #def AssetManifest.path_with_digest(path, digest)
65
+ # arr = path.split('/')
66
+ # filename = arr.pop
67
+ # filename = filename.split('.')
68
+ # ext = filename.pop
69
+ # filename = "#{filename.join('.')}-#{digest}.#{ext}"
70
+ # return filename if arr.count == 0
71
+ # return "#{arr.join('/')}/#{filename}"
23
72
  #end
24
-
25
73
 
26
74
  end
27
75
  end
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.8.53'
2
+ VERSION = '0.8.54'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.53
4
+ version: 0.8.54
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry