Compare commits

..

3 commits

Author SHA1 Message Date
3a00563b6a break: remove /ws from websocket path 2024-11-18 17:44:51 +01:00
d21a74388d feat: update usage output
- add custom usage message
- include instructions for WebSocket client connection

🤖
2024-11-18 08:57:32 +01:00
9feaa9a363 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

🤖
2024-11-18 08:11:39 +01:00
4 changed files with 16 additions and 16 deletions

View file

@ -34,17 +34,17 @@ Here are the available commands:
| `pause` | Pauses the current session | `{"command": "pause", "password": ""}` |
| `resume` | Resumes a paused session | `{"command": "resume", "password": ""}` |
| `reset` | Stops and resets the current session | `{"command": "reset", "password": ""}` |
| `updateSettings` | Update Pomodoro settings | `{"command": "updateSettings", "password": "", "settings": {"focus": 600, "shortBreak": 60, "longBreak": 300, "sessions": 2}}` |
| `updateSettings` | Update Pomodoro settings | `{"command": "updateSettings", "password": "", "settings": {"work": 600, "shortBreak": 60, "longBreak": 300, "sessions": 2}}` |
#### Update Settings Command (`updateSettings`)
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.
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.
- Fields in the `settings` Object:
- `focus`: Length of the focus session (in seconds).
- `work`: Length of the work session (in seconds).
- `shortBreak`: Length of the short break (in seconds).
- `longBreak`: Length of the long break (in seconds).
- `sessions`: Total number of focus/break sessions in the Pomodoro cycle.
- `sessions`: Total number of work/break sessions in the Pomodoro cycle.
All fields are mandatory and may not be ommitted.
@ -55,11 +55,11 @@ The server periodically (every second) sends JSON-encoded messages to all connec
- 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
- settings: Contains the current Pomodoro settings:
- focus: Length of the focus session in seconds (e.g., 1500 for 25 minutes).
- work: Length of the work session in seconds (e.g., 1500 for 25 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).
- sessions: The total number of focus/break sessions (e.g., 4).
- session: The current session number (e.g., 1 for the first focus session).
- sessions: The total number of work/break sessions (e.g., 4).
- session: The current session number (e.g., 1 for the first work session).
- 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.
- 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 |
| --- | --- |
| 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":"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":{"focus":1500, "shortBreak":300, "longBreak":900, "sessions":4}, "session":2, "time_left":50, "ongoing":true, "paused":false, "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":{"focus":1500, "shortBreak":300, "longBreak":900, "sessions":4}, "session":0, "time_left":0, "ongoing":false, "paused":false, "version":"0"} |
| Welcome Message | {"mode":"Idle", "settings":{"work":1500, "shortBreak":300, "longBreak":900, "sessions":4}, "session":0, "time_left":1500, "ongoing":false, "paused":false, "version":"0"} |
| Session Running | {"mode":"Focus", "settings":{"work":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 Paused | {"mode":"Focus", "settings":{"work":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"} |
## Testing

View file

@ -41,7 +41,7 @@
</p>
<p>
<label for="focusDuration">Focus Duration (seconds):</label>
<input type="number" id="foucsDuration" placeholder="Focus time in seconds" value="900" />
<input type="number" id="foucsDuration" placeholder="Work time in seconds" value="900" />
<br />
<label for="shortBreakDuration">Short Break Duration (seconds):</label>
<input type="number" id="shortBreakDuration" placeholder="Short break in seconds" value="300" />

View file

@ -26,7 +26,7 @@ func waitForTimer(t Timer) bool {
}
}
// RunPomodoro iterates the Pomodoro focus/break sessions
// RunPomodoro iterates the Pomodoro work/break sessions
func RunPomodoro() {
mu.Lock()
shared.State.Ongoing = true

View file

@ -4,7 +4,7 @@ import "fmt"
// Represents the configuration of a pomodoro
type PomodoroConfig struct {
Focus int `json:"focus"` // Length of focus sessions in seconds
Focus int `json:"Focus"` // Length of work sessions in seconds
ShortBreak int `json:"shortBreak"` // Length of short break in seconds
LongBreak int `json:"longBreak"` // Length of long break in seconds
Sessions int `json:"sessions"` // Number of total sessions
@ -12,7 +12,7 @@ type PomodoroConfig struct {
// Stringer interface for the PomodocoConfig model
func (c PomodoroConfig) String() string {
return fmt.Sprintf("{focus: %d, short: %d, long: %d, sessions: %d}", c.Focus, c.ShortBreak, c.LongBreak, c.Sessions)
return fmt.Sprintf("{work: %d, short: %d, long: %d, sessions: %d}", c.Focus, c.ShortBreak, c.LongBreak, c.Sessions)
}
// Represents the server configuration