Compare commits

..

3 Commits

Author SHA1 Message Date
46439d2488
0.3.0 2025-04-29 05:57:46 +03:00
c29a7c1594
add gopher publishing 2025-04-29 05:57:26 +03:00
350727cd58
add hotkey menu navigation
Closes: #13
2025-04-29 05:56:42 +03:00
5 changed files with 62 additions and 4 deletions

View File

@ -1 +0,0 @@
patch type="fixed" "use birthtime instead of mtime"

View File

@ -1,2 +1,2 @@
name neofeels
version 0.2.0
version 0.3.0

View File

@ -1,5 +1,16 @@
# Changelog
## [0.3.0] - 2025-04-29
### Added
- add gopher support
- shortcuts to list items in menu and management
### Fixed
- use birthtime instead of mtime
## [0.2.0] - 2025-01-20
### Added

View File

@ -25,7 +25,7 @@ const title = ` ___ __
/ _/__ ___ / /__
/ _/ -_) -_) (_-<
/_/ \__/\__/_/___/
neofeels 0.2.0`
neofeels 0.3.0`
func NewMainMenu(index int) *MainMenu {
return &MainMenu{

View File

@ -28,11 +28,13 @@ var (
PathUser = os.Getenv("HOME")
PathUserFeels = path.Join(PathUser, ".ttbp")
PathUserHTML = path.Join(PathUser, "public_html")
PathUserGopherhole = path.Join(PathUser, "public_gopher", "feels")
PathUserConfig = path.Join(PathUserFeels, "config")
PathUserEntries = path.Join(PathUserFeels, "entries")
PathUserBuried = path.Join(PathUserFeels, "buried")
PathUserBackups = path.Join(PathUserFeels, "backups")
PathUserWWW = path.Join(PathUserFeels, "www")
PathUserGopher = path.Join(PathUserFeels, "gopher")
PathUserRc = path.Join(PathUserConfig, "ttbprc")
PathUserNopub = path.Join(PathUserConfig, "nopub")
PathUserHTMLRender = path.Join(PathUserConfig, "html")
@ -436,7 +438,49 @@ func Publish() {
writer.WriteString(string(footer))
writer.Flush()
}
// TODO: gopher
if cfg.Gopher {
os.RemoveAll(PathUserGopher) // remove all posts and start over
if _, err := os.Stat(PathUserGopher); os.IsNotExist(err) {
os.MkdirAll(PathUserGopher, 0755)
os.Symlink(PathUserGopher, PathUserGopherhole)
}
file, err := os.Create(path.Join(PathUserGopher, "gophermap"))
defer file.Close()
if err != nil {
return
}
writer := bufio.NewWriter(file)
user, _ := user.Current()
writer.WriteString(fmt.Sprintf(`
welcome to %s's gopherfeels.
.:: .::
.: .::
.:.: .: .:: .:: .:: .::::
.:: .: .:: .: .:: .::.::
.:: .::::: .::.::::: .:: .:: .:::
.:: .: .: .:: .::
.:: .:::: .:::: .:::.:: .::
this file is automatically generated by ttbp.
0(about ttbp)%s/~endorphant/ttbp.txt%stilde.town%s70
1(back to user's home)%s/~%s
entries:
`, user.Username, "\t", "\t", "\t", "\t", user.Username))
for _, post := range GetPostsForUser(user.Username) {
if !post.Nopub && post.Words > 0 {
dateString := post.Date.Format("20060102.txt")
os.Symlink(path.Join(PathUserEntries, dateString), path.Join(PathUserGopher, dateString))
writer.WriteString(fmt.Sprintf("0%s\t%s\n", post.Date.Format("2006-01-02"), dateString))
}
}
writer.Flush()
}
}
func Unpublish() {
@ -448,6 +492,10 @@ func Unpublish() {
os.RemoveAll(PathUserWWW)
os.RemoveAll(path.Join(PathUserHTML, cfg.PublishDir))
}
if cfg.Gopher {
os.RemoveAll(PathUserGopher)
os.RemoveAll(PathUserGopherhole)
}
}
func writePage(post Post, header, footer []byte) {