initialize user
parent
8588cbd16d
commit
64ce7e3777
|
@ -19,7 +19,7 @@ make
|
|||
- [ ] feels manager
|
||||
- [ ] feels publishing
|
||||
- [x] plaintext
|
||||
- [ ] html
|
||||
- [x] html
|
||||
- [ ] gopher
|
||||
- [ ] graffiti
|
||||
- [x] documentation with manpages
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -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>
|
|
@ -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
48
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)
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue