flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit eb5675cebd32825947b6db7260727b7d180b9452
parent 540ba027dc552c6617abebfa60a4dcb315e627a4
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sat, 12 Dec 2020 12:02:01 -0800

--amend

Diffstat:
Madmin.go | 20+++++++++++++++++++-
Mconfig.go | 3+++
Mexample-config.toml | 14+++++++++++---
3 files changed, 33 insertions(+), 4 deletions(-)

diff --git a/admin.go b/admin.go @@ -70,7 +70,14 @@ func setPassword(username string, newPass []byte) error { } func activateUser(username string) error { - _, err := DB.Exec("UPDATE user SET active = true WHERE username = ?", username) + // Not ideal here + row := DB.QueryRow("SELECT email FROM user where username = ?", username) + var email string + err := row.Scan(&email) + if err != nil { + return err + } + _, err = DB.Exec("UPDATE user SET active = true WHERE username = ?", username) if err != nil { // TODO verify 1 row updated return err @@ -90,6 +97,17 @@ Have fun!` os.Mkdir(path.Join(c.FilesDirectory, username), os.ModePerm) ioutil.WriteFile(path.Join(c.FilesDirectory, username, "index.gmi"), []byte(baseIndex), 0644) os.Mkdir(path.Join(c.FilesDirectory, username), os.ModePerm) + if c.SMTPUsername != "" { + SendEmail(email, "Welcome to Flounder!", fmt.Sprintf(`Hi + %s, Welcome to Flounder! You can now log into your account at + https://flounder.online/login -- For more information about + Flounder, check out https://admin.flounder.online/ + + Let me know if you have any questions, and have fun! + + Alex + `, username)) + } return nil } diff --git a/config.go b/config.go @@ -22,6 +22,9 @@ type Config struct { MaxUserBytes int64 TLSCertFile string TLSKeyFile string + SMTPServer string + SMTPUsername string + SMTPPassword string } func getConfig(filename string) (Config, error) { diff --git a/example-config.toml b/example-config.toml @@ -1,5 +1,5 @@ # Used in HTML templates and titles -SiteTitle="flounder" +SiteTitle="demoflounder" # Include port if running locally Host="localhost:8165" @@ -9,7 +9,8 @@ HttpPort=8165 HttpsEnabled=false # Folder containing subfolders for each user's files -FilesDirectory="./files" +# Must be absolute path due to bug +FilesDirectory="/home/alex/dev/go-flounder/files" LogFile="./flounder.log" # Gemini autogenerates self-signed certs @@ -20,11 +21,18 @@ GeminiCertStore="/tmp" # TLSCertFile="./server.crt" # TLSKeyFile="./server.key" +# Optional SMTP -- to send notification emails to users on acct activation +# SMTPServer = mail.goodsite.com:587 +# SMTPUsername = myemail@coolplace.com +# SMTPPassword = hunter2 + # Templates and static files # Everything in the static subfolder will be served at / TemplatesDirectory="./templates" DBFile="./flounder.db" -MaxFileSize=128000 # 128 KB +MaxFileBytes=128000 # 128 KB +MaxUserBytes=10000000 # 10 MB + OkExtensions=[".gmi", ".txt", ".jpg", ".jpeg", ".gif", ".png", ".svg", ".webp", ".midi", ".json", ".csv", ".gemini", ".mp3", ".css", ".ttf", ".otf", ".woff", ".woff2"]