further the rearranging

vilmibm 2023-11-01 03:25:26 +00:00
parent 0764534fed
commit 100643d8fc
12 changed files with 20 additions and 25 deletions

14
.gitignore vendored
View File

@ -3,12 +3,12 @@ cmd/launcher/launcher
cmd/request/request cmd/request/request
cmd/contrib/contrib cmd/contrib/contrib
cmd/visit/visit cmd/visit/visit
cmd/signup/signup
cmd/review/review cmd/review/review
cmd/welcome/welcome
cmd/createkeyfile/createkeyfile
cmd/registeruser/registeruser
cmd/stats/stats cmd/stats/stats
cmd/appendkeyfile/appendkeyfile external/cmd/signup/signup
cmd/help/help external/cmd/welcome/welcome
cmd/emailtouser/emailtouser external/cmd/help/help
external/cmd/helpers/emailtouser/emailtouser
external/cmd/helpers/createkeyfile/createkeyfile
external/cmd/helpers/registeruser/registeruser
external/cmd/helpers/appendkeyfile/appendkeyfile

BIN
external/cmd/help/help vendored

Binary file not shown.

View File

@ -10,9 +10,9 @@ import (
"os/exec" "os/exec"
"strconv" "strconv"
"strings" "strings"
"time"
"git.tilde.town/tildetown/town/codes" "git.tilde.town/tildetown/town/codes"
"git.tilde.town/tildetown/town/external/lockingwriter"
"git.tilde.town/tildetown/town/sshkey" "git.tilde.town/tildetown/town/sshkey"
"github.com/charmbracelet/lipgloss" "github.com/charmbracelet/lipgloss"
_ "github.com/mattn/go-sqlite3" _ "github.com/mattn/go-sqlite3"
@ -124,10 +124,8 @@ func (p *Prompter) Select(prompt string, opts []string) (int, error) {
} }
func _main(cs colorScheme) error { func _main(cs colorScheme) error {
logFilename := fmt.Sprintf("/town/var/log/help/%d", time.Now().Unix()) lw := lockingwriter.New()
logFile, err := os.OpenFile(logFilename, os.O_WRONLY|os.O_CREATE|os.O_EXCL, 0600) l := log.New(lw, "help", log.Ldate|log.Ltime|log.LUTC|log.Lshortfile|log.Lmsgprefix)
l := log.New(logFile, "", log.Ldate|log.Ltime|log.LUTC|log.Lshortfile)
defer logFile.Close()
db, err := connectDB() db, err := connectDB()
if err != nil { if err != nil {

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -134,7 +134,6 @@ func main() {
} }
func _main(l *log.Logger, db *sql.DB) error { func _main(l *log.Logger, db *sql.DB) error {
l.Println("starting a session")
pages := tview.NewPages() pages := tview.NewPages()
mainFlex := tview.NewFlex() mainFlex := tview.NewFlex()
input := tview.NewTextArea() input := tview.NewTextArea()
@ -305,7 +304,6 @@ func _main(l *log.Logger, db *sql.DB) error {
/nod /nod
and pressing enter will cause you to nod. some other verbs: /quit /look`)) and pressing enter will cause you to nod. some other verbs: /quit /look`))
case "quit": case "quit":
l.Println("got /quit")
app.Stop() app.Stop()
case "look": case "look":
fmt.Fprintln(msgScroll, "") fmt.Fprintln(msgScroll, "")
@ -314,8 +312,6 @@ func _main(l *log.Logger, db *sql.DB) error {
if !sm.Advance() { if !sm.Advance() {
fmt.Fprintln(msgScroll, "you nod, but nothing happens.") fmt.Fprintln(msgScroll, "you nod, but nothing happens.")
fmt.Fprintln(msgScroll) fmt.Fprintln(msgScroll)
} else {
l.Println("advancing scene")
} }
} }
return return
@ -334,10 +330,7 @@ func _main(l *log.Logger, db *sql.DB) error {
msgScroll.ScrollToEnd() msgScroll.ScrollToEnd()
} }
defer func() { defer db.Close()
l.Println("exiting")
db.Close()
}()
app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Key() { switch event.Key() {

Binary file not shown.

View File

@ -206,7 +206,7 @@ func createUser(data newUserData) (err error) {
func keyfileText(data newUserData) string { func keyfileText(data newUserData) string {
header := `########## GREETINGS! ########## header := `########## GREETINGS! ##########
# Hi! This file was automatically generated by tilde.town when # This file was automatically generated by tilde.town when
# your account was created. You can edit it if you want, but we # your account was created. You can edit it if you want, but we
# recommend adding stuff to ~/.ssh/authorized_keys instead.` # recommend adding stuff to ~/.ssh/authorized_keys instead.`

Binary file not shown.

View File

@ -13,10 +13,13 @@ type LockingWriter struct {
path string path string
} }
const fp = "/town/var/log/external.log" const (
fp = "/town/var/log/external.log"
lp = "/town/var/log/log.lock"
)
func NewLockingWriter() *LockingWriter { func New() *LockingWriter {
f, err := os.Create(fp) f, err := os.OpenFile(fp, os.O_EXCL|os.O_CREATE|os.O_WRONLY, 0660)
if err != nil { if err != nil {
panic(err) panic(err)
} }
@ -28,7 +31,7 @@ func NewLockingWriter() *LockingWriter {
} }
func (l *LockingWriter) Write(p []byte) (n int, err error) { func (l *LockingWriter) Write(p []byte) (n int, err error) {
fl := flock.New(l.path) fl := flock.New(lp)
var locked bool var locked bool
for !locked { for !locked {
@ -38,6 +41,7 @@ func (l *LockingWriter) Write(p []byte) (n int, err error) {
} }
time.Sleep(time.Second) time.Sleep(time.Second)
} }
var f *os.File var f *os.File
f, err = os.OpenFile(l.path, os.O_APPEND|os.O_WRONLY, 0600) f, err = os.OpenFile(l.path, os.O_APPEND|os.O_WRONLY, 0600)
if err != nil { if err != nil {