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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 52aaaaf1b36fe04e4a238a7eb012bf091ea70dcf
|
|
4
|
+
data.tar.gz: d144b7f4c53b1e545faf238011a8b05bd76a7496
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
6
|
-
def admin_ace
|
|
7
|
-
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def admin_index
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
#
|
|
58
|
-
#
|
|
59
|
-
#
|
|
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
|
-
#
|
|
68
|
-
#
|
|
69
|
-
#
|
|
70
|
-
#
|
|
71
|
-
#
|
|
72
|
-
#
|
|
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
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
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
|
|
3
|
-
self.table_name = "asset_manifests"
|
|
4
|
-
attr_accessible :id, :name
|
|
2
|
+
class AssetManifest
|
|
5
3
|
|
|
6
|
-
#def
|
|
7
|
-
#
|
|
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
|
-
#
|
|
10
|
-
#
|
|
11
|
-
#
|
|
12
|
-
#
|
|
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
|
-
#
|
|
15
|
-
#
|
|
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
|
-
# #
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
#
|
|
21
|
-
#
|
|
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
|
data/lib/caboose/version.rb
CHANGED