caboose-cms 0.5.200 → 0.5.201
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/google_spreadsheets.js +32 -0
- data/app/controllers/caboose/google_spreadsheets_controller.rb +16 -0
- data/app/models/caboose/block.rb +3 -1
- data/app/views/caboose/blocks/_google_spreadsheet_cell_value.html.erb +26 -0
- data/app/views/caboose/events/admin_edit.html.erb +1 -2
- data/app/views/caboose/events/admin_new.html.erb +1 -0
- data/config/routes.rb +6 -0
- data/lib/caboose/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWFhNjhhZjc5NGZjNDE4MWI2OGQzZTEyNWUwZTRkYTAyODllMzY5Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTMwNzVmY2RhZWFlMTI2YTMwNmU4YjU4OWNkYWQyOTU5Yzk5Yjc2Mg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OTI0Yjg1YWRjOGFmOGY2NjMzYzc3ODc0MGE0NjVmYjNkN2I2OGQxODNlZGI3
|
10
|
+
MGQ1ZTFmYWRkOGY5YTg5YjQyMDdkNjBhMmMxNmU5YTZkMzZlNjQyOWQ4MWNm
|
11
|
+
NmE4NjNhMDc3NTBmYjFlNTQ3YmI0NzUxOGU4MDA0ZTRjMDNiMjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ODdjM2MzNzM1MWQ2ZTQzYTUwZmRmZDE2NWQ4MzI5ZGZkOTJjODMyNTQ1ZDgy
|
14
|
+
MWRjYTkwNTE4ZjVjNWJiYjUyODI0ZWZhZmMzYzQ1NzMzZjI0MGE1ODAyMDJh
|
15
|
+
NGQ5ZDZmMWRjMGZmNjQ0MjVkYjBiMjY5MTQ4ZTgyNWM3ZGU3ZGY=
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
var google_spreadsheets = false;
|
3
|
+
|
4
|
+
function google_csv_data(spreadsheet_id, col, row)
|
5
|
+
{
|
6
|
+
var csv_array = false;
|
7
|
+
if (!google_spreadsheets) google_spreadsheets = {};
|
8
|
+
if (!google_spreadsheets[spreadsheet_id])
|
9
|
+
{
|
10
|
+
$.ajax({
|
11
|
+
url: "/google-spreadsheets/" + spreadsheet_id + "/csv",
|
12
|
+
type: 'get',
|
13
|
+
success: function(arr){ google_spreadsheets[spreadsheet_id] = arr; },
|
14
|
+
async: false
|
15
|
+
});
|
16
|
+
}
|
17
|
+
var arr = google_spreadsheets[spreadsheet_id];
|
18
|
+
var c = column_name_to_int(col);
|
19
|
+
return arr[parseInt(row)-1][c];
|
20
|
+
}
|
21
|
+
|
22
|
+
function column_name_to_int(col)
|
23
|
+
{
|
24
|
+
var c = 0;
|
25
|
+
if (col.length > 0)
|
26
|
+
{
|
27
|
+
var l = col.length;
|
28
|
+
for (var i=l-1; i >=0; i--)
|
29
|
+
c += Math.pow(25, l-i-1) * (col.charCodeAt(i) - 65);
|
30
|
+
}
|
31
|
+
return c;
|
32
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Caboose
|
4
|
+
class GoogleSpreadsheetsController < Caboose::ApplicationController
|
5
|
+
|
6
|
+
# GET /google-spreadsheets/:spreadsheet_id/csv
|
7
|
+
def csv_data
|
8
|
+
spreadsheet_id = params[:spreadsheet_id]
|
9
|
+
url = "https://docs.google.com/spreadsheets/d/#{spreadsheet_id}/export?format=csv&id=#{spreadsheet_id}&gid=0"
|
10
|
+
resp = HTTParty.get(url)
|
11
|
+
arr = CSV.parse(resp.body)
|
12
|
+
render :json => arr
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
data/app/models/caboose/block.rb
CHANGED
@@ -4,6 +4,7 @@ class Caboose::Block < ActiveRecord::Base
|
|
4
4
|
|
5
5
|
#after_find :get_master_value # TODO
|
6
6
|
|
7
|
+
belongs_to :post
|
7
8
|
belongs_to :page
|
8
9
|
belongs_to :block_type
|
9
10
|
belongs_to :parent, :foreign_key => 'parent_id', :class_name => 'Caboose::Block'
|
@@ -21,7 +22,8 @@ class Caboose::Block < ActiveRecord::Base
|
|
21
22
|
}
|
22
23
|
do_not_validate_attachment_file_type :image
|
23
24
|
|
24
|
-
attr_accessible :id,
|
25
|
+
attr_accessible :id,
|
26
|
+
:post_id,
|
25
27
|
:page_id,
|
26
28
|
:parent_id,
|
27
29
|
:block_type_id,
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%
|
2
|
+
spreadsheet_id = block.child_value('spreadsheet_id')
|
3
|
+
row = block.child_value('row')
|
4
|
+
col = block.child_value('column')
|
5
|
+
%>
|
6
|
+
<div id='block_<%= block.id %>'>
|
7
|
+
<% if editing && (spreadsheet_id.nil? || spreadsheet_id.strip.length == 0) %>
|
8
|
+
[Empty spreadsheet ID]
|
9
|
+
<% elsif editing && (row.nil? || row.strip.length == 0) %>
|
10
|
+
[Empty spreadsheet row]
|
11
|
+
<% elsif editing && (col.nil? || col.strip.length == 0) %>
|
12
|
+
[Empty spreadsheet column]
|
13
|
+
<% elsif !editing && spreadsheet_id && row && col %><% end %>
|
14
|
+
</div>
|
15
|
+
<% if spreadsheet_id && row && col %>
|
16
|
+
<%= content_for :js do %>
|
17
|
+
<%= javascript_include_tag('caboose/google_spreadsheets') %>
|
18
|
+
<script type='text/javascript'>
|
19
|
+
$(document).ready(function() {
|
20
|
+
var str = google_csv_data("<%= raw spreadsheet_id %>", "<%= raw col %>", <%= raw row %>);
|
21
|
+
$('#block_<%= block.id %>').html(str);
|
22
|
+
});
|
23
|
+
</script>
|
24
|
+
<% end %>
|
25
|
+
<% end %>
|
26
|
+
|
@@ -54,7 +54,6 @@ g = @event.calendar_event_group
|
|
54
54
|
|
55
55
|
<% content_for :caboose_js do %>
|
56
56
|
<%= javascript_include_tag "caboose/model/all" %>
|
57
|
-
<%= javascript_include_tag "jquery-ui/datepicker" %>
|
58
57
|
<script type="text/javascript">
|
59
58
|
|
60
59
|
var modal = false;
|
@@ -79,7 +78,7 @@ $(document).ready(function() {
|
|
79
78
|
{ name: 'all_day' , nice_name: 'All day' , type: 'checkbox' , value: <%= raw e.all_day ? 1 : 0 %>, width: 100, after_update: after_all_day_update },
|
80
79
|
{ name: 'repeats' , nice_name: 'Repeats' , type: 'checkbox' , value: <%= raw e.repeats ? 1 : 0 %>, width: 100, after_update: after_repeats_update }
|
81
80
|
],
|
82
|
-
on_load: function() { modal.autosize(); }
|
81
|
+
on_load: function() { modal.autosize(); console.log('Testing'); }
|
83
82
|
});
|
84
83
|
new ModelBinder({
|
85
84
|
name: 'CalendarEventGroup',
|
data/config/routes.rb
CHANGED
@@ -343,6 +343,12 @@ Caboose::Engine.routes.draw do
|
|
343
343
|
post "admin/posts" => "posts#admin_add"
|
344
344
|
delete "admin/posts/:id" => "posts#admin_delete"
|
345
345
|
|
346
|
+
#=============================================================================
|
347
|
+
# Google Spreadsheets
|
348
|
+
#=============================================================================
|
349
|
+
|
350
|
+
get "google-spreadsheets/:spreadsheet_id/csv" => "google_spreadsheets#csv_data"
|
351
|
+
|
346
352
|
#=============================================================================
|
347
353
|
# Calendar
|
348
354
|
#=============================================================================
|
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.5.
|
4
|
+
version: 0.5.201
|
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-04-
|
11
|
+
date: 2015-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -415,6 +415,7 @@ files:
|
|
415
415
|
- app/assets/javascripts/caboose/checkout_payment.js
|
416
416
|
- app/assets/javascripts/caboose/checkout_shipping.js
|
417
417
|
- app/assets/javascripts/caboose/date_format.js
|
418
|
+
- app/assets/javascripts/caboose/google_spreadsheets.js
|
418
419
|
- app/assets/javascripts/caboose/imageZoom.js
|
419
420
|
- app/assets/javascripts/caboose/jquery.datetimepicker.js
|
420
421
|
- app/assets/javascripts/caboose/jquery.detect.js
|
@@ -530,6 +531,7 @@ files:
|
|
530
531
|
- app/controllers/caboose/event_groups_controller.rb
|
531
532
|
- app/controllers/caboose/events_controller.rb
|
532
533
|
- app/controllers/caboose/gift_cards_controller.rb
|
534
|
+
- app/controllers/caboose/google_spreadsheets_controller.rb
|
533
535
|
- app/controllers/caboose/images_controller.rb
|
534
536
|
- app/controllers/caboose/line_items_controller.rb
|
535
537
|
- app/controllers/caboose/login_controller.rb
|
@@ -684,6 +686,7 @@ files:
|
|
684
686
|
- app/views/caboose/blocks/_checkbox.html.erb
|
685
687
|
- app/views/caboose/blocks/_controller_view_content.html.erb
|
686
688
|
- app/views/caboose/blocks/_file.html.erb
|
689
|
+
- app/views/caboose/blocks/_google_spreadsheet_cell_value.html.erb
|
687
690
|
- app/views/caboose/blocks/_heading.html.erb
|
688
691
|
- app/views/caboose/blocks/_html.html.erb
|
689
692
|
- app/views/caboose/blocks/_image.html.erb
|