-
Notifications
You must be signed in to change notification settings - Fork 2
/
event_links.rb
92 lines (79 loc) · 3.52 KB
/
event_links.rb
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# Copyright 2017 Patrick Fairbank. All Rights Reserved.
# @author [email protected] (Patrick Fairbank)
#
# Links for reaching event information.
module FrcLinks
class Server < Sinatra::Base
EVENT_CODE_REGEX = "([A-Za-z0-9]{2,})"
EVENT_URL = "https://frc-events.firstinspires.org"
# Redirects to the team list for the given event.
get /\/(e|event)\/#{EVENT_CODE_REGEX}(\/(\d+))?/i do
event = params["captures"][1]
year = params["captures"][3] || default_year
redirect "#{EVENT_URL}/#{year}/#{event}"
end
# Redirects to the qualification schedule and results for the given event.
get /\/(e|event)\/(q|quals?|qualifications?|s|m)\/#{EVENT_CODE_REGEX}(\/(\d+))?/i do
event = params["captures"][2]
year = params["captures"][4] || default_year
redirect "#{EVENT_URL}/#{year}/#{event}/qualifications"
end
# Redirects to the playoff schedule and results for the given event.
get /\/(e|event)\/(p|playoffs?|e|elims?|eliminations?)\/#{EVENT_CODE_REGEX}(\/(\d+))?/i do
event = params["captures"][2]
year = params["captures"][4] || default_year
redirect "#{EVENT_URL}/#{year}/#{event}/playoffs"
end
# Redirects to the qualification rankings for the given event.
get /\/(e|event)\/(r|rankings?|standings?)\/#{EVENT_CODE_REGEX}(\/(\d+))?/i do
event = params["captures"][2]
year = params["captures"][4] || default_year
redirect "#{EVENT_URL}/#{year}/#{event}/rankings"
end
# Redirects to the awards for the given event.
get /\/(e|event)\/(a|awards?|standings?)\/#{EVENT_CODE_REGEX}(\/(\d+))?/i do
event = params["captures"][2]
year = params["captures"][4] || default_year
redirect "#{EVENT_URL}/#{year}/#{event}/awards"
end
# Redirects to the agenda for the given event.
get /\/(e|event)\/(g|agenda)\/#{EVENT_CODE_REGEX}(\/(\d+))?/i do
event = params["captures"][2]
year = params["captures"][4] || default_year
redirect "http://firstinspires.org/sites/default/files/uploads/frc/#{year}-events/#{year}_" +
"#{event.upcase}_Agenda.pdf"
end
# Redirects to the The Blue Alliance page for the given event.
get /\/(e|event)\/(t|tba)\/#{EVENT_CODE_REGEX}(\/(\d+))?/i do
event = params["captures"][2]
year = params["captures"][4] || default_year
redirect "https://www.thebluealliance.com/event/#{year}#{event}"
end
# Redirects to the COVID information for the given event.
get /\/(e|event)\/(c|covid)\/#{EVENT_CODE_REGEX}(\/(\d+))?/i do
event = params["captures"][2]
year = params["captures"][4] || default_year
redirect "http://firstinspires.org/sites/default/files/uploads/frc/#{year}-events/#{year}_" +
"#{event.upcase}_SiteInfo.pdf"
end
# Redirects to the district ranking page for the given district.
get /\/(dr|districtrankings?)\/([A-Za-z]+)(\/(\d+))?/i do
district = params["captures"][1]
year = params["captures"][3] || default_year
redirect "#{EVENT_URL}/#{year}/district/#{district}"
end
# Redirects to the Kickoff page.
get /\/(ko|kickoff)/i do
redirect "https://www.firstinspires.org/robotics/frc/kickoff"
end
# Redirects to the event list page for the given year.
get /\/(e|events|r|regionals)(\/(\d+))?/i do
year = params["captures"][2] || default_year
redirect "#{EVENT_URL}/#{year}/events/eventlist"
end
# Redirects to the Championship website.
get /\/(c|cmp|championship)/i do
redirect "https://www.firstchampionship.org"
end
end
end