tb_events 1.0.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/README.md +17 -5
- data/Rakefile +2 -2
- data/app/assets/javascripts/admin/events/application.js +16 -0
- data/app/assets/javascripts/{calendar_events.js → admin/events/calendar_events.js} +0 -0
- data/app/assets/javascripts/{spud/admin → admin/events}/calendars.js +0 -0
- data/app/assets/stylesheets/admin/events/application.css +4 -0
- data/app/assets/{javascripts/spud/events.js → stylesheets/admin/events/calendar_events.css} +0 -0
- data/app/assets/stylesheets/{spud → admin/events}/calendars.css +23 -28
- data/app/controllers/admin/calendar_events_controller.rb +67 -0
- data/app/controllers/{spud/admin → admin}/calendars_controller.rb +17 -14
- data/app/controllers/calendar_events_controller.rb +12 -6
- data/app/controllers/calendars_controller.rb +18 -18
- data/app/helpers/admin/calendar_events_helper.rb +2 -0
- data/app/helpers/admin/calendars_helper.rb +13 -0
- data/app/helpers/calendars_helper.rb +66 -35
- data/app/models/spud_calendar.rb +28 -3
- data/app/models/spud_calendar_event.rb +1 -20
- data/app/models/spud_events/calendar_event_model.rb +31 -0
- data/app/views/admin/calendar_events/_calendar.html.erb +19 -0
- data/app/views/admin/calendar_events/_form.html.erb +21 -0
- data/app/views/admin/calendar_events/edit.html.erb +1 -0
- data/app/views/admin/calendar_events/index.html.erb +28 -0
- data/app/views/admin/calendar_events/new.html.erb +1 -0
- data/app/views/admin/calendars/_calendar_legend.html.erb +8 -0
- data/app/views/admin/calendars/_form.html.erb +5 -0
- data/app/views/{spud/admin → admin}/calendars/edit.html.erb +0 -0
- data/app/views/{spud/admin → admin}/calendars/new.html.erb +0 -0
- data/app/views/calendar_events/index.html.erb +22 -0
- data/app/views/calendar_events/show.html.erb +7 -5
- data/app/views/calendars/show.html.erb +19 -4
- data/config/locales/en.yml +9 -0
- data/config/routes.rb +9 -15
- data/db/migrate/20120216191833_create_spud_calendars.rb +2 -2
- data/db/migrate/20140723203144_add_identifier_to_spud_calendars.rb +6 -0
- data/db/migrate/20140730182213_remove_color_from_spud_calendars.rb +9 -0
- data/lib/spud_events/calendar_builder.rb +53 -0
- data/lib/spud_events/configuration.rb +6 -0
- data/lib/spud_events/engine.rb +23 -0
- data/lib/spud_events/version.rb +3 -0
- data/lib/tb_events.rb +4 -4
- metadata +83 -131
- data/app/assets/javascripts/calendars.js +0 -2
- data/app/assets/javascripts/spud/admin/calendar_events.js +0 -2
- data/app/assets/javascripts/spud/admin/events.js +0 -51
- data/app/assets/lib/colorpicker/colorpicker.css +0 -164
- data/app/assets/lib/colorpicker/colorpicker.js +0 -484
- data/app/assets/lib/colorpicker/images/blank.gif +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_background.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_hex.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_hsb_b.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_hsb_h.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_hsb_s.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_indic.gif +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_overlay.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_rgb_b.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_rgb_g.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_rgb_r.png +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_select.gif +0 -0
- data/app/assets/lib/colorpicker/images/colorpicker_submit.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_background.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_hex.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_hsb_b.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_hsb_h.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_hsb_s.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_indic.gif +0 -0
- data/app/assets/lib/colorpicker/images/custom_rgb_b.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_rgb_g.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_rgb_r.png +0 -0
- data/app/assets/lib/colorpicker/images/custom_submit.png +0 -0
- data/app/assets/lib/colorpicker/images/select.png +0 -0
- data/app/assets/lib/colorpicker/images/select2.png +0 -0
- data/app/assets/lib/colorpicker/images/slider.png +0 -0
- data/app/assets/stylesheets/spud/admin/events.css +0 -16
- data/app/assets/stylesheets/spud/calendar_events.css +0 -18
- data/app/assets/stylesheets/spud/events.css +0 -4
- data/app/controllers/spud/admin/calendar_events_controller.rb +0 -64
- data/app/helpers/spud/admin/calendar_events_helper.rb +0 -2
- data/app/helpers/spud/admin/calendars_helper.rb +0 -15
- data/app/views/calendars/_calendar.html.erb +0 -26
- data/app/views/calendars/_calendar_options.html.erb +0 -4
- data/app/views/spud/admin/calendar_events/_calendar.html.erb +0 -14
- data/app/views/spud/admin/calendar_events/_form.html.erb +0 -98
- data/app/views/spud/admin/calendar_events/edit.html.erb +0 -1
- data/app/views/spud/admin/calendar_events/index.html.erb +0 -20
- data/app/views/spud/admin/calendar_events/new.html.erb +0 -1
- data/app/views/spud/admin/calendars/_calendar_legend.html.erb +0 -7
- data/app/views/spud/admin/calendars/_form.html.erb +0 -20
- data/config/application.rb +0 -50
- data/config/boot.rb +0 -6
- data/lib/spud/events/calendar.rb +0 -85
- data/lib/spud/events/calendar_builder.rb +0 -58
- data/lib/spud/events/configuration.rb +0 -10
- data/lib/spud/events/engine.rb +0 -26
- data/lib/spud/events/table_builder.rb +0 -88
- data/lib/spud/events/version.rb +0 -5
data/lib/spud/events/calendar.rb
DELETED
@@ -1,85 +0,0 @@
|
|
1
|
-
module Spud
|
2
|
-
module Events
|
3
|
-
class Calendar
|
4
|
-
attr_accessor :first_weekday, :last_weekday, :month
|
5
|
-
|
6
|
-
def initialize(options={})
|
7
|
-
@year = options[:year] || Time.now.year
|
8
|
-
@month = options[:month] || Time.now.month
|
9
|
-
@first_day_of_week = options[:first_day_of_week] || 0
|
10
|
-
@first_weekday = first_day_of_week(@first_day_of_week)
|
11
|
-
@last_weekday = last_day_of_week(@first_day_of_week)
|
12
|
-
@first = Date.civil(@year, @month, 1)
|
13
|
-
@last = Date.civil(@year, @month, -1)
|
14
|
-
end
|
15
|
-
|
16
|
-
def each_day
|
17
|
-
first_day.upto(last_day) do |day|
|
18
|
-
yield(day)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def last_day
|
23
|
-
last = @last
|
24
|
-
while(last.wday % 7 != @last_weekday % 7)
|
25
|
-
last = last.next
|
26
|
-
end
|
27
|
-
last
|
28
|
-
end
|
29
|
-
|
30
|
-
def first_day
|
31
|
-
first = @first - 6
|
32
|
-
while(first.wday % 7 != (@first_weekday) % 7)
|
33
|
-
first = first.next
|
34
|
-
end
|
35
|
-
first
|
36
|
-
end
|
37
|
-
|
38
|
-
def objects_for_days(objects, day_method, end_method)
|
39
|
-
unless @objects_for_days
|
40
|
-
@objects_for_days = {}
|
41
|
-
days.each do |day|
|
42
|
-
tasks = []
|
43
|
-
objects.each do |object|
|
44
|
-
start_date = object.send(day_method.to_sym).beginning_of_day.to_date
|
45
|
-
end_date = object.send(end_method.to_sym).end_of_day.to_date
|
46
|
-
if day >= start_date && day <= end_date
|
47
|
-
tasks.push(object)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
@objects_for_days[day.strftime("%Y-%m-%d")] = [day, tasks]
|
51
|
-
end
|
52
|
-
end
|
53
|
-
@objects_for_days
|
54
|
-
end
|
55
|
-
|
56
|
-
def days
|
57
|
-
unless @days
|
58
|
-
@days = []
|
59
|
-
each_day{|day| @days << day}
|
60
|
-
end
|
61
|
-
@days
|
62
|
-
end
|
63
|
-
|
64
|
-
def mjdays
|
65
|
-
unless @mjdays
|
66
|
-
@mdays = []
|
67
|
-
each_day{|day| @days << day}
|
68
|
-
end
|
69
|
-
@days
|
70
|
-
end
|
71
|
-
|
72
|
-
def first_day_of_week(day)
|
73
|
-
day
|
74
|
-
end
|
75
|
-
|
76
|
-
def last_day_of_week(day)
|
77
|
-
if day > 0
|
78
|
-
day - 1
|
79
|
-
else
|
80
|
-
6
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
module Spud
|
2
|
-
module Events
|
3
|
-
class CalendarBuilder < Spud::Events::TableBuilder
|
4
|
-
|
5
|
-
def initialize(objects, template, options)
|
6
|
-
super(objects, template, options)
|
7
|
-
@calendar = Spud::Events::Calendar.new(options)
|
8
|
-
@today = options[:today] || Time.now
|
9
|
-
end
|
10
|
-
|
11
|
-
def day(*args,&block)
|
12
|
-
raise ArgumentError, "Missing block" unless block_given?
|
13
|
-
options = options_from_hash(args)
|
14
|
-
day_method = options.delete(:day_method) || :start_at
|
15
|
-
end_method = options.delete(:end_method) || :end_at
|
16
|
-
id_pattern = options.delete(:id)
|
17
|
-
activity_class = options.delete(:activity)
|
18
|
-
output = ""
|
19
|
-
@calendar.objects_for_days(@objects, day_method, end_method).to_a.sort{|a1, a2| a1.first <=> a2.first }.each do |o|
|
20
|
-
key, array = o
|
21
|
-
day, objects = array
|
22
|
-
|
23
|
-
output << @template.tag(:tr,options,true) if (day.wday == @calendar.first_weekday)
|
24
|
-
output << @template.tag(:td,td_options(day, id_pattern, (objects.empty? ? nil: activity_class)), true)
|
25
|
-
output << @template.with_output_buffer{block.call(day, objects)}
|
26
|
-
output << '</td>'
|
27
|
-
output << '</tr>' if (day.wday == @calendar.last_weekday)
|
28
|
-
end
|
29
|
-
@template.content_tag(:tbody, output.html_safe, {}, false)
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def objects_for_days
|
35
|
-
@calendar.objects_for_days(@objects)
|
36
|
-
end
|
37
|
-
|
38
|
-
def td_options(day, id_pattern, activity_class)
|
39
|
-
options = {}
|
40
|
-
if(day.strftime("%Y-%m-%d") == @today.strftime("%Y-%m-%d"))
|
41
|
-
options[:class] = 'today'
|
42
|
-
elsif(day.month != @calendar.month)
|
43
|
-
options[:class] = 'notmonth'
|
44
|
-
elsif(day.wday == 0 or day.wday == 6)
|
45
|
-
options[:class] = 'weekend'
|
46
|
-
elsif activity_class
|
47
|
-
options[:class] = activity_class
|
48
|
-
end
|
49
|
-
if id_pattern
|
50
|
-
options[:id] = day.strftime(id_pattern)
|
51
|
-
end
|
52
|
-
|
53
|
-
options
|
54
|
-
end
|
55
|
-
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/lib/spud/events/engine.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'tb_core'
|
2
|
-
|
3
|
-
module Spud
|
4
|
-
module Events
|
5
|
-
class Engine < Rails::Engine
|
6
|
-
engine_name :tb_events
|
7
|
-
|
8
|
-
config.autoload_paths << File.expand_path("../../..", __FILE__)
|
9
|
-
|
10
|
-
initializer :admin do
|
11
|
-
Spud::Core.configure do |config|
|
12
|
-
config.admin_applications += [{:name => "Events", :thumbnail => "spud/admin/events_thumb.png", :url => "/spud/admin/events",:order => 10}]
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
initializer :assets do |config|
|
17
|
-
Spud::Core.append_admin_javascripts('spud/admin/events')
|
18
|
-
Spud::Core.append_admin_stylesheets('spud/admin/events')
|
19
|
-
Rails.application.config.assets.precompile += [
|
20
|
-
"spud/events.*",
|
21
|
-
"spud/admin/events.*"
|
22
|
-
]
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
module Spud
|
2
|
-
module Events
|
3
|
-
class TableBuilder
|
4
|
-
include ::ActionView::Helpers::TagHelper
|
5
|
-
|
6
|
-
def initialize(objects, template, options)
|
7
|
-
raise ArgumentError, "TableBuilder expects an Array but found a #{objects.inspect}" unless objects.is_a? Array
|
8
|
-
@objects, @template, @options = objects, template, options
|
9
|
-
end
|
10
|
-
|
11
|
-
def head(*args, &block)
|
12
|
-
if block_given?
|
13
|
-
@template.content_tag(:thead, nil, options_from_hash(args), true, &block)
|
14
|
-
else
|
15
|
-
@num_of_columns = args.size
|
16
|
-
content = args.collect do |c|
|
17
|
-
@template.content_tag(:th, c)
|
18
|
-
end.join("\n").html_safe
|
19
|
-
@template.content_tag(:thead, @template.content_tag(:tr,content,{},false))
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def head_r(*args, &block)
|
24
|
-
raise ArgumentError, "Missing block" unless block_given?
|
25
|
-
options = options_from_hash(args)
|
26
|
-
head do
|
27
|
-
@template.content_tag(:tr, nil, options, true, &block)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def body(*args, &block)
|
32
|
-
raise ArgumentError, "Missing block" unless block_given?
|
33
|
-
options = options_from_hash(args)
|
34
|
-
content = @objects.collect do |c|
|
35
|
-
@template.with_output_buffer{block.call(c)}
|
36
|
-
end.join("\n").html_safe
|
37
|
-
@template.content_tag(:tbody, content, options, false)
|
38
|
-
end
|
39
|
-
|
40
|
-
def body_r(*args, &block)
|
41
|
-
raise ArgumentError, "Missing block" unless block_given?
|
42
|
-
options = options_from_hash(args)
|
43
|
-
tds = @objects.collect do |thing|
|
44
|
-
@template.with_output_buffer{block.call(thing)}
|
45
|
-
end
|
46
|
-
content = tds.collect do |td|
|
47
|
-
@template.content_tag(:tr,td, {}, false)
|
48
|
-
end.join("\n").html_safe
|
49
|
-
"\n#{@template.content_tag(:tbody, content, options, false)}".html_safe
|
50
|
-
end
|
51
|
-
|
52
|
-
def r(*args, &block)
|
53
|
-
raise ArgumentError, "Missing block" unless block_given?
|
54
|
-
options = options_from_hash(args)
|
55
|
-
@template.content_tag(:tr, nil, options, true, &block)
|
56
|
-
end
|
57
|
-
|
58
|
-
def h(*args, &block)
|
59
|
-
if block_given?
|
60
|
-
@template.content_tag(:th, nil, options_from_hash(args), true, &block)
|
61
|
-
else
|
62
|
-
content = args.shift
|
63
|
-
@template.content_tag(:th, content, options_from_hash(args))
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
def d(*args, &block)
|
68
|
-
if block_given?
|
69
|
-
@template.content_tag(:td, nil, options_from_hash(args), true, &block)
|
70
|
-
else
|
71
|
-
content = args.shift
|
72
|
-
@template.content_tag(:td, content, options_from_hash(args))
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
private
|
77
|
-
|
78
|
-
def options_from_hash(args)
|
79
|
-
args.last.is_a?(Hash) ? args.pop : {}
|
80
|
-
end
|
81
|
-
|
82
|
-
# def content_tag(tag, content, *args, &block)
|
83
|
-
# options = options_from_hash(args)
|
84
|
-
# @template.content_tag(tag, content, options, &block)
|
85
|
-
# end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|