candl 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +41 -4
- data/Rakefile +1 -1
- data/app/assets/config/candle_manifest.js +2 -2
- data/app/assets/javascripts/{candle → candl}/application.js +0 -0
- data/app/assets/javascripts/{candle → candl}/calendar.coffee +0 -0
- data/app/assets/stylesheets/{candle → candl}/application.scss +0 -0
- data/app/assets/stylesheets/{candle → candl}/calendar.scss +0 -0
- data/app/controllers/{candle → candl}/application_controller.rb +1 -1
- data/app/controllers/{candle → candl}/calendar_controller.rb +2 -2
- data/app/helpers/{candle → candl}/application_helper.rb +1 -1
- data/app/helpers/{candle → candl}/calendar_helper.rb +1 -1
- data/app/jobs/{candle → candl}/application_job.rb +1 -1
- data/app/mailers/{candle → candl}/application_mailer.rb +1 -1
- data/app/models/{candle → candl}/application_record.rb +1 -1
- data/app/views/candle/calendar/_agenda.slim +2 -2
- data/app/views/candle/calendar/_frame.slim +6 -7
- data/app/views/candle/calendar/_month.slim +7 -7
- data/app/views/candle/calendar/show.slim +1 -1
- data/app/views/layouts/candl/application.html.erb +16 -0
- data/config/routes.rb +1 -1
- data/lib/{candle → candl}/agenda_model.rb +1 -1
- data/lib/{candle → candl}/engine.rb +3 -3
- data/lib/{candle → candl}/event_loader_model.rb +7 -2
- data/lib/{candle → candl}/month_model.rb +1 -1
- data/lib/candl/version.rb +3 -0
- data/lib/candl.rb +9 -0
- data/lib/tasks/{candle_tasks.rake → candl_tasks.rake} +1 -1
- data/spec/{candle_spec.rb → candl_spec.rb} +41 -41
- data/spec/dummy/app/assets/config/manifest.js +1 -1
- data/spec/dummy/app/assets/javascripts/application.js +1 -1
- data/spec/dummy/app/assets/stylesheets/application.css +1 -1
- data/spec/dummy/app/views/sample/index-old.html.erb +1 -1
- data/spec/dummy/app/views/sample/show.slim +1 -1
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/environments/production.rb +94 -94
- data/spec/dummy/config/routes.rb +1 -1
- metadata +28 -27
- data/app/views/layouts/candle/application.html.erb +0 -16
- data/lib/candle/version.rb +0 -3
- data/lib/candle.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cfbd460e92519f419a3991ea2d262511351e8f1dde3881660326a579820f88b
|
4
|
+
data.tar.gz: 51af14b7e89684f5877e41a00d1899e3ca3f8deadde218cf486504f68110f6a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '038bdea768c5a4f83ecf3f9c5d17f10dff50adde8ba147c01e78b0e53961fb829ee43219c3b1882296b3248606bddb5061558e68dbe0c8b59479c08ab58a90df'
|
7
|
+
data.tar.gz: 066fdb81b06cc826be4cfb58d9b3595306543318ca4a379737a243e5171f62788a047370af72f69259353a06b71baa88d1dee4ac624b3cb3a983eb8919645b20
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# Candl
|
2
2
|
|
3
3
|
This gem helps load and display a calendar from google calendar in an agenda or month style view.
|
4
4
|
|
@@ -6,7 +6,7 @@ This gem helps load and display a calendar from google calendar in an agenda or
|
|
6
6
|
|
7
7
|
The gem consists of mainly three models. One - the event loader model - is focusing on loading the events from the google server via a restfull api and an api key. The other two are the agenda and month model wich offer functionality to organize the data for an agenda or month view. Next to the models are the views wich come with a "_frame.slim" view. This view can be included in a host view as a partial. This way one can display a calendar inside of another page. The "_frame.slim" is the entry point that prepares the model and view for the respective view type (month/agenda). (It does not come with a seperate week view.)
|
8
8
|
|
9
|
-
Find an example inclusion of the _frame.slim partial in the show.slim file in
|
9
|
+
Find an example inclusion of the _frame.slim partial in the show.slim file in candl/spec/dummy/app/views/sample/show.slim.
|
10
10
|
|
11
11
|
The main steps to use this gem are:
|
12
12
|
- Initialize an agenda or month model object with a config that specifies these values:
|
@@ -45,7 +45,7 @@ Then once configured you can load the events inside of the current timeframe and
|
|
45
45
|
Add this line to your application's Gemfile:
|
46
46
|
|
47
47
|
```ruby
|
48
|
-
gem '
|
48
|
+
gem 'candl'
|
49
49
|
```
|
50
50
|
|
51
51
|
And then execute:
|
@@ -55,7 +55,44 @@ $ bundle
|
|
55
55
|
|
56
56
|
Or install it yourself as:
|
57
57
|
```bash
|
58
|
-
$ gem install
|
58
|
+
$ gem install candl
|
59
|
+
```
|
60
|
+
|
61
|
+
Additionally:
|
62
|
+
Require the library in the ./config/application.rb of your ruby on rails application.
|
63
|
+
```ruby
|
64
|
+
# ./config/application.rb
|
65
|
+
require 'candl'
|
66
|
+
```
|
67
|
+
|
68
|
+
In the view you want the calendar to appear initialize a configuration hash like so:
|
69
|
+
```slim
|
70
|
+
- config = { \
|
71
|
+
calendar: { \
|
72
|
+
google_calendar_api_host_base_path: "https://www.googleapis.com/calendar/v3/calendars/", \
|
73
|
+
calendar_id: "grhnk1uaotql6gv2dkf9ldmqjc@group.calendar.google.com", \
|
74
|
+
api_key: "AIzaSyD1UIlX0n4-DnY3hSoTkeTZFbbsNO2g67E" \
|
75
|
+
}, \
|
76
|
+
agenda: { \
|
77
|
+
display_day_count: 14, \
|
78
|
+
days_shift_coefficient: 7 \
|
79
|
+
}, \
|
80
|
+
month: { \
|
81
|
+
summary_teaser_length_in_characters: 42, \
|
82
|
+
delta_start_of_weekday_from_sunday: 1 \
|
83
|
+
}, \
|
84
|
+
general: { \
|
85
|
+
maps_query_host: "https://www.google.de/maps", \
|
86
|
+
maps_query_parameter: "q", \
|
87
|
+
cache_update_interval_in_s: 7200 \
|
88
|
+
} \
|
89
|
+
}
|
90
|
+
```
|
91
|
+
In this example done in a view that uses .slim instead of .erb but in the end config is just a ruby hash that needs to have the right key's and sensible values for them.
|
92
|
+
|
93
|
+
Then at the position in your view where the calendar is supposed to show itself:
|
94
|
+
```slim
|
95
|
+
= render partial: "candl/calendar/frame", locals: { config: config }
|
59
96
|
```
|
60
97
|
|
61
98
|
## Contributing
|
data/Rakefile
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
//= link_directory ../javascripts/
|
2
|
-
//= link_directory ../stylesheets/
|
1
|
+
//= link_directory ../javascripts/candl .js
|
2
|
+
//= link_directory ../stylesheets/candl .css
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -2,7 +2,7 @@
|
|
2
2
|
- unless calendar_agenda.agenda_grouped_events.empty?
|
3
3
|
.agenda
|
4
4
|
- calendar_agenda.agenda_grouped_events.keys.sort.each do |date|
|
5
|
-
.row_head class=
|
5
|
+
.row_head class=Candl::AgendaModel.emphasize_date(date, Date.today, 'today', 'not_today') = l(date, format: '%A, %e. %B %Y')
|
6
6
|
- calendar_agenda.agenda_grouped_events[date].each do |event|
|
7
7
|
|
8
8
|
.event_shell
|
@@ -12,7 +12,7 @@
|
|
12
12
|
span.time = event.dtstart.localtime.strftime('%k:%M')
|
13
13
|
- else
|
14
14
|
span.time ▶
|
15
|
-
span.flex_wrap_it.breakable.summary{ title =
|
15
|
+
span.flex_wrap_it.breakable.summary{ title = Candl::AgendaModel.summary_title(event) } == event.summary.to_s.force_encoding("UTF-8")
|
16
16
|
i class="material-icons auto_margin_left" arrow_drop_down
|
17
17
|
|
18
18
|
.details style="display: none;"
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
- events_error_free = true
|
3
2
|
- is_month = params[:v] != 'a'
|
4
3
|
- current_shift_factor = params[:s] || 0
|
@@ -8,19 +7,19 @@
|
|
8
7
|
- if is_month
|
9
8
|
- begin
|
10
9
|
- month = Rails.cache.fetch("#month/#{current_shift_factor}/#{date_today}", expires_in: update_interval) do
|
11
|
-
-
|
10
|
+
- Candl::MonthModel.new(config, current_shift_factor, date_today)
|
12
11
|
- rescue => exception
|
13
12
|
- events_error_free = false
|
14
|
-
- puts "
|
13
|
+
- puts "\033[31mERROR - GOT EXCEPTION:\033[0m"
|
15
14
|
- puts exception
|
16
15
|
/ Maybe there is a beter way to signal the exception?
|
17
16
|
- else
|
18
17
|
- begin
|
19
18
|
- agenda = Rails.cache.fetch("#agenda/#{current_shift_factor}/#{date_today}", expires_in: update_interval) do
|
20
|
-
-
|
19
|
+
- Candl::AgendaModel.new(config, current_shift_factor, date_today)
|
21
20
|
- rescue => exception
|
22
21
|
- events_error_free = false
|
23
|
-
- puts "
|
22
|
+
- puts "\033[31mERROR - GOT EXCEPTION:\033[0m"
|
24
23
|
- puts exception
|
25
24
|
/ Maybe there is a beter way to signal the exception?
|
26
25
|
|
@@ -51,9 +50,9 @@
|
|
51
50
|
|
52
51
|
.calendar
|
53
52
|
- if is_month
|
54
|
-
= render partial: "
|
53
|
+
= render partial: "candl/calendar/month", locals: { calendar_month: model }
|
55
54
|
- else
|
56
|
-
= render partial: "
|
55
|
+
= render partial: "candl/calendar/agenda", locals: { calendar_agenda: model }
|
57
56
|
|
58
57
|
- else
|
59
58
|
.error_message Der Kalender kann wegen einer kurzzeitigen technischen Störung gerade nicht angezeigt werden. Bitte versuchen Sie es in einer Weile noch einmal.
|
@@ -9,11 +9,11 @@
|
|
9
9
|
th.weekday_name_header scope="col" = l(date, format: '%A')
|
10
10
|
|
11
11
|
tbody
|
12
|
-
-
|
12
|
+
- Candl::MonthModel.weeks_in_months_view_dates(calendar_month.view_dates).times do |row|
|
13
13
|
tr.day_row
|
14
14
|
- 7.times do |collumn|
|
15
15
|
- current_day = calendar_month.view_dates[7 * row + collumn]
|
16
|
-
td class=
|
16
|
+
td class=Candl::MonthModel.emphasize_date(current_day, Date.today, 'bg-info', 'bg-default')
|
17
17
|
- if current_day.day == 1
|
18
18
|
.day_head = current_day.day.to_s + '. ' + l(current_day, format: '%b.')
|
19
19
|
- else
|
@@ -26,7 +26,7 @@
|
|
26
26
|
- collumn = 0
|
27
27
|
- while collumn < 7 do
|
28
28
|
- current_day = calendar_month.view_dates[7 * row + collumn]
|
29
|
-
- current_event =
|
29
|
+
- current_event = Candl::MonthModel.find_best_fit_for_day(calendar_month.view_dates[7 * row], current_day, weekly_multiday_event_heap)
|
30
30
|
- if current_event
|
31
31
|
- weekly_multiday_event_heap.delete_if{ |event| event.uid == current_event.uid }
|
32
32
|
|
@@ -36,12 +36,12 @@
|
|
36
36
|
|
37
37
|
- if current_event_length_within_current_week > 0
|
38
38
|
td.small_padding colspan=current_event_length_within_current_week
|
39
|
-
.multiday_event.onclick_open_backdrop class=
|
39
|
+
.multiday_event.onclick_open_backdrop class=Candl::MonthModel.multiday_event_cutoff(current_event.dtstart < current_day, current_event.dtend > (calendar_month.view_dates[7 * row + 6] + 1.day), 'multiday_event_leftcut', 'multiday_event_bothcut', 'multiday_event_rightcut')
|
40
40
|
|
41
41
|
.snowflake_popover[data-placement="bottom" data-toggle="popover" data-container="body" type="button" data-html="true" href="#"]
|
42
42
|
|
43
43
|
div
|
44
|
-
span.summary.breakable{ title =
|
44
|
+
span.summary.breakable{ title = Candl::MonthModel.summary_title(current_event) } == current_event.summary.to_s.force_encoding("UTF-8").truncate(calendar_month.summary_teaser_length().to_i, seperator: ' ')
|
45
45
|
|
46
46
|
.popover_content.hide
|
47
47
|
.close_span
|
@@ -81,7 +81,7 @@
|
|
81
81
|
tr.events_row
|
82
82
|
- 7.times do |collumn|
|
83
83
|
- current_day = calendar_month.view_dates[7 * row + collumn]
|
84
|
-
td class=
|
84
|
+
td class=Candl::MonthModel.emphasize_date(current_day, Date.today, 'bg-info', 'bg-default')
|
85
85
|
|
86
86
|
- if calendar_month.grouped_events[current_day]
|
87
87
|
- calendar_month.grouped_events[current_day].sort_by{ |event| event.dtstart.localtime }.each do |event|
|
@@ -91,7 +91,7 @@
|
|
91
91
|
|
92
92
|
div
|
93
93
|
span.time = event.dtstart.localtime.strftime('%k:%M')
|
94
|
-
span.summary.breakable{ title =
|
94
|
+
span.summary.breakable{ title = Candl::MonthModel.summary_title(event) } == event.summary.to_s.force_encoding("UTF-8").truncate(calendar_month.summary_teaser_length.to_i, seperator: ' ')
|
95
95
|
|
96
96
|
.popover_content.hide
|
97
97
|
.close_span
|
@@ -1,3 +1,3 @@
|
|
1
|
-
div Hello, this is the index/show view of the "
|
1
|
+
div Hello, this is the index/show view of the "candl" rails engine gem.
|
2
2
|
|
3
3
|
div You should not see this page. The calendar is supposed to be integrated via a partial (_frame.slim) wich will then render the calendar view inside of the host-apps page.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Candl</title>
|
5
|
+
<%= csrf_meta_tags %>
|
6
|
+
<%= csp_meta_tag %>
|
7
|
+
|
8
|
+
<%= stylesheet_link_tag "candl/application", media: "all" %>
|
9
|
+
<%= javascript_include_tag "candl/application" %>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
|
13
|
+
<%= yield %>
|
14
|
+
|
15
|
+
</body>
|
16
|
+
</html>
|
data/config/routes.rb
CHANGED
@@ -5,10 +5,10 @@ require "material_icons"
|
|
5
5
|
require "bootstrap-sass"
|
6
6
|
require "rails_autolink"
|
7
7
|
|
8
|
-
module
|
8
|
+
module Candl
|
9
9
|
class Engine < ::Rails::Engine
|
10
|
-
isolate_namespace
|
11
|
-
initializer '
|
10
|
+
isolate_namespace Candl
|
11
|
+
initializer 'candl.assets' do |app|
|
12
12
|
%w(stylesheets javascripts).each do |sub|
|
13
13
|
app.config.assets.paths << root.join('app', 'assets', sub).to_s
|
14
14
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'uri'
|
3
3
|
|
4
|
-
module
|
4
|
+
module Candl
|
5
5
|
class EventLoaderModel
|
6
6
|
Event ||= Struct.new(:dtstart, :dtend, :summary, :description, :location, :uid)
|
7
7
|
def self.Event(dtstart, dtend, summary, description, location, uid)
|
@@ -41,7 +41,12 @@ module Candle
|
|
41
41
|
|
42
42
|
requested_events = JSON.parse(Net::HTTP.get(URI.parse(google_test_path)))
|
43
43
|
|
44
|
-
|
44
|
+
if requested_events["items"] != nil
|
45
|
+
restructured_events = requested_events["items"].map{ |e| e["start"]["dateTime"] != nil ? Event.new(DateTime.parse(e["start"]["dateTime"]), DateTime.parse(e["end"]["dateTime"]), e["summary"], e["description"], e["location"], e["id"]) : Event.new(Date.parse(e["start"]["date"]), Date.parse(e["end"]["date"]), e["summary"], e["description"], e["location"], e["id"]) }
|
46
|
+
else
|
47
|
+
# raise Exception.new("Calendar event request failed and responded with:\n #{requested_events}")
|
48
|
+
raise "Calendar event request failed and responded with:\n #{requested_events}"
|
49
|
+
end
|
45
50
|
|
46
51
|
restructured_events.to_a
|
47
52
|
end
|
data/lib/candl.rb
ADDED
@@ -23,16 +23,16 @@ google_base_path = test_config[:calendar][:google_calendar_api_host_base_path]
|
|
23
23
|
calendar_id = test_config[:calendar][:calendar_id]
|
24
24
|
api_key = test_config[:calendar][:api_key]
|
25
25
|
|
26
|
-
describe
|
26
|
+
describe Candl do
|
27
27
|
it "has a version number" do
|
28
|
-
expect(
|
28
|
+
expect(Candl::VERSION).not_to be nil
|
29
29
|
end
|
30
30
|
|
31
31
|
context "Json parsing" do
|
32
32
|
let(:current_shift_factor) { 0 }
|
33
33
|
let(:fake_today) { Date.parse("2019-01-07") }
|
34
34
|
|
35
|
-
let(:agenda) {
|
35
|
+
let(:agenda) { Candl::AgendaModel.new(test_config, current_shift_factor, fake_today) }
|
36
36
|
|
37
37
|
it "Test agenda config" do
|
38
38
|
expect(agenda.display_day_count).to eq(14)
|
@@ -42,24 +42,24 @@ describe Candle do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
|
45
|
-
RSpec.describe
|
45
|
+
RSpec.describe Candl::EventLoaderModel do
|
46
46
|
context "Get AGNEDA events" do
|
47
47
|
let(:current_shift_factor) { 0 }
|
48
48
|
let(:fake_today) { Date.parse("2019-01-07") }
|
49
|
-
let(:agenda) {
|
49
|
+
let(:agenda) { Candl::AgendaModel.new(test_config, current_shift_factor, fake_today) }
|
50
50
|
let(:current_start_date) { agenda.current_start_date(current_shift_factor, fake_today) }
|
51
51
|
let(:current_end_date) { agenda.current_end_date(current_shift_factor, fake_today) }
|
52
52
|
|
53
|
-
let(:unspread_event_1) {
|
54
|
-
let(:unspread_event_2) {
|
55
|
-
let(:unspread_event_3) {
|
56
|
-
let(:unspread_event_4) {
|
53
|
+
let(:unspread_event_1) { Candl::EventLoaderModel::Event.new(DateTime.parse("2019-01-08T17:00:00"), DateTime.parse("2019-01-08T19:30:00"), "summary_1", "description_1", "location_1", "uid_1") }
|
54
|
+
let(:unspread_event_2) { Candl::EventLoaderModel::Event.new(Date.parse("2019-01-08"), Date.parse("2019-01-11"), "summary_2", "description_2", "location_2", "uid_2") }
|
55
|
+
let(:unspread_event_3) { Candl::EventLoaderModel::Event.new(Date.parse("2019-01-09"), Date.parse("2019-01-11"), "summary_2", "description_2", "location_2", "uid_2") }
|
56
|
+
let(:unspread_event_4) { Candl::EventLoaderModel::Event.new(Date.parse("2019-01-10"), Date.parse("2019-01-11"), "summary_2", "description_2", "location_2", "uid_2") }
|
57
57
|
|
58
58
|
let(:unspread_events) { [unspread_event_1, unspread_event_2] }
|
59
59
|
let(:spread_events) { [unspread_event_3, unspread_event_4] }
|
60
60
|
|
61
61
|
it "Spread multiday events" do
|
62
|
-
expect(
|
62
|
+
expect(Candl::EventLoaderModel.spread_multiday_events(unspread_events, current_start_date, current_end_date)).to eq(spread_events)
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -67,16 +67,16 @@ RSpec.describe Candle::EventLoaderModel do
|
|
67
67
|
let(:from) { Date.parse("2019-01-01") }
|
68
68
|
let(:to) { Date.parse("2019-01-31") }
|
69
69
|
it "Build google request path" do
|
70
|
-
expect(
|
70
|
+
expect(Candl::EventLoaderModel.build_google_request_path(google_base_path, calendar_id, api_key, from, to)).to eq("#{google_base_path}#{calendar_id}/events?key=#{api_key}&singleEvents=true&orderBy=startTime&timeMin=#{from}&timeMax=#{to}")
|
71
71
|
end
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
75
|
|
76
|
-
RSpec.describe
|
76
|
+
RSpec.describe Candl::AgendaModel do
|
77
77
|
let(:current_shift_factor) { 0 }
|
78
78
|
let(:fake_today) { Date.parse("2019-01-07") }
|
79
|
-
let(:agenda) {
|
79
|
+
let(:agenda) { Candl::AgendaModel.new(test_config, current_shift_factor, fake_today) }
|
80
80
|
let(:page_path) { "page.host" }
|
81
81
|
|
82
82
|
context "Helper functionality" do
|
@@ -102,10 +102,10 @@ RSpec.describe Candle::AgendaModel do
|
|
102
102
|
expect(agenda.current_shift_for_month(4, Date.parse("2019-01-08"))).to eq(1)
|
103
103
|
end
|
104
104
|
it "emphasized date" do
|
105
|
-
expect(
|
105
|
+
expect(Candl::AgendaModel.emphasize_date(Date.parse("2019-01-08"), Date.parse("2019-01-08"), "emphasized", "regular")).to eq("emphasized")
|
106
106
|
end
|
107
107
|
it "regular date" do
|
108
|
-
expect(
|
108
|
+
expect(Candl::AgendaModel.emphasize_date(Date.parse("2019-01-08"), Date.parse("2019-01-09"), "emphasized", "regular")).to eq("regular")
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
@@ -132,10 +132,10 @@ RSpec.describe Candle::AgendaModel do
|
|
132
132
|
|
133
133
|
context "Month/Agenda view toggle:" do
|
134
134
|
let(:fake_today) { Date.parse("2019-01-07") }
|
135
|
-
let(:date_month_start) {
|
136
|
-
let(:date_month_end) {
|
135
|
+
let(:date_month_start) { Candl::MonthModel.current_month_start(current_shift_factor, fake_today) }
|
136
|
+
let(:date_month_end) { Candl::MonthModel.current_month_end(current_shift_factor, fake_today) }
|
137
137
|
|
138
|
-
let(:month) {
|
138
|
+
let(:month) { Candl::MonthModel.new(test_config, current_shift_factor, fake_today) }
|
139
139
|
let(:months_view_dates) { month.generate_months_view_dates(date_month_start, date_month_end) }
|
140
140
|
|
141
141
|
let(:events) { month.month_events(months_view_dates.first, months_view_dates.last) }
|
@@ -150,13 +150,13 @@ RSpec.describe Candle::AgendaModel do
|
|
150
150
|
end
|
151
151
|
|
152
152
|
|
153
|
-
RSpec.describe
|
153
|
+
RSpec.describe Candl::MonthModel do
|
154
154
|
let(:current_shift_factor) { 0 }
|
155
155
|
let(:fake_today) { Date.parse("2019-01-07") }
|
156
|
-
let(:date_month_start) {
|
157
|
-
let(:date_month_end) {
|
156
|
+
let(:date_month_start) { Candl::MonthModel.current_month_start(current_shift_factor, fake_today) }
|
157
|
+
let(:date_month_end) { Candl::MonthModel.current_month_end(current_shift_factor, fake_today) }
|
158
158
|
|
159
|
-
let(:month) {
|
159
|
+
let(:month) { Candl::MonthModel.new(test_config, current_shift_factor, fake_today) }
|
160
160
|
let(:months_view_dates) { month.generate_months_view_dates(date_month_start, date_month_end) }
|
161
161
|
|
162
162
|
let(:page_path) { "http://page.path/" }
|
@@ -169,11 +169,11 @@ RSpec.describe Candle::MonthModel do
|
|
169
169
|
|
170
170
|
let(:first_weekday) { Date.parse("2019-01-07") }
|
171
171
|
let(:day) { Date.parse("2019-01-08") }
|
172
|
-
let(:event_heap) { [
|
173
|
-
|
172
|
+
let(:event_heap) { [Candl::EventLoaderModel::Event.new(Date.parse("2019-01-08"), Date.parse("2019-01-11"), "s_1", "d_1", "l_1", "u_1"), Candl::EventLoaderModel::Event.new(Date.parse("2019-01-08"), Date.parse("2019-01-9"), "s_1", "d_1", "l_1", "u_1"), Candl::EventLoaderModel::Event.new(Date.parse("2019-01-08"), Date.parse("2019-01-10"), "s_1", "d_1", "l_1", "u_1"),
|
173
|
+
Candl::EventLoaderModel::Event.new(Date.parse("2019-01-09"), Date.parse("2019-01-11"), "s_1", "d_1", "l_1", "u_1")] }
|
174
174
|
|
175
175
|
it "Find best fit for day" do
|
176
|
-
expect(
|
176
|
+
expect(Candl::MonthModel.find_best_fit_for_day(first_weekday, day, event_heap)).to eq(Candl::EventLoaderModel::Event.new(Date.parse("2019-01-08"), Date.parse("2019-01-11"), "s_1", "d_1", "l_1", "u_1"))
|
177
177
|
end
|
178
178
|
|
179
179
|
|
@@ -196,23 +196,23 @@ RSpec.describe Candle::MonthModel do
|
|
196
196
|
end
|
197
197
|
|
198
198
|
it "emphasized date" do
|
199
|
-
expect(
|
199
|
+
expect(Candl::MonthModel.emphasize_date(Date.parse("2019-01-08"), Date.parse("2019-01-08"), "emphasized", "regular")).to eq("emphasized")
|
200
200
|
end
|
201
201
|
it "regular date" do
|
202
|
-
expect(
|
202
|
+
expect(Candl::MonthModel.emphasize_date(Date.parse("2019-01-08"), Date.parse("2019-01-09"), "emphasized", "regular")).to eq("regular")
|
203
203
|
end
|
204
204
|
|
205
205
|
it "multiday event cutoff start" do
|
206
|
-
expect(
|
206
|
+
expect(Candl::MonthModel.multiday_event_cutoff(true, false, "start", "both", "end")).to eq("start")
|
207
207
|
end
|
208
208
|
it "multiday event cutoff both" do
|
209
|
-
expect(
|
209
|
+
expect(Candl::MonthModel.multiday_event_cutoff(true, true, "start", "both", "end")).to eq("both")
|
210
210
|
end
|
211
211
|
it "multiday event cutoff end" do
|
212
|
-
expect(
|
212
|
+
expect(Candl::MonthModel.multiday_event_cutoff(false, true, "start", "both", "end")).to eq("end")
|
213
213
|
end
|
214
214
|
it "multiday event cutoff none" do
|
215
|
-
expect(
|
215
|
+
expect(Candl::MonthModel.multiday_event_cutoff(false, false, "start", "both", "end")).to eq("")
|
216
216
|
end
|
217
217
|
|
218
218
|
let(:weekday_dates_of_date_today) { [Date.parse("2019-01-07"), Date.parse("2019-01-08"), Date.parse("2019-01-09"), Date.parse("2019-01-10"), Date.parse("2019-01-11"), Date.parse("2019-01-12"), Date.parse("2019-01-13")] }
|
@@ -231,8 +231,8 @@ RSpec.describe Candle::MonthModel do
|
|
231
231
|
|
232
232
|
it "months view dates along 12 * 1 month shifts" do
|
233
233
|
shifts_in_year.times do |shift|
|
234
|
-
current_month_start =
|
235
|
-
current_month_end =
|
234
|
+
current_month_start = Candl::MonthModel.current_month_start(shift, fake_today)
|
235
|
+
current_month_end = Candl::MonthModel.current_month_end(shift, fake_today)
|
236
236
|
|
237
237
|
current_months_view_dates = month.generate_months_view_dates(current_month_start, current_month_end)
|
238
238
|
|
@@ -244,24 +244,24 @@ RSpec.describe Candle::MonthModel do
|
|
244
244
|
let(:day_in_five_week_month) { Date.parse("2019-01-01") }
|
245
245
|
let(:day_in_six_week_month) { Date.parse("2019-03-01") }
|
246
246
|
it "weeks in months view dates" do
|
247
|
-
five_week_month_start =
|
248
|
-
five_week_month_end =
|
247
|
+
five_week_month_start = Candl::MonthModel.current_month_start(0, day_in_five_week_month)
|
248
|
+
five_week_month_end = Candl::MonthModel.current_month_end(0, day_in_five_week_month)
|
249
249
|
|
250
|
-
six_week_month_start =
|
251
|
-
six_week_month_end =
|
250
|
+
six_week_month_start = Candl::MonthModel.current_month_start(0, day_in_six_week_month)
|
251
|
+
six_week_month_end = Candl::MonthModel.current_month_end(0, day_in_six_week_month)
|
252
252
|
|
253
253
|
five_week_months_view_dates = month.generate_months_view_dates(five_week_month_start, five_week_month_end)
|
254
254
|
six_week_months_view_dates = month.generate_months_view_dates(six_week_month_start, six_week_month_end)
|
255
255
|
|
256
|
-
expect(
|
257
|
-
expect(
|
256
|
+
expect(Candl::MonthModel.weeks_in_months_view_dates(five_week_months_view_dates)).to eq(5)
|
257
|
+
expect(Candl::MonthModel.weeks_in_months_view_dates(six_week_months_view_dates)).to eq(6)
|
258
258
|
end
|
259
259
|
|
260
260
|
it "current month start" do
|
261
|
-
expect(
|
261
|
+
expect(Candl::MonthModel.current_month_start(current_shift_factor, fake_today)).to eq(date_month_start)
|
262
262
|
end
|
263
263
|
it "current month end" do
|
264
|
-
expect(
|
264
|
+
expect(Candl::MonthModel.current_month_end(current_shift_factor, fake_today)).to eq(date_month_end)
|
265
265
|
end
|
266
266
|
end
|
267
267
|
end
|
@@ -12,7 +12,7 @@
|
|
12
12
|
*
|
13
13
|
*= require_tree .
|
14
14
|
*= require_self
|
15
|
-
*= require
|
15
|
+
*= require candl/application
|
16
16
|
*/
|
17
17
|
|
18
18
|
/* There seems to be a bug that makes it necessary to have some sort of change to this file in order to have the typical asset pipeline behaviour. */
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<div>You should see the calendar rendered below:</div>
|
2
2
|
|
3
|
-
<%= render partial: '
|
3
|
+
<%= render partial: 'candl/calendar/frame', locals: { calendar_id: "grhnk1uaotql6gv2dkf9ldmqjc@group.calendar.google.com", api_key: "AIzaSyD1UIlX0n4-DnY3hSoTkeTZFbbsNO2g67E" } %>
|
@@ -1,94 +1,94 @@
|
|
1
|
-
Rails.application.configure do
|
2
|
-
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
-
|
4
|
-
# Code is not reloaded between requests.
|
5
|
-
config.cache_classes = true
|
6
|
-
|
7
|
-
# Eager load code on boot. This eager loads most of Rails and
|
8
|
-
# your application in memory, allowing both threaded web servers
|
9
|
-
# and those relying on copy on write to perform better.
|
10
|
-
# Rake tasks automatically ignore this option for performance.
|
11
|
-
config.eager_load = true
|
12
|
-
|
13
|
-
# Full error reports are disabled and caching is turned on.
|
14
|
-
config.consider_all_requests_local = false
|
15
|
-
config.action_controller.perform_caching = true
|
16
|
-
|
17
|
-
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
18
|
-
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
19
|
-
# config.require_master_key = true
|
20
|
-
|
21
|
-
# Disable serving static files from the `/public` folder by default since
|
22
|
-
# Apache or NGINX already handles this.
|
23
|
-
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
24
|
-
|
25
|
-
# Compress JavaScripts and CSS.
|
26
|
-
config.assets.js_compressor = :uglifier
|
27
|
-
# config.assets.css_compressor = :sass
|
28
|
-
|
29
|
-
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
30
|
-
config.assets.compile = false
|
31
|
-
|
32
|
-
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
33
|
-
|
34
|
-
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
35
|
-
# config.action_controller.asset_host = 'http://assets.example.com'
|
36
|
-
|
37
|
-
# Specifies the header that your server uses for sending files.
|
38
|
-
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
39
|
-
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
40
|
-
|
41
|
-
# Store uploaded files on the local file system (see config/storage.yml for options)
|
42
|
-
config.active_storage.service = :local
|
43
|
-
|
44
|
-
# Mount Action Cable outside main process or domain
|
45
|
-
# config.action_cable.mount_path = nil
|
46
|
-
# config.action_cable.url = 'wss://example.com/cable'
|
47
|
-
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
|
48
|
-
|
49
|
-
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
50
|
-
# config.force_ssl = true
|
51
|
-
|
52
|
-
# Use the lowest log level to ensure availability of diagnostic information
|
53
|
-
# when problems arise.
|
54
|
-
config.log_level = :debug
|
55
|
-
|
56
|
-
# Prepend all log lines with the following tags.
|
57
|
-
config.log_tags = [ :request_id ]
|
58
|
-
|
59
|
-
# Use a different cache store in production.
|
60
|
-
# config.cache_store = :mem_cache_store
|
61
|
-
|
62
|
-
# Use a real queuing backend for Active Job (and separate queues per environment)
|
63
|
-
# config.active_job.queue_adapter = :resque
|
64
|
-
# config.active_job.queue_name_prefix = "dummy_#{Rails.env}"
|
65
|
-
|
66
|
-
config.action_mailer.perform_caching = false
|
67
|
-
|
68
|
-
# Ignore bad email addresses and do not raise email delivery errors.
|
69
|
-
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
70
|
-
# config.action_mailer.raise_delivery_errors = false
|
71
|
-
|
72
|
-
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
73
|
-
# the I18n.default_locale when a translation cannot be found).
|
74
|
-
config.i18n.fallbacks = true
|
75
|
-
|
76
|
-
# Send deprecation notices to registered listeners.
|
77
|
-
config.active_support.deprecation = :notify
|
78
|
-
|
79
|
-
# Use default logging formatter so that PID and timestamp are not suppressed.
|
80
|
-
config.log_formatter = ::Logger::Formatter.new
|
81
|
-
|
82
|
-
# Use a different logger for distributed setups.
|
83
|
-
# require 'syslog/logger'
|
84
|
-
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
85
|
-
|
86
|
-
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
87
|
-
logger = ActiveSupport::Logger.new(STDOUT)
|
88
|
-
logger.formatter = config.log_formatter
|
89
|
-
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
90
|
-
end
|
91
|
-
|
92
|
-
# Do not dump schema after migrations.
|
93
|
-
config.active_record.dump_schema_after_migration = false
|
94
|
-
end
|
1
|
+
Rails.application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# Code is not reloaded between requests.
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both threaded web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
12
|
+
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
14
|
+
config.consider_all_requests_local = false
|
15
|
+
config.action_controller.perform_caching = true
|
16
|
+
|
17
|
+
# Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
|
18
|
+
# or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
|
19
|
+
# config.require_master_key = true
|
20
|
+
|
21
|
+
# Disable serving static files from the `/public` folder by default since
|
22
|
+
# Apache or NGINX already handles this.
|
23
|
+
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
24
|
+
|
25
|
+
# Compress JavaScripts and CSS.
|
26
|
+
config.assets.js_compressor = :uglifier
|
27
|
+
# config.assets.css_compressor = :sass
|
28
|
+
|
29
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
30
|
+
config.assets.compile = false
|
31
|
+
|
32
|
+
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
33
|
+
|
34
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
35
|
+
# config.action_controller.asset_host = 'http://assets.example.com'
|
36
|
+
|
37
|
+
# Specifies the header that your server uses for sending files.
|
38
|
+
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
|
39
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
|
40
|
+
|
41
|
+
# Store uploaded files on the local file system (see config/storage.yml for options)
|
42
|
+
config.active_storage.service = :local
|
43
|
+
|
44
|
+
# Mount Action Cable outside main process or domain
|
45
|
+
# config.action_cable.mount_path = nil
|
46
|
+
# config.action_cable.url = 'wss://example.com/cable'
|
47
|
+
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
|
48
|
+
|
49
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
50
|
+
# config.force_ssl = true
|
51
|
+
|
52
|
+
# Use the lowest log level to ensure availability of diagnostic information
|
53
|
+
# when problems arise.
|
54
|
+
config.log_level = :debug
|
55
|
+
|
56
|
+
# Prepend all log lines with the following tags.
|
57
|
+
config.log_tags = [ :request_id ]
|
58
|
+
|
59
|
+
# Use a different cache store in production.
|
60
|
+
# config.cache_store = :mem_cache_store
|
61
|
+
|
62
|
+
# Use a real queuing backend for Active Job (and separate queues per environment)
|
63
|
+
# config.active_job.queue_adapter = :resque
|
64
|
+
# config.active_job.queue_name_prefix = "dummy_#{Rails.env}"
|
65
|
+
|
66
|
+
config.action_mailer.perform_caching = false
|
67
|
+
|
68
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
69
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
70
|
+
# config.action_mailer.raise_delivery_errors = false
|
71
|
+
|
72
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
73
|
+
# the I18n.default_locale when a translation cannot be found).
|
74
|
+
config.i18n.fallbacks = true
|
75
|
+
|
76
|
+
# Send deprecation notices to registered listeners.
|
77
|
+
config.active_support.deprecation = :notify
|
78
|
+
|
79
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
80
|
+
config.log_formatter = ::Logger::Formatter.new
|
81
|
+
|
82
|
+
# Use a different logger for distributed setups.
|
83
|
+
# require 'syslog/logger'
|
84
|
+
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
85
|
+
|
86
|
+
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
87
|
+
logger = ActiveSupport::Logger.new(STDOUT)
|
88
|
+
logger.formatter = config.log_formatter
|
89
|
+
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
90
|
+
end
|
91
|
+
|
92
|
+
# Do not dump schema after migrations.
|
93
|
+
config.active_record.dump_schema_after_migration = false
|
94
|
+
end
|
data/spec/dummy/config/routes.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: candl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Schau
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-02-
|
11
|
+
date: 2019-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -244,9 +244,10 @@ dependencies:
|
|
244
244
|
- - ">="
|
245
245
|
- !ruby/object:Gem::Version
|
246
246
|
version: 3.8.0
|
247
|
-
description:
|
248
|
-
|
249
|
-
|
247
|
+
description: This gem provides functionality to handle the loading of event data from
|
248
|
+
a public google calendar via an api key. (Without the need for OAuth.) It does so
|
249
|
+
by offering functions that gather the event data, cache it and structure it in a
|
250
|
+
way that makes it easy to display in an agenda or monthly overview-like style.
|
250
251
|
email:
|
251
252
|
- andreas.schau@hicknhack-software.com
|
252
253
|
executables: []
|
@@ -257,33 +258,33 @@ files:
|
|
257
258
|
- README.md
|
258
259
|
- Rakefile
|
259
260
|
- app/assets/config/candle_manifest.js
|
260
|
-
- app/assets/javascripts/
|
261
|
-
- app/assets/javascripts/
|
262
|
-
- app/assets/stylesheets/
|
263
|
-
- app/assets/stylesheets/
|
264
|
-
- app/controllers/
|
265
|
-
- app/controllers/
|
266
|
-
- app/helpers/
|
267
|
-
- app/helpers/
|
268
|
-
- app/jobs/
|
269
|
-
- app/mailers/
|
270
|
-
- app/models/
|
261
|
+
- app/assets/javascripts/candl/application.js
|
262
|
+
- app/assets/javascripts/candl/calendar.coffee
|
263
|
+
- app/assets/stylesheets/candl/application.scss
|
264
|
+
- app/assets/stylesheets/candl/calendar.scss
|
265
|
+
- app/controllers/candl/application_controller.rb
|
266
|
+
- app/controllers/candl/calendar_controller.rb
|
267
|
+
- app/helpers/candl/application_helper.rb
|
268
|
+
- app/helpers/candl/calendar_helper.rb
|
269
|
+
- app/jobs/candl/application_job.rb
|
270
|
+
- app/mailers/candl/application_mailer.rb
|
271
|
+
- app/models/candl/application_record.rb
|
271
272
|
- app/views/candle/calendar/_agenda.slim
|
272
273
|
- app/views/candle/calendar/_frame.slim
|
273
274
|
- app/views/candle/calendar/_month.slim
|
274
275
|
- app/views/candle/calendar/show.slim
|
275
|
-
- app/views/layouts/
|
276
|
+
- app/views/layouts/candl/application.html.erb
|
276
277
|
- config/locales/de.yml
|
277
278
|
- config/locales/en.yml
|
278
279
|
- config/routes.rb
|
279
|
-
- lib/
|
280
|
-
- lib/
|
281
|
-
- lib/
|
282
|
-
- lib/
|
283
|
-
- lib/
|
284
|
-
- lib/
|
285
|
-
- lib/tasks/
|
286
|
-
- spec/
|
280
|
+
- lib/candl.rb
|
281
|
+
- lib/candl/agenda_model.rb
|
282
|
+
- lib/candl/engine.rb
|
283
|
+
- lib/candl/event_loader_model.rb
|
284
|
+
- lib/candl/month_model.rb
|
285
|
+
- lib/candl/version.rb
|
286
|
+
- lib/tasks/candl_tasks.rake
|
287
|
+
- spec/candl_spec.rb
|
287
288
|
- spec/dummy/Rakefile
|
288
289
|
- spec/dummy/app/assets/config/manifest.js
|
289
290
|
- spec/dummy/app/assets/javascripts/application.js
|
@@ -1835,8 +1836,8 @@ test_files:
|
|
1835
1836
|
- spec/dummy/config/puma.rb
|
1836
1837
|
- spec/dummy/config/storage.yml
|
1837
1838
|
- spec/dummy/config/environments/development.rb
|
1838
|
-
- spec/dummy/config/environments/production.rb
|
1839
1839
|
- spec/dummy/config/environments/test.rb
|
1840
|
+
- spec/dummy/config/environments/production.rb
|
1840
1841
|
- spec/dummy/config/initializers/application_controller_renderer.rb
|
1841
1842
|
- spec/dummy/config/initializers/assets.rb
|
1842
1843
|
- spec/dummy/config/initializers/backtrace_silencers.rb
|
@@ -3288,4 +3289,4 @@ test_files:
|
|
3288
3289
|
- spec/dummy/spec/helpers/sample_helper_spec.rb
|
3289
3290
|
- spec/spec_helper.rb
|
3290
3291
|
- spec/rails_helper.rb
|
3291
|
-
- spec/
|
3292
|
+
- spec/candl_spec.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>Candle</title>
|
5
|
-
<%= csrf_meta_tags %>
|
6
|
-
<%= csp_meta_tag %>
|
7
|
-
|
8
|
-
<%= stylesheet_link_tag "candle/application", media: "all" %>
|
9
|
-
<%= javascript_include_tag "candle/application" %>
|
10
|
-
</head>
|
11
|
-
<body>
|
12
|
-
|
13
|
-
<%= yield %>
|
14
|
-
|
15
|
-
</body>
|
16
|
-
</html>
|
data/lib/candle/version.rb
DELETED