Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Website
poul.org
Commits
72a61bfa
Verified
Commit
72a61bfa
authored
Oct 27, 2021
by
Roberto Bochet
Browse files
Fix generator courses page bug
parent
22676334
Changes
1
Hide whitespace changes
Inline
Side-by-side
_plugins/courses_pages_generator.rb
View file @
72a61bfa
...
...
@@ -98,12 +98,12 @@ module Jekyll
def
preprocessing_editions
(
site
)
site
.
data
[
"courses"
].
each
do
|
n
,
v
|
# checks begins and ends values
if
!
v
[
"begin"
]
or
!
v
[
"ends"
]
# retrieves dates from schedule
dates
=
v
[
"schedule"
].
map
{
|
s
|
s
[
"date"
]
}.
select
{
|
d
|
d
!=
nil
}.
map
{
|
d
|
DateTime
.
parse
(
d
)
}.
reverse
if
!
v
[
"begins"
]
or
!
v
[
"ends"
]
# if schedule dates are set they are used for update begins and ends
if
dates
.
size
!=
0
if
v
[
"schedule"
].
kind_of?
(
Array
)
# retrieves dates from schedule
dates
=
v
[
"schedule"
].
map
{
|
s
|
s
[
"date"
]
}.
select
{
|
d
|
d
!=
nil
}.
map
{
|
d
|
DateTime
.
parse
(
d
)
}.
reverse
v
[
"begins"
]
||=
dates
.
first
v
[
"ends"
]
||=
dates
.
last
...
...
@@ -111,23 +111,25 @@ module Jekyll
elsif
v
[
"begins"
]
!=
nil
v
[
"ends"
]
=
v
[
"begins"
]
else
@logger
.
warn
(
"In session
#{
n
}
is not define any time reference"
)
@logger
.
error
(
"In session
#{
n
}
is not define any time reference"
)
end
end
# check if edition has already been
v
[
"is_past"
]
=
v
[
"ends"
]
<
DateTime
.
now
v
[
"is_past"
]
=
v
[
"ends"
].
nil?
?
false
:
v
[
"ends"
]
<
DateTime
.
now
# fix levels composition of room value
v
[
"schedule"
].
each
do
|
s
|
if
s
[
"room"
]
!=
nil
&&
!
s
[
"room"
].
is_a?
(
Hash
)
s
[
"room"
]
=
{
"room"
=>
s
[
"room"
]
}
end
if
!
v
[
"schedule"
].
nil?
# fix levels composition of room value
v
[
"schedule"
].
each
do
|
s
|
if
s
[
"room"
]
!=
nil
&&
!
s
[
"room"
].
is_a?
(
Hash
)
s
[
"room"
]
=
{
"room"
=>
s
[
"room"
]
}
end
# topics
s
[
"topics"
].
each_index
do
|
t
|
unless
s
[
"topics"
][
t
].
is_a?
(
Hash
)
s
[
"topics"
][
t
]
=
{
"title"
=>
s
[
"topics"
][
t
]
}
# topics
s
[
"topics"
].
each_index
do
|
t
|
unless
s
[
"topics"
][
t
].
is_a?
(
Hash
)
s
[
"topics"
][
t
]
=
{
"title"
=>
s
[
"topics"
][
t
]
}
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment