tb_events 1.1.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +13 -1
- 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 +13 -15
- data/app/controllers/admin/calendars_controller.rb +9 -11
- data/app/controllers/calendar_events_controller.rb +12 -6
- data/app/controllers/calendars_controller.rb +18 -18
- data/app/helpers/admin/calendars_helper.rb +6 -8
- data/app/helpers/calendars_helper.rb +66 -35
- data/app/models/spud_calendar.rb +30 -2
- data/app/models/spud_calendar_event.rb +1 -18
- data/app/models/spud_events/calendar_event_model.rb +31 -0
- data/app/views/admin/calendar_events/_calendar.html.erb +16 -11
- data/app/views/admin/calendar_events/_form.html.erb +16 -98
- data/app/views/admin/calendar_events/index.html.erb +24 -16
- data/app/views/admin/calendars/_calendar_legend.html.erb +5 -4
- data/app/views/admin/calendars/_form.html.erb +4 -19
- data/app/views/calendar_events/index.html.erb +22 -0
- data/app/views/calendar_events/show.html.erb +3 -1
- data/app/views/calendars/show.html.erb +18 -15
- data/config/locales/en.yml +9 -0
- data/config/routes.rb +7 -10
- data/db/migrate/20120216191833_create_spud_calendars.rb +3 -3
- data/db/migrate/20120216192531_create_spud_calendar_events.rb +1 -1
- data/db/migrate/20130214131628_add_location_to_spud_calendar_event.rb +1 -1
- 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 +25 -0
- data/lib/spud_events/version.rb +3 -0
- data/lib/tb_events.rb +4 -4
- metadata +62 -110
- 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/views/calendars/_calendar.html.erb +0 -26
- data/app/views/calendars/_calendar_options.html.erb +0 -4
- 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 -8
- 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
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -1,16 +0,0 @@
|
|
1
|
-
/* ...
|
2
|
-
*= require spud/calendars
|
3
|
-
*= require spud/calendar_events
|
4
|
-
*= require colorpicker/colorpicker
|
5
|
-
*= require_self
|
6
|
-
*/
|
7
|
-
|
8
|
-
/* Calendar Color Picker
|
9
|
-
----------------------- */
|
10
|
-
.spud_events_admin_color_picker {
|
11
|
-
height: 28px;
|
12
|
-
width: 28px;
|
13
|
-
display: block;
|
14
|
-
background-image: url('/assets/colorpicker/images/select2.png');
|
15
|
-
background-position: 50% 50%;
|
16
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
a.spud_events_admin_calendar_event_marker,
|
2
|
-
a.spud_events_calendar_event_marker {
|
3
|
-
color: black;
|
4
|
-
font-size: 11px;
|
5
|
-
padding: 0 3px;
|
6
|
-
margin: 0 0 3px 0;
|
7
|
-
line-height: 13px;
|
8
|
-
display: block;
|
9
|
-
-moz-border-radius: 3px;
|
10
|
-
-webkit-border-radius: 3px;
|
11
|
-
border-radius: 3px;
|
12
|
-
text-decoration: none;
|
13
|
-
}
|
14
|
-
span.spud_events_admin_calendar_event_marker:last-child,
|
15
|
-
span.spud_events_calendar_event_marker:last-child {
|
16
|
-
color: #191919;
|
17
|
-
margin: 0;
|
18
|
-
}
|
@@ -1,26 +0,0 @@
|
|
1
|
-
<div>
|
2
|
-
<h2><%= date.strftime("%B %Y") %></h2>
|
3
|
-
<% build_calendar_for @events, :year => date.year, :month => date.month do |t| %>
|
4
|
-
<%= raw t.head('S', 'M', 'T', 'W', 'T', 'F', 'S') %>
|
5
|
-
<% t.day do |day, tasks| %>
|
6
|
-
<%= content_tag :span, day.day, :class => (tasks.count > 0 ? "spud_events_calendar_date spud_events_calendar_date_active" : "spud_events_calendar_date") %>
|
7
|
-
<% end %>
|
8
|
-
<% end %>
|
9
|
-
</div>
|
10
|
-
|
11
|
-
<nav id="spud_events_calendar_nav">
|
12
|
-
<%= link_to_previous_calendar_month(@calendar_date, {:controller => 'spud/events/calendars', :action => :show}) %>
|
13
|
-
<%= link_to_next_calendar_month(@calendar_date, {:controller => 'spud/events/calendars', :action => :show}) %>
|
14
|
-
</nav>
|
15
|
-
|
16
|
-
<%= build_calendar_for @events, :year => date.year, :month => date.month do |t| %>
|
17
|
-
<%= raw t.head('S', 'M', 'T', 'W', 'T', 'F', 'S') %>
|
18
|
-
<%= t.day do |day, tasks| %>
|
19
|
-
<div class="spud_events_calendar_date_container">
|
20
|
-
<%= content_tag :span, day.day, :class => (tasks.count > 0 ? "spud_events_calendar_date spud_events_calendar_date_active" : "spud_events_calendar_date") %>
|
21
|
-
<% tasks.each do |task| %>
|
22
|
-
<%= link_to task.title[0,25], "#", :class => "spud_events_calendar_event_marker spud_events_calendar_event_#{task.spud_calendar_id}", :style => "background-color: \##{task.spud_calendar.color}; color:\##{calendar_fore_color(task.spud_calendar.color)};" %>
|
23
|
-
<% end %>
|
24
|
-
</div>
|
25
|
-
<% end %>
|
26
|
-
<% end %>
|
data/config/application.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
require File.expand_path('../boot', __FILE__)
|
2
|
-
|
3
|
-
require 'rails/all'
|
4
|
-
|
5
|
-
if defined?(Bundler)
|
6
|
-
# If you precompile assets before deploying to production, use this line
|
7
|
-
Bundler.require *Rails.groups(:assets => %w(development test))
|
8
|
-
# If you want your assets lazily compiled in production, use this line
|
9
|
-
# Bundler.require(:default, :assets, Rails.env)
|
10
|
-
end
|
11
|
-
|
12
|
-
module Spud
|
13
|
-
module Events
|
14
|
-
class Application < Rails::Application
|
15
|
-
# Settings in config/environments/* take precedence over those specified here.
|
16
|
-
# Application configuration should go into files in config/initializers
|
17
|
-
# -- all .rb files in that directory are automatically loaded.
|
18
|
-
|
19
|
-
# Custom directories with classes and modules you want to be autoloadable.
|
20
|
-
# config.autoload_paths += %W(#{config.root}/extras)
|
21
|
-
|
22
|
-
# Only load the plugins named here, in the order given (default is alphabetical).
|
23
|
-
# :all can be used as a placeholder for all plugins not explicitly named.
|
24
|
-
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
25
|
-
|
26
|
-
# Activate observers that should always be running.
|
27
|
-
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
28
|
-
|
29
|
-
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
30
|
-
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
31
|
-
# config.time_zone = 'Central Time (US & Canada)'
|
32
|
-
|
33
|
-
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
34
|
-
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
35
|
-
# config.i18n.default_locale = :de
|
36
|
-
|
37
|
-
# Configure the default encoding used in templates for Ruby 1.9.
|
38
|
-
config.encoding = "utf-8"
|
39
|
-
|
40
|
-
# Configure sensitive parameters which will be filtered from the log file.
|
41
|
-
config.filter_parameters += [:password]
|
42
|
-
|
43
|
-
# Enable the asset pipeline
|
44
|
-
config.assets.enabled = true
|
45
|
-
|
46
|
-
# Version of your assets, change this if you want to expire all your assets
|
47
|
-
config.assets.version = '1.0'
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
data/config/boot.rb
DELETED
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 => "/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
|