Compare commits

...

3 Commits

Author SHA1 Message Date
nate smith 7cb2fd67d1 rsvp form 2024-09-01 15:32:45 -05:00
nate smith ebadba99af towncon wip 2024-09-01 15:24:33 -05:00
nate smith b3294e880f cleanup 2024-09-01 15:17:13 -05:00
6 changed files with 153 additions and 30 deletions

View File

@ -3,7 +3,6 @@ package main
import ( import (
"errors" "errors"
"fmt" "fmt"
"math/rand"
"os" "os"
"os/user" "os/user"
"path" "path"
@ -71,8 +70,6 @@ func validExec(execPath string) error {
} }
func submit(opts *contribOpts) error { func submit(opts *contribOpts) error {
rand.Seed(time.Now().UTC().UnixNano())
var cmdName string var cmdName string
var category string var category string
var shortDesc string var shortDesc string

View File

@ -153,8 +153,6 @@ func _main() error {
r := newReviewer(signupDB, u.Username) r := newReviewer(signupDB, u.Username)
rand.Seed(time.Now().Unix())
su := models.TownSignup{} su := models.TownSignup{}
signups, err := su.All(signupDB) signups, err := su.All(signupDB)
@ -437,7 +435,8 @@ func _main() error {
if exiterr, ok := err.(*exec.ExitError); ok { if exiterr, ok := err.(*exec.ExitError); ok {
// no match or interrupt. who cares // no match or interrupt. who cares
switch exiterr.ExitCode() { switch exiterr.ExitCode() {
case 1: case 130: case 1:
case 130:
return return
} }
} }

View File

@ -6,11 +6,14 @@ import (
"math/rand" "math/rand"
"os" "os"
"os/exec" "os/exec"
"os/user"
"path" "path"
"strings" "strings"
"git.tilde.town/tildetown/town/email"
"github.com/charmbracelet/glamour" "github.com/charmbracelet/glamour"
"github.com/charmbracelet/huh" "github.com/charmbracelet/huh"
"gopkg.in/yaml.v3"
) )
//go:embed banners/* //go:embed banners/*
@ -35,8 +38,128 @@ func banner() (string, error) {
} }
func pager() *exec.Cmd { func info() error {
return exec.Command("/usr/bin/bat") infoContent, err := md.ReadFile("md/info.md")
if err != nil {
return err
}
out, err := glamour.Render(string(infoContent), "dracula")
if err != nil {
return err
}
cmd := exec.Command("/usr/bin/bat")
cmd.Stdin = strings.NewReader(out)
cmd.Stdout = os.Stdout
return cmd.Run()
}
type physicalData struct {
Arriving string
Departing string
Transportation bool
Lodging bool
Allergies string
Couch bool
}
type rsvpData struct {
Being string
PhysicalData *physicalData `yaml:"PhysicalData,omitempty"`
Freeform string
}
func sendRSVPEmail(rd rsvpData) error {
bs, err := yaml.Marshal(rd)
if err != nil {
return err
}
return email.SendLocalEmail("vilmibm", "RSVP TOWNCON24", string(bs))
}
func rsvp(o opts) error {
var being string
var arriving string
var departing string
var transportation bool
lodging := true
var allergies string
couch := true
var freeform string
form := huh.NewForm(
huh.NewGroup(
huh.NewSelect[string]().Title("How will you be attending?").
Options(
huh.NewOption("Digitally", "digital"),
huh.NewOption("Phyiscally", "physical"),
).Value(&being)),
// Physical attendee form
huh.NewGroup(
huh.NewInput().Title("When (day/time) are you arriving?").
Value(&arriving),
huh.NewInput().Title("When (day/time) are you departing?").
Value(&departing),
).WithHideFunc(func() bool {
return being != "physical"
}),
huh.NewGroup(
huh.NewConfirm().Title("Will you be staying overnight at the venue?").
Value(&lodging),
).WithHideFunc(func() bool {
return being != "physical"
}),
huh.NewGroup(
huh.NewConfirm().Title("If the need arises are you ok sleeping on a couch?").
Value(&couch),
).WithHideFunc(func() bool {
return being != "physical" && !lodging
}),
huh.NewGroup(
huh.NewInput().Title("Do you have any food allergies I should be aware of?").
Value(&allergies),
huh.NewConfirm().Title("Will you need any help getting to the venue?").
Description("I have a car and have some ability to help getting people to the venue").
Value(&transportation),
).WithHideFunc(func() bool {
return being != "physical"
}),
// Catch all freeform
huh.NewGroup(
huh.NewText().
Title("Anything you want me to know? Any questions?").
Value(&freeform)))
err := form.Run()
if err != nil {
return err
}
var pd *physicalData
if being == "physical" {
pd = &physicalData{
Arriving: arriving,
Departing: departing,
Transportation: transportation,
Lodging: lodging,
Allergies: allergies,
Couch: couch,
}
}
rd := rsvpData{
Being: being,
Freeform: freeform,
PhysicalData: pd}
return sendRSVPEmail(rd)
}
type opts struct {
Username string
} }
func _main() error { func _main() error {
@ -47,6 +170,18 @@ func _main() error {
fmt.Println(b) fmt.Println(b)
u, err := user.Current()
if err != nil {
return err
}
o := opts{
Username: u.Username,
}
fmt.Printf("\t\t^_^_^_^_^_^_^ hi ~%s ^_^_^_^_^_^_^\n", o.Username)
fmt.Println()
var mode string var mode string
huh.NewSelect[string]().Title("whuddyu wanna doo?"). huh.NewSelect[string]().Title("whuddyu wanna doo?").
@ -60,22 +195,9 @@ func _main() error {
switch mode { switch mode {
case "info": case "info":
infoContent, err := md.ReadFile("md/info.md") return info()
if err != nil {
return err
}
out, err := glamour.Render(string(infoContent), "dracula")
if err != nil {
return err
}
cmd := pager()
cmd.Stdin = strings.NewReader(out)
cmd.Stdout = os.Stdout
err = cmd.Run()
if err != nil {
return err
}
case "rsvp": case "rsvp":
return rsvp(o)
case "submit": case "submit":
case "jam": case "jam":
case "quit": case "quit":

View File

@ -73,6 +73,12 @@ I'll arrange food throughout the event.
There are also plenty of restaurants around the venue if people want to get their own food. There are also plenty of restaurants around the venue if people want to get their own food.
### TRANSPORTATION
The venue is accessible from rail, bus, and cab/uber/lyft. I have a car and can make myself available to pick people up and get them to the venue once they have made it to Chicago if they need. Depending on timing I might not be able to help, however. Contact via my cell phone (`~vilmibm/phone.txt`) to ask about my availability for a ride during the event.
If you are driving parking might be tough in the area--I can offer a few spots by my place in Forest Park if you want to put a car there and then get a ride over to the venue.
### ACTIVITIES ### ACTIVITIES
I'd like to do a field trip on the 12th...Some potential ideas: I'd like to do a field trip on the 12th...Some potential ideas:
@ -84,3 +90,7 @@ I'd like to do a field trip on the 12th...Some potential ideas:
- just hang out and play synths (field trip of the mind) - just hang out and play synths (field trip of the mind)
!!! TBD !!! !!! TBD !!!
## COMMS
For any kind of emergency during the event please contact me via my cell phone. My number can be found at `~vilmibm/phone.txt`.

View File

@ -3,13 +3,11 @@ package main
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil"
"math/rand" "math/rand"
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"strings" "strings"
"time"
"github.com/AlecAivazis/survey/v2" "github.com/AlecAivazis/survey/v2"
"github.com/charmbracelet/glamour" "github.com/charmbracelet/glamour"
@ -39,7 +37,6 @@ func main() {
} }
func visitRandomUser() error { func visitRandomUser() error {
rand.Seed(time.Now().UnixNano())
usernames, err := getUsernames() usernames, err := getUsernames()
if err != nil { if err != nil {
return err return err
@ -78,7 +75,7 @@ func visitPrompt() error {
} }
func visitUser(username string) error { func visitUser(username string) error {
files, err := ioutil.ReadDir(filepath.Join("/home", username)) files, err := os.ReadDir(filepath.Join("/home", username))
if err != nil { if err != nil {
return fmt.Errorf("user is not accepting visitors (could not read user's home directory: %w)", err) return fmt.Errorf("user is not accepting visitors (could not read user's home directory: %w)", err)
} }
@ -90,7 +87,7 @@ func visitUser(username string) error {
path := filepath.Join("/home", username, file.Name()) path := filepath.Join("/home", username, file.Name())
data, err := ioutil.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
break break
} }

View File

@ -12,7 +12,6 @@ import (
"os/user" "os/user"
"path/filepath" "path/filepath"
"syscall" "syscall"
"time"
email "git.tilde.town/tildetown/town/email" email "git.tilde.town/tildetown/town/email"
) )
@ -178,7 +177,6 @@ if you did _not_ request this, please let an admin know.
} }
func genGiteaPassword() string { func genGiteaPassword() string {
rand.Seed(time.Now().UnixNano())
b := make([]byte, 20) b := make([]byte, 20)
for i := range b { for i := range b {
b[i] = pwLetters[rand.Intn(len(pwLetters))] b[i] = pwLetters[rand.Intn(len(pwLetters))]