restructure project following best practices
https://go.dev/doc/modules/layout This also enables us to later import just the db interaction part say to the gemini capsule backend go project.
This commit is contained in:
parent
928c82536f
commit
360fedbebe
11 changed files with 202 additions and 169 deletions
45
entry.go
45
entry.go
|
|
@ -1,45 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"gemini_site/gemlog"
|
||||
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
type EntryPageModel struct {
|
||||
entry gemlog.GemlogEntry
|
||||
}
|
||||
|
||||
func initialEntryPageModel() EntryPageModel {
|
||||
return EntryPageModel{}
|
||||
}
|
||||
|
||||
func (m EntryPageModel) Update(msg tea.Msg, active bool, ctx *context) (EntryPageModel, tea.Cmd) {
|
||||
switch msg := msg.(type) {
|
||||
case gemlog.GemLogLoaded:
|
||||
m.entry = msg.Log
|
||||
case tea.KeyMsg:
|
||||
if !active {
|
||||
return m, nil
|
||||
}
|
||||
switch msg.String() {
|
||||
case "left", "h":
|
||||
cmd := func() tea.Msg {
|
||||
return SwitchPages{Page: EntryList}
|
||||
}
|
||||
return m, cmd
|
||||
}
|
||||
}
|
||||
|
||||
return m, nil
|
||||
|
||||
}
|
||||
|
||||
func (m EntryPageModel) View() string {
|
||||
s := m.entry.Slug
|
||||
s += "\n\n"
|
||||
s += m.entry.Gemtxt
|
||||
s += "\n\n-------------------------\n"
|
||||
s += "\n\nPress h or left arrow to go back"
|
||||
return s
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue