Skip to content

Commit

Permalink
Merge pull request #32 from JuliaCon/2023
Browse files Browse the repository at this point in the history
  • Loading branch information
carstenbauer authored Jun 20, 2023
2 parents 370f70e + 98416a8 commit 934b025
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 59 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Carsten Bauer <[email protected]> and contributors
Copyright (c) 2023 Carsten Bauer <[email protected]> and contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JuliaCon"
uuid = "bfca5e61-7ca9-4d61-a82b-6df663fb0d3c"
authors = ["Carsten Bauer <[email protected]> and contributors"]
version = "2022.0.1"
version = "2023.0.0-DEV"

[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

## T-Shirt code

This package makes the code on the JuliaCon 2021/2022 [T-shirts](#t-shirt) work! Of course, you should [buy one here](https://www.bonfire.com/juliacon-repl/)!
This package makes the code on the JuliaCon 2021/2022/2023 [T-shirts](#t-shirt) work! Of course, you should [buy one here](https://www.bonfire.com/juliacon-repl/)!

To make the `@everywhere` do something you need to start Julia with multiple worker processes: `julia -p 4`.

Expand All @@ -15,7 +15,7 @@ To make the `@everywhere` do something you need to start Julia with multiple wor
```julia
using JuliaCon, Distributed

@everywhere juliacon2022()
@everywhere juliacon2023()
```

<img width="1145" alt="Screenshot 2021-06-02 at 02 05 12" src="https://user-images.githubusercontent.com/187980/120404611-04780180-c347-11eb-860e-88eed268d1a0.png">
Expand Down
2 changes: 1 addition & 1 deletion src/JuliaCon.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,6 @@ function __init__()
end
end

export juliacon2022
export juliacon2023

end
8 changes: 4 additions & 4 deletions src/preferences.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const LOCAL_TIMEZONE = begin
end
end

const PRETALX_JSON_URL = "https://pretalx.com/juliacon-2022/schedule/export/schedule.json"
const DATA_ARCHIVE_JSON_URL = "https://raw.githubusercontent.com/JuliaCon/JuliaConDataArchive/master/juliacon2022_schedule/schedule.json"
const PRETALX_JSON_URL = "https://pretalx.com/juliacon2023/schedule/export/schedule.json"
const DATA_ARCHIVE_JSON_URL = "https://raw.githubusercontent.com/JuliaCon/JuliaConDataArchive/master/juliacon2023_schedule/schedule.json"
const jcon = Ref{DataFrame}()

function set_cachemode(mode::Symbol)
Expand Down Expand Up @@ -70,10 +70,10 @@ function debugmode(on::Bool=true)
# @eval JuliaCon default_now() = ZonedDateTime(Dates.DateTime("2022-07-20T18:00:00.000"), tz"MET") # JuliaCon2022 workshops
# @eval JuliaCon default_now() = ZonedDateTime(Dates.DateTime("2022-07-30T22:00:00.000"), tz"MET") # JuliaCon2022 posters
@eval JuliaCon function default_now()
return ZonedDateTime(Dates.DateTime("2022-07-28T21:30:00.000"), tz"MET")
return ZonedDateTime(Dates.DateTime("2023-07-27T13:35:00.000"), tz"MET")
# return ZonedDateTime(Dates.DateTime("2022-07-24T18:15:00.000"), tz"America/Los_Angeles")
# return ZonedDateTime(Dates.DateTime("2022-07-24T20:00:00.000"), tz"MET")
end # JuliaCon2022
end # JuliaCon2023
else
@eval JuliaCon default_now() = TimeZones.now(LOCAL_TIMEZONE)
end
Expand Down
106 changes: 68 additions & 38 deletions src/schedule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ function json2df(conf)
type = JuliaConTalkType[],
url = String[],
track = String[],
room = String[],
)

for day in conf["days"]
date = Date(day["date"])
for (track, talks) in day["rooms"]
for (room, talks) in day["rooms"]
for talk in talks
# parse duration
tmp = split(talk["duration"], ':')
Expand All @@ -39,7 +40,8 @@ function json2df(conf)
:speaker => String[p["public_name"] for p in talk["persons"]],
:type => talktype_from_str(talk["type"]),
:url => talk["url"],
:track => track,
:track => talk["track"],
:room => room,
)
push!(df, d)
end
Expand Down Expand Up @@ -118,6 +120,28 @@ function _track2color(track::String)
end
end

function _room2color(room::String)
if room == "26-100"
return :red
elseif room == "32-082"
return :green
elseif room == "32-123"
return :magenta
elseif room == "32-124"
return :blue
elseif room == "32-144"
return :yellow
elseif contains(room, "32-D463") || contains(room, "Star")
return :cyan
elseif contains(room, "32-G449") || contains(room, "Kiva")
return 208 # orange, see https://github.com/KristofferC/Crayons.jl/blob/master/README.md
elseif room == "Online"
return :white
else
return :default
end
end


is_schedule_json_available() = isfile(joinpath(CACHE_DIR, "schedule.json"))

Expand Down Expand Up @@ -206,11 +230,15 @@ function _print_running_talks(running_talks; now=default_now())
# println(Dates.format(default_now(), "HH:MM dd-mm-YYYY"))
for talk in eachrow(running_talks)
println()
printstyled(_add_track_emoji(string(talk.track)); bold=true, color=_track2color(talk.track))
printstyled(talk.room; bold=true, color=_room2color(talk.room))
println()
println("\t", talk.title, " (", string(talk.type), ")")
println("\t", "├─ ", _speakers2str(talk.speaker))
println("\t", "└─ ", talk.url)
println("\t", "├─ ", talk.url)
print("\t", "└─ ");
# printstyled(_add_track_emoji(string(talk.track)); bold=false, color=_track2color(talk.track));
printstyled(talk.track; bold=false, color=_track2color(talk.track));
println()
end
println("\n")
println("(Full schedule: $(CONFERENCE_SCHEDULE_URL))")
Expand All @@ -223,10 +251,11 @@ function now(::Val{:text}; now)
if !isnothing(running_talks)
for talk in eachrow(running_talks)
str *= """
$(_add_track_emoji(string(talk.track)))
$(string(talk.room))
\t$(talk.title) ($(string(talk.type)))
\t├─ $(JuliaCon._speakers2str(talk.speaker))
\t└─ $(talk.url)
\t├─ $(talk.url)
\t└─ $(talk.track)
"""
end
end
Expand All @@ -252,16 +281,16 @@ function _speakers2str(speaker::Vector{String})
end

function _get_today_tables(;
now=default_now(), track=nothing, terminal_links=TERMINAL_LINKS, highlighting=true, text_highlighting=false
now=default_now(), room=nothing, terminal_links=TERMINAL_LINKS, highlighting=true, text_highlighting=false
)
jcon = get_conference_schedule()

today_start_utc = ZonedDateTime(DateTime(Date(now), Time("00:00")), JULIACON_TIMEZONE)
today_end_utc = ZonedDateTime(DateTime(Date(now) + Day(1), Time("00:00")), JULIACON_TIMEZONE)

talks_today = filter(jcon; view=true) do talk
# talk is in the requested track (default: any)
if !isnothing(track) && talk.track != track
# talk is in the requested room (default: any)
if !isnothing(room) && talk.room != room
return false
end

Expand All @@ -273,24 +302,25 @@ function _get_today_tables(;
nrow(talks_today) > 0 || return (nothing, nothing, nothing)

# create talk tables
tracks = String[]
rooms = String[]
tables = Matrix{Union{String,URLTextCell}}[]
highlighters = Union{Nothing,Highlighter}[]

# for each track
for track_grp in groupby(talks_today, :track)
# for each room
for room_grp in groupby(talks_today, :room; sort=true)
# build talk-data matrix
data = Matrix{Union{String,URLTextCell}}(undef, nrow(track_grp), 4)
for (i, talk) in enumerate(eachrow(track_grp))
data = Matrix{Union{String,URLTextCell}}(undef, nrow(room_grp), 5)
for (i, talk) in enumerate(eachrow(room_grp))
data[i, 1] = Dates.format(astimezone(talk.start, timezone(now)), "HH:MM")
data[i, 2] = terminal_links ? URLTextCell(talk.title, talk.url) : talk.title
data[i, 3] = JuliaCon.abbrev(talk.type)
data[i, 4] = JuliaCon._speakers2str(talk.speaker)
data[i, 5] = talk.track
end

h_running = Highlighter((data, m, n) -> false, crayon"yellow")
if highlighting
for (i, talk) in enumerate(eachrow(track_grp))
for (i, talk) in enumerate(eachrow(room_grp))
start_time = talk.start
end_time = talk.start + talk.duration
if start_time <= astimezone(now, JULIACON_TIMEZONE) < end_time
Expand All @@ -307,53 +337,53 @@ function _get_today_tables(;
end
end

push!(tracks, first(track_grp).track)
push!(rooms, first(room_grp).room)
push!(tables, data)
push!(highlighters, h_running)
end

@assert length(tables) == length(highlighters) == length(tracks)
return (tracks, tables, highlighters)
@assert length(tables) == length(highlighters) == length(rooms)
return (rooms, tables, highlighters)
end

# A dispatcher for the `today` methods. Defaults to terminal output.
function today(;
now=default_now(),
track=nothing,
room=nothing,
terminal_links=TERMINAL_LINKS,
output=:terminal, # can take the :text value to output a Vector{String}
highlighting=true
)
return today(Val(output); now, track, terminal_links, highlighting)
return today(Val(output); now, room, terminal_links, highlighting)
end

function today(::Val{:terminal}; now, track, terminal_links, highlighting=true)
tracks, tables, highlighters = _get_today_tables(; now, track, terminal_links, highlighting)
function today(::Val{:terminal}; now, room, terminal_links, highlighting=true)
rooms, tables, highlighters = _get_today_tables(; now, room, terminal_links, highlighting)
isnothing(tables) && return nothing

header = (["Time", "Title", "Type", "Speaker"],)
header = (["Time", "Title", "Type", "Speaker", "Track"],)
header_crayon = crayon"dark_gray bold"
border_crayon = crayon"dark_gray"
h_times = Highlighter((data, i, j) -> j == 1, crayon"white bold")

println()
println(Dates.format(TimeZones.Date(now), "E d U Y"))

for j in eachindex(tracks)
track = tracks[j]
for j in eachindex(rooms)
room = rooms[j]
data = tables[j]
h_running = highlighters[j]
println()
pretty_table(
data;
title=_add_track_emoji(track),
title_crayon=Crayon(; foreground=_track2color(track), bold=true),
title=room,
title_crayon=Crayon(; foreground=_room2color(room), bold=true),
header=header,
header_crayon=header_crayon,
border_crayon=border_crayon,
highlighters=(h_times, h_running),
tf=tf_unicode_rounded,
alignment=[:c, :l, :c, :l],
alignment=[:c, :l, :c, :l, :l],
)
end

Expand Down Expand Up @@ -398,32 +428,32 @@ function _add_track_emoji(track::AbstractString)
end
end

function today(::Val{:text}; now, track, terminal_links, highlighting=true)
tracks, tables, highlighters = _get_today_tables(; now, track, terminal_links, highlighting, text_highlighting=highlighting)
function today(::Val{:text}; now, room, terminal_links, highlighting=true)
rooms, tables, highlighters = _get_today_tables(; now, room, terminal_links, highlighting, text_highlighting=highlighting)
isnothing(tables) && return nothing

header = (["Time", "Title", "Type", "Speaker"],)
header = (["Time", "Title", "Type", "Speaker", "Track"],)
header_crayon = crayon"dark_gray bold"
border_crayon = crayon"dark_gray"
h_times = Highlighter((data, i, j) -> j == 1, crayon"white bold")

strings = Vector{String}()
push!(strings, string(Dates.format(TimeZones.Date(now), "E d U Y")))
for j in eachindex(tracks)
track = tracks[j]
for j in eachindex(rooms)
room = rooms[j]
data = tables[j]
h_running = highlighters[j]
str = pretty_table(
String,
data;
title=_add_track_emoji(track),
title_crayon=Crayon(; foreground=_track2color(track), bold=true),
title=room,
title_crayon=Crayon(; foreground=_room2color(room), bold=true),
header=header,
header_crayon=header_crayon,
border_crayon=border_crayon,
highlighters=(h_times, h_running),
tf=tf_unicode_rounded,
alignment=[:c, :l, :c, :l],
alignment=[:c, :l, :c, :l, :l],
)
push!(strings, str)
end
Expand All @@ -450,9 +480,9 @@ end

function tomorrow(;
now=default_now(),
track=nothing,
room=nothing,
terminal_links=TERMINAL_LINKS,
output=:terminal, # can take the :text value to output a Vector{String}
)
return today(Val(output); now = now + Dates.Day(1), track, terminal_links, highlighting = false)
return today(Val(output); now = now + Dates.Day(1), room, terminal_links, highlighting = false)
end
10 changes: 5 additions & 5 deletions src/tshirtcode.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
function juliacon2022(::Val{:terminal})
function juliacon2023(::Val{:terminal})
if myid() == 1
return println(
"Welcome to JuliaCon 2022! Find more information on https://juliacon.org/2022/."
"Welcome to JuliaCon 2023! Find more information on https://juliacon.org/2023/."
)
else
return println("Greetings from ", rand(countries), "!")
Expand All @@ -10,8 +10,8 @@ function juliacon2022(::Val{:terminal})
end

# TODO: needs love for a distributed version based on the :terminal method (no hurry though)
function juliacon2022(::Val{:text})
return "Welcome to JuliaCon 2022! Find more information on https://juliacon.org/2022/."
function juliacon2023(::Val{:text})
return "Welcome to JuliaCon 2023! Find more information on https://juliacon.org/2023/."
end

juliacon2022(; output=:terminal) = juliacon2022(Val(output))
juliacon2023(; output=:terminal) = juliacon2023(Val(output))
15 changes: 8 additions & 7 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ import Dates
using TimeZones

@testset "JuliaCon.jl" begin
@testset "juliacon2022()" begin
@testset "juliacon2023()" begin
@info "Local:"
@test isnothing(juliacon2022())
@test isnothing(juliacon2023())

@info "Distributed:"
withenv("JULIA_PROJECT"=>pwd()) do
addprocs(4)
@eval Main @everywhere using JuliaCon
@test isnothing(@everywhere juliacon2022())
@test isnothing(@everywhere juliacon2023())
rmprocs(workers())
end
end

@testset "Preferences" begin
@testset "Debug mode" begin
fakenow = ZonedDateTime(Dates.DateTime("2022-07-28T21:30:00.000"), tz"MET")
fakenow = ZonedDateTime(Dates.DateTime("2023-07-27T13:35:00.000"), tz"MET")
@test JuliaCon.default_now() != fakenow
@test isnothing(JuliaCon.debugmode())
@test JuliaCon.default_now() == fakenow
Expand Down Expand Up @@ -58,7 +58,8 @@ using TimeZones
@test isnothing(JuliaCon.now())
@test isnothing(JuliaCon.today())
@test isnothing(JuliaCon.today())
@test isnothing(JuliaCon.today(track="BoF"))
# @test isnothing(JuliaCon.today(track="BoF"))
@test isnothing(JuliaCon.today(room="32-124"))
@test isnothing(JuliaCon.today(terminal_links=true))
@test isnothing(JuliaCon.tomorrow())

Expand All @@ -69,12 +70,12 @@ using TimeZones
## Print output
foreach(println, JuliaCon.today(output = :text))
println(JuliaCon.now(output = :text))
println(juliacon2022(output = :text))
println(juliacon2023(output = :text))

## Test output types
@test eltype(JuliaCon.today(output = :text)) == String
@test typeof(JuliaCon.now(output = :text)) == String
@test typeof(juliacon2022(output = :text)) == String
@test typeof(juliacon2023(output = :text)) == String

JuliaCon.debugmode(false)
end
Expand Down

0 comments on commit 934b025

Please sign in to comment.