pull/1/head
vilmibm 2023-02-14 07:33:53 +00:00
parent 5682d3dafd
commit 327e0551b9
2 changed files with 112 additions and 5 deletions

View File

@ -2,12 +2,119 @@ package main
import (
"fmt"
"math/rand"
"os"
"strings"
"time"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
func getTitle() string {
titles := []string{
"yo bum rush the show",
"can i kick it?",
"super nintendo sega genesis",
"birthdays was the worst days",
"where were you when we were getting high?",
"it's real time, real time, time to get real",
}
return titles[rand.Intn(len(titles))]
}
const (
signupDir = "/town/signups"
acceptedDir = "/town/signups/accepted"
rejectedDir = "/town/signups/rejected"
)
// TODO copypasta from signup cmd
type townApplication struct {
When time.Time
Answers map[string]string
}
func (a townApplication) Render() string {
// TODO
return "TODO"
}
func getApplications() ([]townApplication, error) {
entries, err := os.ReadDir(signupDir)
if err != nil {
return nil, fmt.Errorf("failed to read '%s': %w", signupDir, err)
}
out := []townApplication{}
for _, entry := range entries {
if !strings.HasSuffix(entry.Name(), "json") {
continue
}
// TODO read file
// TODO unmarshal
// TODO append
}
// TODO
return out, nil
}
func _main() error {
// TODO tview
return nil
rand.Seed(time.Now().Unix())
applications, err := getApplications()
if err != nil {
return fmt.Errorf("could not get applications: %w", err)
}
pages := tview.NewPages()
mainFlex := tview.NewFlex()
title := tview.NewTextView()
title.SetText(getTitle())
appView := tview.NewTextView()
if len(applications) == 0 {
appView.SetText("no applications found.")
} else {
appView.SetText(applications[0].Render())
}
legend := tview.NewTextView()
legend.SetText("TODO actions legend")
mainFlex.SetDirection(tview.FlexRow)
mainFlex.AddItem(title, 1, -1, false)
mainFlex.AddItem(appView, 0, 1, true)
mainFlex.AddItem(legend, 1, -1, false)
pages.AddPage("main", mainFlex, true, true)
// TODO page for textarea to notate
app := tview.NewApplication()
app.SetRoot(pages, true)
app.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Rune() {
case 's':
// TODO skip
case 'r':
// TODO skip to random
case 'A':
// TODO approve
case 'R':
// TODO reject
case 'n':
// TODO notate
case 'Q':
app.Stop()
}
return event
})
return app.Run()
}
func main() {

View File

@ -16,9 +16,9 @@ import (
)
const (
maxInputLength int = 10000
signupDirectory string = "/town/signups"
logDir string = "/town/var/signup"
maxInputLength = 10000
signupDirectory = "/town/signups"
logDir = "/town/var/signup"
)
type scene struct {