Add grace period and fix bugs

This commit is contained in:
Andrew-71 2024-05-05 13:06:20 +03:00
parent e565c7be6d
commit 349e964364
14 changed files with 148 additions and 35 deletions

View file

@ -6,7 +6,7 @@ This project is *very* opinionated and minimal, and is designed primarily for my
As a result, I can't guarantee that it's either secure or stable.
## Features:
* Each day, you get a text file. You have until 23:59 of that very day to finalise it.
* Each day, you get a new text file. You have until the end of that very day to finalise it.
* You can save named notes to document milestones, big events, or just a nice game you played this month
* You can easily export entire `data` dir in a `.zip` archive for backups
@ -35,6 +35,7 @@ data
config
+-- config.txt
```
Deleting notes is done by clearing contents and clicking "Save" - the app deletes empty files when saving.
### Config options:
Below are defaults of config.txt. The settings are defined in newline separated key=value pairs.
@ -45,6 +46,7 @@ username=admin # Your username
password=admin # Your password
port=7101 # What port to run on (probably leave on 7101 if using docker)
timezone=Local # IANA Time zone database identifier ("UTC", Local", "Europe/Moscow" etc.), Defaults to Local if can't parse.
grace_period=0s # Time after a new day begins, but before the switch to next day's file. e.g. 2h30m - files will change at 2:30am
language=en # ISO-639 language code (currently supported - en, ru)
log_to_file=false # Whether to write logs to a file
log_file=config/log.txt # Where to store the log file if it is enabled
@ -74,4 +76,22 @@ If you for some reason decide to run plain executable instead of docker, it supp
override port
-debug
show debug log
```
### API methods
You can access the API at `/api/<method>`. They are protected by same HTTP Basic Auth as "normal" site.
```
GET /today - get file contents for today
POST /today - save request body into today's file
GET /day - get JSON list of all daily entries
GET /day/<name> - get file contents for a specific day
GET /notes - get JSON list of all named notes
GET /notes/<name> - get file contents for a specific note
POST /notes/<name> - save request body into a named note
GET /export - get .zip archive of entire data directory
GET /readme - get file contents for readme.txt in data dir's root
POST /readme - save request body into readme.txt
```