-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.jl
74 lines (67 loc) · 2.12 KB
/
utils.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
using YAML
using DataFrames
using PrettyTables
using Dates
using Markdown
function hfun_bar(vname)
val = Meta.parse(vname[1])
return round(sqrt(val), digits = 2)
end
function hfun_m1fill(vname)
var = vname[1]
return pagevar("index", var)
end
function lx_baz(com, _)
# keep this first line
brace_content = Franklin.content(com.braces[1]) # input string
# do whatever you want here
return uppercase(brace_content)
end
function hfun_event_table()
events = YAML.load_file("events.yaml")
df = mapreduce(DataFrame, vcat, events)
df = rename(
df,
:event => :Event,
:date => :Date,
:location => :Location,
:topic => :Topic,
)
df = df[:, [:Date, :Event, :Topic, :Location]]
return pretty_table(
String,
df;
show_subheader = false,
tf = tf_html_default,
alignment = :c,
formatters = (x, i, j) -> Franklin.md2html(x; stripp = true),
allow_html_in_cells = true,
)
end
# FIXME
default_location() = "[c-base](https://c-base.org)"
function hfun_front_message()
today = now()
events = YAML.load_file("events.yaml")
latest_event = first(events)
date_event = DateTime(latest_event["date"], DateFormat("d.m.y"))
# FIXME
# Check that the date is a 2nd Tuesday
dayofweek(date_event) == 2 || @warn "The added day is not a Tuesday"
dayofweekofmonth(date_event) == 2 || @warn "The added day is not the second Tuesday"
text = if today > date_event # It's passed already! We put a default message
next_date = tonext(today) do x
dayofweek(x) == Dates.Tuesday &&
dayofweekofmonth(x) == 2
end
"""
**$(day(next_date))th of $(monthname(next_date)) at 19:00 at $(default_location())**. Topic to be announced, if you have a topic [contact us](https://github.com/julia-lang-athens/julia-lang-athens.github.io/issues/new).
"""
else # It's coming!
"""
**$(day(date_event))th of $(monthname(date_event)) at 19:00 at $(latest_event["location"])**.
$(latest_event["topic"])
"""
end
return Franklin.md2html(text; stripp=true)
end