From 64ce7e3777ac2589beb76dc3f6cf0f135e5a826b Mon Sep 17 00:00:00 2001 From: nbsp Date: Wed, 8 Jan 2025 02:45:01 +0200 Subject: [PATCH] initialize user --- README.md | 2 +- assets/footer.html | 3 +++ assets/header.html | 19 ++++++++++++++++++ assets/style.css | 48 ++++++++++++++++++++++++++++++++++++++++++++++ main.go | 48 ++++++++++++++++++++++++++++++++++++++++++++++ ttbp/ttbp.go | 4 ++++ 6 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 assets/footer.html create mode 100644 assets/header.html create mode 100644 assets/style.css diff --git a/README.md b/README.md index f9fa850..cf61f7b 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ make - [ ] feels manager - [ ] feels publishing - [x] plaintext - - [ ] html + - [x] html - [ ] gopher - [ ] graffiti - [x] documentation with manpages diff --git a/assets/footer.html b/assets/footer.html new file mode 100644 index 0000000..faf65ca --- /dev/null +++ b/assets/footer.html @@ -0,0 +1,3 @@ + + + diff --git a/assets/header.html b/assets/header.html new file mode 100644 index 0000000..02908f7 --- /dev/null +++ b/assets/header.html @@ -0,0 +1,19 @@ + + + + + ~%USER% on TTBP + + + +
+

+ ~%USER%@TTBP +

+
+ + + +
+ + diff --git a/assets/style.css b/assets/style.css new file mode 100644 index 0000000..d6669e2 --- /dev/null +++ b/assets/style.css @@ -0,0 +1,48 @@ +body { + background-color: #E0B0FF; + font-family: courier +} + +#meta { + top: -.5em; + position: fixed; + height: 3.5em; + float: left; + text-align: left; + width: 100%; + background-color: #e0b0ff; +} + +#tlogs { + margin-top: 5em; + width: 80%; +} + +.entry { + border: 1px dotted white; + padding: .4em; + margin-bottom:-4em; +} + +.entry p { + padding: 1em; +} + +.entry p.permalink { + font-size: .6em; + font-color: #808080; + text-align: right; +} + +.entry h5 { + text-align: right; + margin-top: .2em; +} + +blockquote { + background-color: black; + color: #e0b0ff; + font-size: 90%; + border: 1px dotted white; + padding: 4px; +} diff --git a/main.go b/main.go index 8cfb87b..bd092a8 100644 --- a/main.go +++ b/main.go @@ -1,11 +1,59 @@ package main import ( + "bufio" + _ "embed" + "fmt" + "os" + "os/user" + "path" + "strings" + "time" + "git.tilde.town/nbsp/neofeels/app" + "git.tilde.town/nbsp/neofeels/config" + "git.tilde.town/nbsp/neofeels/ttbp" "git.tilde.town/nbsp/neofeels/ui" ) +//go:embed assets/header.html +var header string + +//go:embed assets/footer.html +var footer []byte + +//go:embed assets/style.css +var style []byte + +func initializePrompt() { + fmt.Println(`i don't recognize you, stranger. let's make friends. + +the feels engine is an internal blogging platform on tilde.town. it assists you +in recording your feels, giving you the option to publish to html or gopher, and +read the feels of other users on tilde.town. + +press ↵ to set up an account, or Ctrl+c to quit. you can always come back later.`) + input := bufio.NewScanner(os.Stdin) + input.Scan() + + println(ttbp.PathUserConfig, ttbp.PathUserFeels) + + user, _ := user.Current() + header := strings.ReplaceAll(header, "%USER%", user.Username) + header = strings.ReplaceAll(header, "%DATETIME%", time.Now().Format(time.DateTime)) + os.MkdirAll(ttbp.PathUserConfig, 0700) + os.MkdirAll(ttbp.PathUserEntries, 0700) + os.WriteFile(path.Join(ttbp.PathUserConfig, "header.txt"), []byte(header), 0644) + os.WriteFile(path.Join(ttbp.PathUserConfig, "footer.txt"), footer, 0644) + os.WriteFile(path.Join(ttbp.PathUserConfig, "style.css"), style, 0644) + config.Default.Write() +} + func main() { + if _, err := os.Stat(ttbp.PathUserRc); err != nil { + initializePrompt() + } + state, err := ui.New(app.NewMainMenu()) if err != nil { panic(err) diff --git a/ttbp/ttbp.go b/ttbp/ttbp.go index ffd8ef3..3ad6274 100644 --- a/ttbp/ttbp.go +++ b/ttbp/ttbp.go @@ -265,6 +265,10 @@ func Publish(t time.Time) { return // TODO: expose this error to the user } if cfg.Publishing { + if _, err := os.Stat(PathUserWWW); os.IsNotExist(err) { + os.MkdirAll(PathUserWWW, 0700) + os.Symlink(path.Join(PathUserConfig, "style.css"), path.Join(PathUserWWW, "style.css")) + } file, err := os.Create(path.Join(PathUserWWW, "index.html")) defer file.Close()