break: update terminology from "Work" to "Focus"
- change mode from "Work" to "Focus" in server messages
- modify pomodoro configuration to use "Focus" instead of "Work"
- adjust default settings to reflect new terminology
- ensure all references to work duration are updated to focus duration
- update variable names in HTML and JavaScript for clarity
🤖
This commit is contained in:
parent
b3f403cf1a
commit
31179d4af4
9 changed files with 34 additions and 34 deletions
26
README.md
26
README.md
|
@ -34,17 +34,17 @@ Here are the available commands:
|
||||||
| `pause` | Pauses the current session | `{"command": "pause", "password": ""}` |
|
| `pause` | Pauses the current session | `{"command": "pause", "password": ""}` |
|
||||||
| `resume` | Resumes a paused session | `{"command": "resume", "password": ""}` |
|
| `resume` | Resumes a paused session | `{"command": "resume", "password": ""}` |
|
||||||
| `reset` | Stops and resets the current session | `{"command": "reset", "password": ""}` |
|
| `reset` | Stops and resets the current session | `{"command": "reset", "password": ""}` |
|
||||||
| `updateSettings` | Update Pomodoro settings | `{"command": "updateSettings", "password": "", "settings": {"work": 600, "shortBreak": 60, "longBreak": 300, "sessions": 2}}` |
|
| `updateSettings` | Update Pomodoro settings | `{"command": "updateSettings", "password": "", "settings": {"focus": 600, "shortBreak": 60, "longBreak": 300, "sessions": 2}}` |
|
||||||
|
|
||||||
#### Update Settings Command (`updateSettings`)
|
#### Update Settings Command (`updateSettings`)
|
||||||
|
|
||||||
The `updateSettings` command allows clients to modify the Pomodoro timer configuration, including the length of work sessions, short breaks, long breaks, and the total number of sessions in a cycle. This command must include a valid password to be accepted by the server. The updateSettings command can be used when the timer is stopped.
|
The `updateSettings` command allows clients to modify the Pomodoro timer configuration, including the length of focus sessions, short breaks, long breaks, and the total number of sessions in a cycle. This command must include a valid password to be accepted by the server. The updateSettings command can be used when the timer is stopped.
|
||||||
|
|
||||||
- Fields in the `settings` Object:
|
- Fields in the `settings` Object:
|
||||||
- `work`: Length of the work session (in seconds).
|
- `focus`: Length of the focus session (in seconds).
|
||||||
- `shortBreak`: Length of the short break (in seconds).
|
- `shortBreak`: Length of the short break (in seconds).
|
||||||
- `longBreak`: Length of the long break (in seconds).
|
- `longBreak`: Length of the long break (in seconds).
|
||||||
- `sessions`: Total number of work/break sessions in the Pomodoro cycle.
|
- `sessions`: Total number of focus/break sessions in the Pomodoro cycle.
|
||||||
|
|
||||||
All fields are mandatory and may not be ommitted.
|
All fields are mandatory and may not be ommitted.
|
||||||
|
|
||||||
|
@ -52,14 +52,14 @@ All fields are mandatory and may not be ommitted.
|
||||||
|
|
||||||
The server periodically (every second) sends JSON-encoded messages to all connected clients to update them on the current state of the Pomodoro session. These messages contain the following fields:
|
The server periodically (every second) sends JSON-encoded messages to all connected clients to update them on the current state of the Pomodoro session. These messages contain the following fields:
|
||||||
|
|
||||||
- mode: Indicates the current phase of the Pomodoro session ("Work", "ShortBreak", "LongBreak", "End" or "Idle").
|
- mode: Indicates the current phase of the Pomodoro session ("Focus", "ShortBreak", "LongBreak", "End" or "Idle").
|
||||||
- "End" is send only once, after all sessions are finished
|
- "End" is send only once, after all sessions are finished
|
||||||
- settings: Contains the current Pomodoro settings:
|
- settings: Contains the current Pomodoro settings:
|
||||||
- work: Length of the work session in seconds (e.g., 1500 for 25 minutes).
|
- focus: Length of the focus session in seconds (e.g., 1500 for 25 minutes).
|
||||||
- shortBreak: Length of the short break in seconds (e.g., 300 for 5 minutes).
|
- shortBreak: Length of the short break in seconds (e.g., 300 for 5 minutes).
|
||||||
- longBreak: Length of the long break in seconds (e.g., 900 for 15 minutes).
|
- longBreak: Length of the long break in seconds (e.g., 900 for 15 minutes).
|
||||||
- sessions: The total number of work/break sessions (e.g., 4).
|
- sessions: The total number of focus/break sessions (e.g., 4).
|
||||||
- session: The current session number (e.g., 1 for the first work session).
|
- session: The current session number (e.g., 1 for the first focus session).
|
||||||
- time_left: The remaining time for the current mode, in seconds (e.g., 900 for 15 minutes).
|
- time_left: The remaining time for the current mode, in seconds (e.g., 900 for 15 minutes).
|
||||||
- ongoing: Whether a Pomodoro session is currently ongoing.
|
- ongoing: Whether a Pomodoro session is currently ongoing.
|
||||||
- paused: Whether the timer is paused.
|
- paused: Whether the timer is paused.
|
||||||
|
@ -67,11 +67,11 @@ The server periodically (every second) sends JSON-encoded messages to all connec
|
||||||
|
|
||||||
| Message Type | Example |
|
| Message Type | Example |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| Welcome Message | {"mode":"Idle", "settings":{"work":1500, "shortBreak":300, "longBreak":900, "sessions":4}, "session":0, "time_left":1500, "ongoing":false, "paused":false, "version":"0"} |
|
| Welcome Message | {"mode":"Idle", "settings":{"focus":1500, "shortBreak":300, "longBreak":900, "sessions":4}, "session":0, "time_left":1500, "ongoing":false, "paused":false, "version":"0"} |
|
||||||
| Session Running | {"mode":"Work", "settings":{"work":1500, "shortBreak":300, "longBreak":900, "sessions":4}, "session":1, "time_left":900, "ongoing":true, "paused":false, "version":"0"} |
|
| Session Running | {"mode":"Focus", "settings":{"focus":1500, "shortBreak":300, "longBreak":900, "sessions":4}, "session":1, "time_left":900, "ongoing":true, "paused":false, "version":"0"} |
|
||||||
| Session Running | {"mode":"ShortBreak", "settings":{"work":1500, "shortBreak":300, "longBreak":900, "sessions":4}, "session":2, "time_left":50, "ongoing":true, "paused":false, "version":"0"} |
|
| Session Running | {"mode":"ShortBreak", "settings":{"focus":1500, "shortBreak":300, "longBreak":900, "sessions":4}, "session":2, "time_left":50, "ongoing":true, "paused":false, "version":"0"} |
|
||||||
| Session Paused | {"mode":"Work", "settings":{"work":1500, "shortBreak":300, "longBreak":900, "sessions":4}, "session":2, "time_left":456, "ongoing":true, "paused":true, "version":"0"} |
|
| Session Paused | {"mode":"Focus", "settings":{"focus":1500, "shortBreak":300, "longBreak":900, "sessions":4}, "session":2, "time_left":456, "ongoing":true, "paused":true, "version":"0"} |
|
||||||
| Session End/Reset | {"mode":"End", "settings":{"work":1500, "shortBreak":300, "longBreak":900, "sessions":4}, "session":0, "time_left":0, "ongoing":false, "paused":false, "version":"0"} |
|
| Session End/Reset | {"mode":"End", "settings":{"focus":1500, "shortBreak":300, "longBreak":900, "sessions":4}, "session":0, "time_left":0, "ongoing":false, "paused":false, "version":"0"} |
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,10 @@ import (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// define CLI flags
|
// define CLI flags
|
||||||
listenAddress = flag.String("listenAddress", shared.DefaultServerConfig.ListenAddress, "IP address to listen on")
|
listenAddress = flag.String("listenAddress", shared.DefaultServerConfig.ListenAddress, "IP address to listen on")
|
||||||
listenPort = flag.Int("listenPort", shared.DefaultServerConfig.ListenPort, "Port to listen on")
|
listenPort = flag.Int("listenPort", shared.DefaultServerConfig.ListenPort, "Port to listen on")
|
||||||
password = flag.String("password", "", "Control password for pomodoro session (optional)")
|
password = flag.String("password", "", "Control password for pomodoro session (optional)")
|
||||||
showVersionFlag = flag.Bool("version", false, "Output version")
|
showVersion = flag.Bool("version", false, "Output version")
|
||||||
)
|
)
|
||||||
|
|
||||||
// Start the pomodoro server
|
// Start the pomodoro server
|
||||||
|
@ -27,7 +27,7 @@ func Start() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
// show server and protocl version and exit
|
// show server and protocl version and exit
|
||||||
if *showVersionFlag {
|
if *showVersion {
|
||||||
fmt.Printf("GoTomato v%s\n", metadata.GoTomatoVersion)
|
fmt.Printf("GoTomato v%s\n", metadata.GoTomatoVersion)
|
||||||
fmt.Printf("Protocol-Version: %s\n", metadata.ProtocolVersion)
|
fmt.Printf("Protocol-Version: %s\n", metadata.ProtocolVersion)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
|
|
|
@ -40,8 +40,8 @@
|
||||||
<input type="text" id="password" placeholder="Password" />
|
<input type="text" id="password" placeholder="Password" />
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<label for="workDuration">Work Duration (seconds):</label>
|
<label for="focusDuration">Focus Duration (seconds):</label>
|
||||||
<input type="number" id="workDuration" placeholder="Work time in seconds" value="900" />
|
<input type="number" id="foucsDuration" placeholder="Focus time in seconds" value="900" />
|
||||||
<br />
|
<br />
|
||||||
<label for="shortBreakDuration">Short Break Duration (seconds):</label>
|
<label for="shortBreakDuration">Short Break Duration (seconds):</label>
|
||||||
<input type="number" id="shortBreakDuration" placeholder="Short break in seconds" value="300" />
|
<input type="number" id="shortBreakDuration" placeholder="Short break in seconds" value="300" />
|
||||||
|
@ -98,7 +98,7 @@
|
||||||
document.getElementById("saveButton").addEventListener("click", function () {
|
document.getElementById("saveButton").addEventListener("click", function () {
|
||||||
// Get the values from the input fields
|
// Get the values from the input fields
|
||||||
var password = document.getElementById("password").value;
|
var password = document.getElementById("password").value;
|
||||||
var work = parseInt(document.getElementById("workDuration").value);
|
var focus = parseInt(document.getElementById("focusDuration").value);
|
||||||
var shortBreak = parseInt(document.getElementById("shortBreakDuration").value);
|
var shortBreak = parseInt(document.getElementById("shortBreakDuration").value);
|
||||||
var longBreak = parseInt(document.getElementById("longBreakDuration").value);
|
var longBreak = parseInt(document.getElementById("longBreakDuration").value);
|
||||||
var sessions = parseInt(document.getElementById("sessions").value);
|
var sessions = parseInt(document.getElementById("sessions").value);
|
||||||
|
@ -108,7 +108,7 @@
|
||||||
command: "updateSettings",
|
command: "updateSettings",
|
||||||
password: password,
|
password: password,
|
||||||
settings: {
|
settings: {
|
||||||
work: work,
|
focus: focus,
|
||||||
shortBreak: shortBreak,
|
shortBreak: shortBreak,
|
||||||
longBreak: longBreak,
|
longBreak: longBreak,
|
||||||
sessions: sessions
|
sessions: sessions
|
||||||
|
|
|
@ -26,7 +26,7 @@ func waitForTimer(t Timer) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunPomodoro iterates the Pomodoro work/break sessions
|
// RunPomodoro iterates the Pomodoro focus/break sessions
|
||||||
func RunPomodoro() {
|
func RunPomodoro() {
|
||||||
mu.Lock()
|
mu.Lock()
|
||||||
shared.State.Ongoing = true
|
shared.State.Ongoing = true
|
||||||
|
@ -40,9 +40,9 @@ func RunPomodoro() {
|
||||||
|
|
||||||
shared.State.Session = session
|
shared.State.Session = session
|
||||||
|
|
||||||
// Work
|
// Focus
|
||||||
shared.State.Mode = "Work"
|
shared.State.Mode = "Focus"
|
||||||
timer.StartAsync(pomodoroConfig.Work)
|
timer.StartAsync(pomodoroConfig.Focus)
|
||||||
if !waitForTimer(timer) {
|
if !waitForTimer(timer) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ func RunPomodoro() {
|
||||||
|
|
||||||
shared.State.Mode = "Idle"
|
shared.State.Mode = "Idle"
|
||||||
shared.State.Session = 0
|
shared.State.Session = 0
|
||||||
shared.State.TimeLeft = shared.State.Settings.Work
|
shared.State.TimeLeft = shared.State.Settings.Focus
|
||||||
}
|
}
|
||||||
|
|
||||||
func ResetPomodoro() {
|
func ResetPomodoro() {
|
||||||
|
@ -111,6 +111,6 @@ func IsPomodoroPaused() bool {
|
||||||
func UpdateSettings(settings models.PomodoroConfig) {
|
func UpdateSettings(settings models.PomodoroConfig) {
|
||||||
if settings != (models.PomodoroConfig{}) {
|
if settings != (models.PomodoroConfig{}) {
|
||||||
shared.State.Settings = settings
|
shared.State.Settings = settings
|
||||||
shared.State.TimeLeft = settings.Work
|
shared.State.TimeLeft = settings.Focus
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ var DefaultServerConfig = models.ServerConfig{
|
||||||
|
|
||||||
// The default pomodoro config if nothing else is set
|
// The default pomodoro config if nothing else is set
|
||||||
var DefaultPomodoroConfig = models.PomodoroConfig{
|
var DefaultPomodoroConfig = models.PomodoroConfig{
|
||||||
Work: 25 * 60,
|
Focus: 25 * 60,
|
||||||
ShortBreak: 5 * 60,
|
ShortBreak: 5 * 60,
|
||||||
LongBreak: 15 * 60,
|
LongBreak: 15 * 60,
|
||||||
Sessions: 4,
|
Sessions: 4,
|
||||||
|
|
|
@ -10,7 +10,7 @@ var State = models.ServerMessage{
|
||||||
Mode: "Idle",
|
Mode: "Idle",
|
||||||
Settings: DefaultPomodoroConfig,
|
Settings: DefaultPomodoroConfig,
|
||||||
Session: 0,
|
Session: 0,
|
||||||
TimeLeft: DefaultPomodoroConfig.Work,
|
TimeLeft: DefaultPomodoroConfig.Focus,
|
||||||
Ongoing: false,
|
Ongoing: false,
|
||||||
Paused: false,
|
Paused: false,
|
||||||
ProtocolVersion: metadata.ProtocolVersion,
|
ProtocolVersion: metadata.ProtocolVersion,
|
||||||
|
|
|
@ -10,7 +10,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func checkSettings(settings models.PomodoroConfig) bool {
|
func checkSettings(settings models.PomodoroConfig) bool {
|
||||||
return settings.Work > 0 && settings.ShortBreak > 0 && settings.LongBreak > 0 && settings.Sessions > 0
|
return settings.Focus > 0 && settings.ShortBreak > 0 && settings.LongBreak > 0 && settings.Sessions > 0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Listens for commands from a client and handles them
|
// Listens for commands from a client and handles them
|
||||||
|
|
|
@ -4,7 +4,7 @@ import "fmt"
|
||||||
|
|
||||||
// Represents the configuration of a pomodoro
|
// Represents the configuration of a pomodoro
|
||||||
type PomodoroConfig struct {
|
type PomodoroConfig struct {
|
||||||
Work int `json:"work"` // Length of work sessions in seconds
|
Focus int `json:"focus"` // Length of focus sessions in seconds
|
||||||
ShortBreak int `json:"shortBreak"` // Length of short break in seconds
|
ShortBreak int `json:"shortBreak"` // Length of short break in seconds
|
||||||
LongBreak int `json:"longBreak"` // Length of long break in seconds
|
LongBreak int `json:"longBreak"` // Length of long break in seconds
|
||||||
Sessions int `json:"sessions"` // Number of total sessions
|
Sessions int `json:"sessions"` // Number of total sessions
|
||||||
|
@ -12,7 +12,7 @@ type PomodoroConfig struct {
|
||||||
|
|
||||||
// Stringer interface for the PomodocoConfig model
|
// Stringer interface for the PomodocoConfig model
|
||||||
func (c PomodoroConfig) String() string {
|
func (c PomodoroConfig) String() string {
|
||||||
return fmt.Sprintf("{work: %d, short: %d, long: %d, sessions: %d}", c.Work, c.ShortBreak, c.LongBreak, c.Sessions)
|
return fmt.Sprintf("{focus: %d, short: %d, long: %d, sessions: %d}", c.Focus, c.ShortBreak, c.LongBreak, c.Sessions)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Represents the server configuration
|
// Represents the server configuration
|
||||||
|
|
|
@ -2,7 +2,7 @@ package models
|
||||||
|
|
||||||
// Represents the data sent to the client via WebSocket
|
// Represents the data sent to the client via WebSocket
|
||||||
type ServerMessage struct {
|
type ServerMessage struct {
|
||||||
Mode string `json:"mode"` // "Idle", "Work", "ShortBreak", "LongBreak" or "End"
|
Mode string `json:"mode"` // "Idle", "Focus", "ShortBreak", "LongBreak" or "End"
|
||||||
Settings PomodoroConfig `json:"settings"` // The currrent pomodoro settings
|
Settings PomodoroConfig `json:"settings"` // The currrent pomodoro settings
|
||||||
Session int `json:"session"` // Current session number
|
Session int `json:"session"` // Current session number
|
||||||
TimeLeft int `json:"time_left"` // Remaining time in seconds
|
TimeLeft int `json:"time_left"` // Remaining time in seconds
|
||||||
|
|
Loading…
Reference in a new issue