caboose-cms 0.5.215 → 0.5.216
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/controllers/caboose/blocks_controller.rb +14 -0
- data/app/controllers/caboose/users_controller.rb +3 -1
- data/app/models/caboose/block.rb +47 -3
- data/app/models/caboose/schema.rb +12 -10
- data/lib/caboose/version.rb +1 -1
- data/lib/caboose.rb +12 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWU3YzQzNmViZGE1NjI4ZjQ2MmRiZmU5ODFhMTVlNTU4ZWE2MzY1OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YWJjZmNjYWViYWZhZjI0OWJlY2FiNDc4OTExY2Q1ZjRjNjJkZjQ0MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NmVlNmI2MmQ4NTI0ZjA3ODc2ZWVkNTA3YWEwMWJlOGFlYmRhYjVmMzM2OWZl
|
10
|
+
ZmJkYWUyNzg4N2ZiNWU2ZjAzNzE1OWNhYzE3MTUwNWM3MWM1MGY1ZDFjZDdh
|
11
|
+
ZTE2ZjU3MTNiZTQzMzRjNTQ2MDIyMDE5YjkwNmZjYzU1NmQ2Nzg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2MyYmEyYzE4Y2QwZjRkOWY0NGMwODM3OTZiYWE4NDJiZGMxNGZmZTcyYzMw
|
14
|
+
MTE3MDRmMWIyMmY3ODliM2Y2ZTUzZWRhNmIwODY2MTFlOTE4MWIyYTY5NjQw
|
15
|
+
YjdjMTFhNWE2ZmQyNmE1OTNjMzc4ODY4YTk5ZjMyOTc0ZDg2NGQ=
|
@@ -371,6 +371,13 @@ module Caboose
|
|
371
371
|
resp = StdClass.new({'attributes' => {}})
|
372
372
|
b = Block.find(params[:id])
|
373
373
|
b.image = params[:value]
|
374
|
+
|
375
|
+
str = params[:value].original_filename
|
376
|
+
arr = str.split('.')
|
377
|
+
arr.pop
|
378
|
+
str = arr.join('.')
|
379
|
+
b.image_upload_name = b.unique_image_upload_name(str)
|
380
|
+
|
374
381
|
b.save
|
375
382
|
resp.success = true
|
376
383
|
resp.attributes = { 'value' => { 'value' => b.image.url(:tiny) }}
|
@@ -386,6 +393,13 @@ module Caboose
|
|
386
393
|
resp = StdClass.new({'attributes' => {}})
|
387
394
|
b = Block.find(params[:id])
|
388
395
|
b.file = params[:value]
|
396
|
+
|
397
|
+
str = params[:value].original_filename
|
398
|
+
arr = str.split('.')
|
399
|
+
arr.pop
|
400
|
+
str = arr.join('.')
|
401
|
+
b.file_upload_name = b.unique_file_upload_name(str)
|
402
|
+
|
389
403
|
b.save
|
390
404
|
resp.success = true
|
391
405
|
resp.attributes = { 'value' => { 'value' => b.file.url }}
|
@@ -116,7 +116,8 @@ module Caboose
|
|
116
116
|
:last_name => last_name,
|
117
117
|
:email => email,
|
118
118
|
:username => username,
|
119
|
-
:password => Digest::SHA1.hexdigest(Caboose::salt + password)
|
119
|
+
:password => Digest::SHA1.hexdigest(Caboose::salt + password),
|
120
|
+
:site_id => @site.id
|
120
121
|
)
|
121
122
|
good_count = good_count + 1
|
122
123
|
end
|
@@ -142,6 +143,7 @@ module Caboose
|
|
142
143
|
|
143
144
|
user = User.new()
|
144
145
|
user.email = params[:email] ? params[:email].strip.downcase : nil
|
146
|
+
user.site_id = @site.id
|
145
147
|
|
146
148
|
if user.email.length == 0
|
147
149
|
resp.error = "Please enter a valid email address."
|
data/app/models/caboose/block.rb
CHANGED
@@ -9,10 +9,10 @@ class Caboose::Block < ActiveRecord::Base
|
|
9
9
|
belongs_to :block_type
|
10
10
|
belongs_to :parent, :foreign_key => 'parent_id', :class_name => 'Caboose::Block'
|
11
11
|
has_many :children, :foreign_key => 'parent_id', :class_name => 'Caboose::Block', :dependent => :delete_all, :order => 'sort_order'
|
12
|
-
has_attached_file :file, :path => ':path_prefixuploads/:
|
13
|
-
do_not_validate_attachment_file_type :file
|
12
|
+
has_attached_file :file, :path => ':path_prefixuploads/:block_file_upload_name.:extension'
|
13
|
+
do_not_validate_attachment_file_type :file
|
14
14
|
has_attached_file :image,
|
15
|
-
:path => ':path_prefixuploads/:
|
15
|
+
:path => ':path_prefixuploads/:block_image_upload_name_:style.:extension',
|
16
16
|
:default_url => "http://placehold.it/300x300",
|
17
17
|
:styles => {
|
18
18
|
:tiny => '160x120>',
|
@@ -445,5 +445,49 @@ class Caboose::Block < ActiveRecord::Base
|
|
445
445
|
end
|
446
446
|
return true
|
447
447
|
end
|
448
|
+
|
449
|
+
def unique_file_upload_name(str)
|
450
|
+
base = str.downcase.gsub(' ', '-').gsub(/[^\w-]/, '')
|
451
|
+
str = "#{base}"
|
452
|
+
i = 1
|
453
|
+
while Caboose::Block.where("id <> ? and file_upload_name = ?", self.id, str).exists? && i < 100 do
|
454
|
+
str = "#{base}-#{i}"
|
455
|
+
i = i + 1
|
456
|
+
end
|
457
|
+
return str
|
458
|
+
end
|
459
|
+
|
460
|
+
def unique_image_upload_name(str)
|
461
|
+
base = str.downcase.gsub(' ', '-').gsub(/[^\w-]/, '')
|
462
|
+
str = "#{base}"
|
463
|
+
i = 1
|
464
|
+
while Caboose::Block.where("id <> ? and image_upload_name = ?", self.id, str).exists? && i < 100 do
|
465
|
+
str = "#{base}-#{i}"
|
466
|
+
i = i + 1
|
467
|
+
end
|
468
|
+
return str
|
469
|
+
end
|
470
|
+
|
471
|
+
def self.unique_file_upload_name(str)
|
472
|
+
base = str.downcase.gsub(' ', '-').gsub(/[^\w-]/, '')
|
473
|
+
str = "#{base}"
|
474
|
+
i = 1
|
475
|
+
while Caboose::Block.where("file_upload_name = ?", str).exists? && i < 100 do
|
476
|
+
str = "#{base}-#{i}"
|
477
|
+
i = i + 1
|
478
|
+
end
|
479
|
+
return str
|
480
|
+
end
|
481
|
+
|
482
|
+
def self.unique_image_upload_name(str)
|
483
|
+
base = str.downcase.gsub(' ', '-').gsub(/[^\w-]/, '')
|
484
|
+
str = "#{base}"
|
485
|
+
i = 1
|
486
|
+
while Caboose::Block.where("image_upload_name = ?", str).exists? && i < 100 do
|
487
|
+
str = "#{base}-#{i}"
|
488
|
+
i = i + 1
|
489
|
+
end
|
490
|
+
return str
|
491
|
+
end
|
448
492
|
|
449
493
|
end
|
@@ -146,17 +146,19 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
146
146
|
[ :extension , :string ]
|
147
147
|
],
|
148
148
|
Caboose::Block => [
|
149
|
-
[ :page_id , :integer
|
150
|
-
[ :post_id , :integer
|
151
|
-
[ :parent_id , :integer
|
152
|
-
[ :block_type_id , :integer
|
153
|
-
[ :sort_order , :integer
|
154
|
-
[ :constrain , :boolean
|
155
|
-
[ :full_width , :boolean
|
156
|
-
[ :name , :string
|
157
|
-
[ :value , :text
|
149
|
+
[ :page_id , :integer ],
|
150
|
+
[ :post_id , :integer ],
|
151
|
+
[ :parent_id , :integer ],
|
152
|
+
[ :block_type_id , :integer ],
|
153
|
+
[ :sort_order , :integer , { :default => 0 }],
|
154
|
+
[ :constrain , :boolean , { :default => false }],
|
155
|
+
[ :full_width , :boolean , { :default => false }],
|
156
|
+
[ :name , :string ],
|
157
|
+
[ :value , :text ],
|
158
158
|
[ :file , :attachment ],
|
159
|
-
[ :
|
159
|
+
[ :file_upload_name , :string ],
|
160
|
+
[ :image , :attachment ],
|
161
|
+
[ :image_upload_name , :string ]
|
160
162
|
],
|
161
163
|
Caboose::BlockType => [
|
162
164
|
[ :parent_id , :integer ],
|
data/lib/caboose/version.rb
CHANGED
data/lib/caboose.rb
CHANGED
@@ -141,3 +141,15 @@ Paperclip.interpolates :model_url do |attachment, style|
|
|
141
141
|
# Otherwise S3
|
142
142
|
return "#{Caboose::cdn_domain}/#{attachment.path}"
|
143
143
|
end
|
144
|
+
|
145
|
+
Paperclip.interpolates :block_file_upload_name do |attachment, style|
|
146
|
+
b = attachment.instance
|
147
|
+
return b.id if b.file_upload_name.nil? || b.file_upload_name.strip.length == 0
|
148
|
+
return b.file_upload_name
|
149
|
+
end
|
150
|
+
|
151
|
+
Paperclip.interpolates :block_image_upload_name do |attachment, style|
|
152
|
+
b = attachment.instance
|
153
|
+
return b.id if b.image_upload_name.nil? || b.image_upload_name.strip.length == 0
|
154
|
+
return b.image_upload_name
|
155
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: caboose-cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.216
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|