Compare commits

..

No commits in common. "7cb2fd67d153ee3310c1b3406976145338ef77f3" and "7b9ccf0ff22d727d8854563c3952afbeb23e3c1f" have entirely different histories.

6 changed files with 30 additions and 153 deletions

View File

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

View File

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

View File

@ -6,14 +6,11 @@ import (
"math/rand"
"os"
"os/exec"
"os/user"
"path"
"strings"
"git.tilde.town/tildetown/town/email"
"github.com/charmbracelet/glamour"
"github.com/charmbracelet/huh"
"gopkg.in/yaml.v3"
)
//go:embed banners/*
@ -38,128 +35,8 @@ func banner() (string, error) {
}
func info() error {
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 pager() *exec.Cmd {
return exec.Command("/usr/bin/bat")
}
func _main() error {
@ -170,18 +47,6 @@ func _main() error {
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
huh.NewSelect[string]().Title("whuddyu wanna doo?").
@ -195,9 +60,22 @@ func _main() error {
switch mode {
case "info":
return info()
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 := pager()
cmd.Stdin = strings.NewReader(out)
cmd.Stdout = os.Stdout
err = cmd.Run()
if err != nil {
return err
}
case "rsvp":
return rsvp(o)
case "submit":
case "jam":
case "quit":

View File

@ -73,12 +73,6 @@ I'll arrange food throughout the event.
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
I'd like to do a field trip on the 12th...Some potential ideas:
@ -90,7 +84,3 @@ 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)
!!! 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,11 +3,13 @@ package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"os"
"os/exec"
"path/filepath"
"strings"
"time"
"github.com/AlecAivazis/survey/v2"
"github.com/charmbracelet/glamour"
@ -37,6 +39,7 @@ func main() {
}
func visitRandomUser() error {
rand.Seed(time.Now().UnixNano())
usernames, err := getUsernames()
if err != nil {
return err
@ -75,7 +78,7 @@ func visitPrompt() error {
}
func visitUser(username string) error {
files, err := os.ReadDir(filepath.Join("/home", username))
files, err := ioutil.ReadDir(filepath.Join("/home", username))
if err != nil {
return fmt.Errorf("user is not accepting visitors (could not read user's home directory: %w)", err)
}
@ -87,7 +90,7 @@ func visitUser(username string) error {
path := filepath.Join("/home", username, file.Name())
data, err := os.ReadFile(path)
data, err := ioutil.ReadFile(path)
if err != nil {
break
}

View File

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