caboose-cms 0.4.127 → 0.4.128
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/pages_controller.rb +9 -0
- data/app/models/caboose/page.rb +1 -0
- data/app/models/caboose/page_tag.rb +5 -0
- data/app/models/caboose/schema.rb +7 -21
- data/app/models/caboose/user.rb +1 -1
- data/app/views/caboose/blocks/_image.html.erb +11 -11
- data/app/views/caboose/pages/admin_edit_general.html.erb +14 -9
- data/app/views/caboose/pages/admin_edit_seo.html.erb +26 -1
- data/lib/caboose.rb +6 -6
- data/lib/caboose/version.rb +1 -1
- data/lib/tasks/caboose.rake +0 -14
- metadata +3 -5
- data/app/models/caboose/timezone.rb +0 -75
- data/app/models/caboose/timezone_abbreviation.rb +0 -5
- data/app/models/caboose/timezone_offset.rb +0 -5
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NWYxNmY0YjZjYTJkMzBlMGIzNjE0NWI1ZGJlMjU0Njg1M2FmZDc1NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzU3ODgzMjM1MjQwNDQ5NTBkZDY2MjlkOWNjNTVhMmVlNjhhMGNjYQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MmJiZWExOTg4YjdjNWYyNzk3YjgwYTMyMzQ2YmRmMmIwYTBhYWNjYzg2Yjdi
|
10
|
+
MTkzODE2MGMyM2Q2ZDk0ZjY1ZTE4NzIyNTQxZTQzNDhiN2I3M2VjMDVlZWIw
|
11
|
+
YmM4MDk4ZDlhMzYxNWRiMDhjMGIzNGIzNzUzMWNhY2M3OGQ0YWQ=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OTlkZWVlZjYyNTQ4ZWZjMWVmZDUzNmQxYjkwYWU5YjdlODkzZjJlMWE2M2Fm
|
14
|
+
NjExMTBhM2RhNDRhNGY4MDlkMTZlZjljNzUwNWY1ZjU0MzUwYTk3ZTJiNTk4
|
15
|
+
MTM5NzM2ZjMwYTkzMjc4ZDgzNmIzODdiMGJhZTcxNjFiYzQ5MmM=
|
@@ -423,6 +423,15 @@ module Caboose
|
|
423
423
|
Page.update_authorized_for_action(page.id, 'edit', value)
|
424
424
|
when 'approvers'
|
425
425
|
Page.update_authorized_for_action(page.id, 'approve', value)
|
426
|
+
when 'tags'
|
427
|
+
current_tags = page.page_tags.collect{ |t| t.tag }
|
428
|
+
new_tags = value.split(',').collect{ |v| v.strip.downcase }.reject{ |t| t.nil? || t.strip.length == 0 }
|
429
|
+
|
430
|
+
# Delete the tags not in new_tags
|
431
|
+
current_tags.each{ |t| PageTag.where(:page_id => page.id, :tag => t).destroy_all if !new_tags.include?(t) }
|
432
|
+
|
433
|
+
# Add any new tags not in current_tags
|
434
|
+
new_tags.each{ |t| PageTag.create(:page_id => page.id, :tag => t) if !current_tags.include?(t) }
|
426
435
|
end
|
427
436
|
end
|
428
437
|
|
data/app/models/caboose/page.rb
CHANGED
@@ -7,6 +7,7 @@ class Caboose::Page < ActiveRecord::Base
|
|
7
7
|
has_many :children, :class_name => 'Caboose::Page', :foreign_key => 'parent_id', :order => 'sort_order, title'
|
8
8
|
has_many :page_permissions
|
9
9
|
has_many :blocks, :order => 'sort_order'
|
10
|
+
has_many :page_tags, :class_name => 'Caboose::PageTag', :dependent => :delete_all, :order => 'tag'
|
10
11
|
attr_accessible :id ,
|
11
12
|
:site_id ,
|
12
13
|
:parent_id ,
|
@@ -27,8 +27,7 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
27
27
|
Caboose::Block => [:block_type],
|
28
28
|
#Caboose::FieldType => [:model_binder_options],
|
29
29
|
Caboose::AbValue => [:i, :text],
|
30
|
-
Caboose::AbOption => [:text],
|
31
|
-
Caboose::User => [:timezone],
|
30
|
+
Caboose::AbOption => [:text],
|
32
31
|
#Caboose::Field => [:child_block_id],
|
33
32
|
Caboose::BlockType => [:layout_function],
|
34
33
|
Caboose::CalendarEvent => [
|
@@ -233,6 +232,10 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
233
232
|
[ :page_id , :integer ],
|
234
233
|
[ :action , :string ]
|
235
234
|
],
|
235
|
+
Caboose::PageTag => [
|
236
|
+
[ :page_id , :integer ],
|
237
|
+
[ :tag , :string ]
|
238
|
+
],
|
236
239
|
Caboose::PermanentRedirect => [
|
237
240
|
[ :site_id , :integer ],
|
238
241
|
[ :priority , :integer , { :default => 0 }],
|
@@ -300,21 +303,6 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
300
303
|
[ :authentication , :string ], # :plain, :login, :cram_md5.
|
301
304
|
[ :enable_starttls_auto , :boolean , { :default => true }]
|
302
305
|
],
|
303
|
-
Caboose::Timezone => [
|
304
|
-
[ :country_code , :string ],
|
305
|
-
[ :name , :string ]
|
306
|
-
],
|
307
|
-
Caboose::TimezoneAbbreviation => [
|
308
|
-
[ :abbreviation , :string ],
|
309
|
-
[ :name , :string ]
|
310
|
-
],
|
311
|
-
Caboose::TimezoneOffset => [
|
312
|
-
[ :timezone_id , :integer ],
|
313
|
-
[ :abbreviation , :string ],
|
314
|
-
[ :time_start , :integer ],
|
315
|
-
[ :gmt_offset , :integer ],
|
316
|
-
[ :dst , :boolean ]
|
317
|
-
],
|
318
306
|
Caboose::User => [
|
319
307
|
[ :first_name , :string ],
|
320
308
|
[ :last_name , :string ],
|
@@ -326,10 +314,8 @@ class Caboose::Schema < Caboose::Utilities::Schema
|
|
326
314
|
[ :state , :string ],
|
327
315
|
[ :zip , :string ],
|
328
316
|
[ :phone , :string ],
|
329
|
-
[ :fax , :string ],
|
330
|
-
[ :
|
331
|
-
#[ :timezone , :string , { :default => 'America/Chicago' }],
|
332
|
-
[ :timezone_id , :integer , { :defualt => 381 }], # Defaults to 'America/Chicago'
|
317
|
+
[ :fax , :string ],
|
318
|
+
[ :timezone , :string , { :default => 'Central Time (US & Canada)' }],
|
333
319
|
[ :password , :string ],
|
334
320
|
[ :password_reset_id , :string ],
|
335
321
|
[ :password_reset_sent , :datetime ],
|
data/app/models/caboose/user.rb
CHANGED
@@ -12,7 +12,7 @@ class Caboose::User < ActiveRecord::Base
|
|
12
12
|
:large => '600x800>'
|
13
13
|
}
|
14
14
|
do_not_validate_attachment_file_type :image
|
15
|
-
attr_accessible :id, :email, :first_name, :last_name, :username, :token, :password, :phone
|
15
|
+
attr_accessible :id, :email, :first_name, :last_name, :username, :token, :password, :phone, :timezone
|
16
16
|
|
17
17
|
ADMIN_USER_ID = 1
|
18
18
|
LOGGED_OUT_USER_ID = 2
|
@@ -1,15 +1,15 @@
|
|
1
1
|
<%
|
2
|
-
img = block.
|
3
|
-
img_style = block.
|
4
|
-
link = block.
|
5
|
-
align = block.
|
6
|
-
width = block.
|
7
|
-
height = block.
|
8
|
-
mt = block.
|
9
|
-
mr = block.
|
10
|
-
mb = block.
|
11
|
-
ml = block.
|
12
|
-
url = img
|
2
|
+
img = block.child_value('image_src')
|
3
|
+
img_style = block.child_value('image_style')
|
4
|
+
link = block.child_value('link')
|
5
|
+
align = block.child_value('align')
|
6
|
+
width = block.child_value('width')
|
7
|
+
height = block.child_value('height')
|
8
|
+
mt = block.child_value('margin_top').downcase
|
9
|
+
mr = block.child_value('margin_right').downcase
|
10
|
+
mb = block.child_value('margin_bottom').downcase
|
11
|
+
ml = block.child_value('margin_left').downcase
|
12
|
+
url = img ? img.url(img_style.downcase.to_sym) : nil
|
13
13
|
|
14
14
|
img = nil
|
15
15
|
if url && !url.include?('missing.png')
|
@@ -11,6 +11,7 @@
|
|
11
11
|
<div class='field_with_explanation'><div id='page_<%= @page.id %>_hide' ></div><span class='explanation'>Whether or not this page is displayed in the menu.</span></div>
|
12
12
|
<div class='field_with_explanation'><div id='page_<%= @page.id %>_custom_sort_children' ></div><span class='explanation'>Sort child pages alphabetically or <a href='/admin/pages/<%= @page.id %>/child-order'>custom</a>.</span></div>
|
13
13
|
<div class='field_with_explanation'><div id='page_<%= @page.id %>_content_format' ></div><span class='explanation'>Specify whether or not you want to embed ruby code in your page.</span></div>
|
14
|
+
<div class='field_with_explanation'><div id='page_<%= @page.id %>_tags' ></div><span class='explanation'>Tags to help categorize your page. Use as many as you want, just separate by commas.</span></div>
|
14
15
|
|
15
16
|
<%= render :partial => 'caboose/pages/admin_footer' %>
|
16
17
|
|
@@ -48,6 +49,9 @@ $(window).load(function() {
|
|
48
49
|
modal = new CabooseModal(800);
|
49
50
|
});
|
50
51
|
|
52
|
+
<%
|
53
|
+
tags = @page.page_tags.collect{ |t| t.tag }.join(', ')
|
54
|
+
%>
|
51
55
|
$(document).ready(function() {
|
52
56
|
m = new ModelBinder({
|
53
57
|
name: 'Page',
|
@@ -55,15 +59,16 @@ $(document).ready(function() {
|
|
55
59
|
update_url: '/admin/pages/<%= @page.id %>',
|
56
60
|
authenticity_token: '<%= form_authenticity_token %>',
|
57
61
|
attributes: [
|
58
|
-
{ name: 'title' , nice_name: 'Title' , type: 'text' , value: <%= raw Caboose.json(@page.title
|
59
|
-
{ name: 'menu_title' , nice_name: 'Menu title' , type: 'text' , value: <%= raw Caboose.json(@page.menu_title
|
60
|
-
{ name: 'parent_id' , nice_name: 'Parent' , type: 'select' , value: <%= @page.parent_id
|
61
|
-
{ name: 'slug' , nice_name: 'Slug' , type: 'text' , value: <%= raw Caboose.json(@page.slug
|
62
|
-
{ name: 'alias' , nice_name: 'Alias' , type: 'text' , value: <%= raw Caboose.json(@page.alias
|
63
|
-
{ name: 'redirect_url' , nice_name: 'Redirect URL' , type: 'text' , value: <%= raw Caboose.json(@page.redirect_url
|
64
|
-
{ name: 'hide' , nice_name: 'Hide' , type: 'checkbox' , value: <%= raw @page.hide
|
65
|
-
{ name: 'custom_sort_children' , nice_name: 'Custom sort children' , type: 'checkbox' , value: <%= raw @page.custom_sort_children
|
66
|
-
{ name: 'content_format' , nice_name: 'Content format' , type: 'select' , value: <%= raw Caboose.json(@page.content_format)
|
62
|
+
{ name: 'title' , nice_name: 'Title' , type: 'text' , value: <%= raw Caboose.json(@page.title ) %> , width: 400 },
|
63
|
+
{ name: 'menu_title' , nice_name: 'Menu title' , type: 'text' , value: <%= raw Caboose.json(@page.menu_title ) %> , width: 400 },
|
64
|
+
{ name: 'parent_id' , nice_name: 'Parent' , type: 'select' , value: <%= @page.parent_id %> , width: 400, after_update: function() { update_uri(<%= @page.id %>); }, text: <%= raw (@page.parent_id == -1 ? "[No Parent]" : @page.parent.title).to_json %>, options_url: '/admin/pages/sitemap-options' },
|
65
|
+
{ name: 'slug' , nice_name: 'Slug' , type: 'text' , value: <%= raw Caboose.json(@page.slug ) %> , width: 400, after_update: function() { update_uri(<%= @page.id %>); } },
|
66
|
+
{ name: 'alias' , nice_name: 'Alias' , type: 'text' , value: <%= raw Caboose.json(@page.alias ) %> , width: 400, after_update: function() { update_uri(<%= @page.id %>); } },
|
67
|
+
{ name: 'redirect_url' , nice_name: 'Redirect URL' , type: 'text' , value: <%= raw Caboose.json(@page.redirect_url ) %> , width: 400 },
|
68
|
+
{ name: 'hide' , nice_name: 'Hide' , type: 'checkbox' , value: <%= raw @page.hide %> , width: 400 },
|
69
|
+
{ name: 'custom_sort_children' , nice_name: 'Custom sort children' , type: 'checkbox' , value: <%= raw @page.custom_sort_children %> , width: 400 },
|
70
|
+
{ name: 'content_format' , nice_name: 'Content format' , type: 'select' , value: <%= raw Caboose.json(@page.content_format ) %> , width: 400, text: <%= raw Caboose.json(@page.content_format) %>, options_url: '/pages/format-options' },
|
71
|
+
{ name: 'tags' , nice_name: 'Tags' , type: 'text' , value: <%= raw Caboose.json(tags ) %> , width: 400 }
|
67
72
|
]
|
68
73
|
});
|
69
74
|
});
|
@@ -4,6 +4,7 @@
|
|
4
4
|
<p><div id='page_<%= @page.id %>_seo_title'></div></p>
|
5
5
|
<p><div id='page_<%= @page.id %>_meta_keywords'></div></p>
|
6
6
|
<p><div id='page_<%= @page.id %>_meta_description'></div></p>
|
7
|
+
<p id='widths'></p>
|
7
8
|
<p><div id='page_<%= @page.id %>_meta_robots'></div></p>
|
8
9
|
<p><div id='page_<%= @page.id %>_canonical_url'></div></p>
|
9
10
|
<p><div id='page_<%= @page.id %>_fb_description'></div></p>
|
@@ -29,10 +30,34 @@ $(document).ready(function() {
|
|
29
30
|
{ name: 'meta_description' , nice_name: 'Meta Description' , type: 'textarea' , value: <%= raw Caboose.json(@page.meta_description) %>, width: 580, height: 80 },
|
30
31
|
{ name: 'fb_description' , nice_name: 'Facebook Description' , type: 'textarea' , value: <%= raw Caboose.json(@page.fb_description) %>, width: 580, height: 80 },
|
31
32
|
{ name: 'gp_description' , nice_name: 'Google+ Description' , type: 'textarea' , value: <%= raw Caboose.json(@page.gp_description) %>, width: 580, height: 80 }
|
32
|
-
]
|
33
|
+
],
|
34
|
+
on_load: function() {
|
35
|
+
$('#page_<%= @page.id %>_meta_description').keyup(function() {
|
36
|
+
update_widths();
|
37
|
+
});
|
38
|
+
update_widths();
|
39
|
+
}
|
33
40
|
});
|
34
41
|
modal = new CabooseModal(600, 540);
|
42
|
+
|
35
43
|
});
|
36
44
|
|
45
|
+
function update_widths()
|
46
|
+
{
|
47
|
+
var str = $('#page_<%= @page.id %>_meta_description').val();
|
48
|
+
var count = str.length;
|
49
|
+
var width = getTextWidth(str);
|
50
|
+
$('#widths').html('' + count + ' character' + (count == 1 ? '' : 's') + "<br />" + width + " pixel" + (width == 1 ? '' : 's'));
|
51
|
+
}
|
52
|
+
|
53
|
+
function getTextWidth(text)
|
54
|
+
{
|
55
|
+
var canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
|
56
|
+
var context = canvas.getContext("2d");
|
57
|
+
context.font = "18px arial";
|
58
|
+
var metrics = context.measureText(text);
|
59
|
+
return metrics.width;
|
60
|
+
}
|
61
|
+
|
37
62
|
</script>
|
38
63
|
<% end %>
|
data/lib/caboose.rb
CHANGED
@@ -53,11 +53,7 @@ module Caboose
|
|
53
53
|
# Define asset collections
|
54
54
|
mattr_accessor :javascripts, :stylesheets
|
55
55
|
@@javascripts = []
|
56
|
-
@@stylesheets = []
|
57
|
-
|
58
|
-
# API key for timezonedb.com/api
|
59
|
-
mattr_accessor :timezonedb_api_key
|
60
|
-
@@timezonedb_api_key = ''
|
56
|
+
@@stylesheets = []
|
61
57
|
|
62
58
|
# Session length (in hours)
|
63
59
|
mattr_accessor :session_length
|
@@ -65,6 +61,10 @@ module Caboose
|
|
65
61
|
|
66
62
|
# Parse rich text blocks
|
67
63
|
mattr_accessor :parse_richtext_blocks
|
68
|
-
@@parse_richtext_blocks = true
|
64
|
+
@@parse_richtext_blocks = true
|
65
|
+
|
66
|
+
# Default timezone
|
67
|
+
mattr_accessor :timezone
|
68
|
+
@@timezone = 'Central Time (US & Canada)'
|
69
69
|
|
70
70
|
end
|
data/lib/caboose/version.rb
CHANGED
data/lib/tasks/caboose.rake
CHANGED
@@ -57,20 +57,6 @@ namespace :caboose do
|
|
57
57
|
ActiveRecord::SessionStore::Session.delete_all(["updated_at < ?", Caboose::session_length.hours.ago])
|
58
58
|
end
|
59
59
|
|
60
|
-
desc "Loads and refreshes the timezones from timezonedb.com"
|
61
|
-
task :load_timezones => :environment do
|
62
|
-
Caboose::Timezone.load_zones('/Users/william/Sites/repconnex/tmp/timezones')
|
63
|
-
end
|
64
|
-
|
65
|
-
desc "Loads and refreshes the timezones from timezonedb.com"
|
66
|
-
task :test_timezones => :environment do
|
67
|
-
|
68
|
-
d = DateTime.strptime("04/01/2014 10:00 am -0500", "%m/%d/%Y %I:%M %P %Z")
|
69
|
-
puts d
|
70
|
-
d = DateTime.strptime("04/01/2014 10:00 am -0700", "%m/%d/%Y %I:%M %P %Z")
|
71
|
-
puts d
|
72
|
-
end
|
73
|
-
|
74
60
|
desc "Removes duplicate users"
|
75
61
|
task :remove_duplicate_users => :environment do
|
76
62
|
while true
|
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.4.
|
4
|
+
version: 0.4.128
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Barry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -323,6 +323,7 @@ files:
|
|
323
323
|
- app/models/caboose/page.rb
|
324
324
|
- app/models/caboose/page_bar_generator.rb
|
325
325
|
- app/models/caboose/page_permission.rb
|
326
|
+
- app/models/caboose/page_tag.rb
|
326
327
|
- app/models/caboose/pager.rb
|
327
328
|
- app/models/caboose/permanent_redirect.rb
|
328
329
|
- app/models/caboose/permission.rb
|
@@ -340,9 +341,6 @@ files:
|
|
340
341
|
- app/models/caboose/smtp_config.rb
|
341
342
|
- app/models/caboose/states.rb
|
342
343
|
- app/models/caboose/std_class.rb
|
343
|
-
- app/models/caboose/timezone.rb
|
344
|
-
- app/models/caboose/timezone_abbreviation.rb
|
345
|
-
- app/models/caboose/timezone_offset.rb
|
346
344
|
- app/models/caboose/user.rb
|
347
345
|
- app/models/caboose/utilities/schema.rb
|
348
346
|
- app/views/caboose/ab_variants/admin_edit.html.erb
|
@@ -1,75 +0,0 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
|
3
|
-
class Caboose::Timezone < ActiveRecord::Base
|
4
|
-
self.table_name = "timezones"
|
5
|
-
|
6
|
-
has_many :timezone_offsets, :class_name => 'Caboose::TimezoneOffset'
|
7
|
-
attr_accessible :id, :country_code, :name
|
8
|
-
|
9
|
-
def self.load_zones(temp_dir = '/tmp', country_codes = ['US'])
|
10
|
-
`curl -o #{temp_dir}/timezones.csv.zip http://timezonedb.com/files/timezonedb.csv.zip`
|
11
|
-
`unzip #{temp_dir}/timezones.csv.zip -d #{temp_dir}/timezones`
|
12
|
-
|
13
|
-
#Caboose::Timezone.destroy_all
|
14
|
-
#Caboose::TimezoneOffset.destroy_all
|
15
|
-
|
16
|
-
File.foreach("#{temp_dir}/timezones/zone.csv") do |line|
|
17
|
-
data = CSV.parse_line(line)
|
18
|
-
next if !country_codes.include?(data[1])
|
19
|
-
next if Caboose::Timezone.where(:id => data[0].to_i).exists?
|
20
|
-
Caboose::Timezone.create(
|
21
|
-
:id => data[0].to_i,
|
22
|
-
:country_code => data[1],
|
23
|
-
:name => data[2]
|
24
|
-
)
|
25
|
-
end
|
26
|
-
|
27
|
-
File.foreach("#{temp_dir}/timezones/timezone.csv") do |line|
|
28
|
-
data = CSV.parse_line(line)
|
29
|
-
tz_id = data[0].to_i
|
30
|
-
next if !Caboose::Timezone.where(:id => tz_id).exists?
|
31
|
-
next if Caboose::TimezoneOffset.where(:timezone_id => tz_id, :time_start => data[2].to_i).exists?
|
32
|
-
Caboose::TimezoneOffset.create(
|
33
|
-
:timezone_id => data[0].to_i,
|
34
|
-
:abbreviation => data[1],
|
35
|
-
:time_start => data[2],
|
36
|
-
:gmt_offset => data[3],
|
37
|
-
:dst => data[4]
|
38
|
-
)
|
39
|
-
end
|
40
|
-
|
41
|
-
spec = Gem::Specification.find_by_name("caboose-cms")
|
42
|
-
gem_root = spec.gem_dir
|
43
|
-
|
44
|
-
File.foreach(gem_root + '/lib/sample_files/timezone_abbreviations.csv') do |line|
|
45
|
-
data = CSV.parse_line(line)
|
46
|
-
next if Caboose::TimezoneAbbreviation.where(:abbreviation => data[0]).exists?
|
47
|
-
Caboose::TimezoneAbbreviation.create(
|
48
|
-
:abbreviation => data[0],
|
49
|
-
:name => data[1]
|
50
|
-
)
|
51
|
-
end
|
52
|
-
|
53
|
-
`rm -rf #{temp_dir}/timezones`
|
54
|
-
`rm -rf #{temp_dir}/timezones.csv.zip`
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
def local(utc_datetime)
|
59
|
-
tzo = self.timezone_offsets.where('time_start < ?', utc_datetime.to_i).reorder('time_start desc').first
|
60
|
-
return utc_datetime + tzo.gmt_offset.seconds
|
61
|
-
end
|
62
|
-
|
63
|
-
def string_format(d = DateTime.now.utc)
|
64
|
-
tzo = self.timezone_offsets.where('time_start < ?', d.to_i).reorder('time_start desc').first
|
65
|
-
total = tzo.gmt_offset.abs
|
66
|
-
hours = (total/3600).floor
|
67
|
-
x = total - (hours*3600)
|
68
|
-
minutes = x > 0 ? (x/60).floor : 0
|
69
|
-
seconds = total - (hours*3600) - (minutes*60)
|
70
|
-
sign = tzo.gmt_offset >= 0 ? '+' : '-'
|
71
|
-
hours = hours.to_s.rjust(2, '0')
|
72
|
-
return "#{sign}#{hours}#{minutes}"
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|