Add comments

This commit is contained in:
Andrew-71 2024-03-28 10:42:52 +03:00
parent f0198a4a72
commit a53dda25bd
8 changed files with 16 additions and 8 deletions

View file

@ -7,15 +7,16 @@ As a result of this, it is also neither secure nor stable.
## Features:
* Each day, you get a text file. You have until 23:59 of that very day to finalise it.
* At any moment, you can append a single line to log.txt
* You can save named notes to document milestones, big events, or just a nice game you played this month
* There is also a readme.txt file (just like this one, except you get to write it!)
* You can save named notes to document milestones, big events, or just a nice game you played this month*
* There is also a readme.txt file (just like this one, except you get to write it!)*
* You can easily export everything in a zip file for backups
* Everything is plain(text) and simple. No databases, encryption, OAuth, or anything fancy. Even the password is plainte- *wait is this a feature?*
* Docker support (in fact, that's probably the best way to run this)
* Optional Telegram notifications for failed login attempts
*only available through API, subject to change and removal
## Data format:
```
data
@ -26,7 +27,6 @@ data
| +-- note1.txt
| +-- note2.txt
| ...
+-- log.txt
+-- readme.txt
config

View file

@ -4,9 +4,8 @@ List of things to add to this project
* Make scram configurable
* Use reflection in config loading
* Check export function for improvements
* Improve viewing of days (textarea over raw API requests), add notes to frontend
* Add notes to frontend?
* More slog.Debug and a debug flag?
* Think about timezones
* Consider more secure auth methods
* *Go* dependency-less? <-- this is a terrible idea
* Better visual feedback from JS?
* *Go* dependency-less? <-- this is a terrible idea

View file

@ -89,6 +89,7 @@ func (c *Config) Reload() error {
return nil
}
// ConfigInit loads config on startup
func ConfigInit() Config {
cfg := Config{Port: 7101, Username: "admin", Password: "admin"} // Default values are declared here, I guess
err := cfg.Reload()

View file

@ -11,6 +11,7 @@ import (
var ExportPath = "data/export.zip"
// Export saves a .zip archive of the data folder to the passed filename
func Export(filename string) error {
file, err := os.Create(filename)
if err != nil {

View file

@ -5,6 +5,7 @@ import (
"log"
)
// FlagInit processes app flags
func FlagInit() {
config := flag.String("config", "", "override config file")
username := flag.String("user", "", "override username")

View file

@ -1,3 +1,4 @@
// Format time in "Jan 02, 2006" format
function formatDate(date) {
let dateFormat = new Intl.DateTimeFormat('en', {
year: 'numeric',
@ -15,7 +16,7 @@ function updateDate() {
}
// Starts interval to update today's date every hour at 00:00
// Start interval to update today's date every hour at 00:00
function callEveryHour() {
setInterval(updateDate, 1000 * 60 * 60);
}

View file

@ -37,6 +37,7 @@ func InternalError(w http.ResponseWriter, r *http.Request) {
http.ServeFile(w, r, "./pages/error/500.html")
}
// GetToday renders HTML page for today's view
func GetToday(w http.ResponseWriter, r *http.Request) {
day, err := ReadToday()
if err != nil {
@ -63,6 +64,7 @@ func GetToday(w http.ResponseWriter, r *http.Request) {
}
}
// PostToday saves today's entry from form and redirects back to GET
func PostToday(w http.ResponseWriter, r *http.Request) {
err := SaveToday([]byte(r.FormValue("day")))
if err != nil {
@ -71,6 +73,7 @@ func PostToday(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, r.Header.Get("Referer"), 302)
}
// GetDays renders HTML page for list of previous days
func GetDays(w http.ResponseWriter, r *http.Request) {
day, err := ListFiles("day")
if err != nil {
@ -104,6 +107,7 @@ func GetDays(w http.ResponseWriter, r *http.Request) {
}
}
// GetDay renders HTML page for a specific day
func GetDay(w http.ResponseWriter, r *http.Request) {
dayString := chi.URLParam(r, "day")
if dayString == "" {

View file

@ -9,6 +9,7 @@ import (
"strconv"
)
// Serve starts the app's web server
func Serve() {
r := chi.NewRouter()
r.Use(middleware.Logger, middleware.CleanPath, middleware.StripSlashes)