-
Notifications
You must be signed in to change notification settings - Fork 11
Bell Schedule Configuration
Web server configuration is done with config.json
in the top level of the project. port
is the port the web server will listen on. If you disable postgres, it will default to using sqlite3 to record hits.
{
"port": 8080,
"server name": "bell-0",
"postgres": {
"enabled": true,
"user": "postgres",
"host": "localhost",
"database": "bell",
"password": "pass",
"port": 5432
}
}
In the top right of the page, a message is shown. This is controlled by data/message.json
. This message can be set according to user agent as parsed by ua-parser-js. The client will download this message JSON and use the first message that satisfies its user agent.
Here is an example that displays a message to install the Chrome extension only if the browser is Chrome:
[{
"agent": {
"browser": {
"name": "Chrome"
}
},
"message": {
"enabled": true,
"text": "Install the Chrome Extension",
"href": "https://countdown.zone/xt"
}
}, {
"message": {
"enabled": false
}
}]
The data
directory stores all of the data about the schedules/calendar for each school. Within the data
directory, there are directories named with the short names of each school. Each school must contain a source.json
. If the schedules are set locally, the school must also include calendar.txt
, correction.txt
, meta.json
, and schedules.txt
.
Modifications to these files can be made during run time. Clients will check in periodically and receive the updated information.
data
├── custom
│ ├── meta.json
│ └── source.json
├── lahs
│ ├── calendar.txt
│ ├── correction.txt
│ ├── meta.json
│ ├── schedules.txt
│ └── source.json
├── mvhs
│ ├── calendar.txt
│ ├── correction.txt
│ ├── meta.json
│ ├── schedules.txt
│ └── source.json
├── message.json
└── version.txt
source.json
tells the server where the data for the school is located. It can be located either locally in the same directory or hosted externally on another web server.
If it is local, all you need to put is the following (and include the other necessary files in the same directory):
{
"location": "local"
}
If it is external, you need to provide the URL to the external API (other files in the directory are ignored):
{
"location": "web",
"url": "https://bell-api.example.com"
}
meta.json
provides the full school display name and the default period names.
{
"name": "Mountain View High School",
"periods": ["Period 0", "Period 1", "Period 2", "Period 3", "Period 4", "Period 5", "Period 6", "Period 7"]
}
Unfortunately, the server time and school's clock are not always excatly the same. It is frustrating for students to have to wait an extra two seconds for class to end if the website is two seconds early, so adjusting the website to be perfectly accurate with the school clock is a necessity. This can be done by editing correction.txt
.
correction.txt
contains a single number which is the number of milliseconds adjustment to match the school clock. If the server time is behind the school time, you should enter a positive adjustment. If the server time is ahead of the school time, you should enter a negative adjustment. In other words, if the school bell rings after the website expects, you should decrease the adjustment. If the school bell rings before the website expects, you should increase the adjustment.
Before the weekly schedule can be created, we need to fill in the relevant schedules in schedules.txt
. This file contains all of the times of each period for each schedule type. For example, a normal schedule might include all periods while an even block schedule would only include the even periods, and would have different start and end times for each.
Here is an example of how you would enter in a schedule:
* even # Even Block
7:10 Passing to {Period 0}
7:15 {Period 0}
8:45 Passing to {Period 2}
8:50 {Period 2}
10:25 Brunch
10:40 Passing to {Period 4}
10:45 {Period 4}
12:15 Lunch
13:00 Passing to {Period 6}
13:05 {Period 6}
14:35 Free
The *
denotes a new schedule, followed by the schedule's short name. The short name is what will identify this schedule in calendar.txt
. After the #
is the display name of the schedule, which is what will be shown on the website to users.
The periods are each on their own line with a starting time followed by the string with the period name. The starting time uses a 24-hour clock, so in order to indicate 2:00 P.M., for example, you must write 14:00
. Since period names can be changed by each user, they are variables and enclosed in curly braces, such as {Period 0}
. This block with the curly braces will be replaced with the custom period name. You must include all names enclosed in curly braces in the periods section of meta.json
.
This program is designed for schools that have a weekly schedule, where each day is the same schedule based on the day of the week, although it can be used for other systems. A default week must be specified at the beginning of calendars.txt
.
* Default Week
Sun weekend
Mon normal
Tue tutorial
Wed even
Thu odd
Fri normal
Sat weekend
The schedule short names are listed after the shortened day name.
The next section of calendars.txt
is the section for specifying exceptions to the weekly schedule.
* Special Days
11/22/2017 holiday # Teacher Service Day
11/23/2017 holiday # Thanksgiving Day
12/18/2017-01/01/2018 holiday # Holiday Recess
Each exception is written on its own line. The line begins with either the date or the range of dates the special schedule is in effect, followed by the schedule's short name, then a custom display name to override the normal display name, if desired. Dates are in MM/DD/YYYY
format, and a range is specified by putting a -
between the starting and ending dates, like so: 12/19/2016-01/02/2017
. You can override the default schedule name with a #
.