caboose-cms 0.7.79 → 0.7.80
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 +4 -4
- data/app/assets/javascripts/caboose/admin_media_index.js +56 -10
- data/app/controllers/caboose/media_categories_controller.rb +15 -0
- data/app/controllers/caboose/media_controller.rb +3 -2
- data/app/controllers/caboose/settings_controller.rb +2 -1
- data/app/controllers/caboose/social_controller.rb +51 -0
- data/app/models/caboose/media.rb +2 -1
- data/app/models/caboose/media_category.rb +1 -1
- data/app/models/caboose/schema.rb +3 -0
- data/app/models/caboose/social_config.rb +2 -0
- data/app/views/caboose/fonts/admin_index.html.erb +1 -1
- data/app/views/caboose/posts/admin_index.html.erb +2 -2
- data/app/views/caboose/roles/edit.html.erb +3 -3
- data/app/views/caboose/settings/index.html.erb +1 -1
- data/app/views/caboose/social/admin_edit.html.erb +37 -1
- data/app/views/caboose/users/admin_edit_password.html.erb +1 -1
- data/config/routes.rb +3 -0
- data/lib/caboose/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bd2b52001e41aff8f4b36f2ddb73f81a7413475
|
4
|
+
data.tar.gz: 5306fa69c2584768d96091eea8d8447c81f0e911
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d3adcda361933fd03b6947823d55077b4c09f9279f9a0d89995dbd4cee470d85799aee12e5f9b9b0773ca337e74a97b242920272ffedf4d4d9387d77b41a584
|
7
|
+
data.tar.gz: 589cece85814a30dac022c3dd957003a6b631799cc3982c5b90106f53423ab45d9d02ed7d7a23365b883c82a549089a2170582bf90d4b7efe9a65af0ca88432d
|
@@ -29,6 +29,8 @@ MediaController.prototype = {
|
|
29
29
|
.append($('<a/>').attr('href', '#').html('Upload').click(function(e) { e.preventDefault(); that.toggle_uploader(); }))
|
30
30
|
.append(' | ')
|
31
31
|
.append($('<a/>').attr('href', '#').html('Select All').click(function(e) { e.preventDefault(); that.select_all_media(); }))
|
32
|
+
.append(' | ')
|
33
|
+
.append($('<a/>').attr('href', '#').attr('id', 'sort-btn').html('Sort').click(function(e) { e.preventDefault(); that.sort_media(); }))
|
32
34
|
)
|
33
35
|
.append($('<div/>').attr('id', 'the_uploader'));
|
34
36
|
that.refresh();
|
@@ -41,6 +43,56 @@ MediaController.prototype = {
|
|
41
43
|
that.refresh_media();
|
42
44
|
that.print_controls();
|
43
45
|
},
|
46
|
+
|
47
|
+
change_sort_order: function(list) {
|
48
|
+
var that = this;
|
49
|
+
// console.log(list.toString());
|
50
|
+
$.ajax({
|
51
|
+
url: '/admin/media-categories/' + that.cat_id + '/sort-order',
|
52
|
+
type: 'put',
|
53
|
+
data: {
|
54
|
+
sort: list
|
55
|
+
},
|
56
|
+
success: function(resp) {
|
57
|
+
console.log("success");
|
58
|
+
}
|
59
|
+
});
|
60
|
+
},
|
61
|
+
|
62
|
+
sort_media: function() {
|
63
|
+
var that = this;
|
64
|
+
var btn = $("#sort-btn");
|
65
|
+
if ( btn.text() == "Sort" ) {
|
66
|
+
$("li.media").draggable("disable");
|
67
|
+
$("#sort-btn").text("Done Sorting");
|
68
|
+
$("li.media").css("cursor","move");
|
69
|
+
$("#media ul").sortable({
|
70
|
+
update: function(event, ui) {
|
71
|
+
var index = ui.item.index();
|
72
|
+
var start = ui.item.data('start');
|
73
|
+
var media_id = ui.item.attr("id").replace("media","");
|
74
|
+
var sort_list = [];
|
75
|
+
for(var i=1;i <= $("#media ul li").length; i++) {
|
76
|
+
// console.log(i);
|
77
|
+
var m = $('#media ul li:nth-child(' + i + ')').attr('id').replace("media","");
|
78
|
+
// if (m) {
|
79
|
+
sort_list.push(m);
|
80
|
+
// }
|
81
|
+
}
|
82
|
+
that.change_sort_order(sort_list);
|
83
|
+
}
|
84
|
+
});
|
85
|
+
$("#media ul").sortable('enable');
|
86
|
+
$("#media ul li").css("border-color","#98FF97");
|
87
|
+
}
|
88
|
+
else if ( btn.text() == "Done Sorting") {
|
89
|
+
$("#media ul").sortable("disable");
|
90
|
+
$("li.media").draggable("enable");
|
91
|
+
$("li.media").css("cursor","default");
|
92
|
+
$("#sort-btn").text("Sort");
|
93
|
+
$("#media ul li").css("border-color","#666");
|
94
|
+
}
|
95
|
+
},
|
44
96
|
|
45
97
|
toggle_uploader: function()
|
46
98
|
{
|
@@ -299,7 +351,8 @@ MediaController.prototype = {
|
|
299
351
|
revert: 'invalid',
|
300
352
|
start: function() { $(this).data("origPosition", $(this).position()); }
|
301
353
|
});
|
302
|
-
});
|
354
|
+
});
|
355
|
+
// $("#media ul").sortable();
|
303
356
|
},
|
304
357
|
|
305
358
|
//============================================================================
|
@@ -320,14 +373,6 @@ MediaController.prototype = {
|
|
320
373
|
}
|
321
374
|
|
322
375
|
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
376
|
},
|
332
377
|
|
333
378
|
select_all_media: function()
|
@@ -422,7 +467,8 @@ MediaController.prototype = {
|
|
422
467
|
var that = this;
|
423
468
|
that.cat_id = cat_id;
|
424
469
|
that.print_categories();
|
425
|
-
that.refresh_media();
|
470
|
+
that.refresh_media();
|
471
|
+
$("#sort-btn").text("Sort");
|
426
472
|
},
|
427
473
|
|
428
474
|
add_category: function(name)
|
@@ -32,6 +32,21 @@ module Caboose
|
|
32
32
|
render :json => Caboose::MediaCategory.tree_hash(@site.id)
|
33
33
|
end
|
34
34
|
|
35
|
+
# PUT /admin/media-categories/:id/sort-order
|
36
|
+
def admin_update_sort_order
|
37
|
+
return unless user_is_allowed('mediacategories', 'edit')
|
38
|
+
resp = Caboose::StdClass.new
|
39
|
+
mc = MediaCategory.find(params[:id])
|
40
|
+
sort = params[:sort].to_a
|
41
|
+
sort.each_with_index do |s,i|
|
42
|
+
m = Media.where(:id => s.to_i).first
|
43
|
+
m.sort_order = i
|
44
|
+
m.save
|
45
|
+
end
|
46
|
+
resp.success = true
|
47
|
+
render :json => resp
|
48
|
+
end
|
49
|
+
|
35
50
|
# POST /admin/media-categories
|
36
51
|
def admin_add
|
37
52
|
return unless user_is_allowed('mediacategories', 'add')
|
@@ -44,7 +44,6 @@ module Caboose
|
|
44
44
|
def admin_json
|
45
45
|
return if !user_is_allowed('media', 'view')
|
46
46
|
render :json => false and return if @site.nil?
|
47
|
-
|
48
47
|
id = params[:media_category_id]
|
49
48
|
cat = id ? MediaCategory.find(id) : MediaCategory.top_category(@site.id)
|
50
49
|
render :json => cat.api_hash
|
@@ -93,6 +92,7 @@ module Caboose
|
|
93
92
|
case name
|
94
93
|
when 'name' then m.name = value
|
95
94
|
when 'description' then m.description = value
|
95
|
+
when 'sort_order' then m.sort_order = value
|
96
96
|
when 'image_url' then
|
97
97
|
m.processed = false
|
98
98
|
m.delay.download_image_from_url(value)
|
@@ -175,7 +175,8 @@ module Caboose
|
|
175
175
|
end
|
176
176
|
m = Media.where(:media_category_id => media_category_id, :original_name => original_name, :name => name).first
|
177
177
|
if m.nil?
|
178
|
-
|
178
|
+
max = Media.where(:media_category_id => media_category_id).maximum(:sort_order)
|
179
|
+
m = Media.create(:media_category_id => media_category_id, :sort_order => (max ? (max + 1) : 0), :original_name => original_name, :name => name, :image_content_type => image_content_type, :file_content_type => file_content_type, :processed => false)
|
179
180
|
end
|
180
181
|
p = Product.where(:media_category_id => media_category_id).last
|
181
182
|
if p
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
1
3
|
module Caboose
|
2
4
|
class SocialController < ApplicationController
|
3
5
|
layout 'caboose/admin'
|
@@ -43,6 +45,55 @@ module Caboose
|
|
43
45
|
resp.success = save && sc.save
|
44
46
|
render :json => resp
|
45
47
|
end
|
48
|
+
|
49
|
+
|
50
|
+
# GET /api/instagram
|
51
|
+
def authorize_instagram
|
52
|
+
code = params[:code]
|
53
|
+
site_id = params[:state]
|
54
|
+
site = Site.where(:id => site_id).first
|
55
|
+
master_site = Site.where(:is_master => true).first
|
56
|
+
master_domain = master_site ? (master_site.primary_domain ? master_site.primary_domain.domain : 'caboosecms.com') : 'caboosecms.com'
|
57
|
+
domain = site ? (site.primary_domain ? site.primary_domain.domain : 'www.caboosecms.com') : 'www.caboosecms.com'
|
58
|
+
resp = HTTParty.post(
|
59
|
+
'https://api.instagram.com/oauth/access_token',
|
60
|
+
:body => {
|
61
|
+
:client_id => 'bac12987b6cb4262a004f3ffc388accc',
|
62
|
+
:client_secret => 'ede277a5b2df47fe8efcb69a9fac8e07',
|
63
|
+
:grant_type => 'authorization_code',
|
64
|
+
:redirect_uri => 'http://' + master_domain + '/api/instagram',
|
65
|
+
:code => code
|
66
|
+
}
|
67
|
+
)
|
68
|
+
if resp
|
69
|
+
if resp['code'] && (resp['code'] == 400 || resp['code'] = '400')
|
70
|
+
redirect_to 'http://' + domain + '/admin/social?instagram=fail'
|
71
|
+
elsif !resp['access_token'].blank?
|
72
|
+
sc = SocialConfig.where(:site_id => site_id).first
|
73
|
+
sc.instagram_access_token = resp['access_token']
|
74
|
+
sc.instagram_user_id = resp['user']['id']
|
75
|
+
sc.instagram_username = resp['user']['username']
|
76
|
+
sc.save
|
77
|
+
redirect_to 'http://' + domain + '/admin/social?instagram=success'
|
78
|
+
end
|
79
|
+
else
|
80
|
+
redirect_to 'http://' + domain + '/admin/social?instagram=fail'
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# DELETE /api/instagram
|
85
|
+
def deauthorize_instagram
|
86
|
+
resp = StdClass.new
|
87
|
+
site_id = params[:site_id]
|
88
|
+
site = Site.where(:id => site_id).first
|
89
|
+
sc = SocialConfig.where(:site_id => site.id).first
|
90
|
+
sc.instagram_username = nil
|
91
|
+
sc.instagram_user_id = nil
|
92
|
+
sc.instagram_access_token = nil
|
93
|
+
sc.save
|
94
|
+
resp.success = true
|
95
|
+
render :json => resp
|
96
|
+
end
|
46
97
|
|
47
98
|
end
|
48
99
|
end
|
data/app/models/caboose/media.rb
CHANGED
@@ -3,7 +3,7 @@ class Caboose::MediaCategory < ActiveRecord::Base
|
|
3
3
|
self.table_name = "media_categories"
|
4
4
|
belongs_to :parent, :class_name => 'Caboose::MediaCategory'
|
5
5
|
has_many :children, :class_name => 'Caboose::MediaCategory', :foreign_key => 'parent_id', :order => 'name'
|
6
|
-
has_many :media, :class_name => 'Caboose::Media', :order => '
|
6
|
+
has_many :media, :class_name => 'Caboose::Media', :order => 'sort_order'
|
7
7
|
attr_accessible :id, :site_id, :parent_id, :name
|
8
8
|
|
9
9
|
def self.top_category(site_id)
|
@@ -355,6 +355,7 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
355
355
|
[ :media_category_id , :integer ],
|
356
356
|
[ :name , :string ],
|
357
357
|
[ :description , :text ],
|
358
|
+
[ :sort_order , :integer ],
|
358
359
|
[ :original_name , :string ],
|
359
360
|
[ :image , :attachment ],
|
360
361
|
[ :file , :attachment ],
|
@@ -709,6 +710,8 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
709
710
|
[ :facebook_page_id , :string ],
|
710
711
|
[ :twitter_username , :string ],
|
711
712
|
[ :instagram_username , :string ],
|
713
|
+
[ :instagram_user_id , :string ],
|
714
|
+
[ :instagram_access_token , :text ],
|
712
715
|
[ :youtube_url , :string ],
|
713
716
|
[ :pinterest_url , :string ],
|
714
717
|
[ :vimeo_url , :string ],
|
@@ -8,7 +8,7 @@
|
|
8
8
|
'id' => 'ID #',
|
9
9
|
'published' => 'Published',
|
10
10
|
'title' => 'Title',
|
11
|
-
|
11
|
+
# 'body' => 'Body',
|
12
12
|
'created_at' => 'Date Created'
|
13
13
|
})
|
14
14
|
%>
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<td><%= raw p.id %></td>
|
19
19
|
<td><%= p.published ? "Yes" : "No" %></td>
|
20
20
|
<td><%= raw p.title %></td>
|
21
|
-
|
21
|
+
|
22
22
|
<td><%= p.created_at.strftime("%m/%d/%Y") %></td>
|
23
23
|
</tr>
|
24
24
|
<% end %>
|
@@ -57,9 +57,9 @@ $(document).ready(function() {
|
|
57
57
|
new ModelBinder({
|
58
58
|
name: 'Role',
|
59
59
|
id: <%= @role.id %>,
|
60
|
-
listing_url: '
|
61
|
-
update_url: '
|
62
|
-
delete_url: '
|
60
|
+
listing_url: '/admin/roles',
|
61
|
+
update_url: '/admin/roles/<%= @role.id %>',
|
62
|
+
delete_url: '/admin/roles/<%= @role.id %>',
|
63
63
|
authenticity_token: '<%= form_authenticity_token %>',
|
64
64
|
attributes: [
|
65
65
|
{ name: 'parent_id' , nice_name: 'Parent' , type: 'select', value: <%= @role.parent_id %>, text: "<%= @role.parent.nil? ? '[No parent]' : @role.parent.name %>", show_controls: true, loading_message: 'Getting roles...', options_url: '/admin/roles/options', width: 590, message: 'message' },
|
@@ -18,7 +18,7 @@
|
|
18
18
|
%>
|
19
19
|
</tr>
|
20
20
|
<% @settings.each do |setting| %>
|
21
|
-
<tr onclick="window.location='/admin/settings/<%= setting.id
|
21
|
+
<tr onclick="window.location='/admin/settings/<%= setting.id %>';">
|
22
22
|
<td><%= setting.name %></td>
|
23
23
|
<td><%= setting.value %></td>
|
24
24
|
</tr>
|
@@ -1,12 +1,27 @@
|
|
1
1
|
<%
|
2
2
|
sc = @social_config
|
3
|
+
ms = Caboose::Site.where(:is_master => true).first
|
4
|
+
domain = ms ? (ms.primary_domain ? ms.primary_domain.domain : 'www.caboosecms.com') : 'www.caboosecms.com'
|
3
5
|
%>
|
4
6
|
<h1>Social Media Config</h1>
|
5
7
|
|
6
8
|
<p>Find your Facebook page ID <a href="http://findmyfacebookid.com/" target="_blank">here</a>.</p>
|
7
9
|
<p><div id="socialconfig_<%= sc.id %>_facebook_page_id" ></div></p>
|
8
10
|
<p><div id="socialconfig_<%= sc.id %>_twitter_username" ></div></p>
|
9
|
-
<p><div id="socialconfig_<%= sc.id %>_instagram_username" ></div
|
11
|
+
<p><div id="socialconfig_<%= sc.id %>_instagram_username" ></div>
|
12
|
+
<% if sc.instagram_access_token %>
|
13
|
+
<p style="margin-top:4px;width:518px;font-size:14px;color:green;text-align:right;">
|
14
|
+
Authorized
|
15
|
+
<a href="#" id="deauthorize-instagram" style="color:#949494;font-size:12px;margin-left:6px;">Deauthorize</a>
|
16
|
+
</p><% end %>
|
17
|
+
</p>
|
18
|
+
<% if !sc.instagram_access_token %>
|
19
|
+
<p style="margin-top:2px;width:518px;font-size:13px;color:#000;text-align:right;"><a href="https://api.instagram.com/oauth/authorize/?client_id=bac12987b6cb4262a004f3ffc388accc&redirect_uri=http://<%= domain %>/api/instagram&response_type=code&state=<%= @site.id %>">Authorize Instagram</a> (you must authorize to show posts on this website)
|
20
|
+
<% if params[:instagram] && params[:instagram] == 'fail' %>
|
21
|
+
<br /><span style="color:red;">Instagram login failed. Please try again.</span>
|
22
|
+
<% end %>
|
23
|
+
</p>
|
24
|
+
<% end %>
|
10
25
|
<p><div id="socialconfig_<%= sc.id %>_youtube_url" ></div></p>
|
11
26
|
<p><div id="socialconfig_<%= sc.id %>_pinterest_url" ></div></p>
|
12
27
|
<p><div id="socialconfig_<%= sc.id %>_vimeo_url" ></div></p>
|
@@ -19,11 +34,32 @@ sc = @social_config
|
|
19
34
|
|
20
35
|
<div id='message'></div>
|
21
36
|
|
37
|
+
<% content_for :caboose_css do %>
|
38
|
+
<style type="text/css">
|
39
|
+
#deauthorize-instagram:hover {
|
40
|
+
color: red !important;
|
41
|
+
}
|
42
|
+
</style>
|
43
|
+
<% end %>
|
44
|
+
|
22
45
|
<% content_for :caboose_js do %>
|
23
46
|
<%= javascript_include_tag "caboose/model/all" %>
|
24
47
|
<script type="text/javascript">
|
25
48
|
|
26
49
|
$(document).ready(function() {
|
50
|
+
$("#deauthorize-instagram").click(function(event) {
|
51
|
+
event.preventDefault();
|
52
|
+
$.ajax({
|
53
|
+
url: "/api/instagram",
|
54
|
+
type: 'delete',
|
55
|
+
data: {
|
56
|
+
site_id: <%= @site.id %>
|
57
|
+
},
|
58
|
+
success: function(data) {
|
59
|
+
document.location.reload(true);
|
60
|
+
}
|
61
|
+
});
|
62
|
+
});
|
27
63
|
|
28
64
|
new ModelBinder({
|
29
65
|
name: 'SocialConfig',
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<p><input type='password' name='password2' id='password2' value="" placeholder='Confirm password' /></p>
|
7
7
|
<div id='message'></div>
|
8
8
|
<p>
|
9
|
-
<input type='button' value='Back' onclick="window.location='/admin/users/<%= @edituser.id
|
9
|
+
<input type='button' value='Back' onclick="window.location='/admin/users/<%= @edituser.id %>';" />
|
10
10
|
<input type='button' value='Update Password' onclick="update_password();" />
|
11
11
|
</p>
|
12
12
|
|
data/config/routes.rb
CHANGED
@@ -246,6 +246,7 @@ Caboose::Engine.routes.draw do
|
|
246
246
|
get "/admin/media-categories/tree" => "media_categories#admin_tree"
|
247
247
|
post "/admin/media-categories" => "media_categories#admin_add"
|
248
248
|
post "/admin/media-categories/:id/attach" => "media_categories#admin_attach"
|
249
|
+
put "/admin/media-categories/:id/sort-order" => "media_categories#admin_update_sort_order"
|
249
250
|
put "/admin/media-categories/:id" => "media_categories#admin_update"
|
250
251
|
delete "/admin/media-categories/:id" => "media_categories#admin_delete"
|
251
252
|
|
@@ -751,6 +752,8 @@ Caboose::Engine.routes.draw do
|
|
751
752
|
#=============================================================================
|
752
753
|
|
753
754
|
get "/api/products" => "products#api_index"
|
755
|
+
get "/api/instagram" => "social#authorize_instagram"
|
756
|
+
delete "/api/instagram" => "social#deauthorize_instagram"
|
754
757
|
get "/api/products/:id" => "products#api_details"
|
755
758
|
get "/api/products/:id/variants" => "products#api_variants"
|
756
759
|
get "caboose/block-types" => "block_types#api_block_type_list"
|
data/lib/caboose/version.rb
CHANGED
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.7.
|
4
|
+
version: 0.7.80
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -1237,7 +1237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
1237
1237
|
version: '0'
|
1238
1238
|
requirements: []
|
1239
1239
|
rubyforge_project:
|
1240
|
-
rubygems_version: 2.
|
1240
|
+
rubygems_version: 2.5.1
|
1241
1241
|
signing_key:
|
1242
1242
|
specification_version: 4
|
1243
1243
|
summary: CMS built on rails.
|