From 912de2f79257b324e049faab7564c7e4d3d029b2 Mon Sep 17 00:00:00 2001 From: Toby Padilla Date: Thu, 12 Aug 2021 17:22:24 -0500 Subject: [PATCH] Include clone urls in default README --- tui/bubble.go | 14 ++++++++------ tui/bubbles/repo/bubble.go | 8 +++++++- tui/defaults.go | 6 ++++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/tui/bubble.go b/tui/bubble.go index 51109f08b..e961ab51b 100644 --- a/tui/bubble.go +++ b/tui/bubble.go @@ -24,19 +24,21 @@ const ( quitState ) -type MenuEntry struct { - Name string `json:"name"` - Note string `json:"note"` - Repo string `json:"repo"` -} - type Config struct { Name string `json:"name"` + Host string `json:"host"` + Port int64 `json:"port"` ShowAllRepos bool `json:"show_all_repos"` Menu []MenuEntry `json:"menu"` RepoSource *git.RepoSource } +type MenuEntry struct { + Name string `json:"name"` + Note string `json:"note"` + Repo string `json:"repo"` +} + type SessionConfig struct { Width int Height int diff --git a/tui/bubbles/repo/bubble.go b/tui/bubbles/repo/bubble.go index 45dba827e..dbfd40e0b 100644 --- a/tui/bubbles/repo/bubble.go +++ b/tui/bubbles/repo/bubble.go @@ -41,7 +41,13 @@ func (b *Bubble) Init() tea.Cmd { } func (b *Bubble) Update(msg tea.Msg) (tea.Model, tea.Cmd) { - return b.readmeViewport.Update(msg) + var cmds []tea.Cmd + rv, cmd := b.readmeViewport.Update(msg) + b.readmeViewport = rv.(*ViewportBubble) + if cmd != nil { + cmds = append(cmds, cmd) + } + return b, tea.Batch(cmds...) } func (b *Bubble) View() string { diff --git a/tui/defaults.go b/tui/defaults.go index 4d31c6c51..eea8af3ca 100644 --- a/tui/defaults.go +++ b/tui/defaults.go @@ -9,16 +9,18 @@ import ( "github.com/go-git/go-git/v5/plumbing/object" ) -const defaultReadme = "# Smoothie\nWelcome to Smoothie. To setup your own configuration, please clone this repo." +const defaultReadme = "# Smoothie\n\n Welcome! You can configure your Smoothie server by cloning this repo and pushing changes.\n\n## Repos\n\n{{ range .Menu }}* {{ .Name }}{{ if .Note }} - {{ .Note }} {{ end }}\n - `git clone ssh://{{$.Host}}:{{$.Port}}/{{.Repo}}`\n{{ end }}" const defaultConfig = `{ "name": "Smoothie", "show_all_repos": true, + "host": "localhost", + "port": 23231, "menu": [ { "name": "Home", "repo": "config", - "note": "Configuration and content repo" + "note": "Configuration and content repo for this server" } ] }`