concerto_content_scheduling 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +13 -0
- data/README.md +2 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/concerto_content_scheduling/application.js +15 -0
- data/app/assets/javascripts/concerto_content_scheduling/selectTime.js +6 -0
- data/app/assets/stylesheets/concerto_content_scheduling/application.css +16 -0
- data/app/controllers/concerto_content_scheduling/application_controller.rb +4 -0
- data/app/helpers/concerto_content_scheduling/application_helper.rb +4 -0
- data/app/models/concerns/scheduling.rb +83 -0
- data/app/views/concerto_content_scheduling/content/_details.html.erb +13 -0
- data/app/views/concerto_content_scheduling/content/_schedule.html.erb +50 -0
- data/app/views/concerto_content_scheduling/content/_tile_labels.html.erb +3 -0
- data/app/views/layouts/concerto_content_scheduling/application.html.erb +14 -0
- data/config/locales/en.yml +15 -0
- data/config/routes.rb +2 -0
- data/db/migrate/20140618183357_add_schedule_to_contents.rb +5 -0
- data/lib/concerto_content_scheduling.rb +4 -0
- data/lib/concerto_content_scheduling/engine.rb +38 -0
- data/lib/concerto_content_scheduling/version.rb +3 -0
- data/lib/tasks/concerto_content_scheduling_tasks.rake +4 -0
- data/test/concerto_content_scheduling_test.rb +7 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +83 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +4 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/test_helper.rb +15 -0
- metadata +204 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: cd009084f48ed4f67f8fdc7d3d061a7ec088c98e
|
4
|
+
data.tar.gz: d712aa0fa7a4ca642a1dbd3d3c15592bcc3d8635
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 77f57feac651849f67ef8807298ac92fe467d3598c542d2f02428d59b4dba24b129512b1cfc8acb849a72e1886d74d3142f94fcf053c0d923710aacd8a13cc8b
|
7
|
+
data.tar.gz: 829039e8fa16d505f9b4e824e6bca8c1f888f7f9b594dedbe63c52a483f96c68c32a1458696b4f1091affc4bb350a62a5cfd6caa60ae7a121c71fbd1f8863bd1
|
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright 2014 Concerto Authors
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'ConcertoContentScheduling'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require recurring_select
|
14
|
+
//= require jquery.timepicker.js
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,16 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_self
|
14
|
+
*= require recurring_select
|
15
|
+
*= require_tree .
|
16
|
+
*/
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Concerns::Scheduling
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
attr_accessor :schedule_info
|
6
|
+
|
7
|
+
after_initialize :create_schedule_info
|
8
|
+
after_find :load_schedule_info
|
9
|
+
before_validation :save_schedule_info
|
10
|
+
|
11
|
+
def self.form_attributes
|
12
|
+
# Content's original form_attributes, plus our new ones
|
13
|
+
[:name, :duration, :data, {:start_time => [:time, :date]}, {:end_time => [:time, :date]}] + [:schedule_info => [:criteria, :start_time, :end_time]]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module ClassMethods
|
18
|
+
end
|
19
|
+
|
20
|
+
def has_schedule?
|
21
|
+
if self.blank? or self.schedule_info.blank? or !self.schedule_info.is_a?(Hash) or
|
22
|
+
!self.schedule_info.include?("start_time") or !self.schedule_info.include?("end_time") or
|
23
|
+
!self.schedule_info.include?("criteria") or self.schedule_info["start_time"].blank? or
|
24
|
+
self.schedule_info["end_time"].blank? or self.schedule_info["criteria"].blank? or self.schedule_info["criteria"] == "null"
|
25
|
+
return false
|
26
|
+
end
|
27
|
+
return true
|
28
|
+
end
|
29
|
+
|
30
|
+
def is_active_per_schedule?
|
31
|
+
active = true
|
32
|
+
|
33
|
+
if !has_schedule?
|
34
|
+
# missing or incomplete schedule information so assume active
|
35
|
+
else
|
36
|
+
# see if it is within the viewing window for the day
|
37
|
+
begin
|
38
|
+
if Clock.time >= Time.parse(self.schedule_info['start_time']) && Clock.time <= Time.parse(self.schedule_info['end_time'])
|
39
|
+
# and it matches the criteria
|
40
|
+
s = IceCube::Schedule.new(self.start_time)
|
41
|
+
s.add_recurrence_rule(RecurringSelect.dirty_hash_to_rule(self.schedule_info['criteria']))
|
42
|
+
active = s.occurs_on? Clock.time
|
43
|
+
else
|
44
|
+
active = false
|
45
|
+
end
|
46
|
+
rescue => e
|
47
|
+
active = false
|
48
|
+
Rails.logger.error("Unable to determine if schedule is active - #{e.message} for content #{self.id}")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
active
|
53
|
+
end
|
54
|
+
|
55
|
+
def create_schedule_info
|
56
|
+
self.schedule_info = {
|
57
|
+
"start_time" => ConcertoConfig[:content_default_start_time],
|
58
|
+
"end_time" => ConcertoConfig[:content_default_end_time],
|
59
|
+
"criteria" => nil
|
60
|
+
} if self.schedule_info.nil?
|
61
|
+
end
|
62
|
+
|
63
|
+
def load_schedule_info
|
64
|
+
self.schedule_info = JSON.load(self.schedule) rescue {}
|
65
|
+
create_schedule_info
|
66
|
+
if self.schedule_info.has_key?('criteria') and self.schedule_info['criteria'] == 'null'
|
67
|
+
self.schedule_info['criteria'] = nil
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def save_schedule_info
|
72
|
+
self.schedule = JSON.dump(self.schedule_info)
|
73
|
+
end
|
74
|
+
|
75
|
+
def schedule_in_words
|
76
|
+
if has_schedule?
|
77
|
+
s = IceCube::Schedule.new(self.start_time)
|
78
|
+
s.add_recurrence_rule(RecurringSelect.dirty_hash_to_rule(self.schedule_info['criteria']))
|
79
|
+
s.to_s
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="subblock">
|
2
|
+
<p class="uppercase" style="margin-bottom: 0px;"><small><b><%= t('.schedule') %></b></small></p>
|
3
|
+
|
4
|
+
<ul>
|
5
|
+
<% if @content.respond_to?(:has_schedule?) and @content.has_schedule? %>
|
6
|
+
<li><%=t('.from') %> <%= l Time.parse(@content.schedule_info['start_time']), :format => :twelve_hour_time %></li>
|
7
|
+
<li><%=t('.until') %> <%= l Time.parse(@content.schedule_info['end_time']),:format => :twelve_hour_time %></li>
|
8
|
+
<li><%= @content.schedule_in_words %></li>
|
9
|
+
<% else %>
|
10
|
+
<li><%=t('.available')%></li>
|
11
|
+
<% end %>
|
12
|
+
</ul>
|
13
|
+
</div>
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<%= stylesheet_link_tag "concerto_content_scheduling/application", media: "all" %>
|
2
|
+
<%= javascript_include_tag "concerto_content_scheduling/application" %>
|
3
|
+
|
4
|
+
<%
|
5
|
+
rules = []
|
6
|
+
if !@content.schedule_info.blank? and @content.schedule_info.has_key?('criteria') and
|
7
|
+
!@content.schedule_info['criteria'].blank? and @content.schedule_info['criteria'] != "null"
|
8
|
+
rules << RecurringSelect.dirty_hash_to_rule(@content.schedule_info['criteria'])
|
9
|
+
end
|
10
|
+
%>
|
11
|
+
|
12
|
+
<fieldset>
|
13
|
+
<legend><span><%=t('.schedule')%></span></legend>
|
14
|
+
<%= form.fields_for :schedule_info do |schedule| %>
|
15
|
+
<div class="row-fluid">
|
16
|
+
<div class="span6">
|
17
|
+
<%= schedule.label :criteria, t('.frequency') %>
|
18
|
+
<%= schedule.select_recurring :criteria, rules %>
|
19
|
+
</div>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<br />
|
23
|
+
|
24
|
+
<div class="row-fluid">
|
25
|
+
<div class="span3">
|
26
|
+
<div class="clearfix datetime">
|
27
|
+
<%= schedule.label :start_time, t('.from_time')%>
|
28
|
+
<div class="input">
|
29
|
+
<div class="input-prepend">
|
30
|
+
<span class="add-on"><%= t(:at) %></span>
|
31
|
+
<%= schedule.text_field :start_time, :maxlength => 20, :value => @content.schedule_info['start_time'], :class => "timefield input-small" %>
|
32
|
+
</div>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<div class="span3">
|
38
|
+
<div class="clearfix datetime">
|
39
|
+
<%= schedule.label :end_time, t('.until_time')%>
|
40
|
+
<div class="input">
|
41
|
+
<div class="input-prepend">
|
42
|
+
<span class="add-on"><%=t(:at)%></span>
|
43
|
+
<%= schedule.text_field :end_time, :value => @content.schedule_info['end_time'], :maxlength => 20, :class => "timefield input-small" %>
|
44
|
+
</div>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
</div>
|
49
|
+
<% end %>
|
50
|
+
</fieldset>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>ConcertoContentScheduling</title>
|
5
|
+
<%= stylesheet_link_tag "concerto_content_scheduling/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "concerto_content_scheduling/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
en:
|
2
|
+
concerto_content_scheduling:
|
3
|
+
|
4
|
+
content:
|
5
|
+
schedule:
|
6
|
+
frequency: 'Frequency'
|
7
|
+
schedule: 'Schedule'
|
8
|
+
from_time: 'From Time'
|
9
|
+
until_time: 'Until Time'
|
10
|
+
details:
|
11
|
+
available: 'Available'
|
12
|
+
from: 'from'
|
13
|
+
until: 'until'
|
14
|
+
not_scheduled: 'Not Scheduled'
|
15
|
+
schedule: 'Schedule'
|
data/config/routes.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'recurring_select'
|
2
|
+
|
3
|
+
module ConcertoContentScheduling
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
isolate_namespace ConcertoContentScheduling
|
6
|
+
engine_name 'concerto_content_scheduling'
|
7
|
+
|
8
|
+
def plugin_info(plugin_info_class)
|
9
|
+
@plugin_info ||= plugin_info_class.new do
|
10
|
+
|
11
|
+
extend_model Content, ConcertoContentScheduling::Concerns::Scheduling
|
12
|
+
|
13
|
+
add_view_hook "ContentsController",
|
14
|
+
:content_form,
|
15
|
+
:partial => "concerto_content_scheduling/content/schedule"
|
16
|
+
|
17
|
+
add_view_hook "ContentsController",
|
18
|
+
:content_details,
|
19
|
+
:partial => "concerto_content_scheduling/content/details"
|
20
|
+
|
21
|
+
add_view_hook "ContentsController",
|
22
|
+
:tile_labels,
|
23
|
+
:partial => "concerto_content_scheduling/content/tile_labels"
|
24
|
+
|
25
|
+
# filter the contents according to the schedule
|
26
|
+
# the manykinds plugin if concurrently enabled will cause this to be skipped
|
27
|
+
add_controller_hook "Subscription", :filter_contents, :after do
|
28
|
+
@contents.reject!{|c| !c.is_active_per_schedule?}
|
29
|
+
end
|
30
|
+
|
31
|
+
add_controller_hook "ContentsController", :update_params, :after do
|
32
|
+
@attributes.concat([:schedule_info => [:criteria, :start_time, :end_time]])
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|