initialize user

trunk
nbsp 2025-01-08 02:45:01 +02:00
parent 8588cbd16d
commit 64ce7e3777
No known key found for this signature in database
GPG Key ID: 7184AC1C9835CE48
6 changed files with 123 additions and 1 deletions

View File

@ -19,7 +19,7 @@ make
- [ ] feels manager - [ ] feels manager
- [ ] feels publishing - [ ] feels publishing
- [x] plaintext - [x] plaintext
- [ ] html - [x] html
- [ ] gopher - [ ] gopher
- [ ] graffiti - [ ] graffiti
- [x] documentation with manpages - [x] documentation with manpages

View File

@ -0,0 +1,3 @@
</div>
</body>
</html>

19
assets/header.html 100644
View File

@ -0,0 +1,19 @@
<!doctype html>
<html>
<head>
<!--- this header automatically generated by ttbp initialization on %DATETIME% --->
<title>~%USER% on TTBP</title>
<link rel="stylesheet" href="style.css" />
</head>
<body>
<div id="meta">
<h1>
<a href="index.html#">~%USER%</a>@<a href="/~%USER%/neofeels">TTBP</a>
</h1>
</div>
<!---put your custom html here-->
<!---don't put anything after this line-->
<div id="tlogs"></div>
</body>
</html>

48
assets/style.css 100644
View File

@ -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;
}

48
main.go
View File

@ -1,11 +1,59 @@
package main package main
import ( import (
"bufio"
_ "embed"
"fmt"
"os"
"os/user"
"path"
"strings"
"time"
"git.tilde.town/nbsp/neofeels/app" "git.tilde.town/nbsp/neofeels/app"
"git.tilde.town/nbsp/neofeels/config"
"git.tilde.town/nbsp/neofeels/ttbp"
"git.tilde.town/nbsp/neofeels/ui" "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() { func main() {
if _, err := os.Stat(ttbp.PathUserRc); err != nil {
initializePrompt()
}
state, err := ui.New(app.NewMainMenu()) state, err := ui.New(app.NewMainMenu())
if err != nil { if err != nil {
panic(err) panic(err)

View File

@ -265,6 +265,10 @@ func Publish(t time.Time) {
return // TODO: expose this error to the user return // TODO: expose this error to the user
} }
if cfg.Publishing { 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")) file, err := os.Create(path.Join(PathUserWWW, "index.html"))
defer file.Close() defer file.Close()