From da45f627e09079eadbf7f14d3539380c7c5a8458 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Mon, 9 Sep 2019 19:35:16 -0700 Subject: [PATCH 001/145] Initial v2 commit, deep in restructuring... maybe not for the better? --- bookmarks.go | 68 ++++ client.go | 541 +++++++++++++++++++++++++++++ footbar.go | 54 +++ gopher/gopher.go | 2 +- gopher/open_browser_darwin.go | 2 +- gopher/open_browser_linux.go | 2 +- gopher/open_browser_other.go | 2 +- gopher/open_browser_windows.go | 2 +- headbar.go | 47 +++ main.go | 606 +++++++-------------------------- page.go | 30 ++ pages.go | 54 +++ url.go | 107 ++++++ 13 files changed, 1026 insertions(+), 491 deletions(-) create mode 100644 bookmarks.go create mode 100644 client.go create mode 100644 footbar.go create mode 100644 headbar.go create mode 100644 page.go create mode 100644 pages.go create mode 100644 url.go diff --git a/bookmarks.go b/bookmarks.go new file mode 100644 index 0000000..3b044fd --- /dev/null +++ b/bookmarks.go @@ -0,0 +1,68 @@ +package main + +import ( + "fmt" +) + +//------------------------------------------------\\ +// + + + T Y P E S + + + \\ +//--------------------------------------------------\\ + +type Bookmarks struct { + IsOpen bool + IsFocused bool + Position int + Length int + Titles []string + Links []string +} + +//------------------------------------------------\\ +// + + + R E C E I V E R S + + + \\ +//--------------------------------------------------\\ + +func (b *Bookmarks) Add([]string) error { + // TODO add a bookmark + return fmt.Errorf("") +} + +func (b *Bookmarks) Delete(int) error { + // TODO delete a bookmark + return fmt.Errorf("") +} + +func (b *Bookmarks) ToggleOpen() { + b.IsOpen = !b.IsOpen + if b.IsOpen { + b.IsFocused = true + } else { + b.IsFocused = false + } +} + +func (b *Bookmarks) ToggleFocused() { + if b.IsOpen { + b.IsFocused = !b.IsFocused + } +} + +func (b *Bookmarks) IniDump() string { + // TODO create dump of values for INI file + return "" +} + +func (b *Bookmarks) Render() ([]string, error) { + // TODO grab all of the bookmarks as a fixed + // width string including border and spacing + return []string{}, fmt.Errorf("") +} + + +//------------------------------------------------\\ +// + + + F U N C T I O N S + + + \\ +//--------------------------------------------------\\ + +func MakeBookmarks() Bookmarks { + return Bookmarks{false, false, 0, 0, make([]string, 0), make([]string, 0)} +} + diff --git a/client.go b/client.go new file mode 100644 index 0000000..8c2bdc0 --- /dev/null +++ b/client.go @@ -0,0 +1,541 @@ +package main + +import ( + "fmt" + "io/ioutil" + "net" + "os" + "os/exec" + "os/user" + "regexp" + "strconv" + "strings" + "time" + + "tildegit.org/sloum/bombadillo/cmdparse" + "tildegit.org/sloum/bombadillo/cui" + "tildegit.org/sloum/bombadillo/gopher" +) + +//------------------------------------------------\\ +// + + + T Y P E S + + + \\ +//--------------------------------------------------\\ + +type client struct { + Height int + Width int + Options map[string]string + Message string + PageState Pages + BookMarks Bookmarks + TopBar Headbar + FootBar Footbar +} + + +//------------------------------------------------\\ +// + + + R E C E I V E R S + + + \\ +//--------------------------------------------------\\ + +func (c *client) GetSize() { + for { + redraw := false + cmd := exec.Command("stty", "size") + cmd.Stdin = os.Stdin + out, err := cmd.Output() + if err != nil { + fmt.Println("Fatal error: Unable to retrieve terminal size") + os.Exit(5) + } + var h, w int + fmt.Sscan(string(out), &h, &w) + if h != c.Height || w != c.Width { + redraw = true + } + + c.Height = h + c.Width = w + + if redraw { + c.Draw() + } + + time.Sleep(1 * time.Second) + } +} + +func (c *client) Draw() { + // TODO build this out. + // It should call all of the renders + // and add them to the a string buffer + // It should then print the buffer +} + +func (c *client) TakeControlInput() { + input := cui.Getch() + + switch input { + case 'j', 'J': + // scroll down one line + c.Scroll(1) + case 'k', 'K': + // scroll up one line + c.Scroll(-1) + case 'q', 'Q': + // quite bombadillo + cui.Exit() + case 'g': + // scroll to top + c.Scroll(-len(c.PageState.History[c.PageState.Position].WrappedContent)) + case 'G': + // scroll to bottom + c.Scroll(len(c.PageState.History[c.PageState.Position].WrappedContent)) + case 'd': + // scroll down 75% + distance := c.Height - c.Height / 4 + c.Scroll(distance) + case 'u': + // scroll up 75% + distance := c.Height - c.Height / 4 + c.Scroll(-distance) + case 'b': + // go back + err := c.PageState.NavigateHistory(-1) + if err != nil { + c.SetMessage(err.Error(), false) + c.DrawMessage() + } else { + c.Draw() + } + case 'B': + // open the bookmarks browser + c.BookMarks.ToggleOpen() + c.Draw() + case 'f', 'F': + // go forward + err := c.PageState.NavigateHistory(1) + if err != nil { + c.SetMessage(err.Error(), false) + c.DrawMessage() + } else { + c.Draw() + } + case '\t': + // Toggle bookmark browser focus on/off + c.BookMarks.ToggleFocused() + c.Draw() + case ':', ' ': + // Process a command + c.ClearMessage() + c.ClearMessageLine() + entry, err := cui.GetLine() + c.ClearMessageLine() + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + break + } else if strings.TrimSpace(entry) == "" { + break + } + + parser := cmdparse.NewParser(strings.NewReader(entry)) + p, err := parser.Parse() + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + } else { + err := c.routeCommandInput(p) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + } + } + } +} + + +func (c *client) routeCommandInput(com *cmdparse.Command) error { + var err error + switch com.Type { + case cmdparse.SIMPLE: + c.simpleCommand(com.Action) + case cmdparse.GOURL: + c.goToURL(com.Target) + case cmdparse.GOLINK: + c.goToLink(com.Target) + case cmdparse.DO: + c.doCommand(com.Action, com.Value) + case cmdparse.DOLINK: + // err = doLinkCommand(com.Action, com.Target) + case cmdparse.DOAS: + c.doCommandAs(com.Action, com.Value) + case cmdparse.DOLINKAS: + // err = doLinkCommandAs(com.Action, com.Target, com.Value) + default: + return fmt.Errorf("Unknown command entry!") + } + + return err +} + +func (c *client) simpleCommand(action string) { + action = strings.ToUpper(action) + switch action { + case "Q", "QUIT": + cui.Exit() + case "H", "HOME": + if c.Options["homeurl"] != "unset" { + go c.Visit(c.Options["homeurl"]) + } else { + c.SetMessage(fmt.Sprintf("No home address has been set"), false) + c.DrawMessage() + } + case "B", "BOOKMARKS": + c.BookMarks.ToggleOpen() + case "SEARCH": + c.search() + case "HELP", "?": + go c.Visit(helplocation) + default: + c.SetMessage(fmt.Sprintf("Unknown action %q", action), true) + c.DrawMessage() + } +} + +func (c *client) doCommand(action string, values []string) { + if length := len(values); length != 1 { + c.SetMessage(fmt.Sprintf("Expected 1 argument, received %d", len(values)), true) + c.DrawMessage() + return + } + + switch action { + case "CHECK", "C": + c.displayConfigValue(values[0]) + default: + c.SetMessage(fmt.Sprintf("Unknown action %q", action), true) + c.DrawMessage() + } +} + +func (c *client) doCommandAs(action string, values []string) { + if len(values) < 2 { + c.SetMessage(fmt.Sprintf("Expected 1 argument, received %d", len(values)), true) + c.DrawMessage() + return + } + + if values[0] == "." { + values[0] = c.PageState.History[c.PageState.Position].Location.Full + } + + switch action { + case "ADD", "A": + err := c.BookMarks.Add(values) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + + err = saveConfig() + if err != nil { + c.SetMessage("Error saving bookmark to file", true) + c.DrawMessage() + } + if c.BookMarks.IsOpen { + c.Draw() + } + + case "WRITE", "W": + // TODO figure out how best to handle file + // writing... it will depend on request model + // using fetch would be best + // - - - - - - - - - - - - - - - - - - - - - + // var data []byte + // if values[0] == "." { + // d, err := c.getCurrentPageRawData() + // if err != nil { + // c.SetMessage(err.Error(), true) + // c.DrawMessage() + // return + // } + // data = []byte(d) + // } + // fp, err := c.saveFile(data, strings.Join(values[1:], " ")) + // if err != nil { + // c.SetMessage(err.Error(), true) + // c.DrawMessage() + // return + // } + // c.SetMessage(fmt.Sprintf("File saved to: %s", fp), false) + // c.DrawMessage() + + case "SET", "S": + if _, ok := c.Options[values[0]]; ok { + c.Options[values[0]] = strings.Join(values[1:], " ") + err := saveConfig() + if err != nil { + c.SetMessage("Value set, but error saving config to file", true) + c.DrawMessage() + } else { + c.SetMessage(fmt.Sprintf("%s is now set to %q", values[0], c.Options[values[0]]), true) + c.DrawMessage() + } + return + } + c.SetMessage(fmt.Sprintf("Unable to set %s, it does not exist", values[0]), true) + c.DrawMessage() + return + } + c.SetMessage(fmt.Sprintf("Unknown command structure"), true) +} + +func (c *client) getCurrentPageUrl() (string, error) { + if c.PageState.Length < 1 { + return "", fmt.Errorf("There are no pages in history") + } + return c.PageState.History[c.PageState.Position].Location.Full, nil +} + +func (c *client) getCurrentPageRawData() (string, error) { + if c.PageState.Length < 1 { + return "", fmt.Errorf("There are no pages in history") + } + return c.PageState.History[c.PageState.Position].RawContent, nil +} + +func (c *client) saveFile(data []byte, name string) (string, error) { + savePath := c.Options["savelocation"] + name + err := ioutil.WriteFile(savePath, data, 0644) + if err != nil { + return "", err + } + + return savePath, nil +} + +func (c *client) search() { + c.ClearMessage() + c.ClearMessageLine() + fmt.Print("?") + entry, err := cui.GetLine() + c.ClearMessageLine() + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } else if strings.TrimSpace(entry) == "" { + return + } + u, err := MakeUrl(c.Options["searchurl"]) + if err != nil { + c.SetMessage("'searchurl' is not set to a valid url", true) + c.DrawMessage() + return + } + switch u.Scheme { + case "gopher": + go c.Visit(fmt.Sprintf("%s\t%s",u.Full,entry)) + case "gemini": + // TODO url escape the entry variable + escapedEntry := entry + go c.Visit(fmt.Sprintf("%s?%s",u.Full,escapedEntry)) + case "http", "https": + c.SetMessage("Attempting to open in web browser", false) + c.DrawMessage() + err := gopher.OpenBrowser(u.Full) + if err != nil { + c.SetMessage(err.Error(), true) + } else { + c.SetMessage("Opened in web browser", false) + } + c.DrawMessage() + default: + c.SetMessage(fmt.Sprintf("%q is not a supported protocol", u.Scheme), true) + c.DrawMessage() + } +} + +func (c *client) Scroll(amount int) { + page := c.PageState.History[c.PageState.Position] + bottom := len(page.WrappedContent) - c.Height + if amount < 0 && page.ScrollPosition == 0 { + c.SetMessage("You are already at the top", false) + c.DrawMessage() + fmt.Print("\a") + return + } else if amount > 0 && page.ScrollPosition == bottom || bottom < 0 { + c.SetMessage("You are already at the bottom", false) + c.DrawMessage() + fmt.Print("\a") + return + } + + newScrollPosition := page.ScrollPosition + amount + if newScrollPosition < 0 { + newScrollPosition = 0 + } else if newScrollPosition > bottom { + newScrollPosition = bottom + } + + page.ScrollPosition = newScrollPosition + c.Draw() +} + +func (c *client) displayConfigValue(setting string) { + if val, ok := c.Options[setting]; ok { + c.SetMessage(fmt.Sprintf("%s is set to: %q", setting, val), false) + c.DrawMessage() + } else { + c.SetMessage(fmt.Sprintf("Invalid: %q does not exist", setting), true) + c.DrawMessage() + } +} + +func (c *client) SetMessage(msg string, isError bool) { + leadIn, leadOut := "", "" + if isError { + leadIn = "\033[31m" + leadOut = "\033[0m" + } + + c.Message = fmt.Sprintf("%s%s%s", leadIn, msg, leadOut) +} + +func (c *client) DrawMessage() { + c.ClearMessageLine() + cui.MoveCursorTo(c.Height-1, 0) + fmt.Print(c.Message) +} + +func (c *client) ClearMessage() { + c.Message = "" +} + +func (c *client) ClearMessageLine() { + cui.MoveCursorTo(c.Height-1, 0) + cui.Clear("line") +} + +func (c *client) goToURL(u string) { + if num, _ := regexp.MatchString(`^-?\d+.?\d*$`, u); num { + c.goToLink(u) + return + } + + go c.Visit(u) +} + +func (c *client) goToLink(l string) { + if num, _ := regexp.MatchString(`^-?\d+$`, l); num && c.PageState.Length > 0 { + linkcount := len(c.PageState.History[c.PageState.Position].Links) + item, err := strconv.Atoi(l) + if err != nil { + c.SetMessage(fmt.Sprintf("Invalid link id: %s", l), true) + c.DrawMessage() + return + } + if item <= linkcount && item > 0 { + linkurl := c.PageState.History[c.PageState.Position].Links[item-1] + c.Visit(linkurl) + } else { + c.SetMessage(fmt.Sprintf("Invalid link id: %s", l), true) + c.DrawMessage() + return + } + } + + c.SetMessage(fmt.Sprintf("Invalid link id: %s", l), true) + c.DrawMessage() +} + +func (c *client) Visit(url string) { + u, err := MakeUrl(url) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + + switch u.Scheme { + case "gopher": + // TODO send over to gopher request + case "gemini": + // TODO send over to gemini request + case "http", "https": + c.SetMessage("Attempting to open in web browser", false) + c.DrawMessage() + if strings.ToUpper(c.Options["openhttp"]) == "TRUE" { + err := gopher.OpenBrowser(u.Full) + if err != nil { + c.SetMessage(err.Error(), true) + } else { + c.SetMessage("Opened in web browser", false) + } + c.DrawMessage() + } else { + c.SetMessage("'openhttp' is not set to true, aborting opening web link", false) + c.DrawMessage() + } + default: + c.SetMessage(fmt.Sprintf("%q is not a supported protocol", u.Scheme), true) + c.DrawMessage() + } +} + + +//------------------------------------------------\\ +// + + + F U N C T I O N S + + + \\ +//--------------------------------------------------\\ + +func MakeClient(name string) *client { + var userinfo, _ = user.Current() + var options = map[string]string{ + "homeurl": "gopher://colorfield.space:70/1/bombadillo-info", + "savelocation": userinfo.HomeDir, + "searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs", + "openhttp": "false", + "httpbrowser": "lynx", + "configlocation": userinfo.HomeDir, + } + c := client{0, 0, options, "", MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar()} + c.GetSize() + return &c +} + +// Retrieve a byte slice of raw response dataa +// from a url string +func Fetch(url string) ([]byte, error) { + u, err := MakeUrl(url) + if err != nil { + return []byte(""), err + } + + timeOut := time.Duration(5) * time.Second + + if u.Host == "" || u.Port == "" { + return []byte(""), fmt.Errorf("Incomplete request url") + } + + addr := u.Host + ":" + u.Port + + conn, err := net.DialTimeout("tcp", addr, timeOut) + if err != nil { + return []byte(""), err + } + + send := u.Resource + "\n" + + _, err = conn.Write([]byte(send)) + if err != nil { + return []byte(""), err + } + + result, err := ioutil.ReadAll(conn) + if err != nil { + return []byte(""), err + } + + return result, err +} diff --git a/footbar.go b/footbar.go new file mode 100644 index 0000000..be1ea60 --- /dev/null +++ b/footbar.go @@ -0,0 +1,54 @@ +package main + +import ( + "fmt" +) + +//------------------------------------------------\\ +// + + + T Y P E S + + + \\ +//--------------------------------------------------\\ + +type Footbar struct { + PercentRead string + PageType string + Content string +} + + +//------------------------------------------------\\ +// + + + R E C E I V E R S + + + \\ +//--------------------------------------------------\\ + +func (f *Footbar) SetPercentRead(p int) { + f.PercentRead = fmt.Sprintf("%d%%", p) +} + +func (f *Footbar) SetPageType(t string) { + f.PageType = t +} + +func (f *Footbar) Draw() { + // TODO this will actually draw the bar + // without having to redraw everything else +} + +func (f *Footbar) Build(width string) string { + // TODO Build out header to specified width + f.Content = "" // This is a temp value to show intention + return "" +} + +func (f *Footbar) Render() string { + // TODO returns a full line + return "" +} + + +//------------------------------------------------\\ +// + + + F U N C T I O N S + + + \\ +//--------------------------------------------------\\ + +func MakeFootbar() Footbar { + return Footbar{"", "N/A", ""} +} + diff --git a/gopher/gopher.go b/gopher/gopher.go index 82bedea..5f488fe 100644 --- a/gopher/gopher.go +++ b/gopher/gopher.go @@ -88,7 +88,7 @@ func Visit(addr, openhttp string) (View, error) { if u.Gophertype == "h" { if res, tf := isWebLink(u.Resource); tf && strings.ToUpper(openhttp) == "TRUE" { - err := openBrowser(res) + err := OpenBrowser(res) if err != nil { return View{}, err } diff --git a/gopher/open_browser_darwin.go b/gopher/open_browser_darwin.go index edafe36..33db791 100644 --- a/gopher/open_browser_darwin.go +++ b/gopher/open_browser_darwin.go @@ -4,6 +4,6 @@ package gopher import "os/exec" -func openBrowser(url string) error { +func OpenBrowser(url string) error { return exec.Command("open", url).Start() } diff --git a/gopher/open_browser_linux.go b/gopher/open_browser_linux.go index 2ce35c9..bea56c3 100644 --- a/gopher/open_browser_linux.go +++ b/gopher/open_browser_linux.go @@ -4,6 +4,6 @@ package gopher import "os/exec" -func openBrowser(url string) error { +func OpenBrowser(url string) error { return exec.Command("xdg-open", url).Start() } diff --git a/gopher/open_browser_other.go b/gopher/open_browser_other.go index 1659ea3..f452ed4 100644 --- a/gopher/open_browser_other.go +++ b/gopher/open_browser_other.go @@ -6,6 +6,6 @@ package gopher import "fmt" -func openBrowser(url string) error { +func OpenBrowser(url string) error { return fmt.Errorf("Unsupported os for browser detection") } diff --git a/gopher/open_browser_windows.go b/gopher/open_browser_windows.go index b57c9d6..2912217 100644 --- a/gopher/open_browser_windows.go +++ b/gopher/open_browser_windows.go @@ -4,6 +4,6 @@ package gopher import "os/exec" -func openBrowser(url string) error { +func OpenBrowser(url string) error { return exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() } diff --git a/headbar.go b/headbar.go new file mode 100644 index 0000000..8aafc55 --- /dev/null +++ b/headbar.go @@ -0,0 +1,47 @@ +package main + + +//------------------------------------------------\\ +// + + + T Y P E S + + + \\ +//--------------------------------------------------\\ + +type Headbar struct { + title string + url string + content string +} + + +//------------------------------------------------\\ +// + + + R E C E I V E R S + + + \\ +//--------------------------------------------------\\ + +func (h *Headbar) SetUrl(u string) { + h.url = u +} + +func (h *Headbar) Build(width string) string { + // TODO Build out header to specified width + h.content = "" // This is a temp value to show intention + return "" +} + +func (h *Headbar) Draw() { + // TODO this will actually draw the bar + // without having to redraw everything else +} + +func (h *Headbar) Render() string { + // TODO returns the content value + return "" +} + + +//------------------------------------------------\\ +// + + + F U N C T I O N S + + + \\ +//--------------------------------------------------\\ + +func MakeHeadbar(title string) Headbar { + return Headbar{title, "", title} +} + diff --git a/main.go b/main.go index 015fe78..ff354bb 100644 --- a/main.go +++ b/main.go @@ -1,402 +1,143 @@ package main import ( - "fmt" "io/ioutil" "os" - "os/user" - "regexp" - "strconv" + // "strconv" "strings" - "tildegit.org/sloum/bombadillo/cmdparse" "tildegit.org/sloum/bombadillo/config" "tildegit.org/sloum/bombadillo/cui" - "tildegit.org/sloum/bombadillo/gopher" + // "tildegit.org/sloum/bombadillo/gopher" ) +var bombadillo *client var helplocation string = "gopher://colorfield.space:70/1/bombadillo-info" -var history gopher.History = gopher.MakeHistory() -var screen *cui.Screen -var userinfo, _ = user.Current() var settings config.Config -var options = map[string]string{ - "homeurl": "gopher://colorfield.space:70/1/bombadillo-info", - "savelocation": userinfo.HomeDir, - "searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs", - "openhttp": "false", - "httpbrowser": "lynx", -} -func saveFile(address, name string) error { - quickMessage("Saving file...", false) - url, err := gopher.MakeUrl(address) - if err != nil { - quickMessage("Saving file...", true) - return err - } +// func saveFileFromData(v gopher.View) error { + // quickMessage("Saving file...", false) + // urlsplit := strings.Split(v.Address.Full, "/") + // filename := urlsplit[len(urlsplit)-1] + // saveMsg := fmt.Sprintf("Saved file as %q", options["savelocation"]+filename) + // err := ioutil.WriteFile(options["savelocation"]+filename, []byte(strings.Join(v.Content, "")), 0644) + // if err != nil { + // quickMessage("Saving file...", true) + // return err + // } - data, err := gopher.Retrieve(url) - if err != nil { - quickMessage("Saving file...", true) - return err - } + // quickMessage(saveMsg, false) + // return nil +// } - err = ioutil.WriteFile(options["savelocation"]+name, data, 0644) - if err != nil { - quickMessage("Saving file...", true) - return err - } - quickMessage(fmt.Sprintf("Saved file to %s%s", options["savelocation"], name), false) - return nil -} -func saveFileFromData(v gopher.View) error { - quickMessage("Saving file...", false) - urlsplit := strings.Split(v.Address.Full, "/") - filename := urlsplit[len(urlsplit)-1] - saveMsg := fmt.Sprintf("Saved file as %q", options["savelocation"]+filename) - err := ioutil.WriteFile(options["savelocation"]+filename, []byte(strings.Join(v.Content, "")), 0644) - if err != nil { - quickMessage("Saving file...", true) - return err - } +// func doLinkCommand(action, target string) error { + // num, err := strconv.Atoi(target) + // if err != nil { + // return fmt.Errorf("Expected number, got %q", target) + // } - quickMessage(saveMsg, false) - return nil -} + // switch action { + // case "DELETE", "D": + // err := settings.Bookmarks.Del(num) + // if err != nil { + // return err + // } -func search(u string) error { - cui.MoveCursorTo(screen.Height-1, 0) - cui.Clear("line") - fmt.Print("Enter form input: ") - cui.MoveCursorTo(screen.Height-1, 17) + // screen.Windows[1].Content = settings.Bookmarks.List() + // err = saveConfig() + // if err != nil { + // return err + // } - entry, err := cui.GetLine() - if err != nil { - return err - } + // screen.ReflashScreen(false) + // return nil + // case "BOOKMARKS", "B": + // if num > len(settings.Bookmarks.Links)-1 { + // return fmt.Errorf("There is no bookmark with ID %d", num) + // } + // err := goToURL(settings.Bookmarks.Links[num]) + // return err + // } - quickMessage("Searching...", false) - searchurl := fmt.Sprintf("%s\t%s", u, entry) - sv, err := gopher.Visit(searchurl, options["openhttp"]) - if err != nil { - quickMessage("Searching...", true) - return err - } - history.Add(sv) - quickMessage("Searching...", true) - updateMainContent() - screen.Windows[0].Scrollposition = 0 - screen.ReflashScreen(true) - return nil -} + // return fmt.Errorf("This method has not been built") +// } -func routeInput(com *cmdparse.Command) error { - var err error - switch com.Type { - case cmdparse.SIMPLE: - err = simpleCommand(com.Action) - case cmdparse.GOURL: - err = goToURL(com.Target) - case cmdparse.GOLINK: - err = goToLink(com.Target) - case cmdparse.DO: - err = doCommand(com.Action, com.Value) - case cmdparse.DOLINK: - err = doLinkCommand(com.Action, com.Target) - case cmdparse.DOAS: - err = doCommandAs(com.Action, com.Value) - case cmdparse.DOLINKAS: - err = doLinkCommandAs(com.Action, com.Target, com.Value) - default: - return fmt.Errorf("Unknown command entry!") - } - return err -} +// func doCommand(action string, values []string) error { + // if length := len(values); length != 1 { + // return fmt.Errorf("Expected 1 argument, received %d", length) + // } -func toggleBookmarks() { - bookmarks := screen.Windows[1] - main := screen.Windows[0] - if bookmarks.Show { - bookmarks.Show = false - screen.Activewindow = 0 - main.Active = true - bookmarks.Active = false - } else { - bookmarks.Show = true - screen.Activewindow = 1 - main.Active = false - bookmarks.Active = true - } + // switch action { + // case "CHECK", "C": + // err := checkConfigValue(values[0]) + // if err != nil { + // return err + // } + // return nil + // } + // return fmt.Errorf("Unknown command structure") +// } - screen.ReflashScreen(false) -} +// func doLinkCommandAs(action, target string, values []string) error { + // num, err := strconv.Atoi(target) + // if err != nil { + // return fmt.Errorf("Expected number, got %q", target) + // } -func simpleCommand(a string) error { - a = strings.ToUpper(a) - switch a { - case "Q", "QUIT": - cui.Exit() - case "H", "HOME": - return goHome() - case "B", "BOOKMARKS": - toggleBookmarks() - case "SEARCH": - return search(options["searchengine"]) - case "HELP", "?": - return goToURL(helplocation) + // links := history.Collection[history.Position].Links + // if num >= len(links) { + // return fmt.Errorf("Invalid link id: %s", target) + // } - default: - return fmt.Errorf("Unknown action %q", a) - } - return nil -} + // switch action { + // case "ADD", "A": + // newBookmark := append([]string{links[num-1]}, values...) + // err := settings.Bookmarks.Add(newBookmark) + // if err != nil { + // return err + // } -func goToURL(u string) error { - if num, _ := regexp.MatchString(`^-?\d+.?\d*$`, u); num { - return goToLink(u) - } - quickMessage("Loading...", false) - v, err := gopher.Visit(u, options["openhttp"]) - if err != nil { - quickMessage("Loading...", true) - return err - } - quickMessage("Loading...", true) + // screen.Windows[1].Content = settings.Bookmarks.List() - if v.Address.Gophertype == "7" { - err := search(v.Address.Full) - if err != nil { - return err - } - } else if v.Address.IsBinary { - return saveFileFromData(v) - } else { - history.Add(v) - } - updateMainContent() - screen.Windows[0].Scrollposition = 0 - screen.ReflashScreen(true) - return nil -} + // err = saveConfig() + // if err != nil { + // return err + // } -func goToLink(l string) error { - if num, _ := regexp.MatchString(`^-?\d+$`, l); num && history.Length > 0 { - linkcount := len(history.Collection[history.Position].Links) - item, _ := strconv.Atoi(l) - if item <= linkcount && item > 0 { - linkurl := history.Collection[history.Position].Links[item-1] - quickMessage("Loading...", false) - v, err := gopher.Visit(linkurl, options["openhttp"]) - if err != nil { - quickMessage("Loading...", true) - return err - } - quickMessage("Loading...", true) + // screen.ReflashScreen(false) + // return nil + // case "WRITE", "W": + // return saveFile(links[num-1], strings.Join(values, " ")) + // } - if v.Address.Gophertype == "7" { - err := search(linkurl) - if err != nil { - return err - } - } else if v.Address.IsBinary { - return saveFileFromData(v) - } else { - history.Add(v) - } - } else { - return fmt.Errorf("Invalid link id: %s", l) - } - } else { - return fmt.Errorf("Invalid link id: %s", l) - } - updateMainContent() - screen.Windows[0].Scrollposition = 0 - screen.ReflashScreen(true) - return nil -} + // return fmt.Errorf("This method has not been built") +// } -func goHome() error { - if options["homeurl"] != "unset" { - return goToURL(options["homeurl"]) - } - return fmt.Errorf("No home address has been set") -} - -func doLinkCommand(action, target string) error { - num, err := strconv.Atoi(target) - if err != nil { - return fmt.Errorf("Expected number, got %q", target) - } - - switch action { - case "DELETE", "D": - err := settings.Bookmarks.Del(num) - if err != nil { - return err - } - - screen.Windows[1].Content = settings.Bookmarks.List() - err = saveConfig() - if err != nil { - return err - } - - screen.ReflashScreen(false) - return nil - case "BOOKMARKS", "B": - if num > len(settings.Bookmarks.Links)-1 { - return fmt.Errorf("There is no bookmark with ID %d", num) - } - err := goToURL(settings.Bookmarks.Links[num]) - return err - } - - return fmt.Errorf("This method has not been built") -} - -func doCommandAs(action string, values []string) error { - if len(values) < 2 { - return fmt.Errorf("%q", values) - } - - if values[0] == "." { - values[0] = history.Collection[history.Position].Address.Full - } - - switch action { - case "ADD", "A": - err := settings.Bookmarks.Add(values) - if err != nil { - return err - } - - screen.Windows[1].Content = settings.Bookmarks.List() - err = saveConfig() - if err != nil { - return err - } - - screen.ReflashScreen(false) - return nil - case "WRITE", "W": - return saveFile(values[0], strings.Join(values[1:], " ")) - case "SET", "S": - if _, ok := options[values[0]]; ok { - options[values[0]] = strings.Join(values[1:], " ") - return saveConfig() - } - return fmt.Errorf("Unable to set %s, it does not exist", values[0]) - } - return fmt.Errorf("Unknown command structure") -} - -func doCommand(action string, values []string) error { - if length := len(values); length != 1 { - return fmt.Errorf("Expected 1 argument, received %d", length) - } - - switch action { - case "CHECK", "C": - err := checkConfigValue(values[0]) - if err != nil { - return err - } - return nil - } - return fmt.Errorf("Unknown command structure") -} - -func checkConfigValue(setting string) error { - if val, ok := options[setting]; ok { - quickMessage(fmt.Sprintf("%s is set to: %q", setting, val), false) - return nil - - } - return fmt.Errorf("Unable to check %q, it does not exist", setting) -} - -func doLinkCommandAs(action, target string, values []string) error { - num, err := strconv.Atoi(target) - if err != nil { - return fmt.Errorf("Expected number, got %q", target) - } - - links := history.Collection[history.Position].Links - if num >= len(links) { - return fmt.Errorf("Invalid link id: %s", target) - } - - switch action { - case "ADD", "A": - newBookmark := append([]string{links[num-1]}, values...) - err := settings.Bookmarks.Add(newBookmark) - if err != nil { - return err - } - - screen.Windows[1].Content = settings.Bookmarks.List() - - err = saveConfig() - if err != nil { - return err - } - - screen.ReflashScreen(false) - return nil - case "WRITE", "W": - return saveFile(links[num-1], strings.Join(values, " ")) - } - - return fmt.Errorf("This method has not been built") -} - -func updateMainContent() { - screen.Windows[0].Content = history.Collection[history.Position].Content - screen.Bars[0].SetMessage(history.Collection[history.Position].Address.Full) -} - -func clearInput(incError bool) { - cui.MoveCursorTo(screen.Height-1, 0) - cui.Clear("line") - if incError { - cui.MoveCursorTo(screen.Height, 0) - cui.Clear("line") - } -} - -func quickMessage(msg string, clearMsg bool) { - xPos := screen.Width - 2 - len(msg) - if xPos < 2 { - xPos = 2 - } - cui.MoveCursorTo(screen.Height, xPos) - if clearMsg { - cui.Clear("right") - } else { - fmt.Print("\033[48;5;21m\033[38;5;15m", msg, "\033[0m") - } -} +// func updateMainContent() { + // screen.Windows[0].Content = history.Collection[history.Position].Content + // screen.Bars[0].SetMessage(history.Collection[history.Position].Address.Full) +// } func saveConfig() error { - bkmrks := settings.Bookmarks.IniDump() + bkmrks := bombadillo.BookMarks.IniDump() + // TODO opts becomes a string builder rather than concat opts := "\n[SETTINGS]\n" - for k, v := range options { + for k, v := range bombadillo.Options { opts += k opts += "=" opts += v opts += "\n" } - return ioutil.WriteFile(userinfo.HomeDir+"/.bombadillo.ini", []byte(bkmrks+opts), 0644) + return ioutil.WriteFile(bombadillo.Options["configlocation"] + "/.bombadillo.ini", []byte(bkmrks+opts), 0644) } func loadConfig() error { - file, err := os.Open(userinfo.HomeDir + "/.bombadillo.ini") + file, err := os.Open(bombadillo.Options["configlocation"] + "/.bombadillo.ini") if err != nil { err = saveConfig() if err != nil { @@ -407,72 +148,29 @@ func loadConfig() error { confparser := config.NewParser(file) settings, _ = confparser.Parse() file.Close() - screen.Windows[1].Content = settings.Bookmarks.List() for _, v := range settings.Settings { lowerkey := strings.ToLower(v.Key) - if _, ok := options[lowerkey]; ok { - options[lowerkey] = v.Value + if lowerkey == "configlocation" { + // The config should always be stored in home + // folder. Users cannot really edit this value. + // It is still stored in the ini and as a part + // of the options map. + continue + } + + if _, ok := bombadillo.Options[lowerkey]; ok { + bombadillo.Options[lowerkey] = v.Value } } return nil } -func toggleActiveWindow() { - if screen.Windows[1].Show { - if screen.Windows[0].Active { - screen.Windows[0].Active = false - screen.Windows[1].Active = true - screen.Activewindow = 1 - } else { - screen.Windows[0].Active = true - screen.Windows[1].Active = false - screen.Activewindow = 0 - } - screen.Windows[1].DrawWindow() - } -} - -func displayError(err error) { - cui.MoveCursorTo(screen.Height, 0) - fmt.Print("\033[41m\033[37m", err, "\033[0m") -} - func initClient() error { - history.Position = -1 - - screen = cui.NewScreen() + bombadillo = MakeClient(" ((( Bombadillo ))) ") cui.SetCharMode() - - screen.AddWindow(2, 1, screen.Height-2, screen.Width, false, false, true) - screen.Windows[0].Active = true - screen.AddMsgBar(1, " ((( Bombadillo ))) ", " A fun gopher client!", true) - bookmarksWidth := 40 - if screen.Width < 40 { - bookmarksWidth = screen.Width - } - screen.AddWindow(2, screen.Width-bookmarksWidth, screen.Height-2, screen.Width, false, true, false) - return loadConfig() -} - -func handleResize() { - oldh, oldw := screen.Height, screen.Width - screen.GetSize() - if screen.Height != oldh || screen.Width != oldw { - screen.Windows[0].Box.Row2 = screen.Height - 2 - screen.Windows[0].Box.Col2 = screen.Width - bookmarksWidth := 40 - if screen.Width < 40 { - bookmarksWidth = screen.Width - } - screen.Windows[1].Box.Row2 = screen.Height - 2 - screen.Windows[1].Box.Col1 = screen.Width - bookmarksWidth - screen.Windows[1].Box.Col2 = screen.Width - - screen.DrawAllWindows() - screen.DrawMsgBars() - screen.ClearCommandArea() - } + err := loadConfig() + return err } func main() { @@ -480,91 +178,27 @@ func main() { defer cui.Exit() err := initClient() if err != nil { - // if we can't initialize the window, - // we can't do anything! + // if we can't initialize we should bail out panic(err) } - mainWindow := screen.Windows[0] + // Start polling for terminal size changes + go bombadillo.GetSize() if len(os.Args) > 1 { - err = goToURL(os.Args[1]) + // If a url was passed, move it down the line + // Goroutine so keypresses can be made during + // page load + go bombadillo.Visit(os.Args[1]) } else { - err = goHome() - } - - if err != nil { - displayError(err) - } else { - updateMainContent() + // Otherwise, load the homeurl + // Goroutine so keypresses can be made during + // page load + go bombadillo.Visit(bombadillo.Options["homeurl"]) } + // Loop indefinitely on user input for { - c := cui.Getch() - - handleResize() - - switch c { - case 'j', 'J': - screen.Windows[screen.Activewindow].ScrollDown() - screen.ReflashScreen(false) - case 'k', 'K': - screen.Windows[screen.Activewindow].ScrollUp() - screen.ReflashScreen(false) - case 'q', 'Q': - cui.Exit() - case 'g': - screen.Windows[screen.Activewindow].ScrollHome() - screen.ReflashScreen(false) - case 'G': - screen.Windows[screen.Activewindow].ScrollEnd() - screen.ReflashScreen(false) - case 'd': - screen.Windows[screen.Activewindow].PageDown() - screen.ReflashScreen(false) - case 'u': - screen.Windows[screen.Activewindow].PageUp() - screen.ReflashScreen(false) - case 'b': - success := history.GoBack() - if success { - mainWindow.Scrollposition = 0 - updateMainContent() - screen.ReflashScreen(true) - } - case 'B': - toggleBookmarks() - case 'f', 'F': - success := history.GoForward() - if success { - mainWindow.Scrollposition = 0 - updateMainContent() - screen.ReflashScreen(true) - } - case '\t': - toggleActiveWindow() - case ':', ' ': - cui.MoveCursorTo(screen.Height-1, 0) - entry, err := cui.GetLine() - if err != nil { - displayError(err) - } - - // Clear entry line and error line - clearInput(true) - if entry == "" { - continue - } - parser := cmdparse.NewParser(strings.NewReader(entry)) - p, err := parser.Parse() - if err != nil { - displayError(err) - } else { - err := routeInput(p) - if err != nil { - displayError(err) - } - } - } + bombadillo.TakeControlInput() } } diff --git a/page.go b/page.go new file mode 100644 index 0000000..2e4b85e --- /dev/null +++ b/page.go @@ -0,0 +1,30 @@ +package main + + +//------------------------------------------------\\ +// + + + T Y P E S + + + \\ +//--------------------------------------------------\\ + +type Page struct { + WrappedContent []string + RawContent string + Links []string + Location Url + ScrollPosition int +} + +//------------------------------------------------\\ +// + + + R E C E I V E R S + + + \\ +//--------------------------------------------------\\ + + + +//------------------------------------------------\\ +// + + + F U N C T I O N S + + + \\ +//--------------------------------------------------\\ + +func MakePage(url Url, content string) Page { + p := Page{make([]string, 0), content, make([]string, 0), url, 0} + return p +} + diff --git a/pages.go b/pages.go new file mode 100644 index 0000000..5c844e8 --- /dev/null +++ b/pages.go @@ -0,0 +1,54 @@ +package main + +import ( + "fmt" +) + +//------------------------------------------------\\ +// + + + T Y P E S + + + \\ +//--------------------------------------------------\\ + +type Pages struct { + Position int + Length int + History [20]Page +} + + +//------------------------------------------------\\ +// + + + R E C E I V E R S + + + \\ +//--------------------------------------------------\\ + +func (p *Pages) NavigateHistory(qty int) error { + newPosition := p.Position + qty + if newPosition < 0 { + return fmt.Errorf("You are already at the beginning of history") + } else if newPosition > p.Length - 1 { + return fmt.Errorf("Your way is blocked by void, there is nothing forward") + } + + p.Position = newPosition + return nil +} + +func (p *Pages) Add(pg Page) error { + // TODO add the given page onto the pages struct + // handling truncation of the history as needed. + return fmt.Errorf("") +} + +func (p *Pages) Render() ([]string, error) { + // TODO grab the current page as wrappedContent + // May need to handle spacing at end of lines. + return []string{}, fmt.Errorf("") +} + +//------------------------------------------------\\ +// + + + F U N C T I O N S + + + \\ +//--------------------------------------------------\\ + +func MakePages() Pages { + return Pages{-1, 0, [20]Page{}} +} + + diff --git a/url.go b/url.go new file mode 100644 index 0000000..b6dfebd --- /dev/null +++ b/url.go @@ -0,0 +1,107 @@ +package main + +import ( + "fmt" + "regexp" + "strings" +) + +//------------------------------------------------\\ +// + + + T Y P E S + + + \\ +//--------------------------------------------------\\ + +type Url struct { + Scheme string + Host string + Port string + Resource string + Full string + Mime string + DownloadOnly bool +} + +//------------------------------------------------\\ +// + + + R E C E I V E R S + + + \\ +//--------------------------------------------------\\ + +// There are currently no receivers for the Url struct + + +//------------------------------------------------\\ +// + + + F U N C T I O N S + + + \\ +//--------------------------------------------------\\ + + +// MakeUrl is a Url constructor that takes in a string +// representation of a url and returns a Url struct and +// an error (or nil). +func MakeUrl(u string) (Url, error) { + var out Url + re := regexp.MustCompile(`^((?Pgopher|http|https|gemini):\/\/)?(?P[\w\-\.\d]+)(?::(?P\d+)?)?(?:/(?P[01345679gIhisp])?)?(?P.*)?$`) + match := re.FindStringSubmatch(u) + + if valid := re.MatchString(u); !valid { + return out, fmt.Errorf("Invalid url/unable to parse") + } + + for i, name := range re.SubexpNames() { + switch name { + case "scheme": + out.Scheme = match[i] + case "host": + out.Host = match[i] + case "port": + out.Port = match[i] + case "type": + out.Mime = match[i] + case "resource": + out.Resource = match[i] + } + } + + if out.Scheme == "" { + out.Scheme = "gopher" + } + + if out.Host == "" { + return out, fmt.Errorf("no host") + } + + if out.Scheme == "gopher" && out.Port == "" { + out.Port = "70" + } else if out.Scheme == "http" && out.Port == "" { + out.Port = "80" + } else if out.Scheme == "https" && out.Port == "" { + out.Port = "443" + } else if out.Scheme == "gemini" && out.Port == "" { + out.Port = "1965" + } + + if out.Scheme == "gopher" && out.Mime == "" { + out.Mime = "0" + } + + if out.Mime == "" && (out.Resource == "" || out.Resource == "/") && out.Scheme == "gopher" { + out.Mime = "1" + } + + if out.Mime == "7" && strings.Contains(out.Resource, "\t") { + out.Mime = "1" + } + + if out.Scheme == "gopher" { + switch out.Mime { + case "1", "0", "h", "7": + out.DownloadOnly = false + default: + out.DownloadOnly = true + } + } else { + out.Resource = fmt.Sprintf("%s%s", out.Mime, out.Resource) + out.Mime = "" + } + + out.Full = out.Scheme + "://" + out.Host + ":" + out.Port + "/" + out.Mime + out.Resource + + return out, nil +} From 84631a38da4fe79b673c1f0d1c4b14f290992685 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Tue, 10 Sep 2019 20:13:30 -0700 Subject: [PATCH 002/145] Adds telnet and http modules, updates visit method on client --- bookmarks.go | 62 +++++++++++++++++++++++++++------- client.go | 38 +++++++++++++-------- gopher/gopher.go | 22 ++++++------ gopher/open_browser_darwin.go | 9 ----- gopher/open_browser_linux.go | 9 ----- gopher/open_browser_other.go | 11 ------ gopher/open_browser_windows.go | 9 ----- http/open_browser_darwin.go | 13 +++++++ http/open_browser_linux.go | 13 +++++++ http/open_browser_other.go | 11 ++++++ http/open_browser_windows.go | 13 +++++++ page.go | 4 +-- telnet/telnet.go | 24 +++++++++++++ 13 files changed, 160 insertions(+), 78 deletions(-) delete mode 100644 gopher/open_browser_darwin.go delete mode 100644 gopher/open_browser_linux.go delete mode 100644 gopher/open_browser_other.go delete mode 100644 gopher/open_browser_windows.go create mode 100644 http/open_browser_darwin.go create mode 100644 http/open_browser_linux.go create mode 100644 http/open_browser_other.go create mode 100644 http/open_browser_windows.go create mode 100644 telnet/telnet.go diff --git a/bookmarks.go b/bookmarks.go index 3b044fd..a4c0c84 100644 --- a/bookmarks.go +++ b/bookmarks.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "strings" ) //------------------------------------------------\\ @@ -21,14 +22,24 @@ type Bookmarks struct { // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ -func (b *Bookmarks) Add([]string) error { - // TODO add a bookmark - return fmt.Errorf("") +func (b *Bookmarks) Add(v []string) (string, error) { + if len(v) < 2 { + return "", fmt.Errorf("Received %d arguments, expected 2+", len(v)) + } + b.Titles = append(b.Titles, strings.Join(v[1:], " ")) + b.Links = append(b.Links, v[0]) + b.Length = len(b.Titles) + return "Bookmark added successfully", nil } -func (b *Bookmarks) Delete(int) error { - // TODO delete a bookmark - return fmt.Errorf("") +func (b *Bookmarks) Delete(i int) (string, error) { + if i < len(b.Titles) && len(b.Titles) == len(b.Links) { + b.Titles = append(b.Titles[:i], b.Titles[i+1:]...) + b.Links = append(b.Links[:i], b.Links[i+1:]...) + b.Length = len(b.Titles) + return "Bookmark deleted successfully", nil + } + return "", fmt.Errorf("Bookmark %d does not exist", i) } func (b *Bookmarks) ToggleOpen() { @@ -46,17 +57,42 @@ func (b *Bookmarks) ToggleFocused() { } } -func (b *Bookmarks) IniDump() string { - // TODO create dump of values for INI file - return "" +func (b Bookmarks) IniDump() string { + if len(b.Titles) < 0 { + return "" + } + out := "[BOOKMARKS]\n" + for i := 0; i < len(b.Titles); i++ { + out += b.Titles[i] + out += "=" + out += b.Links[i] + out += "\n" + } + return out } -func (b *Bookmarks) Render() ([]string, error) { - // TODO grab all of the bookmarks as a fixed - // width string including border and spacing - return []string{}, fmt.Errorf("") +// Get a list, including link nums, of bookmarks +// as a string slice +func (b Bookmarks) List() []string { + var out []string + for i, t := range b.Titles { + out = append(out, fmt.Sprintf("[%d] %s", i, t)) + } + return out } +func (b Bookmarks) Render() ([]string, error) { + // TODO Use b.List() to get the necessary + // text and add on the correct border for + // rendering the focus. Use sprintf, left + // aligned: "| %-36.36s |" of the like. + return []string{}, nil +} + +// TODO handle scrolling of the bookmarks list +// either here widh a scroll up/down or in the client +// code for scroll + //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ diff --git a/client.go b/client.go index 8c2bdc0..bd4719e 100644 --- a/client.go +++ b/client.go @@ -14,7 +14,10 @@ import ( "tildegit.org/sloum/bombadillo/cmdparse" "tildegit.org/sloum/bombadillo/cui" - "tildegit.org/sloum/bombadillo/gopher" + // "tildegit.org/sloum/bombadillo/gemini" + // "tildegit.org/sloum/bombadillo/gopher" + "tildegit.org/sloum/bombadillo/http" + "tildegit.org/sloum/bombadillo/telnet" ) //------------------------------------------------\\ @@ -231,11 +234,14 @@ func (c *client) doCommandAs(action string, values []string) { switch action { case "ADD", "A": - err := c.BookMarks.Add(values) + msg, err := c.BookMarks.Add(values) if err != nil { c.SetMessage(err.Error(), true) c.DrawMessage() return + } else { + c.SetMessage(msg, false) + c.DrawMessage() } err = saveConfig() @@ -342,15 +348,7 @@ func (c *client) search() { escapedEntry := entry go c.Visit(fmt.Sprintf("%s?%s",u.Full,escapedEntry)) case "http", "https": - c.SetMessage("Attempting to open in web browser", false) - c.DrawMessage() - err := gopher.OpenBrowser(u.Full) - if err != nil { - c.SetMessage(err.Error(), true) - } else { - c.SetMessage("Opened in web browser", false) - } - c.DrawMessage() + c.Visit(u.Full) default: c.SetMessage(fmt.Sprintf("%q is not a supported protocol", u.Scheme), true) c.DrawMessage() @@ -463,19 +461,31 @@ func (c *client) Visit(url string) { // TODO send over to gopher request case "gemini": // TODO send over to gemini request + case "telnet": + c.SetMessage("Attempting to start telnet session", false) + c.DrawMessage() + msg, err := telnet.StartSession(u.Host, u.Port) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + } else { + c.SetMessage(msg, true) + c.DrawMessage() + } + c.Draw() case "http", "https": c.SetMessage("Attempting to open in web browser", false) c.DrawMessage() if strings.ToUpper(c.Options["openhttp"]) == "TRUE" { - err := gopher.OpenBrowser(u.Full) + msg, err := http.OpenInBrowser(u.Full) if err != nil { c.SetMessage(err.Error(), true) } else { - c.SetMessage("Opened in web browser", false) + c.SetMessage(msg, false) } c.DrawMessage() } else { - c.SetMessage("'openhttp' is not set to true, aborting opening web link", false) + c.SetMessage("'openhttp' is not set to true, cannot open web link", false) c.DrawMessage() } default: diff --git a/gopher/gopher.go b/gopher/gopher.go index 5f488fe..d2c97a4 100644 --- a/gopher/gopher.go +++ b/gopher/gopher.go @@ -5,7 +5,7 @@ package gopher import ( "errors" - "fmt" + // "fmt" "io/ioutil" "net" "strings" @@ -86,16 +86,16 @@ func Visit(addr, openhttp string) (View, error) { return View{}, err } - if u.Gophertype == "h" { - if res, tf := isWebLink(u.Resource); tf && strings.ToUpper(openhttp) == "TRUE" { - err := OpenBrowser(res) - if err != nil { - return View{}, err - } - - return View{}, fmt.Errorf("") - } - } + // if u.Gophertype == "h" { + // if res, tf := isWebLink(u.Resource); tf && strings.ToUpper(openhttp) == "TRUE" { + // err := OpenBrowser(res) + // if err != nil { + // return View{}, err + // } +// + // return View{}, fmt.Errorf("") + // } + // } text, err := Retrieve(u) if err != nil { diff --git a/gopher/open_browser_darwin.go b/gopher/open_browser_darwin.go deleted file mode 100644 index 33db791..0000000 --- a/gopher/open_browser_darwin.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build darwin - -package gopher - -import "os/exec" - -func OpenBrowser(url string) error { - return exec.Command("open", url).Start() -} diff --git a/gopher/open_browser_linux.go b/gopher/open_browser_linux.go deleted file mode 100644 index bea56c3..0000000 --- a/gopher/open_browser_linux.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build linux - -package gopher - -import "os/exec" - -func OpenBrowser(url string) error { - return exec.Command("xdg-open", url).Start() -} diff --git a/gopher/open_browser_other.go b/gopher/open_browser_other.go deleted file mode 100644 index f452ed4..0000000 --- a/gopher/open_browser_other.go +++ /dev/null @@ -1,11 +0,0 @@ -// +build !linux -// +build !darwin -// +build !windows - -package gopher - -import "fmt" - -func OpenBrowser(url string) error { - return fmt.Errorf("Unsupported os for browser detection") -} diff --git a/gopher/open_browser_windows.go b/gopher/open_browser_windows.go deleted file mode 100644 index 2912217..0000000 --- a/gopher/open_browser_windows.go +++ /dev/null @@ -1,9 +0,0 @@ -// +build windows - -package gopher - -import "os/exec" - -func OpenBrowser(url string) error { - return exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() -} diff --git a/http/open_browser_darwin.go b/http/open_browser_darwin.go new file mode 100644 index 0000000..dd7da7a --- /dev/null +++ b/http/open_browser_darwin.go @@ -0,0 +1,13 @@ +// +build darwin + +package http + +import "os/exec" + +func OpenInBrowser(url string) (string, error) { + err := exec.Command("open", url).Start() + if err != nil { + return "", err + } + return "Opened in system default web browser", nil +} diff --git a/http/open_browser_linux.go b/http/open_browser_linux.go new file mode 100644 index 0000000..dc99845 --- /dev/null +++ b/http/open_browser_linux.go @@ -0,0 +1,13 @@ +// +build linux + +package http + +import "os/exec" + +func OpenInBrowser(url string) (string, error) { + err := exec.Command("xdg-open", url).Start() + if err != nil { + return "", err + } + return "Opened in system default web browser", nil +} diff --git a/http/open_browser_other.go b/http/open_browser_other.go new file mode 100644 index 0000000..c6e5342 --- /dev/null +++ b/http/open_browser_other.go @@ -0,0 +1,11 @@ +// +build !linux +// +build !darwin +// +build !windows + +package http + +import "fmt" + +func OpenInBrowser(url string) (string, error) { + return "", fmt.Errorf("Unsupported os for browser detection") +} diff --git a/http/open_browser_windows.go b/http/open_browser_windows.go new file mode 100644 index 0000000..0ddf6c7 --- /dev/null +++ b/http/open_browser_windows.go @@ -0,0 +1,13 @@ +// +build windows + +package http + +import "os/exec" + +func OpenInBrowser(url string) (string, error) { + err := exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start() + if err != nil { + return "", err + } + return "Opened in system default web browser", nil +} diff --git a/page.go b/page.go index 2e4b85e..9fa0a0e 100644 --- a/page.go +++ b/page.go @@ -6,7 +6,7 @@ package main //--------------------------------------------------\\ type Page struct { - WrappedContent []string + WrappedContent string RawContent string Links []string Location Url @@ -24,7 +24,7 @@ type Page struct { //--------------------------------------------------\\ func MakePage(url Url, content string) Page { - p := Page{make([]string, 0), content, make([]string, 0), url, 0} + p := Page{"", content, make([]string, 0), url, 0} return p } diff --git a/telnet/telnet.go b/telnet/telnet.go new file mode 100644 index 0000000..609f13d --- /dev/null +++ b/telnet/telnet.go @@ -0,0 +1,24 @@ +package telnet + +import ( + "fmt" + "os" + "os/exec" +) + +func StartSession(host string, port string) (string, error) { + // Case for telnet links + c := exec.Command("telnet", host, port) + c.Stdin = os.Stdin + c.Stdout = os.Stdout + c.Stderr = os.Stderr + // Clear the screen and position the cursor at the top left + fmt.Print("\033[2J\033[0;0H") + err := c.Run() + if err != nil { + return "", fmt.Errorf("Telnet error response: %s", err.Error()) + } + + return "Telnet session terminated", nil +} + From a6d1f45be871df3cfd3cc76b1418324f8fef7727 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Tue, 10 Sep 2019 20:23:44 -0700 Subject: [PATCH 003/145] Added clarifying comments --- client.go | 2 ++ cui/cui.go | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/client.go b/client.go index bd4719e..4773435 100644 --- a/client.go +++ b/client.go @@ -449,6 +449,8 @@ func (c *client) goToLink(l string) { } func (c *client) Visit(url string) { + // TODO both gemini and gopher should return a string + // The wrap lines function in cui needs to be rewritten u, err := MakeUrl(url) if err != nil { c.SetMessage(err.Error(), true) diff --git a/cui/cui.go b/cui/cui.go index a784ce7..b00e07e 100644 --- a/cui/cui.go +++ b/cui/cui.go @@ -85,6 +85,12 @@ func Clear(dir string) { // than the specified console width, splitting them over two lines. returns the // amended document content as a slice. func wrapLines(s []string, consolewidth int) []string { + // TODO redo this so that it returns a string and can hard and + // soft wrap. It will use parsing to go char by char. CUI should + // set tabs to 4 on screen init. Multispace chars should be detected + // tab spacing should be detected using % to see where the next tab stop + // is. Use a counter as building the sub buffer. len returns num of bytes + // be sure to get num of chars instead: len([]rune("a")). indent := " " //11 spaces out := []string{} for _, ln := range s { From b7d7d021ed6d69973ade395cec436b957aa44963 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Tue, 10 Sep 2019 22:30:29 -0700 Subject: [PATCH 004/145] Begun work on gopher module --- gopher/gopher.go | 121 ++++++++++++++++++++++++++++++----------------- 1 file changed, 77 insertions(+), 44 deletions(-) diff --git a/gopher/gopher.go b/gopher/gopher.go index d2c97a4..d32dc70 100644 --- a/gopher/gopher.go +++ b/gopher/gopher.go @@ -5,7 +5,7 @@ package gopher import ( "errors" - // "fmt" + "fmt" "io/ioutil" "net" "strings" @@ -21,17 +21,21 @@ import ( var types = map[string]string{ "0": "TXT", "1": "MAP", - "h": "HTM", "3": "ERR", "4": "BIN", "5": "DOS", - "s": "SND", - "g": "GIF", - "I": "IMG", - "9": "BIN", - "7": "FTS", "6": "UUE", + "7": "FTS", + "8": "TEL", + "9": "BIN", + "g": "GIF", + "G": "GEM", + "h": "HTM", + "I": "IMG", "p": "PNG", + "s": "SND", + "S": "SSH", + "T": "TEL", } //------------------------------------------------\\ @@ -43,25 +47,22 @@ var types = map[string]string{ // available to use directly, but in most implementations // using the "Visit" receiver of the History struct will // be better. -func Retrieve(u Url) ([]byte, error) { +func Retrieve(host, port, resource string) ([]byte, error) { nullRes := make([]byte, 0) timeOut := time.Duration(5) * time.Second - if u.Host == "" || u.Port == "" { + if host == "" || port == "" { return nullRes, errors.New("Incomplete request url") } - addr := u.Host + ":" + u.Port + addr := host + ":" + port conn, err := net.DialTimeout("tcp", addr, timeOut) if err != nil { return nullRes, err } - send := u.Resource + "\n" - if u.Scheme == "http" || u.Scheme == "https" { - send = u.Gophertype - } + send := resource + "\n" _, err = conn.Write([]byte(send)) if err != nil { @@ -73,43 +74,27 @@ func Retrieve(u Url) ([]byte, error) { return nullRes, err } - return result, err + return result, nil } -// Visit is a high level combination of a few different -// types that makes it easy to create a Url, make a request -// to that Url, and add the response and Url to a View. -// Returns a copy of the view and an error (or nil). -func Visit(addr, openhttp string) (View, error) { - u, err := MakeUrl(addr) +// Visit handles the making of the request, parsing of maps, and returning +// the correct information to the client +func Visit(gophertype, host, port, resource string) (string, []string, error) { + resp, err := Retrieve(host, port, resource) + text := string(resp) + links := []string{} + if err != nil { - return View{}, err + return "", []string{}, err + } else if IsDownloadOnly(gophertype) { + return text, []string{}, nil } - // if u.Gophertype == "h" { - // if res, tf := isWebLink(u.Resource); tf && strings.ToUpper(openhttp) == "TRUE" { - // err := OpenBrowser(res) - // if err != nil { - // return View{}, err - // } -// - // return View{}, fmt.Errorf("") - // } - // } - - text, err := Retrieve(u) - if err != nil { - return View{}, err + if gophertype == "1" { + text, links = parseMap(text) } - var pageContent []string - if u.IsBinary && u.Gophertype != "7" { - pageContent = []string{string(text)} - } else { - pageContent = strings.Split(string(text), "\n") - } - - return MakeView(u, pageContent), nil + return text, links, nil } func getType(t string) string { @@ -127,3 +112,51 @@ func isWebLink(resource string) (string, bool) { } return "", false } + +// TODO Make sure when parsing maps that links have the correct +// protocol rather than 'gopher', where applicable (telnet, gemini, etc). +func parseMap(text string) (string, []string) { + splitContent := strings.Split(text, "\n") + links := make([]string, 0, 10) + + for i, e := range splitContent { + e = strings.Trim(e, "\r\n") + if e == "." { + splitContent[i] = "" + continue + } + + line := strings.Split(e, "\t") + var title string + // TODO REFACTOR LINE == HERE + // - - - - - - - - - - - - - - + if len(line[0]) > 1 { + title = line[0][1:] + } else { + title = "" + } + if len(line) > 1 && len(line[0]) > 0 && string(line[0][0]) == "i" { + splitContent[i] = " " + string(title) + } else if len(line) >= 4 { + fulllink := fmt.Sprintf("%s://%s:%s/%s%s", "protocol" ,line[2], line[3], string(line[0][0]), line[1]) + links = append(links, fulllink) + linktext := fmt.Sprintf("(%s) %2d %s", getType(string(line[0][0])), len(links), title) + splitContent[i] = linktext + } + } + return "", links +} + +// Returns false for all text formats (including html +// even though it may link out. Things like telnet +// should never make it into the retrieve call for +// this module, having been handled in the client +// based on their protocol. +func IsDownloadOnly(gophertype string) bool { + switch gophertype { + case "0", "1", "3", "7", "h": + return false + default: + return true + } +} From bccca61ec223a6b1cac875e9a634b863575fa420 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Wed, 11 Sep 2019 22:53:36 -0700 Subject: [PATCH 005/145] Some level of screen draw now works --- bookmarks.go | 49 +++++++++++++++++--- client.go | 51 ++++++++++++++++++--- config/parser.go | 12 ++--- cui/cui.go | 4 +- footbar.go | 18 ++------ gopher/bookmark.go | 65 -------------------------- gopher/gopher.go | 42 +++++++++++++---- gopher/history.go | 112 --------------------------------------------- gopher/url.go | 94 ------------------------------------- gopher/view.go | 83 --------------------------------- headbar.go | 18 +++----- main.go | 8 ++-- page.go | 60 ++++++++++++++++++++++-- pages.go | 31 +++++++++---- url.go | 4 +- 15 files changed, 224 insertions(+), 427 deletions(-) delete mode 100644 gopher/bookmark.go delete mode 100644 gopher/history.go delete mode 100644 gopher/url.go delete mode 100644 gopher/view.go diff --git a/bookmarks.go b/bookmarks.go index a4c0c84..503e648 100644 --- a/bookmarks.go +++ b/bookmarks.go @@ -3,6 +3,8 @@ package main import ( "fmt" "strings" + + "tildegit.org/sloum/bombadillo/cui" ) //------------------------------------------------\\ @@ -81,16 +83,49 @@ func (b Bookmarks) List() []string { return out } -func (b Bookmarks) Render() ([]string, error) { - // TODO Use b.List() to get the necessary - // text and add on the correct border for - // rendering the focus. Use sprintf, left - // aligned: "| %-36.36s |" of the like. - return []string{}, nil +func (b Bookmarks) Render(termwidth, termheight int) []string { + width := 40 + termheight -= 3 + var wall, ceil, tr, tl, br, bl string + if termwidth < 40 { + width = termwidth + } + if b.IsFocused { + wall = cui.Shapes["awall"] + ceil = cui.Shapes["aceiling"] + tr = cui.Shapes["atr"] + br = cui.Shapes["abr"] + tl = cui.Shapes["atl"] + bl = cui.Shapes["abl"] + } else { + wall = cui.Shapes["wall"] + ceil = cui.Shapes["ceiling"] + tr = cui.Shapes["tr"] + br = cui.Shapes["br"] + tl = cui.Shapes["tl"] + bl = cui.Shapes["bl"] + } + + out := make([]string, 5) + top := fmt.Sprintf("%s%s%s", tl, strings.Repeat(ceil, width-2), tr) + out = append(out, top) + marks := b.List() + contentWidth := termwidth - 2 + for i := 0; i < termheight - 2; i++ { + if i + b.Position >= b.Length { + out = append(out, fmt.Sprintf("%s%-*.*s%s", wall, contentWidth, contentWidth, "", wall )) + } else { + out = append(out, fmt.Sprintf("%s%-*.*s%s", wall, contentWidth, contentWidth, marks[i + b.Position], wall )) + } + } + + bottom := fmt.Sprintf("%s%s%s", bl, strings.Repeat(ceil, width-2), br) + out = append(out, bottom) + return out } // TODO handle scrolling of the bookmarks list -// either here widh a scroll up/down or in the client +// either here with a scroll up/down or in the client // code for scroll diff --git a/client.go b/client.go index 4773435..f326fbc 100644 --- a/client.go +++ b/client.go @@ -15,7 +15,7 @@ import ( "tildegit.org/sloum/bombadillo/cmdparse" "tildegit.org/sloum/bombadillo/cui" // "tildegit.org/sloum/bombadillo/gemini" - // "tildegit.org/sloum/bombadillo/gopher" + "tildegit.org/sloum/bombadillo/gopher" "tildegit.org/sloum/bombadillo/http" "tildegit.org/sloum/bombadillo/telnet" ) @@ -68,10 +68,30 @@ func (c *client) GetSize() { } func (c *client) Draw() { - // TODO build this out. - // It should call all of the renders - // and add them to the a string buffer - // It should then print the buffer + var screen strings.Builder + screen.Grow(c.Height * c.Width) + screen.WriteString(c.TopBar.Render(c.Width, "This is a test")) + screen.WriteString("\n") + pageContent := c.PageState.Render(c.Height) + if c.BookMarks.IsOpen { + bm := c.BookMarks.Render(c.Width, c.Height) + bmWidth := len([]rune(bm[0])) + for i, ln := range pageContent { + screen.WriteString(ln[:len(ln) - bmWidth]) + screen.WriteString(bm[i]) + screen.WriteString("\n") + } + } else { + for _, ln := range pageContent { + screen.WriteString(ln) + screen.WriteString("\n") + } + } + screen.WriteString("\n") // for the input line + screen.WriteString(c.FootBar.Render(c.Width)) + cui.Clear("screen") + cui.MoveCursorTo(0,0) + fmt.Print(screen.String()) } func (c *client) TakeControlInput() { @@ -131,6 +151,7 @@ func (c *client) TakeControlInput() { // Process a command c.ClearMessage() c.ClearMessageLine() + cui.MoveCursorTo(c.Height-2, 0) entry, err := cui.GetLine() c.ClearMessageLine() if err != nil { @@ -460,9 +481,26 @@ func (c *client) Visit(url string) { switch u.Scheme { case "gopher": - // TODO send over to gopher request + u, err := MakeUrl(url) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + content, links, err := gopher.Visit(u.Mime, u.Host, u.Port, u.Resource) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + pg := MakePage(u, content, links) + pg.WrapContent(c.Width) + c.PageState.Add(pg) + c.Draw() case "gemini": // TODO send over to gemini request + c.SetMessage("Gemini is not currently supported", false) + c.DrawMessage() case "telnet": c.SetMessage("Attempting to start telnet session", false) c.DrawMessage() @@ -512,7 +550,6 @@ func MakeClient(name string) *client { "configlocation": userinfo.HomeDir, } c := client{0, 0, options, "", MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar()} - c.GetSize() return &c } diff --git a/config/parser.go b/config/parser.go index 4661ac6..038c889 100644 --- a/config/parser.go +++ b/config/parser.go @@ -4,7 +4,6 @@ import ( "fmt" "io" "strings" - "tildegit.org/sloum/bombadillo/gopher" ) //------------------------------------------------\\ @@ -21,7 +20,10 @@ type Parser struct { } type Config struct { - Bookmarks gopher.Bookmarks + // Bookmarks gopher.Bookmarks + Bookmarks struct { + Titles, Links []string + } Colors []KeyValue Settings []KeyValue } @@ -86,10 +88,8 @@ func (p *Parser) Parse() (Config, error) { } switch section { case "BOOKMARKS": - err := c.Bookmarks.Add([]string{keyval.Value, keyval.Key}) - if err != nil { - return c, err - } + c.Bookmarks.Titles = append(c.Bookmarks.Titles, keyval.Value) + c.Bookmarks.Links = append(c.Bookmarks.Links, keyval.Key) case "COLORS": c.Colors = append(c.Colors, keyval) case "SETTINGS": diff --git a/cui/cui.go b/cui/cui.go index b00e07e..5cb5d79 100644 --- a/cui/cui.go +++ b/cui/cui.go @@ -9,7 +9,7 @@ import ( "strings" ) -var shapes = map[string]string{ +var Shapes = map[string]string{ "wall": "╵", "ceiling": "╴", "tl": "┌", @@ -25,7 +25,7 @@ var shapes = map[string]string{ } func drawShape(shape string) { - if val, ok := shapes[shape]; ok { + if val, ok := Shapes[shape]; ok { fmt.Printf("%s", val) } else { fmt.Print("x") diff --git a/footbar.go b/footbar.go index be1ea60..dab20bf 100644 --- a/footbar.go +++ b/footbar.go @@ -9,9 +9,8 @@ import ( //--------------------------------------------------\\ type Footbar struct { - PercentRead string + PercentRead int PageType string - Content string } @@ -20,7 +19,7 @@ type Footbar struct { //--------------------------------------------------\\ func (f *Footbar) SetPercentRead(p int) { - f.PercentRead = fmt.Sprintf("%d%%", p) + f.PercentRead = p } func (f *Footbar) SetPageType(t string) { @@ -32,15 +31,8 @@ func (f *Footbar) Draw() { // without having to redraw everything else } -func (f *Footbar) Build(width string) string { - // TODO Build out header to specified width - f.Content = "" // This is a temp value to show intention - return "" -} - -func (f *Footbar) Render() string { - // TODO returns a full line - return "" +func (f *Footbar) Render(termWidth int) string { + return fmt.Sprintf("\033[7m%-*.*s\033[0m", termWidth, termWidth, "") } @@ -49,6 +41,6 @@ func (f *Footbar) Render() string { //--------------------------------------------------\\ func MakeFootbar() Footbar { - return Footbar{"", "N/A", ""} + return Footbar{100, "N/A"} } diff --git a/gopher/bookmark.go b/gopher/bookmark.go deleted file mode 100644 index 24ac80f..0000000 --- a/gopher/bookmark.go +++ /dev/null @@ -1,65 +0,0 @@ -package gopher - -import ( - "fmt" - "strings" -) - -//------------------------------------------------\\ -// + + + T Y P E S + + + \\ -//--------------------------------------------------\\ - -//Bookmarks is a holder for titles and links that -//can be retrieved by index -type Bookmarks struct { - Titles []string - Links []string -} - -//------------------------------------------------\\ -// + + + R E C E I V E R S + + + \\ -//--------------------------------------------------\\ - -// Add adds a new title and link combination to the bookmarks -// struct. It takes as input a string slice in which the first -// element represents the link and all following items represent -// the title of the bookmark (they will be joined with spaces). -func (b *Bookmarks) Add(v []string) error { - if len(v) < 2 { - return fmt.Errorf("Received %d arguments, expected 2 or more", len(v)) - } - b.Titles = append(b.Titles, strings.Join(v[1:], " ")) - b.Links = append(b.Links, v[0]) - return nil -} - -func (b *Bookmarks) Del(i int) error { - if i < len(b.Titles) && i < len(b.Links) { - b.Titles = append(b.Titles[:i], b.Titles[i+1:]...) - b.Links = append(b.Links[:i], b.Links[i+1:]...) - return nil - } - return fmt.Errorf("Bookmark %d does not exist", i) -} - -func (b Bookmarks) List() []string { - var out []string - for i, t := range b.Titles { - out = append(out, fmt.Sprintf("[%d] %s", i, t)) - } - return out -} - -func (b Bookmarks) IniDump() string { - if len(b.Titles) < 0 { - return "" - } - out := "[BOOKMARKS]\n" - for i := 0; i < len(b.Titles); i++ { - out += b.Titles[i] - out += "=" - out += b.Links[i] - out += "\n" - } - return out -} diff --git a/gopher/gopher.go b/gopher/gopher.go index d32dc70..b990682 100644 --- a/gopher/gopher.go +++ b/gopher/gopher.go @@ -81,15 +81,18 @@ func Retrieve(host, port, resource string) ([]byte, error) { // the correct information to the client func Visit(gophertype, host, port, resource string) (string, []string, error) { resp, err := Retrieve(host, port, resource) + if err != nil { + return "", []string{}, err + } + text := string(resp) links := []string{} - if err != nil { - return "", []string{}, err - } else if IsDownloadOnly(gophertype) { + if IsDownloadOnly(gophertype) { return text, []string{}, nil } + if gophertype == "1" { text, links = parseMap(text) } @@ -113,8 +116,6 @@ func isWebLink(resource string) (string, bool) { return "", false } -// TODO Make sure when parsing maps that links have the correct -// protocol rather than 'gopher', where applicable (telnet, gemini, etc). func parseMap(text string) (string, []string) { splitContent := strings.Split(text, "\n") links := make([]string, 0, 10) @@ -128,23 +129,23 @@ func parseMap(text string) (string, []string) { line := strings.Split(e, "\t") var title string - // TODO REFACTOR LINE == HERE - // - - - - - - - - - - - - - - + if len(line[0]) > 1 { title = line[0][1:] } else { title = "" } + if len(line) > 1 && len(line[0]) > 0 && string(line[0][0]) == "i" { splitContent[i] = " " + string(title) } else if len(line) >= 4 { - fulllink := fmt.Sprintf("%s://%s:%s/%s%s", "protocol" ,line[2], line[3], string(line[0][0]), line[1]) - links = append(links, fulllink) + link := buildLink(line[2], line[3], string(line[0][0]), line[1]) + links = append(links, link) linktext := fmt.Sprintf("(%s) %2d %s", getType(string(line[0][0])), len(links), title) splitContent[i] = linktext } } - return "", links + return strings.Join(splitContent, "\n"), links } // Returns false for all text formats (including html @@ -160,3 +161,24 @@ func IsDownloadOnly(gophertype string) bool { return true } } + +func buildLink(host, port, gtype, resource string) string { + switch gtype { + case "8", "T": + return fmt.Sprintf("telnet://%s:%s", host, port) + case "G": + return fmt.Sprintf("gemini://%s:%s%s", host, port, resource) + case "h": + u, tf := isWebLink(resource) + if tf { + if len(u) > 4 && string(u[:5]) == "http" { + return u + } else { + return fmt.Sprintf("http://%s", u) + } + } + return fmt.Sprintf("gopher://%s:%s/h%s", host, port, resource) + default: + return fmt.Sprintf("gopher://%s:%s/%s%s", host, port, gtype, resource) + } +} diff --git a/gopher/history.go b/gopher/history.go deleted file mode 100644 index 5fdc439..0000000 --- a/gopher/history.go +++ /dev/null @@ -1,112 +0,0 @@ -package gopher - -import ( - "errors" - "fmt" -) - -//------------------------------------------------\\ -// + + + T Y P E S + + + \\ -//--------------------------------------------------\\ - -// The history struct represents the history of the browsing -// session. It contains the current history position, the -// length of the active history space (this can be different -// from the available capacity in the Collection), and a -// collection array containing View structs representing -// each page in the current history. In general usage this -// struct should be initialized via the MakeHistory function. -type History struct { - Position int - Length int - Collection [20]View -} - -//------------------------------------------------\\ -// + + + R E C E I V E R S + + + \\ -//--------------------------------------------------\\ - -// The "Add" receiver takes a view and adds it to -// the history struct that called it. "Add" returns -// nothing. "Add" will shift history down if the max -// history length would be exceeded, and will reset -// history length if something is added in the middle. -func (h *History) Add(v View) { - v.ParseMap() - if h.Position == h.Length-1 && h.Length < len(h.Collection) { - h.Collection[h.Length] = v - h.Length++ - h.Position++ - } else if h.Position == h.Length-1 && h.Length == 20 { - for x := 1; x < len(h.Collection); x++ { - h.Collection[x-1] = h.Collection[x] - } - h.Collection[len(h.Collection)-1] = v - } else { - h.Position += 1 - h.Length = h.Position + 1 - h.Collection[h.Position] = v - } -} - -// The "Get" receiver is called by a history struct -// and returns a View from the current position, will -// return an error if history is empty and there is -// nothing to get. -func (h History) Get() (*View, error) { - if h.Position < 0 { - return nil, errors.New("History is empty, cannot get item from empty history.") - } - - return &h.Collection[h.Position], nil -} - -// The "GoBack" receiver is called by a history struct. -// When called it decrements the current position and -// displays the content for the View in that position. -// If history is at position 0, no action is taken. -func (h *History) GoBack() bool { - if h.Position > 0 { - h.Position-- - return true - } - - fmt.Print("\a") - return false -} - -// The "GoForward" receiver is called by a history struct. -// When called it increments the current position and -// displays the content for the View in that position. -// If history is at position len - 1, no action is taken. -func (h *History) GoForward() bool { - if h.Position+1 < h.Length { - h.Position++ - return true - } - - fmt.Print("\a") - return false -} - -// The "DisplayCurrentView" receiver is called by a history -// struct. It calls the Display receiver for th view struct -// at the current history position. "DisplayCurrentView" does -// not return anything, and does nothing if position is less -// that 0. -func (h *History) DisplayCurrentView() { - h.Collection[h.Position].Display() -} - -//------------------------------------------------\\ -// + + + F U N C T I O N S + + + \\ -//--------------------------------------------------\\ - -// Constructor function for History struct. -// This is used to initialize history position -// as -1, which is needed. Returns a copy of -// initialized History struct (does NOT return -// a pointer to the struct). -func MakeHistory() History { - return History{-1, 0, [20]View{}} -} diff --git a/gopher/url.go b/gopher/url.go deleted file mode 100644 index c94f020..0000000 --- a/gopher/url.go +++ /dev/null @@ -1,94 +0,0 @@ -package gopher - -import ( - "errors" - "regexp" - "strings" -) - -//------------------------------------------------\\ -// + + + T Y P E S + + + \\ -//--------------------------------------------------\\ - -// The url struct represents a URL for the rest of the system. -// It includes component parts as well as a full URL string. -type Url struct { - Scheme string - Host string - Port string - Gophertype string - Resource string - Full string - IsBinary bool -} - -//------------------------------------------------\\ -// + + + F U N C T I O N S + + + \\ -//--------------------------------------------------\\ - -// MakeUrl is a Url constructor that takes in a string -// representation of a url and returns a Url struct and -// an error (or nil). -func MakeUrl(u string) (Url, error) { - var out Url - re := regexp.MustCompile(`^((?Pgopher|http|https|ftp|telnet):\/\/)?(?P[\w\-\.\d]+)(?::(?P\d+)?)?(?:/(?P[01345679gIhisp])?)?(?P.*)?$`) - match := re.FindStringSubmatch(u) - - if valid := re.MatchString(u); !valid { - return out, errors.New("Invalid URL or command character") - } - - for i, name := range re.SubexpNames() { - switch name { - case "scheme": - out.Scheme = match[i] - case "host": - out.Host = match[i] - case "port": - out.Port = match[i] - case "type": - out.Gophertype = match[i] - case "resource": - out.Resource = match[i] - } - } - - if out.Scheme == "" { - out.Scheme = "gopher" - } - - if out.Host == "" { - return out, errors.New("no host") - } - - if out.Scheme == "gopher" && out.Port == "" { - out.Port = "70" - } else if out.Scheme == "http" && out.Port == "" { - out.Port = "80" - } else if out.Scheme == "https" && out.Port == "" { - out.Port = "443" - } - - if out.Gophertype == "" && (out.Resource == "" || out.Resource == "/") { - out.Gophertype = "1" - } - - if out.Scheme == "gopher" && out.Gophertype == "" { - out.Gophertype = "0" - } - - if out.Gophertype == "7" && strings.Contains(out.Resource, "\t") { - out.Gophertype = "1" - } - - switch out.Gophertype { - case "1", "0", "h", "7": - out.IsBinary = false - default: - out.IsBinary = true - } - - out.Full = out.Scheme + "://" + out.Host + ":" + out.Port + "/" + out.Gophertype + out.Resource - - return out, nil -} diff --git a/gopher/view.go b/gopher/view.go deleted file mode 100644 index 813f4ca..0000000 --- a/gopher/view.go +++ /dev/null @@ -1,83 +0,0 @@ -package gopher - -import ( - "fmt" - "strings" -) - -//------------------------------------------------\\ -// + + + T Y P E S + + + \\ -//--------------------------------------------------\\ - -// View is a struct representing a gopher page. It contains -// the page content as a string slice, a list of link URLs -// as string slices, and the Url struct representing the page. -type View struct { - Content []string - Links []string - Address Url -} - -//------------------------------------------------\\ -// + + + R E C E I V E R S + + + \\ -//--------------------------------------------------\\ - -// ParseMap is called by a view struct to parse a gophermap. -// It checks if the view is for a gophermap. If not,it does -// nothing. If so, it parses the gophermap into comment lines -// and link lines. For link lines it adds a link to the links -// slice and changes the content value to just the printable -// string plus a gophertype indicator and a link number that -// relates to the link position in the links slice. This -// receiver does not return anything. -func (v *View) ParseMap() { - if v.Address.Gophertype == "1" || v.Address.Gophertype == "7" { - for i, e := range v.Content { - e = strings.Trim(e, "\r\n") - if e == "." { - v.Content[i] = " " - continue - } - - line := strings.Split(e, "\t") - var title string - if len(line[0]) > 1 { - title = line[0][1:] - } else { - title = "" - } - if len(line) > 1 && len(line[0]) > 0 && string(line[0][0]) == "i" { - v.Content[i] = " " + string(title) - } else if len(line) >= 4 { - fulllink := fmt.Sprintf("%s:%s/%s%s", line[2], line[3], string(line[0][0]), line[1]) - v.Links = append(v.Links, fulllink) - linktext := fmt.Sprintf("(%s) %2d %s", getType(string(line[0][0])), len(v.Links), title) - v.Content[i] = linktext - } - } - } -} - -// Display is called on a view struct to print the contents of the view. -// This receiver does not return anything. -func (v View) Display() { - fmt.Println() - for _, el := range v.Content { - fmt.Println(el) - } -} - -//------------------------------------------------\\ -// + + + F U N C T I O N S + + + \\ -//--------------------------------------------------\\ - -// MakeView creates and returns a new View struct from -// a Url and a string splice of content. This is used to -// initialize a View with a Url struct, links, and content. -// It takes a Url struct and a content []string and returns -// a View (NOT a pointer to a View). -func MakeView(url Url, content []string) View { - v := View{content, make([]string, 0), url} - v.ParseMap() - return v -} diff --git a/headbar.go b/headbar.go index 8aafc55..d467a43 100644 --- a/headbar.go +++ b/headbar.go @@ -1,5 +1,8 @@ package main +import ( + "fmt" +) //------------------------------------------------\\ // + + + T Y P E S + + + \\ @@ -7,8 +10,6 @@ package main type Headbar struct { title string - url string - content string } @@ -16,13 +17,8 @@ type Headbar struct { // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ -func (h *Headbar) SetUrl(u string) { - h.url = u -} - func (h *Headbar) Build(width string) string { // TODO Build out header to specified width - h.content = "" // This is a temp value to show intention return "" } @@ -31,9 +27,9 @@ func (h *Headbar) Draw() { // without having to redraw everything else } -func (h *Headbar) Render() string { - // TODO returns the content value - return "" +func (h *Headbar) Render(width int, message string) string { + maxMsgWidth := width - len([]rune(h.title)) + return fmt.Sprintf("\033[7m%s%-*.*s\033[0m", h.title, maxMsgWidth, maxMsgWidth, message) } @@ -42,6 +38,6 @@ func (h *Headbar) Render() string { //--------------------------------------------------\\ func MakeHeadbar(title string) Headbar { - return Headbar{title, "", title} + return Headbar{title} } diff --git a/main.go b/main.go index ff354bb..9f2e642 100644 --- a/main.go +++ b/main.go @@ -174,8 +174,8 @@ func initClient() error { } func main() { - cui.HandleAlternateScreen("smcup") - defer cui.Exit() + // cui.HandleAlternateScreen("smcup") + // defer cui.Exit() err := initClient() if err != nil { // if we can't initialize we should bail out @@ -189,12 +189,12 @@ func main() { // If a url was passed, move it down the line // Goroutine so keypresses can be made during // page load - go bombadillo.Visit(os.Args[1]) + bombadillo.Visit(os.Args[1]) } else { // Otherwise, load the homeurl // Goroutine so keypresses can be made during // page load - go bombadillo.Visit(bombadillo.Options["homeurl"]) + bombadillo.Visit(bombadillo.Options["homeurl"]) } // Loop indefinitely on user input diff --git a/page.go b/page.go index 9fa0a0e..e67124d 100644 --- a/page.go +++ b/page.go @@ -1,12 +1,16 @@ package main +import ( + "strings" + "bytes" +) //------------------------------------------------\\ // + + + T Y P E S + + + \\ //--------------------------------------------------\\ type Page struct { - WrappedContent string + WrappedContent []string RawContent string Links []string Location Url @@ -17,14 +21,64 @@ type Page struct { // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ +func (p *Page) ScrollPositionRange(termHeight int) (int, int) { + termHeight -= 3 + if len(p.WrappedContent) - p.ScrollPosition < termHeight { + p.ScrollPosition = len(p.WrappedContent) - termHeight + } + if p.ScrollPosition < 0 { + p.ScrollPosition = 0 + } + var end int + if len(p.WrappedContent) < termHeight { + end = len(p.WrappedContent) + } else { + end = p.ScrollPosition + termHeight + } + return p.ScrollPosition, end +} + +func (p *Page) WrapContent(width int) { + // TODO this is a temporary wrapping function + // in order to test. Rebuild it. + src := strings.Split(p.RawContent, "\n") + out := []string{} + for _, ln := range src { + if len([]rune(ln)) <= width { + out = append(out, ln) + } else { + words := strings.SplitAfter(ln, " ") + var subout bytes.Buffer + for i, wd := range words { + sublen := subout.Len() + wdlen := len([]rune(wd)) + if sublen+wdlen <= width { + subout.WriteString(wd) + if i == len(words)-1 { + out = append(out, subout.String()) + } + } else { + out = append(out, subout.String()) + subout.Reset() + subout.WriteString(wd) + if i == len(words)-1 { + out = append(out, subout.String()) + subout.Reset() + } + } + } + } + } + p.WrappedContent = out +} //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ -func MakePage(url Url, content string) Page { - p := Page{"", content, make([]string, 0), url, 0} +func MakePage(url Url, content string, links []string) Page { + p := Page{make([]string, 0), content, links, url, 0} return p } diff --git a/pages.go b/pages.go index 5c844e8..a4f12c3 100644 --- a/pages.go +++ b/pages.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "strings" ) //------------------------------------------------\\ @@ -31,16 +32,30 @@ func (p *Pages) NavigateHistory(qty int) error { return nil } -func (p *Pages) Add(pg Page) error { - // TODO add the given page onto the pages struct - // handling truncation of the history as needed. - return fmt.Errorf("") +func (p *Pages) Add(pg Page) { + if p.Position == p.Length - 1 && p.Length < len(p.History) { + p.History[p.Length] = pg + p.Length++ + p.Position++ + } else if p.Position == p.Length - 1 && p.Length == 20 { + for x := 1; x < len(p.History); x++ { + p.History[x-1] = p.History[x] + } + p.History[len(p.History)-1] = pg + } else { + p.Position += 1 + p.Length = p.Position + 1 + p.History[p.Position] = pg + } } -func (p *Pages) Render() ([]string, error) { - // TODO grab the current page as wrappedContent - // May need to handle spacing at end of lines. - return []string{}, fmt.Errorf("") +func (p *Pages) Render(termHeight int) []string { + if p.Length < 1 { + msg := "Welcome to Bombadillo,\nif this is your first time here\ntype:\n\n:help\n(and then press enter)" + return strings.Split(msg, "\n") + } + beg, end := p.History[p.Position].ScrollPositionRange(termHeight) + return p.History[p.Position].WrappedContent[beg:end] } //------------------------------------------------\\ diff --git a/url.go b/url.go index b6dfebd..58673fd 100644 --- a/url.go +++ b/url.go @@ -37,11 +37,11 @@ type Url struct { // an error (or nil). func MakeUrl(u string) (Url, error) { var out Url - re := regexp.MustCompile(`^((?Pgopher|http|https|gemini):\/\/)?(?P[\w\-\.\d]+)(?::(?P\d+)?)?(?:/(?P[01345679gIhisp])?)?(?P.*)?$`) + re := regexp.MustCompile(`^((?Pgopher|telnet|http|https|gemini):\/\/)?(?P[\w\-\.\d]+)(?::(?P\d+)?)?(?:/(?P[01345679gIhisp])?)?(?P.*)?$`) match := re.FindStringSubmatch(u) if valid := re.MatchString(u); !valid { - return out, fmt.Errorf("Invalid url/unable to parse") + return out, fmt.Errorf("Invalid url, unable to parse") } for i, name := range re.SubexpNames() { From 98e34576ca11e11865712f82ae99a1152899fdc8 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 12 Sep 2019 20:57:48 -0700 Subject: [PATCH 006/145] Worked out resizing and wrapping bugs. Now hard wraps, rather than soft. --- bookmarks.go | 4 +-- client.go | 72 +++++++++++++++++++++++++++++++++++++++++----------- headbar.go | 7 ++--- main.go | 8 ++++-- page.go | 45 +++++++++++++++----------------- pages.go | 30 +++++++++++++++++----- url.go | 2 +- 7 files changed, 114 insertions(+), 54 deletions(-) diff --git a/bookmarks.go b/bookmarks.go index 503e648..3e08eab 100644 --- a/bookmarks.go +++ b/bookmarks.go @@ -106,11 +106,11 @@ func (b Bookmarks) Render(termwidth, termheight int) []string { bl = cui.Shapes["bl"] } - out := make([]string, 5) + out := make([]string, 0, 5) top := fmt.Sprintf("%s%s%s", tl, strings.Repeat(ceil, width-2), tr) out = append(out, top) marks := b.List() - contentWidth := termwidth - 2 + contentWidth := width - 2 for i := 0; i < termheight - 2; i++ { if i + b.Position >= b.Length { out = append(out, fmt.Sprintf("%s%-*.*s%s", wall, contentWidth, contentWidth, "", wall )) diff --git a/client.go b/client.go index f326fbc..c59195b 100644 --- a/client.go +++ b/client.go @@ -59,32 +59,45 @@ func (c *client) GetSize() { c.Height = h c.Width = w + if redraw { c.Draw() } - time.Sleep(1 * time.Second) + time.Sleep(500 * time.Millisecond) } } func (c *client) Draw() { var screen strings.Builder screen.Grow(c.Height * c.Width) - screen.WriteString(c.TopBar.Render(c.Width, "This is a test")) + screen.WriteString(c.TopBar.Render(c.Width)) screen.WriteString("\n") - pageContent := c.PageState.Render(c.Height) + pageContent := c.PageState.Render(c.Height, c.Width) if c.BookMarks.IsOpen { bm := c.BookMarks.Render(c.Width, c.Height) - bmWidth := len([]rune(bm[0])) - for i, ln := range pageContent { - screen.WriteString(ln[:len(ln) - bmWidth]) + bmWidth := 40 + for i := 0; i < c.Height - 3; i++ { + if c.Width > bmWidth { + contentWidth := c.Width - bmWidth - 1 + if i < len(pageContent) - 1 { + screen.WriteString(fmt.Sprintf("%-*.*s", contentWidth, contentWidth, pageContent[i])) + } else { + screen.WriteString(fmt.Sprintf("%-*.*s", contentWidth, contentWidth, " ")) + } + } screen.WriteString(bm[i]) screen.WriteString("\n") } } else { - for _, ln := range pageContent { - screen.WriteString(ln) - screen.WriteString("\n") + for i := 0; i < c.Height - 3; i++ { + if i < len(pageContent) - 1 { + screen.WriteString(pageContent[i]) + screen.WriteString("\n") + } else { + screen.WriteString(fmt.Sprintf("%*s", c.Width, " ")) + screen.WriteString("\n") + } } } screen.WriteString("\n") // for the input line @@ -92,6 +105,7 @@ func (c *client) Draw() { cui.Clear("screen") cui.MoveCursorTo(0,0) fmt.Print(screen.String()) + c.DrawMessage() } func (c *client) TakeControlInput() { @@ -100,34 +114,49 @@ func (c *client) TakeControlInput() { switch input { case 'j', 'J': // scroll down one line + c.ClearMessage() + c.ClearMessageLine() c.Scroll(1) case 'k', 'K': // scroll up one line + c.ClearMessage() + c.ClearMessageLine() c.Scroll(-1) case 'q', 'Q': // quite bombadillo cui.Exit() case 'g': // scroll to top + c.ClearMessage() + c.ClearMessageLine() c.Scroll(-len(c.PageState.History[c.PageState.Position].WrappedContent)) case 'G': // scroll to bottom + c.ClearMessage() + c.ClearMessageLine() c.Scroll(len(c.PageState.History[c.PageState.Position].WrappedContent)) case 'd': // scroll down 75% + c.ClearMessage() + c.ClearMessageLine() distance := c.Height - c.Height / 4 c.Scroll(distance) case 'u': // scroll up 75% + c.ClearMessage() + c.ClearMessageLine() distance := c.Height - c.Height / 4 c.Scroll(-distance) case 'b': // go back + c.ClearMessage() + c.ClearMessageLine() err := c.PageState.NavigateHistory(-1) if err != nil { c.SetMessage(err.Error(), false) c.DrawMessage() } else { + c.SetHeaderUrl() c.Draw() } case 'B': @@ -136,11 +165,14 @@ func (c *client) TakeControlInput() { c.Draw() case 'f', 'F': // go forward + c.ClearMessage() + c.ClearMessageLine() err := c.PageState.NavigateHistory(1) if err != nil { c.SetMessage(err.Error(), false) c.DrawMessage() } else { + c.SetHeaderUrl() c.Draw() } case '\t': @@ -151,7 +183,6 @@ func (c *client) TakeControlInput() { // Process a command c.ClearMessage() c.ClearMessageLine() - cui.MoveCursorTo(c.Height-2, 0) entry, err := cui.GetLine() c.ClearMessageLine() if err != nil { @@ -378,13 +409,13 @@ func (c *client) search() { func (c *client) Scroll(amount int) { page := c.PageState.History[c.PageState.Position] - bottom := len(page.WrappedContent) - c.Height + bottom := len(page.WrappedContent) - c.Height + 3 // 3 for the three bars: top, msg, bottom if amount < 0 && page.ScrollPosition == 0 { c.SetMessage("You are already at the top", false) c.DrawMessage() fmt.Print("\a") return - } else if amount > 0 && page.ScrollPosition == bottom || bottom < 0 { + } else if (amount > 0 && page.ScrollPosition == bottom) || bottom < 0 { c.SetMessage("You are already at the bottom", false) c.DrawMessage() fmt.Print("\a") @@ -398,7 +429,7 @@ func (c *client) Scroll(amount int) { newScrollPosition = bottom } - page.ScrollPosition = newScrollPosition + c.PageState.History[c.PageState.Position].ScrollPosition = newScrollPosition c.Draw() } @@ -464,9 +495,15 @@ func (c *client) goToLink(l string) { return } } +} - c.SetMessage(fmt.Sprintf("Invalid link id: %s", l), true) - c.DrawMessage() +func (c *client) SetHeaderUrl() { + if c.PageState.Length > 0 { + u := c.PageState.History[c.PageState.Position].Location.Full + c.TopBar.url = u + } else { + c.TopBar.url = "" + } } func (c *client) Visit(url string) { @@ -487,6 +524,8 @@ func (c *client) Visit(url string) { c.DrawMessage() return } + c.SetMessage("Loading...", false) + c.DrawMessage() content, links, err := gopher.Visit(u.Mime, u.Host, u.Port, u.Resource) if err != nil { c.SetMessage(err.Error(), true) @@ -496,6 +535,9 @@ func (c *client) Visit(url string) { pg := MakePage(u, content, links) pg.WrapContent(c.Width) c.PageState.Add(pg) + c.ClearMessage() + c.ClearMessageLine() + c.SetHeaderUrl() c.Draw() case "gemini": // TODO send over to gemini request diff --git a/headbar.go b/headbar.go index d467a43..8782857 100644 --- a/headbar.go +++ b/headbar.go @@ -10,6 +10,7 @@ import ( type Headbar struct { title string + url string } @@ -27,9 +28,9 @@ func (h *Headbar) Draw() { // without having to redraw everything else } -func (h *Headbar) Render(width int, message string) string { +func (h *Headbar) Render(width int) string { maxMsgWidth := width - len([]rune(h.title)) - return fmt.Sprintf("\033[7m%s%-*.*s\033[0m", h.title, maxMsgWidth, maxMsgWidth, message) + return fmt.Sprintf("\033[7m%s%-*.*s\033[0m", h.title, maxMsgWidth, maxMsgWidth, h.url) } @@ -38,6 +39,6 @@ func (h *Headbar) Render(width int, message string) string { //--------------------------------------------------\\ func MakeHeadbar(title string) Headbar { - return Headbar{title} + return Headbar{title, ""} } diff --git a/main.go b/main.go index 9f2e642..780189f 100644 --- a/main.go +++ b/main.go @@ -163,6 +163,10 @@ func loadConfig() error { } } + for i, v := range settings.Bookmarks.Titles { + bombadillo.BookMarks.Add([]string{v, settings.Bookmarks.Links[i]}) + } + return nil } @@ -174,8 +178,8 @@ func initClient() error { } func main() { - // cui.HandleAlternateScreen("smcup") - // defer cui.Exit() + cui.HandleAlternateScreen("smcup") + defer cui.Exit() err := initClient() if err != nil { // if we can't initialize we should bail out diff --git a/page.go b/page.go index e67124d..3fe0a0e 100644 --- a/page.go +++ b/page.go @@ -2,7 +2,6 @@ package main import ( "strings" - "bytes" ) //------------------------------------------------\\ @@ -42,35 +41,31 @@ func (p *Page) ScrollPositionRange(termHeight int) (int, int) { func (p *Page) WrapContent(width int) { // TODO this is a temporary wrapping function // in order to test. Rebuild it. - src := strings.Split(p.RawContent, "\n") - out := []string{} - for _, ln := range src { - if len([]rune(ln)) <= width { - out = append(out, ln) + counter := 0 + var content strings.Builder + content.Grow(len(p.RawContent)) + for _, ch := range p.RawContent { + if ch == '\n' { + content.WriteRune(ch) + counter = 0 } else { - words := strings.SplitAfter(ln, " ") - var subout bytes.Buffer - for i, wd := range words { - sublen := subout.Len() - wdlen := len([]rune(wd)) - if sublen+wdlen <= width { - subout.WriteString(wd) - if i == len(words)-1 { - out = append(out, subout.String()) - } - } else { - out = append(out, subout.String()) - subout.Reset() - subout.WriteString(wd) - if i == len(words)-1 { - out = append(out, subout.String()) - subout.Reset() - } + if counter < width { + content.WriteRune(ch) + counter++ + } else { + content.WriteRune('\n') + counter = 0 + if p.Location.Mime == "1" { + spacer := " " + content.WriteString(spacer) + counter += len(spacer) } + content.WriteRune(ch) } } } - p.WrappedContent = out + + p.WrappedContent = strings.Split(content.String(), "\n") } //------------------------------------------------\\ diff --git a/pages.go b/pages.go index a4f12c3..9fde2d2 100644 --- a/pages.go +++ b/pages.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "strings" ) //------------------------------------------------\\ @@ -49,13 +48,32 @@ func (p *Pages) Add(pg Page) { } } -func (p *Pages) Render(termHeight int) []string { +func (p *Pages) Render(termHeight, termWidth int) []string { if p.Length < 1 { - msg := "Welcome to Bombadillo,\nif this is your first time here\ntype:\n\n:help\n(and then press enter)" - return strings.Split(msg, "\n") + return []string{""} } - beg, end := p.History[p.Position].ScrollPositionRange(termHeight) - return p.History[p.Position].WrappedContent[beg:end] + pos := p.History[p.Position].ScrollPosition + prev := len(p.History[p.Position].WrappedContent) + p.History[p.Position].WrapContent(termWidth) + now := len(p.History[p.Position].WrappedContent) + if prev > now { + diff := prev - now + pos = pos - diff + } else if prev < now { + diff := now - prev + pos = pos + diff + if pos > now - termHeight { + pos = now - termHeight + } + } + + if pos < 0 || now < termHeight - 3 { + pos = 0 + } + + p.History[p.Position].ScrollPosition = pos + + return p.History[p.Position].WrappedContent[pos:] } //------------------------------------------------\\ diff --git a/url.go b/url.go index 58673fd..7956d94 100644 --- a/url.go +++ b/url.go @@ -78,7 +78,7 @@ func MakeUrl(u string) (Url, error) { } if out.Scheme == "gopher" && out.Mime == "" { - out.Mime = "0" + out.Mime = "1" } if out.Mime == "" && (out.Resource == "" || out.Resource == "/") && out.Scheme == "gopher" { From f2f730f3c5d01c837b1dac771f55d88069fb39dc Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Fri, 13 Sep 2019 22:56:38 -0700 Subject: [PATCH 007/145] Vast improvements, still squashing bugs like crazy. --- bookmarks.go | 6 +-- client.go | 128 +++++++++++++++++++++++++++++++++++++++------------ defaults.go | 49 ++++++++++++++++++++ footbar.go | 27 +++++++---- headbar.go | 10 ++-- main.go | 99 ++------------------------------------- page.go | 18 +++++++- pages.go | 2 +- 8 files changed, 196 insertions(+), 143 deletions(-) create mode 100644 defaults.go diff --git a/bookmarks.go b/bookmarks.go index 3e08eab..a3eb82d 100644 --- a/bookmarks.go +++ b/bookmarks.go @@ -107,10 +107,10 @@ func (b Bookmarks) Render(termwidth, termheight int) []string { } out := make([]string, 0, 5) - top := fmt.Sprintf("%s%s%s", tl, strings.Repeat(ceil, width-2), tr) + contentWidth := width - 2 + top := fmt.Sprintf("%s%s%s", tl, strings.Repeat(ceil, contentWidth), tr) out = append(out, top) marks := b.List() - contentWidth := width - 2 for i := 0; i < termheight - 2; i++ { if i + b.Position >= b.Length { out = append(out, fmt.Sprintf("%s%-*.*s%s", wall, contentWidth, contentWidth, "", wall )) @@ -119,7 +119,7 @@ func (b Bookmarks) Render(termwidth, termheight int) []string { } } - bottom := fmt.Sprintf("%s%s%s", bl, strings.Repeat(ceil, width-2), br) + bottom := fmt.Sprintf("%s%s%s", bl, strings.Repeat(ceil, contentWidth), br) out = append(out, bottom) return out } diff --git a/client.go b/client.go index c59195b..016cf3f 100644 --- a/client.go +++ b/client.go @@ -6,7 +6,7 @@ import ( "net" "os" "os/exec" - "os/user" + // "os/user" "regexp" "strconv" "strings" @@ -41,6 +41,8 @@ type client struct { //--------------------------------------------------\\ func (c *client) GetSize() { + c.SetMessage("Initializing...", false) + c.DrawMessage() for { redraw := false cmd := exec.Command("stty", "size") @@ -71,28 +73,33 @@ func (c *client) GetSize() { func (c *client) Draw() { var screen strings.Builder screen.Grow(c.Height * c.Width) - screen.WriteString(c.TopBar.Render(c.Width)) + screen.WriteString(c.TopBar.Render(c.Width, c.Options["theme"])) screen.WriteString("\n") pageContent := c.PageState.Render(c.Height, c.Width) + if c.Options["theme"] == "inverse" { + screen.WriteString("\033[7m") + } if c.BookMarks.IsOpen { bm := c.BookMarks.Render(c.Width, c.Height) - bmWidth := 40 + // TODO remove this hard coded value + bmWidth := len([]rune(bm[0])) for i := 0; i < c.Height - 3; i++ { if c.Width > bmWidth { - contentWidth := c.Width - bmWidth - 1 - if i < len(pageContent) - 1 { + contentWidth := c.Width - bmWidth + if i < len(pageContent) { screen.WriteString(fmt.Sprintf("%-*.*s", contentWidth, contentWidth, pageContent[i])) } else { screen.WriteString(fmt.Sprintf("%-*.*s", contentWidth, contentWidth, " ")) } } + screen.WriteString(bm[i]) screen.WriteString("\n") } } else { for i := 0; i < c.Height - 3; i++ { if i < len(pageContent) - 1 { - screen.WriteString(pageContent[i]) + screen.WriteString(fmt.Sprintf("%-*.*s", c.Width, c.Width, pageContent[i])) screen.WriteString("\n") } else { screen.WriteString(fmt.Sprintf("%*s", c.Width, " ")) @@ -100,8 +107,9 @@ func (c *client) Draw() { } } } + screen.WriteString("\033[0m") screen.WriteString("\n") // for the input line - screen.WriteString(c.FootBar.Render(c.Width)) + screen.WriteString(c.FootBar.Render(c.Width, c.PageState.Position, c.Options["theme"])) cui.Clear("screen") cui.MoveCursorTo(0,0) fmt.Print(screen.String()) @@ -183,6 +191,9 @@ func (c *client) TakeControlInput() { // Process a command c.ClearMessage() c.ClearMessageLine() + if c.Options["theme"] == "normal" { + fmt.Printf("\033[7m%*.*s\r", c.Width, c.Width, "") + } entry, err := cui.GetLine() c.ClearMessageLine() if err != nil { @@ -190,6 +201,7 @@ func (c *client) TakeControlInput() { c.DrawMessage() break } else if strings.TrimSpace(entry) == "" { + c.DrawMessage() break } @@ -221,7 +233,7 @@ func (c *client) routeCommandInput(com *cmdparse.Command) error { case cmdparse.DO: c.doCommand(com.Action, com.Value) case cmdparse.DOLINK: - // err = doLinkCommand(com.Action, com.Target) + c.doLinkCommand(com.Action, com.Target) case cmdparse.DOAS: c.doCommandAs(com.Action, com.Value) case cmdparse.DOLINKAS: @@ -337,7 +349,8 @@ func (c *client) doCommandAs(action string, values []string) { c.SetMessage("Value set, but error saving config to file", true) c.DrawMessage() } else { - c.SetMessage(fmt.Sprintf("%s is now set to %q", values[0], c.Options[values[0]]), true) + c.Draw() + c.SetMessage(fmt.Sprintf("%s is now set to %q", values[0], c.Options[values[0]]), false) c.DrawMessage() } return @@ -373,6 +386,47 @@ func (c *client) saveFile(data []byte, name string) (string, error) { return savePath, nil } +func (c *client) doLinkCommand(action, target string) { + num, err := strconv.Atoi(target) + if err != nil { + c.SetMessage(fmt.Sprintf("Expected number, got %q", target), true) + c.DrawMessage() + } + + switch action { + case "DELETE", "D": + msg, err := c.BookMarks.Delete(num) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } else { + c.SetMessage(msg, false) + c.DrawMessage() + } + + err = saveConfig() + if err != nil { + c.SetMessage("Error saving bookmark deletion to file", true) + c.DrawMessage() + } + if c.BookMarks.IsOpen { + c.Draw() + } + case "BOOKMARKS", "B": + if num > len(c.BookMarks.Links)-1 { + c.SetMessage(fmt.Sprintf("There is no bookmark with ID %d", num), true) + c.DrawMessage() + return + } + c.Visit(c.BookMarks.Links[num]) + default: + c.SetMessage(fmt.Sprintf("Action %q does not exist for target %q", action, target), true) + c.DrawMessage() + } + +} + func (c *client) search() { c.ClearMessage() c.ClearMessageLine() @@ -408,6 +462,7 @@ func (c *client) search() { } func (c *client) Scroll(amount int) { + var percentRead int page := c.PageState.History[c.PageState.Position] bottom := len(page.WrappedContent) - c.Height + 3 // 3 for the three bars: top, msg, bottom if amount < 0 && page.ScrollPosition == 0 { @@ -416,6 +471,7 @@ func (c *client) Scroll(amount int) { fmt.Print("\a") return } else if (amount > 0 && page.ScrollPosition == bottom) || bottom < 0 { + c.FootBar.SetPercentRead(100) c.SetMessage("You are already at the bottom", false) c.DrawMessage() fmt.Print("\a") @@ -430,6 +486,14 @@ func (c *client) Scroll(amount int) { } c.PageState.History[c.PageState.Position].ScrollPosition = newScrollPosition + + if len(page.WrappedContent) < c.Height - 3 { + percentRead = 100 + } else { + percentRead = int(float32(newScrollPosition + c.Height - 3) / float32(len(page.WrappedContent)) * 100.0) + } + c.FootBar.SetPercentRead(percentRead) + c.Draw() } @@ -446,21 +510,30 @@ func (c *client) displayConfigValue(setting string) { func (c *client) SetMessage(msg string, isError bool) { leadIn, leadOut := "", "" if isError { - leadIn = "\033[31m" + leadIn = "\033[91m" + leadOut = "\033[0m" + + if c.Options["theme"] == "normal" { + leadIn = "\033[101;7m" + } + } + + if c.Options["theme"] == "normal" { + leadIn = "\033[7m" leadOut = "\033[0m" } - c.Message = fmt.Sprintf("%s%s%s", leadIn, msg, leadOut) + c.Message = fmt.Sprintf("%s%-*.*s%s", leadIn, c.Width, c.Width, msg, leadOut) } func (c *client) DrawMessage() { c.ClearMessageLine() cui.MoveCursorTo(c.Height-1, 0) - fmt.Print(c.Message) + fmt.Printf("%s", c.Message) } func (c *client) ClearMessage() { - c.Message = "" + c.SetMessage("", false) } func (c *client) ClearMessageLine() { @@ -518,12 +591,6 @@ func (c *client) Visit(url string) { switch u.Scheme { case "gopher": - u, err := MakeUrl(url) - if err != nil { - c.SetMessage(err.Error(), true) - c.DrawMessage() - return - } c.SetMessage("Loading...", false) c.DrawMessage() content, links, err := gopher.Visit(u.Mime, u.Host, u.Port, u.Resource) @@ -535,13 +602,14 @@ func (c *client) Visit(url string) { pg := MakePage(u, content, links) pg.WrapContent(c.Width) c.PageState.Add(pg) + c.Scroll(0) // to update percent read c.ClearMessage() c.ClearMessageLine() c.SetHeaderUrl() c.Draw() case "gemini": // TODO send over to gemini request - c.SetMessage("Gemini is not currently supported", false) + c.SetMessage("Bombadillo has not mastered Gemini yet, check back soon", false) c.DrawMessage() case "telnet": c.SetMessage("Attempting to start telnet session", false) @@ -582,16 +650,16 @@ func (c *client) Visit(url string) { //--------------------------------------------------\\ func MakeClient(name string) *client { - var userinfo, _ = user.Current() - var options = map[string]string{ - "homeurl": "gopher://colorfield.space:70/1/bombadillo-info", - "savelocation": userinfo.HomeDir, - "searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs", - "openhttp": "false", - "httpbrowser": "lynx", - "configlocation": userinfo.HomeDir, - } - c := client{0, 0, options, "", MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar()} + // var userinfo, _ = user.Current() + // var options = map[string]string{ + // "homeurl": "gopher://colorfield.space:70/1/bombadillo-info", + // "savelocation": userinfo.HomeDir, + // "searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs", + // "openhttp": "false", + // "httpbrowser": "lynx", + // "configlocation": userinfo.HomeDir, + // } + c := client{0, 0, defaultOptions, "", MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar()} return &c } diff --git a/defaults.go b/defaults.go new file mode 100644 index 0000000..87fa557 --- /dev/null +++ b/defaults.go @@ -0,0 +1,49 @@ +package main + +import ( + "os/user" +) + +var userinfo, _ = user.Current() +var defaultOptions = map[string]string{ + // + // General configuration options + // + "homeurl": "gopher://colorfield.space:70/1/bombadillo-info", + "savelocation": userinfo.HomeDir, + "searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs", + "openhttp": "false", + "httpbrowser": "lynx", + "telnetcommand": "telnet", + "configlocation": userinfo.HomeDir, + "theme": "normal", // "normal", "inverted" +} + +// TODO decide whether or not to institute a color theme +// system. Preliminary testing implies it should be very +// doable. +var theme = map[string]string{ + "topbar_title_bg": "", + "topbar_link_fg": "", + "body_bg": "237", + "body_fg": "", + "bookmarks_bg": "", + "bookmarks_fg": "", + "command_bg": "", + "message_fg": "", + "error_fg": "", + "bottombar_bg": "", + "bottombar_fg": "", + // + // text style options + // + "topbar_title_style": "bold", + "topbar_link_style": "plain", + "body_style": "plain", + "bookmark_body_style": "plain", + "bookmark_border_style": "plain", + "message_style": "italic", + "error_style": "bold", + "command_style": "plain", + "bottom_bar_style": "plain", +} diff --git a/footbar.go b/footbar.go index dab20bf..c2d2e27 100644 --- a/footbar.go +++ b/footbar.go @@ -2,14 +2,16 @@ package main import ( "fmt" + "strconv" ) + //------------------------------------------------\\ // + + + T Y P E S + + + \\ //--------------------------------------------------\\ type Footbar struct { - PercentRead int + PercentRead string PageType string } @@ -19,20 +21,25 @@ type Footbar struct { //--------------------------------------------------\\ func (f *Footbar) SetPercentRead(p int) { - f.PercentRead = p + if p > 100 { + p = 100 + } else if p < 0 { + p = 0 + } + f.PercentRead = strconv.Itoa(p) + "%" } func (f *Footbar) SetPageType(t string) { f.PageType = t } -func (f *Footbar) Draw() { - // TODO this will actually draw the bar - // without having to redraw everything else -} - -func (f *Footbar) Render(termWidth int) string { - return fmt.Sprintf("\033[7m%-*.*s\033[0m", termWidth, termWidth, "") +func (f *Footbar) Render(termWidth, position int, theme string) string { + pre := fmt.Sprintf("HST: (%2.2d) - - - %4s Read ", position + 1, f.PercentRead) + out := "\033[0m%*.*s " + if theme == "inverse" { + out = "\033[7m%*.*s \033[0m" + } + return fmt.Sprintf(out, termWidth - 1, termWidth - 1, pre) } @@ -41,6 +48,6 @@ func (f *Footbar) Render(termWidth int) string { //--------------------------------------------------\\ func MakeFootbar() Footbar { - return Footbar{100, "N/A"} + return Footbar{"---", "N/A"} } diff --git a/headbar.go b/headbar.go index 8782857..e1f1434 100644 --- a/headbar.go +++ b/headbar.go @@ -28,9 +28,13 @@ func (h *Headbar) Draw() { // without having to redraw everything else } -func (h *Headbar) Render(width int) string { - maxMsgWidth := width - len([]rune(h.title)) - return fmt.Sprintf("\033[7m%s%-*.*s\033[0m", h.title, maxMsgWidth, maxMsgWidth, h.url) +func (h *Headbar) Render(width int, theme string) string { + maxMsgWidth := width - len([]rune(h.title)) - 2 + if theme == "inverse" { + return fmt.Sprintf("\033[7m%s▟\033[27m %-*.*s\033[0m", h.title, maxMsgWidth, maxMsgWidth, h.url) + } else { + return fmt.Sprintf("%s▟\033[7m %-*.*s\033[0m", h.title, maxMsgWidth, maxMsgWidth, h.url) + } } diff --git a/main.go b/main.go index 780189f..e754b9e 100644 --- a/main.go +++ b/main.go @@ -3,12 +3,10 @@ package main import ( "io/ioutil" "os" - // "strconv" "strings" "tildegit.org/sloum/bombadillo/config" "tildegit.org/sloum/bombadillo/cui" - // "tildegit.org/sloum/bombadillo/gopher" ) var bombadillo *client @@ -32,96 +30,6 @@ var settings config.Config // } - -// func doLinkCommand(action, target string) error { - // num, err := strconv.Atoi(target) - // if err != nil { - // return fmt.Errorf("Expected number, got %q", target) - // } - - // switch action { - // case "DELETE", "D": - // err := settings.Bookmarks.Del(num) - // if err != nil { - // return err - // } - - // screen.Windows[1].Content = settings.Bookmarks.List() - // err = saveConfig() - // if err != nil { - // return err - // } - - // screen.ReflashScreen(false) - // return nil - // case "BOOKMARKS", "B": - // if num > len(settings.Bookmarks.Links)-1 { - // return fmt.Errorf("There is no bookmark with ID %d", num) - // } - // err := goToURL(settings.Bookmarks.Links[num]) - // return err - // } - - // return fmt.Errorf("This method has not been built") -// } - - -// func doCommand(action string, values []string) error { - // if length := len(values); length != 1 { - // return fmt.Errorf("Expected 1 argument, received %d", length) - // } - - // switch action { - // case "CHECK", "C": - // err := checkConfigValue(values[0]) - // if err != nil { - // return err - // } - // return nil - // } - // return fmt.Errorf("Unknown command structure") -// } - -// func doLinkCommandAs(action, target string, values []string) error { - // num, err := strconv.Atoi(target) - // if err != nil { - // return fmt.Errorf("Expected number, got %q", target) - // } - - // links := history.Collection[history.Position].Links - // if num >= len(links) { - // return fmt.Errorf("Invalid link id: %s", target) - // } - - // switch action { - // case "ADD", "A": - // newBookmark := append([]string{links[num-1]}, values...) - // err := settings.Bookmarks.Add(newBookmark) - // if err != nil { - // return err - // } - - // screen.Windows[1].Content = settings.Bookmarks.List() - - // err = saveConfig() - // if err != nil { - // return err - // } - - // screen.ReflashScreen(false) - // return nil - // case "WRITE", "W": - // return saveFile(links[num-1], strings.Join(values, " ")) - // } - - // return fmt.Errorf("This method has not been built") -// } - -// func updateMainContent() { - // screen.Windows[0].Content = history.Collection[history.Position].Content - // screen.Bars[0].SetMessage(history.Collection[history.Position].Address.Full) -// } - func saveConfig() error { bkmrks := bombadillo.BookMarks.IniDump() // TODO opts becomes a string builder rather than concat @@ -186,6 +94,9 @@ func main() { panic(err) } + // TODO find out why the loading message + // has disappeared on initial load... + // Start polling for terminal size changes go bombadillo.GetSize() @@ -193,12 +104,12 @@ func main() { // If a url was passed, move it down the line // Goroutine so keypresses can be made during // page load - bombadillo.Visit(os.Args[1]) + go bombadillo.Visit(os.Args[1]) } else { // Otherwise, load the homeurl // Goroutine so keypresses can be made during // page load - bombadillo.Visit(bombadillo.Options["homeurl"]) + go bombadillo.Visit(bombadillo.Options["homeurl"]) } // Loop indefinitely on user input diff --git a/page.go b/page.go index 3fe0a0e..20514b6 100644 --- a/page.go +++ b/page.go @@ -38,9 +38,11 @@ func (p *Page) ScrollPositionRange(termHeight int) (int, int) { return p.ScrollPosition, end } +// Performs a hard wrap to the requested +// width and updates the WrappedContent +// of the Page struct width a string slice +// of the wrapped data func (p *Page) WrapContent(width int) { - // TODO this is a temporary wrapping function - // in order to test. Rebuild it. counter := 0 var content strings.Builder content.Grow(len(p.RawContent)) @@ -48,6 +50,18 @@ func (p *Page) WrapContent(width int) { if ch == '\n' { content.WriteRune(ch) counter = 0 + } else if ch == '\t' { + if counter + 4 < width { + content.WriteString(" ") + counter += 4 + } else { + content.WriteRune('\n') + counter = 0 + } + } else if ch == '\r' { + // This handles non-linux line endings... + // to some degree... + continue } else { if counter < width { content.WriteRune(ch) diff --git a/pages.go b/pages.go index 9fde2d2..08a403b 100644 --- a/pages.go +++ b/pages.go @@ -50,7 +50,7 @@ func (p *Pages) Add(pg Page) { func (p *Pages) Render(termHeight, termWidth int) []string { if p.Length < 1 { - return []string{""} + return make([]string, 0) } pos := p.History[p.Position].ScrollPosition prev := len(p.History[p.Position].WrappedContent) From cb3bcc9465907fe17ed6bbd57e4e22aa2ed40d3e Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 14 Sep 2019 15:45:23 -0700 Subject: [PATCH 008/145] Relicenses bobmadillo --- LICENSE | 867 +++++++++++------------------------------------ client.go | 55 ++- gopher/gopher.go | 2 +- main.go | 10 +- url.go | 4 + 5 files changed, 233 insertions(+), 705 deletions(-) diff --git a/LICENSE b/LICENSE index f288702..63d7936 100644 --- a/LICENSE +++ b/LICENSE @@ -1,674 +1,195 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 +Non-Profit Open Software License 3.0 + +This Non-Profit Open Software License ("Non-Profit OSL") version 3.0 (the +"License") applies to any original work of authorship (the "Original Work") +whose owner (the "Licensor") has placed the following licensing notice adjacent +to the copyright notice for the Original Work: + +Licensed under the Non-Profit Open Software License version 3.0 + +1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, +non-exclusive, sublicensable license, for the duration of the copyright, to +do the following: + + a) to reproduce the Original Work in copies, either alone or as part of a + collective work; + + b) to translate, adapt, alter, transform, modify, or arrange the Original + Work, thereby creating derivative works ("Derivative Works") based upon the + Original Work; + + c) to distribute or communicate copies of the Original Work and Derivative + Works to the public, with the proviso that copies of Original Work or Derivative + Works that You distribute or communicate shall be licensed under this Non-Profit + Open Software License or as provided in section 17(d); + + d) to perform the Original Work publicly; and + + e) to display the Original Work publicly. + +2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, +non-exclusive, sublicensable license, under patent claims owned or controlled +by the Licensor that are embodied in the Original Work as furnished by the +Licensor, for the duration of the patents, to make, use, sell, offer for sale, +have made, and import the Original Work and Derivative Works. + +3) Grant of Source Code License. The term "Source Code" means the preferred +form of the Original Work for making modifications to it and all available +documentation describing how to modify the Original Work. Licensor agrees +to provide a machine-readable copy of the Source Code of the Original Work +along with each copy of the Original Work that Licensor distributes. Licensor +reserves the right to satisfy this obligation by placing a machine-readable +copy of the Source Code in an information repository reasonably calculated +to permit inexpensive and convenient access by You for as long as Licensor +continues to distribute the Original Work. + +4) Exclusions From License Grant. Neither the names of Licensor, nor the names +of any contributors to the Original Work, nor any of their trademarks or service +marks, may be used to endorse or promote products derived from this Original +Work without express prior permission of the Licensor. Except as expressly +stated herein, nothing in this License grants any license to Licensor's trademarks, +copyrights, patents, trade secrets or any other intellectual property. No +patent license is granted to make, use, sell, offer for sale, have made, or +import embodiments of any patent claims other than the licensed claims defined +in Section 2. No license is granted to the trademarks of Licensor even if +such marks are included in the Original Work. Nothing in this License shall +be interpreted to prohibit Licensor from licensing under terms different from +this License any Original Work that Licensor otherwise would have a right +to license. + +5) External Deployment. The term "External Deployment" means the use, distribution, +or communication of the Original Work or Derivative Works in any way such +that the Original Work or Derivative Works may be used by anyone other than +You, whether those works are distributed or communicated to those persons +or made available as an application intended for use over a network. As an +express condition for the grants of license hereunder, You must treat any +External Deployment by You of the Original Work or a Derivative Work as a +distribution under section 1(c). + +6) Attribution Rights. You must retain, in the Source Code of any Derivative +Works that You create, all copyright, patent, or trademark notices from the +Source Code of the Original Work, as well as any notices of licensing and +any descriptive text identified therein as an "Attribution Notice." You must +cause the Source Code for any Derivative Works that You create to carry a +prominent Attribution Notice reasonably calculated to inform recipients that +You have modified the Original Work. + +7) Warranty of Provenance and Disclaimer of Warranty. The Original Work is +provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either +express or implied, including, without limitation, the warranties of non-infringement, +merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO +THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY +constitutes an essential part of this License. No license to the Original +Work is granted by this License except under this disclaimer. + +8) Limitation of Liability. Under no circumstances and under no legal theory, +whether in tort (including negligence), contract, or otherwise, shall the +Licensor be liable to anyone for any direct, indirect, special, incidental, +or consequential damages of any character arising as a result of this License +or the use of the Original Work including, without limitation, damages for +loss of goodwill, work stoppage, computer failure or malfunction, or any and +all other commercial damages or losses. This limitation of liability shall +not apply to the extent applicable law prohibits such limitation. + +9) Acceptance and Termination. If, at any time, You expressly assented to +this License, that assent indicates your clear and irrevocable acceptance +of this License and all of its terms and conditions. If You distribute or +communicate copies of the Original Work or a Derivative Work, You must make +a reasonable effort under the circumstances to obtain the express assent of +recipients to the terms of this License. This License conditions your rights +to undertake the activities listed in Section 1, including your right to create +Derivative Works based upon the Original Work, and doing so without honoring +these terms and conditions is prohibited by copyright law and international +treaty. Nothing in this License is intended to affect copyright exceptions +and limitations (including "fair use" or "fair dealing"). This License shall +terminate immediately and You may no longer exercise any of the rights granted +to You by this License upon your failure to honor the conditions in Section +1(c). + +10) Termination for Patent Action. This License shall terminate automatically +and You may no longer exercise any of the rights granted to You by this License +as of the date You commence an action, including a cross-claim or counterclaim, +against Licensor or any licensee alleging that the Original Work infringes +a patent. This termination provision shall not apply for an action alleging +patent infringement by combinations of the Original Work with other software +or hardware. + +11) Jurisdiction, Venue and Governing Law. Any action or suit relating to +this License may be brought only in the courts of a jurisdiction wherein the +Licensor resides or in which Licensor conducts its primary business, and under +the laws of that jurisdiction excluding its conflict-of-law provisions. The +application of the United Nations Convention on Contracts for the International +Sale of Goods is expressly excluded. Any use of the Original Work outside +the scope of this License or after its termination shall be subject to the +requirements and penalties of copyright or patent law in the appropriate jurisdiction. +This section shall survive the termination of this License. + +12) Attorneys' Fees. In any action to enforce the terms of this License or +seeking damages relating thereto, the prevailing party shall be entitled to +recover its costs and expenses, including, without limitation, reasonable +attorneys' fees and costs incurred in connection with such action, including +any appeal of such action. This section shall survive the termination of this +License. + +13) Miscellaneous. If any provision of this License is held to be unenforceable, +such provision shall be reformed only to the extent necessary to make it enforceable. + +14) Definition of "You" in This License. "You" throughout this License, whether +in upper or lower case, means an individual or a legal entity exercising rights +under, and complying with all of the terms of, this License. For legal entities, +"You" includes any entity that controls, is controlled by, or is under common +control with you. For purposes of this definition, "control" means (i) the +power, direct or indirect, to cause the direction or management of such entity, +whether by contract or otherwise, or (ii) ownership of fifty percent (50%) +or more of the outstanding shares, or (iii) beneficial ownership of such entity. + +15) Right to Use. You may use the Original Work in all ways not otherwise +restricted or conditioned by this License or by law, and Licensor promises +not to interfere with or be responsible for such uses by You. + +16) Modification of This License. This License is Copyright © 2005 Lawrence +Rosen. Permission is granted to copy, distribute, or communicate this License +without modification. Nothing in this License permits You to modify this License +as applied to the Original Work or to Derivative Works. However, You may modify +the text of this License and copy, distribute or communicate your modified +version (the "Modified License") and apply it to other original works of authorship +subject to the following conditions: (i) You may not indicate in any way that +your Modified License is the "Open Software License" or "OSL" and you may +not use those names in the name of your Modified License; (ii) You must replace +the notice specified in the first paragraph above with the notice "Licensed +under " or with a notice of your own that is +not confusingly similar to the notice in this License; and (iii) You may not +claim that your original works are open source software unless your Modified +License has been approved by Open Source Initiative (OSI) and You comply with +its license review and certification process. + +17) Non-Profit Amendment. The name of this amended version of the Open Software +License ("OSL 3.0") is "Non-Profit Open Software License 3.0". The original +OSL 3.0 license has been amended as follows: + + (a) Licensor represents and declares that it is a not-for-profit organization + that derives no revenue whatsoever from the distribution of the Original Work + or Derivative Works thereof, or from support or services relating thereto. + + (b) The first sentence of Section 7 ["Warranty of Provenance"] of OSL 3.0 + has been stricken. For Original Works licensed under this Non-Profit OSL 3.0, + LICENSOR OFFERS NO WARRANTIES WHATSOEVER. + + (c) In the first sentence of Section 8 ["Limitation of Liability"] of this + Non-Profit OSL 3.0, the list of damages for which LIABILITY IS LIMITED now + includes "direct" damages. + + (d) The proviso in Section 1(c) of this License now refers to this "Non-Profit + Open Software License" rather than the "Open Software License". You may distribute + or communicate the Original Work or Derivative Works thereof under this Non-Profit + OSL 3.0 license only if You make the representation and declaration in paragraph + (a) of this Section 17. Otherwise, You shall distribute or communicate the + Original Work or Derivative Works thereof only under the OSL 3.0 license and + You shall publish clear licensing notices so stating. Also by way of clarification, + this License does not authorize You to distribute or communicate works under + this Non-Profit OSL 3.0 if You received them under the original OSL 3.0 license. + + (e) Original Works licensed under this license shall reference "Non-Profit + OSL 3.0" in licensing notices to distinguish them from works licensed under + the original OSL 3.0 license. - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read -. diff --git a/client.go b/client.go index 016cf3f..91a6d10 100644 --- a/client.go +++ b/client.go @@ -40,11 +40,26 @@ type client struct { // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ +func (c *client) GetSizeOnce() { + cmd := exec.Command("stty", "size") + cmd.Stdin = os.Stdin + out, err := cmd.Output() + if err != nil { + fmt.Println("Fatal error: Unable to retrieve terminal size") + os.Exit(5) + } + var h, w int + fmt.Sscan(string(out), &h, &w) + c.Height = h + c.Width = w +} + func (c *client) GetSize() { - c.SetMessage("Initializing...", false) - c.DrawMessage() + c.GetSizeOnce() + c.SetMessage("Loading...", false) + c.Draw() + for { - redraw := false cmd := exec.Command("stty", "size") cmd.Stdin = os.Stdin out, err := cmd.Output() @@ -55,14 +70,8 @@ func (c *client) GetSize() { var h, w int fmt.Sscan(string(out), &h, &w) if h != c.Height || w != c.Width { - redraw = true - } - - c.Height = h - c.Width = w - - - if redraw { + c.Height = h + c.Width = w c.Draw() } @@ -81,7 +90,6 @@ func (c *client) Draw() { } if c.BookMarks.IsOpen { bm := c.BookMarks.Render(c.Width, c.Height) - // TODO remove this hard coded value bmWidth := len([]rune(bm[0])) for i := 0; i < c.Height - 3; i++ { if c.Width > bmWidth { @@ -108,12 +116,12 @@ func (c *client) Draw() { } } screen.WriteString("\033[0m") + screen.WriteString(c.Message) screen.WriteString("\n") // for the input line screen.WriteString(c.FootBar.Render(c.Width, c.PageState.Position, c.Options["theme"])) cui.Clear("screen") cui.MoveCursorTo(0,0) fmt.Print(screen.String()) - c.DrawMessage() } func (c *client) TakeControlInput() { @@ -123,12 +131,10 @@ func (c *client) TakeControlInput() { case 'j', 'J': // scroll down one line c.ClearMessage() - c.ClearMessageLine() c.Scroll(1) case 'k', 'K': // scroll up one line c.ClearMessage() - c.ClearMessageLine() c.Scroll(-1) case 'q', 'Q': // quite bombadillo @@ -136,29 +142,24 @@ func (c *client) TakeControlInput() { case 'g': // scroll to top c.ClearMessage() - c.ClearMessageLine() c.Scroll(-len(c.PageState.History[c.PageState.Position].WrappedContent)) case 'G': // scroll to bottom c.ClearMessage() - c.ClearMessageLine() c.Scroll(len(c.PageState.History[c.PageState.Position].WrappedContent)) case 'd': // scroll down 75% c.ClearMessage() - c.ClearMessageLine() distance := c.Height - c.Height / 4 c.Scroll(distance) case 'u': // scroll up 75% c.ClearMessage() - c.ClearMessageLine() distance := c.Height - c.Height / 4 c.Scroll(-distance) case 'b': // go back c.ClearMessage() - c.ClearMessageLine() err := c.PageState.NavigateHistory(-1) if err != nil { c.SetMessage(err.Error(), false) @@ -174,7 +175,6 @@ func (c *client) TakeControlInput() { case 'f', 'F': // go forward c.ClearMessage() - c.ClearMessageLine() err := c.PageState.NavigateHistory(1) if err != nil { c.SetMessage(err.Error(), false) @@ -349,9 +349,8 @@ func (c *client) doCommandAs(action string, values []string) { c.SetMessage("Value set, but error saving config to file", true) c.DrawMessage() } else { - c.Draw() c.SetMessage(fmt.Sprintf("%s is now set to %q", values[0], c.Options[values[0]]), false) - c.DrawMessage() + c.Draw() } return } @@ -527,7 +526,7 @@ func (c *client) SetMessage(msg string, isError bool) { } func (c *client) DrawMessage() { - c.ClearMessageLine() + // c.ClearMessageLine() cui.MoveCursorTo(c.Height-1, 0) fmt.Printf("%s", c.Message) } @@ -580,8 +579,9 @@ func (c *client) SetHeaderUrl() { } func (c *client) Visit(url string) { - // TODO both gemini and gopher should return a string - // The wrap lines function in cui needs to be rewritten + c.SetMessage("Loading...", false) + c.DrawMessage() + u, err := MakeUrl(url) if err != nil { c.SetMessage(err.Error(), true) @@ -591,8 +591,6 @@ func (c *client) Visit(url string) { switch u.Scheme { case "gopher": - c.SetMessage("Loading...", false) - c.DrawMessage() content, links, err := gopher.Visit(u.Mime, u.Host, u.Port, u.Resource) if err != nil { c.SetMessage(err.Error(), true) @@ -604,7 +602,6 @@ func (c *client) Visit(url string) { c.PageState.Add(pg) c.Scroll(0) // to update percent read c.ClearMessage() - c.ClearMessageLine() c.SetHeaderUrl() c.Draw() case "gemini": diff --git a/gopher/gopher.go b/gopher/gopher.go index b990682..dbf0d49 100644 --- a/gopher/gopher.go +++ b/gopher/gopher.go @@ -171,7 +171,7 @@ func buildLink(host, port, gtype, resource string) string { case "h": u, tf := isWebLink(resource) if tf { - if len(u) > 4 && string(u[:5]) == "http" { + if len(u) > 4 && string(u[:4]) == "http" { return u } else { return fmt.Sprintf("http://%s", u) diff --git a/main.go b/main.go index e754b9e..4f8348a 100644 --- a/main.go +++ b/main.go @@ -1,5 +1,11 @@ package main +// Bombadillo is distributed under the "Non-Profit Open Source Software License 3.0" +// The license is included with the source code in the file LICENSE. The basic +// takeway: use, remix, and share this software for any purpose that is not a commercial +// purpose as defined by the above mentioned license and is itself distributed udner +// the terms of said license with said license file included. + import ( "io/ioutil" "os" @@ -104,12 +110,12 @@ func main() { // If a url was passed, move it down the line // Goroutine so keypresses can be made during // page load - go bombadillo.Visit(os.Args[1]) + bombadillo.Visit(os.Args[1]) } else { // Otherwise, load the homeurl // Goroutine so keypresses can be made during // page load - go bombadillo.Visit(bombadillo.Options["homeurl"]) + bombadillo.Visit(bombadillo.Options["homeurl"]) } // Loop indefinitely on user input diff --git a/url.go b/url.go index 7956d94..faedbbb 100644 --- a/url.go +++ b/url.go @@ -101,6 +101,10 @@ func MakeUrl(u string) (Url, error) { out.Mime = "" } + if out.Scheme == "http" || out.Scheme == "https" { + out.Mime = "" + } + out.Full = out.Scheme + "://" + out.Host + ":" + out.Port + "/" + out.Mime + out.Resource return out, nil From e7a1b4e34828f6028fc2b5254b4b25cc1d4f0a47 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 15 Sep 2019 21:24:45 -0700 Subject: [PATCH 009/145] Fixes order of opperations issue when drawing messages --- client.go | 108 +++++++++++++++++++++++++++++++++++++++++++---------- headbar.go | 10 ----- main.go | 19 +++++----- 3 files changed, 98 insertions(+), 39 deletions(-) diff --git a/client.go b/client.go index 91a6d10..e0abfa6 100644 --- a/client.go +++ b/client.go @@ -29,6 +29,7 @@ type client struct { Width int Options map[string]string Message string + MessageIsErr bool PageState Pages BookMarks Bookmarks TopBar Headbar @@ -116,7 +117,8 @@ func (c *client) Draw() { } } screen.WriteString("\033[0m") - screen.WriteString(c.Message) + // TODO using message here breaks on resize, must regenerate + screen.WriteString(c.RenderMessage()) screen.WriteString("\n") // for the input line screen.WriteString(c.FootBar.Render(c.Width, c.PageState.Position, c.Options["theme"])) cui.Clear("screen") @@ -237,7 +239,7 @@ func (c *client) routeCommandInput(com *cmdparse.Command) error { case cmdparse.DOAS: c.doCommandAs(com.Action, com.Value) case cmdparse.DOLINKAS: - // err = doLinkCommandAs(com.Action, com.Target, com.Value) + c.doLinkCommandAs(com.Action, com.Target, com.Value) default: return fmt.Errorf("Unknown command entry!") } @@ -361,6 +363,52 @@ func (c *client) doCommandAs(action string, values []string) { c.SetMessage(fmt.Sprintf("Unknown command structure"), true) } +func (c *client) doLinkCommandAs(action, target string, values []string) { + num, err := strconv.Atoi(target) + if err != nil { + c.SetMessage(fmt.Sprintf("Expected link number, got %q", target), true) + c.DrawMessage() + return + } + + switch action { + case "ADD", "A": + links := c.PageState.History[c.PageState.Position].Links + if num >= len(links) { + c.SetMessage(fmt.Sprintf("Invalid link id: %s", target), true) + c.DrawMessage() + return + } + bm := make([]string, 0, 5) + bm = append(bm, links[num-1]) + bm = append(bm, values...) + msg, err := c.BookMarks.Add(bm) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } else { + c.SetMessage(msg, false) + c.DrawMessage() + } + + err = saveConfig() + if err != nil { + c.SetMessage("Error saving bookmark to file", true) + c.DrawMessage() + } + if c.BookMarks.IsOpen { + c.Draw() + } + case "WRITE", "W": + // TODO get file writing working in some semblance of universal way + // return saveFile(links[num-1], strings.Join(values, " ")) + default: + c.SetMessage(fmt.Sprintf("Unknown command structure"), true) + } +} + + func (c *client) getCurrentPageUrl() (string, error) { if c.PageState.Length < 1 { return "", fmt.Errorf("There are no pages in history") @@ -429,6 +477,9 @@ func (c *client) doLinkCommand(action, target string) { func (c *client) search() { c.ClearMessage() c.ClearMessageLine() + // TODO handle keeping the full command bar here + // like was done for regular command entry + // maybe split into separate function fmt.Print("?") entry, err := cui.GetLine() c.ClearMessageLine() @@ -439,9 +490,9 @@ func (c *client) search() { } else if strings.TrimSpace(entry) == "" { return } - u, err := MakeUrl(c.Options["searchurl"]) + u, err := MakeUrl(c.Options["searchengine"]) if err != nil { - c.SetMessage("'searchurl' is not set to a valid url", true) + c.SetMessage("'searchengine' is not set to a valid url", true) c.DrawMessage() return } @@ -507,28 +558,47 @@ func (c *client) displayConfigValue(setting string) { } func (c *client) SetMessage(msg string, isError bool) { + c.MessageIsErr = isError + c.Message = msg +} + +func (c *client) DrawMessage() { leadIn, leadOut := "", "" - if isError { - leadIn = "\033[91m" - leadOut = "\033[0m" - - if c.Options["theme"] == "normal" { - leadIn = "\033[101;7m" - } - } - if c.Options["theme"] == "normal" { leadIn = "\033[7m" leadOut = "\033[0m" } - c.Message = fmt.Sprintf("%s%-*.*s%s", leadIn, c.Width, c.Width, msg, leadOut) + if c.MessageIsErr { + leadIn = "\033[31;1m" + leadOut = "\033[0m" + + if c.Options["theme"] == "normal" { + leadIn = "\033[41;1;7m" + } + } + + cui.MoveCursorTo(c.Height-1, 0) + fmt.Printf("%s%-*.*s%s", leadIn, c.Width, c.Width, c.Message, leadOut) } -func (c *client) DrawMessage() { - // c.ClearMessageLine() - cui.MoveCursorTo(c.Height-1, 0) - fmt.Printf("%s", c.Message) +func (c *client) RenderMessage() string { + leadIn, leadOut := "", "" + if c.Options["theme"] == "normal" { + leadIn = "\033[7m" + leadOut = "\033[0m" + } + + if c.MessageIsErr { + leadIn = "\033[31;1m" + leadOut = "\033[0m" + + if c.Options["theme"] == "normal" { + leadIn = "\033[41;1;7m" + } + } + + return fmt.Sprintf("%s%-*.*s%s", leadIn, c.Width, c.Width, c.Message, leadOut) } func (c *client) ClearMessage() { @@ -656,7 +726,7 @@ func MakeClient(name string) *client { // "httpbrowser": "lynx", // "configlocation": userinfo.HomeDir, // } - c := client{0, 0, defaultOptions, "", MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar()} + c := client{0, 0, defaultOptions, "", false, MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar()} return &c } diff --git a/headbar.go b/headbar.go index e1f1434..e6d43ef 100644 --- a/headbar.go +++ b/headbar.go @@ -18,16 +18,6 @@ type Headbar struct { // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ -func (h *Headbar) Build(width string) string { - // TODO Build out header to specified width - return "" -} - -func (h *Headbar) Draw() { - // TODO this will actually draw the bar - // without having to redraw everything else -} - func (h *Headbar) Render(width int, theme string) string { maxMsgWidth := width - len([]rune(h.title)) - 2 if theme == "inverse" { diff --git a/main.go b/main.go index 4f8348a..f87b4d8 100644 --- a/main.go +++ b/main.go @@ -37,17 +37,19 @@ var settings config.Config func saveConfig() error { + var opts strings.Builder bkmrks := bombadillo.BookMarks.IniDump() - // TODO opts becomes a string builder rather than concat - opts := "\n[SETTINGS]\n" + + opts.WriteString(bkmrks) + opts.WriteString("\n[SETTINGS]\n") for k, v := range bombadillo.Options { - opts += k - opts += "=" - opts += v - opts += "\n" + opts.WriteString(k) + opts.WriteRune('=') + opts.WriteString(v) + opts.WriteRune('\n') } - return ioutil.WriteFile(bombadillo.Options["configlocation"] + "/.bombadillo.ini", []byte(bkmrks+opts), 0644) + return ioutil.WriteFile(bombadillo.Options["configlocation"] + "/.bombadillo.ini", []byte(opts.String()), 0644) } func loadConfig() error { @@ -100,9 +102,6 @@ func main() { panic(err) } - // TODO find out why the loading message - // has disappeared on initial load... - // Start polling for terminal size changes go bombadillo.GetSize() From 1af11f1b8f3b4a48016321ec952571c2c593b397 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 15 Sep 2019 21:26:32 -0700 Subject: [PATCH 010/145] Removes duplicated code in messaging system --- client.go | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/client.go b/client.go index e0abfa6..3aba883 100644 --- a/client.go +++ b/client.go @@ -563,23 +563,8 @@ func (c *client) SetMessage(msg string, isError bool) { } func (c *client) DrawMessage() { - leadIn, leadOut := "", "" - if c.Options["theme"] == "normal" { - leadIn = "\033[7m" - leadOut = "\033[0m" - } - - if c.MessageIsErr { - leadIn = "\033[31;1m" - leadOut = "\033[0m" - - if c.Options["theme"] == "normal" { - leadIn = "\033[41;1;7m" - } - } - cui.MoveCursorTo(c.Height-1, 0) - fmt.Printf("%s%-*.*s%s", leadIn, c.Width, c.Width, c.Message, leadOut) + fmt.Print(c.RenderMessage()) } func (c *client) RenderMessage() string { From 7e53ce6aea61531cb7e30cfcd62d91d73a20314c Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Mon, 16 Sep 2019 09:53:13 -0700 Subject: [PATCH 011/145] Fixed broken simple command: b --- client.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 3aba883..2800c35 100644 --- a/client.go +++ b/client.go @@ -82,7 +82,8 @@ func (c *client) GetSize() { func (c *client) Draw() { var screen strings.Builder - screen.Grow(c.Height * c.Width) + screen.Grow(c.Height * c.Width + c.Width) + screen.WriteString("\033[0m") screen.WriteString(c.TopBar.Render(c.Width, c.Options["theme"])) screen.WriteString("\n") pageContent := c.PageState.Render(c.Height, c.Width) @@ -121,7 +122,7 @@ func (c *client) Draw() { screen.WriteString(c.RenderMessage()) screen.WriteString("\n") // for the input line screen.WriteString(c.FootBar.Render(c.Width, c.PageState.Position, c.Options["theme"])) - cui.Clear("screen") + // cui.Clear("screen") cui.MoveCursorTo(0,0) fmt.Print(screen.String()) } @@ -216,7 +217,7 @@ func (c *client) TakeControlInput() { err := c.routeCommandInput(p) if err != nil { c.SetMessage(err.Error(), true) - c.DrawMessage() + c.Draw() } } } @@ -261,6 +262,7 @@ func (c *client) simpleCommand(action string) { } case "B", "BOOKMARKS": c.BookMarks.ToggleOpen() + c.Draw() case "SEARCH": c.search() case "HELP", "?": From 21fe5714a396e78e1a161e1127bfd943aa92d616 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Mon, 16 Sep 2019 19:38:07 -0700 Subject: [PATCH 012/145] Bookmarks can be scrolled when focused --- bookmarks.go | 18 ++++++---- client.go | 95 ++++++++++++++++++++++++++++++++++++---------------- cui/cui.go | 28 +++++++++------- 3 files changed, 93 insertions(+), 48 deletions(-) diff --git a/bookmarks.go b/bookmarks.go index a3eb82d..9647725 100644 --- a/bookmarks.go +++ b/bookmarks.go @@ -86,20 +86,24 @@ func (b Bookmarks) List() []string { func (b Bookmarks) Render(termwidth, termheight int) []string { width := 40 termheight -= 3 - var wall, ceil, tr, tl, br, bl string + var walll, wallr, floor, ceil, tr, tl, br, bl string if termwidth < 40 { width = termwidth } if b.IsFocused { - wall = cui.Shapes["awall"] + walll = cui.Shapes["awalll"] + wallr = cui.Shapes["awallr"] ceil = cui.Shapes["aceiling"] + floor = cui.Shapes["afloor"] tr = cui.Shapes["atr"] br = cui.Shapes["abr"] tl = cui.Shapes["atl"] bl = cui.Shapes["abl"] } else { - wall = cui.Shapes["wall"] + walll = cui.Shapes["walll"] + wallr = cui.Shapes["wallr"] ceil = cui.Shapes["ceiling"] + floor = cui.Shapes["floor"] tr = cui.Shapes["tr"] br = cui.Shapes["br"] tl = cui.Shapes["tl"] @@ -112,14 +116,14 @@ func (b Bookmarks) Render(termwidth, termheight int) []string { out = append(out, top) marks := b.List() for i := 0; i < termheight - 2; i++ { - if i + b.Position >= b.Length { - out = append(out, fmt.Sprintf("%s%-*.*s%s", wall, contentWidth, contentWidth, "", wall )) + if i + b.Position >= len(b.Titles) { + out = append(out, fmt.Sprintf("%s%-*.*s%s", walll, contentWidth, contentWidth, "", wallr)) } else { - out = append(out, fmt.Sprintf("%s%-*.*s%s", wall, contentWidth, contentWidth, marks[i + b.Position], wall )) + out = append(out, fmt.Sprintf("%s%-*.*s%s", walll, contentWidth, contentWidth, marks[i + b.Position], wallr)) } } - bottom := fmt.Sprintf("%s%s%s", bl, strings.Repeat(ceil, contentWidth), br) + bottom := fmt.Sprintf("%s%s%s", bl, strings.Repeat(floor, contentWidth), br) out = append(out, bottom) return out } diff --git a/client.go b/client.go index 2800c35..372a00d 100644 --- a/client.go +++ b/client.go @@ -102,8 +102,21 @@ func (c *client) Draw() { screen.WriteString(fmt.Sprintf("%-*.*s", contentWidth, contentWidth, " ")) } } + + if c.Options["theme"] == "inverse" && !c.BookMarks.IsFocused { + screen.WriteString("\033[2;7m") + } else if !c.BookMarks.IsFocused { + screen.WriteString("\033[2m") + } screen.WriteString(bm[i]) + + if c.Options["theme"] == "inverse" && !c.BookMarks.IsFocused { + screen.WriteString("\033[7;22m") + } else if !c.BookMarks.IsFocused { + screen.WriteString("\033[0m") + } + screen.WriteString("\n") } } else { @@ -514,39 +527,63 @@ func (c *client) search() { } func (c *client) Scroll(amount int) { - var percentRead int - page := c.PageState.History[c.PageState.Position] - bottom := len(page.WrappedContent) - c.Height + 3 // 3 for the three bars: top, msg, bottom - if amount < 0 && page.ScrollPosition == 0 { - c.SetMessage("You are already at the top", false) - c.DrawMessage() - fmt.Print("\a") - return - } else if (amount > 0 && page.ScrollPosition == bottom) || bottom < 0 { - c.FootBar.SetPercentRead(100) - c.SetMessage("You are already at the bottom", false) - c.DrawMessage() - fmt.Print("\a") - return - } + if c.BookMarks.IsFocused { + bottom := len(c.BookMarks.Titles) - c.Height + 5 // 3 for the three bars: top, msg, bottom + if amount < 0 && c.BookMarks.Position == 0 { + c.SetMessage("The bookmark ladder does not go up any further", false) + c.DrawMessage() + fmt.Print("\a") + return + } else if (amount > 0 && c.BookMarks.Position == bottom) || bottom < 0 { + c.SetMessage("Feel the ground beneath your bookmarks", false) + c.DrawMessage() + fmt.Print("\a") + return + } - newScrollPosition := page.ScrollPosition + amount - if newScrollPosition < 0 { - newScrollPosition = 0 - } else if newScrollPosition > bottom { - newScrollPosition = bottom - } + newScrollPosition := c.BookMarks.Position + amount + if newScrollPosition < 0 { + newScrollPosition = 0 + } else if newScrollPosition > bottom { + newScrollPosition = bottom + } - c.PageState.History[c.PageState.Position].ScrollPosition = newScrollPosition - - if len(page.WrappedContent) < c.Height - 3 { - percentRead = 100 + c.BookMarks.Position = newScrollPosition + c.Draw() } else { - percentRead = int(float32(newScrollPosition + c.Height - 3) / float32(len(page.WrappedContent)) * 100.0) - } - c.FootBar.SetPercentRead(percentRead) + var percentRead int + page := c.PageState.History[c.PageState.Position] + bottom := len(page.WrappedContent) - c.Height + 3 // 3 for the three bars: top, msg, bottom + if amount < 0 && page.ScrollPosition == 0 { + c.SetMessage("You are already at the top", false) + c.DrawMessage() + fmt.Print("\a") + return + } else if (amount > 0 && page.ScrollPosition == bottom) || bottom < 0 { + c.FootBar.SetPercentRead(100) + c.SetMessage("You are already at the bottom", false) + c.DrawMessage() + fmt.Print("\a") + return + } - c.Draw() + newScrollPosition := page.ScrollPosition + amount + if newScrollPosition < 0 { + newScrollPosition = 0 + } else if newScrollPosition > bottom { + newScrollPosition = bottom + } + + c.PageState.History[c.PageState.Position].ScrollPosition = newScrollPosition + + if len(page.WrappedContent) < c.Height - 3 { + percentRead = 100 + } else { + percentRead = int(float32(newScrollPosition + c.Height - 3) / float32(len(page.WrappedContent)) * 100.0) + } + c.FootBar.SetPercentRead(percentRead) + c.Draw() + } } func (c *client) displayConfigValue(setting string) { diff --git a/cui/cui.go b/cui/cui.go index 5cb5d79..e6cfb1c 100644 --- a/cui/cui.go +++ b/cui/cui.go @@ -10,18 +10,22 @@ import ( ) var Shapes = map[string]string{ - "wall": "╵", - "ceiling": "╴", - "tl": "┌", - "tr": "┐", - "bl": "└", - "br": "┘", - "awall": "║", - "aceiling": "═", - "atl": "╔", - "atr": "╗", - "abl": "╚", - "abr": "╝", + "walll": "╎", + "wallr": " ", + "ceiling": " ", + "floor": " ", + "tl": "╎", + "tr": " ", + "bl": "╎", + "br": " ", + "awalll": "▌", + "awallr": "▐", + "aceiling": "▀", + "afloor": "▄", + "atl": "▞", + "atr": "▜", + "abl": "▚", + "abr": "▟", } func drawShape(shape string) { From 8a3ddad58e9829bfe61d5c6990c1d1c0ec34c0d8 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Tue, 17 Sep 2019 21:57:21 -0700 Subject: [PATCH 013/145] Added ability to view a link's url with the check command --- .gitignore | 1 + client.go | 30 +++++++++++++---- gemini/gemini.go | 83 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 107 insertions(+), 7 deletions(-) create mode 100644 gemini/gemini.go diff --git a/.gitignore b/.gitignore index 9fe1ace..cb9380e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ bombadillo +*.asciinema diff --git a/client.go b/client.go index 372a00d..766bd96 100644 --- a/client.go +++ b/client.go @@ -386,16 +386,19 @@ func (c *client) doLinkCommandAs(action, target string, values []string) { return } + num -= 1 + + links := c.PageState.History[c.PageState.Position].Links + if num >= len(links) || num < 0 { + c.SetMessage(fmt.Sprintf("Invalid link id: %s", target), true) + c.DrawMessage() + return + } + switch action { case "ADD", "A": - links := c.PageState.History[c.PageState.Position].Links - if num >= len(links) { - c.SetMessage(fmt.Sprintf("Invalid link id: %s", target), true) - c.DrawMessage() - return - } bm := make([]string, 0, 5) - bm = append(bm, links[num-1]) + bm = append(bm, links[num]) bm = append(bm, values...) msg, err := c.BookMarks.Add(bm) if err != nil { @@ -455,6 +458,7 @@ func (c *client) doLinkCommand(action, target string) { c.DrawMessage() } + switch action { case "DELETE", "D": msg, err := c.BookMarks.Delete(num) @@ -482,6 +486,18 @@ func (c *client) doLinkCommand(action, target string) { return } c.Visit(c.BookMarks.Links[num]) + case "CHECK", "C": + num -= 1 + + links := c.PageState.History[c.PageState.Position].Links + if num >= len(links) || num < 0 { + c.SetMessage(fmt.Sprintf("Invalid link id: %s", target), true) + c.DrawMessage() + return + } + link := links[num] + c.SetMessage(fmt.Sprintf("[%d] %s", num + 1, link), false) + c.DrawMessage() default: c.SetMessage(fmt.Sprintf("Action %q does not exist for target %q", action, target), true) c.DrawMessage() diff --git a/gemini/gemini.go b/gemini/gemini.go new file mode 100644 index 0000000..d0f3ce9 --- /dev/null +++ b/gemini/gemini.go @@ -0,0 +1,83 @@ +package gemini + +import ( + "crypto/tls" + "fmt" + "net" + "io/ioutil" + // "strings" + "time" + + // "tildegit.org/sloum/mailcap" +) + + +//------------------------------------------------\\ +// + + + F U N C T I O N S + + + \\ +//--------------------------------------------------\\ + +func Retrieve(host, port, resource string) ([]byte, error) { + nullRes := make([]byte, 0) + timeOut := time.Duration(5) * time.Second + + if host == "" || port == "" { + return nullRes, fmt.Errorf("Incomplete request url") + } + + addr := host + ":" + port + + conf := &tls.Config{ + InsecureSkipVerify: true, + } + + conn, err := net.DialTimeout("tcp", addr, timeOut) + if err != nil { + return nullRes, err + } + + secureConn := tls.Client(conn, conf) + + send := resource + "\n" + + _, err = secureConn.Write([]byte(send)) + if err != nil { + return nullRes, err + } + + result, err := ioutil.ReadAll(conn) + if err != nil { + return nullRes, err + } + + return result, nil +} + +func Visit(host, port, resource string) (string, []string, error) { + resp, err := Retrieve(host, port, resource) + if err != nil { + return "", []string{}, err + } + + // TODO break out the header + // header := "" + mime := "" + mimeMaj := mime + mimeMin := mime + // status := "" + content := string(resp) + + if mimeMaj == "text" && mimeMin == "gemini" { + // text := string(resp) + // links := []string{} + + // TODO parse geminimap from 'content' + } else if mimeMaj == "text" { + // TODO just return the text + } else { + // TODO use mailcap to try and open the file + } + + + return content, []string{}, nil +} + From 7e4a32c67a27052d8326ac70d9ad4057f6bbad27 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Wed, 18 Sep 2019 20:27:56 -0700 Subject: [PATCH 014/145] Adds buggy but present gemini support --- client.go | 34 +++++++++-- gemini/gemini.go | 147 +++++++++++++++++++++++++++++++++++------------ url.go | 2 +- 3 files changed, 141 insertions(+), 42 deletions(-) diff --git a/client.go b/client.go index 766bd96..4a49108 100644 --- a/client.go +++ b/client.go @@ -14,7 +14,7 @@ import ( "tildegit.org/sloum/bombadillo/cmdparse" "tildegit.org/sloum/bombadillo/cui" - // "tildegit.org/sloum/bombadillo/gemini" + "tildegit.org/sloum/bombadillo/gemini" "tildegit.org/sloum/bombadillo/gopher" "tildegit.org/sloum/bombadillo/http" "tildegit.org/sloum/bombadillo/telnet" @@ -715,9 +715,35 @@ func (c *client) Visit(url string) { c.SetHeaderUrl() c.Draw() case "gemini": - // TODO send over to gemini request - c.SetMessage("Bombadillo has not mastered Gemini yet, check back soon", false) - c.DrawMessage() + capsule, err := gemini.Visit(u.Host, u.Port, u.Resource) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + switch capsule.Status { + case 2: + pg := MakePage(u, capsule.Content, capsule.Links) + pg.WrapContent(c.Width) + c.PageState.Add(pg) + c.Scroll(0) + c.ClearMessage() + c.SetHeaderUrl() + c.Draw() + case 3: + c.SetMessage("[3] Redirect. Follow redirect? y or any other key for no", false) + c.DrawMessage() + ch := cui.Getch() + if ch == 'y' || ch == 'Y' { + c.Visit(capsule.Content) + } else { + c.SetMessage("Redirect aborted", false) + c.DrawMessage() + } + } + + // c.SetMessage("Bombadillo has not mastered Gemini yet, check back soon", false) + // c.DrawMessage() case "telnet": c.SetMessage("Attempting to start telnet session", false) c.DrawMessage() diff --git a/gemini/gemini.go b/gemini/gemini.go index d0f3ce9..e8edee0 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -3,81 +3,154 @@ package gemini import ( "crypto/tls" "fmt" - "net" "io/ioutil" - // "strings" - "time" + "strconv" + "strings" // "tildegit.org/sloum/mailcap" ) +type Capsule struct { + MimeMaj string + MimeMin string + Status int + Content string + Links []string +} //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ -func Retrieve(host, port, resource string) ([]byte, error) { - nullRes := make([]byte, 0) - timeOut := time.Duration(5) * time.Second - +func Retrieve(host, port, resource string) (string, error) { if host == "" || port == "" { - return nullRes, fmt.Errorf("Incomplete request url") + return "", fmt.Errorf("Incomplete request url") } addr := host + ":" + port conf := &tls.Config{ + MinVersion: tls.VersionTLS12, InsecureSkipVerify: true, } - conn, err := net.DialTimeout("tcp", addr, timeOut) + conn, err := tls.Dial("tcp", addr, conf) if err != nil { - return nullRes, err + return "", err } - secureConn := tls.Client(conn, conf) + defer conn.Close() - send := resource + "\n" + send := "gemini://" + addr + "/" + resource + "\r\n" - _, err = secureConn.Write([]byte(send)) + _, err = conn.Write([]byte(send)) if err != nil { - return nullRes, err + return "", err } result, err := ioutil.ReadAll(conn) if err != nil { - return nullRes, err + return "", err } - return result, nil + return string(result), nil } -func Visit(host, port, resource string) (string, []string, error) { - resp, err := Retrieve(host, port, resource) +func Visit(host, port, resource string) (Capsule, error) { + capsule := MakeCapsule() + rawResp, err := Retrieve(host, port, resource) if err != nil { - return "", []string{}, err + return capsule, err } + + resp := strings.SplitN(rawResp, "\r\n", 2) + if len(resp) != 2 { + if err != nil { + return capsule, fmt.Errorf("Invalid response from server") + } + } + header := strings.SplitN(resp[0], " ", 2) + if len([]rune(header[0])) != 2 { + header = strings.SplitN(resp[0], "\t", 2) + if len([]rune(header[0])) != 2 { + return capsule, fmt.Errorf("Invalid response format from server") + } + } + + body := resp[1] - // TODO break out the header - // header := "" - mime := "" - mimeMaj := mime - mimeMin := mime - // status := "" - content := string(resp) - - if mimeMaj == "text" && mimeMin == "gemini" { - // text := string(resp) - // links := []string{} - - // TODO parse geminimap from 'content' - } else if mimeMaj == "text" { - // TODO just return the text - } else { - // TODO use mailcap to try and open the file + // Get status code single digit form + capsule.Status, err = strconv.Atoi(string(header[0][0])) + if err != nil { + return capsule, fmt.Errorf("Invalid status response from server") } + // Parse the meta as needed + var meta string - return content, []string{}, nil + switch capsule.Status { + case 1: + // handle search + return capsule, fmt.Errorf("Gemini input not yet supported") + case 2: + mimeAndCharset := strings.Split(header[1], ";") + meta = mimeAndCharset[0] + minMajMime := strings.Split(meta, "/") + if len(minMajMime) < 2 { + return capsule, fmt.Errorf("Improperly formatted mimetype received from server") + } + capsule.MimeMaj = minMajMime[0] + capsule.MimeMin = minMajMime[1] + if capsule.MimeMaj == "text" && capsule.MimeMin == "gemini" { + rootUrl := fmt.Sprintf("gemini://%s:%s", host, port) + capsule.Content, capsule.Links = parseGemini(body, rootUrl) + } else { + capsule.Content = body + } + return capsule, nil + case 3: + // The client will handle informing the user of a redirect + // and then request the new url + capsule.Content = header[1] + return capsule, nil + case 4: + return capsule, fmt.Errorf("[4] Temporary Failure. %s", header[1]) + case 5: + return capsule, fmt.Errorf("[5] Permanent Failure. %s", header[1]) + case 6: + return capsule, fmt.Errorf("[6] Client Certificate Required (Not supported by Bombadillo)") + default: + return capsule, fmt.Errorf("Invalid response status from server") + } +} + +func parseGemini(b, rootUrl string) (string, []string) { + splitContent := strings.Split(b, "\n") + links := make([]string, 0, 10) + + for i, ln := range splitContent { + splitContent[i] = strings.Trim(ln, "\r\n") + if len([]rune(ln)) > 3 && ln[:2] == "=>" { + trimmedSubLn := strings.Trim(ln[2:], "\r\n\t \a") + lineSplit := strings.SplitN(trimmedSubLn, " ", 2) + if len(lineSplit) != 2 { + lineSplit = append(lineSplit, lineSplit[0]) + } + lineSplit[0] = strings.Trim(lineSplit[0], "\t\n\r \a") + lineSplit[1] = strings.Trim(lineSplit[1], "\t\n\r \a") + if len(lineSplit[0]) > 0 && lineSplit[0][0] == '/' { + lineSplit[0] = fmt.Sprintf("%s%s", rootUrl, lineSplit[0]) + } + links = append(links, lineSplit[0]) + linknum := fmt.Sprintf("[%d]", len(links)) + splitContent[i] = fmt.Sprintf("%-5s %s", linknum, lineSplit[1]) + } + } + return strings.Join(splitContent, "\n"), links +} + + +func MakeCapsule() Capsule { + return Capsule{"", "", 0, "", make([]string, 0, 5)} } diff --git a/url.go b/url.go index faedbbb..5babdc8 100644 --- a/url.go +++ b/url.go @@ -97,8 +97,8 @@ func MakeUrl(u string) (Url, error) { out.DownloadOnly = true } } else { - out.Resource = fmt.Sprintf("%s%s", out.Mime, out.Resource) out.Mime = "" + out.Resource = fmt.Sprintf("%s%s", out.Mime, out.Resource) } if out.Scheme == "http" || out.Scheme == "https" { From 5114ac1a157717b042876d3e73c47cd758fe0cfb Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Wed, 18 Sep 2019 22:03:19 -0700 Subject: [PATCH 015/145] Updates gophermap rendering to support gemini urls as h URL:... style links --- gopher/gopher.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gopher/gopher.go b/gopher/gopher.go index dbf0d49..3b15440 100644 --- a/gopher/gopher.go +++ b/gopher/gopher.go @@ -171,7 +171,7 @@ func buildLink(host, port, gtype, resource string) string { case "h": u, tf := isWebLink(resource) if tf { - if len(u) > 4 && string(u[:4]) == "http" { + if strings.Index(u, "://") > 0 { return u } else { return fmt.Sprintf("http://%s", u) From 08795920159e960ab5ec1f67258cff5c071bb8bb Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 19 Sep 2019 15:32:26 -0700 Subject: [PATCH 016/145] Adds search with terms inline, also gemini file rendering --- client.go | 48 +++++++++++++++++++++++++++--------------------- gemini/gemini.go | 27 +++++++++++++++++---------- 2 files changed, 44 insertions(+), 31 deletions(-) diff --git a/client.go b/client.go index 4a49108..6d3aa28 100644 --- a/client.go +++ b/client.go @@ -277,7 +277,7 @@ func (c *client) simpleCommand(action string) { c.BookMarks.ToggleOpen() c.Draw() case "SEARCH": - c.search() + c.search("") case "HELP", "?": go c.Visit(helplocation) default: @@ -296,6 +296,8 @@ func (c *client) doCommand(action string, values []string) { switch action { case "CHECK", "C": c.displayConfigValue(values[0]) + case "SEARCH": + c.search(strings.Join(values, " ")) default: c.SetMessage(fmt.Sprintf("Unknown action %q", action), true) c.DrawMessage() @@ -505,21 +507,27 @@ func (c *client) doLinkCommand(action, target string) { } -func (c *client) search() { - c.ClearMessage() - c.ClearMessageLine() - // TODO handle keeping the full command bar here - // like was done for regular command entry - // maybe split into separate function - fmt.Print("?") - entry, err := cui.GetLine() - c.ClearMessageLine() - if err != nil { - c.SetMessage(err.Error(), true) - c.DrawMessage() - return - } else if strings.TrimSpace(entry) == "" { - return +func (c *client) search(q string) { + var entry string + var err error + if q == "" { + c.ClearMessage() + c.ClearMessageLine() + if c.Options["theme"] == "normal" { + fmt.Printf("\033[7m%*.*s\r", c.Width, c.Width, "") + } + fmt.Print("?") + entry, err = cui.GetLine() + c.ClearMessageLine() + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } else if strings.TrimSpace(entry) == "" { + return + } + } else { + entry = q } u, err := MakeUrl(c.Options["searchengine"]) if err != nil { @@ -614,7 +622,7 @@ func (c *client) displayConfigValue(setting string) { func (c *client) SetMessage(msg string, isError bool) { c.MessageIsErr = isError - c.Message = msg + c.Message = strings.ReplaceAll(msg, "\t", "%09") } func (c *client) DrawMessage() { @@ -682,7 +690,7 @@ func (c *client) goToLink(l string) { func (c *client) SetHeaderUrl() { if c.PageState.Length > 0 { u := c.PageState.History[c.PageState.Position].Location.Full - c.TopBar.url = u + c.TopBar.url = strings.ReplaceAll(u, "\t", "%09") } else { c.TopBar.url = "" } @@ -692,6 +700,7 @@ func (c *client) Visit(url string) { c.SetMessage("Loading...", false) c.DrawMessage() + url = strings.ReplaceAll(url, "%09", "\t") u, err := MakeUrl(url) if err != nil { c.SetMessage(err.Error(), true) @@ -741,9 +750,6 @@ func (c *client) Visit(url string) { c.DrawMessage() } } - - // c.SetMessage("Bombadillo has not mastered Gemini yet, check back soon", false) - // c.DrawMessage() case "telnet": c.SetMessage("Attempting to start telnet session", false) c.DrawMessage() diff --git a/gemini/gemini.go b/gemini/gemini.go index e8edee0..f2fd88c 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -131,19 +131,26 @@ func parseGemini(b, rootUrl string) (string, []string) { for i, ln := range splitContent { splitContent[i] = strings.Trim(ln, "\r\n") if len([]rune(ln)) > 3 && ln[:2] == "=>" { - trimmedSubLn := strings.Trim(ln[2:], "\r\n\t \a") - lineSplit := strings.SplitN(trimmedSubLn, " ", 2) - if len(lineSplit) != 2 { - lineSplit = append(lineSplit, lineSplit[0]) + var link, decorator string + subLn := strings.Trim(ln[2:], "\r\n\t \a") + splitPoint := strings.IndexAny(subLn, " \t") + + if splitPoint < 0 || len([]rune(subLn)) - 1 <= splitPoint { + link = subLn + decorator = subLn + } else { + link = strings.Trim(subLn[:splitPoint], "\t\n\r \a") + decorator = strings.Trim(subLn[splitPoint:], "\t\n\r \a") } - lineSplit[0] = strings.Trim(lineSplit[0], "\t\n\r \a") - lineSplit[1] = strings.Trim(lineSplit[1], "\t\n\r \a") - if len(lineSplit[0]) > 0 && lineSplit[0][0] == '/' { - lineSplit[0] = fmt.Sprintf("%s%s", rootUrl, lineSplit[0]) + + if len(link) > 0 && link[0] == '/' { + link = fmt.Sprintf("%s%s", rootUrl, link) + } else if len(link) > 0 && strings.Index(link, "://") < 0 { + link = fmt.Sprintf("%s/%s", rootUrl, link) } - links = append(links, lineSplit[0]) + links = append(links, link) linknum := fmt.Sprintf("[%d]", len(links)) - splitContent[i] = fmt.Sprintf("%-5s %s", linknum, lineSplit[1]) + splitContent[i] = fmt.Sprintf("%-5s %s", linknum, decorator) } } return strings.Join(splitContent, "\n"), links From fdaf6312aba7c58d267479a969d77cb1db710867 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 19 Sep 2019 20:29:17 -0700 Subject: [PATCH 017/145] Adds a terminal mode change to disallow line wrapping by the terminal, also fixes a resize scroll issue and disallows escape characters in text files --- client.go | 21 +++++++++++++-------- cui/cui.go | 1 + main.go | 1 + page.go | 7 +++---- 4 files changed, 18 insertions(+), 12 deletions(-) diff --git a/client.go b/client.go index 6d3aa28..544cf56 100644 --- a/client.go +++ b/client.go @@ -73,7 +73,7 @@ func (c *client) GetSize() { if h != c.Height || w != c.Width { c.Height = h c.Width = w - c.Draw() + c.Scroll(0) } time.Sleep(500 * time.Millisecond) @@ -732,13 +732,18 @@ func (c *client) Visit(url string) { } switch capsule.Status { case 2: - pg := MakePage(u, capsule.Content, capsule.Links) - pg.WrapContent(c.Width) - c.PageState.Add(pg) - c.Scroll(0) - c.ClearMessage() - c.SetHeaderUrl() - c.Draw() + if capsule.MimeMaj == "text" { + pg := MakePage(u, capsule.Content, capsule.Links) + pg.WrapContent(c.Width) + c.PageState.Add(pg) + c.Scroll(0) + c.ClearMessage() + c.SetHeaderUrl() + c.Draw() + } else { + c.SetMessage("Still mulling how to handle binary files... come back soon", false) + c.DrawMessage() + } case 3: c.SetMessage("[3] Redirect. Follow redirect? y or any other key for no", false) c.DrawMessage() diff --git a/cui/cui.go b/cui/cui.go index e6cfb1c..deb69ea 100644 --- a/cui/cui.go +++ b/cui/cui.go @@ -65,6 +65,7 @@ func Exit() { fmt.Print("\n") fmt.Print("\033[?25h") + HandleAlternateScreen("smam") HandleAlternateScreen("rmcup") os.Exit(0) } diff --git a/main.go b/main.go index f87b4d8..b738899 100644 --- a/main.go +++ b/main.go @@ -94,6 +94,7 @@ func initClient() error { } func main() { + cui.HandleAlternateScreen("rmam") cui.HandleAlternateScreen("smcup") defer cui.Exit() err := initClient() diff --git a/page.go b/page.go index 20514b6..ee8b68c 100644 --- a/page.go +++ b/page.go @@ -46,7 +46,7 @@ func (p *Page) WrapContent(width int) { counter := 0 var content strings.Builder content.Grow(len(p.RawContent)) - for _, ch := range p.RawContent { + for _, ch := range []rune(p.RawContent) { if ch == '\n' { content.WriteRune(ch) counter = 0 @@ -58,9 +58,8 @@ func (p *Page) WrapContent(width int) { content.WriteRune('\n') counter = 0 } - } else if ch == '\r' { - // This handles non-linux line endings... - // to some degree... + } else if ch == '\r' || ch == '\v' || ch == '\b' || ch == '\f' || ch == 27 { + // Get rid of control characters we dont want continue } else { if counter < width { From 8c42748432874c7ac83c2f50fbbaf4caf82279ff Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 19 Sep 2019 21:29:52 -0700 Subject: [PATCH 018/145] Fixes issue where percent read was incorrect when moving through history --- client.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index 544cf56..da0a40f 100644 --- a/client.go +++ b/client.go @@ -101,6 +101,7 @@ func (c *client) Draw() { } else { screen.WriteString(fmt.Sprintf("%-*.*s", contentWidth, contentWidth, " ")) } + screen.WriteString("\033[500C\033[39D") } if c.Options["theme"] == "inverse" && !c.BookMarks.IsFocused { @@ -125,7 +126,7 @@ func (c *client) Draw() { screen.WriteString(fmt.Sprintf("%-*.*s", c.Width, c.Width, pageContent[i])) screen.WriteString("\n") } else { - screen.WriteString(fmt.Sprintf("%*s", c.Width, " ")) + screen.WriteString(fmt.Sprintf("%*.*s", c.Width, c.Width, " ")) screen.WriteString("\n") } } @@ -182,6 +183,7 @@ func (c *client) TakeControlInput() { c.DrawMessage() } else { c.SetHeaderUrl() + c.SetPercentRead() c.Draw() } case 'B': @@ -197,6 +199,7 @@ func (c *client) TakeControlInput() { c.DrawMessage() } else { c.SetHeaderUrl() + c.SetPercentRead() c.Draw() } case '\t': @@ -610,6 +613,17 @@ func (c *client) Scroll(amount int) { } } +func (c *client) SetPercentRead() { + page := c.PageState.History[c.PageState.Position] + var percentRead int + if len(page.WrappedContent) < c.Height - 3 { + percentRead = 100 + } else { + percentRead = int(float32(page.ScrollPosition + c.Height - 3) / float32(len(page.WrappedContent)) * 100.0) + } + c.FootBar.SetPercentRead(percentRead) +} + func (c *client) displayConfigValue(setting string) { if val, ok := c.Options[setting]; ok { c.SetMessage(fmt.Sprintf("%s is set to: %q", setting, val), false) From 19f210f2431a1cbc58b0a11784354d73d0376a0f Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Fri, 20 Sep 2019 09:18:16 -0700 Subject: [PATCH 019/145] Renames a cui function to be more appropriate and adds command line flag for version number --- cui/cui.go | 6 +++--- main.go | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/cui/cui.go b/cui/cui.go index deb69ea..6fe79b5 100644 --- a/cui/cui.go +++ b/cui/cui.go @@ -65,8 +65,8 @@ func Exit() { fmt.Print("\n") fmt.Print("\033[?25h") - HandleAlternateScreen("smam") - HandleAlternateScreen("rmcup") + Tput("smam") // turn off line wrap + Tput("rmcup") // use alternate screen os.Exit(0) } @@ -178,7 +178,7 @@ func SetLineMode() { } } -func HandleAlternateScreen(opt string) { +func Tput(opt string) { cmd := exec.Command("tput", opt) cmd.Stdin = os.Stdin cmd.Stdout = os.Stdout diff --git a/main.go b/main.go index b738899..b5b8a01 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,8 @@ package main // the terms of said license with said license file included. import ( + "flag" + "fmt" "io/ioutil" "os" "strings" @@ -15,6 +17,8 @@ import ( "tildegit.org/sloum/bombadillo/cui" ) +const version = "2.0.0" + var bombadillo *client var helplocation string = "gopher://colorfield.space:70/1/bombadillo-info" var settings config.Config @@ -94,8 +98,16 @@ func initClient() error { } func main() { - cui.HandleAlternateScreen("rmam") - cui.HandleAlternateScreen("smcup") + getVersion := flag.Bool("v", false, "See version number") + flag.Parse() + if *getVersion { + fmt.Printf("Bombadillo v%s\n", version) + os.Exit(0) + } + args := flag.Args() + + cui.Tput("rmam") // turn off line wrapping + cui.Tput("smcup") // use alternate screen defer cui.Exit() err := initClient() if err != nil { @@ -106,11 +118,11 @@ func main() { // Start polling for terminal size changes go bombadillo.GetSize() - if len(os.Args) > 1 { + if len(args) > 0 { // If a url was passed, move it down the line // Goroutine so keypresses can be made during // page load - bombadillo.Visit(os.Args[1]) + bombadillo.Visit(args[0]) } else { // Otherwise, load the homeurl // Goroutine so keypresses can be made during From db1cf75d2efbd2b5b5e52cb9177b1dfca0290593 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Fri, 20 Sep 2019 16:15:53 -0700 Subject: [PATCH 020/145] Cleans up some display issues --- bookmarks.go | 1 + client.go | 183 +++++++++++++++++++++++++---------------------- defaults.go | 28 -------- gemini/gemini.go | 47 ++++++++++++ main.go | 2 +- 5 files changed, 146 insertions(+), 115 deletions(-) diff --git a/bookmarks.go b/bookmarks.go index 9647725..cb2b773 100644 --- a/bookmarks.go +++ b/bookmarks.go @@ -50,6 +50,7 @@ func (b *Bookmarks) ToggleOpen() { b.IsFocused = true } else { b.IsFocused = false + cui.Clear("screen") } } diff --git a/client.go b/client.go index da0a40f..07be1c7 100644 --- a/client.go +++ b/client.go @@ -3,7 +3,6 @@ package main import ( "fmt" "io/ioutil" - "net" "os" "os/exec" // "os/user" @@ -73,7 +72,8 @@ func (c *client) GetSize() { if h != c.Height || w != c.Width { c.Height = h c.Width = w - c.Scroll(0) + c.SetPercentRead() + c.Draw() } time.Sleep(500 * time.Millisecond) @@ -86,7 +86,7 @@ func (c *client) Draw() { screen.WriteString("\033[0m") screen.WriteString(c.TopBar.Render(c.Width, c.Options["theme"])) screen.WriteString("\n") - pageContent := c.PageState.Render(c.Height, c.Width) + pageContent := c.PageState.Render(c.Height, c.Width - 1) if c.Options["theme"] == "inverse" { screen.WriteString("\033[7m") } @@ -122,11 +122,11 @@ func (c *client) Draw() { } } else { for i := 0; i < c.Height - 3; i++ { - if i < len(pageContent) - 1 { - screen.WriteString(fmt.Sprintf("%-*.*s", c.Width, c.Width, pageContent[i])) + if i < len(pageContent) { + screen.WriteString(fmt.Sprintf("%-*.*s", c.Width - 1, c.Width - 1, pageContent[i])) screen.WriteString("\n") } else { - screen.WriteString(fmt.Sprintf("%*.*s", c.Width, c.Width, " ")) + screen.WriteString(fmt.Sprintf("%-*.*s", c.Width, c.Width, " ")) screen.WriteString("\n") } } @@ -301,6 +301,28 @@ func (c *client) doCommand(action string, values []string) { c.displayConfigValue(values[0]) case "SEARCH": c.search(strings.Join(values, " ")) + case "WRITE", "W": + if values[0] == "." { + values[0] = c.PageState.History[c.PageState.Position].Location.Full + } + u, err := MakeUrl(values[0]) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + fns := strings.Split(u.Resource, "/") + var fn string + if len(fns) > 0 { + fn = strings.Trim(fns[len(fns) - 1], "\t\r\n \a\f\v") + } else { + fn = "index" + } + if fn == "" { + fn = "index" + } + c.saveFile(u, fn) + default: c.SetMessage(fmt.Sprintf("Unknown action %q", action), true) c.DrawMessage() @@ -340,28 +362,15 @@ func (c *client) doCommandAs(action string, values []string) { } case "WRITE", "W": - // TODO figure out how best to handle file - // writing... it will depend on request model - // using fetch would be best - // - - - - - - - - - - - - - - - - - - - - - - // var data []byte - // if values[0] == "." { - // d, err := c.getCurrentPageRawData() - // if err != nil { - // c.SetMessage(err.Error(), true) - // c.DrawMessage() - // return - // } - // data = []byte(d) - // } - // fp, err := c.saveFile(data, strings.Join(values[1:], " ")) - // if err != nil { - // c.SetMessage(err.Error(), true) - // c.DrawMessage() - // return - // } - // c.SetMessage(fmt.Sprintf("File saved to: %s", fp), false) - // c.DrawMessage() + u, err := MakeUrl(values[0]) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + fileName := strings.Join(values[1:], "-") + fileName = strings.Trim(fileName, " \t\r\n\a\f\v") + c.saveFile(u, fileName) case "SET", "S": if _, ok := c.Options[values[0]]; ok { @@ -424,8 +433,10 @@ func (c *client) doLinkCommandAs(action, target string, values []string) { c.Draw() } case "WRITE", "W": - // TODO get file writing working in some semblance of universal way - // return saveFile(links[num-1], strings.Join(values, " ")) + out := make([]string, 0, len(values) + 1) + out = append(out, links[num]) + out = append(out, values...) + c.doCommandAs(action, out) default: c.SetMessage(fmt.Sprintf("Unknown command structure"), true) } @@ -446,14 +457,35 @@ func (c *client) getCurrentPageRawData() (string, error) { return c.PageState.History[c.PageState.Position].RawContent, nil } -func (c *client) saveFile(data []byte, name string) (string, error) { - savePath := c.Options["savelocation"] + name - err := ioutil.WriteFile(savePath, data, 0644) - if err != nil { - return "", err +func (c *client) saveFile(u Url, name string) { + var file []byte + var err error + switch u.Scheme { + case "gopher": + file, err = gopher.Retrieve(u.Host, u.Port, u.Resource) + case "gemini": + file, err = gemini.Fetch(u.Host, u.Port, u.Resource) + default: + c.SetMessage(fmt.Sprintf("Saving files over %s is not supported", u.Scheme), true) + c.DrawMessage() + return } - return savePath, nil + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + savePath := c.Options["savelocation"] + name + err = ioutil.WriteFile(savePath, file, 0644) + if err != nil { + c.SetMessage("Error writing file to disk", true) + c.DrawMessage() + return + } + + c.SetMessage(fmt.Sprintf("File saved to: %s", savePath), false) + c.DrawMessage() } func (c *client) doLinkCommand(action, target string) { @@ -503,6 +535,30 @@ func (c *client) doLinkCommand(action, target string) { link := links[num] c.SetMessage(fmt.Sprintf("[%d] %s", num + 1, link), false) c.DrawMessage() + case "WRITE", "W": + links := c.PageState.History[c.PageState.Position].Links + if len(links) < num || num < 1 { + c.SetMessage("Invalid link ID", true) + c.DrawMessage() + return + } + u, err := MakeUrl(links[num-1]) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + fns := strings.Split(u.Resource, "/") + var fn string + if len(fns) > 0 { + fn = strings.Trim(fns[len(fns) - 1], "\t\r\n \a\f\v") + } else { + fn = "index" + } + if fn == "" { + fn = "index" + } + c.saveFile(u, fn) default: c.SetMessage(fmt.Sprintf("Action %q does not exist for target %q", action, target), true) c.DrawMessage() @@ -576,7 +632,6 @@ func (c *client) Scroll(amount int) { } c.BookMarks.Position = newScrollPosition - c.Draw() } else { var percentRead int page := c.PageState.History[c.PageState.Position] @@ -609,8 +664,8 @@ func (c *client) Scroll(amount int) { percentRead = int(float32(newScrollPosition + c.Height - 3) / float32(len(page.WrappedContent)) * 100.0) } c.FootBar.SetPercentRead(percentRead) - c.Draw() } + c.Draw() } func (c *client) SetPercentRead() { @@ -731,9 +786,9 @@ func (c *client) Visit(url string) { return } pg := MakePage(u, content, links) - pg.WrapContent(c.Width) + pg.WrapContent(c.Width - 1) c.PageState.Add(pg) - c.Scroll(0) // to update percent read + c.SetPercentRead() c.ClearMessage() c.SetHeaderUrl() c.Draw() @@ -748,9 +803,9 @@ func (c *client) Visit(url string) { case 2: if capsule.MimeMaj == "text" { pg := MakePage(u, capsule.Content, capsule.Links) - pg.WrapContent(c.Width) + pg.WrapContent(c.Width - 1) c.PageState.Add(pg) - c.Scroll(0) + c.SetPercentRead() c.ClearMessage() c.SetHeaderUrl() c.Draw() @@ -808,51 +863,7 @@ func (c *client) Visit(url string) { //--------------------------------------------------\\ func MakeClient(name string) *client { - // var userinfo, _ = user.Current() - // var options = map[string]string{ - // "homeurl": "gopher://colorfield.space:70/1/bombadillo-info", - // "savelocation": userinfo.HomeDir, - // "searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs", - // "openhttp": "false", - // "httpbrowser": "lynx", - // "configlocation": userinfo.HomeDir, - // } c := client{0, 0, defaultOptions, "", false, MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar()} return &c } -// Retrieve a byte slice of raw response dataa -// from a url string -func Fetch(url string) ([]byte, error) { - u, err := MakeUrl(url) - if err != nil { - return []byte(""), err - } - - timeOut := time.Duration(5) * time.Second - - if u.Host == "" || u.Port == "" { - return []byte(""), fmt.Errorf("Incomplete request url") - } - - addr := u.Host + ":" + u.Port - - conn, err := net.DialTimeout("tcp", addr, timeOut) - if err != nil { - return []byte(""), err - } - - send := u.Resource + "\n" - - _, err = conn.Write([]byte(send)) - if err != nil { - return []byte(""), err - } - - result, err := ioutil.ReadAll(conn) - if err != nil { - return []byte(""), err - } - - return result, err -} diff --git a/defaults.go b/defaults.go index 87fa557..2d8ac8c 100644 --- a/defaults.go +++ b/defaults.go @@ -19,31 +19,3 @@ var defaultOptions = map[string]string{ "theme": "normal", // "normal", "inverted" } -// TODO decide whether or not to institute a color theme -// system. Preliminary testing implies it should be very -// doable. -var theme = map[string]string{ - "topbar_title_bg": "", - "topbar_link_fg": "", - "body_bg": "237", - "body_fg": "", - "bookmarks_bg": "", - "bookmarks_fg": "", - "command_bg": "", - "message_fg": "", - "error_fg": "", - "bottombar_bg": "", - "bottombar_fg": "", - // - // text style options - // - "topbar_title_style": "bold", - "topbar_link_style": "plain", - "body_style": "plain", - "bookmark_body_style": "plain", - "bookmark_border_style": "plain", - "message_style": "italic", - "error_style": "bold", - "command_style": "plain", - "bottom_bar_style": "plain", -} diff --git a/gemini/gemini.go b/gemini/gemini.go index f2fd88c..91755f4 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -56,6 +56,53 @@ func Retrieve(host, port, resource string) (string, error) { return string(result), nil } +func Fetch(host, port, resource string) ([]byte, error) { + rawResp, err := Retrieve(host, port, resource) + if err != nil { + return make([]byte, 0), err + } + + resp := strings.SplitN(rawResp, "\r\n", 2) + if len(resp) != 2 { + if err != nil { + return make([]byte, 0), fmt.Errorf("Invalid response from server") + } + } + header := strings.SplitN(resp[0], " ", 2) + if len([]rune(header[0])) != 2 { + header = strings.SplitN(resp[0], "\t", 2) + if len([]rune(header[0])) != 2 { + return make([]byte,0), fmt.Errorf("Invalid response format from server") + } + } + + // Get status code single digit form + status, err := strconv.Atoi(string(header[0][0])) + if err != nil { + return make([]byte, 0), fmt.Errorf("Invalid status response from server") + } + + if status != 2 { + switch status { + case 1: + return make([]byte, 0), fmt.Errorf("[1] Queries cannot be saved.") + case 3: + return make([]byte, 0), fmt.Errorf("[3] Redirects cannot be saved.") + case 4: + return make([]byte, 0), fmt.Errorf("[4] Temporary Failure.") + case 5: + return make([]byte, 0), fmt.Errorf("[5] Permanent Failure.") + case 6: + return make([]byte, 0), fmt.Errorf("[6] Client Certificate Required (Not supported by Bombadillo)") + default: + return make([]byte, 0), fmt.Errorf("Invalid response status from server") + } + } + + return []byte(resp[1]), nil + +} + func Visit(host, port, resource string) (Capsule, error) { capsule := MakeCapsule() rawResp, err := Retrieve(host, port, resource) diff --git a/main.go b/main.go index b5b8a01..0e5c803 100644 --- a/main.go +++ b/main.go @@ -106,7 +106,7 @@ func main() { } args := flag.Args() - cui.Tput("rmam") // turn off line wrapping + cui.Tput("rmam") // turn off line wrapping cui.Tput("smcup") // use alternate screen defer cui.Exit() err := initClient() From 1050b858dd1b741a12df4a3aac146b979c58e2c4 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Fri, 20 Sep 2019 18:24:12 -0700 Subject: [PATCH 021/145] Finished working through file saving for gopher and gemini, and added mailcap functionality to gemini --- client.go | 107 +++++++++++++++++++++++++++++++++++++++++++++------- defaults.go | 1 + main.go | 23 +++-------- 3 files changed, 100 insertions(+), 31 deletions(-) diff --git a/client.go b/client.go index 07be1c7..4ff6a05 100644 --- a/client.go +++ b/client.go @@ -5,7 +5,6 @@ import ( "io/ioutil" "os" "os/exec" - // "os/user" "regexp" "strconv" "strings" @@ -17,6 +16,7 @@ import ( "tildegit.org/sloum/bombadillo/gopher" "tildegit.org/sloum/bombadillo/http" "tildegit.org/sloum/bombadillo/telnet" + // "tildegit.org/sloum/mailcap" ) //------------------------------------------------\\ @@ -460,6 +460,8 @@ func (c *client) getCurrentPageRawData() (string, error) { func (c *client) saveFile(u Url, name string) { var file []byte var err error + c.SetMessage(fmt.Sprintf("Saving %s ...", name), false) + c.DrawMessage() switch u.Scheme { case "gopher": file, err = gopher.Retrieve(u.Host, u.Port, u.Resource) @@ -488,6 +490,22 @@ func (c *client) saveFile(u Url, name string) { c.DrawMessage() } +func (c *client) saveFileFromData(d, name string) { + data := []byte(d) + c.SetMessage(fmt.Sprintf("Saving %s ...", name), false) + c.DrawMessage() + savePath := c.Options["savelocation"] + name + err := ioutil.WriteFile(savePath, data, 0644) + if err != nil { + c.SetMessage("Error writing file to disk", true) + c.DrawMessage() + return + } + + c.SetMessage(fmt.Sprintf("File saved to: %s", savePath), false) + c.DrawMessage() +} + func (c *client) doLinkCommand(action, target string) { num, err := strconv.Atoi(target) if err != nil { @@ -779,19 +797,29 @@ func (c *client) Visit(url string) { switch u.Scheme { case "gopher": - content, links, err := gopher.Visit(u.Mime, u.Host, u.Port, u.Resource) - if err != nil { - c.SetMessage(err.Error(), true) - c.DrawMessage() - return + if u.DownloadOnly { + nameSplit := strings.Split(u.Resource, "/") + filename := nameSplit[len(nameSplit) - 1] + filename = strings.Trim(filename, " \t\r\n\v\f\a") + if filename == "" { + filename = "gopherfile" + } + c.saveFile(u, filename) + } else { + content, links, err := gopher.Visit(u.Mime, u.Host, u.Port, u.Resource) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + pg := MakePage(u, content, links) + pg.WrapContent(c.Width - 1) + c.PageState.Add(pg) + c.SetPercentRead() + c.ClearMessage() + c.SetHeaderUrl() + c.Draw() } - pg := MakePage(u, content, links) - pg.WrapContent(c.Width - 1) - c.PageState.Add(pg) - c.SetPercentRead() - c.ClearMessage() - c.SetHeaderUrl() - c.Draw() case "gemini": capsule, err := gemini.Visit(u.Host, u.Port, u.Resource) if err != nil { @@ -810,8 +838,59 @@ func (c *client) Visit(url string) { c.SetHeaderUrl() c.Draw() } else { - c.SetMessage("Still mulling how to handle binary files... come back soon", false) + c.SetMessage("The file is non-text: (o)pen or (w)rite to disk", false) c.DrawMessage() + var ch rune + for { + ch = cui.Getch() + if ch == 'o' || ch == 'w' { + break + } + } + switch ch { + case 'o': + mime := fmt.Sprintf("%s/%s", capsule.MimeMaj, capsule.MimeMin) + var term bool + if c.Options["terminalonly"] == "true" { + term = true + } else { + term = false + } + mcEntry, err := mc.FindMatch(mime, "view", term) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + file, err := ioutil.TempFile("/tmp/", "bombadillo-*.tmp") + if err != nil { + c.SetMessage("Unable to create temporary file for opening, aborting file open", true) + c.DrawMessage() + return + } + // defer os.Remove(file.Name()) + file.Write([]byte(capsule.Content)) + com, e := mcEntry.Command(file.Name()) + if e != nil { + c.SetMessage(e.Error(), true) + c.DrawMessage() + return + } + com.Stdin = os.Stdin + com.Stdout = os.Stdout + com.Stderr = os.Stderr + if c.Options["terminalonly"] == "true" { + cui.Clear("screen") + } + com.Run() + c.SetMessage("File opened by an appropriate program", true) + c.DrawMessage() + c.Draw() + case 'w': + nameSplit := strings.Split(u.Resource, "/") + filename := nameSplit[len(nameSplit) - 1] + c.saveFileFromData(capsule.Content, filename) + } } case 3: c.SetMessage("[3] Redirect. Follow redirect? y or any other key for no", false) diff --git a/defaults.go b/defaults.go index 2d8ac8c..8d744de 100644 --- a/defaults.go +++ b/defaults.go @@ -17,5 +17,6 @@ var defaultOptions = map[string]string{ "telnetcommand": "telnet", "configlocation": userinfo.HomeDir, "theme": "normal", // "normal", "inverted" + "terminalonly": "true", } diff --git a/main.go b/main.go index 0e5c803..1e7c6bc 100644 --- a/main.go +++ b/main.go @@ -15,6 +15,7 @@ import ( "tildegit.org/sloum/bombadillo/config" "tildegit.org/sloum/bombadillo/cui" + "tildegit.org/sloum/mailcap" ) const version = "2.0.0" @@ -22,23 +23,7 @@ const version = "2.0.0" var bombadillo *client var helplocation string = "gopher://colorfield.space:70/1/bombadillo-info" var settings config.Config - - -// func saveFileFromData(v gopher.View) error { - // quickMessage("Saving file...", false) - // urlsplit := strings.Split(v.Address.Full, "/") - // filename := urlsplit[len(urlsplit)-1] - // saveMsg := fmt.Sprintf("Saved file as %q", options["savelocation"]+filename) - // err := ioutil.WriteFile(options["savelocation"]+filename, []byte(strings.Join(v.Content, "")), 0644) - // if err != nil { - // quickMessage("Saving file...", true) - // return err - // } - - // quickMessage(saveMsg, false) - // return nil -// } - +var mc *mailcap.Mailcap func saveConfig() error { var opts strings.Builder @@ -106,6 +91,10 @@ func main() { } args := flag.Args() + // Build the mailcap db + // So that we can open files from gemini + mc = mailcap.NewMailcap() + cui.Tput("rmam") // turn off line wrapping cui.Tput("smcup") // use alternate screen defer cui.Exit() From 2f14011a486eb34eece358f9d55439f063aab261 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 21 Sep 2019 14:12:18 -0700 Subject: [PATCH 022/145] Adds temporary ability to not add invalid value for theme. Also adds a temporary first draft of a manpage for bombadillo. --- bombadillo.1 | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++ client.go | 8 +- defaults.go | 3 + main.go | 7 ++ 4 files changed, 218 insertions(+), 1 deletion(-) create mode 100644 bombadillo.1 diff --git a/bombadillo.1 b/bombadillo.1 new file mode 100644 index 0000000..1d28a72 --- /dev/null +++ b/bombadillo.1 @@ -0,0 +1,201 @@ +." Text automatically generated by txt2man +.TH "bombadillo" 1 "21 SEP 2019" "" "General Opperation Manual" +.SH NAME +\fBbombadillo \fP- a non-web client +.SH SYNOPSIS +.nf +.fam C +\fBbombadillo\fP [\fB-v\fP] [\fB-h\fP] [\fIurl\fP] +.fam T +.fi +.SH DESCRIPTION +\fBbombadillo\fP is a terminal based client for a number of internet protocols, including gopher and gemini. \fBbombadillo\fP will also connect links to a user's default web browser or telnet client. Commands input is loosely based on Vi and Less and is comprised of two modes: key and line input mode. +.SH OPTIONS +.TP +.B +\fB-v\fP +Display the version number of \fBbombadillo\fP. +.TP +.B +\fB-h\fP +Usage help. Displays all command line options with a short description. +.SH COMMANDS +.SS KEY COMMANDS +These commands work as a single keypress anytime \fBbombadillo\fP is not taking in a line based command. This is the default command mode of \fBbombadillo\fP. +.TP +.B +b +Navigate back one place in your document history. +.TP +.B +B +Toggle the bookmarks panel open/closed. +.TP +.B +d +Scroll down an amount corresponding to 75% of your terminal window height in the current document. +.TP +.B +f +Navigate forward one place in your document history. +.TP +.B +g +Scroll to the top of the current document. +.TP +.B +G +Scroll to the bottom of the current document. +.TP +.B +j +Scroll down a single line in the current document. +.TP +.B +k +Scroll up a single line. +.TP +.B +q +Quit \fBbombadillo\fP. +.TP +.B +u +Scroll up an amount corresponding to 75% of your terminal window height in the current document. +.TP +.B + +Toggle the scroll focus between the bookmarks panel and the document panel. Only has an effect if the bookmarks panel is open. +.TP +.B + +Enter line command mode. Once a line command is input, the mode will automatically revert to key command mode. +.TP +.B +: +Alias for . Enter line command mode. +.SS LINE COMMANDS +These commands are typed in by the user to perform an action of some sort. As listed in KEY COMMANDS, this mode is initiated by pressing : or . The command names themselves are not case sensitive, though the arguments supplied to them may be. +.SS NAVIGATION +.TP +.B +[url] +Navigates to the requested url. +.TP +.B +[link id] +Follows a link on the current document with the given number. +.TP +.B +bookmarks [bookmark id] +Navigates to the url represented by the bookmark matching bookmark id. \fIb\fP can be entered, rather than the full \fIbookmarks\fP. +.TP +.B +home +Navigates to the document set by the \fIhomeurl\fP setting. \fIh\fP can be entered, rather than the full \fIhome\fP. +.TP +.B +search [keywords\.\.\.] +Submits a search to the search engine set by the \fIsearchengine\fP setting, with the query being the provided keyword(s). +.TP +.B +search +Queries the user for search terms and submits a search to the search engine set by the \fIsearchengine\fP setting. +.TP +.B +write [url] +Writes data from a given url to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. +.TP +.B +write [url] [filename\.\.\.] +Writes data from a given url to a file. The file is named by the filename argument should should not include a leading \fI/\fP. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. +.TP +.B +write [link id]] +Writes data from a given link id in the current document to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. +.TP +.B +write [link id] [filename\.\.\.] +Writes data from a given link id in the current document to a file. The file is named by the filename argument should should not include a leading \fI/\fP. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. +.TP +.B +write . +Writes the current document to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. +.TP +.B +write . [filename\.\.\.] +Writes the current document to a file. The file is named by the filename argument should should not include a leading \fI/\fP. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. +.TP +.B +help +Navigates to the gopher based help page for \fBbombadillo\fP. \fI?\fP can be used instead of the full \fIhelp\fP. +.SS BOOKMARKS +.TP +.B +bookmarks +Toggles the bookmarks panel open/closed. Alias for KEY COMMAND \fIB\fP. \fIb\fP can be used instead of the full \fIbookmarks\fP. +.TP +.B +add [url] [name\.\.\.] +Adds the url as a bookmarks labeled by name. \fIa\fP can be used instead of the full \fIadd\fP. +.TP +.B +add [link id] [name\.\.\.] +Adds the url represented by the link id within the current document as a bookmark labeled by name. \fIa\fP can be used instead of the full \fIadd\fP. +.TP +.B +add [.] [name\.\.\.] +Adds the current document's url as a bookmark labeled by name. \fIa\fP can be used instead of the full \fIadd\fP. +.TP +.B +delete [bookmark id]] +Deletes the bookmark matching the bookmark id. \fId\fP can be used instead of the full \fIdelete\fP. +.SS MISC +.TP +.B +check [link id] +Displays the url corresponding to a given link id for the current document. \fIc\fP can be used instead of the full \fIcheck\fP. +.TP +.B +check [setting name] +Displays the current value for a given configuration setting. \fIc\fP can be used instead of the full \fIcheck\fP. +.TP +.B +set [setting name] +Sets the value for a given configuration setting. \fIs\fP can be used instead of the full \fIset\fP. +.TP +.B +quit +Quits \fBbombadillo\fP. Alias for KEY COMMAND \fIq\fP. \fIq\fP can be used instead of the full \fIquit\fP. +.SH FILES +\fBbombadillo\fP keeps a hidden configuration file in a user's home directory. The file is a simplified ini file titled '.bombadillo.ini'. It is generated when a user first loads \fBbombadillo\fP and is updated with bookmarks and settings as a user adds them. The file can be directly edited, but it is best to use the SET command to update settings whenever possible. To return to the state of a fresh install, simply remove the file and a new one will be generated with the \fBbombadillo\fP defaults. +.SH SETTINGS +The following is a list of the settings that \fBbombadillo\fP recognizes, as well as a description of their valid values. +.TP +.B +homeurl +The url that \fBbombadillo\fP navigates to when the program loads or when the \fIhome\fP or \fIh\fP LINE COMMAND is issued. This should be a valid url. If a scheme/protocol is not included, gopher will be assumed. +.TP +.B +savelocation +The path to the folder that \fBbombadillo\fP should write files to. This should be a valid filepath for the system and should end in a \fI/\fP. Defaults to a user's home directory. +.TP +.B +searchengine +The url to use for the LINE COMMANDs \fI?\fP and \fIsearch\fP. Should be a valid search path that terms may be appended to. Defaults to \fIgopher://gopher.floodgap.com:70/7/v2/vs\fP. +.TP +.B +openhttp +Tells the client whether or not to try to follow web (http/https) links. If set to \fItrue\fP, \fBbombadillo\fP will try to open a user's default web browser to the link in question. Any value other than \fItrue\fP is considered false. Defaults to \fIfalse\fP. +.TP +.B +telnetcommand +Tells the client what command to use to start a telnet session. Should be a valid command, including any flags. The address being navigated to will be added to the end of the command. Defaults to \fItelnet\fP. +.TP +.B +theme +Can toggle between visual modes. Valid values are \fInormal\fP and \fIinverse\fP. When set to ivnerse, the terminal color mode is inversed. Defaults to \fInormal\fP. +.TP +.B +terminalonly +Sets whether or not to try to open non-text files served via gemini in gui programs or not. If set to \fItrue\fP, bombdaillo will only attempt to use terminal programs to open files. If set to anything else, \fBbombadillo\fP may choose graphical and terminal programs. Defaults to \fItrue\fP. diff --git a/client.go b/client.go index 4ff6a05..77c14ad 100644 --- a/client.go +++ b/client.go @@ -374,7 +374,13 @@ func (c *client) doCommandAs(action string, values []string) { case "SET", "S": if _, ok := c.Options[values[0]]; ok { - c.Options[values[0]] = strings.Join(values[1:], " ") + val := strings.Join(values[1:], " ") + if values[0] == "theme" && val != "normal" && val != "inverse" { + c.SetMessage("Theme can only be set to 'normal' or 'inverse'", true) + c.DrawMessage() + return + } + c.Options[values[0]] = val err := saveConfig() if err != nil { c.SetMessage("Value set, but error saving config to file", true) diff --git a/defaults.go b/defaults.go index 8d744de..690a403 100644 --- a/defaults.go +++ b/defaults.go @@ -9,6 +9,9 @@ var defaultOptions = map[string]string{ // // General configuration options // + // Edit these values before compile to have different default values + // ... though they can always be edited from within bombadillo as well + // it just may take more time/work. "homeurl": "gopher://colorfield.space:70/1/bombadillo-info", "savelocation": userinfo.HomeDir, "searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs", diff --git a/main.go b/main.go index 1e7c6bc..e66a9e9 100644 --- a/main.go +++ b/main.go @@ -32,6 +32,10 @@ func saveConfig() error { opts.WriteString(bkmrks) opts.WriteString("\n[SETTINGS]\n") for k, v := range bombadillo.Options { + if k == "theme" && v != "normal" && v != "inverse" { + v = "normal" + bombadillo.Options["theme"] = "normal" + } opts.WriteString(k) opts.WriteRune('=') opts.WriteString(v) @@ -64,6 +68,9 @@ func loadConfig() error { } if _, ok := bombadillo.Options[lowerkey]; ok { + if lowerkey == "theme" && v.Value != "normal" && v.Value != "inverse" { + v.Value = "normal" + } bombadillo.Options[lowerkey] = v.Value } } From ff209c4ae3dd85e1809a69423f8ce0965b92c2d9 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 21 Sep 2019 22:02:20 -0700 Subject: [PATCH 023/145] Adds status 1 support to gemini, fixes bug in url where gophertypes were getting thrown out of nongopher addresses, and fixes up relative linking in gemini maps --- client.go | 23 +++++++++++++++-------- gemini/gemini.go | 13 +++++++------ url.go | 2 +- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/client.go b/client.go index 77c14ad..642d9f4 100644 --- a/client.go +++ b/client.go @@ -280,7 +280,7 @@ func (c *client) simpleCommand(action string) { c.BookMarks.ToggleOpen() c.Draw() case "SEARCH": - c.search("") + c.search("", "", "?") case "HELP", "?": go c.Visit(helplocation) default: @@ -300,7 +300,7 @@ func (c *client) doCommand(action string, values []string) { case "CHECK", "C": c.displayConfigValue(values[0]) case "SEARCH": - c.search(strings.Join(values, " ")) + c.search(strings.Join(values, " "), "", "") case "WRITE", "W": if values[0] == "." { values[0] = c.PageState.History[c.PageState.Position].Location.Full @@ -590,16 +590,16 @@ func (c *client) doLinkCommand(action, target string) { } -func (c *client) search(q string) { +func (c *client) search(query, url, question string) { var entry string var err error - if q == "" { + if query == "" { c.ClearMessage() c.ClearMessageLine() if c.Options["theme"] == "normal" { fmt.Printf("\033[7m%*.*s\r", c.Width, c.Width, "") } - fmt.Print("?") + fmt.Print(question) entry, err = cui.GetLine() c.ClearMessageLine() if err != nil { @@ -610,11 +610,14 @@ func (c *client) search(q string) { return } } else { - entry = q + entry = query } - u, err := MakeUrl(c.Options["searchengine"]) + if url == "" { + url = c.Options["searchengine"] + } + u, err := MakeUrl(url) if err != nil { - c.SetMessage("'searchengine' is not set to a valid url", true) + c.SetMessage("The search url is not a valid url", true) c.DrawMessage() return } @@ -811,6 +814,8 @@ func (c *client) Visit(url string) { filename = "gopherfile" } c.saveFile(u, filename) + } else if u.Mime == "7" { + c.search("", u.Full, "?") } else { content, links, err := gopher.Visit(u.Mime, u.Host, u.Port, u.Resource) if err != nil { @@ -834,6 +839,8 @@ func (c *client) Visit(url string) { return } switch capsule.Status { + case 1: + c.search("", u.Full, capsule.Content) case 2: if capsule.MimeMaj == "text" { pg := MakePage(u, capsule.Content, capsule.Links) diff --git a/gemini/gemini.go b/gemini/gemini.go index 91755f4..7b6de31 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -137,8 +137,8 @@ func Visit(host, port, resource string) (Capsule, error) { switch capsule.Status { case 1: - // handle search - return capsule, fmt.Errorf("Gemini input not yet supported") + capsule.Content = header[1] + return capsule, nil case 2: mimeAndCharset := strings.Split(header[1], ";") meta = mimeAndCharset[0] @@ -149,7 +149,10 @@ func Visit(host, port, resource string) (Capsule, error) { capsule.MimeMaj = minMajMime[0] capsule.MimeMin = minMajMime[1] if capsule.MimeMaj == "text" && capsule.MimeMin == "gemini" { - rootUrl := fmt.Sprintf("gemini://%s:%s", host, port) + if len(resource) > 0 && resource[0] != '/' { + resource = fmt.Sprintf("/%s", resource) + } + rootUrl := fmt.Sprintf("gemini://%s:%s%s", host, port, resource) capsule.Content, capsule.Links = parseGemini(body, rootUrl) } else { capsule.Content = body @@ -190,10 +193,8 @@ func parseGemini(b, rootUrl string) (string, []string) { decorator = strings.Trim(subLn[splitPoint:], "\t\n\r \a") } - if len(link) > 0 && link[0] == '/' { + if strings.Index(link, "://") < 0 { link = fmt.Sprintf("%s%s", rootUrl, link) - } else if len(link) > 0 && strings.Index(link, "://") < 0 { - link = fmt.Sprintf("%s/%s", rootUrl, link) } links = append(links, link) linknum := fmt.Sprintf("[%d]", len(links)) diff --git a/url.go b/url.go index 5babdc8..faedbbb 100644 --- a/url.go +++ b/url.go @@ -97,8 +97,8 @@ func MakeUrl(u string) (Url, error) { out.DownloadOnly = true } } else { - out.Mime = "" out.Resource = fmt.Sprintf("%s%s", out.Mime, out.Resource) + out.Mime = "" } if out.Scheme == "http" || out.Scheme == "https" { From b66dd3baa9dbbb489d7e4b8926b7dd0dbfdaf6a0 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 22 Sep 2019 15:08:15 -0700 Subject: [PATCH 024/145] Fixes relative linking for gemini --- gemini/gemini.go | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/gemini/gemini.go b/gemini/gemini.go index 7b6de31..4d8b044 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -151,9 +151,12 @@ func Visit(host, port, resource string) (Capsule, error) { if capsule.MimeMaj == "text" && capsule.MimeMin == "gemini" { if len(resource) > 0 && resource[0] != '/' { resource = fmt.Sprintf("/%s", resource) + } else if resource == "" { + resource = "/" } - rootUrl := fmt.Sprintf("gemini://%s:%s%s", host, port, resource) - capsule.Content, capsule.Links = parseGemini(body, rootUrl) + currentUrl := fmt.Sprintf("gemini://%s:%s%s", host, port, resource) + rootUrl := fmt.Sprintf("gemini://%s:%s", host, port) + capsule.Content, capsule.Links = parseGemini(body, rootUrl, currentUrl) } else { capsule.Content = body } @@ -174,7 +177,7 @@ func Visit(host, port, resource string) (Capsule, error) { } } -func parseGemini(b, rootUrl string) (string, []string) { +func parseGemini(b, rootUrl, currentUrl string) (string, []string) { splitContent := strings.Split(b, "\n") links := make([]string, 0, 10) @@ -193,9 +196,10 @@ func parseGemini(b, rootUrl string) (string, []string) { decorator = strings.Trim(subLn[splitPoint:], "\t\n\r \a") } - if strings.Index(link, "://") < 0 { - link = fmt.Sprintf("%s%s", rootUrl, link) + if strings.Index(link, "://") < 0 { + link = handleRelativeUrl(link, rootUrl, currentUrl) } + links = append(links, link) linknum := fmt.Sprintf("[%d]", len(links)) splitContent[i] = fmt.Sprintf("%-5s %s", linknum, decorator) @@ -204,6 +208,24 @@ func parseGemini(b, rootUrl string) (string, []string) { return strings.Join(splitContent, "\n"), links } +func handleRelativeUrl(u, root, current string) string { + if len(u) < 1 { + return u + } + + if u[0] == '/' { + return fmt.Sprintf("%s%s", root, u) + } + + ind := strings.LastIndex(current, "/") + if ind < 10 { + return fmt.Sprintf("%s/%s", root, u) + } + + current = current[:ind + 1] + return fmt.Sprintf("%s%s", current, u) +} + func MakeCapsule() Capsule { return Capsule{"", "", 0, "", make([]string, 0, 5)} From 74473ff3091abd421bfab60776fa011a4ccad256 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Mon, 23 Sep 2019 08:49:33 -0700 Subject: [PATCH 025/145] Returns license to gpl3 --- LICENSE | 756 +++++++++++++++++++++++++++++++++++++++++++------------- main.go | 21 +- 2 files changed, 607 insertions(+), 170 deletions(-) diff --git a/LICENSE b/LICENSE index 63d7936..810fce6 100644 --- a/LICENSE +++ b/LICENSE @@ -1,195 +1,621 @@ -Non-Profit Open Software License 3.0 + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 -This Non-Profit Open Software License ("Non-Profit OSL") version 3.0 (the -"License") applies to any original work of authorship (the "Original Work") -whose owner (the "Licensor") has placed the following licensing notice adjacent -to the copyright notice for the Original Work: + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. -Licensed under the Non-Profit Open Software License version 3.0 + Preamble -1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, -non-exclusive, sublicensable license, for the duration of the copyright, to -do the following: + The GNU General Public License is a free, copyleft license for +software and other kinds of works. - a) to reproduce the Original Work in copies, either alone or as part of a - collective work; + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. - b) to translate, adapt, alter, transform, modify, or arrange the Original - Work, thereby creating derivative works ("Derivative Works") based upon the - Original Work; + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. - c) to distribute or communicate copies of the Original Work and Derivative - Works to the public, with the proviso that copies of Original Work or Derivative - Works that You distribute or communicate shall be licensed under this Non-Profit - Open Software License or as provided in section 17(d); + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. - d) to perform the Original Work publicly; and + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. - e) to display the Original Work publicly. + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. -2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, -non-exclusive, sublicensable license, under patent claims owned or controlled -by the Licensor that are embodied in the Original Work as furnished by the -Licensor, for the duration of the patents, to make, use, sell, offer for sale, -have made, and import the Original Work and Derivative Works. + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. -3) Grant of Source Code License. The term "Source Code" means the preferred -form of the Original Work for making modifications to it and all available -documentation describing how to modify the Original Work. Licensor agrees -to provide a machine-readable copy of the Source Code of the Original Work -along with each copy of the Original Work that Licensor distributes. Licensor -reserves the right to satisfy this obligation by placing a machine-readable -copy of the Source Code in an information repository reasonably calculated -to permit inexpensive and convenient access by You for as long as Licensor -continues to distribute the Original Work. + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. -4) Exclusions From License Grant. Neither the names of Licensor, nor the names -of any contributors to the Original Work, nor any of their trademarks or service -marks, may be used to endorse or promote products derived from this Original -Work without express prior permission of the Licensor. Except as expressly -stated herein, nothing in this License grants any license to Licensor's trademarks, -copyrights, patents, trade secrets or any other intellectual property. No -patent license is granted to make, use, sell, offer for sale, have made, or -import embodiments of any patent claims other than the licensed claims defined -in Section 2. No license is granted to the trademarks of Licensor even if -such marks are included in the Original Work. Nothing in this License shall -be interpreted to prohibit Licensor from licensing under terms different from -this License any Original Work that Licensor otherwise would have a right -to license. + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. -5) External Deployment. The term "External Deployment" means the use, distribution, -or communication of the Original Work or Derivative Works in any way such -that the Original Work or Derivative Works may be used by anyone other than -You, whether those works are distributed or communicated to those persons -or made available as an application intended for use over a network. As an -express condition for the grants of license hereunder, You must treat any -External Deployment by You of the Original Work or a Derivative Work as a -distribution under section 1(c). + The precise terms and conditions for copying, distribution and +modification follow. -6) Attribution Rights. You must retain, in the Source Code of any Derivative -Works that You create, all copyright, patent, or trademark notices from the -Source Code of the Original Work, as well as any notices of licensing and -any descriptive text identified therein as an "Attribution Notice." You must -cause the Source Code for any Derivative Works that You create to carry a -prominent Attribution Notice reasonably calculated to inform recipients that -You have modified the Original Work. + TERMS AND CONDITIONS -7) Warranty of Provenance and Disclaimer of Warranty. The Original Work is -provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either -express or implied, including, without limitation, the warranties of non-infringement, -merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO -THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY -constitutes an essential part of this License. No license to the Original -Work is granted by this License except under this disclaimer. + 0. Definitions. -8) Limitation of Liability. Under no circumstances and under no legal theory, -whether in tort (including negligence), contract, or otherwise, shall the -Licensor be liable to anyone for any direct, indirect, special, incidental, -or consequential damages of any character arising as a result of this License -or the use of the Original Work including, without limitation, damages for -loss of goodwill, work stoppage, computer failure or malfunction, or any and -all other commercial damages or losses. This limitation of liability shall -not apply to the extent applicable law prohibits such limitation. + "This License" refers to version 3 of the GNU General Public License. -9) Acceptance and Termination. If, at any time, You expressly assented to -this License, that assent indicates your clear and irrevocable acceptance -of this License and all of its terms and conditions. If You distribute or -communicate copies of the Original Work or a Derivative Work, You must make -a reasonable effort under the circumstances to obtain the express assent of -recipients to the terms of this License. This License conditions your rights -to undertake the activities listed in Section 1, including your right to create -Derivative Works based upon the Original Work, and doing so without honoring -these terms and conditions is prohibited by copyright law and international -treaty. Nothing in this License is intended to affect copyright exceptions -and limitations (including "fair use" or "fair dealing"). This License shall -terminate immediately and You may no longer exercise any of the rights granted -to You by this License upon your failure to honor the conditions in Section -1(c). + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. -10) Termination for Patent Action. This License shall terminate automatically -and You may no longer exercise any of the rights granted to You by this License -as of the date You commence an action, including a cross-claim or counterclaim, -against Licensor or any licensee alleging that the Original Work infringes -a patent. This termination provision shall not apply for an action alleging -patent infringement by combinations of the Original Work with other software -or hardware. + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. -11) Jurisdiction, Venue and Governing Law. Any action or suit relating to -this License may be brought only in the courts of a jurisdiction wherein the -Licensor resides or in which Licensor conducts its primary business, and under -the laws of that jurisdiction excluding its conflict-of-law provisions. The -application of the United Nations Convention on Contracts for the International -Sale of Goods is expressly excluded. Any use of the Original Work outside -the scope of this License or after its termination shall be subject to the -requirements and penalties of copyright or patent law in the appropriate jurisdiction. -This section shall survive the termination of this License. + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. -12) Attorneys' Fees. In any action to enforce the terms of this License or -seeking damages relating thereto, the prevailing party shall be entitled to -recover its costs and expenses, including, without limitation, reasonable -attorneys' fees and costs incurred in connection with such action, including -any appeal of such action. This section shall survive the termination of this -License. + A "covered work" means either the unmodified Program or a work based +on the Program. -13) Miscellaneous. If any provision of this License is held to be unenforceable, -such provision shall be reformed only to the extent necessary to make it enforceable. + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. -14) Definition of "You" in This License. "You" throughout this License, whether -in upper or lower case, means an individual or a legal entity exercising rights -under, and complying with all of the terms of, this License. For legal entities, -"You" includes any entity that controls, is controlled by, or is under common -control with you. For purposes of this definition, "control" means (i) the -power, direct or indirect, to cause the direction or management of such entity, -whether by contract or otherwise, or (ii) ownership of fifty percent (50%) -or more of the outstanding shares, or (iii) beneficial ownership of such entity. + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. -15) Right to Use. You may use the Original Work in all ways not otherwise -restricted or conditioned by this License or by law, and Licensor promises -not to interfere with or be responsible for such uses by You. + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. -16) Modification of This License. This License is Copyright © 2005 Lawrence -Rosen. Permission is granted to copy, distribute, or communicate this License -without modification. Nothing in this License permits You to modify this License -as applied to the Original Work or to Derivative Works. However, You may modify -the text of this License and copy, distribute or communicate your modified -version (the "Modified License") and apply it to other original works of authorship -subject to the following conditions: (i) You may not indicate in any way that -your Modified License is the "Open Software License" or "OSL" and you may -not use those names in the name of your Modified License; (ii) You must replace -the notice specified in the first paragraph above with the notice "Licensed -under " or with a notice of your own that is -not confusingly similar to the notice in this License; and (iii) You may not -claim that your original works are open source software unless your Modified -License has been approved by Open Source Initiative (OSI) and You comply with -its license review and certification process. + 1. Source Code. -17) Non-Profit Amendment. The name of this amended version of the Open Software -License ("OSL 3.0") is "Non-Profit Open Software License 3.0". The original -OSL 3.0 license has been amended as follows: + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. - (a) Licensor represents and declares that it is a not-for-profit organization - that derives no revenue whatsoever from the distribution of the Original Work - or Derivative Works thereof, or from support or services relating thereto. + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. - (b) The first sentence of Section 7 ["Warranty of Provenance"] of OSL 3.0 - has been stricken. For Original Works licensed under this Non-Profit OSL 3.0, - LICENSOR OFFERS NO WARRANTIES WHATSOEVER. + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. - (c) In the first sentence of Section 8 ["Limitation of Liability"] of this - Non-Profit OSL 3.0, the list of damages for which LIABILITY IS LIMITED now - includes "direct" damages. + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. - (d) The proviso in Section 1(c) of this License now refers to this "Non-Profit - Open Software License" rather than the "Open Software License". You may distribute - or communicate the Original Work or Derivative Works thereof under this Non-Profit - OSL 3.0 license only if You make the representation and declaration in paragraph - (a) of this Section 17. Otherwise, You shall distribute or communicate the - Original Work or Derivative Works thereof only under the OSL 3.0 license and - You shall publish clear licensing notices so stating. Also by way of clarification, - this License does not authorize You to distribute or communicate works under - this Non-Profit OSL 3.0 if You received them under the original OSL 3.0 license. + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. - (e) Original Works licensed under this license shall reference "Non-Profit - OSL 3.0" in licensing notices to distinguish them from works licensed under - the original OSL 3.0 license. + The Corresponding Source for a work in source code form is that +same work. + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS diff --git a/main.go b/main.go index e66a9e9..ffe6eab 100644 --- a/main.go +++ b/main.go @@ -1,10 +1,21 @@ package main +// Bombadillo is a gopher and gemini client for the terminal of unix or unix-like systems. +// +// Copyright (C) 2019 Brian Evans +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . -// Bombadillo is distributed under the "Non-Profit Open Source Software License 3.0" -// The license is included with the source code in the file LICENSE. The basic -// takeway: use, remix, and share this software for any purpose that is not a commercial -// purpose as defined by the above mentioned license and is itself distributed udner -// the terms of said license with said license file included. import ( "flag" From dd4849e6b3ca71e2dfedc73a14cc13fd0dafbc99 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Mon, 23 Sep 2019 09:09:47 -0700 Subject: [PATCH 026/145] Updated readme with release information and manpage information --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2fa6bf0..ed52c4d 100644 --- a/README.md +++ b/README.md @@ -39,13 +39,13 @@ If you would prefer to download a binary for your system, rather than build from ### Documentation -Bombadillo has documentation available in three places currently. The first is the [Bombadillo homepage](https://rawtext.club/~sloum/bombadillo.html#docs), which has lots of information about the program, links to places around Gopher, and documentation of the commands and configuration options. +Bombadillo has documentation available in four places currently. The first is the [Bombadillo homepage](https://rawtext.club/~sloum/bombadillo.html#docs), which has lots of information about the program, links to places around Gopher, and documentation of the commands and configuration options. Secondly, and possibly more importantly, documentation is available via Gopher from within Bombadillo. When a user launches Bombadillo for the first time, their `homeurl` is set to the help file. As such they will have access to all of the key bindings, commands, and configuration from the first run. A user can also type `:?` or `:help` at any time to return to the documentation. Remember that Bombadillo uses vim-like key bindings, so scroll with `j` and `k` to view the docs file. -Lastly, this repo contains a file `bombadillo-info`. This is a duplicate of the help file that is hosted over gopher mentioned above. Per user request it has been added to the repo so that pull requests can be created with updates to the documentation. +Thirdly, this repo contains a file `bombadillo-info`. This is a duplicate of the help file that is hosted over gopher mentioned above. Per user request it has been added to the repo so that pull requests can be created with updates to the documentation. -The longterm hope is to create an installer of some sort that will move bombadillo onto a users path (compiling if need be) and installing a man file (yet to be created) onto their system. There is also talk about being able to open local files and use bombadillo as a pager, which would enable linking in the included help file. +Lastly, but perhaps most importantly, a manpage is now included in the repo as `bombadillo.1`. Current efforts are underway to automate the install of both bombadillo and this manpgage. ## Contributing @@ -55,3 +55,7 @@ Bombadillo development is largely handled by Sloum, with help from jboverf and s This project is licensed under the GNU GPL version 3- see the [LICENSE](LICENSE) file for details. +## Releases + +Starting with v2.0.0 releases into `master` will be version-tagged. Work done toward the next release will be created on work branches named for what they are doing and then merged into `develop` to be combined with other ongoing efforts before a release is merged into `master`. At present there is no specific release schedule. It will depend on the urgency of the work that makes its way into develop and will but up to the project maintainers' judgement when to release from `develop`. + From b219e659ab27c9ca4e33e7771fcf67086c0eb7bd Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Mon, 23 Sep 2019 09:11:17 -0700 Subject: [PATCH 027/145] Updated readme contributors language --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ed52c4d..9bf3b31 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Lastly, but perhaps most importantly, a manpage is now included in the repo as ` ## Contributing -Bombadillo development is largely handled by Sloum, with help from jboverf and some community input. If you would like to get involved, please reach out or submit an issue. At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. +Bombadillo development is largely handled by Sloum, with help from jboverf, asdf, and some community input. If you would like to get involved, please reach out or submit an issue. At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. If you have forked and would like to make a pull request, please make the pull request into `develop` where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. ## License From df2a7fbd0567a066e161d5b8a38c3d3d1d5f0278 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Mon, 23 Sep 2019 21:18:46 -0700 Subject: [PATCH 028/145] Adds validation to setting and loading configuration options. --- client.go | 6 +++--- main.go | 38 +++++++++++++++++++++++++++++++++++--- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/client.go b/client.go index 642d9f4..54eb354 100644 --- a/client.go +++ b/client.go @@ -375,12 +375,12 @@ func (c *client) doCommandAs(action string, values []string) { case "SET", "S": if _, ok := c.Options[values[0]]; ok { val := strings.Join(values[1:], " ") - if values[0] == "theme" && val != "normal" && val != "inverse" { - c.SetMessage("Theme can only be set to 'normal' or 'inverse'", true) + if !validateOpt(values[0], val) { + c.SetMessage(fmt.Sprintf("Invalid setting for %q", values[0]), true) c.DrawMessage() return } - c.Options[values[0]] = val + c.Options[values[0]] = lowerCaseOpt(values[0], val) err := saveConfig() if err != nil { c.SetMessage("Value set, but error saving config to file", true) diff --git a/main.go b/main.go index ffe6eab..57d00b8 100644 --- a/main.go +++ b/main.go @@ -56,6 +56,37 @@ func saveConfig() error { return ioutil.WriteFile(bombadillo.Options["configlocation"] + "/.bombadillo.ini", []byte(opts.String()), 0644) } +func validateOpt(opt, val string) bool { + var validOpts = map[string][]string{ + "openhttp": []string{"true", "false"}, + "theme": []string{"normal", "inverse"}, + "terminalonly": []string{"true", "false"}, + } + + opt = strings.ToLower(opt) + val = strings.ToLower(val) + + if _, ok := validOpts[opt]; ok { + for _, item := range validOpts[opt] { + if item == val { + return true + } + } + return false + } else { + return true + } +} + +func lowerCaseOpt(opt, val string) string { + switch opt { + case "openhttp", "theme", "terminalonly": + return strings.ToLower(val) + default: + return val + } +} + func loadConfig() error { file, err := os.Open(bombadillo.Options["configlocation"] + "/.bombadillo.ini") if err != nil { @@ -79,10 +110,11 @@ func loadConfig() error { } if _, ok := bombadillo.Options[lowerkey]; ok { - if lowerkey == "theme" && v.Value != "normal" && v.Value != "inverse" { - v.Value = "normal" + if validateOpt(lowerkey, v.Value) { + bombadillo.Options[lowerkey] = v.Value + } else { + bombadillo.Options[lowerkey] = defaultOptions[lowerkey] } - bombadillo.Options[lowerkey] = v.Value } } From 5e68d81a6346bdd89f19243a0e8318fc2fad4d2e Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Tue, 24 Sep 2019 21:23:44 -0700 Subject: [PATCH 029/145] Starts building out a tofu system for certificate pinning --- gemini/gemini.go | 66 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/gemini/gemini.go b/gemini/gemini.go index 4d8b044..39cda6d 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -6,10 +6,10 @@ import ( "io/ioutil" "strconv" "strings" - - // "tildegit.org/sloum/mailcap" + "time" ) + type Capsule struct { MimeMaj string MimeMin string @@ -18,6 +18,50 @@ type Capsule struct { Links []string } +type TofuDigest struct { + db map[string][]map[string]string +} + +//------------------------------------------------\\ +// + + + R E C E I V E R S + + + \\ +//--------------------------------------------------\\ + +func (t *TofuDigest) Remove(host string, indexToRemove int) error { + if _, ok := t.db[host]; ok { + if indexToRemove < 0 || indexToRemove >= len(t.db[host]) { + return fmt.Errorf("Invalid index") + } else if len(t.db[host]) > indexToRemove { + t.db[host] = append(t.db[host][:indexToRemove], t.db[host][indexToRemove+1:]...) + } else if len(t.db[host]) - 1 == indexToRemove { + t.db[host] = t.db[host][:indexToRemove] + } + return nil + } + return fmt.Errorf("Invalid host") +} + +func (t *TofuDigest) Add(host, hash string, start, end int64) { + s := strconv.FormatInt(start, 10) + e := strconv.FormatInt(end, 10) + added := strconv.FormatInt(time.Now().Unix(), 10) + entry := map[string]string{"hash": hash, "start": s, "end": e, "added": added} + t.db[host] = append(t.db[host], entry) +} + +// Removes all entries that are expired +func (t *TofuDigest) Clean() { + now := time.Now() + for host, slice := range t.db { + for index, entry := range slice { + intFromStringTime, err := strconv.ParseInt(entry["end"], 10, 64) + if err != nil || now.After(time.Unix(intFromStringTime, 0)) { + t.Remove(host, index) + } + } + } +} + + //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ @@ -41,6 +85,24 @@ func Retrieve(host, port, resource string) (string, error) { defer conn.Close() + // Verify that the handshake ahs completed and that + // the hostname on the certificate(s) from the server + // is the hostname we have requested + connState := conn.ConnectionState() + if connState.HandshakeComplete { + if len(connState.PeerCertificates) > 0 { + for _, cert := range connState.PeerCertificates { + if err = cert.VerifyHostname(host); err == nil { + break + } + } + if err != nil { + return "", err + } + } + } + + send := "gemini://" + addr + "/" + resource + "\r\n" _, err = conn.Write([]byte(send)) From 7896858facaa28343b96d1ed7bea5b1f44c0a209 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 26 Sep 2019 18:30:44 -0700 Subject: [PATCH 030/145] Updated url regex to allow for any scheme --- url.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/url.go b/url.go index faedbbb..343cdbb 100644 --- a/url.go +++ b/url.go @@ -37,7 +37,7 @@ type Url struct { // an error (or nil). func MakeUrl(u string) (Url, error) { var out Url - re := regexp.MustCompile(`^((?Pgopher|telnet|http|https|gemini):\/\/)?(?P[\w\-\.\d]+)(?::(?P\d+)?)?(?:/(?P[01345679gIhisp])?)?(?P.*)?$`) + re := regexp.MustCompile(`^((?P[a-zA-Z]+):\/\/)?(?P[\w\-\.\d]+)(?::(?P\d+)?)?(?:/(?P[01345679gIhisp])?)?(?P.*)?$`) match := re.FindStringSubmatch(u) if valid := re.MatchString(u); !valid { @@ -58,6 +58,7 @@ func MakeUrl(u string) (Url, error) { out.Resource = match[i] } } + out.Scheme = strings.ToLower(out.Scheme) if out.Scheme == "" { out.Scheme = "gopher" From 4c92870790f00308206d1c8e3977a60f41371000 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 26 Sep 2019 18:40:14 -0700 Subject: [PATCH 031/145] Cleans up url struct creation a bit --- url.go | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/url.go b/url.go index 343cdbb..73b5226 100644 --- a/url.go +++ b/url.go @@ -58,16 +58,17 @@ func MakeUrl(u string) (Url, error) { out.Resource = match[i] } } + + if out.Host == "" { + return out, fmt.Errorf("no host") + } + out.Scheme = strings.ToLower(out.Scheme) if out.Scheme == "" { out.Scheme = "gopher" } - if out.Host == "" { - return out, fmt.Errorf("no host") - } - if out.Scheme == "gopher" && out.Port == "" { out.Port = "70" } else if out.Scheme == "http" && out.Port == "" { @@ -76,21 +77,20 @@ func MakeUrl(u string) (Url, error) { out.Port = "443" } else if out.Scheme == "gemini" && out.Port == "" { out.Port = "1965" - } - - if out.Scheme == "gopher" && out.Mime == "" { - out.Mime = "1" - } - - if out.Mime == "" && (out.Resource == "" || out.Resource == "/") && out.Scheme == "gopher" { - out.Mime = "1" - } - - if out.Mime == "7" && strings.Contains(out.Resource, "\t") { - out.Mime = "1" + } else if out.Scheme == "telnet" && out.Port == "" { + out.Port = "23" } if out.Scheme == "gopher" { + if out.Mime == "" { + out.Mime = "1" + } + if out.Resource == "" || out.Resource == "/" { + out.Mime = "1" + } + if out.Mime == "7" && strings.Contains(out.Resource, "\t") { + out.Mime = "1" + } switch out.Mime { case "1", "0", "h", "7": out.DownloadOnly = false @@ -102,10 +102,6 @@ func MakeUrl(u string) (Url, error) { out.Mime = "" } - if out.Scheme == "http" || out.Scheme == "https" { - out.Mime = "" - } - out.Full = out.Scheme + "://" + out.Host + ":" + out.Port + "/" + out.Mime + out.Resource return out, nil From bef32b7ff56f60e6d1a7e24d326f49f710787755 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 26 Sep 2019 22:08:57 -0700 Subject: [PATCH 032/145] Adds basic tofu certificate pinning --- bookmarks.go | 2 +- client.go | 11 ++-- config/parser.go | 6 +- gemini/gemini.go | 143 ++++++++++++++++++++++++++++++++++------------- main.go | 11 +++- 5 files changed, 123 insertions(+), 50 deletions(-) diff --git a/bookmarks.go b/bookmarks.go index cb2b773..3e320c4 100644 --- a/bookmarks.go +++ b/bookmarks.go @@ -61,7 +61,7 @@ func (b *Bookmarks) ToggleFocused() { } func (b Bookmarks) IniDump() string { - if len(b.Titles) < 0 { + if len(b.Titles) < 1 { return "" } out := "[BOOKMARKS]\n" diff --git a/client.go b/client.go index 54eb354..05bee18 100644 --- a/client.go +++ b/client.go @@ -16,7 +16,6 @@ import ( "tildegit.org/sloum/bombadillo/gopher" "tildegit.org/sloum/bombadillo/http" "tildegit.org/sloum/bombadillo/telnet" - // "tildegit.org/sloum/mailcap" ) //------------------------------------------------\\ @@ -33,6 +32,7 @@ type client struct { BookMarks Bookmarks TopBar Headbar FootBar Footbar + Certs gemini.TofuDigest } @@ -154,7 +154,7 @@ func (c *client) TakeControlInput() { c.ClearMessage() c.Scroll(-1) case 'q', 'Q': - // quite bombadillo + // quit bombadillo cui.Exit() case 'g': // scroll to top @@ -472,7 +472,7 @@ func (c *client) saveFile(u Url, name string) { case "gopher": file, err = gopher.Retrieve(u.Host, u.Port, u.Resource) case "gemini": - file, err = gemini.Fetch(u.Host, u.Port, u.Resource) + file, err = gemini.Fetch(u.Host, u.Port, u.Resource, &c.Certs) default: c.SetMessage(fmt.Sprintf("Saving files over %s is not supported", u.Scheme), true) c.DrawMessage() @@ -832,7 +832,8 @@ func (c *client) Visit(url string) { c.Draw() } case "gemini": - capsule, err := gemini.Visit(u.Host, u.Port, u.Resource) + capsule, err := gemini.Visit(u.Host, u.Port, u.Resource, &c.Certs) + go saveConfig() if err != nil { c.SetMessage(err.Error(), true) c.DrawMessage() @@ -955,7 +956,7 @@ func (c *client) Visit(url string) { //--------------------------------------------------\\ func MakeClient(name string) *client { - c := client{0, 0, defaultOptions, "", false, MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar()} + c := client{0, 0, defaultOptions, "", false, MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar(), gemini.MakeTofuDigest()} return &c } diff --git a/config/parser.go b/config/parser.go index 038c889..780bfa7 100644 --- a/config/parser.go +++ b/config/parser.go @@ -24,8 +24,8 @@ type Config struct { Bookmarks struct { Titles, Links []string } - Colors []KeyValue Settings []KeyValue + Certs []KeyValue } type KeyValue struct { @@ -90,8 +90,8 @@ func (p *Parser) Parse() (Config, error) { case "BOOKMARKS": c.Bookmarks.Titles = append(c.Bookmarks.Titles, keyval.Value) c.Bookmarks.Links = append(c.Bookmarks.Links, keyval.Key) - case "COLORS": - c.Colors = append(c.Colors, keyval) + case "CERTS": + c.Certs = append(c.Certs, keyval) case "SETTINGS": c.Settings = append(c.Settings, keyval) } diff --git a/gemini/gemini.go b/gemini/gemini.go index 39cda6d..adce235 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -1,6 +1,8 @@ package gemini import ( + "bytes" + "crypto/sha1" "crypto/tls" "fmt" "io/ioutil" @@ -15,58 +17,78 @@ type Capsule struct { MimeMin string Status int Content string - Links []string + Links []string } + type TofuDigest struct { - db map[string][]map[string]string + certs map[string]string } + //------------------------------------------------\\ // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ -func (t *TofuDigest) Remove(host string, indexToRemove int) error { - if _, ok := t.db[host]; ok { - if indexToRemove < 0 || indexToRemove >= len(t.db[host]) { - return fmt.Errorf("Invalid index") - } else if len(t.db[host]) > indexToRemove { - t.db[host] = append(t.db[host][:indexToRemove], t.db[host][indexToRemove+1:]...) - } else if len(t.db[host]) - 1 == indexToRemove { - t.db[host] = t.db[host][:indexToRemove] - } +func (t *TofuDigest) Remove(host string) error { + if _, ok := t.certs[strings.ToLower(host)]; ok { + delete(t.certs, host) return nil } return fmt.Errorf("Invalid host") } -func (t *TofuDigest) Add(host, hash string, start, end int64) { - s := strconv.FormatInt(start, 10) - e := strconv.FormatInt(end, 10) - added := strconv.FormatInt(time.Now().Unix(), 10) - entry := map[string]string{"hash": hash, "start": s, "end": e, "added": added} - t.db[host] = append(t.db[host], entry) +func (t *TofuDigest) Add(host, hash string) { + t.certs[strings.ToLower(host)] = hash } -// Removes all entries that are expired -func (t *TofuDigest) Clean() { - now := time.Now() - for host, slice := range t.db { - for index, entry := range slice { - intFromStringTime, err := strconv.ParseInt(entry["end"], 10, 64) - if err != nil || now.After(time.Unix(intFromStringTime, 0)) { - t.Remove(host, index) - } - } +func (t *TofuDigest) Exists(host string) bool { + if _, ok := t.certs[strings.ToLower(host)]; ok { + return true } + return false } +func (t *TofuDigest) Find(host string) (string, error) { + if hash, ok := t.certs[strings.ToLower(host)]; ok { + return hash, nil + } + return "", fmt.Errorf("Invalid hostname, no key saved") +} + +func (t *TofuDigest) Match(host, hash string) bool { + host = strings.ToLower(host) + if _, ok := t.certs[host]; !ok { + return false + } + if t.certs[host] == hash { + return true + } + return false +} + +func (t *TofuDigest) IniDump() string { + if len(t.certs) < 1 { + return "" + } + var out strings.Builder + out.WriteString("[CERTS]\n") + for k, v := range t.certs { + out.WriteString(k) + out.WriteString("=") + out.WriteString(v) + out.WriteString("\n") + } + return out.String() +} + + //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ -func Retrieve(host, port, resource string) (string, error) { +func Retrieve(host, port, resource string, td *TofuDigest) (string, error) { if host == "" || port == "" { return "", fmt.Errorf("Incomplete request url") } @@ -83,25 +105,54 @@ func Retrieve(host, port, resource string) (string, error) { return "", err } + now := time.Now() + defer conn.Close() // Verify that the handshake ahs completed and that // the hostname on the certificate(s) from the server // is the hostname we have requested connState := conn.ConnectionState() - if connState.HandshakeComplete { - if len(connState.PeerCertificates) > 0 { - for _, cert := range connState.PeerCertificates { - if err = cert.VerifyHostname(host); err == nil { - break - } + if len(connState.PeerCertificates) < 0 { + return "", fmt.Errorf("Insecure, no certificates offered by server") + } + hostCertExists := td.Exists(host) + matched := false + + for _, cert := range connState.PeerCertificates { + if hostCertExists { + if td.Match(host, hashCert(cert.Raw)) { + matched = true + if now.Before(cert.NotBefore) { + return "", fmt.Errorf("Server certificate error: certificate not valid yet") + } + + if now.After(cert.NotAfter) { + return "", fmt.Errorf("Server certificate error: certificate expired") + } + + if err = cert.VerifyHostname(host); err != nil { + return "", fmt.Errorf("Server certificate error: %s", err) + } + break + } + } else { + if now.Before(cert.NotBefore) || now.After(cert.NotAfter) { + continue } - if err != nil { - return "", err + + if err = cert.VerifyHostname(host); err != nil { + return "", fmt.Errorf("Server certificate error: %s", err) } + + td.Add(host, hashCert(cert.Raw)) + matched = true } } + if !matched { + return "", fmt.Errorf("Server certificate error: No matching certificate provided") + } send := "gemini://" + addr + "/" + resource + "\r\n" @@ -118,8 +169,8 @@ func Retrieve(host, port, resource string) (string, error) { return string(result), nil } -func Fetch(host, port, resource string) ([]byte, error) { - rawResp, err := Retrieve(host, port, resource) +func Fetch(host, port, resource string, td *TofuDigest) ([]byte, error) { + rawResp, err := Retrieve(host, port, resource, td) if err != nil { return make([]byte, 0), err } @@ -165,9 +216,9 @@ func Fetch(host, port, resource string) ([]byte, error) { } -func Visit(host, port, resource string) (Capsule, error) { +func Visit(host, port, resource string, td *TofuDigest) (Capsule, error) { capsule := MakeCapsule() - rawResp, err := Retrieve(host, port, resource) + rawResp, err := Retrieve(host, port, resource, td) if err != nil { return capsule, err } @@ -288,8 +339,20 @@ func handleRelativeUrl(u, root, current string) string { return fmt.Sprintf("%s%s", current, u) } +func hashCert(cert []byte) string { + hash := sha1.Sum(cert) + hex := make([][]byte, len(hash)) + for i, data := range hash { + hex[i] = []byte(fmt.Sprintf("%02X", data)) + } + return fmt.Sprintf("%s", string(bytes.Join(hex, []byte("-")))) +} + func MakeCapsule() Capsule { return Capsule{"", "", 0, "", make([]string, 0, 5)} } +func MakeTofuDigest() TofuDigest { + return TofuDigest{make(map[string]string)} +} diff --git a/main.go b/main.go index 57d00b8..41f3be3 100644 --- a/main.go +++ b/main.go @@ -24,6 +24,7 @@ import ( "os" "strings" + _ "tildegit.org/sloum/bombadillo/gemini" "tildegit.org/sloum/bombadillo/config" "tildegit.org/sloum/bombadillo/cui" "tildegit.org/sloum/mailcap" @@ -39,8 +40,8 @@ var mc *mailcap.Mailcap func saveConfig() error { var opts strings.Builder bkmrks := bombadillo.BookMarks.IniDump() + certs := bombadillo.Certs.IniDump() - opts.WriteString(bkmrks) opts.WriteString("\n[SETTINGS]\n") for k, v := range bombadillo.Options { if k == "theme" && v != "normal" && v != "inverse" { @@ -53,6 +54,10 @@ func saveConfig() error { opts.WriteRune('\n') } + opts.WriteString(bkmrks) + + opts.WriteString(certs) + return ioutil.WriteFile(bombadillo.Options["configlocation"] + "/.bombadillo.ini", []byte(opts.String()), 0644) } @@ -122,6 +127,10 @@ func loadConfig() error { bombadillo.BookMarks.Add([]string{v, settings.Bookmarks.Links[i]}) } + for _, v := range settings.Certs { + bombadillo.Certs.Add(v.Key, v.Value) + } + return nil } From 6c52299c7af25c5502f91cf7a1e78648453e5eda Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Fri, 27 Sep 2019 19:19:23 -0700 Subject: [PATCH 033/145] Fixes a few logical issues and order of op --- client.go | 2 +- gemini/gemini.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index 05bee18..241bbc4 100644 --- a/client.go +++ b/client.go @@ -833,12 +833,12 @@ func (c *client) Visit(url string) { } case "gemini": capsule, err := gemini.Visit(u.Host, u.Port, u.Resource, &c.Certs) - go saveConfig() if err != nil { c.SetMessage(err.Error(), true) c.DrawMessage() return } + go saveConfig() switch capsule.Status { case 1: c.search("", u.Full, capsule.Content) diff --git a/gemini/gemini.go b/gemini/gemini.go index adce235..4e03492 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -113,7 +113,7 @@ func Retrieve(host, port, resource string, td *TofuDigest) (string, error) { // the hostname on the certificate(s) from the server // is the hostname we have requested connState := conn.ConnectionState() - if len(connState.PeerCertificates) < 0 { + if len(connState.PeerCertificates) < 1 { return "", fmt.Errorf("Insecure, no certificates offered by server") } hostCertExists := td.Exists(host) From bd004d74c21f2161ce13f3b7d6126c3523c7ae69 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 28 Sep 2019 10:20:23 -0700 Subject: [PATCH 034/145] Refactors TOFU approach --- client.go | 2 +- gemini/gemini.go | 114 ++++++++++++++++++++++++++++------------------- 2 files changed, 70 insertions(+), 46 deletions(-) diff --git a/client.go b/client.go index 241bbc4..3f84350 100644 --- a/client.go +++ b/client.go @@ -551,7 +551,7 @@ func (c *client) doLinkCommand(action, target string) { num -= 1 links := c.PageState.History[c.PageState.Position].Links - if num >= len(links) || num < 0 { + if num >= len(links) || num < 1 { c.SetMessage(fmt.Sprintf("Invalid link id: %s", target), true) c.DrawMessage() return diff --git a/gemini/gemini.go b/gemini/gemini.go index 4e03492..ef4ee15 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -56,15 +56,55 @@ func (t *TofuDigest) Find(host string) (string, error) { return "", fmt.Errorf("Invalid hostname, no key saved") } -func (t *TofuDigest) Match(host, hash string) bool { +func (t *TofuDigest) Match(host string, cState *tls.ConnectionState) error { host = strings.ToLower(host) - if _, ok := t.certs[host]; !ok { - return false + now := time.Now() + + for _, cert := range cState.PeerCertificates { + if t.certs[host] != hashCert(cert.Raw) { + continue + } + + if now.Before(cert.NotBefore) { + return fmt.Errorf("Certificate is not valid yet") + } + + if now.After(cert.NotAfter) { + return fmt.Errorf("EXP") + } + + if err := cert.VerifyHostname(host); err != nil { + return fmt.Errorf("Certificate error: %s", err) + } + + return nil } - if t.certs[host] == hash { - return true + + return fmt.Errorf("No matching certificate was found for host %q", host) +} + +func (t *TofuDigest) newCert(host string, cState *tls.ConnectionState) error { + host = strings.ToLower(host) + now := time.Now() + + for _, cert := range cState.PeerCertificates { + if now.Before(cert.NotBefore) { + continue + } + + if now.After(cert.NotAfter) { + continue + } + + if err := cert.VerifyHostname(host); err != nil { + continue + } + + t.Add(host, hashCert(cert.Raw)) + return nil } - return false + + return fmt.Errorf("No valid certificates were offered by host %q", host) } func (t *TofuDigest) IniDump() string { @@ -105,53 +145,37 @@ func Retrieve(host, port, resource string, td *TofuDigest) (string, error) { return "", err } - now := time.Now() - defer conn.Close() - // Verify that the handshake ahs completed and that - // the hostname on the certificate(s) from the server - // is the hostname we have requested connState := conn.ConnectionState() + + // Begin TOFU screening... + + // If no certificates are offered, bail out if len(connState.PeerCertificates) < 1 { return "", fmt.Errorf("Insecure, no certificates offered by server") } - hostCertExists := td.Exists(host) - matched := false - for _, cert := range connState.PeerCertificates { - if hostCertExists { - if td.Match(host, hashCert(cert.Raw)) { - matched = true - if now.Before(cert.NotBefore) { - return "", fmt.Errorf("Server certificate error: certificate not valid yet") - } - - if now.After(cert.NotAfter) { - return "", fmt.Errorf("Server certificate error: certificate expired") - } - - if err = cert.VerifyHostname(host); err != nil { - return "", fmt.Errorf("Server certificate error: %s", err) - } - break - } - } else { - if now.Before(cert.NotBefore) || now.After(cert.NotAfter) { - continue + if td.Exists(host) { + err := td.Match(host, &connState) + if err != nil && err.Error() != "EXP" { + // On any error other than EXP (expired), return the error + return "", err + } else if err.Error() == "EXP" { + // If the certificate we had was expired, check if they have + // offered a new valid cert and update the certificate + err := td.newCert(host, &connState) + if err != nil { + // If there are no valid certs to offer, let the client know + return "", err } - - if err = cert.VerifyHostname(host); err != nil { - return "", fmt.Errorf("Server certificate error: %s", err) - } - - td.Add(host, hashCert(cert.Raw)) - matched = true } - } - - if !matched { - return "", fmt.Errorf("Server certificate error: No matching certificate provided") + } else { + err = td.newCert(host, &connState) + if err != nil { + // If there are no valid certs to offer, let the client know + return "", err + } } send := "gemini://" + addr + "/" + resource + "\r\n" @@ -345,7 +369,7 @@ func hashCert(cert []byte) string { for i, data := range hash { hex[i] = []byte(fmt.Sprintf("%02X", data)) } - return fmt.Sprintf("%s", string(bytes.Join(hex, []byte("-")))) + return fmt.Sprintf("%s", string(bytes.Join(hex, []byte(":")))) } From 2fd2d6c722561818896f413edf0e6160b8a5af8e Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 28 Sep 2019 16:29:42 -0700 Subject: [PATCH 035/145] Added command for user purging of certificates, and fixed multiword search --- client.go | 26 ++++++++++++++++++++++++-- cmdparse/lexer.go | 8 +++++--- gemini/gemini.go | 10 +++++++--- 3 files changed, 36 insertions(+), 8 deletions(-) diff --git a/client.go b/client.go index 3f84350..a8b7b2f 100644 --- a/client.go +++ b/client.go @@ -279,6 +279,8 @@ func (c *client) simpleCommand(action string) { case "B", "BOOKMARKS": c.BookMarks.ToggleOpen() c.Draw() + case "R", "REFRESH": + // TODO build refresh code case "SEARCH": c.search("", "", "?") case "HELP", "?": @@ -299,8 +301,27 @@ func (c *client) doCommand(action string, values []string) { switch action { case "CHECK", "C": c.displayConfigValue(values[0]) + case "PURGE", "P": + err := c.Certs.Purge(values[0]) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + if values[0] == "*" { + c.SetMessage("All certificates have been purged", false) + c.DrawMessage() + } else { + c.SetMessage(fmt.Sprintf("The certificate for %q has been purged", strings.ToLower(values[0])), false) + c.DrawMessage() + } + err = saveConfig() + if err != nil { + c.SetMessage("Error saving purge to file", true) + c.DrawMessage() + } case "SEARCH": - c.search(strings.Join(values, " "), "", "") + c.search(values[0], "", "") case "WRITE", "W": if values[0] == "." { values[0] = c.PageState.History[c.PageState.Position].Location.Full @@ -360,7 +381,8 @@ func (c *client) doCommandAs(action string, values []string) { if c.BookMarks.IsOpen { c.Draw() } - + case "SEARCH": + c.search(strings.Join(values, " "), "", "") case "WRITE", "W": u, err := MakeUrl(values[0]) if err != nil { diff --git a/cmdparse/lexer.go b/cmdparse/lexer.go index 673d7dc..529bb2a 100644 --- a/cmdparse/lexer.go +++ b/cmdparse/lexer.go @@ -68,9 +68,11 @@ func (s *scanner) scanText() Token { capInput := strings.ToUpper(buf.String()) switch capInput { - case "DELETE", "ADD", "WRITE", "SET", "RECALL", "R", "SEARCH", - "W", "A", "D", "S", "Q", "QUIT", "B", "BOOKMARKS", "H", - "HOME", "?", "HELP", "C", "CHECK": + case "D", "DELETE", "A", "ADD","W", "WRITE", + "S", "SET", "R", "REFRESH", "SEARCH", + "Q", "QUIT", "B", "BOOKMARKS", "H", + "HOME", "?", "HELP", "C", "CHECK", + "P", "PURGE": return Token{Action, capInput} } diff --git a/gemini/gemini.go b/gemini/gemini.go index ef4ee15..878f6b7 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -30,12 +30,16 @@ type TofuDigest struct { // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ -func (t *TofuDigest) Remove(host string) error { - if _, ok := t.certs[strings.ToLower(host)]; ok { +func (t *TofuDigest) Purge(host string) error { + host = strings.ToLower(host) + if host == "*" { + t.certs = make(map[string]string) + return nil + } else if _, ok := t.certs[strings.ToLower(host)]; ok { delete(t.certs, host) return nil } - return fmt.Errorf("Invalid host") + return fmt.Errorf("Invalid host %q", host) } func (t *TofuDigest) Add(host, hash string) { From 8edf886488e3d01a007ed27229bc3055487be61c Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 28 Sep 2019 16:58:42 -0700 Subject: [PATCH 036/145] Fixes a logical isssue where I was checking an errors value, but the error may have been nil and therefore had no value --- gemini/gemini.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gemini/gemini.go b/gemini/gemini.go index 878f6b7..fc0d3dc 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -161,13 +161,14 @@ func Retrieve(host, port, resource string, td *TofuDigest) (string, error) { } if td.Exists(host) { + // See if we have a matching cert err := td.Match(host, &connState) if err != nil && err.Error() != "EXP" { - // On any error other than EXP (expired), return the error + // If there is no match and it isnt because of an expiration + // just return the error return "", err - } else if err.Error() == "EXP" { - // If the certificate we had was expired, check if they have - // offered a new valid cert and update the certificate + } else if err != nil { + // The cert expired, see if they are offering one that is valid... err := td.newCert(host, &connState) if err != nil { // If there are no valid certs to offer, let the client know From df793c78f235b5de990415fa40637e33b1b53d4f Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Tue, 1 Oct 2019 21:38:13 -0700 Subject: [PATCH 037/145] Adds basic functioning client cert, but always sends. Would prefer to only send on ask. --- defaults.go | 2 ++ gemini/gemini.go | 20 ++++++++++++++++++-- main.go | 3 +++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/defaults.go b/defaults.go index 690a403..e3273d2 100644 --- a/defaults.go +++ b/defaults.go @@ -21,5 +21,7 @@ var defaultOptions = map[string]string{ "configlocation": userinfo.HomeDir, "theme": "normal", // "normal", "inverted" "terminalonly": "true", + "tlscertificate": "", + "tlskey": "", } diff --git a/gemini/gemini.go b/gemini/gemini.go index fc0d3dc..bba7377 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -22,7 +22,9 @@ type Capsule struct { type TofuDigest struct { - certs map[string]string + certs map[string]string + ClientCert tls.Certificate + UseClientCert bool } @@ -30,6 +32,16 @@ type TofuDigest struct { // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ +func (t *TofuDigest) LoadCertificate(cert, key string) { + validClientCert := true + certificate, err := tls.LoadX509KeyPair(cert, key) + if err != nil { + panic(err) + } + t.ClientCert = certificate + t.UseClientCert = validClientCert +} + func (t *TofuDigest) Purge(host string) error { host = strings.ToLower(host) if host == "*" { @@ -144,6 +156,10 @@ func Retrieve(host, port, resource string, td *TofuDigest) (string, error) { InsecureSkipVerify: true, } + if td.UseClientCert { + conf.Certificates = []tls.Certificate{td.ClientCert} + } + conn, err := tls.Dial("tcp", addr, conf) if err != nil { return "", err @@ -383,5 +399,5 @@ func MakeCapsule() Capsule { } func MakeTofuDigest() TofuDigest { - return TofuDigest{make(map[string]string)} + return TofuDigest{make(map[string]string), tls.Certificate{}, false} } diff --git a/main.go b/main.go index 41f3be3..a989364 100644 --- a/main.go +++ b/main.go @@ -138,6 +138,9 @@ func initClient() error { bombadillo = MakeClient(" ((( Bombadillo ))) ") cui.SetCharMode() err := loadConfig() + if bombadillo.Options["tlscertificate"] != "" && bombadillo.Options["tlskey"] != "" { + bombadillo.Certs.LoadCertificate(bombadillo.Options["tlscertificate"], bombadillo.Options["tlskey"]) + } return err } From 5539f6c2c61f114542b9332f0336f9eb704367b8 Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Wed, 2 Oct 2019 09:24:01 -0700 Subject: [PATCH 038/145] Switches the way client certs are provided --- gemini/gemini.go | 4 +++- go.mod | 2 ++ go.sum | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 go.sum diff --git a/gemini/gemini.go b/gemini/gemini.go index bba7377..9e474fc 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -157,7 +157,9 @@ func Retrieve(host, port, resource string, td *TofuDigest) (string, error) { } if td.UseClientCert { - conf.Certificates = []tls.Certificate{td.ClientCert} + conf.GetClientCertificate = func(*tls.CertificateRequestInfo) (*tls.Certificate, error) { + return &td.ClientCert, nil + } } conn, err := tls.Dial("tcp", addr, conf) diff --git a/go.mod b/go.mod index 143f7b1..4326c42 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module tildegit.org/sloum/bombadillo go 1.10 + +require tildegit.org/sloum/mailcap v0.0.0-20190706214029-b787a49e9db2 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..60768f8 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +tildegit.org/sloum/mailcap v0.0.0-20190706214029-b787a49e9db2 h1:tAPIFBpXwOq1Ytxk8aGsDjCutnwUC01BVkK77QS1bdU= +tildegit.org/sloum/mailcap v0.0.0-20190706214029-b787a49e9db2/go.mod h1:m4etAw9DbXsdanDUNS8oERhL+7y4II82ZLHWzw2yibg= From c12bc16015f7b89653f75ba2d27bf0d797bdbc21 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Wed, 2 Oct 2019 19:25:29 -0700 Subject: [PATCH 039/145] Sets certificate to update as SET is called --- client.go | 3 +++ gemini/gemini.go | 14 +++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/client.go b/client.go index a8b7b2f..424cb97 100644 --- a/client.go +++ b/client.go @@ -403,6 +403,9 @@ func (c *client) doCommandAs(action string, values []string) { return } c.Options[values[0]] = lowerCaseOpt(values[0], val) + if values[0] == "tlskey" || values[0] == "tlscertificate" { + c.Certs.LoadCertificate(c.Options["tlscertificate"], c.Options["tlskey"]) + } err := saveConfig() if err != nil { c.SetMessage("Value set, but error saving config to file", true) diff --git a/gemini/gemini.go b/gemini/gemini.go index 9e474fc..14bf788 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -24,7 +24,6 @@ type Capsule struct { type TofuDigest struct { certs map[string]string ClientCert tls.Certificate - UseClientCert bool } @@ -33,13 +32,12 @@ type TofuDigest struct { //--------------------------------------------------\\ func (t *TofuDigest) LoadCertificate(cert, key string) { - validClientCert := true certificate, err := tls.LoadX509KeyPair(cert, key) if err != nil { - panic(err) + t.ClientCert = tls.Certificate{} + return } t.ClientCert = certificate - t.UseClientCert = validClientCert } func (t *TofuDigest) Purge(host string) error { @@ -156,10 +154,8 @@ func Retrieve(host, port, resource string, td *TofuDigest) (string, error) { InsecureSkipVerify: true, } - if td.UseClientCert { - conf.GetClientCertificate = func(*tls.CertificateRequestInfo) (*tls.Certificate, error) { - return &td.ClientCert, nil - } + conf.GetClientCertificate = func(*tls.CertificateRequestInfo) (*tls.Certificate, error) { + return &td.ClientCert, nil } conn, err := tls.Dial("tcp", addr, conf) @@ -401,5 +397,5 @@ func MakeCapsule() Capsule { } func MakeTofuDigest() TofuDigest { - return TofuDigest{make(map[string]string), tls.Certificate{}, false} + return TofuDigest{make(map[string]string), tls.Certificate{}} } From 3b1065f384a85d8facdc54ad1f75160bb0547d9d Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Wed, 2 Oct 2019 19:37:39 -0700 Subject: [PATCH 040/145] Updating go module declaration to require go 1.12+ --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 4326c42..609acc7 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,5 @@ module tildegit.org/sloum/bombadillo -go 1.10 +go 1.12 require tildegit.org/sloum/mailcap v0.0.0-20190706214029-b787a49e9db2 From 484fb77aa3efe31ae3986b0961fc7deae3bd38b3 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Fri, 4 Oct 2019 22:50:06 -0700 Subject: [PATCH 041/145] Adds support for local files, making bombadillo a functional pager --- client.go | 15 +++++++++++++++ local/local.go | 21 +++++++++++++++++++++ url.go | 26 +++++++++++++++++++++++++- 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 local/local.go diff --git a/client.go b/client.go index a8b7b2f..a7db115 100644 --- a/client.go +++ b/client.go @@ -15,6 +15,7 @@ import ( "tildegit.org/sloum/bombadillo/gemini" "tildegit.org/sloum/bombadillo/gopher" "tildegit.org/sloum/bombadillo/http" + "tildegit.org/sloum/bombadillo/local" "tildegit.org/sloum/bombadillo/telnet" ) @@ -966,6 +967,20 @@ func (c *client) Visit(url string) { c.SetMessage("'openhttp' is not set to true, cannot open web link", false) c.DrawMessage() } + case "local": + content, err := local.Open(u.Resource) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + pg := MakePage(u, content, []string{}) + pg.WrapContent(c.Width - 1) + c.PageState.Add(pg) + c.SetPercentRead() + c.ClearMessage() + c.SetHeaderUrl() + c.Draw() default: c.SetMessage(fmt.Sprintf("%q is not a supported protocol", u.Scheme), true) c.DrawMessage() diff --git a/local/local.go b/local/local.go new file mode 100644 index 0000000..c119be7 --- /dev/null +++ b/local/local.go @@ -0,0 +1,21 @@ +package local + +import ( + "fmt" + "io/ioutil" + "os" +) + +func Open(address string) (string, error) { + file, err := os.Open(address) + if err != nil { + return "", fmt.Errorf("Unable to open file: %s", address) + } + defer file.Close() + + bytes, err := ioutil.ReadAll(file) + if err != nil { + return "", fmt.Errorf("Unable to read file: %s", address) + } + return string(bytes), nil +} diff --git a/url.go b/url.go index 73b5226..1850887 100644 --- a/url.go +++ b/url.go @@ -2,6 +2,8 @@ package main import ( "fmt" + "os" + "path/filepath" "regexp" "strings" ) @@ -37,7 +39,29 @@ type Url struct { // an error (or nil). func MakeUrl(u string) (Url, error) { var out Url - re := regexp.MustCompile(`^((?P[a-zA-Z]+):\/\/)?(?P[\w\-\.\d]+)(?::(?P\d+)?)?(?:/(?P[01345679gIhisp])?)?(?P.*)?$`) + if local := strings.HasPrefix(u, "local://"); u[0] == '/' || u[0] == '.' || u[0] == '~' || local { + if local && len(u) > 8 { + u = u[8:] + } + home, err := os.UserHomeDir() + if err != nil { + home = "" + } + u = strings.Replace(u, "~", home, 1) + res, err := filepath.Abs(u) + if err != nil { + return out, fmt.Errorf("Invalid path, unable to parse") + } + out.Scheme = "local" + out.Host = "" + out.Port = "" + out.Mime = "" + out.Resource = res + out.Full = out.Scheme + "://" + out.Resource + return out, nil + } + + re := regexp.MustCompile(`^((?P[a-zA-Z]+):\/\/)?(?P[\w\-\.\d/]+)(?::(?P\d+)?)?(?:/(?P[01345679gIhisp])?)?(?P.*)?$`) match := re.FindStringSubmatch(u) if valid := re.MatchString(u); !valid { From ee9fc8332c8287f26500975ba394c3b12cf21bb1 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 5 Oct 2019 13:10:09 -0700 Subject: [PATCH 042/145] Adds support for listing directories as well as getting file contents --- local/local.go | 39 +++++++++++++++++++++++++++++++++++++++ url.go | 1 + 2 files changed, 40 insertions(+) diff --git a/local/local.go b/local/local.go index c119be7..cbcfe0e 100644 --- a/local/local.go +++ b/local/local.go @@ -4,18 +4,57 @@ import ( "fmt" "io/ioutil" "os" + "strings" ) func Open(address string) (string, error) { + if !pathExists(address) { + return "", fmt.Errorf("Invalid system path: %s", address) + } + file, err := os.Open(address) if err != nil { return "", fmt.Errorf("Unable to open file: %s", address) } defer file.Close() + + if pathIsDir(address) { + fileList, err := file.Readdirnames(0) + if err != nil { + return "", fmt.Errorf("Unable to read from directory: %s", address) + } + var out strings.Builder + out.WriteString(fmt.Sprintf("Current directory: %s\n\n", address)) + for _, obj := range fileList { + out.WriteString(obj) + out.WriteString("\n") + } + return out.String(), nil + } + bytes, err := ioutil.ReadAll(file) if err != nil { return "", fmt.Errorf("Unable to read file: %s", address) } return string(bytes), nil } + + +func pathExists(p string) bool { + exists := true + + if _, err := os.Stat(p); os.IsNotExist(err) { + exists = false + } + + return exists +} + +func pathIsDir(p string) bool { + info, err := os.Stat(p) + if err != nil { + return false + } + return info.IsDir() +} diff --git a/url.go b/url.go index 1850887..21c140c 100644 --- a/url.go +++ b/url.go @@ -130,3 +130,4 @@ func MakeUrl(u string) (Url, error) { return out, nil } + From b5fc017978da47f5fac13e0c3f2bc6a65d11ca91 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 5 Oct 2019 17:55:15 -0700 Subject: [PATCH 043/145] Added refresh feature --- client.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/client.go b/client.go index a7db115..9c45107 100644 --- a/client.go +++ b/client.go @@ -187,6 +187,15 @@ func (c *client) TakeControlInput() { c.SetPercentRead() c.Draw() } + case 'R': + c.ClearMessage() + err := c.ReloadPage() + if err != nil { + c.SetMessage(err.Error(), false) + c.DrawMessage() + } else { + c.Draw() + } case 'B': // open the bookmarks browser c.BookMarks.ToggleOpen() @@ -987,6 +996,21 @@ func (c *client) Visit(url string) { } } +func (c *client) ReloadPage() error { + if c.PageState.Length < 1 { + return fmt.Errorf("There is no page to reload") + } + url := c.PageState.History[c.PageState.Position].Location.Full + err := c.PageState.NavigateHistory(-1) + if err != nil { + return err + } + length := c.PageState.Length + c.Visit(url) + c.PageState.Length = length + return nil +} + //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ From b2a8e7dba5dded073e678b8b783063550f978f13 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 6 Oct 2019 19:59:46 -0700 Subject: [PATCH 044/145] Adds basic finger protocol support to Bombadillo --- client.go | 15 +++++++++++++++ finger/finger.go | 31 +++++++++++++++++++++++++++++++ url.go | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 finger/finger.go diff --git a/client.go b/client.go index a8b7b2f..1e7c93d 100644 --- a/client.go +++ b/client.go @@ -12,6 +12,7 @@ import ( "tildegit.org/sloum/bombadillo/cmdparse" "tildegit.org/sloum/bombadillo/cui" + "tildegit.org/sloum/bombadillo/finger" "tildegit.org/sloum/bombadillo/gemini" "tildegit.org/sloum/bombadillo/gopher" "tildegit.org/sloum/bombadillo/http" @@ -966,6 +967,20 @@ func (c *client) Visit(url string) { c.SetMessage("'openhttp' is not set to true, cannot open web link", false) c.DrawMessage() } + case "finger": + content, err := finger.Finger(u.Host, u.Port, u.Resource) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + pg := MakePage(u, content, []string{}) + pg.WrapContent(c.Width - 1) + c.PageState.Add(pg) + c.SetPercentRead() + c.ClearMessage() + c.SetHeaderUrl() + c.Draw() default: c.SetMessage(fmt.Sprintf("%q is not a supported protocol", u.Scheme), true) c.DrawMessage() diff --git a/finger/finger.go b/finger/finger.go new file mode 100644 index 0000000..d02a1b1 --- /dev/null +++ b/finger/finger.go @@ -0,0 +1,31 @@ +package finger + +import ( + "fmt" + "net" + "io/ioutil" + "time" +) + +func Finger(host, port, resource string) (string, error) { + addr := fmt.Sprintf("%s:%s", host, port) + + timeOut := time.Duration(3) * time.Second + conn, err := net.DialTimeout("tcp", addr, timeOut) + if err != nil { + return "", err + } + + defer conn.Close() + + _, err = conn.Write([]byte(resource + "\r\n")) + if err != nil { + return "", err + } + + result, err := ioutil.ReadAll(conn) + if err != nil { + return "", err + } + return string(result), nil +} diff --git a/url.go b/url.go index 73b5226..0588ab1 100644 --- a/url.go +++ b/url.go @@ -36,6 +36,13 @@ type Url struct { // representation of a url and returns a Url struct and // an error (or nil). func MakeUrl(u string) (Url, error) { + if len(u) < 1 { + return Url{}, fmt.Errorf("Invalid url, unable to parse") + } + if strings.HasPrefix(u, "finger://") { + return parseFinger(u) + } + var out Url re := regexp.MustCompile(`^((?P[a-zA-Z]+):\/\/)?(?P[\w\-\.\d]+)(?::(?P\d+)?)?(?:/(?P[01345679gIhisp])?)?(?P.*)?$`) match := re.FindStringSubmatch(u) @@ -106,3 +113,32 @@ func MakeUrl(u string) (Url, error) { return out, nil } + +func parseFinger(u string) (Url, error) { + var out Url + out.Scheme = "finger" + if len(u) < 10 { + return out, fmt.Errorf("Invalid finger address") + } + u = u[9:] + userPlusAddress := strings.Split(u, "@") + if len(userPlusAddress) > 1 { + out.Resource = userPlusAddress[0] + u = userPlusAddress[1] + } + hostPort := strings.Split(u, ":") + if len(hostPort) < 2 { + out.Port = "79" + } else { + out.Port = hostPort[1] + } + out.Host = hostPort[0] + resource := "" + if out.Resource != "" { + resource = out.Resource + "@" + } + out.Full = fmt.Sprintf("%s://%s%s:%s", out.Scheme, resource, out.Host, out.Port) + return out, nil +} + + From 104582907613246d2f49af3ab04de63b9680a716 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 8 Oct 2019 18:13:01 +1100 Subject: [PATCH 045/145] Simple fix applied, expanded error message, gofmt --- client.go | 82 ++++++++++++++++++++++++++----------------------------- 1 file changed, 38 insertions(+), 44 deletions(-) diff --git a/client.go b/client.go index a8b7b2f..dfacbc1 100644 --- a/client.go +++ b/client.go @@ -23,19 +23,18 @@ import ( //--------------------------------------------------\\ type client struct { - Height int - Width int - Options map[string]string - Message string + Height int + Width int + Options map[string]string + Message string MessageIsErr bool - PageState Pages - BookMarks Bookmarks - TopBar Headbar - FootBar Footbar - Certs gemini.TofuDigest + PageState Pages + BookMarks Bookmarks + TopBar Headbar + FootBar Footbar + Certs gemini.TofuDigest } - //------------------------------------------------\\ // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ @@ -82,21 +81,21 @@ func (c *client) GetSize() { func (c *client) Draw() { var screen strings.Builder - screen.Grow(c.Height * c.Width + c.Width) + screen.Grow(c.Height*c.Width + c.Width) screen.WriteString("\033[0m") screen.WriteString(c.TopBar.Render(c.Width, c.Options["theme"])) screen.WriteString("\n") - pageContent := c.PageState.Render(c.Height, c.Width - 1) - if c.Options["theme"] == "inverse" { + pageContent := c.PageState.Render(c.Height, c.Width-1) + if c.Options["theme"] == "inverse" { screen.WriteString("\033[7m") } if c.BookMarks.IsOpen { bm := c.BookMarks.Render(c.Width, c.Height) bmWidth := len([]rune(bm[0])) - for i := 0; i < c.Height - 3; i++ { + for i := 0; i < c.Height-3; i++ { if c.Width > bmWidth { contentWidth := c.Width - bmWidth - if i < len(pageContent) { + if i < len(pageContent) { screen.WriteString(fmt.Sprintf("%-*.*s", contentWidth, contentWidth, pageContent[i])) } else { screen.WriteString(fmt.Sprintf("%-*.*s", contentWidth, contentWidth, " ")) @@ -109,7 +108,7 @@ func (c *client) Draw() { } else if !c.BookMarks.IsFocused { screen.WriteString("\033[2m") } - + screen.WriteString(bm[i]) if c.Options["theme"] == "inverse" && !c.BookMarks.IsFocused { @@ -121,9 +120,9 @@ func (c *client) Draw() { screen.WriteString("\n") } } else { - for i := 0; i < c.Height - 3; i++ { + for i := 0; i < c.Height-3; i++ { if i < len(pageContent) { - screen.WriteString(fmt.Sprintf("%-*.*s", c.Width - 1, c.Width - 1, pageContent[i])) + screen.WriteString(fmt.Sprintf("%-*.*s", c.Width-1, c.Width-1, pageContent[i])) screen.WriteString("\n") } else { screen.WriteString(fmt.Sprintf("%-*.*s", c.Width, c.Width, " ")) @@ -137,7 +136,7 @@ func (c *client) Draw() { screen.WriteString("\n") // for the input line screen.WriteString(c.FootBar.Render(c.Width, c.PageState.Position, c.Options["theme"])) // cui.Clear("screen") - cui.MoveCursorTo(0,0) + cui.MoveCursorTo(0, 0) fmt.Print(screen.String()) } @@ -167,12 +166,12 @@ func (c *client) TakeControlInput() { case 'd': // scroll down 75% c.ClearMessage() - distance := c.Height - c.Height / 4 + distance := c.Height - c.Height/4 c.Scroll(distance) case 'u': // scroll up 75% c.ClearMessage() - distance := c.Height - c.Height / 4 + distance := c.Height - c.Height/4 c.Scroll(-distance) case 'b': // go back @@ -239,7 +238,6 @@ func (c *client) TakeControlInput() { } } - func (c *client) routeCommandInput(com *cmdparse.Command) error { var err error switch com.Type { @@ -286,7 +284,7 @@ func (c *client) simpleCommand(action string) { case "HELP", "?": go c.Visit(helplocation) default: - c.SetMessage(fmt.Sprintf("Unknown action %q", action), true) + c.SetMessage(fmt.Sprintf("Unknown action %q", action), true) c.DrawMessage() } } @@ -335,7 +333,7 @@ func (c *client) doCommand(action string, values []string) { fns := strings.Split(u.Resource, "/") var fn string if len(fns) > 0 { - fn = strings.Trim(fns[len(fns) - 1], "\t\r\n \a\f\v") + fn = strings.Trim(fns[len(fns)-1], "\t\r\n \a\f\v") } else { fn = "index" } @@ -345,7 +343,7 @@ func (c *client) doCommand(action string, values []string) { c.saveFile(u, fn) default: - c.SetMessage(fmt.Sprintf("Unknown action %q", action), true) + c.SetMessage(fmt.Sprintf("Unknown action %q", action), true) c.DrawMessage() } } @@ -461,7 +459,7 @@ func (c *client) doLinkCommandAs(action, target string, values []string) { c.Draw() } case "WRITE", "W": - out := make([]string, 0, len(values) + 1) + out := make([]string, 0, len(values)+1) out = append(out, links[num]) out = append(out, values...) c.doCommandAs(action, out) @@ -470,7 +468,6 @@ func (c *client) doLinkCommandAs(action, target string, values []string) { } } - func (c *client) getCurrentPageUrl() (string, error) { if c.PageState.Length < 1 { return "", fmt.Errorf("There are no pages in history") @@ -506,10 +503,10 @@ func (c *client) saveFile(u Url, name string) { c.DrawMessage() return } - savePath := c.Options["savelocation"] + name + savePath := c.Options["savelocation"] + "/" + name err = ioutil.WriteFile(savePath, file, 0644) if err != nil { - c.SetMessage("Error writing file to disk", true) + c.SetMessage("Error writing file: "+err.Error(), true) c.DrawMessage() return } @@ -541,7 +538,6 @@ func (c *client) doLinkCommand(action, target string) { c.DrawMessage() } - switch action { case "DELETE", "D": msg, err := c.BookMarks.Delete(num) @@ -579,7 +575,7 @@ func (c *client) doLinkCommand(action, target string) { return } link := links[num] - c.SetMessage(fmt.Sprintf("[%d] %s", num + 1, link), false) + c.SetMessage(fmt.Sprintf("[%d] %s", num+1, link), false) c.DrawMessage() case "WRITE", "W": links := c.PageState.History[c.PageState.Position].Links @@ -597,7 +593,7 @@ func (c *client) doLinkCommand(action, target string) { fns := strings.Split(u.Resource, "/") var fn string if len(fns) > 0 { - fn = strings.Trim(fns[len(fns) - 1], "\t\r\n \a\f\v") + fn = strings.Trim(fns[len(fns)-1], "\t\r\n \a\f\v") } else { fn = "index" } @@ -606,7 +602,7 @@ func (c *client) doLinkCommand(action, target string) { } c.saveFile(u, fn) default: - c.SetMessage(fmt.Sprintf("Action %q does not exist for target %q", action, target), true) + c.SetMessage(fmt.Sprintf("Action %q does not exist for target %q", action, target), true) c.DrawMessage() } @@ -645,11 +641,11 @@ func (c *client) search(query, url, question string) { } switch u.Scheme { case "gopher": - go c.Visit(fmt.Sprintf("%s\t%s",u.Full,entry)) + go c.Visit(fmt.Sprintf("%s\t%s", u.Full, entry)) case "gemini": // TODO url escape the entry variable escapedEntry := entry - go c.Visit(fmt.Sprintf("%s?%s",u.Full,escapedEntry)) + go c.Visit(fmt.Sprintf("%s?%s", u.Full, escapedEntry)) case "http", "https": c.Visit(u.Full) default: @@ -707,10 +703,10 @@ func (c *client) Scroll(amount int) { c.PageState.History[c.PageState.Position].ScrollPosition = newScrollPosition - if len(page.WrappedContent) < c.Height - 3 { + if len(page.WrappedContent) < c.Height-3 { percentRead = 100 } else { - percentRead = int(float32(newScrollPosition + c.Height - 3) / float32(len(page.WrappedContent)) * 100.0) + percentRead = int(float32(newScrollPosition+c.Height-3) / float32(len(page.WrappedContent)) * 100.0) } c.FootBar.SetPercentRead(percentRead) } @@ -720,10 +716,10 @@ func (c *client) Scroll(amount int) { func (c *client) SetPercentRead() { page := c.PageState.History[c.PageState.Position] var percentRead int - if len(page.WrappedContent) < c.Height - 3 { + if len(page.WrappedContent) < c.Height-3 { percentRead = 100 } else { - percentRead = int(float32(page.ScrollPosition + c.Height - 3) / float32(len(page.WrappedContent)) * 100.0) + percentRead = int(float32(page.ScrollPosition+c.Height-3) / float32(len(page.WrappedContent)) * 100.0) } c.FootBar.SetPercentRead(percentRead) } @@ -830,7 +826,7 @@ func (c *client) Visit(url string) { case "gopher": if u.DownloadOnly { nameSplit := strings.Split(u.Resource, "/") - filename := nameSplit[len(nameSplit) - 1] + filename := nameSplit[len(nameSplit)-1] filename = strings.Trim(filename, " \t\r\n\v\f\a") if filename == "" { filename = "gopherfile" @@ -924,7 +920,7 @@ func (c *client) Visit(url string) { c.Draw() case 'w': nameSplit := strings.Split(u.Resource, "/") - filename := nameSplit[len(nameSplit) - 1] + filename := nameSplit[len(nameSplit)-1] c.saveFileFromData(capsule.Content, filename) } } @@ -954,7 +950,7 @@ func (c *client) Visit(url string) { case "http", "https": c.SetMessage("Attempting to open in web browser", false) c.DrawMessage() - if strings.ToUpper(c.Options["openhttp"]) == "TRUE" { + if strings.ToUpper(c.Options["openhttp"]) == "TRUE" { msg, err := http.OpenInBrowser(u.Full) if err != nil { c.SetMessage(err.Error(), true) @@ -972,7 +968,6 @@ func (c *client) Visit(url string) { } } - //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ @@ -981,4 +976,3 @@ func MakeClient(name string) *client { c := client{0, 0, defaultOptions, "", false, MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar(), gemini.MakeTofuDigest()} return &c } - From d862b168639baf537d9ce7811c9320b43dc60bba Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Tue, 8 Oct 2019 19:52:06 -0700 Subject: [PATCH 046/145] Fixes bug where screan flashes clear when bookmarks are toggled closed --- bookmarks.go | 1 - 1 file changed, 1 deletion(-) diff --git a/bookmarks.go b/bookmarks.go index 3e320c4..5faf22a 100644 --- a/bookmarks.go +++ b/bookmarks.go @@ -50,7 +50,6 @@ func (b *Bookmarks) ToggleOpen() { b.IsFocused = true } else { b.IsFocused = false - cui.Clear("screen") } } From 60dafccebae76fe185d962991bd713d8bcbaba2e Mon Sep 17 00:00:00 2001 From: asdf Date: Wed, 9 Oct 2019 17:36:41 +1100 Subject: [PATCH 047/145] Fix using path/filepath Join function --- client.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index dfacbc1..aadce15 100644 --- a/client.go +++ b/client.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "os" "os/exec" + "path/filepath" "regexp" "strconv" "strings" @@ -503,7 +504,8 @@ func (c *client) saveFile(u Url, name string) { c.DrawMessage() return } - savePath := c.Options["savelocation"] + "/" + name + + savePath := filepath.Join(c.Options["savelocation"], name) err = ioutil.WriteFile(savePath, file, 0644) if err != nil { c.SetMessage("Error writing file: "+err.Error(), true) @@ -519,10 +521,11 @@ func (c *client) saveFileFromData(d, name string) { data := []byte(d) c.SetMessage(fmt.Sprintf("Saving %s ...", name), false) c.DrawMessage() - savePath := c.Options["savelocation"] + name + + savePath := filepath.Join(c.Options["savelocation"], name) err := ioutil.WriteFile(savePath, data, 0644) if err != nil { - c.SetMessage("Error writing file to disk", true) + c.SetMessage("Error writing file: "+err.Error(), true) c.DrawMessage() return } From 86485154c99b3ddcdbfc73d65f0bc95b70d40458 Mon Sep 17 00:00:00 2001 From: asdf Date: Thu, 10 Oct 2019 17:05:50 +1100 Subject: [PATCH 048/145] Inital try at handling SIGCONT --- main.go | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/main.go b/main.go index a989364..58e92a0 100644 --- a/main.go +++ b/main.go @@ -1,4 +1,5 @@ package main + // Bombadillo is a gopher and gemini client for the terminal of unix or unix-like systems. // // Copyright (C) 2019 Brian Evans @@ -16,17 +17,18 @@ package main // You should have received a copy of the GNU General Public License // along with this program. If not, see . - import ( "flag" "fmt" "io/ioutil" "os" + "os/signal" "strings" + "syscall" - _ "tildegit.org/sloum/bombadillo/gemini" "tildegit.org/sloum/bombadillo/config" "tildegit.org/sloum/bombadillo/cui" + _ "tildegit.org/sloum/bombadillo/gemini" "tildegit.org/sloum/mailcap" ) @@ -58,13 +60,13 @@ func saveConfig() error { opts.WriteString(certs) - return ioutil.WriteFile(bombadillo.Options["configlocation"] + "/.bombadillo.ini", []byte(opts.String()), 0644) + return ioutil.WriteFile(bombadillo.Options["configlocation"]+"/.bombadillo.ini", []byte(opts.String()), 0644) } func validateOpt(opt, val string) bool { var validOpts = map[string][]string{ - "openhttp": []string{"true", "false"}, - "theme": []string{"normal", "inverse"}, + "openhttp": []string{"true", "false"}, + "theme": []string{"normal", "inverse"}, "terminalonly": []string{"true", "false"}, } @@ -115,7 +117,7 @@ func loadConfig() error { } if _, ok := bombadillo.Options[lowerkey]; ok { - if validateOpt(lowerkey, v.Value) { + if validateOpt(lowerkey, v.Value) { bombadillo.Options[lowerkey] = v.Value } else { bombadillo.Options[lowerkey] = defaultOptions[lowerkey] @@ -144,6 +146,17 @@ func initClient() error { return err } +// On SIGCONT, ensure the terminal is still in the correct mode +// Accepts the signal, does the work, then starts another instance +// to handle any future occurences of SIGCONT +func handleSIGCONT(c <-chan os.Signal) { + <-c + cui.Tput("rmam") // turn off line wrapping + cui.Tput("smcup") // use alternate screen + cui.SetCharMode() + go handleSIGCONT(c) +} + func main() { getVersion := flag.Bool("v", false, "See version number") flag.Parse() @@ -153,11 +166,16 @@ func main() { } args := flag.Args() + // buffered channel to capture SIGCONT for handling + c := make(chan os.Signal, 1) + signal.Notify(c, syscall.SIGCONT) + go handleSIGCONT(c) + // Build the mailcap db // So that we can open files from gemini mc = mailcap.NewMailcap() - cui.Tput("rmam") // turn off line wrapping + cui.Tput("rmam") // turn off line wrapping cui.Tput("smcup") // use alternate screen defer cui.Exit() err := initClient() From 6faf4e5205719592c3a33022ca6a05d51189993a Mon Sep 17 00:00:00 2001 From: asdf Date: Fri, 11 Oct 2019 12:04:19 +1100 Subject: [PATCH 049/145] fixes screen display properly, better start location --- main.go | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/main.go b/main.go index 58e92a0..249139d 100644 --- a/main.go +++ b/main.go @@ -146,15 +146,17 @@ func initClient() error { return err } -// On SIGCONT, ensure the terminal is still in the correct mode -// Accepts the signal, does the work, then starts another instance -// to handle any future occurences of SIGCONT +// In the event of SIGCONT, ensure the display is shown correctly. Accepts a +// signal, blocking until it is received. Once not blocked, corrects terminal +// display settings. Loops indefinitely, does not return. func handleSIGCONT(c <-chan os.Signal) { - <-c - cui.Tput("rmam") // turn off line wrapping - cui.Tput("smcup") // use alternate screen - cui.SetCharMode() - go handleSIGCONT(c) + for { + <-c + cui.Tput("rmam") // turn off line wrapping + cui.Tput("smcup") // use alternate screen + cui.SetCharMode() + bombadillo.Draw() + } } func main() { @@ -166,11 +168,6 @@ func main() { } args := flag.Args() - // buffered channel to capture SIGCONT for handling - c := make(chan os.Signal, 1) - signal.Notify(c, syscall.SIGCONT) - go handleSIGCONT(c) - // Build the mailcap db // So that we can open files from gemini mc = mailcap.NewMailcap() @@ -184,6 +181,11 @@ func main() { panic(err) } + // watch for SIGCONT, send it to be handled + c := make(chan os.Signal, 1) + signal.Notify(c, syscall.SIGCONT) + go handleSIGCONT(c) + // Start polling for terminal size changes go bombadillo.GetSize() From 207a45d6787b677961306004dd00f96c482eb91d Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 10 Oct 2019 21:28:51 -0700 Subject: [PATCH 050/145] HOT FIX: Removes underwrite for lines when bookmarks is closed --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index 5ebe7e9..3a1a975 100644 --- a/client.go +++ b/client.go @@ -125,7 +125,7 @@ func (c *client) Draw() { } else { for i := 0; i < c.Height-3; i++ { if i < len(pageContent) { - screen.WriteString(fmt.Sprintf("%-*.*s", c.Width-1, c.Width-1, pageContent[i])) + screen.WriteString(fmt.Sprintf("%-*.*s", c.Width, c.Width, pageContent[i])) screen.WriteString("\n") } else { screen.WriteString(fmt.Sprintf("%-*.*s", c.Width, c.Width, " ")) From 74ada2b8ed2f377a26444340c07058b3f7645e43 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 10 Oct 2019 22:07:32 -0700 Subject: [PATCH 051/145] HOT FIX: Returned url regex to rightful state and fixed numerical issue with check command --- client.go | 2 +- url.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index 3a1a975..5625bf5 100644 --- a/client.go +++ b/client.go @@ -586,7 +586,7 @@ func (c *client) doLinkCommand(action, target string) { num -= 1 links := c.PageState.History[c.PageState.Position].Links - if num >= len(links) || num < 1 { + if num >= len(links) || num < 0 { c.SetMessage(fmt.Sprintf("Invalid link id: %s", target), true) c.DrawMessage() return diff --git a/url.go b/url.go index 8b23d1b..b77f0c6 100644 --- a/url.go +++ b/url.go @@ -68,7 +68,7 @@ func MakeUrl(u string) (Url, error) { return out, nil } - re := regexp.MustCompile(`^((?P[a-zA-Z]+):\/\/)?(?P[\w\-\.\d/]+)(?::(?P\d+)?)?(?:/(?P[01345679gIhisp])?)?(?P.*)?$`) + re := regexp.MustCompile(`^((?P[a-zA-Z]+):\/\/)?(?P[\w\-\.\d]+)(?::(?P\d+)?)?(?:/(?P[01345679gIhisp])?)?(?P.*)?$`) match := re.FindStringSubmatch(u) if valid := re.MatchString(u); !valid { From 3af224056ac271e225229bab3778531dd79b8653 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Fri, 11 Oct 2019 21:33:57 -0700 Subject: [PATCH 052/145] Improves certificate error messaging --- gemini/gemini.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/gemini/gemini.go b/gemini/gemini.go index 14bf788..f4700fa 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -100,17 +100,24 @@ func (t *TofuDigest) Match(host string, cState *tls.ConnectionState) error { func (t *TofuDigest) newCert(host string, cState *tls.ConnectionState) error { host = strings.ToLower(host) now := time.Now() + var reasons strings.Builder - for _, cert := range cState.PeerCertificates { + for index, cert := range cState.PeerCertificates { + if index > 0 { + reasons.WriteString("; ") + } if now.Before(cert.NotBefore) { + reasons.WriteString(fmt.Sprintf("Cert [%d] is not valid yet", index + 1)) continue } if now.After(cert.NotAfter) { + reasons.WriteString(fmt.Sprintf("Cert [%d] is expired", index + 1)) continue } if err := cert.VerifyHostname(host); err != nil { + reasons.WriteString(fmt.Sprintf("Cert [%d] hostname does not match", index + 1)) continue } @@ -118,7 +125,7 @@ func (t *TofuDigest) newCert(host string, cState *tls.ConnectionState) error { return nil } - return fmt.Errorf("No valid certificates were offered by host %q", host) + return fmt.Errorf(reasons.String()) } func (t *TofuDigest) IniDump() string { From 3537880242401af897277c20cb92fb2da7cf8225 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 12 Oct 2019 11:48:16 -0700 Subject: [PATCH 053/145] Corrected lexer commands --- client.go | 11 +++++++++-- cmdparse/lexer.go | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index 5625bf5..71b998d 100644 --- a/client.go +++ b/client.go @@ -289,8 +289,15 @@ func (c *client) simpleCommand(action string) { case "B", "BOOKMARKS": c.BookMarks.ToggleOpen() c.Draw() - case "R", "REFRESH": - // TODO build refresh code + case "R", "RELOAD": + c.ClearMessage() + err := c.ReloadPage() + if err != nil { + c.SetMessage(err.Error(), false) + c.DrawMessage() + } else { + c.Draw() + } case "SEARCH": c.search("", "", "?") case "HELP", "?": diff --git a/cmdparse/lexer.go b/cmdparse/lexer.go index 529bb2a..f61bf4c 100644 --- a/cmdparse/lexer.go +++ b/cmdparse/lexer.go @@ -69,7 +69,7 @@ func (s *scanner) scanText() Token { capInput := strings.ToUpper(buf.String()) switch capInput { case "D", "DELETE", "A", "ADD","W", "WRITE", - "S", "SET", "R", "REFRESH", "SEARCH", + "S", "SET", "R", "RELOAD", "SEARCH", "Q", "QUIT", "B", "BOOKMARKS", "H", "HOME", "?", "HELP", "C", "CHECK", "P", "PURGE": From e44666cd05067c43cedd22562f49a6f20392e296 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 12 Oct 2019 14:52:51 -0700 Subject: [PATCH 054/145] Updates man file --- bombadillo.1 | 198 ++++++++++++++++++++++++++++++++++----------------- 1 file changed, 131 insertions(+), 67 deletions(-) diff --git a/bombadillo.1 b/bombadillo.1 index 1d28a72..e023009 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -1,5 +1,4 @@ -." Text automatically generated by txt2man -.TH "bombadillo" 1 "21 SEP 2019" "" "General Opperation Manual" +.TH "bombadillo" 1 "12 OCT 2019" "" "General Opperation Manual" .SH NAME \fBbombadillo \fP- a non-web client .SH SYNOPSIS @@ -9,7 +8,7 @@ .fam T .fi .SH DESCRIPTION -\fBbombadillo\fP is a terminal based client for a number of internet protocols, including gopher and gemini. \fBbombadillo\fP will also connect links to a user's default web browser or telnet client. Commands input is loosely based on Vi and Less and is comprised of two modes: key and line input mode. +\fBbombadillo\fP is a terminal based client for a number of internet protocols. \fBbombadillo\fP will also connect links to a user's default web browser or telnet client. Commands input is loosely based on Vi and Less and is comprised of two modes: key and line input mode. .SH OPTIONS .TP .B @@ -19,6 +18,32 @@ Display the version number of \fBbombadillo\fP. .B \fB-h\fP Usage help. Displays all command line options with a short description. +.SH PROTOCOL SUPPORT +All of the below protocols are supported. With the exception of gopher, the protocol name must be present as the scheme component of a url in the form of \fI[protocol]://[the rest of the url]\fP. +.TP +.B +gopher +Gopher is the default protocol for \fBbombadillo\fP. Any textual item types will be visited and shown to the user and any non-text types will be downloaded. Type 7 (querying) is fully supported. As the default protocol, any url that is not prefixed with the scheme section of a url (\fIgopher://\fP for example) will be treated as gopher urls. +.TP +.B +gemini +Gemini is supported, but as a new protocol with an incomplete specification, features may change over time. At present Bombadillo supports TLS with a trust on first use certificate pinning system (similar to SSH). Client certificates are also supported via option configuration. Gemini maps and other text types are rendered in the client and non-text types will trigger a prompt to the user to download or open in an appropriate program. +.TP +.B +finger +Basic support is provided for the finger protocol. The format is: \fIfinger://[[username@]][hostname]\fP. Many servers still support finger and it can be fun to see if friends are online or read about the users who's phlogs you follow. +.TP +.B +local +Local is similar to the \fIfile\fP protocol user's may be used to in web browsers or the like. The only difference is that the feature set of local may be smaller than file. User's can use the local scheme to view files on their local system. Directories are supported as viewable text object as well as any files. Wildcards and globbing are not supported. Using \fI~\fP to represent a user's home directory, as well as relative paths, are supported. +.TP +.B +telnet +Telnet is not supported directly, but addresses will be followed and opened as a subprocess by whatever telnet client a user sets in their settings (defaulting to \fItelnet\fP). In some cases this behavior may be buggy. +.TP +.B +http, https +Neither of the world wide web protocols are supported directly. However, bombadillo is capable of attempting to open web links in a user's default web browser. This feature is opt-in only and controlled in a user's settings. This feature does not function properly in a terminal only environment at present. .SH COMMANDS .SS KEY COMMANDS These commands work as a single keypress anytime \fBbombadillo\fP is not taking in a line based command. This is the default command mode of \fBbombadillo\fP. @@ -60,6 +85,10 @@ q Quit \fBbombadillo\fP. .TP .B +R +Reload the current page (does not destroy forward history) +.TP +.B u Scroll up an amount corresponding to 75% of your terminal window height in the current document. .TP @@ -73,10 +102,9 @@ Enter line command mode. Once a line command is input, the mode will automatical .TP .B : -Alias for . Enter line command mode. +Alias for . Enter line command mode. .SS LINE COMMANDS These commands are typed in by the user to perform an action of some sort. As listed in KEY COMMANDS, this mode is initiated by pressing : or . The command names themselves are not case sensitive, though the arguments supplied to them may be. -.SS NAVIGATION .TP .B [url] @@ -87,55 +115,6 @@ Navigates to the requested url. Follows a link on the current document with the given number. .TP .B -bookmarks [bookmark id] -Navigates to the url represented by the bookmark matching bookmark id. \fIb\fP can be entered, rather than the full \fIbookmarks\fP. -.TP -.B -home -Navigates to the document set by the \fIhomeurl\fP setting. \fIh\fP can be entered, rather than the full \fIhome\fP. -.TP -.B -search [keywords\.\.\.] -Submits a search to the search engine set by the \fIsearchengine\fP setting, with the query being the provided keyword(s). -.TP -.B -search -Queries the user for search terms and submits a search to the search engine set by the \fIsearchengine\fP setting. -.TP -.B -write [url] -Writes data from a given url to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. -.TP -.B -write [url] [filename\.\.\.] -Writes data from a given url to a file. The file is named by the filename argument should should not include a leading \fI/\fP. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. -.TP -.B -write [link id]] -Writes data from a given link id in the current document to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. -.TP -.B -write [link id] [filename\.\.\.] -Writes data from a given link id in the current document to a file. The file is named by the filename argument should should not include a leading \fI/\fP. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. -.TP -.B -write . -Writes the current document to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. -.TP -.B -write . [filename\.\.\.] -Writes the current document to a file. The file is named by the filename argument should should not include a leading \fI/\fP. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. -.TP -.B -help -Navigates to the gopher based help page for \fBbombadillo\fP. \fI?\fP can be used instead of the full \fIhelp\fP. -.SS BOOKMARKS -.TP -.B -bookmarks -Toggles the bookmarks panel open/closed. Alias for KEY COMMAND \fIB\fP. \fIb\fP can be used instead of the full \fIbookmarks\fP. -.TP -.B add [url] [name\.\.\.] Adds the url as a bookmarks labeled by name. \fIa\fP can be used instead of the full \fIadd\fP. .TP @@ -144,13 +123,16 @@ add [link id] [name\.\.\.] Adds the url represented by the link id within the current document as a bookmark labeled by name. \fIa\fP can be used instead of the full \fIadd\fP. .TP .B -add [.] [name\.\.\.] +add . [name\.\.\.] Adds the current document's url as a bookmark labeled by name. \fIa\fP can be used instead of the full \fIadd\fP. .TP .B -delete [bookmark id]] -Deletes the bookmark matching the bookmark id. \fId\fP can be used instead of the full \fIdelete\fP. -.SS MISC +bookmarks +Toggles the bookmarks panel open/closed. Alias for KEY COMMAND \fIB\fP. \fIb\fP can be used instead of the full \fIbookmarks\fP. +.TP +.B +bookmarks [bookmark id] +Navigates to the url represented by the bookmark matching bookmark id. \fIb\fP can be entered, rather than the full \fIbookmarks\fP. .TP .B check [link id] @@ -161,14 +143,70 @@ check [setting name] Displays the current value for a given configuration setting. \fIc\fP can be used instead of the full \fIcheck\fP. .TP .B -set [setting name] -Sets the value for a given configuration setting. \fIs\fP can be used instead of the full \fIset\fP. +delete [bookmark id]] +Deletes the bookmark matching the bookmark id. \fId\fP can be used instead of the full \fIdelete\fP. +.TP +.B +help +Navigates to the gopher based help page for \fBbombadillo\fP. \fI?\fP can be used instead of the full \fIhelp\fP. +.TP +.B +home +Navigates to the document set by the \fIhomeurl\fP setting. \fIh\fP can be entered, rather than the full \fIhome\fP. +.TP +.B +purge * +Deletes all pinned gemini server certificates. \fIp\fP can be used instead of the full \fIpurge\fP. +.TP +.B +purge [host name] +Deletes the pinned gemini server certificate for the given hostname. \fIp\fP can be used instead of the full \fIpurge\fP. .TP .B quit Quits \fBbombadillo\fP. Alias for KEY COMMAND \fIq\fP. \fIq\fP can be used instead of the full \fIquit\fP. +.TP +.B +reload +Requests the current document from the server again. This does not break forward history the way entering the url again would. \fIr\fP can be used instead of the full \fIreload\fP. +.TP +.B +search +Queries the user for search terms and submits a search to the search engine set by the \fIsearchengine\fP setting. +.TP +.B +search [keywords\.\.\.] +Submits a search to the search engine set by the \fIsearchengine\fP setting, with the query being the provided keyword(s). +.TP +.B +set [setting name] +Sets the value for a given configuration setting. \fIs\fP can be used instead of the full \fIset\fP. +.TP +.B +write . +Writes the current document to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. +.TP +.B +write [url] +Writes data from a given url to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. +.TP +.B +write [link id]] +Writes data from a given link id in the current document to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. +.TP +.B +write . [filename\.\.\.] +Writes the current document to a file. The file is named by the filename argument should should not include a leading \fI/\fP. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. +.TP +.B +write [url] [filename\.\.\.] +Writes data from a given url to a file. The file is named by the filename argument should should not include a leading \fI/\fP. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. +.TP +.B +write [link id] [filename\.\.\.] +Writes data from a given link id in the current document to a file. The file is named by the filename argument should should not include a leading \fI/\fP. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. .SH FILES -\fBbombadillo\fP keeps a hidden configuration file in a user's home directory. The file is a simplified ini file titled '.bombadillo.ini'. It is generated when a user first loads \fBbombadillo\fP and is updated with bookmarks and settings as a user adds them. The file can be directly edited, but it is best to use the SET command to update settings whenever possible. To return to the state of a fresh install, simply remove the file and a new one will be generated with the \fBbombadillo\fP defaults. +\fBbombadillo\fP keeps a hidden configuration file in a user's home directory. The file is a simplified ini file titled \fI.bombadillo.ini\fP. It is generated when a user first loads \fBbombadillo\fP and is updated with bookmarks and settings as a user adds them. The file can be directly edited, but it is best to use the SET command to update settings whenever possible. To return to the state of a fresh install, simply remove the file and a new one will be generated with the \fBbombadillo\fP defaults. .SH SETTINGS The following is a list of the settings that \fBbombadillo\fP recognizes, as well as a description of their valid values. .TP @@ -177,6 +215,10 @@ homeurl The url that \fBbombadillo\fP navigates to when the program loads or when the \fIhome\fP or \fIh\fP LINE COMMAND is issued. This should be a valid url. If a scheme/protocol is not included, gopher will be assumed. .TP .B +openhttp +Tells the client whether or not to try to follow web (http/https) links. If set to \fItrue\fP, \fBbombadillo\fP will try to open a user's default web browser to the link in question. Any value other than \fItrue\fP is considered false. Defaults to \fIfalse\fP. Does not work in a terminal only environment. +.TP +.B savelocation The path to the folder that \fBbombadillo\fP should write files to. This should be a valid filepath for the system and should end in a \fI/\fP. Defaults to a user's home directory. .TP @@ -185,17 +227,39 @@ searchengine The url to use for the LINE COMMANDs \fI?\fP and \fIsearch\fP. Should be a valid search path that terms may be appended to. Defaults to \fIgopher://gopher.floodgap.com:70/7/v2/vs\fP. .TP .B -openhttp -Tells the client whether or not to try to follow web (http/https) links. If set to \fItrue\fP, \fBbombadillo\fP will try to open a user's default web browser to the link in question. Any value other than \fItrue\fP is considered false. Defaults to \fIfalse\fP. -.TP -.B telnetcommand Tells the client what command to use to start a telnet session. Should be a valid command, including any flags. The address being navigated to will be added to the end of the command. Defaults to \fItelnet\fP. .TP .B +terminalonly +Sets whether or not to try to open non-text files served via gemini in gui programs or not. If set to \fItrue\fP, bombdaillo will only attempt to use terminal programs to open files. If set to anything else, \fBbombadillo\fP may choose graphical and terminal programs. Defaults to \fItrue\fP. +.TP +.B theme Can toggle between visual modes. Valid values are \fInormal\fP and \fIinverse\fP. When set to ivnerse, the terminal color mode is inversed. Defaults to \fInormal\fP. .TP .B -terminalonly -Sets whether or not to try to open non-text files served via gemini in gui programs or not. If set to \fItrue\fP, bombdaillo will only attempt to use terminal programs to open files. If set to anything else, \fBbombadillo\fP may choose graphical and terminal programs. Defaults to \fItrue\fP. +tlscertificate +A path to a tls certificate file on a user's local filesystem. Defaults to NULL. Both \fItlscertificate\fP and \fItlskey\fP must be set for client certificates to work in gemini. +.TP +.B +tlskey +A path the a tls key that pairs with the tlscertificate setting, on a user's local filesystem. Defaults to NULL. Both \fItlskey\fP and \fItlscertificate\fP must be set for client certificates to work in gemini. +.SH BUGS +There are very likely bugs. Many known bugs can be found in the issues section of \fBbombadillo\fP's software repository (see \fIlinks\fP). +.SH LINKS +\fBbombadillo\fP maintains a web presence in the following locations: +.TP +.B +Code Repository +https://tildegit.org/sloum/bombadillo +.TP +.B +Web Homepage +http://bombadillo.colorfield.space +.TP +.B +Gopher Homepage +gopher://bombadillo.colorfield.space +.SH AUTHORS +\fBbombadillo\fP was primarily developed by sloum, with kind and patient assistance from ~asdf and jboverf. From 2dc64684bb9f919008484c288dec48e345ea5dfe Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 13 Oct 2019 22:23:04 -0700 Subject: [PATCH 055/145] More descriptive error msg --- gemini/gemini.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gemini/gemini.go b/gemini/gemini.go index f4700fa..a666329 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -167,7 +167,7 @@ func Retrieve(host, port, resource string, td *TofuDigest) (string, error) { conn, err := tls.Dial("tcp", addr, conf) if err != nil { - return "", err + return "", fmt.Errorf("TLS Dial Error: %s", err.Error()) } defer conn.Close() From 7ed2b46b326976268ff7eb27161c17824254aefc Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Mon, 14 Oct 2019 16:29:40 -0700 Subject: [PATCH 056/145] First go at a makefile, woo-hoo! --- Makefile | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ VERSION | 1 + main.go | 14 +++++++++++--- 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 Makefile create mode 100644 VERSION diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..99ba95a --- /dev/null +++ b/Makefile @@ -0,0 +1,51 @@ +BINARY := bombadillo +man1dir := /usr/local/share/man/man1 +#PKGS := $(shell go list ./... |grep -v /vendor) +VERSION := $(shell git describe --tags 2> /dev/null) +BUILD := $(shell date) +GOPATH ?= $(HOME)/go +GOBIN ?= ${GOPATH}/bin +BUILD_PATH ?= ${GOBIN} + +# If VERSION is empty or not deffined use the contents of the VERSION file +ifndef VERSION + VERSION := $(shell cat ./VERSION) +endif + +LDFLAGS := +ifdef CONF_PATH + LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD} -X main.conf_path${conf_path}" +else + LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD}" +endif + +.PHONY: test +test: + @echo ${LDFLAGS} + @echo ${VERSION} + @echo ${BUILD_PATH} + +.PHONY: build +build: + @go build ${LDFLAGS} -o ${BINARY} + +.PHONY: install +install: install-man + @go build ${LDFLAGS} -o ${BUILD_PATH}/${BINARY} + +.PHONY: install-man +install-man: bombadillo.1 + @gzip -k ./bombadillo.1 + @install -d ${man1dir} + @install -m 0644 ./bombadillo.1.gz ${man1dir} + +.PHONY: clean +clean: + @go clean -i + @rm ./bombadillo.1.gz 2> /dev/null + +.PHONY: uninstall +uninstall: clean + @rm -f ${man1dir}/bombadillo.1.gz + @echo Removing ${BINARY} + @rm -f ${BUILD_PATH}/${BINARY} diff --git a/VERSION b/VERSION new file mode 100644 index 0000000..46b105a --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +v2.0.0 diff --git a/main.go b/main.go index 249139d..ded782d 100644 --- a/main.go +++ b/main.go @@ -32,7 +32,9 @@ import ( "tildegit.org/sloum/mailcap" ) -const version = "2.0.0" +var version string +var build string +var conf_path string var bombadillo *client var helplocation string = "gopher://colorfield.space:70/1/bombadillo-info" @@ -95,6 +97,11 @@ func lowerCaseOpt(opt, val string) string { } func loadConfig() error { + // If a compile time override exists for configlocation + // set it before loading the config. + if conf_path != "" { + bombadillo.Options["configlocation"] = conf_path + } file, err := os.Open(bombadillo.Options["configlocation"] + "/.bombadillo.ini") if err != nil { err = saveConfig() @@ -109,8 +116,9 @@ func loadConfig() error { for _, v := range settings.Settings { lowerkey := strings.ToLower(v.Key) if lowerkey == "configlocation" { - // The config should always be stored in home - // folder. Users cannot really edit this value. + // The config defaults to the home folder. + // Users cannot really edit this value. But + // a compile time override is available. // It is still stored in the ini and as a part // of the options map. continue From 59aa8a1ef29f75ea9f0d343c281666caa5233d98 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Mon, 14 Oct 2019 20:25:32 -0700 Subject: [PATCH 057/145] Removes old files, updates default homepage, and more makefile stuff --- Makefile | 23 ++++--- bombadillo-info | 162 ------------------------------------------------ defaults.go | 2 +- notes.md | 60 ------------------ 4 files changed, 15 insertions(+), 232 deletions(-) delete mode 100644 bombadillo-info delete mode 100644 notes.md diff --git a/Makefile b/Makefile index 99ba95a..e5d651e 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,26 @@ BINARY := bombadillo man1dir := /usr/local/share/man/man1 -#PKGS := $(shell go list ./... |grep -v /vendor) -VERSION := $(shell git describe --tags 2> /dev/null) -BUILD := $(shell date) -GOPATH ?= $(HOME)/go +GOPATH ?= ${HOME}/go GOBIN ?= ${GOPATH}/bin BUILD_PATH ?= ${GOBIN} +# Use a dateformat rather than -I flag since OSX +# does not support -I. It also doesn't support +# %:z - so settle for %z. +BUILD_TIME := ${shell date "+%Y-%m-%dT%H:%M%z"} + # If VERSION is empty or not deffined use the contents of the VERSION file +VERSION := ${shell git describe --tags 2> /dev/null} ifndef VERSION - VERSION := $(shell cat ./VERSION) + VERSION := ${shell cat ./VERSION} endif -LDFLAGS := +# If an alternate configuration path is provided when make is run, +# include it as an ldflag ifdef CONF_PATH - LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD} -X main.conf_path${conf_path}" + LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD_TIME} -X main.conf_path=${CONF_PATH}" else - LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD}" + LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD_TIME}" endif .PHONY: test @@ -42,10 +46,11 @@ install-man: bombadillo.1 .PHONY: clean clean: @go clean -i - @rm ./bombadillo.1.gz 2> /dev/null + @rm -f ./bombadillo.1.gz 2> /dev/null .PHONY: uninstall uninstall: clean @rm -f ${man1dir}/bombadillo.1.gz @echo Removing ${BINARY} @rm -f ${BUILD_PATH}/${BINARY} + diff --git a/bombadillo-info b/bombadillo-info deleted file mode 100644 index dd5807a..0000000 --- a/bombadillo-info +++ /dev/null @@ -1,162 +0,0 @@ -i false null.host 70 -i false null.host 70 -i **** bombadillo **** false null.host 70 -i false null.host 70 -ibombadillo is a gopher client for the terminal. it functions as a pager false null.host 70 -iwith a "full screen" terminal user interface. keys are mapped similarly false null.host 70 -ito vim (as detailed below). source code can be downloaded from the link false null.host 70 -iand is written in golang. linux and osx are fully supported for both arm false null.host 70 -iand x86_64. false null.host 70 -i false null.host 70 -iin bombadillo, scroll down with 'j' and up with 'k'. this is being false null.host 70 -ilisted here to facilitate easier viewing of the rest of this doc false null.host 70 -ifor first time users. false null.host 70 -i false null.host 70 -i false null.host 70 -isource code is available here: false null.host 70 -hhttp://tildegit.org/sloum/bombadillo url:http://tildegit.org/sloum/bombadillo colorfield.space 70 -i false null.host 70 -iweb based documentation/links available here: false null.host 70 -hhttps://rawtext.club/~sloum/bombadillo.html url:https://rawtext.club/~sloum/bombadillo.html colorfield.space 70 -i false null.host 70 -i false null.host 70 -ito open the above link in bombadillo a user must enable the feature. to do so false null.host 70 -ia user would ":set openhttp true". this will open the http based web link in false null.host 70 -itheir default web browser. a user can change back to false at any time if false null.host 70 -iprefer to not open non-gopher links. if a default web browser is not set, the false null.host 70 -itrue value will still result in failure :( unfortunately, if you are in a false null.host 70 -inon-graphical environment entiely (such as in a remote shell) you will likely false null.host 70 -inot be able to open a web browser as lynx (or the like) are not generally false null.host 70 -iset up to work as a system default browser. -i false null.host 70 -ibombadillo uses, if it is available, the alternate terminal buffer. this will false null.host 70 -ihelp keep your terminal clean when you exit as well as create a better full false null.host 70 -iscreen experience in a terminal. a configuration flag to toggle this feature false null.host 70 -iis in the works. -i false null.host 70 -i false null.host 70 -i** quick start ** false null.host 70 -i false null.host 70 -iupon opening bombadillo for the first time a user will be presented with this false null.host 70 -iscreen and a top bar with the application title. to visit a page a user can false null.host 70 -ienter a colon followed by a gopher url or a link number (shown on the active false null.host 70 -ipage to the left of link text and to the right of the gopher type). For false null.host 70 -iexample: false null.host 70 -i false null.host 70 -i:colorfield.space false null.host 70 -i false null.host 70 -iupon doing so the user will see the colorfield.space gopher page false null.host 70 -iyou will see the ':' key come up a lot as it leads into many commands. false null.host 70 -i false null.host 70 -iyou can pass a url to bombadillo when opening it from the terminal. false null.host 70 -idoing so will open the client directly to that url. for example: false null.host 70 -i false null.host 70 -i bombadillo gopher://colorfield.space false null.host 70 -i false null.host 70 -i false null.host 70 -iA note on window resizing: false null.host 70 -i false null.host 70 -iIf you resize your terminal window the screen will wrap text in weird/wild false null.host 70 -iways. Pressing any key when the screen is in this state will redraw the false null.host 70 -iscreen and realign the text. false null.host 70 -i false null.host 70 -i false null.host 70 -i false null.host 70 -i** hot keys ** false null.host 70 -i false null.host 70 -isome keys function as "hot keys". when pressed, they will initite an false null.host 70 -iaction immediately. the following keys work as hot keys: false null.host 70 -i false null.host 70 -ikey behavior false null.host 70 -i-------- -------------------------------------------------------------- false null.host 70 -i q quit bombadillo false null.host 70 -i b back (go back a place in browsing history if available) false null.host 70 -i f forward (go forward a place in browsing history if available) false null.host 70 -i j scroll down (if there is room to do so) false null.host 70 -i k scroll up (if there is room to do so) false null.host 70 -i G scroll to bottom (end) false null.host 70 -i g scroll to top (home) false null.host 70 -i d page down false null.host 70 -i u page up false null.host 70 -i B toggle bookmarks sidebar into or out of view false null.host 70 -i : enter command mode false null.host 70 -i SPC enter command mode false null.host 70 -i TAB cycle window focus false null.host 70 -i false null.host 70 -i *window focus changes only have an effect if the bookmark window is open. false null.host 70 -i Changing focus will allow the focused window to be scrolled while both false null.host 70 -i windows are visible on screen. false null.host 70 -i false null.host 70 -i false null.host 70 -i false null.host 70 -i** commands ** false null.host 70 -i false null.host 70 -ionce in command mode, the following commands are available: false null.host 70 -i (most can function using just their first letter... ex: false null.host 70 -i :q will quit false null.host 70 -i :w . somefile.txt will save the current file as somefile.txt false null.host 70 -i all current commands work this way in addition to their long form) false null.host 70 -i false null.host 70 -i false null.host 70 -iaction syntax notes false null.host 70 -i----------------- -------------------------------- --------------------- false null.host 70 -iquit bombadillo :quit same as 'q' hot key false null.host 70 -ivisit homepage :home set by homeurl option false null.host 70 -ivisit help :help short version :? false null.host 70 -isearch :search will ask for kwds false null.host 70 -ivisit url :[url] valid gopher url false null.host 70 -ivisit link :[number] link # on active page false null.host 70 -iview bookmarks :bookmarks same as 'B' hot key false null.host 70 -ivisit bookmark :bookmarks [number] valid bookmark # false null.host 70 -iadd bookmark :add [url] [bookmark title] valid gopher url false null.host 70 -iadd bookmark :add [link #] [bookmark title] link # on active page false null.host 70 -iadd bookmark :add . [bookmark title] adds active page false null.host 70 -idelete bookmark :delete [number] valid bookmark # false null.host 70 -iset an option :set [option] [value] used for configuration false null.host 70 -icheck an option :check [option name] used to check config false null.host 70 -iwrite to file :write [url] [file name] valid gopher url false null.host 70 -iwrite to file :write [link #] [file name] link # on active page false null.host 70 -iwrite to file :write . [file name] saves active page false null.host 70 -i false null.host 70 -i *: navigating to a non-text gophertype will automaticall save false null.host 70 -i files save to the path set by the 'saveurl' option (defaults false null.host 70 -i to a user's Downloads folder in their home directory). false null.host 70 -i **: search is entered on its own and will query the user for keywords false null.host 70 -i and will then query the search service set as 'searchengine' false null.host 70 -i (defaults to veronica2) false null.host 70 -i false null.host 70 -i false null.host 70 -i false null.host 70 -i false null.host 70 -i** configuartion ** false null.host 70 -i false null.host 70 -ivarious configuartion options can be set via the 'set' command. false null.host 70 -ithe following are the currently avialable options, more will be false null.host 70 -icoming in the near future (including color theme options) false null.host 70 -i false null.host 70 -ionce a user sets an option or adds a bookmark a config file will be false null.host 70 -icreated in their home directory. the file will be named '.bombadillo.ini' false null.host 70 -iwhile it can be edited directly, it is recommended to use bombadillo false null.host 70 -ito interact with said file. -i false null.host 70 -i false null.host 70 -i option value type default false null.host 70 -i--------------- ------------------------- ------------------------ false null.host 70 -i false null.host 70 -ihomeurl valid gopher url this document false null.host 70 -isavelocation an non-relative filepath /[home path]/Downloads/ false null.host 70 -isearchengine a type 7 gopher url gopher.floodgap.com:70/7/v2/vs false null.host 70 -iopenhttp true/false false false null.host 70 -i false null.host 70 -i false null.host 70 -i false null.host 70 -i false null.host 70 -i false null.host 70 -i false null.host 70 -ifor more information please contact the following: false null.host 70 -1colorfield space / colorfield.space 70 -isloum@sdf.org false null.host 70 -htildegit url:http://tildergit.org/sloum colorfield.space 70 -i false null.host 70 -i false null.host 70 -i false null.host 70 diff --git a/defaults.go b/defaults.go index e3273d2..93b25cc 100644 --- a/defaults.go +++ b/defaults.go @@ -12,7 +12,7 @@ var defaultOptions = map[string]string{ // Edit these values before compile to have different default values // ... though they can always be edited from within bombadillo as well // it just may take more time/work. - "homeurl": "gopher://colorfield.space:70/1/bombadillo-info", + "homeurl": "gopher://bombadillo.colorfield.space:70/1/user-guide.map", "savelocation": userinfo.HomeDir, "searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs", "openhttp": "false", diff --git a/notes.md b/notes.md deleted file mode 100644 index cc6d2e1..0000000 --- a/notes.md +++ /dev/null @@ -1,60 +0,0 @@ -TODO -- Add styles/color support -- Add code comments/documentation for all items -- Make sure html links using the URL convention work correctly - - - -Control keys/input: - -q quit -j scrolldown -k scrollup -f toggle showing favorites as subwindow -TODO - r refresh current page data (re-request) - -GO -:# go to link num -:url go to url - -SIMPLE -:quit quit -:home visit home -:bookmarks toogle bookmarks window -:search -:help - -DOLINK -:delete # delete bookmark with num -:bookmarks # visit bookmark with num - -DOLINKAS -:write # name write linknum to file -:add # name add link num as favorite - -DOAS -:write url name write url to file -:add url name add link url as favorite -:set something something set a system variable - - - -value, action, word - -- - - - - - - - - - - - - - - - - - - -Config format: - -[favorites] -colorfield.space ++ gopher://colorfield.space:70/ -My phlog ++ gopher://circumlunar.space/1/~sloum/ - -[options] -home ++ gopher://sdf.org -searchengine ++ gopher://floodgap.place/v2/veronicasomething -savelocation ++ ~/Downloads/ -httpbrowser ++ lynx -openhttp ++ true - - - From 3e6c61dcdc44803fd593ad1da17e037861ed80fb Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Mon, 14 Oct 2019 20:27:40 -0700 Subject: [PATCH 058/145] Remaps help to the user guide at bombadillo.colorfield.space --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index ded782d..9f0eadb 100644 --- a/main.go +++ b/main.go @@ -37,7 +37,7 @@ var build string var conf_path string var bombadillo *client -var helplocation string = "gopher://colorfield.space:70/1/bombadillo-info" +var helplocation string = "gopher://bombadillo.colorfield.space:70/1/user-guide.map" var settings config.Config var mc *mailcap.Mailcap From 6609cca70e3197d6e84d61407246fa09fe182c1a Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Mon, 14 Oct 2019 20:34:20 -0700 Subject: [PATCH 059/145] Removed a v from the sprintf for version output. --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 9f0eadb..1a8ff27 100644 --- a/main.go +++ b/main.go @@ -171,7 +171,7 @@ func main() { getVersion := flag.Bool("v", false, "See version number") flag.Parse() if *getVersion { - fmt.Printf("Bombadillo v%s\n", version) + fmt.Printf("Bombadillo %s\n", version) os.Exit(0) } args := flag.Args() From 32e769c9da1aa221819c9493892f6b7939fd52cc Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Tue, 15 Oct 2019 08:53:47 -0700 Subject: [PATCH 060/145] Moves custom config path into defaults.go from makefile --- Makefile | 8 +------- defaults.go | 7 ++++++- main.go | 6 ------ 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index e5d651e..17e6b8f 100644 --- a/Makefile +++ b/Makefile @@ -15,13 +15,7 @@ ifndef VERSION VERSION := ${shell cat ./VERSION} endif -# If an alternate configuration path is provided when make is run, -# include it as an ldflag -ifdef CONF_PATH - LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD_TIME} -X main.conf_path=${CONF_PATH}" -else - LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD_TIME}" -endif +LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD_TIME}" .PHONY: test test: diff --git a/defaults.go b/defaults.go index 93b25cc..8766005 100644 --- a/defaults.go +++ b/defaults.go @@ -12,11 +12,16 @@ var defaultOptions = map[string]string{ // Edit these values before compile to have different default values // ... though they can always be edited from within bombadillo as well // it just may take more time/work. + // + // To change the default location for the config you can enter + // any valid path as a string, if you want an absolute, or + // concatenate with the main default: `userinfo.HomeDir` like so: + // "configlocation": userinfo.HomeDir + "/config/" "homeurl": "gopher://bombadillo.colorfield.space:70/1/user-guide.map", "savelocation": userinfo.HomeDir, "searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs", "openhttp": "false", - "httpbrowser": "lynx", + "httpbrowser": "", "telnetcommand": "telnet", "configlocation": userinfo.HomeDir, "theme": "normal", // "normal", "inverted" diff --git a/main.go b/main.go index 1a8ff27..1189d77 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,6 @@ import ( var version string var build string -var conf_path string var bombadillo *client var helplocation string = "gopher://bombadillo.colorfield.space:70/1/user-guide.map" @@ -97,11 +96,6 @@ func lowerCaseOpt(opt, val string) string { } func loadConfig() error { - // If a compile time override exists for configlocation - // set it before loading the config. - if conf_path != "" { - bombadillo.Options["configlocation"] = conf_path - } file, err := os.Open(bombadillo.Options["configlocation"] + "/.bombadillo.ini") if err != nil { err = saveConfig() From 33bca45b98137159e875273edace90e5f1fd31c5 Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Tue, 15 Oct 2019 09:31:48 -0700 Subject: [PATCH 061/145] Makes makefile structure more modular and fixes clean to not remove installed binary --- Makefile | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 17e6b8f..b10a461 100644 --- a/Makefile +++ b/Makefile @@ -17,34 +17,31 @@ endif LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD_TIME}" -.PHONY: test -test: - @echo ${LDFLAGS} - @echo ${VERSION} - @echo ${BUILD_PATH} +.PHONY: install +install: build install-bin install-man clean .PHONY: build build: - @go build ${LDFLAGS} -o ${BINARY} - -.PHONY: install -install: install-man - @go build ${LDFLAGS} -o ${BUILD_PATH}/${BINARY} + go build ${LDFLAGS} -o ${BINARY} .PHONY: install-man install-man: bombadillo.1 - @gzip -k ./bombadillo.1 - @install -d ${man1dir} - @install -m 0644 ./bombadillo.1.gz ${man1dir} + gzip -k ./bombadillo.1 + install -d ${man1dir} + install -m 0644 ./bombadillo.1.gz ${man1dir} + +.PHONY: install-bin +install-bin: + install -d ${BUILD_PATH} + install ./${BINARY} ${BUILD_PATH}/${BINARY} .PHONY: clean clean: - @go clean -i - @rm -f ./bombadillo.1.gz 2> /dev/null + go clean + rm -f ./bombadillo.1.gz 2> /dev/null .PHONY: uninstall uninstall: clean - @rm -f ${man1dir}/bombadillo.1.gz - @echo Removing ${BINARY} - @rm -f ${BUILD_PATH}/${BINARY} + rm -f ${man1dir}/bombadillo.1.gz + rm -f ${BUILD_PATH}/${BINARY} From 0fc0dddb97bff4491d58f3fefd29a387c9b183ad Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Tue, 15 Oct 2019 13:26:05 -0700 Subject: [PATCH 062/145] Adds some a bit about config location being variable --- bombadillo.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bombadillo.1 b/bombadillo.1 index e023009..4befe25 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -206,7 +206,7 @@ Writes data from a given url to a file. The file is named by the filename argume write [link id] [filename\.\.\.] Writes data from a given link id in the current document to a file. The file is named by the filename argument should should not include a leading \fI/\fP. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. .SH FILES -\fBbombadillo\fP keeps a hidden configuration file in a user's home directory. The file is a simplified ini file titled \fI.bombadillo.ini\fP. It is generated when a user first loads \fBbombadillo\fP and is updated with bookmarks and settings as a user adds them. The file can be directly edited, but it is best to use the SET command to update settings whenever possible. To return to the state of a fresh install, simply remove the file and a new one will be generated with the \fBbombadillo\fP defaults. +\fBbombadillo\fP keeps a hidden configuration file in a user's home directory. The file is a simplified ini file titled \fI.bombadillo.ini\fP. It is generated when a user first loads \fBbombadillo\fP and is updated with bookmarks and settings as a user adds them. The file can be directly edited, but it is best to use the SET command to update settings whenever possible. To return to the state of a fresh install, simply remove the file and a new one will be generated with the \fBbombadillo\fP defaults. On some systems an administrator may set the configuration file location to somewhere other than a user's home folder. If you do not see the file where you expect it, contact your system administrator. .SH SETTINGS The following is a list of the settings that \fBbombadillo\fP recognizes, as well as a description of their valid values. .TP From cc27c8270351ae89563f2cccd193be49b723b598 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Tue, 15 Oct 2019 19:36:50 -0700 Subject: [PATCH 063/145] HOT FIX: Removes defaults from man file since they can be set at compile time. Users should use CHECK to see settings. --- bombadillo.1 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bombadillo.1 b/bombadillo.1 index 4befe25..1fea65a 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -216,27 +216,27 @@ The url that \fBbombadillo\fP navigates to when the program loads or when the \f .TP .B openhttp -Tells the client whether or not to try to follow web (http/https) links. If set to \fItrue\fP, \fBbombadillo\fP will try to open a user's default web browser to the link in question. Any value other than \fItrue\fP is considered false. Defaults to \fIfalse\fP. Does not work in a terminal only environment. +Tells the client whether or not to try to follow web (http/https) links. If set to \fItrue\fP, \fBbombadillo\fP will try to open a user's default web browser to the link in question. Any value other than \fItrue\fP is considered false. .TP .B savelocation -The path to the folder that \fBbombadillo\fP should write files to. This should be a valid filepath for the system and should end in a \fI/\fP. Defaults to a user's home directory. +The path to the folder that \fBbombadillo\fP should write files to. This should be a valid filepath for the system and should end in a \fI/\fP. .TP .B searchengine -The url to use for the LINE COMMANDs \fI?\fP and \fIsearch\fP. Should be a valid search path that terms may be appended to. Defaults to \fIgopher://gopher.floodgap.com:70/7/v2/vs\fP. +The url to use for the LINE COMMANDs \fI?\fP and \fIsearch\fP. Should be a valid search path that terms may be appended to. .TP .B telnetcommand -Tells the client what command to use to start a telnet session. Should be a valid command, including any flags. The address being navigated to will be added to the end of the command. Defaults to \fItelnet\fP. +Tells the client what command to use to start a telnet session. Should be a valid command, including any flags. The address being navigated to will be added to the end of the command. .TP .B terminalonly -Sets whether or not to try to open non-text files served via gemini in gui programs or not. If set to \fItrue\fP, bombdaillo will only attempt to use terminal programs to open files. If set to anything else, \fBbombadillo\fP may choose graphical and terminal programs. Defaults to \fItrue\fP. +Sets whether or not to try to open non-text files served via gemini in gui programs or not. If set to \fItrue\fP, bombdaillo will only attempt to use terminal programs to open files. If set to anything else, \fBbombadillo\fP may choose from the appropriate programs installed on the system, if one is present. .TP .B theme -Can toggle between visual modes. Valid values are \fInormal\fP and \fIinverse\fP. When set to ivnerse, the terminal color mode is inversed. Defaults to \fInormal\fP. +Can toggle between visual modes. Valid values are \fInormal\fP and \fIinverse\fP. When set to ivnerse, the terminal color mode is inversed. .TP .B tlscertificate @@ -248,7 +248,7 @@ A path the a tls key that pairs with the tlscertificate setting, on a user's loc .SH BUGS There are very likely bugs. Many known bugs can be found in the issues section of \fBbombadillo\fP's software repository (see \fIlinks\fP). .SH LINKS -\fBbombadillo\fP maintains a web presence in the following locations: +\fBbombadillo\fP maintains a presence in the following locations: .TP .B Code Repository From 1c0295e32e26872ddfc6ab526c9e46f3c800efa5 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Tue, 15 Oct 2019 20:07:54 -0700 Subject: [PATCH 064/145] Updates readme to better fit the 2.0.0 build methodology --- README.md | 56 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 9bf3b31..d9859ad 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ # Bombadillo -Bombadillo is a modern [Gopher](https://en.wikipedia.org/wiki/Gopher_(protocol)) client for the terminal, and functions as a pager/terminal UI. Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Bombadillo is under active development. +Bombadillo is a non-web client for the terminal, and functions as a pager/terminal UI. Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Currently, Bombadillo supports the following protocols: +- gopher +- gemini +- finger +- local (a user's filesystem) +- telnet (by opening links in a subprocess w/ a telnet application) +- http/https links can be opened in a user's default web browser as an opt-in behavior ## Getting Started @@ -9,29 +15,49 @@ These instructions will get a copy of the project up and running on your local m ### Prerequisites -If building from source, you will need to have [Go](https://golang.org/) version >= 1.11. Bombadillo uses the module system, so if using 1.11 you will need to have that feature enabled. If using a version > 1.11, you already have modules enabled. +If building from source, you will need to have [Go](https://golang.org/) version >= 1.12. -Bombadillo does not use any outside dependencies beyond the Go standard library. +### Building, Installing, Uninstalling -### Installing +Bombadillo installation uses `make`. It is possible to just use the go compiler directly (`go install`) if you do not wish to have a man page installed and do not want a program to manage uninstalling and cleaning up. -Assuming you have `go` installed, run the following: +By default Bombadillo will try to install to `$GOBIN`. If it is not set it will try `$GOPATH/bin` (if `$GOPATH` is set), otherwise `~/go/bin`. + +#### Basic Installation + +Once you have `go` installed you can build a few different ways. Most users will want the following: ``` git clone https://tildegit.org/sloum/bombadillo.git cd bombadillo -go install +make install ``` -Once you have done that you should, assuming `go install` is set up to install to a place on your path, you should be able to run the following from anywhere on your system to use Bombadillo: +Once that is done you should be able to run `bombadillo` (assuming that one of the default install locations exists and is on your path) or view the manual with `man bombadillo`. + +#### Custom Installation + +There are a number of default configuration options in the file `defaults.go`. These can all be set prior to building in order to have these defaults apply to all users of Bombadillo on a given system. That said, the basic configuration already present should be suitable for most users (and all settings but one can be changed from within a Bombadillo session). + +The installation location can be overridden at compile time, which can be very useful for administrators wanting to set up Bombadillo on a multi-user machine. If you wanted to install to, for example, `/usr/local/bin` you would do the following: ``` -bombadillo +git clone https://tildegit.org/sloum/bombadillo.git +cd bombadillo +make install BUILD_PATH=/usr/local/bin +``` + +#### Uninstall + +If you used the makefile to install Bombadillo then uninstalling is very simple. From the Bombadillo source folder run: + +``` +make uninstall ``` #### Troubleshooting -If you run `bombadillo` and get `bombadillo: command not found`, try running `go build` from within the cloned repo. Then try: `./bombadillo`. If that works it means that Go does not install to your path. `go build` added an executable file to the repo directory. Move that file to somewhere on your path. I suggest `/usr/local/bin` on most systems, but that may be a matter of personal preference. +If you run `bombadillo` and get `bombadillo: command not found`, try running `make build` from within the cloned repo. Then try: `./bombadillo`. If that works it means that Go does not install to your path, or the custom path you selected is not on your path. Try the custom install from above to a location you know to be on your path. ### Downloading @@ -39,21 +65,17 @@ If you would prefer to download a binary for your system, rather than build from ### Documentation -Bombadillo has documentation available in four places currently. The first is the [Bombadillo homepage](https://rawtext.club/~sloum/bombadillo.html#docs), which has lots of information about the program, links to places around Gopher, and documentation of the commands and configuration options. +Bombadillo's primary documentation can be found in the man entry that installs with Bombadillo. To access it run `man bombadillo` after first installing Bombadillo. If for some reason that does not work, the document can be accessed directly from the source folder with `man ./bombadillo.1`. -Secondly, and possibly more importantly, documentation is available via Gopher from within Bombadillo. When a user launches Bombadillo for the first time, their `homeurl` is set to the help file. As such they will have access to all of the key bindings, commands, and configuration from the first run. A user can also type `:?` or `:help` at any time to return to the documentation. Remember that Bombadillo uses vim-like key bindings, so scroll with `j` and `k` to view the docs file. - -Thirdly, this repo contains a file `bombadillo-info`. This is a duplicate of the help file that is hosted over gopher mentioned above. Per user request it has been added to the repo so that pull requests can be created with updates to the documentation. - -Lastly, but perhaps most importantly, a manpage is now included in the repo as `bombadillo.1`. Current efforts are underway to automate the install of both bombadillo and this manpgage. +In addition to the man page, users can get information on Bombadillo on the web @ [http://bombadillo.colorfield.space](http://bombadillo.colorfield.space). Running the command `help` inside Bombadillo will navigate a user to the gopher server hosted at [bombadillo.colorfield.space](gopher://bombadillo.colorfield.space), specifically the user guide. ## Contributing -Bombadillo development is largely handled by Sloum, with help from jboverf, asdf, and some community input. If you would like to get involved, please reach out or submit an issue. At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. If you have forked and would like to make a pull request, please make the pull request into `develop` where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. +Bombadillo development is largely handled by Sloum, with help from asdf, jboverf, and some community input. If you would like to get involved, please reach out or submit an issue. At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. If you have forked and would like to make a pull request, please make the pull request into `develop` where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. While input is always welcome, not all requests will be granted. That said, we do our best to make Bombadillo a useful piece of software for its users and in general want to help you out. ## License -This project is licensed under the GNU GPL version 3- see the [LICENSE](LICENSE) file for details. +This project is licensed under the GNU GPL version 3. See the [LICENSE](LICENSE) file for details. ## Releases From d22d8bf40622d7136574e1e88ea4c2b98af4a5d4 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Wed, 16 Oct 2019 19:23:39 -0700 Subject: [PATCH 065/145] Updated uninstall logic to work better, particularly with non-gopath install points --- Makefile | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index b10a461..6c21323 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,9 @@ -BINARY := bombadillo -man1dir := /usr/local/share/man/man1 -GOPATH ?= ${HOME}/go -GOBIN ?= ${GOPATH}/bin -BUILD_PATH ?= ${GOBIN} +BINARY := bombadillo +man1dir := /usr/local/share/man/man1 +GOPATH ?= ${HOME}/go +GOBIN ?= ${GOPATH}/bin +BUILD_PATH ?= ${GOBIN} +UNINST_FROM := ${shell which bombadillo} # Use a dateformat rather than -I flag since OSX # does not support -I. It also doesn't support @@ -18,7 +19,7 @@ endif LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD_TIME}" .PHONY: install -install: build install-bin install-man clean +install: install-bin install-man clean .PHONY: build build: @@ -31,9 +32,9 @@ install-man: bombadillo.1 install -m 0644 ./bombadillo.1.gz ${man1dir} .PHONY: install-bin -install-bin: +install-bin: build install -d ${BUILD_PATH} - install ./${BINARY} ${BUILD_PATH}/${BINARY} + install -m 0755 ./${BINARY} ${BUILD_PATH}/${BINARY} .PHONY: clean clean: @@ -43,5 +44,5 @@ clean: .PHONY: uninstall uninstall: clean rm -f ${man1dir}/bombadillo.1.gz - rm -f ${BUILD_PATH}/${BINARY} + rm -f ${UNINST_FROM} From 1031805bfca2bd27d6558964ec3a03e4d14e1bc5 Mon Sep 17 00:00:00 2001 From: asdf Date: Mon, 21 Oct 2019 13:23:58 +1100 Subject: [PATCH 066/145] Ammended variables to include prefix and destdir --- Makefile | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 6c21323..5786f8b 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,6 @@ -BINARY := bombadillo -man1dir := /usr/local/share/man/man1 -GOPATH ?= ${HOME}/go -GOBIN ?= ${GOPATH}/bin -BUILD_PATH ?= ${GOBIN} -UNINST_FROM := ${shell which bombadillo} +BINARY := bombadillo +PREFIX := /usr/local +MANPREFIX := ${PREFIX}/share/man # Use a dateformat rather than -I flag since OSX # does not support -I. It also doesn't support @@ -18,23 +15,23 @@ endif LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD_TIME}" -.PHONY: install -install: install-bin install-man clean - .PHONY: build build: go build ${LDFLAGS} -o ${BINARY} +.PHONY: install +install: install-bin install-man clean + .PHONY: install-man install-man: bombadillo.1 gzip -k ./bombadillo.1 - install -d ${man1dir} - install -m 0644 ./bombadillo.1.gz ${man1dir} + install -d ${DESTDIR}${MANPREFIX}/man1 + install -m 0644 ./bombadillo.1.gz ${DESTDIR}${MANPREFIX}/man1 .PHONY: install-bin install-bin: build - install -d ${BUILD_PATH} - install -m 0755 ./${BINARY} ${BUILD_PATH}/${BINARY} + install -d ${DESTDIR}${PREFIX}/bin + install -m 0755 ./${BINARY} ${DESTDIR}${PREFIX}/bin/${BINARY} .PHONY: clean clean: @@ -43,6 +40,6 @@ clean: .PHONY: uninstall uninstall: clean - rm -f ${man1dir}/bombadillo.1.gz - rm -f ${UNINST_FROM} + rm -f ${DESTDIR}${MANPREFIX}/man1/bombadillo.1.gz + rm -f ${DESTDIR}${PREFIX}/bin/${BINARY} From 68a91c58f22b0b007809949c67bd4f355075cee4 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 22 Oct 2019 13:55:33 +1100 Subject: [PATCH 067/145] Updated README.md to reflect new build options --- README.md | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9bf3b31..2bf2897 100644 --- a/README.md +++ b/README.md @@ -9,33 +9,47 @@ These instructions will get a copy of the project up and running on your local m ### Prerequisites -If building from source, you will need to have [Go](https://golang.org/) version >= 1.11. Bombadillo uses the module system, so if using 1.11 you will need to have that feature enabled. If using a version > 1.11, you already have modules enabled. +If building from source, you will need to have [Go](https://golang.org/) version >= 1.12. -Bombadillo does not use any outside dependencies beyond the Go standard library. +While Bombadillo has one external dependency of [Mailcap](https://tildegit.org/sloum/mailcap), no action is typically required to download this, as it is handled automatically during the build process. ### Installing -Assuming you have `go` installed, run the following: +Assuming you have all prerequisites installed, Bombadillo can be installed on your system using the following commands: ``` git clone https://tildegit.org/sloum/bombadillo.git cd bombadillo -go install +sudo make install ``` -Once you have done that you should, assuming `go install` is set up to install to a place on your path, you should be able to run the following from anywhere on your system to use Bombadillo: +Once this is done, you should be able to start Bombadillo using the following command: ``` bombadillo +``` + +#### Other installation options + +If you only want to install Bombadillo for your own user account, you could try the following in the cloned repository: + ``` +make PREFIX=~ install +``` + +You can then add `~/bin` to your PATH environment variable, and `~/share/man` to your manpath. + +The `PREFIX` option can be used to install Bombadillo to any location different to `/usr/local`. #### Troubleshooting -If you run `bombadillo` and get `bombadillo: command not found`, try running `go build` from within the cloned repo. Then try: `./bombadillo`. If that works it means that Go does not install to your path. `go build` added an executable file to the repo directory. Move that file to somewhere on your path. I suggest `/usr/local/bin` on most systems, but that may be a matter of personal preference. +If you run `bombadillo` and get `bombadillo: command not found`, try running `make` from within the cloned repository. Then try: `./bombadillo`. This means that Bombadillo is not being installed to a location in your `PATH`. + +Please feel free to [open an issue](https://tildegit.org/sloum/bombadillo/issues) if you experience any other issues with the installation. ### Downloading -If you would prefer to download a binary for your system, rather than build from source, please visit the [Bombadillo downloads](https://rawtext.club/~sloum/bombadillo.html#downloads) page. Don't see your OS/architecture? Bombadillo can be built for use with any POSIX compliant system that is supported as a target for the Go compiler (Linux, BSD, OS X, Plan 9). No testing has been done for Windows. The program will build, but will likely not work properly outside of the Linux subsystem. If you are a Windows user and would like to do some testing or get involved in development please reach out or open an issue. +If you would prefer to download a binary for your system, rather than build from source, please visit the [Bombadillo downloads](https://rawtext.club/~sloum/bombadillo.html#downloads) page. Don't see your OS/architecture? Bombadillo can be built for use with any POSIX compliant system that is supported as a target for the Go compiler (Linux, BSD, OS X, Plan 9). No testing has been done for Windows. The program will build, but will likely not work properly outside of the Linux subsystem. If you are a Windows user and would like to do some testing or get involved in development please reach out or [open an issue](https://tildegit.org/sloum/bombadillo/issues). ### Documentation From d5246a7d3ebb9066e7888907631bc69fd2580028 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 22 Oct 2019 14:02:26 +1100 Subject: [PATCH 068/145] Corrected troubleshooting information --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bf2897..814f10e 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ The `PREFIX` option can be used to install Bombadillo to any location different #### Troubleshooting -If you run `bombadillo` and get `bombadillo: command not found`, try running `make` from within the cloned repository. Then try: `./bombadillo`. This means that Bombadillo is not being installed to a location in your `PATH`. +If you run `bombadillo` and get `bombadillo: command not found`, try running `make` from within the cloned repository. Next, try: `./bombadillo`. If this works, it means that the installation was not completed to an area in your `PATH`. Please feel free to [open an issue](https://tildegit.org/sloum/bombadillo/issues) if you experience any other issues with the installation. From 95837e108a233f345130e965b0f39ca158f438ab Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 22 Oct 2019 14:45:39 +1100 Subject: [PATCH 069/145] Added printHelp, provide more info on -h and -v --- main.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 1189d77..1514243 100644 --- a/main.go +++ b/main.go @@ -112,7 +112,7 @@ func loadConfig() error { if lowerkey == "configlocation" { // The config defaults to the home folder. // Users cannot really edit this value. But - // a compile time override is available. + // a compile time override is available. // It is still stored in the ini and as a part // of the options map. continue @@ -161,11 +161,28 @@ func handleSIGCONT(c <-chan os.Signal) { } } +//printHelp produces a nice display message when the --help flag is used +func printHelp() { + art := `Bombadillo + +Syntax: bombadillo [url] + bombadillo [options...] + +Example: bombadillo gopher://bombadillo.colorfield.space + bombadillo -v + +Options: +` + fmt.Fprint(os.Stdout, art) + flag.PrintDefaults() +} + func main() { - getVersion := flag.Bool("v", false, "See version number") + getVersion := flag.Bool("v", false, "Print version information and exit") + flag.Usage = printHelp flag.Parse() if *getVersion { - fmt.Printf("Bombadillo %s\n", version) + fmt.Printf("Bombadillo %s - build %s\n", version, build) os.Exit(0) } args := flag.Args() From 17b1e6eff280047e4829ee7c5fcfc35a6c666474 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 22 Oct 2019 15:00:01 +1100 Subject: [PATCH 070/145] Unified wording, updated man page --- README.md | 2 +- bombadillo.1 | 5 +++-- main.go | 10 +++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 814f10e..f16e7b0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Bombadillo +# Bombadillo - a non-web client Bombadillo is a modern [Gopher](https://en.wikipedia.org/wiki/Gopher_(protocol)) client for the terminal, and functions as a pager/terminal UI. Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Bombadillo is under active development. diff --git a/bombadillo.1 b/bombadillo.1 index 1d28a72..e01925f 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -5,7 +5,8 @@ .SH SYNOPSIS .nf .fam C -\fBbombadillo\fP [\fB-v\fP] [\fB-h\fP] [\fIurl\fP] +\fBbombadillo\fP [\fIurl\fP] +\fBbombadillo\fP [\fBOPTION\fP] .fam T .fi .SH DESCRIPTION @@ -14,7 +15,7 @@ .TP .B \fB-v\fP -Display the version number of \fBbombadillo\fP. +Display version information and exit. .TP .B \fB-h\fP diff --git a/main.go b/main.go index 1514243..4bd03f0 100644 --- a/main.go +++ b/main.go @@ -163,13 +163,13 @@ func handleSIGCONT(c <-chan os.Signal) { //printHelp produces a nice display message when the --help flag is used func printHelp() { - art := `Bombadillo + art := `Bombadillo - a non-web client -Syntax: bombadillo [url] - bombadillo [options...] +Syntax: bombadillo [url] + bombadillo [options...] -Example: bombadillo gopher://bombadillo.colorfield.space - bombadillo -v +Examples: bombadillo gopher://bombadillo.colorfield.space + bombadillo -v Options: ` From 1bc6e75ada094118964a5e5fdf6d536da8c5eb9f Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 22 Oct 2019 15:07:37 +1100 Subject: [PATCH 071/145] Unified wording for -v option --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 4bd03f0..6a71c13 100644 --- a/main.go +++ b/main.go @@ -178,7 +178,7 @@ Options: } func main() { - getVersion := flag.Bool("v", false, "Print version information and exit") + getVersion := flag.Bool("v", false, "Display version information and exit") flag.Usage = printHelp flag.Parse() if *getVersion { From 2b6a738d04868726abe25d72700113c4d9b9b902 Mon Sep 17 00:00:00 2001 From: asdf Date: Wed, 23 Oct 2019 13:52:47 +1100 Subject: [PATCH 072/145] Added uninstall information --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 814f10e..263f1a3 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,16 @@ If you run `bombadillo` and get `bombadillo: command not found`, try running `ma Please feel free to [open an issue](https://tildegit.org/sloum/bombadillo/issues) if you experience any other issues with the installation. +### Uninstalling + +To uninstall Bombadillo, simply run the following command from the cloned repository: + +``` +sudo make uninstall +``` + +Please note that directories created during the installation will not be removed. + ### Downloading If you would prefer to download a binary for your system, rather than build from source, please visit the [Bombadillo downloads](https://rawtext.club/~sloum/bombadillo.html#downloads) page. Don't see your OS/architecture? Bombadillo can be built for use with any POSIX compliant system that is supported as a target for the Go compiler (Linux, BSD, OS X, Plan 9). No testing has been done for Windows. The program will build, but will likely not work properly outside of the Linux subsystem. If you are a Windows user and would like to do some testing or get involved in development please reach out or [open an issue](https://tildegit.org/sloum/bombadillo/issues). From 552e21113902ba5e37aeca6e91541a2608a61008 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Tue, 22 Oct 2019 22:02:32 -0700 Subject: [PATCH 073/145] Adds web support in lynx mode --- bombadillo.1 | 9 +++++++-- client.go | 44 +++++++++++++++++++++++++++++++----------- defaults.go | 2 +- http/lynx_mode.go | 49 +++++++++++++++++++++++++++++++++++++++++++++++ main.go | 4 +++- 5 files changed, 93 insertions(+), 15 deletions(-) create mode 100644 http/lynx_mode.go diff --git a/bombadillo.1 b/bombadillo.1 index 1fea65a..c03d56f 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -215,8 +215,13 @@ homeurl The url that \fBbombadillo\fP navigates to when the program loads or when the \fIhome\fP or \fIh\fP LINE COMMAND is issued. This should be a valid url. If a scheme/protocol is not included, gopher will be assumed. .TP .B +lynxmode +Will use lynx as a rendering engine for http/https requests if lynx is installed and \fIopenhttp\fP is set to \fItrue\fP. Valid values are \fItrue\fP and \fIfalse\fP. +.TP +.B openhttp -Tells the client whether or not to try to follow web (http/https) links. If set to \fItrue\fP, \fBbombadillo\fP will try to open a user's default web browser to the link in question. Any value other than \fItrue\fP is considered false. +Tells the client whether or not to try to follow web (http/https) links. If set to \fItrue\fP, \fBbombadillo\fP will try to open a user's default web browser to the link in question. Valid values are \fItrue\fP and \fIfalse\fP. + .TP .B savelocation @@ -232,7 +237,7 @@ Tells the client what command to use to start a telnet session. Should be a vali .TP .B terminalonly -Sets whether or not to try to open non-text files served via gemini in gui programs or not. If set to \fItrue\fP, bombdaillo will only attempt to use terminal programs to open files. If set to anything else, \fBbombadillo\fP may choose from the appropriate programs installed on the system, if one is present. +Sets whether or not to try to open non-text files served via gemini in gui programs or not. If set to \fItrue\fP \fBbombdaillo\fP will only attempt to use terminal programs to open files. If set to \fIfalse\fP \fBbombadillo\fP may choose from the appropriate programs installed on the system, including graphical ones. .TP .B theme diff --git a/client.go b/client.go index 71b998d..4b49f77 100644 --- a/client.go +++ b/client.go @@ -972,19 +972,41 @@ func (c *client) Visit(url string) { } c.Draw() case "http", "https": - c.SetMessage("Attempting to open in web browser", false) - c.DrawMessage() - if strings.ToUpper(c.Options["openhttp"]) == "TRUE" { - msg, err := http.OpenInBrowser(u.Full) - if err != nil { - c.SetMessage(err.Error(), true) - } else { - c.SetMessage(msg, false) - } - c.DrawMessage() - } else { + if strings.ToUpper(c.Options["openhttp"]) != "TRUE" { c.SetMessage("'openhttp' is not set to true, cannot open web link", false) c.DrawMessage() + return + } + switch strings.ToUpper(c.Options["lynxmode"]) { + case "TRUE": + page, err := http.Visit(u.Full, c.Width - 1) + if err != nil { + c.SetMessage(fmt.Sprintf("Lynx error: %s", err.Error()), true) + c.DrawMessage() + return + } + pg := MakePage(u, page.Content, page.Links) + pg.WrapContent(c.Width - 1) + c.PageState.Add(pg) + c.SetPercentRead() + c.ClearMessage() + c.SetHeaderUrl() + c.Draw() + default: + if strings.ToUpper(c.Options["terminalonly"]) == "TRUE" { + c.SetMessage("'terminalonly' is set to true and 'lynxmode' is not enabled, cannot open web link", false) + c.DrawMessage() + } else { + c.SetMessage("Attempting to open in web browser", false) + c.DrawMessage() + msg, err := http.OpenInBrowser(u.Full) + if err != nil { + c.SetMessage(err.Error(), true) + } else { + c.SetMessage(msg, false) + } + c.DrawMessage() + } } case "local": content, err := local.Open(u.Resource) diff --git a/defaults.go b/defaults.go index e3273d2..a7d1661 100644 --- a/defaults.go +++ b/defaults.go @@ -16,12 +16,12 @@ var defaultOptions = map[string]string{ "savelocation": userinfo.HomeDir, "searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs", "openhttp": "false", - "httpbrowser": "lynx", "telnetcommand": "telnet", "configlocation": userinfo.HomeDir, "theme": "normal", // "normal", "inverted" "terminalonly": "true", "tlscertificate": "", "tlskey": "", + "lynxmode": "false", } diff --git a/http/lynx_mode.go b/http/lynx_mode.go new file mode 100644 index 0000000..325b759 --- /dev/null +++ b/http/lynx_mode.go @@ -0,0 +1,49 @@ +package http + +import ( + "fmt" + "os/exec" + "strings" +) + +type page struct { + Content string + Links []string +} + +func Visit(url string, width int) (page, error) { + if width > 80 { + width = 80 + } + w := fmt.Sprintf("-width=%d", width) + c, err := exec.Command("lynx", "-dump", w, url).Output() + if err != nil { + return page{}, err + } + return parseLinks(string(c)), nil +} + +func parseLinks(c string) page { + var out page + contentUntil := strings.LastIndex(c, "References") + if contentUntil >= 1 { + out.Content = c[:contentUntil] + } else { + out.Content = c + out.Links = make([]string, 0) + return out + } + links := c[contentUntil+11:] + links = strings.TrimSpace(links) + linkSlice := strings.Split(links, "\n") + out.Links = make([]string, 0, len(linkSlice)) + for _, link := range linkSlice { + ls := strings.SplitN(link, ".", 2) + if len(ls) < 2 { + continue + } + out.Links = append(out.Links, strings.TrimSpace(ls[1])) + } + return out + +} diff --git a/main.go b/main.go index 249139d..69eba38 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main -// Bombadillo is a gopher and gemini client for the terminal of unix or unix-like systems. +// Bombadillo is an internet client for the terminal of unix or +// unix-like systems. // // Copyright (C) 2019 Brian Evans // @@ -68,6 +69,7 @@ func validateOpt(opt, val string) bool { "openhttp": []string{"true", "false"}, "theme": []string{"normal", "inverse"}, "terminalonly": []string{"true", "false"}, + "lynxmode": []string{"true", "false"}, } opt = strings.ToLower(opt) From 231ccc36d32b6f19f230478d307f623705a0af6f Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Tue, 22 Oct 2019 22:13:08 -0700 Subject: [PATCH 074/145] Ran go fmt on a few files --- client.go | 3 +-- http/lynx_mode.go | 4 ++-- main.go | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index 4b49f77..107e1c7 100644 --- a/client.go +++ b/client.go @@ -979,7 +979,7 @@ func (c *client) Visit(url string) { } switch strings.ToUpper(c.Options["lynxmode"]) { case "TRUE": - page, err := http.Visit(u.Full, c.Width - 1) + page, err := http.Visit(u.Full, c.Width-1) if err != nil { c.SetMessage(fmt.Sprintf("Lynx error: %s", err.Error()), true) c.DrawMessage() @@ -1057,7 +1057,6 @@ func (c *client) ReloadPage() error { return nil } - //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ diff --git a/http/lynx_mode.go b/http/lynx_mode.go index 325b759..6b431e5 100644 --- a/http/lynx_mode.go +++ b/http/lynx_mode.go @@ -7,8 +7,8 @@ import ( ) type page struct { - Content string - Links []string + Content string + Links []string } func Visit(url string, width int) (page, error) { diff --git a/main.go b/main.go index 69eba38..a755cc5 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,6 @@ package main -// Bombadillo is an internet client for the terminal of unix or +// Bombadillo is an internet client for the terminal of unix or // unix-like systems. // // Copyright (C) 2019 Brian Evans From 2c6a0a85eea0ffad683574c5dabebf5691ff95f6 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 22 Oct 2019 14:45:39 +1100 Subject: [PATCH 075/145] Added printHelp, provide more info on -h and -v --- main.go | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 1189d77..1514243 100644 --- a/main.go +++ b/main.go @@ -112,7 +112,7 @@ func loadConfig() error { if lowerkey == "configlocation" { // The config defaults to the home folder. // Users cannot really edit this value. But - // a compile time override is available. + // a compile time override is available. // It is still stored in the ini and as a part // of the options map. continue @@ -161,11 +161,28 @@ func handleSIGCONT(c <-chan os.Signal) { } } +//printHelp produces a nice display message when the --help flag is used +func printHelp() { + art := `Bombadillo + +Syntax: bombadillo [url] + bombadillo [options...] + +Example: bombadillo gopher://bombadillo.colorfield.space + bombadillo -v + +Options: +` + fmt.Fprint(os.Stdout, art) + flag.PrintDefaults() +} + func main() { - getVersion := flag.Bool("v", false, "See version number") + getVersion := flag.Bool("v", false, "Print version information and exit") + flag.Usage = printHelp flag.Parse() if *getVersion { - fmt.Printf("Bombadillo %s\n", version) + fmt.Printf("Bombadillo %s - build %s\n", version, build) os.Exit(0) } args := flag.Args() From 5b1f8984b71f0ae5f8023baa4b9c56d8fed2f5f1 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 22 Oct 2019 15:00:01 +1100 Subject: [PATCH 076/145] Unified wording, updated man page --- README.md | 2 +- bombadillo.1 | 5 +++-- main.go | 10 +++++----- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 263f1a3..7593b85 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Bombadillo +# Bombadillo - a non-web client Bombadillo is a modern [Gopher](https://en.wikipedia.org/wiki/Gopher_(protocol)) client for the terminal, and functions as a pager/terminal UI. Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Bombadillo is under active development. diff --git a/bombadillo.1 b/bombadillo.1 index 1fea65a..e2a2504 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -4,7 +4,8 @@ .SH SYNOPSIS .nf .fam C -\fBbombadillo\fP [\fB-v\fP] [\fB-h\fP] [\fIurl\fP] +\fBbombadillo\fP [\fIurl\fP] +\fBbombadillo\fP [\fBOPTION\fP] .fam T .fi .SH DESCRIPTION @@ -13,7 +14,7 @@ .TP .B \fB-v\fP -Display the version number of \fBbombadillo\fP. +Display version information and exit. .TP .B \fB-h\fP diff --git a/main.go b/main.go index 1514243..4bd03f0 100644 --- a/main.go +++ b/main.go @@ -163,13 +163,13 @@ func handleSIGCONT(c <-chan os.Signal) { //printHelp produces a nice display message when the --help flag is used func printHelp() { - art := `Bombadillo + art := `Bombadillo - a non-web client -Syntax: bombadillo [url] - bombadillo [options...] +Syntax: bombadillo [url] + bombadillo [options...] -Example: bombadillo gopher://bombadillo.colorfield.space - bombadillo -v +Examples: bombadillo gopher://bombadillo.colorfield.space + bombadillo -v Options: ` From 3f0bf1ec41d607b401156c26f12dc9f9fbc74ae6 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 22 Oct 2019 15:07:37 +1100 Subject: [PATCH 077/145] Unified wording for -v option --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 4bd03f0..6a71c13 100644 --- a/main.go +++ b/main.go @@ -178,7 +178,7 @@ Options: } func main() { - getVersion := flag.Bool("v", false, "Print version information and exit") + getVersion := flag.Bool("v", false, "Display version information and exit") flag.Usage = printHelp flag.Parse() if *getVersion { From a393b00ad12303aa354039c139cd2535f4be5322 Mon Sep 17 00:00:00 2001 From: asdf Date: Thu, 24 Oct 2019 13:25:31 +1100 Subject: [PATCH 078/145] Handle more signals without breaking terminal --- cui/cui.go | 16 +++++++++++++--- main.go | 36 ++++++++++++++++++++---------------- 2 files changed, 33 insertions(+), 19 deletions(-) diff --git a/cui/cui.go b/cui/cui.go index a7b865d..7d5d71a 100644 --- a/cui/cui.go +++ b/cui/cui.go @@ -57,15 +57,25 @@ func moveCursorToward(dir string, amount int) { } func Exit() { + CleanupTerm() + os.Exit(0) +} + +func InitTerm() { + SetCharMode() + Tput("rmam") // turn off line wrapping + Tput("smcup") // use alternate screen +} + +func CleanupTerm() { moveCursorToward("down", 500) moveCursorToward("right", 500) SetLineMode() fmt.Print("\n") fmt.Print("\033[?25h") - Tput("smam") // turn off line wrap - Tput("rmcup") // use alternate screen - os.Exit(0) + Tput("smam") // turn on line wrap + Tput("rmcup") // stop using alternate screen } func Clear(dir string) { diff --git a/main.go b/main.go index 1189d77..e7d7c2d 100644 --- a/main.go +++ b/main.go @@ -112,7 +112,7 @@ func loadConfig() error { if lowerkey == "configlocation" { // The config defaults to the home folder. // Users cannot really edit this value. But - // a compile time override is available. + // a compile time override is available. // It is still stored in the ini and as a part // of the options map. continue @@ -140,7 +140,6 @@ func loadConfig() error { func initClient() error { bombadillo = MakeClient(" ((( Bombadillo ))) ") - cui.SetCharMode() err := loadConfig() if bombadillo.Options["tlscertificate"] != "" && bombadillo.Options["tlskey"] != "" { bombadillo.Certs.LoadCertificate(bombadillo.Options["tlscertificate"], bombadillo.Options["tlskey"]) @@ -148,16 +147,22 @@ func initClient() error { return err } -// In the event of SIGCONT, ensure the display is shown correctly. Accepts a -// signal, blocking until it is received. Once not blocked, corrects terminal -// display settings. Loops indefinitely, does not return. -func handleSIGCONT(c <-chan os.Signal) { - for { - <-c - cui.Tput("rmam") // turn off line wrapping - cui.Tput("smcup") // use alternate screen - cui.SetCharMode() +// In the event of specific signals, ensure the display is shown correctly. +// Accepts a signal, blocking until it is received. Once not blocked, corrects +// terminal display settings. Loops indefinitely, does not return. +func handleSignals(c <-chan os.Signal) { + switch <-c { + case syscall.SIGTSTP: + cui.CleanupTerm() + //TODO: getting stuck here + // SIGSTOP seems to be the right signal, but the process + // does not recover? + syscall.Kill(syscall.Getpid(), syscall.SIGSTOP) + case syscall.SIGCONT: + cui.InitTerm() bombadillo.Draw() + case syscall.SIGINT: + cui.Exit() } } @@ -174,8 +179,7 @@ func main() { // So that we can open files from gemini mc = mailcap.NewMailcap() - cui.Tput("rmam") // turn off line wrapping - cui.Tput("smcup") // use alternate screen + cui.InitTerm() defer cui.Exit() err := initClient() if err != nil { @@ -183,10 +187,10 @@ func main() { panic(err) } - // watch for SIGCONT, send it to be handled + // watch for signals, send them to be handled c := make(chan os.Signal, 1) - signal.Notify(c, syscall.SIGCONT) - go handleSIGCONT(c) + signal.Notify(c, syscall.SIGTSTP, syscall.SIGCONT, syscall.SIGINT) + go handleSignals(c) // Start polling for terminal size changes go bombadillo.GetSize() From e32ba04a1a636ca7a60b368acf2cc89c2a068c65 Mon Sep 17 00:00:00 2001 From: asdf Date: Thu, 24 Oct 2019 13:42:38 +1100 Subject: [PATCH 079/145] Missed the for loop...plus some documentation --- cui/cui.go | 9 ++++++--- main.go | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/cui/cui.go b/cui/cui.go index 7d5d71a..fa57870 100644 --- a/cui/cui.go +++ b/cui/cui.go @@ -56,26 +56,29 @@ func moveCursorToward(dir string, amount int) { } } +// Exit performs cleanup operations before exiting the application func Exit() { CleanupTerm() os.Exit(0) } +// InitTerm sets the terminal modes appropriate for Bombadillo func InitTerm() { SetCharMode() Tput("rmam") // turn off line wrapping Tput("smcup") // use alternate screen } +// CleanupTerm reverts changs to terminal mode made by InitTerm func CleanupTerm() { moveCursorToward("down", 500) moveCursorToward("right", 500) SetLineMode() fmt.Print("\n") - fmt.Print("\033[?25h") - Tput("smam") // turn on line wrap - Tput("rmcup") // stop using alternate screen + fmt.Print("\033[?25h") // reenables cursor blinking + Tput("smam") // turn on line wrap + Tput("rmcup") // stop using alternate screen } func Clear(dir string) { diff --git a/main.go b/main.go index e7d7c2d..99e4c3c 100644 --- a/main.go +++ b/main.go @@ -149,20 +149,20 @@ func initClient() error { // In the event of specific signals, ensure the display is shown correctly. // Accepts a signal, blocking until it is received. Once not blocked, corrects -// terminal display settings. Loops indefinitely, does not return. +// terminal display settings as appropriate for that signal. Loops +// indefinitely, does not return. func handleSignals(c <-chan os.Signal) { - switch <-c { - case syscall.SIGTSTP: - cui.CleanupTerm() - //TODO: getting stuck here - // SIGSTOP seems to be the right signal, but the process - // does not recover? - syscall.Kill(syscall.Getpid(), syscall.SIGSTOP) - case syscall.SIGCONT: - cui.InitTerm() - bombadillo.Draw() - case syscall.SIGINT: - cui.Exit() + for { + switch <-c { + case syscall.SIGTSTP: + cui.CleanupTerm() + syscall.Kill(syscall.Getpid(), syscall.SIGSTOP) + case syscall.SIGCONT: + cui.InitTerm() + bombadillo.Draw() + case syscall.SIGINT: + cui.Exit() + } } } From e5c0bd74432c9bdedf809b4b39b210d33f86b9e1 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Wed, 23 Oct 2019 19:52:22 -0700 Subject: [PATCH 080/145] Updated man page --- bombadillo.1 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bombadillo.1 b/bombadillo.1 index e554608..02c2b6d 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -44,7 +44,7 @@ Telnet is not supported directly, but addresses will be followed and opened as a .TP .B http, https -Neither of the world wide web protocols are supported directly. However, bombadillo is capable of attempting to open web links in a user's default web browser. This feature is opt-in only and controlled in a user's settings. This feature does not function properly in a terminal only environment at present. +Neither of the world wide web protocols are supported directly. However,\fBbombadillo\fPis capable of attempting to open web links in a user's default web browser. This feature is opt-in only and controlled in a user's settings. Opening in a default web browser only works if a user has a gui environment available. An alternate option to get web content directly in the client is to install the lynx web browser on the system and turn on 'lynxmode' in the settings (and opt in to following http links). Doing so will allow web content, rendered by lynx, to be viewable directly in \fBbombadillo\fP. .SH COMMANDS .SS KEY COMMANDS These commands work as a single keypress anytime \fBbombadillo\fP is not taking in a line based command. This is the default command mode of \fBbombadillo\fP. @@ -269,3 +269,4 @@ Gopher Homepage gopher://bombadillo.colorfield.space .SH AUTHORS \fBbombadillo\fP was primarily developed by sloum, with kind and patient assistance from ~asdf and jboverf. + From 67d7df680443566d5c526938cdac7f5b3058ab90 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Fri, 25 Oct 2019 20:06:13 -0700 Subject: [PATCH 081/145] Reworks the protocol handling and makes html downloads work --- client.go | 402 ++++++++++++++++++++++++++-------------------- http/lynx_mode.go | 36 +++++ 2 files changed, 261 insertions(+), 177 deletions(-) diff --git a/client.go b/client.go index 107e1c7..f106183 100644 --- a/client.go +++ b/client.go @@ -514,6 +514,8 @@ func (c *client) saveFile(u Url, name string) { file, err = gopher.Retrieve(u.Host, u.Port, u.Resource) case "gemini": file, err = gemini.Fetch(u.Host, u.Port, u.Resource, &c.Certs) + case "http", "https": + file, err = http.Fetch(u.Full) default: c.SetMessage(fmt.Sprintf("Saving files over %s is not supported", u.Scheme), true) c.DrawMessage() @@ -737,6 +739,21 @@ func (c *client) Scroll(amount int) { c.Draw() } +func (c *client) ReloadPage() error { + if c.PageState.Length < 1 { + return fmt.Errorf("There is no page to reload") + } + url := c.PageState.History[c.PageState.Position].Location.Full + err := c.PageState.NavigateHistory(-1) + if err != nil { + return err + } + length := c.PageState.Length + c.Visit(url) + c.PageState.Length = length + return nil +} + func (c *client) SetPercentRead() { page := c.PageState.History[c.PageState.Position] var percentRead int @@ -834,6 +851,8 @@ func (c *client) SetHeaderUrl() { } } +// Visit functions as a controller/router to the +// appropriate protocol handler func (c *client) Visit(url string) { c.SetMessage("Loading...", false) c.DrawMessage() @@ -848,137 +867,199 @@ func (c *client) Visit(url string) { switch u.Scheme { case "gopher": - if u.DownloadOnly { - nameSplit := strings.Split(u.Resource, "/") - filename := nameSplit[len(nameSplit)-1] - filename = strings.Trim(filename, " \t\r\n\v\f\a") - if filename == "" { - filename = "gopherfile" - } - c.saveFile(u, filename) - } else if u.Mime == "7" { - c.search("", u.Full, "?") - } else { - content, links, err := gopher.Visit(u.Mime, u.Host, u.Port, u.Resource) - if err != nil { - c.SetMessage(err.Error(), true) - c.DrawMessage() - return - } - pg := MakePage(u, content, links) + c.handleGopher(u) + case "gemini": + c.handleGemini(u) + case "telnet": + c.handleTelnet(u) + case "http", "https": + c.handleWeb(u) + case "local": + c.handleLocal(u) + case "finger": + c.handleFinger(u) + default: + c.SetMessage(fmt.Sprintf("%q is not a supported protocol", u.Scheme), true) + c.DrawMessage() + } +} + + +// +++ Begin Protocol Handlers +++ + +func (c *client) handleGopher(u Url) { + if u.DownloadOnly { + nameSplit := strings.Split(u.Resource, "/") + filename := nameSplit[len(nameSplit)-1] + filename = strings.Trim(filename, " \t\r\n\v\f\a") + if filename == "" { + filename = "gopherfile" + } + c.saveFile(u, filename) + } else if u.Mime == "7" { + c.search("", u.Full, "?") + } else { + content, links, err := gopher.Visit(u.Mime, u.Host, u.Port, u.Resource) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + pg := MakePage(u, content, links) + pg.WrapContent(c.Width - 1) + c.PageState.Add(pg) + c.SetPercentRead() + c.ClearMessage() + c.SetHeaderUrl() + c.Draw() + } +} + +func (c *client) handleGemini(u Url) { + capsule, err := gemini.Visit(u.Host, u.Port, u.Resource, &c.Certs) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + go saveConfig() + switch capsule.Status { + case 1: + c.search("", u.Full, capsule.Content) + case 2: + if capsule.MimeMaj == "text" { + pg := MakePage(u, capsule.Content, capsule.Links) pg.WrapContent(c.Width - 1) c.PageState.Add(pg) c.SetPercentRead() c.ClearMessage() c.SetHeaderUrl() c.Draw() - } - case "gemini": - capsule, err := gemini.Visit(u.Host, u.Port, u.Resource, &c.Certs) - if err != nil { - c.SetMessage(err.Error(), true) - c.DrawMessage() - return - } - go saveConfig() - switch capsule.Status { - case 1: - c.search("", u.Full, capsule.Content) - case 2: - if capsule.MimeMaj == "text" { - pg := MakePage(u, capsule.Content, capsule.Links) - pg.WrapContent(c.Width - 1) - c.PageState.Add(pg) - c.SetPercentRead() - c.ClearMessage() - c.SetHeaderUrl() - c.Draw() - } else { - c.SetMessage("The file is non-text: (o)pen or (w)rite to disk", false) - c.DrawMessage() - var ch rune - for { - ch = cui.Getch() - if ch == 'o' || ch == 'w' { - break - } - } - switch ch { - case 'o': - mime := fmt.Sprintf("%s/%s", capsule.MimeMaj, capsule.MimeMin) - var term bool - if c.Options["terminalonly"] == "true" { - term = true - } else { - term = false - } - mcEntry, err := mc.FindMatch(mime, "view", term) - if err != nil { - c.SetMessage(err.Error(), true) - c.DrawMessage() - return - } - file, err := ioutil.TempFile("/tmp/", "bombadillo-*.tmp") - if err != nil { - c.SetMessage("Unable to create temporary file for opening, aborting file open", true) - c.DrawMessage() - return - } - // defer os.Remove(file.Name()) - file.Write([]byte(capsule.Content)) - com, e := mcEntry.Command(file.Name()) - if e != nil { - c.SetMessage(e.Error(), true) - c.DrawMessage() - return - } - com.Stdin = os.Stdin - com.Stdout = os.Stdout - com.Stderr = os.Stderr - if c.Options["terminalonly"] == "true" { - cui.Clear("screen") - } - com.Run() - c.SetMessage("File opened by an appropriate program", true) - c.DrawMessage() - c.Draw() - case 'w': - nameSplit := strings.Split(u.Resource, "/") - filename := nameSplit[len(nameSplit)-1] - c.saveFileFromData(capsule.Content, filename) - } - } - case 3: - c.SetMessage("[3] Redirect. Follow redirect? y or any other key for no", false) - c.DrawMessage() - ch := cui.Getch() - if ch == 'y' || ch == 'Y' { - c.Visit(capsule.Content) - } else { - c.SetMessage("Redirect aborted", false) - c.DrawMessage() - } - } - case "telnet": - c.SetMessage("Attempting to start telnet session", false) - c.DrawMessage() - msg, err := telnet.StartSession(u.Host, u.Port) - if err != nil { - c.SetMessage(err.Error(), true) - c.DrawMessage() } else { - c.SetMessage(msg, true) + c.SetMessage("The file is non-text: (o)pen or (w)rite to disk", false) + c.DrawMessage() + var ch rune + for { + ch = cui.Getch() + if ch == 'o' || ch == 'w' { + break + } + } + switch ch { + case 'o': + mime := fmt.Sprintf("%s/%s", capsule.MimeMaj, capsule.MimeMin) + var term bool + if c.Options["terminalonly"] == "true" { + term = true + } else { + term = false + } + mcEntry, err := mc.FindMatch(mime, "view", term) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + file, err := ioutil.TempFile("/tmp/", "bombadillo-*.tmp") + if err != nil { + c.SetMessage("Unable to create temporary file for opening, aborting file open", true) + c.DrawMessage() + return + } + // defer os.Remove(file.Name()) + file.Write([]byte(capsule.Content)) + com, e := mcEntry.Command(file.Name()) + if e != nil { + c.SetMessage(e.Error(), true) + c.DrawMessage() + return + } + com.Stdin = os.Stdin + com.Stdout = os.Stdout + com.Stderr = os.Stderr + if c.Options["terminalonly"] == "true" { + cui.Clear("screen") + } + com.Run() + c.SetMessage("File opened by an appropriate program", true) + c.DrawMessage() + c.Draw() + case 'w': + nameSplit := strings.Split(u.Resource, "/") + filename := nameSplit[len(nameSplit)-1] + c.saveFileFromData(capsule.Content, filename) + } + } + case 3: + c.SetMessage("[3] Redirect. Follow redirect? y or any other key for no", false) + c.DrawMessage() + ch := cui.Getch() + if ch == 'y' || ch == 'Y' { + c.Visit(capsule.Content) + } else { + c.SetMessage("Redirect aborted", false) c.DrawMessage() } - c.Draw() - case "http", "https": - if strings.ToUpper(c.Options["openhttp"]) != "TRUE" { - c.SetMessage("'openhttp' is not set to true, cannot open web link", false) - c.DrawMessage() - return - } - switch strings.ToUpper(c.Options["lynxmode"]) { - case "TRUE": + } +} + +func (c *client) handleTelnet(u Url) { + c.SetMessage("Attempting to start telnet session", false) + c.DrawMessage() + msg, err := telnet.StartSession(u.Host, u.Port) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + } else { + c.SetMessage(msg, true) + c.DrawMessage() + } + c.Draw() +} + +func (c *client) handleLocal(u Url) { + content, err := local.Open(u.Resource) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + pg := MakePage(u, content, []string{}) + pg.WrapContent(c.Width - 1) + c.PageState.Add(pg) + c.SetPercentRead() + c.ClearMessage() + c.SetHeaderUrl() + c.Draw() +} + +func (c *client) handleFinger(u Url) { + content, err := finger.Finger(u.Host, u.Port, u.Resource) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + pg := MakePage(u, content, []string{}) + pg.WrapContent(c.Width - 1) + c.PageState.Add(pg) + c.SetPercentRead() + c.ClearMessage() + c.SetHeaderUrl() + c.Draw() +} + +func (c *client) handleWeb(u Url) { + // Following http is disabled + if strings.ToUpper(c.Options["openhttp"]) != "TRUE" { + c.SetMessage("'openhttp' is not set to true, cannot open web link", false) + c.DrawMessage() + return + } + + // Use lynxmode + if strings.ToUpper(c.Options["lynxmode"]) == "TRUE" { + if http.IsTextFile(u.Full) { page, err := http.Visit(u.Full, c.Width-1) if err != nil { c.SetMessage(fmt.Sprintf("Lynx error: %s", err.Error()), true) @@ -992,70 +1073,37 @@ func (c *client) Visit(url string) { c.ClearMessage() c.SetHeaderUrl() c.Draw() - default: - if strings.ToUpper(c.Options["terminalonly"]) == "TRUE" { - c.SetMessage("'terminalonly' is set to true and 'lynxmode' is not enabled, cannot open web link", false) - c.DrawMessage() + } else { + c.SetMessage("The file is non-text: writing to disk...", false) + c.DrawMessage() + var fn string + if i := strings.LastIndex(u.Full, "/"); i > 0 && i + 1 < len(u.Full) { + fn = u.Full[i + 1:] } else { - c.SetMessage("Attempting to open in web browser", false) - c.DrawMessage() - msg, err := http.OpenInBrowser(u.Full) - if err != nil { - c.SetMessage(err.Error(), true) - } else { - c.SetMessage(msg, false) - } - c.DrawMessage() + fn = "bombadillo.download" } + c.saveFile(u, fn) } - case "local": - content, err := local.Open(u.Resource) - if err != nil { - c.SetMessage(err.Error(), true) + + // Open in default web browser if available + } else { + if strings.ToUpper(c.Options["terminalonly"]) == "TRUE" { + c.SetMessage("'terminalonly' is set to true and 'lynxmode' is not enabled, cannot open web link", false) c.DrawMessage() - return - } - pg := MakePage(u, content, []string{}) - pg.WrapContent(c.Width - 1) - c.PageState.Add(pg) - c.SetPercentRead() - c.ClearMessage() - c.SetHeaderUrl() - c.Draw() - case "finger": - content, err := finger.Finger(u.Host, u.Port, u.Resource) - if err != nil { - c.SetMessage(err.Error(), true) + } else { + c.SetMessage("Attempting to open in web browser", false) + c.DrawMessage() + msg, err := http.OpenInBrowser(u.Full) + if err != nil { + c.SetMessage(err.Error(), true) + } else { + c.SetMessage(msg, false) + } c.DrawMessage() - return } - pg := MakePage(u, content, []string{}) - pg.WrapContent(c.Width - 1) - c.PageState.Add(pg) - c.SetPercentRead() - c.ClearMessage() - c.SetHeaderUrl() - c.Draw() - default: - c.SetMessage(fmt.Sprintf("%q is not a supported protocol", u.Scheme), true) - c.DrawMessage() } } -func (c *client) ReloadPage() error { - if c.PageState.Length < 1 { - return fmt.Errorf("There is no page to reload") - } - url := c.PageState.History[c.PageState.Position].Location.Full - err := c.PageState.NavigateHistory(-1) - if err != nil { - return err - } - length := c.PageState.Length - c.Visit(url) - c.PageState.Length = length - return nil -} //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ diff --git a/http/lynx_mode.go b/http/lynx_mode.go index 6b431e5..d329d1d 100644 --- a/http/lynx_mode.go +++ b/http/lynx_mode.go @@ -2,6 +2,8 @@ package http import ( "fmt" + "io/ioutil" + "net/http" "os/exec" "strings" ) @@ -23,6 +25,24 @@ func Visit(url string, width int) (page, error) { return parseLinks(string(c)), nil } +// Returns false on err or non-text type +// Else returns true +func IsTextFile(url string) bool { + c, err := exec.Command("lynx", "-dump", "-head", url).Output() + if err != nil { + return false + } + content := string(c) + content = strings.ToLower(content) + headers := strings.Split(content, "\n") + for _, header := range headers { + if strings.Contains(header, "content-type:") && strings.Contains(header, "text") { + return true + } + } + return false +} + func parseLinks(c string) page { var out page contentUntil := strings.LastIndex(c, "References") @@ -47,3 +67,19 @@ func parseLinks(c string) page { return out } + +func Fetch(url string) ([]byte, error) { + resp, err := http.Get(url) + if err != nil { + return []byte{}, err + } + defer resp.Body.Close() + + bodyBytes, err := ioutil.ReadAll(resp.Body) + if err != nil { + return []byte{}, err + } + + return bodyBytes, nil +} + From ceeaa2d0f04b1782263d95acf92a3f25d1b5b119 Mon Sep 17 00:00:00 2001 From: asdf Date: Sun, 27 Oct 2019 11:31:06 +1100 Subject: [PATCH 082/145] Spelling/syntax errors, suggested rewrite of web section --- bombadillo.1 | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/bombadillo.1 b/bombadillo.1 index 02c2b6d..62eb5af 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -1,4 +1,4 @@ -.TH "bombadillo" 1 "12 OCT 2019" "" "General Opperation Manual" +.TH "bombadillo" 1 "12 OCT 2019" "" "General Operation Manual" .SH NAME \fBbombadillo \fP- a non-web client .SH SYNOPSIS @@ -32,7 +32,7 @@ Gemini is supported, but as a new protocol with an incomplete specification, fea .TP .B finger -Basic support is provided for the finger protocol. The format is: \fIfinger://[[username@]][hostname]\fP. Many servers still support finger and it can be fun to see if friends are online or read about the users who's phlogs you follow. +Basic support is provided for the finger protocol. The format is: \fIfinger://[[username@]][hostname]\fP. Many servers still support finger and it can be fun to see if friends are online or read about the users whose phlogs you follow. .TP .B local @@ -44,7 +44,11 @@ Telnet is not supported directly, but addresses will be followed and opened as a .TP .B http, https -Neither of the world wide web protocols are supported directly. However,\fBbombadillo\fPis capable of attempting to open web links in a user's default web browser. This feature is opt-in only and controlled in a user's settings. Opening in a default web browser only works if a user has a gui environment available. An alternate option to get web content directly in the client is to install the lynx web browser on the system and turn on 'lynxmode' in the settings (and opt in to following http links). Doing so will allow web content, rendered by lynx, to be viewable directly in \fBbombadillo\fP. +Neither of the world wide web protocols are supported directly. However, \fBbombadillo\fP can open web links in a user's default web browser, or display web content directly in the client via the lynx web browser. Opening http links is opt-in only, controlled by the \fIopenhttp\fP setting. +.IP +Opening links in a default web browser only works if a GUI environment is available. +.IP +Opening web content directly in the client requires the lynx web browser, and is enabled using the \fIlynxmode\fP setting. Web content is processed using lynx, and then displayed in the client. .SH COMMANDS .SS KEY COMMANDS These commands work as a single keypress anytime \fBbombadillo\fP is not taking in a line based command. This is the default command mode of \fBbombadillo\fP. @@ -238,11 +242,11 @@ Tells the client what command to use to start a telnet session. Should be a vali .TP .B terminalonly -Sets whether or not to try to open non-text files served via gemini in gui programs or not. If set to \fItrue\fP \fBbombdaillo\fP will only attempt to use terminal programs to open files. If set to \fIfalse\fP \fBbombadillo\fP may choose from the appropriate programs installed on the system, including graphical ones. +Sets whether or not to try to open non-text files served via gemini in GUI programs or not. If set to \fItrue\fP \fBbombadillo\fP will only attempt to use terminal programs to open files. If set to \fIfalse\fP \fBbombadillo\fP may choose from the appropriate programs installed on the system, including graphical ones. .TP .B theme -Can toggle between visual modes. Valid values are \fInormal\fP and \fIinverse\fP. When set to ivnerse, the terminal color mode is inversed. +Can toggle between visual modes. Valid values are \fInormal\fP and \fIinverse\fP. When set to inverse, the terminal color mode is inverted. .TP .B tlscertificate @@ -250,7 +254,7 @@ A path to a tls certificate file on a user's local filesystem. Defaults to NULL. .TP .B tlskey -A path the a tls key that pairs with the tlscertificate setting, on a user's local filesystem. Defaults to NULL. Both \fItlskey\fP and \fItlscertificate\fP must be set for client certificates to work in gemini. +A path to a tls key that pairs with the tlscertificate setting, on a user's local filesystem. Defaults to NULL. Both \fItlskey\fP and \fItlscertificate\fP must be set for client certificates to work in gemini. .SH BUGS There are very likely bugs. Many known bugs can be found in the issues section of \fBbombadillo\fP's software repository (see \fIlinks\fP). .SH LINKS From 9d77c3cea085b2d534762c4f55e390320524fb58 Mon Sep 17 00:00:00 2001 From: asdf Date: Sun, 27 Oct 2019 11:48:03 +1100 Subject: [PATCH 083/145] Removed empty line at end of man page --- bombadillo.1 | 1 - 1 file changed, 1 deletion(-) diff --git a/bombadillo.1 b/bombadillo.1 index 62eb5af..72baf04 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -273,4 +273,3 @@ Gopher Homepage gopher://bombadillo.colorfield.space .SH AUTHORS \fBbombadillo\fP was primarily developed by sloum, with kind and patient assistance from ~asdf and jboverf. - From be4741895e1c7ae00eec325ba803286a1544ff94 Mon Sep 17 00:00:00 2001 From: asdf Date: Sun, 27 Oct 2019 23:24:52 +1100 Subject: [PATCH 084/145] Found and addressed some possible path issues --- client.go | 9 ++++----- main.go | 3 ++- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client.go b/client.go index 71b998d..021267a 100644 --- a/client.go +++ b/client.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "os" "os/exec" + "path" "path/filepath" "regexp" "strconv" @@ -504,6 +505,7 @@ func (c *client) getCurrentPageRawData() (string, error) { return c.PageState.History[c.PageState.Position].RawContent, nil } +// Saves the specified URL to the specified file path. func (c *client) saveFile(u Url, name string) { var file []byte var err error @@ -849,8 +851,7 @@ func (c *client) Visit(url string) { switch u.Scheme { case "gopher": if u.DownloadOnly { - nameSplit := strings.Split(u.Resource, "/") - filename := nameSplit[len(nameSplit)-1] + filename := path.Base(u.Resource) filename = strings.Trim(filename, " \t\r\n\v\f\a") if filename == "" { filename = "gopherfile" @@ -943,8 +944,7 @@ func (c *client) Visit(url string) { c.DrawMessage() c.Draw() case 'w': - nameSplit := strings.Split(u.Resource, "/") - filename := nameSplit[len(nameSplit)-1] + filename := path.Base(u.Resource) c.saveFileFromData(capsule.Content, filename) } } @@ -1035,7 +1035,6 @@ func (c *client) ReloadPage() error { return nil } - //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ diff --git a/main.go b/main.go index 8a95281..867ef17 100644 --- a/main.go +++ b/main.go @@ -23,6 +23,7 @@ import ( "io/ioutil" "os" "os/signal" + "path/filepath" "strings" "syscall" @@ -61,7 +62,7 @@ func saveConfig() error { opts.WriteString(certs) - return ioutil.WriteFile(bombadillo.Options["configlocation"]+"/.bombadillo.ini", []byte(opts.String()), 0644) + return ioutil.WriteFile(filepath.Join(bombadillo.Options["configlocation"], ".bombadillo.ini"), []byte(opts.String()), 0644) } func validateOpt(opt, val string) bool { From 9c2caf4a6f2c43a6b96d8064b188244a1aeaa18a Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 27 Oct 2019 11:09:45 -0700 Subject: [PATCH 085/145] Updates man page --- README.md | 6 ++++-- bombadillo.1 | 4 ++-- client.go | 58 +++++----------------------------------------------- main.go | 6 ------ 4 files changed, 11 insertions(+), 63 deletions(-) diff --git a/README.md b/README.md index 7593b85..eb09b0f 100644 --- a/README.md +++ b/README.md @@ -9,9 +9,11 @@ These instructions will get a copy of the project up and running on your local m ### Prerequisites -If building from source, you will need to have [Go](https://golang.org/) version >= 1.12. +If building from source, you will need to have [Go](https://golang.org/) version >= 1.11. -While Bombadillo has one external dependency of [Mailcap](https://tildegit.org/sloum/mailcap), no action is typically required to download this, as it is handled automatically during the build process. +#### Optional + +[Lynx](https://lynx.invisible-island.net/), the text based web browser, can be used as a parsing engine for http/https. This is a totally optional item and Lynx is in no way required in order to compile or run Bombadillo. Having it available on the system can help create a richer experience by allowing users to navigate directly to web content in Bombadillo. Many users may wish to avoid this entirely,a nd the default configuration does not have this behavior turned on. To turn it on from within Bombadillo enter the command `set lynxmode true`. ### Installing diff --git a/bombadillo.1 b/bombadillo.1 index 72baf04..b694e3a 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -1,4 +1,4 @@ -.TH "bombadillo" 1 "12 OCT 2019" "" "General Operation Manual" +.TH "bombadillo" 1 "27 OCT 2019" "" "General Operation Manual" .SH NAME \fBbombadillo \fP- a non-web client .SH SYNOPSIS @@ -28,7 +28,7 @@ Gopher is the default protocol for \fBbombadillo\fP. Any textual item types will .TP .B gemini -Gemini is supported, but as a new protocol with an incomplete specification, features may change over time. At present Bombadillo supports TLS with a trust on first use certificate pinning system (similar to SSH). Client certificates are also supported via option configuration. Gemini maps and other text types are rendered in the client and non-text types will trigger a prompt to the user to download or open in an appropriate program. +Gemini is supported, but as a new protocol with an incomplete specification, features may change over time. At present Bombadillo supports TLS with a trust on first use certificate pinning system (similar to SSH). Client certificates are also supported via option configuration. Gemini maps and other text types are rendered in the client and non-text types will be downloaded. .TP .B finger diff --git a/client.go b/client.go index f106183..452dad1 100644 --- a/client.go +++ b/client.go @@ -936,62 +936,14 @@ func (c *client) handleGemini(u Url) { c.SetHeaderUrl() c.Draw() } else { - c.SetMessage("The file is non-text: (o)pen or (w)rite to disk", false) + c.SetMessage("The file is non-text: writing to disk...", false) c.DrawMessage() - var ch rune - for { - ch = cui.Getch() - if ch == 'o' || ch == 'w' { - break - } - } - switch ch { - case 'o': - mime := fmt.Sprintf("%s/%s", capsule.MimeMaj, capsule.MimeMin) - var term bool - if c.Options["terminalonly"] == "true" { - term = true - } else { - term = false - } - mcEntry, err := mc.FindMatch(mime, "view", term) - if err != nil { - c.SetMessage(err.Error(), true) - c.DrawMessage() - return - } - file, err := ioutil.TempFile("/tmp/", "bombadillo-*.tmp") - if err != nil { - c.SetMessage("Unable to create temporary file for opening, aborting file open", true) - c.DrawMessage() - return - } - // defer os.Remove(file.Name()) - file.Write([]byte(capsule.Content)) - com, e := mcEntry.Command(file.Name()) - if e != nil { - c.SetMessage(e.Error(), true) - c.DrawMessage() - return - } - com.Stdin = os.Stdin - com.Stdout = os.Stdout - com.Stderr = os.Stderr - if c.Options["terminalonly"] == "true" { - cui.Clear("screen") - } - com.Run() - c.SetMessage("File opened by an appropriate program", true) - c.DrawMessage() - c.Draw() - case 'w': - nameSplit := strings.Split(u.Resource, "/") - filename := nameSplit[len(nameSplit)-1] - c.saveFileFromData(capsule.Content, filename) - } + nameSplit := strings.Split(u.Resource, "/") + filename := nameSplit[len(nameSplit)-1] + c.saveFileFromData(capsule.Content, filename) } case 3: - c.SetMessage("[3] Redirect. Follow redirect? y or any other key for no", false) + c.SetMessage(fmt.Sprintf("Follow redirect (y/n): %s?", capsule.Content), false) c.DrawMessage() ch := cui.Getch() if ch == 'y' || ch == 'Y' { diff --git a/main.go b/main.go index 6108ebc..2e1860e 100644 --- a/main.go +++ b/main.go @@ -30,7 +30,6 @@ import ( "tildegit.org/sloum/bombadillo/config" "tildegit.org/sloum/bombadillo/cui" _ "tildegit.org/sloum/bombadillo/gemini" - "tildegit.org/sloum/mailcap" ) var version string @@ -39,7 +38,6 @@ var build string var bombadillo *client var helplocation string = "gopher://bombadillo.colorfield.space:70/1/user-guide.map" var settings config.Config -var mc *mailcap.Mailcap func saveConfig() error { var opts strings.Builder @@ -194,10 +192,6 @@ func main() { } args := flag.Args() - // Build the mailcap db - // So that we can open files from gemini - mc = mailcap.NewMailcap() - cui.InitTerm() defer cui.Exit() err := initClient() From 73c77fd625f29da4e6327bf2a648b2ca51f1e000 Mon Sep 17 00:00:00 2001 From: asdf Date: Mon, 28 Oct 2019 11:10:03 +1100 Subject: [PATCH 086/145] Corrected spelling error --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eb09b0f..141e1a5 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ If building from source, you will need to have [Go](https://golang.org/) version #### Optional -[Lynx](https://lynx.invisible-island.net/), the text based web browser, can be used as a parsing engine for http/https. This is a totally optional item and Lynx is in no way required in order to compile or run Bombadillo. Having it available on the system can help create a richer experience by allowing users to navigate directly to web content in Bombadillo. Many users may wish to avoid this entirely,a nd the default configuration does not have this behavior turned on. To turn it on from within Bombadillo enter the command `set lynxmode true`. +[Lynx](https://lynx.invisible-island.net/), the text based web browser, can be used as a parsing engine for http/https. This is a totally optional item and Lynx is in no way required in order to compile or run Bombadillo. Having it available on the system can help create a richer experience by allowing users to navigate directly to web content in Bombadillo. Many users may wish to avoid this entirely, and the default configuration does not have this behavior turned on. To turn it on from within Bombadillo enter the command `set lynxmode true`. ### Installing From b441ac4624133dd9ccfc0a6b94ea5f64b3da73ff Mon Sep 17 00:00:00 2001 From: asdf Date: Mon, 28 Oct 2019 11:21:07 +1100 Subject: [PATCH 087/145] go.mod, go.sum mailcap cleanup, version decrement --- go.mod | 4 +--- go.sum | 2 -- 2 files changed, 1 insertion(+), 5 deletions(-) delete mode 100644 go.sum diff --git a/go.mod b/go.mod index 609acc7..acb6d6f 100644 --- a/go.mod +++ b/go.mod @@ -1,5 +1,3 @@ module tildegit.org/sloum/bombadillo -go 1.12 - -require tildegit.org/sloum/mailcap v0.0.0-20190706214029-b787a49e9db2 +go 1.11 diff --git a/go.sum b/go.sum deleted file mode 100644 index 60768f8..0000000 --- a/go.sum +++ /dev/null @@ -1,2 +0,0 @@ -tildegit.org/sloum/mailcap v0.0.0-20190706214029-b787a49e9db2 h1:tAPIFBpXwOq1Ytxk8aGsDjCutnwUC01BVkK77QS1bdU= -tildegit.org/sloum/mailcap v0.0.0-20190706214029-b787a49e9db2/go.mod h1:m4etAw9DbXsdanDUNS8oERhL+7y4II82ZLHWzw2yibg= From 8b0d87f30cc25707fdff86eae59e312c219e47b4 Mon Sep 17 00:00:00 2001 From: asdf Date: Mon, 28 Oct 2019 22:03:04 +1100 Subject: [PATCH 088/145] Reverting changes to client.go --- client.go | 348 +++++++++++++++++++++++++++++------------------------- 1 file changed, 185 insertions(+), 163 deletions(-) diff --git a/client.go b/client.go index 021267a..452dad1 100644 --- a/client.go +++ b/client.go @@ -5,7 +5,6 @@ import ( "io/ioutil" "os" "os/exec" - "path" "path/filepath" "regexp" "strconv" @@ -505,7 +504,6 @@ func (c *client) getCurrentPageRawData() (string, error) { return c.PageState.History[c.PageState.Position].RawContent, nil } -// Saves the specified URL to the specified file path. func (c *client) saveFile(u Url, name string) { var file []byte var err error @@ -516,6 +514,8 @@ func (c *client) saveFile(u Url, name string) { file, err = gopher.Retrieve(u.Host, u.Port, u.Resource) case "gemini": file, err = gemini.Fetch(u.Host, u.Port, u.Resource, &c.Certs) + case "http", "https": + file, err = http.Fetch(u.Full) default: c.SetMessage(fmt.Sprintf("Saving files over %s is not supported", u.Scheme), true) c.DrawMessage() @@ -739,6 +739,21 @@ func (c *client) Scroll(amount int) { c.Draw() } +func (c *client) ReloadPage() error { + if c.PageState.Length < 1 { + return fmt.Errorf("There is no page to reload") + } + url := c.PageState.History[c.PageState.Position].Location.Full + err := c.PageState.NavigateHistory(-1) + if err != nil { + return err + } + length := c.PageState.Length + c.Visit(url) + c.PageState.Length = length + return nil +} + func (c *client) SetPercentRead() { page := c.PageState.History[c.PageState.Position] var percentRead int @@ -836,6 +851,8 @@ func (c *client) SetHeaderUrl() { } } +// Visit functions as a controller/router to the +// appropriate protocol handler func (c *client) Visit(url string) { c.SetMessage("Loading...", false) c.DrawMessage() @@ -850,131 +867,184 @@ func (c *client) Visit(url string) { switch u.Scheme { case "gopher": - if u.DownloadOnly { - filename := path.Base(u.Resource) - filename = strings.Trim(filename, " \t\r\n\v\f\a") - if filename == "" { - filename = "gopherfile" - } - c.saveFile(u, filename) - } else if u.Mime == "7" { - c.search("", u.Full, "?") - } else { - content, links, err := gopher.Visit(u.Mime, u.Host, u.Port, u.Resource) - if err != nil { - c.SetMessage(err.Error(), true) - c.DrawMessage() - return - } - pg := MakePage(u, content, links) + c.handleGopher(u) + case "gemini": + c.handleGemini(u) + case "telnet": + c.handleTelnet(u) + case "http", "https": + c.handleWeb(u) + case "local": + c.handleLocal(u) + case "finger": + c.handleFinger(u) + default: + c.SetMessage(fmt.Sprintf("%q is not a supported protocol", u.Scheme), true) + c.DrawMessage() + } +} + + +// +++ Begin Protocol Handlers +++ + +func (c *client) handleGopher(u Url) { + if u.DownloadOnly { + nameSplit := strings.Split(u.Resource, "/") + filename := nameSplit[len(nameSplit)-1] + filename = strings.Trim(filename, " \t\r\n\v\f\a") + if filename == "" { + filename = "gopherfile" + } + c.saveFile(u, filename) + } else if u.Mime == "7" { + c.search("", u.Full, "?") + } else { + content, links, err := gopher.Visit(u.Mime, u.Host, u.Port, u.Resource) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + pg := MakePage(u, content, links) + pg.WrapContent(c.Width - 1) + c.PageState.Add(pg) + c.SetPercentRead() + c.ClearMessage() + c.SetHeaderUrl() + c.Draw() + } +} + +func (c *client) handleGemini(u Url) { + capsule, err := gemini.Visit(u.Host, u.Port, u.Resource, &c.Certs) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + go saveConfig() + switch capsule.Status { + case 1: + c.search("", u.Full, capsule.Content) + case 2: + if capsule.MimeMaj == "text" { + pg := MakePage(u, capsule.Content, capsule.Links) pg.WrapContent(c.Width - 1) c.PageState.Add(pg) c.SetPercentRead() c.ClearMessage() c.SetHeaderUrl() c.Draw() - } - case "gemini": - capsule, err := gemini.Visit(u.Host, u.Port, u.Resource, &c.Certs) - if err != nil { - c.SetMessage(err.Error(), true) + } else { + c.SetMessage("The file is non-text: writing to disk...", false) c.DrawMessage() - return + nameSplit := strings.Split(u.Resource, "/") + filename := nameSplit[len(nameSplit)-1] + c.saveFileFromData(capsule.Content, filename) } - go saveConfig() - switch capsule.Status { - case 1: - c.search("", u.Full, capsule.Content) - case 2: - if capsule.MimeMaj == "text" { - pg := MakePage(u, capsule.Content, capsule.Links) - pg.WrapContent(c.Width - 1) - c.PageState.Add(pg) - c.SetPercentRead() - c.ClearMessage() - c.SetHeaderUrl() - c.Draw() - } else { - c.SetMessage("The file is non-text: (o)pen or (w)rite to disk", false) - c.DrawMessage() - var ch rune - for { - ch = cui.Getch() - if ch == 'o' || ch == 'w' { - break - } - } - switch ch { - case 'o': - mime := fmt.Sprintf("%s/%s", capsule.MimeMaj, capsule.MimeMin) - var term bool - if c.Options["terminalonly"] == "true" { - term = true - } else { - term = false - } - mcEntry, err := mc.FindMatch(mime, "view", term) - if err != nil { - c.SetMessage(err.Error(), true) - c.DrawMessage() - return - } - file, err := ioutil.TempFile("/tmp/", "bombadillo-*.tmp") - if err != nil { - c.SetMessage("Unable to create temporary file for opening, aborting file open", true) - c.DrawMessage() - return - } - // defer os.Remove(file.Name()) - file.Write([]byte(capsule.Content)) - com, e := mcEntry.Command(file.Name()) - if e != nil { - c.SetMessage(e.Error(), true) - c.DrawMessage() - return - } - com.Stdin = os.Stdin - com.Stdout = os.Stdout - com.Stderr = os.Stderr - if c.Options["terminalonly"] == "true" { - cui.Clear("screen") - } - com.Run() - c.SetMessage("File opened by an appropriate program", true) - c.DrawMessage() - c.Draw() - case 'w': - filename := path.Base(u.Resource) - c.saveFileFromData(capsule.Content, filename) - } - } - case 3: - c.SetMessage("[3] Redirect. Follow redirect? y or any other key for no", false) - c.DrawMessage() - ch := cui.Getch() - if ch == 'y' || ch == 'Y' { - c.Visit(capsule.Content) - } else { - c.SetMessage("Redirect aborted", false) - c.DrawMessage() - } - } - case "telnet": - c.SetMessage("Attempting to start telnet session", false) + case 3: + c.SetMessage(fmt.Sprintf("Follow redirect (y/n): %s?", capsule.Content), false) c.DrawMessage() - msg, err := telnet.StartSession(u.Host, u.Port) - if err != nil { - c.SetMessage(err.Error(), true) + ch := cui.Getch() + if ch == 'y' || ch == 'Y' { + c.Visit(capsule.Content) + } else { + c.SetMessage("Redirect aborted", false) + c.DrawMessage() + } + } +} + +func (c *client) handleTelnet(u Url) { + c.SetMessage("Attempting to start telnet session", false) + c.DrawMessage() + msg, err := telnet.StartSession(u.Host, u.Port) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + } else { + c.SetMessage(msg, true) + c.DrawMessage() + } + c.Draw() +} + +func (c *client) handleLocal(u Url) { + content, err := local.Open(u.Resource) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + pg := MakePage(u, content, []string{}) + pg.WrapContent(c.Width - 1) + c.PageState.Add(pg) + c.SetPercentRead() + c.ClearMessage() + c.SetHeaderUrl() + c.Draw() +} + +func (c *client) handleFinger(u Url) { + content, err := finger.Finger(u.Host, u.Port, u.Resource) + if err != nil { + c.SetMessage(err.Error(), true) + c.DrawMessage() + return + } + pg := MakePage(u, content, []string{}) + pg.WrapContent(c.Width - 1) + c.PageState.Add(pg) + c.SetPercentRead() + c.ClearMessage() + c.SetHeaderUrl() + c.Draw() +} + +func (c *client) handleWeb(u Url) { + // Following http is disabled + if strings.ToUpper(c.Options["openhttp"]) != "TRUE" { + c.SetMessage("'openhttp' is not set to true, cannot open web link", false) + c.DrawMessage() + return + } + + // Use lynxmode + if strings.ToUpper(c.Options["lynxmode"]) == "TRUE" { + if http.IsTextFile(u.Full) { + page, err := http.Visit(u.Full, c.Width-1) + if err != nil { + c.SetMessage(fmt.Sprintf("Lynx error: %s", err.Error()), true) + c.DrawMessage() + return + } + pg := MakePage(u, page.Content, page.Links) + pg.WrapContent(c.Width - 1) + c.PageState.Add(pg) + c.SetPercentRead() + c.ClearMessage() + c.SetHeaderUrl() + c.Draw() + } else { + c.SetMessage("The file is non-text: writing to disk...", false) + c.DrawMessage() + var fn string + if i := strings.LastIndex(u.Full, "/"); i > 0 && i + 1 < len(u.Full) { + fn = u.Full[i + 1:] + } else { + fn = "bombadillo.download" + } + c.saveFile(u, fn) + } + + // Open in default web browser if available + } else { + if strings.ToUpper(c.Options["terminalonly"]) == "TRUE" { + c.SetMessage("'terminalonly' is set to true and 'lynxmode' is not enabled, cannot open web link", false) c.DrawMessage() } else { - c.SetMessage(msg, true) + c.SetMessage("Attempting to open in web browser", false) c.DrawMessage() - } - c.Draw() - case "http", "https": - c.SetMessage("Attempting to open in web browser", false) - c.DrawMessage() - if strings.ToUpper(c.Options["openhttp"]) == "TRUE" { msg, err := http.OpenInBrowser(u.Full) if err != nil { c.SetMessage(err.Error(), true) @@ -982,58 +1052,10 @@ func (c *client) Visit(url string) { c.SetMessage(msg, false) } c.DrawMessage() - } else { - c.SetMessage("'openhttp' is not set to true, cannot open web link", false) - c.DrawMessage() } - case "local": - content, err := local.Open(u.Resource) - if err != nil { - c.SetMessage(err.Error(), true) - c.DrawMessage() - return - } - pg := MakePage(u, content, []string{}) - pg.WrapContent(c.Width - 1) - c.PageState.Add(pg) - c.SetPercentRead() - c.ClearMessage() - c.SetHeaderUrl() - c.Draw() - case "finger": - content, err := finger.Finger(u.Host, u.Port, u.Resource) - if err != nil { - c.SetMessage(err.Error(), true) - c.DrawMessage() - return - } - pg := MakePage(u, content, []string{}) - pg.WrapContent(c.Width - 1) - c.PageState.Add(pg) - c.SetPercentRead() - c.ClearMessage() - c.SetHeaderUrl() - c.Draw() - default: - c.SetMessage(fmt.Sprintf("%q is not a supported protocol", u.Scheme), true) - c.DrawMessage() } } -func (c *client) ReloadPage() error { - if c.PageState.Length < 1 { - return fmt.Errorf("There is no page to reload") - } - url := c.PageState.History[c.PageState.Position].Location.Full - err := c.PageState.NavigateHistory(-1) - if err != nil { - return err - } - length := c.PageState.Length - c.Visit(url) - c.PageState.Length = length - return nil -} //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ From f4e5209f24b8f20a6338591d5b506ba909c624e5 Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Mon, 28 Oct 2019 11:48:16 -0700 Subject: [PATCH 089/145] Updates readme to be more current with the develop branch --- README.md | 62 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index d9859ad..bea3519 100644 --- a/README.md +++ b/README.md @@ -1,77 +1,95 @@ # Bombadillo -Bombadillo is a non-web client for the terminal, and functions as a pager/terminal UI. Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Currently, Bombadillo supports the following protocols: -- gopher -- gemini -- finger -- local (a user's filesystem) -- telnet (by opening links in a subprocess w/ a telnet application) -- http/https links can be opened in a user's default web browser as an opt-in behavior +Bombadillo is a non-web client for the terminal, and functions as a pager/terminal UI. Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Currently, Bombadillo supports the following protocols as first class citizens: +* gopher +* gemini +* finger +* local (a user's filesystem) + +Support for the following protocols is also available via integration with 3rd party applications: +* telnet + * By opening links in a subprocess w/ a telnet application +* http/https + * Web support is opt-in (turned off by default) + * Links can be opened in a user's default web browser when in a graphical environment + * Web pages can be rendered directly in Bombadillo if [Lynx](https://lynx.invisible-island.net/) is installed on the system to handle the document parsing. ## Getting Started -These instructions will get a copy of the project up and running on your local machine. +These instructions will get a copy of the project up and running on your local machine. The following only applies if you are building from source (rather than using a precompiled binary). ### Prerequisites -If building from source, you will need to have [Go](https://golang.org/) version >= 1.12. +You will need to have [Go](https://golang.org/) version >= 1.11. ### Building, Installing, Uninstalling -Bombadillo installation uses `make`. It is possible to just use the go compiler directly (`go install`) if you do not wish to have a man page installed and do not want a program to manage uninstalling and cleaning up. +Bombadillo installation uses `make`. It is also possible to just use the go compiler directly (`go install`), but this is not the recommended approach. -By default Bombadillo will try to install to `$GOBIN`. If it is not set it will try `$GOPATH/bin` (if `$GOPATH` is set), otherwise `~/go/bin`. +By default running `make` from the source code directory will build Bombadillo in the local directory. This is fine for testing or trying things out. But for usage systemwide and easy access to documentation, you will likely want to install. #### Basic Installation -Once you have `go` installed you can build a few different ways. Most users will want the following: +Most users will want to isntall via the following: ``` git clone https://tildegit.org/sloum/bombadillo.git cd bombadillo -make install +sudo make install ``` +Note: the usage of sudo here will be system dependent. Most systems will require it for installation to `/usr/local/bin`. -Once that is done you should be able to run `bombadillo` (assuming that one of the default install locations exists and is on your path) or view the manual with `man bombadillo`. +You can then run `bombadillo` or familiarize yourself with the application by running `man bombadillo`. #### Custom Installation There are a number of default configuration options in the file `defaults.go`. These can all be set prior to building in order to have these defaults apply to all users of Bombadillo on a given system. That said, the basic configuration already present should be suitable for most users (and all settings but one can be changed from within a Bombadillo session). -The installation location can be overridden at compile time, which can be very useful for administrators wanting to set up Bombadillo on a multi-user machine. If you wanted to install to, for example, `/usr/local/bin` you would do the following: +The installation location can be overridden at compile time, which can be very useful for administrators wanting to set up Bombadillo on a multi-user machine. ``` git clone https://tildegit.org/sloum/bombadillo.git cd bombadillo -make install BUILD_PATH=/usr/local/bin +sudo make DESTDIR=/some/directory install ``` +There are two things to know about when using the above format: +1. The above would install Bombadillo to `/some/directory/usr/local/bin`, _not_ to `/some/directory`. So you will want to make sure your `$PATH` is set accordingly. +2. Using the above will install the man page to `/some/directory/usr/local/share/man`, rather than its usual location. You will want to update your `manpath` accordingly. + #### Uninstall If you used the makefile to install Bombadillo then uninstalling is very simple. From the Bombadillo source folder run: ``` -make uninstall +sudo make uninstall ``` +If you used a custom `DESTDIR` value during install, you will need to supply it when uninstalling: +``` +sudo make DESTDIR=/some/directory uninstall +``` + +Uninstall will clean up any build files, remove the installed binary, and remove the manpage from the system. If will _not_ remove any directories created as a part of the installation, nor will it remove any Bombadillo user configuration files. + #### Troubleshooting -If you run `bombadillo` and get `bombadillo: command not found`, try running `make build` from within the cloned repo. Then try: `./bombadillo`. If that works it means that Go does not install to your path, or the custom path you selected is not on your path. Try the custom install from above to a location you know to be on your path. +If you run `bombadillo` and get `bombadillo: command not found`, try running `make build` from within the cloned repo. Then try: `./bombadillo`. If that works it means that the application is getting built correctly and the issue is likely in your path settings. Any errors during `make install` should be pretty visible, as you will be able to see what command it failed on. ### Downloading -If you would prefer to download a binary for your system, rather than build from source, please visit the [Bombadillo downloads](https://rawtext.club/~sloum/bombadillo.html#downloads) page. Don't see your OS/architecture? Bombadillo can be built for use with any POSIX compliant system that is supported as a target for the Go compiler (Linux, BSD, OS X, Plan 9). No testing has been done for Windows. The program will build, but will likely not work properly outside of the Linux subsystem. If you are a Windows user and would like to do some testing or get involved in development please reach out or open an issue. +If you would prefer to download a binary for your system, rather than build from source, please visit the [Bombadillo releases](http://bombadillo.colorfield.space/releases) page. Don't see your OS/architecture? Bombadillo can be built for use with any system that is supported as a target for the Go compiler (Linux, BSD, OS X, Plan 9). There is no explicit support for, or testing done for, Windows or Plan 9. The program should build on those systems, but you may encounter unexpected behaviors or incompatibilities. ### Documentation Bombadillo's primary documentation can be found in the man entry that installs with Bombadillo. To access it run `man bombadillo` after first installing Bombadillo. If for some reason that does not work, the document can be accessed directly from the source folder with `man ./bombadillo.1`. -In addition to the man page, users can get information on Bombadillo on the web @ [http://bombadillo.colorfield.space](http://bombadillo.colorfield.space). Running the command `help` inside Bombadillo will navigate a user to the gopher server hosted at [bombadillo.colorfield.space](gopher://bombadillo.colorfield.space), specifically the user guide. +In addition to the man page, users can get information on Bombadillo on the web @ [http://bombadillo.colorfield.space](http://bombadillo.colorfield.space). Running the command `help` inside Bombadillo will navigate a user to the gopher server hosted at [bombadillo.colorfield.space](gopher://bombadillo.colorfield.space); specifically the user guide. ## Contributing -Bombadillo development is largely handled by Sloum, with help from asdf, jboverf, and some community input. If you would like to get involved, please reach out or submit an issue. At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. If you have forked and would like to make a pull request, please make the pull request into `develop` where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. While input is always welcome, not all requests will be granted. That said, we do our best to make Bombadillo a useful piece of software for its users and in general want to help you out. +Bombadillo development is largely handled by Sloum, with help from asdf, jboverf, and some community input. If you would like to get involved, please reach out or submit an [issue](https://tildegit.org/sloum/bombadillo/issues). At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. If you have forked and would like to make a pull request, please make the pull request into `develop` where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. While input is always welcome, not all requests will be granted. That said, we do our best to make Bombadillo a useful piece of software for its users and in general want to help you out. ## License @@ -79,5 +97,5 @@ This project is licensed under the GNU GPL version 3. See the [LICENSE](LICENSE) ## Releases -Starting with v2.0.0 releases into `master` will be version-tagged. Work done toward the next release will be created on work branches named for what they are doing and then merged into `develop` to be combined with other ongoing efforts before a release is merged into `master`. At present there is no specific release schedule. It will depend on the urgency of the work that makes its way into develop and will but up to the project maintainers' judgement when to release from `develop`. +Starting with v2.0.0 releases into `master` will be version-tagged. Work done toward the next release will be created on work branches named for what they are doing and then merged into `develop` to be combined with other ongoing efforts before a release is merged into `master`. At present there is no specific release schedule. It will depend on the urgency of the work that makes its way into develop and will be up to the project maintainers' judgement when to release from `develop`. From 3efde7d061da6f8256cff624c0c8c009dc8ea211 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Mon, 28 Oct 2019 22:14:11 -0700 Subject: [PATCH 090/145] Fixes a glitch that was preventing redirects from getting shown in lynxmode --- http/lynx_mode.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/http/lynx_mode.go b/http/lynx_mode.go index d329d1d..3cc89ca 100644 --- a/http/lynx_mode.go +++ b/http/lynx_mode.go @@ -38,9 +38,16 @@ func IsTextFile(url string) bool { for _, header := range headers { if strings.Contains(header, "content-type:") && strings.Contains(header, "text") { return true + } else if strings.Contains(header, "content-type:") { + return false } } - return false + + // If we made it here, there is no content-type header. + // So in the event of the unknown, lets render to the + // screen. This will allow redirects to get rendered + // as well. + return true } func parseLinks(c string) page { From ab6037d39d6f163b28cf024a5aa927cc0f4dccc5 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 29 Oct 2019 21:19:14 +1100 Subject: [PATCH 091/145] Initial review --- README.md | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index bea3519..2c0ca0e 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,16 @@ # Bombadillo -Bombadillo is a non-web client for the terminal, and functions as a pager/terminal UI. Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Currently, Bombadillo supports the following protocols as first class citizens: +Bombadillo is a non-web client for the terminal, and functions as a pager/terminal UI. + +Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Currently, Bombadillo supports the following protocols as first class citizens: * gopher * gemini * finger -* local (a user's filesystem) +* local (a user's file system) Support for the following protocols is also available via integration with 3rd party applications: * telnet - * By opening links in a subprocess w/ a telnet application + * Links are opened in a telnet application run as a subprocess * http/https * Web support is opt-in (turned off by default) * Links can be opened in a user's default web browser when in a graphical environment @@ -25,22 +27,29 @@ You will need to have [Go](https://golang.org/) version >= 1.11. ### Building, Installing, Uninstalling -Bombadillo installation uses `make`. It is also possible to just use the go compiler directly (`go install`), but this is not the recommended approach. +Bombadillo installation uses `make`. It is also possible to use Go to build and install (i.e `go build`, `go install`), but this is not the recommended approach. -By default running `make` from the source code directory will build Bombadillo in the local directory. This is fine for testing or trying things out. But for usage systemwide and easy access to documentation, you will likely want to install. +Running `make` from the source code directory will build Bombadillo in the local directory. This is fine for testing or trying things out. For usage system-wide, and easy access to documentation, follow the installation instructions below. #### Basic Installation -Most users will want to isntall via the following: +Most users will want to install using the following commands: ``` git clone https://tildegit.org/sloum/bombadillo.git cd bombadillo sudo make install ``` -Note: the usage of sudo here will be system dependent. Most systems will require it for installation to `/usr/local/bin`. +*Note: the usage of `sudo` here will be system dependent. Most systems will require it for installation to `/usr/local/bin`.* -You can then run `bombadillo` or familiarize yourself with the application by running `man bombadillo`. +You can then start Bombadillo by running the command: +``` +bombadillo +``` +To familiarize yourself with the application, documentation is available by running the command: +``` +man bombadillo +``` #### Custom Installation @@ -71,11 +80,11 @@ If you used a custom `DESTDIR` value during install, you will need to supply it sudo make DESTDIR=/some/directory uninstall ``` -Uninstall will clean up any build files, remove the installed binary, and remove the manpage from the system. If will _not_ remove any directories created as a part of the installation, nor will it remove any Bombadillo user configuration files. +Uninstall will clean up any build files, remove the installed binary, and remove the man page from the system. If will _not_ remove any directories created as a part of the installation, nor will it remove any Bombadillo user configuration files. #### Troubleshooting -If you run `bombadillo` and get `bombadillo: command not found`, try running `make build` from within the cloned repo. Then try: `./bombadillo`. If that works it means that the application is getting built correctly and the issue is likely in your path settings. Any errors during `make install` should be pretty visible, as you will be able to see what command it failed on. +If you run `bombadillo` and get `bombadillo: command not found`, try running `make` from within the cloned repo. Then try: `./bombadillo`. If that works it means that the application is getting built correctly and the issue is likely in your path settings. Any errors during `make install` should be pretty visible, as you will be able to see what command it failed on. ### Downloading @@ -89,7 +98,11 @@ In addition to the man page, users can get information on Bombadillo on the web ## Contributing -Bombadillo development is largely handled by Sloum, with help from asdf, jboverf, and some community input. If you would like to get involved, please reach out or submit an [issue](https://tildegit.org/sloum/bombadillo/issues). At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. If you have forked and would like to make a pull request, please make the pull request into `develop` where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. While input is always welcome, not all requests will be granted. That said, we do our best to make Bombadillo a useful piece of software for its users and in general want to help you out. +Bombadillo development is largely handled by Sloum, with help from asdf, jboverf, and some community input. If you would like to get involved, please reach out or submit an issue. + +At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. + +If you have forked and would like to make a pull request, please make the pull request into develop where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. While input is always welcome, not all requests will be granted. That said, we do our best to make Bombadillo a useful piece of software for its users and in general want to help you out. ## License @@ -97,5 +110,5 @@ This project is licensed under the GNU GPL version 3. See the [LICENSE](LICENSE) ## Releases -Starting with v2.0.0 releases into `master` will be version-tagged. Work done toward the next release will be created on work branches named for what they are doing and then merged into `develop` to be combined with other ongoing efforts before a release is merged into `master`. At present there is no specific release schedule. It will depend on the urgency of the work that makes its way into develop and will be up to the project maintainers' judgement when to release from `develop`. +Starting with version 2.0.0 releases into `master` will be version-tagged. Work done toward the next release will be created on work branches named for what they are doing and then merged into `develop` to be combined with other ongoing efforts before a release is merged into `master`. At present there is no specific release schedule. It will depend on the urgency of the work that makes its way into develop and will be up to the project maintainers' judgement when to release from `develop`. From a9654a6804be3754d94ba7e8ba46001488546620 Mon Sep 17 00:00:00 2001 From: asdf Date: Fri, 1 Nov 2019 13:32:59 +1100 Subject: [PATCH 092/145] Expanded the contributing section --- README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2c0ca0e..a342cb7 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Uninstall will clean up any build files, remove the installed binary, and remove #### Troubleshooting -If you run `bombadillo` and get `bombadillo: command not found`, try running `make` from within the cloned repo. Then try: `./bombadillo`. If that works it means that the application is getting built correctly and the issue is likely in your path settings. Any errors during `make install` should be pretty visible, as you will be able to see what command it failed on. +If you run `bombadillo` and get `bombadillo: command not found`, try running `make` from within the cloned repo. Then try: `./bombadillo`. If that works it means that the application is getting built correctly and the issue is likely in your path settings. Any errors during `make install` should be visible, and you will be able to see what command it failed on. ### Downloading @@ -98,11 +98,19 @@ In addition to the man page, users can get information on Bombadillo on the web ## Contributing -Bombadillo development is largely handled by Sloum, with help from asdf, jboverf, and some community input. If you would like to get involved, please reach out or submit an issue. +Bombadillo development is largely handled by Sloum, with help from asdf, jboverf, and community input. -At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. +There are many ways to contribute to Bombadillo, including a fair few that don't require knowledge of programming: -If you have forked and would like to make a pull request, please make the pull request into develop where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. While input is always welcome, not all requests will be granted. That said, we do our best to make Bombadillo a useful piece of software for its users and in general want to help you out. +- Try out the client and let us know if you have a suggestion for improvement, or if you find a bug. +- Read the documentation and let us know if something isn't well explained, or needs correction. +- Maybe you have a cool logo or some art that you think would look nice. + +If you have something in mind, please reach out or [open an issue](https://tildegit.org/sloum/bombadillo/issues). + +We aim for simplicity and quality, and do our best to make Bombadillo useful to its users. Any proposals for change are reviewed by the maintainers with this in mind, and not every request will be accepted. Furthermore, this software is developed in our spare time for the good of all, and help is provided as best efforts. In general, we want to help! + +The maintainers use the [tildegit](https://tildegit.org) issues system to discuss new features, track bugs, and communicate with users regarding issues and suggestions. Pull requests should typically have an associated issue, and should target the `develop` branch. ## License @@ -111,4 +119,3 @@ This project is licensed under the GNU GPL version 3. See the [LICENSE](LICENSE) ## Releases Starting with version 2.0.0 releases into `master` will be version-tagged. Work done toward the next release will be created on work branches named for what they are doing and then merged into `develop` to be combined with other ongoing efforts before a release is merged into `master`. At present there is no specific release schedule. It will depend on the urgency of the work that makes its way into develop and will be up to the project maintainers' judgement when to release from `develop`. - From 867db2bbe9b2c1d242d8d181101e66ae3d53e519 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Tue, 15 Oct 2019 20:07:54 -0700 Subject: [PATCH 093/145] Updates readme to better fit the 2.0.0 build methodology --- README.md | 68 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 141e1a5..fa551c5 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ # Bombadillo - a non-web client -Bombadillo is a modern [Gopher](https://en.wikipedia.org/wiki/Gopher_(protocol)) client for the terminal, and functions as a pager/terminal UI. Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Bombadillo is under active development. +Bombadillo is a non-web client for the terminal, and functions as a pager/terminal UI. Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Currently, Bombadillo supports the following protocols: +- gopher +- gemini +- finger +- local (a user's filesystem) +- telnet (by opening links in a subprocess w/ a telnet application) +- http/https links can be opened in a user's default web browser as an opt-in behavior ## Getting Started @@ -9,32 +15,44 @@ These instructions will get a copy of the project up and running on your local m ### Prerequisites -If building from source, you will need to have [Go](https://golang.org/) version >= 1.11. +If building from source, you will need to have [Go](https://golang.org/) version >= 1.12. -#### Optional +### Building, Installing, Uninstalling -[Lynx](https://lynx.invisible-island.net/), the text based web browser, can be used as a parsing engine for http/https. This is a totally optional item and Lynx is in no way required in order to compile or run Bombadillo. Having it available on the system can help create a richer experience by allowing users to navigate directly to web content in Bombadillo. Many users may wish to avoid this entirely, and the default configuration does not have this behavior turned on. To turn it on from within Bombadillo enter the command `set lynxmode true`. +Bombadillo installation uses `make`. It is possible to just use the go compiler directly (`go install`) if you do not wish to have a man page installed and do not want a program to manage uninstalling and cleaning up. -### Installing +By default Bombadillo will try to install to `$GOBIN`. If it is not set it will try `$GOPATH/bin` (if `$GOPATH` is set), otherwise `~/go/bin`. -Assuming you have all prerequisites installed, Bombadillo can be installed on your system using the following commands: +#### Basic Installation + +Once you have `go` installed you can build a few different ways. Most users will want the following: ``` git clone https://tildegit.org/sloum/bombadillo.git cd bombadillo -sudo make install +make install ``` -Once this is done, you should be able to start Bombadillo using the following command: +Once that is done you should be able to run `bombadillo` (assuming that one of the default install locations exists and is on your path) or view the manual with `man bombadillo`. + +#### Custom Installation + +There are a number of default configuration options in the file `defaults.go`. These can all be set prior to building in order to have these defaults apply to all users of Bombadillo on a given system. That said, the basic configuration already present should be suitable for most users (and all settings but one can be changed from within a Bombadillo session). + +The installation location can be overridden at compile time, which can be very useful for administrators wanting to set up Bombadillo on a multi-user machine. If you wanted to install to, for example, `/usr/local/bin` you would do the following: ``` -bombadillo -``` +git clone https://tildegit.org/sloum/bombadillo.git +cd bombadillo +make install BUILD_PATH=/usr/local/bin +``` -#### Other installation options +#### Uninstall -If you only want to install Bombadillo for your own user account, you could try the following in the cloned repository: +If you used the makefile to install Bombadillo then uninstalling is very simple. From the Bombadillo source folder run: +``` +make uninstall ``` make PREFIX=~ install ``` @@ -45,19 +63,7 @@ The `PREFIX` option can be used to install Bombadillo to any location different #### Troubleshooting -If you run `bombadillo` and get `bombadillo: command not found`, try running `make` from within the cloned repository. Next, try: `./bombadillo`. If this works, it means that the installation was not completed to an area in your `PATH`. - -Please feel free to [open an issue](https://tildegit.org/sloum/bombadillo/issues) if you experience any other issues with the installation. - -### Uninstalling - -To uninstall Bombadillo, simply run the following command from the cloned repository: - -``` -sudo make uninstall -``` - -Please note that directories created during the installation will not be removed. +If you run `bombadillo` and get `bombadillo: command not found`, try running `make build` from within the cloned repo. Then try: `./bombadillo`. If that works it means that Go does not install to your path, or the custom path you selected is not on your path. Try the custom install from above to a location you know to be on your path. ### Downloading @@ -65,21 +71,17 @@ If you would prefer to download a binary for your system, rather than build from ### Documentation -Bombadillo has documentation available in four places currently. The first is the [Bombadillo homepage](https://rawtext.club/~sloum/bombadillo.html#docs), which has lots of information about the program, links to places around Gopher, and documentation of the commands and configuration options. +Bombadillo's primary documentation can be found in the man entry that installs with Bombadillo. To access it run `man bombadillo` after first installing Bombadillo. If for some reason that does not work, the document can be accessed directly from the source folder with `man ./bombadillo.1`. -Secondly, and possibly more importantly, documentation is available via Gopher from within Bombadillo. When a user launches Bombadillo for the first time, their `homeurl` is set to the help file. As such they will have access to all of the key bindings, commands, and configuration from the first run. A user can also type `:?` or `:help` at any time to return to the documentation. Remember that Bombadillo uses vim-like key bindings, so scroll with `j` and `k` to view the docs file. - -Thirdly, this repo contains a file `bombadillo-info`. This is a duplicate of the help file that is hosted over gopher mentioned above. Per user request it has been added to the repo so that pull requests can be created with updates to the documentation. - -Lastly, but perhaps most importantly, a manpage is now included in the repo as `bombadillo.1`. Current efforts are underway to automate the install of both bombadillo and this manpgage. +In addition to the man page, users can get information on Bombadillo on the web @ [http://bombadillo.colorfield.space](http://bombadillo.colorfield.space). Running the command `help` inside Bombadillo will navigate a user to the gopher server hosted at [bombadillo.colorfield.space](gopher://bombadillo.colorfield.space), specifically the user guide. ## Contributing -Bombadillo development is largely handled by Sloum, with help from jboverf, asdf, and some community input. If you would like to get involved, please reach out or submit an issue. At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. If you have forked and would like to make a pull request, please make the pull request into `develop` where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. +Bombadillo development is largely handled by Sloum, with help from asdf, jboverf, and some community input. If you would like to get involved, please reach out or submit an issue. At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. If you have forked and would like to make a pull request, please make the pull request into `develop` where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. While input is always welcome, not all requests will be granted. That said, we do our best to make Bombadillo a useful piece of software for its users and in general want to help you out. ## License -This project is licensed under the GNU GPL version 3- see the [LICENSE](LICENSE) file for details. +This project is licensed under the GNU GPL version 3. See the [LICENSE](LICENSE) file for details. ## Releases From 61907aed1e354999ec5cbdd79e7c03eb5b4ad612 Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Mon, 28 Oct 2019 11:48:16 -0700 Subject: [PATCH 094/145] Updates readme to be more current with the develop branch --- README.md | 62 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index fa551c5..f53d869 100644 --- a/README.md +++ b/README.md @@ -1,58 +1,74 @@ # Bombadillo - a non-web client -Bombadillo is a non-web client for the terminal, and functions as a pager/terminal UI. Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Currently, Bombadillo supports the following protocols: -- gopher -- gemini -- finger -- local (a user's filesystem) -- telnet (by opening links in a subprocess w/ a telnet application) -- http/https links can be opened in a user's default web browser as an opt-in behavior +Bombadillo is a non-web client for the terminal, and functions as a pager/terminal UI. Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Currently, Bombadillo supports the following protocols as first class citizens: +* gopher +* gemini +* finger +* local (a user's filesystem) + +Support for the following protocols is also available via integration with 3rd party applications: +* telnet + * By opening links in a subprocess w/ a telnet application +* http/https + * Web support is opt-in (turned off by default) + * Links can be opened in a user's default web browser when in a graphical environment + * Web pages can be rendered directly in Bombadillo if [Lynx](https://lynx.invisible-island.net/) is installed on the system to handle the document parsing. ## Getting Started -These instructions will get a copy of the project up and running on your local machine. +These instructions will get a copy of the project up and running on your local machine. The following only applies if you are building from source (rather than using a precompiled binary). ### Prerequisites -If building from source, you will need to have [Go](https://golang.org/) version >= 1.12. +You will need to have [Go](https://golang.org/) version >= 1.11. ### Building, Installing, Uninstalling -Bombadillo installation uses `make`. It is possible to just use the go compiler directly (`go install`) if you do not wish to have a man page installed and do not want a program to manage uninstalling and cleaning up. +Bombadillo installation uses `make`. It is also possible to just use the go compiler directly (`go install`), but this is not the recommended approach. -By default Bombadillo will try to install to `$GOBIN`. If it is not set it will try `$GOPATH/bin` (if `$GOPATH` is set), otherwise `~/go/bin`. +By default running `make` from the source code directory will build Bombadillo in the local directory. This is fine for testing or trying things out. But for usage systemwide and easy access to documentation, you will likely want to install. #### Basic Installation -Once you have `go` installed you can build a few different ways. Most users will want the following: +Most users will want to isntall via the following: ``` git clone https://tildegit.org/sloum/bombadillo.git cd bombadillo -make install +sudo make install ``` +Note: the usage of sudo here will be system dependent. Most systems will require it for installation to `/usr/local/bin`. -Once that is done you should be able to run `bombadillo` (assuming that one of the default install locations exists and is on your path) or view the manual with `man bombadillo`. +You can then run `bombadillo` or familiarize yourself with the application by running `man bombadillo`. #### Custom Installation There are a number of default configuration options in the file `defaults.go`. These can all be set prior to building in order to have these defaults apply to all users of Bombadillo on a given system. That said, the basic configuration already present should be suitable for most users (and all settings but one can be changed from within a Bombadillo session). -The installation location can be overridden at compile time, which can be very useful for administrators wanting to set up Bombadillo on a multi-user machine. If you wanted to install to, for example, `/usr/local/bin` you would do the following: +The installation location can be overridden at compile time, which can be very useful for administrators wanting to set up Bombadillo on a multi-user machine. ``` git clone https://tildegit.org/sloum/bombadillo.git cd bombadillo -make install BUILD_PATH=/usr/local/bin +sudo make DESTDIR=/some/directory install ``` +There are two things to know about when using the above format: +1. The above would install Bombadillo to `/some/directory/usr/local/bin`, _not_ to `/some/directory`. So you will want to make sure your `$PATH` is set accordingly. +2. Using the above will install the man page to `/some/directory/usr/local/share/man`, rather than its usual location. You will want to update your `manpath` accordingly. + #### Uninstall If you used the makefile to install Bombadillo then uninstalling is very simple. From the Bombadillo source folder run: ``` -make uninstall +sudo make uninstall +``` + +If you used a custom `DESTDIR` value during install, you will need to supply it when uninstalling: +``` +sudo make DESTDIR=/some/directory uninstall ``` make PREFIX=~ install ``` @@ -61,23 +77,25 @@ You can then add `~/bin` to your PATH environment variable, and `~/share/man` to The `PREFIX` option can be used to install Bombadillo to any location different to `/usr/local`. +Uninstall will clean up any build files, remove the installed binary, and remove the manpage from the system. If will _not_ remove any directories created as a part of the installation, nor will it remove any Bombadillo user configuration files. + #### Troubleshooting -If you run `bombadillo` and get `bombadillo: command not found`, try running `make build` from within the cloned repo. Then try: `./bombadillo`. If that works it means that Go does not install to your path, or the custom path you selected is not on your path. Try the custom install from above to a location you know to be on your path. +If you run `bombadillo` and get `bombadillo: command not found`, try running `make build` from within the cloned repo. Then try: `./bombadillo`. If that works it means that the application is getting built correctly and the issue is likely in your path settings. Any errors during `make install` should be pretty visible, as you will be able to see what command it failed on. ### Downloading -If you would prefer to download a binary for your system, rather than build from source, please visit the [Bombadillo downloads](https://rawtext.club/~sloum/bombadillo.html#downloads) page. Don't see your OS/architecture? Bombadillo can be built for use with any POSIX compliant system that is supported as a target for the Go compiler (Linux, BSD, OS X, Plan 9). No testing has been done for Windows. The program will build, but will likely not work properly outside of the Linux subsystem. If you are a Windows user and would like to do some testing or get involved in development please reach out or [open an issue](https://tildegit.org/sloum/bombadillo/issues). +If you would prefer to download a binary for your system, rather than build from source, please visit the [Bombadillo releases](http://bombadillo.colorfield.space/releases) page. Don't see your OS/architecture? Bombadillo can be built for use with any system that is supported as a target for the Go compiler (Linux, BSD, OS X, Plan 9). There is no explicit support for, or testing done for, Windows or Plan 9. The program should build on those systems, but you may encounter unexpected behaviors or incompatibilities. ### Documentation Bombadillo's primary documentation can be found in the man entry that installs with Bombadillo. To access it run `man bombadillo` after first installing Bombadillo. If for some reason that does not work, the document can be accessed directly from the source folder with `man ./bombadillo.1`. -In addition to the man page, users can get information on Bombadillo on the web @ [http://bombadillo.colorfield.space](http://bombadillo.colorfield.space). Running the command `help` inside Bombadillo will navigate a user to the gopher server hosted at [bombadillo.colorfield.space](gopher://bombadillo.colorfield.space), specifically the user guide. +In addition to the man page, users can get information on Bombadillo on the web @ [http://bombadillo.colorfield.space](http://bombadillo.colorfield.space). Running the command `help` inside Bombadillo will navigate a user to the gopher server hosted at [bombadillo.colorfield.space](gopher://bombadillo.colorfield.space); specifically the user guide. ## Contributing -Bombadillo development is largely handled by Sloum, with help from asdf, jboverf, and some community input. If you would like to get involved, please reach out or submit an issue. At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. If you have forked and would like to make a pull request, please make the pull request into `develop` where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. While input is always welcome, not all requests will be granted. That said, we do our best to make Bombadillo a useful piece of software for its users and in general want to help you out. +Bombadillo development is largely handled by Sloum, with help from asdf, jboverf, and some community input. If you would like to get involved, please reach out or submit an [issue](https://tildegit.org/sloum/bombadillo/issues). At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. If you have forked and would like to make a pull request, please make the pull request into `develop` where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. While input is always welcome, not all requests will be granted. That said, we do our best to make Bombadillo a useful piece of software for its users and in general want to help you out. ## License @@ -85,5 +103,5 @@ This project is licensed under the GNU GPL version 3. See the [LICENSE](LICENSE) ## Releases -Starting with v2.0.0 releases into `master` will be version-tagged. Work done toward the next release will be created on work branches named for what they are doing and then merged into `develop` to be combined with other ongoing efforts before a release is merged into `master`. At present there is no specific release schedule. It will depend on the urgency of the work that makes its way into develop and will but up to the project maintainers' judgement when to release from `develop`. +Starting with v2.0.0 releases into `master` will be version-tagged. Work done toward the next release will be created on work branches named for what they are doing and then merged into `develop` to be combined with other ongoing efforts before a release is merged into `master`. At present there is no specific release schedule. It will depend on the urgency of the work that makes its way into develop and will be up to the project maintainers' judgement when to release from `develop`. From 24deae900eb48baf955f8fdfd27cb2877c3ce191 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 29 Oct 2019 21:19:14 +1100 Subject: [PATCH 095/145] Initial review --- README.md | 37 +++++++++++++++++++++++++------------ 1 file changed, 25 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index f53d869..941cf06 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,16 @@ # Bombadillo - a non-web client -Bombadillo is a non-web client for the terminal, and functions as a pager/terminal UI. Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Currently, Bombadillo supports the following protocols as first class citizens: +Bombadillo is a non-web client for the terminal, and functions as a pager/terminal UI. + +Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Currently, Bombadillo supports the following protocols as first class citizens: * gopher * gemini * finger -* local (a user's filesystem) +* local (a user's file system) Support for the following protocols is also available via integration with 3rd party applications: * telnet - * By opening links in a subprocess w/ a telnet application + * Links are opened in a telnet application run as a subprocess * http/https * Web support is opt-in (turned off by default) * Links can be opened in a user's default web browser when in a graphical environment @@ -25,22 +27,29 @@ You will need to have [Go](https://golang.org/) version >= 1.11. ### Building, Installing, Uninstalling -Bombadillo installation uses `make`. It is also possible to just use the go compiler directly (`go install`), but this is not the recommended approach. +Bombadillo installation uses `make`. It is also possible to use Go to build and install (i.e `go build`, `go install`), but this is not the recommended approach. -By default running `make` from the source code directory will build Bombadillo in the local directory. This is fine for testing or trying things out. But for usage systemwide and easy access to documentation, you will likely want to install. +Running `make` from the source code directory will build Bombadillo in the local directory. This is fine for testing or trying things out. For usage system-wide, and easy access to documentation, follow the installation instructions below. #### Basic Installation -Most users will want to isntall via the following: +Most users will want to install using the following commands: ``` git clone https://tildegit.org/sloum/bombadillo.git cd bombadillo sudo make install ``` -Note: the usage of sudo here will be system dependent. Most systems will require it for installation to `/usr/local/bin`. +*Note: the usage of `sudo` here will be system dependent. Most systems will require it for installation to `/usr/local/bin`.* -You can then run `bombadillo` or familiarize yourself with the application by running `man bombadillo`. +You can then start Bombadillo by running the command: +``` +bombadillo +``` +To familiarize yourself with the application, documentation is available by running the command: +``` +man bombadillo +``` #### Custom Installation @@ -77,11 +86,11 @@ You can then add `~/bin` to your PATH environment variable, and `~/share/man` to The `PREFIX` option can be used to install Bombadillo to any location different to `/usr/local`. -Uninstall will clean up any build files, remove the installed binary, and remove the manpage from the system. If will _not_ remove any directories created as a part of the installation, nor will it remove any Bombadillo user configuration files. +Uninstall will clean up any build files, remove the installed binary, and remove the man page from the system. If will _not_ remove any directories created as a part of the installation, nor will it remove any Bombadillo user configuration files. #### Troubleshooting -If you run `bombadillo` and get `bombadillo: command not found`, try running `make build` from within the cloned repo. Then try: `./bombadillo`. If that works it means that the application is getting built correctly and the issue is likely in your path settings. Any errors during `make install` should be pretty visible, as you will be able to see what command it failed on. +If you run `bombadillo` and get `bombadillo: command not found`, try running `make` from within the cloned repo. Then try: `./bombadillo`. If that works it means that the application is getting built correctly and the issue is likely in your path settings. Any errors during `make install` should be pretty visible, as you will be able to see what command it failed on. ### Downloading @@ -95,7 +104,11 @@ In addition to the man page, users can get information on Bombadillo on the web ## Contributing -Bombadillo development is largely handled by Sloum, with help from asdf, jboverf, and some community input. If you would like to get involved, please reach out or submit an [issue](https://tildegit.org/sloum/bombadillo/issues). At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. If you have forked and would like to make a pull request, please make the pull request into `develop` where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. While input is always welcome, not all requests will be granted. That said, we do our best to make Bombadillo a useful piece of software for its users and in general want to help you out. +Bombadillo development is largely handled by Sloum, with help from asdf, jboverf, and some community input. If you would like to get involved, please reach out or submit an issue. + +At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. + +If you have forked and would like to make a pull request, please make the pull request into develop where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. While input is always welcome, not all requests will be granted. That said, we do our best to make Bombadillo a useful piece of software for its users and in general want to help you out. ## License @@ -103,5 +116,5 @@ This project is licensed under the GNU GPL version 3. See the [LICENSE](LICENSE) ## Releases -Starting with v2.0.0 releases into `master` will be version-tagged. Work done toward the next release will be created on work branches named for what they are doing and then merged into `develop` to be combined with other ongoing efforts before a release is merged into `master`. At present there is no specific release schedule. It will depend on the urgency of the work that makes its way into develop and will be up to the project maintainers' judgement when to release from `develop`. +Starting with version 2.0.0 releases into `master` will be version-tagged. Work done toward the next release will be created on work branches named for what they are doing and then merged into `develop` to be combined with other ongoing efforts before a release is merged into `master`. At present there is no specific release schedule. It will depend on the urgency of the work that makes its way into develop and will be up to the project maintainers' judgement when to release from `develop`. From 56ec4962acc73846b02f0ec61501443b21e49b7e Mon Sep 17 00:00:00 2001 From: asdf Date: Fri, 1 Nov 2019 13:32:59 +1100 Subject: [PATCH 096/145] Expanded the contributing section --- README.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 941cf06..dcac34e 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Uninstall will clean up any build files, remove the installed binary, and remove #### Troubleshooting -If you run `bombadillo` and get `bombadillo: command not found`, try running `make` from within the cloned repo. Then try: `./bombadillo`. If that works it means that the application is getting built correctly and the issue is likely in your path settings. Any errors during `make install` should be pretty visible, as you will be able to see what command it failed on. +If you run `bombadillo` and get `bombadillo: command not found`, try running `make` from within the cloned repo. Then try: `./bombadillo`. If that works it means that the application is getting built correctly and the issue is likely in your path settings. Any errors during `make install` should be visible, and you will be able to see what command it failed on. ### Downloading @@ -104,11 +104,19 @@ In addition to the man page, users can get information on Bombadillo on the web ## Contributing -Bombadillo development is largely handled by Sloum, with help from asdf, jboverf, and some community input. If you would like to get involved, please reach out or submit an issue. +Bombadillo development is largely handled by Sloum, with help from asdf, jboverf, and community input. -At present the developers use the tildegit issues system to discuss new features, track bugs, and communicate with users about hopes and/or issues for/with the software. +There are many ways to contribute to Bombadillo, including a fair few that don't require knowledge of programming: -If you have forked and would like to make a pull request, please make the pull request into develop where it will be reviewed by one of the maintainers. That said, a heads up or comment/issue somewhere is advised. While input is always welcome, not all requests will be granted. That said, we do our best to make Bombadillo a useful piece of software for its users and in general want to help you out. +- Try out the client and let us know if you have a suggestion for improvement, or if you find a bug. +- Read the documentation and let us know if something isn't well explained, or needs correction. +- Maybe you have a cool logo or some art that you think would look nice. + +If you have something in mind, please reach out or [open an issue](https://tildegit.org/sloum/bombadillo/issues). + +We aim for simplicity and quality, and do our best to make Bombadillo useful to its users. Any proposals for change are reviewed by the maintainers with this in mind, and not every request will be accepted. Furthermore, this software is developed in our spare time for the good of all, and help is provided as best efforts. In general, we want to help! + +The maintainers use the [tildegit](https://tildegit.org) issues system to discuss new features, track bugs, and communicate with users regarding issues and suggestions. Pull requests should typically have an associated issue, and should target the `develop` branch. ## License @@ -117,4 +125,3 @@ This project is licensed under the GNU GPL version 3. See the [LICENSE](LICENSE) ## Releases Starting with version 2.0.0 releases into `master` will be version-tagged. Work done toward the next release will be created on work branches named for what they are doing and then merged into `develop` to be combined with other ongoing efforts before a release is merged into `master`. At present there is no specific release schedule. It will depend on the urgency of the work that makes its way into develop and will be up to the project maintainers' judgement when to release from `develop`. - From 743d1cec4469df84a8942932dbe9991fbb8f5a7b Mon Sep 17 00:00:00 2001 From: asdf Date: Sat, 2 Nov 2019 14:07:59 +1100 Subject: [PATCH 097/145] Further changes from review feedback. --- README.md | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index dcac34e..e71eaa0 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,10 @@ # Bombadillo - a non-web client -Bombadillo is a non-web client for the terminal, and functions as a pager/terminal UI. +Bombadillo is a non-web client for the terminal. -Bombadillo features vim-like keybindings, configurable settings, and a robust command selection. Currently, Bombadillo supports the following protocols as first class citizens: +Bombadillo features a full terminal user interface, vim-like keybindings, document pager, configurable settings, and a robust command selection. + +Currently, Bombadillo supports the following protocols as first class citizens: * gopher * gemini * finger @@ -10,13 +12,12 @@ Bombadillo features vim-like keybindings, configurable settings, and a robust co Support for the following protocols is also available via integration with 3rd party applications: * telnet - * Links are opened in a telnet application run as a subprocess + * Links are opened in a telnet application run as a subprocess. * http/https - * Web support is opt-in (turned off by default) - * Links can be opened in a user's default web browser when in a graphical environment + * Web support is opt-in (turned off by default). + * Links can be opened in a user's default web browser when in a graphical environment. * Web pages can be rendered directly in Bombadillo if [Lynx](https://lynx.invisible-island.net/) is installed on the system to handle the document parsing. - ## Getting Started These instructions will get a copy of the project up and running on your local machine. The following only applies if you are building from source (rather than using a precompiled binary). @@ -35,7 +36,7 @@ Running `make` from the source code directory will build Bombadillo in the local Most users will want to install using the following commands: -``` +```shell git clone https://tildegit.org/sloum/bombadillo.git cd bombadillo sudo make install @@ -43,21 +44,28 @@ sudo make install *Note: the usage of `sudo` here will be system dependent. Most systems will require it for installation to `/usr/local/bin`.* You can then start Bombadillo by running the command: -``` +```shell bombadillo ``` To familiarize yourself with the application, documentation is available by running the command: -``` +```shell man bombadillo ``` #### Custom Installation +##### Configuration Options +There are a number of default configuration options in the file `defaults.go`, allowing customisation of the default settings for users of Bombadillo. -There are a number of default configuration options in the file `defaults.go`. These can all be set prior to building in order to have these defaults apply to all users of Bombadillo on a given system. That said, the basic configuration already present should be suitable for most users (and all settings but one can be changed from within a Bombadillo session). +To use this feature, amend the `defaults.go` file as appropriate, then follow the standard install instructions. +Full documentation for these options is contained within the `defaults.go` file. + +An administrator might use this to feature to set a default for all users of a system. Typically though, these options should not need changing, and a user may change most of these settings themselves once they start Bombadillo. The one option that can only be configured in `defaults.go` is `configlocation` which controls where `.bombadillo.ini` is stored. + +##### Override Install Location The installation location can be overridden at compile time, which can be very useful for administrators wanting to set up Bombadillo on a multi-user machine. -``` +```shell git clone https://tildegit.org/sloum/bombadillo.git cd bombadillo sudo make DESTDIR=/some/directory install @@ -71,12 +79,12 @@ There are two things to know about when using the above format: If you used the makefile to install Bombadillo then uninstalling is very simple. From the Bombadillo source folder run: -``` +```shell sudo make uninstall ``` If you used a custom `DESTDIR` value during install, you will need to supply it when uninstalling: -``` +```shell sudo make DESTDIR=/some/directory uninstall ``` make PREFIX=~ install From 3b74654c3d7c65dec0360d5137873daa163df374 Mon Sep 17 00:00:00 2001 From: asdf Date: Sun, 3 Nov 2019 12:39:56 +1100 Subject: [PATCH 098/145] Add image to README.md --- README.md | 2 ++ bombadillo-screenshot.png | Bin 0 -> 52878 bytes 2 files changed, 2 insertions(+) create mode 100644 bombadillo-screenshot.png diff --git a/README.md b/README.md index e71eaa0..854b608 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ Bombadillo is a non-web client for the terminal. +![a screenshot of the bombadillo client](bombadillo-screenshot.png) + Bombadillo features a full terminal user interface, vim-like keybindings, document pager, configurable settings, and a robust command selection. Currently, Bombadillo supports the following protocols as first class citizens: diff --git a/bombadillo-screenshot.png b/bombadillo-screenshot.png new file mode 100644 index 0000000000000000000000000000000000000000..bdbe373fbd15cbf5ab1864947cf16ec4804f5a8d GIT binary patch literal 52878 zcma%hQ?RJ9(&e^o+qP}nJlnQy+qP}n_CDLTZO-}covE6ashWrHA*)kKSCY=xy;dR= z9zm>q==p>8qP`vZUpv@cBU5ACIrqN z_9g@-?iQv10PY(t*=DIaZHYC%Mku@>?f#f>S6aM5>|Z}@RH6~Z<<#dcNkmoY87?yE zHb5MXr@!B?F25snH$`simef5cb9GxzaY1&OzaP)ftZ!dGzJ0EHWxaaeH!kdlr`kTU z-m?03$&b&hFnVpfe)%VJmye&Ty1M$i!!Mlkr!jLLK8qR8-=|L3PWdQ(dhmIET|e&~ z3BUH-dHfDOaG#uSalf-Ef2-0ake?6|Y z+U)!w^ze6W@4MFC@83l}_)uok=D;W689%!5uEJLRxbumg#;Bowv{!n)h_$|gKTp@T zyEc1HFK@)?L@L|oWWUh{UvcrXgPD5pslRH!7<=n(-A>&O(av0vc60kFMW!DED2gPd*fci9yv4%H^8Z?Kt1(FS7Mm zqN8jDmW=x;N0mcwH|M}kiQa|zUvF1_r##8z0~(WTtt7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=)6T&`Yxvo~N4b~X!eDQv)p@GE| zC(J9ItxU;BN8C|FF(1Rfdq`_fPMbFqBK`(X6u+0ZeLV@> Date: Sat, 2 Nov 2019 19:45:55 -0700 Subject: [PATCH 099/145] Removes ascii escape codes from remote content --- page.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/page.go b/page.go index ee8b68c..edc3006 100644 --- a/page.go +++ b/page.go @@ -45,8 +45,15 @@ func (p *Page) ScrollPositionRange(termHeight int) (int, int) { func (p *Page) WrapContent(width int) { counter := 0 var content strings.Builder + escape := false content.Grow(len(p.RawContent)) for _, ch := range []rune(p.RawContent) { + if escape { + if (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') { + escape = false + } + continue + } if ch == '\n' { content.WriteRune(ch) counter = 0 @@ -58,9 +65,12 @@ func (p *Page) WrapContent(width int) { content.WriteRune('\n') counter = 0 } - } else if ch == '\r' || ch == '\v' || ch == '\b' || ch == '\f' || ch == 27 { + } else if ch == '\r' || ch == '\v' || ch == '\b' || ch == '\f' { // Get rid of control characters we dont want continue + } else if ch == 27 { + escape = true + continue } else { if counter < width { content.WriteRune(ch) From b998fa9e7cf6378a5e45a58fbad37ec505159681 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 2 Nov 2019 20:18:21 -0700 Subject: [PATCH 100/145] Adds suffixing for file writes --- client.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/client.go b/client.go index 452dad1..599bade 100644 --- a/client.go +++ b/client.go @@ -529,6 +529,14 @@ func (c *client) saveFile(u Url, name string) { } savePath := filepath.Join(c.Options["savelocation"], name) + suffix := 1 + _, fileErr := os.Stat(savePath) + for fileErr == nil { + fn := fmt.Sprintf("%s.%d", name, suffix) + savePath = filepath.Join(c.Options["savelocation"], fn) + _, fileErr = os.Stat(savePath) + suffix++ + } err = ioutil.WriteFile(savePath, file, 0644) if err != nil { c.SetMessage("Error writing file: "+err.Error(), true) @@ -546,6 +554,14 @@ func (c *client) saveFileFromData(d, name string) { c.DrawMessage() savePath := filepath.Join(c.Options["savelocation"], name) + suffix := 1 + _, fileErr := os.Stat(savePath) + for fileErr == nil { + fn := fmt.Sprintf("%s.%d", name, suffix) + savePath = filepath.Join(c.Options["savelocation"], fn) + _, fileErr = os.Stat(savePath) + suffix++ + } err := ioutil.WriteFile(savePath, data, 0644) if err != nil { c.SetMessage("Error writing file: "+err.Error(), true) From 3a96792cf3bb54127630df8e3814239a8209bc02 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 2 Nov 2019 22:14:10 -0700 Subject: [PATCH 101/145] Moved repeated logic into function --- client.go | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/client.go b/client.go index 599bade..b2d6e80 100644 --- a/client.go +++ b/client.go @@ -528,18 +528,12 @@ func (c *client) saveFile(u Url, name string) { return } - savePath := filepath.Join(c.Options["savelocation"], name) - suffix := 1 - _, fileErr := os.Stat(savePath) - for fileErr == nil { - fn := fmt.Sprintf("%s.%d", name, suffix) - savePath = filepath.Join(c.Options["savelocation"], fn) - _, fileErr = os.Stat(savePath) - suffix++ - } + // We are ignoring the error here since WriteFile will + // generate the same error, and will handle the messaging + savePath, _ := findAvailableFileName(c.Options["savelocation"], name) err = ioutil.WriteFile(savePath, file, 0644) if err != nil { - c.SetMessage("Error writing file: "+err.Error(), true) + c.SetMessage("Error writing file: "+err.Error()+savePath, true) c.DrawMessage() return } @@ -553,18 +547,12 @@ func (c *client) saveFileFromData(d, name string) { c.SetMessage(fmt.Sprintf("Saving %s ...", name), false) c.DrawMessage() - savePath := filepath.Join(c.Options["savelocation"], name) - suffix := 1 - _, fileErr := os.Stat(savePath) - for fileErr == nil { - fn := fmt.Sprintf("%s.%d", name, suffix) - savePath = filepath.Join(c.Options["savelocation"], fn) - _, fileErr = os.Stat(savePath) - suffix++ - } + // We are ignoring the error here since WriteFile will + // generate the same error, and will handle the messaging + savePath, _ := findAvailableFileName(c.Options["savelocation"], name) err := ioutil.WriteFile(savePath, data, 0644) if err != nil { - c.SetMessage("Error writing file: "+err.Error(), true) + c.SetMessage("Error writing file: "+err.Error()+savePath, true) c.DrawMessage() return } @@ -1081,3 +1069,21 @@ func MakeClient(name string) *client { c := client{0, 0, defaultOptions, "", false, MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar(), gemini.MakeTofuDigest()} return &c } + +func findAvailableFileName(fpath, fname string) (string, error) { + savePath := filepath.Join(fpath, fname) + _, fileErr := os.Stat(savePath) + + for suffix := 1; fileErr == nil; suffix++ { + fn := fmt.Sprintf("%s.%d", fname, suffix) + savePath = filepath.Join(fpath, fn) + _, fileErr = os.Stat(savePath) + + if !os.IsNotExist(fileErr) && fileErr != nil { + return savePath, fileErr + } + } + + return savePath, nil +} + From eef9ba6e813ac7deb5e03eb86c83e9c7f815e7c0 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 2 Nov 2019 22:15:31 -0700 Subject: [PATCH 102/145] Removes debugging code --- client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index b2d6e80..df55ad2 100644 --- a/client.go +++ b/client.go @@ -533,7 +533,7 @@ func (c *client) saveFile(u Url, name string) { savePath, _ := findAvailableFileName(c.Options["savelocation"], name) err = ioutil.WriteFile(savePath, file, 0644) if err != nil { - c.SetMessage("Error writing file: "+err.Error()+savePath, true) + c.SetMessage("Error writing file: "+err.Error(), true) c.DrawMessage() return } @@ -552,7 +552,7 @@ func (c *client) saveFileFromData(d, name string) { savePath, _ := findAvailableFileName(c.Options["savelocation"], name) err := ioutil.WriteFile(savePath, data, 0644) if err != nil { - c.SetMessage("Error writing file: "+err.Error()+savePath, true) + c.SetMessage("Error writing file: "+err.Error(), true) c.DrawMessage() return } From aaa37cbb9f0601383512c12d7588790b5d7b4511 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 3 Nov 2019 16:42:16 -0800 Subject: [PATCH 103/145] Removes usage of library methods that are only available in 1.12 --- client.go | 6 +++--- url.go | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/client.go b/client.go index 452dad1..3f99ecb 100644 --- a/client.go +++ b/client.go @@ -777,7 +777,7 @@ func (c *client) displayConfigValue(setting string) { func (c *client) SetMessage(msg string, isError bool) { c.MessageIsErr = isError - c.Message = strings.ReplaceAll(msg, "\t", "%09") + c.Message = strings.Replace(msg, "\t", "%09", -1) } func (c *client) DrawMessage() { @@ -845,7 +845,7 @@ func (c *client) goToLink(l string) { func (c *client) SetHeaderUrl() { if c.PageState.Length > 0 { u := c.PageState.History[c.PageState.Position].Location.Full - c.TopBar.url = strings.ReplaceAll(u, "\t", "%09") + c.TopBar.url = strings.Replace(u, "\t", "%09", -1) } else { c.TopBar.url = "" } @@ -857,7 +857,7 @@ func (c *client) Visit(url string) { c.SetMessage("Loading...", false) c.DrawMessage() - url = strings.ReplaceAll(url, "%09", "\t") + url = strings.Replace(url, "%09", "\t", -1) u, err := MakeUrl(url) if err != nil { c.SetMessage(err.Error(), true) diff --git a/url.go b/url.go index b77f0c6..b1b921e 100644 --- a/url.go +++ b/url.go @@ -2,7 +2,7 @@ package main import ( "fmt" - "os" + "os/user" "path/filepath" "regexp" "strings" @@ -50,9 +50,12 @@ func MakeUrl(u string) (Url, error) { if local && len(u) > 8 { u = u[8:] } - home, err := os.UserHomeDir() + var home string + userinfo, err := user.Current() if err != nil { home = "" + } else { + home = userinfo.HomeDir } u = strings.Replace(u, "~", home, 1) res, err := filepath.Abs(u) From 23a78b45b388f1c17b314c5ab71905fbfdaeb414 Mon Sep 17 00:00:00 2001 From: asdf Date: Mon, 4 Nov 2019 14:05:59 +1100 Subject: [PATCH 104/145] Amended Makefile to include additional variables as per #66 --- Makefile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 5786f8b..8c88dc3 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,17 @@ BINARY := bombadillo PREFIX := /usr/local -MANPREFIX := ${PREFIX}/share/man +EXEC_PREFIX := ${PREFIX} +BINDIR := ${EXEC_PREFIX}/bin +DATAROOTDIR := ${PREFIX}/share +MANDIR := ${DATAROOTDIR}/share/man +MAN1DIR := ${MANDIR}/man1 # Use a dateformat rather than -I flag since OSX # does not support -I. It also doesn't support # %:z - so settle for %z. BUILD_TIME := ${shell date "+%Y-%m-%dT%H:%M%z"} -# If VERSION is empty or not deffined use the contents of the VERSION file +# If VERSION is empty or not defined use the contents of the VERSION file VERSION := ${shell git describe --tags 2> /dev/null} ifndef VERSION VERSION := ${shell cat ./VERSION} @@ -25,13 +29,13 @@ install: install-bin install-man clean .PHONY: install-man install-man: bombadillo.1 gzip -k ./bombadillo.1 - install -d ${DESTDIR}${MANPREFIX}/man1 - install -m 0644 ./bombadillo.1.gz ${DESTDIR}${MANPREFIX}/man1 + install -d ${DESTDIR}${MAN1DIR} + install -m 0644 ./bombadillo.1.gz ${DESTDIR}${MAN1DIR} .PHONY: install-bin install-bin: build - install -d ${DESTDIR}${PREFIX}/bin - install -m 0755 ./${BINARY} ${DESTDIR}${PREFIX}/bin/${BINARY} + install -d ${DESTDIR}${BINDIR} + install -m 0755 ./${BINARY} ${DESTDIR}${BINDIR} .PHONY: clean clean: @@ -40,6 +44,6 @@ clean: .PHONY: uninstall uninstall: clean - rm -f ${DESTDIR}${MANPREFIX}/man1/bombadillo.1.gz - rm -f ${DESTDIR}${PREFIX}/bin/${BINARY} + rm -f ${DESTDIR}${MAN1DIR}/bombadillo.1.gz + rm -f ${DESTDIR}${BINDIR}/${BINARY} From 8e9f2f614f6cdcd054fe7cf2e1c32e6a22f5de98 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 5 Nov 2019 13:32:08 +1100 Subject: [PATCH 105/145] Amended README, corrected error in Makefile --- Makefile | 3 +-- README.md | 21 +++++++++------------ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 8c88dc3..db881aa 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ PREFIX := /usr/local EXEC_PREFIX := ${PREFIX} BINDIR := ${EXEC_PREFIX}/bin DATAROOTDIR := ${PREFIX}/share -MANDIR := ${DATAROOTDIR}/share/man +MANDIR := ${DATAROOTDIR}/man MAN1DIR := ${MANDIR}/man1 # Use a dateformat rather than -I flag since OSX @@ -46,4 +46,3 @@ clean: uninstall: clean rm -f ${DESTDIR}${MAN1DIR}/bombadillo.1.gz rm -f ${DESTDIR}${BINDIR}/${BINARY} - diff --git a/README.md b/README.md index 854b608..72cd746 100644 --- a/README.md +++ b/README.md @@ -70,31 +70,28 @@ The installation location can be overridden at compile time, which can be very u ```shell git clone https://tildegit.org/sloum/bombadillo.git cd bombadillo -sudo make DESTDIR=/some/directory install +sudo make install PREFIX=/some/directory ``` There are two things to know about when using the above format: -1. The above would install Bombadillo to `/some/directory/usr/local/bin`, _not_ to `/some/directory`. So you will want to make sure your `$PATH` is set accordingly. -2. Using the above will install the man page to `/some/directory/usr/local/share/man`, rather than its usual location. You will want to update your `manpath` accordingly. +1. The above would install Bombadillo to `/some/directory/bin`, _not_ to `/some/directory`. So you will want to make sure your `$PATH` is set accordingly. +2. Using the above will install the man page to `/some/directory/share/man/man1`, rather than its usual location. You will want to update your `manpath` accordingly. + +There are other overrides available - please review the [Makefile](Makefile) for more information. #### Uninstall -If you used the makefile to install Bombadillo then uninstalling is very simple. From the Bombadillo source folder run: +If you used the Makefile to install Bombadillo then uninstalling is very simple. From the Bombadillo source folder run: ```shell sudo make uninstall ``` -If you used a custom `DESTDIR` value during install, you will need to supply it when uninstalling: +If you used a custom `PREFIX` value during install, you will need to supply it when uninstalling: + ```shell -sudo make DESTDIR=/some/directory uninstall +sudo make uninstall PREFIX=/some/directory ``` -make PREFIX=~ install -``` - -You can then add `~/bin` to your PATH environment variable, and `~/share/man` to your manpath. - -The `PREFIX` option can be used to install Bombadillo to any location different to `/usr/local`. Uninstall will clean up any build files, remove the installed binary, and remove the man page from the system. If will _not_ remove any directories created as a part of the installation, nor will it remove any Bombadillo user configuration files. From b240d8340e4d1a103108a369f2af56e0fe681e67 Mon Sep 17 00:00:00 2001 From: asdf Date: Thu, 7 Nov 2019 13:22:06 +1100 Subject: [PATCH 106/145] Makefile has GOCMD variable for supporting multiple versions of Go --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index db881aa..ed3e3b6 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,4 @@ +GOCMD := go BINARY := bombadillo PREFIX := /usr/local EXEC_PREFIX := ${PREFIX} @@ -21,7 +22,7 @@ LDFLAGS := -ldflags "-s -X main.version=${VERSION} -X main.build=${BUILD_TIME}" .PHONY: build build: - go build ${LDFLAGS} -o ${BINARY} + ${GOCMD} build ${LDFLAGS} -o ${BINARY} .PHONY: install install: install-bin install-man clean @@ -39,7 +40,7 @@ install-bin: build .PHONY: clean clean: - go clean + ${GOCMD} clean rm -f ./bombadillo.1.gz 2> /dev/null .PHONY: uninstall From a8fc394a3db801f36404ec5f7bdbc606ca8b29bd Mon Sep 17 00:00:00 2001 From: asdf Date: Thu, 7 Nov 2019 21:17:50 +1100 Subject: [PATCH 107/145] Prevent changes in telnet breaking terminal display --- telnet/telnet.go | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/telnet/telnet.go b/telnet/telnet.go index 609f13d..a6bc7b9 100644 --- a/telnet/telnet.go +++ b/telnet/telnet.go @@ -1,19 +1,32 @@ +// Package telnet provides a function that starts a telnet session in a subprocess. package telnet import ( "fmt" "os" "os/exec" + + "tildegit.org/sloum/bombadillo/cui" ) +// StartSession starts a telnet session as a subprocess, connecting to the host +// and port specified. Telnet is run interactively as a subprocess until the +// process ends. It returns any errors from the telnet session. func StartSession(host string, port string) (string, error) { - // Case for telnet links c := exec.Command("telnet", host, port) c.Stdin = os.Stdin c.Stdout = os.Stdout c.Stderr = os.Stderr + // Clear the screen and position the cursor at the top left fmt.Print("\033[2J\033[0;0H") + // Defer reset and reinit of the terminal to prevent any changes from + // telnet carrying over to the client (or beyond...) + defer func() { + cui.Tput("reset") + cui.InitTerm() + }() + err := c.Run() if err != nil { return "", fmt.Errorf("Telnet error response: %s", err.Error()) @@ -21,4 +34,3 @@ func StartSession(host string, port string) (string, error) { return "Telnet session terminated", nil } - From b35ceb14d63ae0c53200aa9f616eb8ea1d900deb Mon Sep 17 00:00:00 2001 From: asdf Date: Thu, 7 Nov 2019 22:29:22 +1100 Subject: [PATCH 108/145] Added developer documentation, testing to Makefile --- Makefile | 4 ++++ README.md | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/Makefile b/Makefile index ed3e3b6..d8d2c33 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ BINDIR := ${EXEC_PREFIX}/bin DATAROOTDIR := ${PREFIX}/share MANDIR := ${DATAROOTDIR}/man MAN1DIR := ${MANDIR}/man1 +test : GOCMD := go1.11.13 # Use a dateformat rather than -I flag since OSX # does not support -I. It also doesn't support @@ -47,3 +48,6 @@ clean: uninstall: clean rm -f ${DESTDIR}${MAN1DIR}/bombadillo.1.gz rm -f ${DESTDIR}${BINDIR}/${BINARY} + +.PHONY: test +test: clean build diff --git a/README.md b/README.md index 72cd746..4738877 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,14 @@ We aim for simplicity and quality, and do our best to make Bombadillo useful to The maintainers use the [tildegit](https://tildegit.org) issues system to discuss new features, track bugs, and communicate with users regarding issues and suggestions. Pull requests should typically have an associated issue, and should target the `develop` branch. +## Development + +Following the standard install instructions should lead you to have nearly everything you need to commence development. The only additions to this are: + +- To be able to submit pull requests, you will need to fork this repository first. +- Bombadillo is tested against Go 1.11. This version can be installed as per the [Go install documentation](https://golang.org/doc/install#extra_versions). Tests for this version are run using 'make test'. +- Linting is performed by `gofmt` and [golangci-lint](https://github.com/golangci/golangci-lint) + ## License This project is licensed under the GNU GPL version 3. See the [LICENSE](LICENSE) file for details. From ba9a016dfd1aa36295e5463c452cacd5e39f0337 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 7 Nov 2019 20:11:25 -0800 Subject: [PATCH 109/145] Removes the WRITE AS command and updates the man page to reflect the change --- bombadillo.1 | 14 +------------- client.go | 14 ++------------ 2 files changed, 3 insertions(+), 25 deletions(-) diff --git a/bombadillo.1 b/bombadillo.1 index b694e3a..39c52d5 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -196,20 +196,8 @@ write [url] Writes data from a given url to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. .TP .B -write [link id]] +write [link id] Writes data from a given link id in the current document to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. -.TP -.B -write . [filename\.\.\.] -Writes the current document to a file. The file is named by the filename argument should should not include a leading \fI/\fP. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. -.TP -.B -write [url] [filename\.\.\.] -Writes data from a given url to a file. The file is named by the filename argument should should not include a leading \fI/\fP. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. -.TP -.B -write [link id] [filename\.\.\.] -Writes data from a given link id in the current document to a file. The file is named by the filename argument should should not include a leading \fI/\fP. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. .SH FILES \fBbombadillo\fP keeps a hidden configuration file in a user's home directory. The file is a simplified ini file titled \fI.bombadillo.ini\fP. It is generated when a user first loads \fBbombadillo\fP and is updated with bookmarks and settings as a user adds them. The file can be directly edited, but it is best to use the SET command to update settings whenever possible. To return to the state of a fresh install, simply remove the file and a new one will be generated with the \fBbombadillo\fP defaults. On some systems an administrator may set the configuration file location to somewhere other than a user's home folder. If you do not see the file where you expect it, contact your system administrator. .SH SETTINGS diff --git a/client.go b/client.go index 9f845a0..eac6331 100644 --- a/client.go +++ b/client.go @@ -369,7 +369,7 @@ func (c *client) doCommand(action string, values []string) { func (c *client) doCommandAs(action string, values []string) { if len(values) < 2 { - c.SetMessage(fmt.Sprintf("Expected 1 argument, received %d", len(values)), true) + c.SetMessage(fmt.Sprintf("Expected 2+ arguments, received %d", len(values)), true) c.DrawMessage() return } @@ -400,17 +400,6 @@ func (c *client) doCommandAs(action string, values []string) { } case "SEARCH": c.search(strings.Join(values, " "), "", "") - case "WRITE", "W": - u, err := MakeUrl(values[0]) - if err != nil { - c.SetMessage(err.Error(), true) - c.DrawMessage() - return - } - fileName := strings.Join(values[1:], "-") - fileName = strings.Trim(fileName, " \t\r\n\a\f\v") - c.saveFile(u, fileName) - case "SET", "S": if _, ok := c.Options[values[0]]; ok { val := strings.Join(values[1:], " ") @@ -438,6 +427,7 @@ func (c *client) doCommandAs(action string, values []string) { return } c.SetMessage(fmt.Sprintf("Unknown command structure"), true) + c.DrawMessage() } func (c *client) doLinkCommandAs(action, target string, values []string) { From ecef63f099d286c470de4441d9c85b6a0877469c Mon Sep 17 00:00:00 2001 From: asdf Date: Fri, 8 Nov 2019 16:20:54 +1100 Subject: [PATCH 110/145] Use word directory instead of folder, correct savepath info --- bombadillo.1 | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bombadillo.1 b/bombadillo.1 index 39c52d5..a5660eb 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -189,17 +189,17 @@ Sets the value for a given configuration setting. \fIs\fP can be used instead of .TP .B write . -Writes the current document to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. +Writes the current document to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the directory set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. .TP .B write [url] -Writes data from a given url to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. +Writes data from a given url to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the directory set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. .TP .B write [link id] -Writes data from a given link id in the current document to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the folder set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. +Writes data from a given link id in the current document to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the directory set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. .SH FILES -\fBbombadillo\fP keeps a hidden configuration file in a user's home directory. The file is a simplified ini file titled \fI.bombadillo.ini\fP. It is generated when a user first loads \fBbombadillo\fP and is updated with bookmarks and settings as a user adds them. The file can be directly edited, but it is best to use the SET command to update settings whenever possible. To return to the state of a fresh install, simply remove the file and a new one will be generated with the \fBbombadillo\fP defaults. On some systems an administrator may set the configuration file location to somewhere other than a user's home folder. If you do not see the file where you expect it, contact your system administrator. +\fBbombadillo\fP keeps a hidden configuration file in a user's home directory. The file is a simplified ini file titled \fI.bombadillo.ini\fP. It is generated when a user first loads \fBbombadillo\fP and is updated with bookmarks and settings as a user adds them. The file can be directly edited, but it is best to use the SET command to update settings whenever possible. To return to the state of a fresh install, simply remove the file and a new one will be generated with the \fBbombadillo\fP defaults. On some systems an administrator may set the configuration file location to somewhere other than a user's home directory. If you do not see the file where you expect it, contact your system administrator. .SH SETTINGS The following is a list of the settings that \fBbombadillo\fP recognizes, as well as a description of their valid values. .TP @@ -218,7 +218,7 @@ Tells the client whether or not to try to follow web (http/https) links. If set .TP .B savelocation -The path to the folder that \fBbombadillo\fP should write files to. This should be a valid filepath for the system and should end in a \fI/\fP. +The path to the directory that \fBbombadillo\fP should write files to. This must be a valid filepath for the system, must be a directory, and must already exist. .TP .B searchengine From 2038c9c4ac15cc42892174189c95f5425db6f328 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 9 Nov 2019 19:27:15 -0800 Subject: [PATCH 111/145] HOTFIX: Removes incorrect draw of error message --- client.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client.go b/client.go index eac6331..80e7b36 100644 --- a/client.go +++ b/client.go @@ -424,10 +424,9 @@ func (c *client) doCommandAs(action string, values []string) { } c.SetMessage(fmt.Sprintf("Unable to set %s, it does not exist", values[0]), true) c.DrawMessage() - return + default: + c.SetMessage(fmt.Sprintf("Unknown command structure"), true) } - c.SetMessage(fmt.Sprintf("Unknown command structure"), true) - c.DrawMessage() } func (c *client) doLinkCommandAs(action, target string, values []string) { From e4f7147e4f40f2d1c144d2df3f2d2c38183d7b5c Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 10 Nov 2019 10:41:12 -0800 Subject: [PATCH 112/145] Ran format on each file --- bookmarks.go | 20 ++++++++---------- client.go | 15 ++++++-------- cmdparse/lexer.go | 4 ++-- config/parser.go | 8 ++++---- cui/cui_test.go | 4 ---- defaults.go | 29 +++++++++++++------------- finger/finger.go | 2 +- footbar.go | 10 +++------ gemini/gemini.go | 52 +++++++++++++++++++++-------------------------- gopher/gopher.go | 9 ++++---- headbar.go | 5 +---- http/lynx_mode.go | 3 +-- local/local.go | 14 ++++++------- page.go | 13 ++++++------ pages.go | 17 +++++++--------- url.go | 18 +++++++--------- 16 files changed, 94 insertions(+), 129 deletions(-) diff --git a/bookmarks.go b/bookmarks.go index 5faf22a..8f8cc0d 100644 --- a/bookmarks.go +++ b/bookmarks.go @@ -12,12 +12,12 @@ import ( //--------------------------------------------------\\ type Bookmarks struct { - IsOpen bool + IsOpen bool IsFocused bool - Position int - Length int - Titles []string - Links []string + Position int + Length int + Titles []string + Links []string } //------------------------------------------------\\ @@ -89,7 +89,7 @@ func (b Bookmarks) Render(termwidth, termheight int) []string { var walll, wallr, floor, ceil, tr, tl, br, bl string if termwidth < 40 { width = termwidth - } + } if b.IsFocused { walll = cui.Shapes["awalll"] wallr = cui.Shapes["awallr"] @@ -115,11 +115,11 @@ func (b Bookmarks) Render(termwidth, termheight int) []string { top := fmt.Sprintf("%s%s%s", tl, strings.Repeat(ceil, contentWidth), tr) out = append(out, top) marks := b.List() - for i := 0; i < termheight - 2; i++ { - if i + b.Position >= len(b.Titles) { + for i := 0; i < termheight-2; i++ { + if i+b.Position >= len(b.Titles) { out = append(out, fmt.Sprintf("%s%-*.*s%s", walll, contentWidth, contentWidth, "", wallr)) } else { - out = append(out, fmt.Sprintf("%s%-*.*s%s", walll, contentWidth, contentWidth, marks[i + b.Position], wallr)) + out = append(out, fmt.Sprintf("%s%-*.*s%s", walll, contentWidth, contentWidth, marks[i+b.Position], wallr)) } } @@ -132,7 +132,6 @@ func (b Bookmarks) Render(termwidth, termheight int) []string { // either here with a scroll up/down or in the client // code for scroll - //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ @@ -140,4 +139,3 @@ func (b Bookmarks) Render(termwidth, termheight int) []string { func MakeBookmarks() Bookmarks { return Bookmarks{false, false, 0, 0, make([]string, 0), make([]string, 0)} } - diff --git a/client.go b/client.go index 80e7b36..952f9f6 100644 --- a/client.go +++ b/client.go @@ -877,8 +877,7 @@ func (c *client) Visit(url string) { } } - -// +++ Begin Protocol Handlers +++ +// +++ Begin Protocol Handlers +++ func (c *client) handleGopher(u Url) { if u.DownloadOnly { @@ -1022,15 +1021,15 @@ func (c *client) handleWeb(u Url) { c.SetMessage("The file is non-text: writing to disk...", false) c.DrawMessage() var fn string - if i := strings.LastIndex(u.Full, "/"); i > 0 && i + 1 < len(u.Full) { - fn = u.Full[i + 1:] + if i := strings.LastIndex(u.Full, "/"); i > 0 && i+1 < len(u.Full) { + fn = u.Full[i+1:] } else { fn = "bombadillo.download" } c.saveFile(u, fn) } - // Open in default web browser if available + // Open in default web browser if available } else { if strings.ToUpper(c.Options["terminalonly"]) == "TRUE" { c.SetMessage("'terminalonly' is set to true and 'lynxmode' is not enabled, cannot open web link", false) @@ -1049,7 +1048,6 @@ func (c *client) handleWeb(u Url) { } } - //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ @@ -1061,12 +1059,12 @@ func MakeClient(name string) *client { func findAvailableFileName(fpath, fname string) (string, error) { savePath := filepath.Join(fpath, fname) - _, fileErr := os.Stat(savePath) + _, fileErr := os.Stat(savePath) for suffix := 1; fileErr == nil; suffix++ { fn := fmt.Sprintf("%s.%d", fname, suffix) savePath = filepath.Join(fpath, fn) - _, fileErr = os.Stat(savePath) + _, fileErr = os.Stat(savePath) if !os.IsNotExist(fileErr) && fileErr != nil { return savePath, fileErr @@ -1075,4 +1073,3 @@ func findAvailableFileName(fpath, fname string) (string, error) { return savePath, nil } - diff --git a/cmdparse/lexer.go b/cmdparse/lexer.go index f61bf4c..8b882c3 100644 --- a/cmdparse/lexer.go +++ b/cmdparse/lexer.go @@ -68,10 +68,10 @@ func (s *scanner) scanText() Token { capInput := strings.ToUpper(buf.String()) switch capInput { - case "D", "DELETE", "A", "ADD","W", "WRITE", + case "D", "DELETE", "A", "ADD", "W", "WRITE", "S", "SET", "R", "RELOAD", "SEARCH", "Q", "QUIT", "B", "BOOKMARKS", "H", - "HOME", "?", "HELP", "C", "CHECK", + "HOME", "?", "HELP", "C", "CHECK", "P", "PURGE": return Token{Action, capInput} } diff --git a/config/parser.go b/config/parser.go index 780bfa7..5f69ebf 100644 --- a/config/parser.go +++ b/config/parser.go @@ -21,11 +21,11 @@ type Parser struct { type Config struct { // Bookmarks gopher.Bookmarks - Bookmarks struct { - Titles, Links []string + Bookmarks struct { + Titles, Links []string } - Settings []KeyValue - Certs []KeyValue + Settings []KeyValue + Certs []KeyValue } type KeyValue struct { diff --git a/cui/cui_test.go b/cui/cui_test.go index 941e6a6..d2d9d30 100644 --- a/cui/cui_test.go +++ b/cui/cui_test.go @@ -1,5 +1 @@ package cui - -import ( -) - diff --git a/defaults.go b/defaults.go index dc5d124..ec33090 100644 --- a/defaults.go +++ b/defaults.go @@ -12,21 +12,20 @@ var defaultOptions = map[string]string{ // Edit these values before compile to have different default values // ... though they can always be edited from within bombadillo as well // it just may take more time/work. - // - // To change the default location for the config you can enter - // any valid path as a string, if you want an absolute, or - // concatenate with the main default: `userinfo.HomeDir` like so: - // "configlocation": userinfo.HomeDir + "/config/" - "homeurl": "gopher://bombadillo.colorfield.space:70/1/user-guide.map", - "savelocation": userinfo.HomeDir, - "searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs", - "openhttp": "false", - "telnetcommand": "telnet", + // + // To change the default location for the config you can enter + // any valid path as a string, if you want an absolute, or + // concatenate with the main default: `userinfo.HomeDir` like so: + // "configlocation": userinfo.HomeDir + "/config/" + "homeurl": "gopher://bombadillo.colorfield.space:70/1/user-guide.map", + "savelocation": userinfo.HomeDir, + "searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs", + "openhttp": "false", + "telnetcommand": "telnet", "configlocation": userinfo.HomeDir, - "theme": "normal", // "normal", "inverted" - "terminalonly": "true", + "theme": "normal", // "normal", "inverted" + "terminalonly": "true", "tlscertificate": "", - "tlskey": "", - "lynxmode": "false", + "tlskey": "", + "lynxmode": "false", } - diff --git a/finger/finger.go b/finger/finger.go index d02a1b1..ac2ca80 100644 --- a/finger/finger.go +++ b/finger/finger.go @@ -2,8 +2,8 @@ package finger import ( "fmt" - "net" "io/ioutil" + "net" "time" ) diff --git a/footbar.go b/footbar.go index c2d2e27..b0aef21 100644 --- a/footbar.go +++ b/footbar.go @@ -5,17 +5,15 @@ import ( "strconv" ) - //------------------------------------------------\\ // + + + T Y P E S + + + \\ //--------------------------------------------------\\ type Footbar struct { PercentRead string - PageType string + PageType string } - //------------------------------------------------\\ // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ @@ -34,15 +32,14 @@ func (f *Footbar) SetPageType(t string) { } func (f *Footbar) Render(termWidth, position int, theme string) string { - pre := fmt.Sprintf("HST: (%2.2d) - - - %4s Read ", position + 1, f.PercentRead) + pre := fmt.Sprintf("HST: (%2.2d) - - - %4s Read ", position+1, f.PercentRead) out := "\033[0m%*.*s " if theme == "inverse" { out = "\033[7m%*.*s \033[0m" } - return fmt.Sprintf(out, termWidth - 1, termWidth - 1, pre) + return fmt.Sprintf(out, termWidth-1, termWidth-1, pre) } - //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ @@ -50,4 +47,3 @@ func (f *Footbar) Render(termWidth, position int, theme string) string { func MakeFootbar() Footbar { return Footbar{"---", "N/A"} } - diff --git a/gemini/gemini.go b/gemini/gemini.go index a666329..49d6e40 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -11,22 +11,19 @@ import ( "time" ) - type Capsule struct { - MimeMaj string + MimeMaj string MimeMin string - Status int - Content string + Status int + Content string Links []string } - type TofuDigest struct { - certs map[string]string - ClientCert tls.Certificate + certs map[string]string + ClientCert tls.Certificate } - //------------------------------------------------\\ // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ @@ -107,17 +104,17 @@ func (t *TofuDigest) newCert(host string, cState *tls.ConnectionState) error { reasons.WriteString("; ") } if now.Before(cert.NotBefore) { - reasons.WriteString(fmt.Sprintf("Cert [%d] is not valid yet", index + 1)) + reasons.WriteString(fmt.Sprintf("Cert [%d] is not valid yet", index+1)) continue } if now.After(cert.NotAfter) { - reasons.WriteString(fmt.Sprintf("Cert [%d] is expired", index + 1)) + reasons.WriteString(fmt.Sprintf("Cert [%d] is expired", index+1)) continue } if err := cert.VerifyHostname(host); err != nil { - reasons.WriteString(fmt.Sprintf("Cert [%d] hostname does not match", index + 1)) + reasons.WriteString(fmt.Sprintf("Cert [%d] hostname does not match", index+1)) continue } @@ -143,8 +140,6 @@ func (t *TofuDigest) IniDump() string { return out.String() } - - //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ @@ -157,7 +152,7 @@ func Retrieve(host, port, resource string, td *TofuDigest) (string, error) { addr := host + ":" + port conf := &tls.Config{ - MinVersion: tls.VersionTLS12, + MinVersion: tls.VersionTLS12, InsecureSkipVerify: true, } @@ -183,7 +178,7 @@ func Retrieve(host, port, resource string, td *TofuDigest) (string, error) { if td.Exists(host) { // See if we have a matching cert - err := td.Match(host, &connState) + err := td.Match(host, &connState) if err != nil && err.Error() != "EXP" { // If there is no match and it isnt because of an expiration // just return the error @@ -223,21 +218,21 @@ func Fetch(host, port, resource string, td *TofuDigest) ([]byte, error) { rawResp, err := Retrieve(host, port, resource, td) if err != nil { return make([]byte, 0), err - } + } resp := strings.SplitN(rawResp, "\r\n", 2) if len(resp) != 2 { if err != nil { return make([]byte, 0), fmt.Errorf("Invalid response from server") - } + } } header := strings.SplitN(resp[0], " ", 2) if len([]rune(header[0])) != 2 { header = strings.SplitN(resp[0], "\t", 2) if len([]rune(header[0])) != 2 { - return make([]byte,0), fmt.Errorf("Invalid response format from server") - } - } + return make([]byte, 0), fmt.Errorf("Invalid response format from server") + } + } // Get status code single digit form status, err := strconv.Atoi(string(header[0][0])) @@ -271,24 +266,24 @@ func Visit(host, port, resource string, td *TofuDigest) (Capsule, error) { rawResp, err := Retrieve(host, port, resource, td) if err != nil { return capsule, err - } + } resp := strings.SplitN(rawResp, "\r\n", 2) if len(resp) != 2 { if err != nil { return capsule, fmt.Errorf("Invalid response from server") - } + } } header := strings.SplitN(resp[0], " ", 2) if len([]rune(header[0])) != 2 { header = strings.SplitN(resp[0], "\t", 2) if len([]rune(header[0])) != 2 { return capsule, fmt.Errorf("Invalid response format from server") - } - } + } + } body := resp[1] - + // Get status code single digit form capsule.Status, err = strconv.Atoi(string(header[0][0])) if err != nil { @@ -351,7 +346,7 @@ func parseGemini(b, rootUrl, currentUrl string) (string, []string) { subLn := strings.Trim(ln[2:], "\r\n\t \a") splitPoint := strings.IndexAny(subLn, " \t") - if splitPoint < 0 || len([]rune(subLn)) - 1 <= splitPoint { + if splitPoint < 0 || len([]rune(subLn))-1 <= splitPoint { link = subLn decorator = subLn } else { @@ -359,7 +354,7 @@ func parseGemini(b, rootUrl, currentUrl string) (string, []string) { decorator = strings.Trim(subLn[splitPoint:], "\t\n\r \a") } - if strings.Index(link, "://") < 0 { + if strings.Index(link, "://") < 0 { link = handleRelativeUrl(link, rootUrl, currentUrl) } @@ -385,7 +380,7 @@ func handleRelativeUrl(u, root, current string) string { return fmt.Sprintf("%s/%s", root, u) } - current = current[:ind + 1] + current = current[:ind+1] return fmt.Sprintf("%s%s", current, u) } @@ -398,7 +393,6 @@ func hashCert(cert []byte) string { return fmt.Sprintf("%s", string(bytes.Join(hex, []byte(":")))) } - func MakeCapsule() Capsule { return Capsule{"", "", 0, "", make([]string, 0, 5)} } diff --git a/gopher/gopher.go b/gopher/gopher.go index 3b15440..fd5744f 100644 --- a/gopher/gopher.go +++ b/gopher/gopher.go @@ -83,8 +83,8 @@ func Visit(gophertype, host, port, resource string) (string, []string, error) { resp, err := Retrieve(host, port, resource) if err != nil { return "", []string{}, err - } - + } + text := string(resp) links := []string{} @@ -92,7 +92,6 @@ func Visit(gophertype, host, port, resource string) (string, []string, error) { return text, []string{}, nil } - if gophertype == "1" { text, links = parseMap(text) } @@ -116,7 +115,7 @@ func isWebLink(resource string) (string, bool) { return "", false } -func parseMap(text string) (string, []string) { +func parseMap(text string) (string, []string) { splitContent := strings.Split(text, "\n") links := make([]string, 0, 10) @@ -135,7 +134,7 @@ func parseMap(text string) (string, []string) { } else { title = "" } - + if len(line) > 1 && len(line[0]) > 0 && string(line[0][0]) == "i" { splitContent[i] = " " + string(title) } else if len(line) >= 4 { diff --git a/headbar.go b/headbar.go index e6d43ef..79ce11c 100644 --- a/headbar.go +++ b/headbar.go @@ -10,10 +10,9 @@ import ( type Headbar struct { title string - url string + url string } - //------------------------------------------------\\ // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ @@ -27,7 +26,6 @@ func (h *Headbar) Render(width int, theme string) string { } } - //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ @@ -35,4 +33,3 @@ func (h *Headbar) Render(width int, theme string) string { func MakeHeadbar(title string) Headbar { return Headbar{title, ""} } - diff --git a/http/lynx_mode.go b/http/lynx_mode.go index 3cc89ca..782aee3 100644 --- a/http/lynx_mode.go +++ b/http/lynx_mode.go @@ -44,7 +44,7 @@ func IsTextFile(url string) bool { } // If we made it here, there is no content-type header. - // So in the event of the unknown, lets render to the + // So in the event of the unknown, lets render to the // screen. This will allow redirects to get rendered // as well. return true @@ -89,4 +89,3 @@ func Fetch(url string) ([]byte, error) { return bodyBytes, nil } - diff --git a/local/local.go b/local/local.go index cbcfe0e..430a499 100644 --- a/local/local.go +++ b/local/local.go @@ -18,7 +18,6 @@ func Open(address string) (string, error) { } defer file.Close() - if pathIsDir(address) { fileList, err := file.Readdirnames(0) if err != nil { @@ -40,21 +39,20 @@ func Open(address string) (string, error) { return string(bytes), nil } - func pathExists(p string) bool { exists := true - if _, err := os.Stat(p); os.IsNotExist(err) { - exists = false - } + if _, err := os.Stat(p); os.IsNotExist(err) { + exists = false + } - return exists + return exists } func pathIsDir(p string) bool { - info, err := os.Stat(p) + info, err := os.Stat(p) if err != nil { return false - } + } return info.IsDir() } diff --git a/page.go b/page.go index ee8b68c..44ded97 100644 --- a/page.go +++ b/page.go @@ -10,9 +10,9 @@ import ( type Page struct { WrappedContent []string - RawContent string - Links []string - Location Url + RawContent string + Links []string + Location Url ScrollPosition int } @@ -22,7 +22,7 @@ type Page struct { func (p *Page) ScrollPositionRange(termHeight int) (int, int) { termHeight -= 3 - if len(p.WrappedContent) - p.ScrollPosition < termHeight { + if len(p.WrappedContent)-p.ScrollPosition < termHeight { p.ScrollPosition = len(p.WrappedContent) - termHeight } if p.ScrollPosition < 0 { @@ -51,7 +51,7 @@ func (p *Page) WrapContent(width int) { content.WriteRune(ch) counter = 0 } else if ch == '\t' { - if counter + 4 < width { + if counter+4 < width { content.WriteString(" ") counter += 4 } else { @@ -69,7 +69,7 @@ func (p *Page) WrapContent(width int) { content.WriteRune('\n') counter = 0 if p.Location.Mime == "1" { - spacer := " " + spacer := " " content.WriteString(spacer) counter += len(spacer) } @@ -89,4 +89,3 @@ func MakePage(url Url, content string, links []string) Page { p := Page{make([]string, 0), content, links, url, 0} return p } - diff --git a/pages.go b/pages.go index 08a403b..e40ec93 100644 --- a/pages.go +++ b/pages.go @@ -10,11 +10,10 @@ import ( type Pages struct { Position int - Length int - History [20]Page + Length int + History [20]Page } - //------------------------------------------------\\ // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ @@ -23,7 +22,7 @@ func (p *Pages) NavigateHistory(qty int) error { newPosition := p.Position + qty if newPosition < 0 { return fmt.Errorf("You are already at the beginning of history") - } else if newPosition > p.Length - 1 { + } else if newPosition > p.Length-1 { return fmt.Errorf("Your way is blocked by void, there is nothing forward") } @@ -32,11 +31,11 @@ func (p *Pages) NavigateHistory(qty int) error { } func (p *Pages) Add(pg Page) { - if p.Position == p.Length - 1 && p.Length < len(p.History) { + if p.Position == p.Length-1 && p.Length < len(p.History) { p.History[p.Length] = pg p.Length++ p.Position++ - } else if p.Position == p.Length - 1 && p.Length == 20 { + } else if p.Position == p.Length-1 && p.Length == 20 { for x := 1; x < len(p.History); x++ { p.History[x-1] = p.History[x] } @@ -62,12 +61,12 @@ func (p *Pages) Render(termHeight, termWidth int) []string { } else if prev < now { diff := now - prev pos = pos + diff - if pos > now - termHeight { + if pos > now-termHeight { pos = now - termHeight } } - if pos < 0 || now < termHeight - 3 { + if pos < 0 || now < termHeight-3 { pos = 0 } @@ -83,5 +82,3 @@ func (p *Pages) Render(termHeight, termWidth int) []string { func MakePages() Pages { return Pages{-1, 0, [20]Page{}} } - - diff --git a/url.go b/url.go index b1b921e..aaa2cbd 100644 --- a/url.go +++ b/url.go @@ -13,12 +13,12 @@ import ( //--------------------------------------------------\\ type Url struct { - Scheme string - Host string - Port string - Resource string - Full string - Mime string + Scheme string + Host string + Port string + Resource string + Full string + Mime string DownloadOnly bool } @@ -28,12 +28,10 @@ type Url struct { // There are currently no receivers for the Url struct - //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ - // MakeUrl is a Url constructor that takes in a string // representation of a url and returns a Url struct and // an error (or nil). @@ -152,7 +150,7 @@ func parseFinger(u string) (Url, error) { if len(userPlusAddress) > 1 { out.Resource = userPlusAddress[0] u = userPlusAddress[1] - } + } hostPort := strings.Split(u, ":") if len(hostPort) < 2 { out.Port = "79" @@ -167,5 +165,3 @@ func parseFinger(u string) (Url, error) { out.Full = fmt.Sprintf("%s://%s%s:%s", out.Scheme, resource, out.Host, out.Port) return out, nil } - - From f5c5dcd736fa8222cee1a551f400ec6ebc5e998c Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 10 Nov 2019 11:35:52 -0800 Subject: [PATCH 113/145] Handles a number of linter errors --- bookmarks.go | 18 +++++++++++++----- client.go | 20 +++++++++----------- footbar.go | 9 +++++++++ headbar.go | 8 ++++++-- main.go | 3 +-- page.go | 5 ++++- pages.go | 2 +- 7 files changed, 43 insertions(+), 22 deletions(-) diff --git a/bookmarks.go b/bookmarks.go index 8f8cc0d..0268378 100644 --- a/bookmarks.go +++ b/bookmarks.go @@ -11,6 +11,9 @@ import ( // + + + T Y P E S + + + \\ //--------------------------------------------------\\ +// Bookmarks represents the contents of the bookmarks +// bar, as well as its visibility, focus, and scroll +// state. type Bookmarks struct { IsOpen bool IsFocused bool @@ -24,6 +27,7 @@ type Bookmarks struct { // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ +// Add a bookmark to the bookmarks struct func (b *Bookmarks) Add(v []string) (string, error) { if len(v) < 2 { return "", fmt.Errorf("Received %d arguments, expected 2+", len(v)) @@ -34,6 +38,7 @@ func (b *Bookmarks) Add(v []string) (string, error) { return "Bookmark added successfully", nil } +// Delete a bookmark from the bookmarks struct func (b *Bookmarks) Delete(i int) (string, error) { if i < len(b.Titles) && len(b.Titles) == len(b.Links) { b.Titles = append(b.Titles[:i], b.Titles[i+1:]...) @@ -44,6 +49,7 @@ func (b *Bookmarks) Delete(i int) (string, error) { return "", fmt.Errorf("Bookmark %d does not exist", i) } +// ToggleOpen toggles visibility state of the bookmarks bar func (b *Bookmarks) ToggleOpen() { b.IsOpen = !b.IsOpen if b.IsOpen { @@ -53,12 +59,15 @@ func (b *Bookmarks) ToggleOpen() { } } +// ToggleFocused toggles the focal state of the bookmarks bar func (b *Bookmarks) ToggleFocused() { if b.IsOpen { b.IsFocused = !b.IsFocused } } +// IniDump returns a string representing the current bookmarks +// in the format that .bombadillo.ini uses func (b Bookmarks) IniDump() string { if len(b.Titles) < 1 { return "" @@ -73,7 +82,7 @@ func (b Bookmarks) IniDump() string { return out } -// Get a list, including link nums, of bookmarks +// List returns a list, including link nums, of bookmarks // as a string slice func (b Bookmarks) List() []string { var out []string @@ -83,6 +92,8 @@ func (b Bookmarks) List() []string { return out } +// Render returns a string slice with the contents of each +// visual row of the bookmark bar. func (b Bookmarks) Render(termwidth, termheight int) []string { width := 40 termheight -= 3 @@ -128,14 +139,11 @@ func (b Bookmarks) Render(termwidth, termheight int) []string { return out } -// TODO handle scrolling of the bookmarks list -// either here with a scroll up/down or in the client -// code for scroll - //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ +// MakeBookmarks creates a Bookmark struct with default values func MakeBookmarks() Bookmarks { return Bookmarks{false, false, 0, 0, make([]string, 0), make([]string, 0)} } diff --git a/client.go b/client.go index 952f9f6..35fd5af 100644 --- a/client.go +++ b/client.go @@ -385,10 +385,9 @@ func (c *client) doCommandAs(action string, values []string) { c.SetMessage(err.Error(), true) c.DrawMessage() return - } else { - c.SetMessage(msg, false) - c.DrawMessage() } + c.SetMessage(msg, false) + c.DrawMessage() err = saveConfig() if err != nil { @@ -437,7 +436,7 @@ func (c *client) doLinkCommandAs(action, target string, values []string) { return } - num -= 1 + num-- links := c.PageState.History[c.PageState.Position].Links if num >= len(links) || num < 0 { @@ -456,10 +455,9 @@ func (c *client) doLinkCommandAs(action, target string, values []string) { c.SetMessage(err.Error(), true) c.DrawMessage() return - } else { - c.SetMessage(msg, false) - c.DrawMessage() } + c.SetMessage(msg, false) + c.DrawMessage() err = saveConfig() if err != nil { @@ -564,10 +562,9 @@ func (c *client) doLinkCommand(action, target string) { c.SetMessage(err.Error(), true) c.DrawMessage() return - } else { - c.SetMessage(msg, false) - c.DrawMessage() } + c.SetMessage(msg, false) + c.DrawMessage() err = saveConfig() if err != nil { @@ -585,7 +582,7 @@ func (c *client) doLinkCommand(action, target string) { } c.Visit(c.BookMarks.Links[num]) case "CHECK", "C": - num -= 1 + num-- links := c.PageState.History[c.PageState.Position].Links if num >= len(links) || num < 0 { @@ -1052,6 +1049,7 @@ func (c *client) handleWeb(u Url) { // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ +// Creates a client instance and names the client after the string that is passed in func MakeClient(name string) *client { c := client{0, 0, defaultOptions, "", false, MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar(), gemini.MakeTofuDigest()} return &c diff --git a/footbar.go b/footbar.go index b0aef21..94140f5 100644 --- a/footbar.go +++ b/footbar.go @@ -9,6 +9,8 @@ import ( // + + + T Y P E S + + + \\ //--------------------------------------------------\\ +// Footbar deals with the values present in the +// client's footbar type Footbar struct { PercentRead string PageType string @@ -18,6 +20,8 @@ type Footbar struct { // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ +// SetPercentRead sets the percentage of the current +// document the user has read func (f *Footbar) SetPercentRead(p int) { if p > 100 { p = 100 @@ -27,10 +31,14 @@ func (f *Footbar) SetPercentRead(p int) { f.PercentRead = strconv.Itoa(p) + "%" } +// SetPageType sets the current page's type +// NOTE: This is not currently in use func (f *Footbar) SetPageType(t string) { f.PageType = t } +// Render returns a string representing the visual display +// of the bookmarks bar func (f *Footbar) Render(termWidth, position int, theme string) string { pre := fmt.Sprintf("HST: (%2.2d) - - - %4s Read ", position+1, f.PercentRead) out := "\033[0m%*.*s " @@ -44,6 +52,7 @@ func (f *Footbar) Render(termWidth, position int, theme string) string { // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ +// MakeFootbar returns a footbar with default values func MakeFootbar() Footbar { return Footbar{"---", "N/A"} } diff --git a/headbar.go b/headbar.go index 79ce11c..cd5eea2 100644 --- a/headbar.go +++ b/headbar.go @@ -8,6 +8,9 @@ import ( // + + + T Y P E S + + + \\ //--------------------------------------------------\\ +// Headbar represents the contents of the top bar of +// the client and contains the client name and the +// current URL type Headbar struct { title string url string @@ -17,19 +20,20 @@ type Headbar struct { // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ +// Render returns a string with the contents of theHeadbar func (h *Headbar) Render(width int, theme string) string { maxMsgWidth := width - len([]rune(h.title)) - 2 if theme == "inverse" { return fmt.Sprintf("\033[7m%s▟\033[27m %-*.*s\033[0m", h.title, maxMsgWidth, maxMsgWidth, h.url) - } else { - return fmt.Sprintf("%s▟\033[7m %-*.*s\033[0m", h.title, maxMsgWidth, maxMsgWidth, h.url) } + return fmt.Sprintf("%s▟\033[7m %-*.*s\033[0m", h.title, maxMsgWidth, maxMsgWidth, h.url) } //------------------------------------------------\\ // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ +// MakeHeadbar returns a Headbar with default values func MakeHeadbar(title string) Headbar { return Headbar{title, ""} } diff --git a/main.go b/main.go index 54e7713..3c03392 100644 --- a/main.go +++ b/main.go @@ -82,9 +82,8 @@ func validateOpt(opt, val string) bool { } } return false - } else { - return true } + return true } func lowerCaseOpt(opt, val string) string { diff --git a/page.go b/page.go index 44ded97..891b86d 100644 --- a/page.go +++ b/page.go @@ -8,6 +8,9 @@ import ( // + + + T Y P E S + + + \\ //--------------------------------------------------\\ +// Page represents a visited URL's contents; including +// the raw content, wrapped content, link slice, URL, +// and the current scroll position type Page struct { WrappedContent []string RawContent string @@ -38,7 +41,7 @@ func (p *Page) ScrollPositionRange(termHeight int) (int, int) { return p.ScrollPosition, end } -// Performs a hard wrap to the requested +// WrapContent performs a hard wrap to the requested // width and updates the WrappedContent // of the Page struct width a string slice // of the wrapped data diff --git a/pages.go b/pages.go index e40ec93..90f570a 100644 --- a/pages.go +++ b/pages.go @@ -41,7 +41,7 @@ func (p *Pages) Add(pg Page) { } p.History[len(p.History)-1] = pg } else { - p.Position += 1 + p.Position++ p.Length = p.Position + 1 p.History[p.Position] = pg } From 3a33320ec53fd4e464291b91a8c2f3ad851974db Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 10 Nov 2019 14:14:45 -0800 Subject: [PATCH 114/145] Removed dead code and empty file --- cui/cui.go | 13 ------------- cui/cui_test.go | 1 - 2 files changed, 14 deletions(-) delete mode 100644 cui/cui_test.go diff --git a/cui/cui.go b/cui/cui.go index fa57870..85b14cc 100644 --- a/cui/cui.go +++ b/cui/cui.go @@ -26,19 +26,6 @@ var Shapes = map[string]string{ "abr": "▟", } -func drawShape(shape string) { - if val, ok := Shapes[shape]; ok { - fmt.Printf("%s", val) - } else { - fmt.Print("x") - } -} - -func moveThenDrawShape(r, c int, s string) { - MoveCursorTo(r, c) - drawShape(s) -} - func MoveCursorTo(row, col int) { fmt.Printf("\033[%d;%dH", row, col) } diff --git a/cui/cui_test.go b/cui/cui_test.go deleted file mode 100644 index d2d9d30..0000000 --- a/cui/cui_test.go +++ /dev/null @@ -1 +0,0 @@ -package cui From 6d9ae540e3648707cb2fe271e6a5632f391b8676 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 10 Nov 2019 16:18:27 -0800 Subject: [PATCH 115/145] Responds to GoMetaLinter for more of the codebase. --- client.go | 9 +++++---- main.go | 8 ++++---- page.go | 3 +++ pages.go | 14 ++++++++++++++ url.go | 5 +++++ 5 files changed, 31 insertions(+), 8 deletions(-) diff --git a/client.go b/client.go index 35fd5af..699871f 100644 --- a/client.go +++ b/client.go @@ -51,7 +51,7 @@ func (c *client) GetSizeOnce() { os.Exit(5) } var h, w int - fmt.Sscan(string(out), &h, &w) + _, _ = fmt.Sscan(string(out), &h, &w) c.Height = h c.Width = w } @@ -70,7 +70,7 @@ func (c *client) GetSize() { os.Exit(5) } var h, w int - fmt.Sscan(string(out), &h, &w) + _, _ = fmt.Sscan(string(out), &h, &w) if h != c.Height || w != c.Width { c.Height = h c.Width = w @@ -268,7 +268,7 @@ func (c *client) routeCommandInput(com *cmdparse.Command) error { case cmdparse.DOLINKAS: c.doLinkCommandAs(com.Action, com.Target, com.Value) default: - return fmt.Errorf("Unknown command entry!") + return fmt.Errorf("Unknown command entry") } return err @@ -1049,7 +1049,8 @@ func (c *client) handleWeb(u Url) { // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ -// Creates a client instance and names the client after the string that is passed in +// MakeClient returns a client struct and names the client after +// the string that is passed in func MakeClient(name string) *client { c := client{0, 0, defaultOptions, "", false, MakePages(), MakeBookmarks(), MakeHeadbar(name), MakeFootbar(), gemini.MakeTofuDigest()} return &c diff --git a/main.go b/main.go index 3c03392..4b644bb 100644 --- a/main.go +++ b/main.go @@ -106,7 +106,7 @@ func loadConfig() error { confparser := config.NewParser(file) settings, _ = confparser.Parse() - file.Close() + _ = file.Close() for _, v := range settings.Settings { lowerkey := strings.ToLower(v.Key) if lowerkey == "configlocation" { @@ -128,7 +128,7 @@ func loadConfig() error { } for i, v := range settings.Bookmarks.Titles { - bombadillo.BookMarks.Add([]string{v, settings.Bookmarks.Links[i]}) + _, _ = bombadillo.BookMarks.Add([]string{v, settings.Bookmarks.Links[i]}) } for _, v := range settings.Certs { @@ -156,7 +156,7 @@ func handleSignals(c <-chan os.Signal) { switch <-c { case syscall.SIGTSTP: cui.CleanupTerm() - syscall.Kill(syscall.Getpid(), syscall.SIGSTOP) + _ = syscall.Kill(syscall.Getpid(), syscall.SIGSTOP) case syscall.SIGCONT: cui.InitTerm() bombadillo.Draw() @@ -178,7 +178,7 @@ Examples: bombadillo gopher://bombadillo.colorfield.space Options: ` - fmt.Fprint(os.Stdout, art) + _, _ = fmt.Fprint(os.Stdout, art) flag.PrintDefaults() } diff --git a/page.go b/page.go index 891b86d..4e7b54c 100644 --- a/page.go +++ b/page.go @@ -23,6 +23,8 @@ type Page struct { // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ +// ScrollPositionRange may not be in actual usage.... +// TODO: find where this is being used func (p *Page) ScrollPositionRange(termHeight int) (int, int) { termHeight -= 3 if len(p.WrappedContent)-p.ScrollPosition < termHeight { @@ -88,6 +90,7 @@ func (p *Page) WrapContent(width int) { // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ +// MakePage returns a Page struct with default values func MakePage(url Url, content string, links []string) Page { p := Page{make([]string, 0), content, links, url, 0} return p diff --git a/pages.go b/pages.go index 90f570a..3a1db87 100644 --- a/pages.go +++ b/pages.go @@ -8,6 +8,9 @@ import ( // + + + T Y P E S + + + \\ //--------------------------------------------------\\ +// Pages is a struct that represents the history of the client. +// It functions as a container for the pages (history array) and +// tracks the current history length and location. type Pages struct { Position int Length int @@ -18,6 +21,10 @@ type Pages struct { // + + + R E C E I V E R S + + + \\ //--------------------------------------------------\\ +// NavigateHistory takes a positive or negative integer +// and updates the current history position. Checks are done +// to make sure that the position moved to is a valid history +// location. Returns an error or nil. func (p *Pages) NavigateHistory(qty int) error { newPosition := p.Position + qty if newPosition < 0 { @@ -30,6 +37,10 @@ func (p *Pages) NavigateHistory(qty int) error { return nil } +// Add gets passed a Page, which gets added to the history +// arrayr. Add also updates the current length and position +// of the Pages struct to which it belongs. Add also shifts +// off array items if necessary. func (p *Pages) Add(pg Page) { if p.Position == p.Length-1 && p.Length < len(p.History) { p.History[p.Length] = pg @@ -47,6 +58,8 @@ func (p *Pages) Add(pg Page) { } } +// Render wraps the content for the current page and returns +// the page content as a string slice func (p *Pages) Render(termHeight, termWidth int) []string { if p.Length < 1 { return make([]string, 0) @@ -79,6 +92,7 @@ func (p *Pages) Render(termHeight, termWidth int) []string { // + + + F U N C T I O N S + + + \\ //--------------------------------------------------\\ +// MakePages returns a Pages struct with default values func MakePages() Pages { return Pages{-1, 0, [20]Page{}} } diff --git a/url.go b/url.go index aaa2cbd..bc1895a 100644 --- a/url.go +++ b/url.go @@ -12,6 +12,11 @@ import ( // + + + T Y P E S + + + \\ //--------------------------------------------------\\ +// Url is a struct representing the different pieces +// of a url. This custom struct is used rather than the +// built-in url library so-as to support gopher URLs, as +// well as track mime-type and renderability (can the +// response to the url be rendered as text in the client). type Url struct { Scheme string Host string From 34e9e109e219cd7f5b2a2969dff880a9a85d094e Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Mon, 11 Nov 2019 16:07:50 -0800 Subject: [PATCH 116/145] Correcting an error message --- gemini/gemini.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gemini/gemini.go b/gemini/gemini.go index a666329..ee6a413 100644 --- a/gemini/gemini.go +++ b/gemini/gemini.go @@ -256,7 +256,7 @@ func Fetch(host, port, resource string, td *TofuDigest) ([]byte, error) { case 5: return make([]byte, 0), fmt.Errorf("[5] Permanent Failure.") case 6: - return make([]byte, 0), fmt.Errorf("[6] Client Certificate Required (Not supported by Bombadillo)") + return make([]byte, 0), fmt.Errorf("[6] Client Certificate Required") default: return make([]byte, 0), fmt.Errorf("Invalid response status from server") } @@ -334,7 +334,7 @@ func Visit(host, port, resource string, td *TofuDigest) (Capsule, error) { case 5: return capsule, fmt.Errorf("[5] Permanent Failure. %s", header[1]) case 6: - return capsule, fmt.Errorf("[6] Client Certificate Required (Not supported by Bombadillo)") + return capsule, fmt.Errorf("[6] Client Certificate Required") default: return capsule, fmt.Errorf("Invalid response status from server") } From 45eabef94518700eab7beffa46bfe70f0bbf3092 Mon Sep 17 00:00:00 2001 From: asdf Date: Thu, 7 Nov 2019 22:29:22 +1100 Subject: [PATCH 117/145] Added developer documentation, testing to Makefile --- Makefile | 4 ++++ README.md | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/Makefile b/Makefile index ed3e3b6..d8d2c33 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ BINDIR := ${EXEC_PREFIX}/bin DATAROOTDIR := ${PREFIX}/share MANDIR := ${DATAROOTDIR}/man MAN1DIR := ${MANDIR}/man1 +test : GOCMD := go1.11.13 # Use a dateformat rather than -I flag since OSX # does not support -I. It also doesn't support @@ -47,3 +48,6 @@ clean: uninstall: clean rm -f ${DESTDIR}${MAN1DIR}/bombadillo.1.gz rm -f ${DESTDIR}${BINDIR}/${BINARY} + +.PHONY: test +test: clean build diff --git a/README.md b/README.md index 72cd746..4738877 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,14 @@ We aim for simplicity and quality, and do our best to make Bombadillo useful to The maintainers use the [tildegit](https://tildegit.org) issues system to discuss new features, track bugs, and communicate with users regarding issues and suggestions. Pull requests should typically have an associated issue, and should target the `develop` branch. +## Development + +Following the standard install instructions should lead you to have nearly everything you need to commence development. The only additions to this are: + +- To be able to submit pull requests, you will need to fork this repository first. +- Bombadillo is tested against Go 1.11. This version can be installed as per the [Go install documentation](https://golang.org/doc/install#extra_versions). Tests for this version are run using 'make test'. +- Linting is performed by `gofmt` and [golangci-lint](https://github.com/golangci/golangci-lint) + ## License This project is licensed under the GNU GPL version 3. See the [LICENSE](LICENSE) file for details. From 36e52477eb6a15a2997f46348436bcef62b6a3a1 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 12 Nov 2019 13:05:15 +1100 Subject: [PATCH 118/145] Further generalisation of development advice --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4738877..2697745 100644 --- a/README.md +++ b/README.md @@ -130,8 +130,8 @@ The maintainers use the [tildegit](https://tildegit.org) issues system to discus Following the standard install instructions should lead you to have nearly everything you need to commence development. The only additions to this are: - To be able to submit pull requests, you will need to fork this repository first. -- Bombadillo is tested against Go 1.11. This version can be installed as per the [Go install documentation](https://golang.org/doc/install#extra_versions). Tests for this version are run using 'make test'. -- Linting is performed by `gofmt` and [golangci-lint](https://github.com/golangci/golangci-lint) +- Bombadillo must be tested against Go 1.11 to ensure backward compatibility. This version can be installed as per the [Go install documentation](https://golang.org/doc/install#extra_versions). Tests for this version are run using 'make test'. +- Linting must be performed on new changes using `gofmt` and [golangci-lint](https://github.com/golangci/golangci-lint) ## License From 494a70859efc025be1a30974dd0a2d12d827ac85 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 12 Nov 2019 14:21:10 +1100 Subject: [PATCH 119/145] Incorporated feedback --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2697745..8a64232 100644 --- a/README.md +++ b/README.md @@ -130,7 +130,7 @@ The maintainers use the [tildegit](https://tildegit.org) issues system to discus Following the standard install instructions should lead you to have nearly everything you need to commence development. The only additions to this are: - To be able to submit pull requests, you will need to fork this repository first. -- Bombadillo must be tested against Go 1.11 to ensure backward compatibility. This version can be installed as per the [Go install documentation](https://golang.org/doc/install#extra_versions). Tests for this version are run using 'make test'. +- The build process must be tested with Go 1.11 to ensure backward compatibility. This version can be installed as per the [Go install documentation](https://golang.org/doc/install#extra_versions). Check that changes build with this version using `make test`. - Linting must be performed on new changes using `gofmt` and [golangci-lint](https://github.com/golangci/golangci-lint) ## License From 0239fdceba797ddfa48d938b784fc9f13297d740 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 12 Nov 2019 16:08:57 +1100 Subject: [PATCH 120/145] Add xdg config home functionality, documentation --- bombadillo.1 | 2 +- defaults.go | 70 +++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 60 insertions(+), 12 deletions(-) diff --git a/bombadillo.1 b/bombadillo.1 index a5660eb..c93d642 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -199,7 +199,7 @@ Writes data from a given url to a file. The file is named by the last component write [link id] Writes data from a given link id in the current document to a file. The file is named by the last component of the url path. If the last component is blank or \fI/\fP a default name will be used. The file saves to the directory set by the \fIsavelocation\fP setting. \fIw\fP can be entered rather than the full \fIwrite\fP. .SH FILES -\fBbombadillo\fP keeps a hidden configuration file in a user's home directory. The file is a simplified ini file titled \fI.bombadillo.ini\fP. It is generated when a user first loads \fBbombadillo\fP and is updated with bookmarks and settings as a user adds them. The file can be directly edited, but it is best to use the SET command to update settings whenever possible. To return to the state of a fresh install, simply remove the file and a new one will be generated with the \fBbombadillo\fP defaults. On some systems an administrator may set the configuration file location to somewhere other than a user's home directory. If you do not see the file where you expect it, contact your system administrator. +\fBbombadillo\fP keeps a hidden configuration file in a user's XDG configuration directory. The file is a simplified ini file titled \fI.bombadillo.ini\fP. It is generated when a user first loads \fBbombadillo\fP and is updated with bookmarks and settings as a user adds them. The file can be directly edited, but it is best to use the SET command to update settings whenever possible. To return to the state of a fresh install, simply remove the file and a new one will be generated with the \fBbombadillo\fP defaults. On some systems an administrator may set the configuration file location to somewhere other than the default setting. If you do not see the file where you expect it, or if your settings are not being read, try \fI:check configlocation\fP to see where the file should be, or contact your system administrator for more information. .SH SETTINGS The following is a list of the settings that \fBbombadillo\fP recognizes, as well as a description of their valid values. .TP diff --git a/defaults.go b/defaults.go index ec33090..9da05a5 100644 --- a/defaults.go +++ b/defaults.go @@ -1,31 +1,79 @@ package main import ( + "os" "os/user" + "path/filepath" ) -var userinfo, _ = user.Current() var defaultOptions = map[string]string{ + // The configuration options below control the default settings for + // users of Bombadillo. // - // General configuration options + // Changes take effect when Bombadillo is built. Follow the standard + // install instructions after making a change. // - // Edit these values before compile to have different default values - // ... though they can always be edited from within bombadillo as well - // it just may take more time/work. + // Most options can be changed by a user in the Bombadillo client, and + // changes made here will not overwrite an existing user's settings. + // The exception to both cases is "configlocation" which controls where + // .bombadillo.ini is stored. If you make changes to this setting, + // consider moving bombadillo.ini to the new location as well, so you + // (or your users) do not loose bookmarks or other preferences. // - // To change the default location for the config you can enter - // any valid path as a string, if you want an absolute, or - // concatenate with the main default: `userinfo.HomeDir` like so: - // "configlocation": userinfo.HomeDir + "/config/" + // Further explanation of each option is available in the man page. + + // Basic Usage + // + // Any option can be defined as a string, like this: + // "option": "value" + // + // Options can also have values calculated on startup. There are two + // functions below that do just this: homePath() and xdgConfigPath() + // You can set any value to use these functions like this: + // "option": homePath() + // "option": xdgConfigPath() + // See the comments for these functions for more information on what + // they do. + // + // You can also use `filepath.Join()` if you want to build a file path. + // For example, specify "~/bombadillo" like so: + // "option": filepath.Join(homePath(), bombadillo) + + // Moving .bombadillo.ini out of your home directory + // + // To ensure .bombadillo.ini is saved as per XDG config spec, change + // the "configlocation" as follows: + // "configlocation": xdgConfigPath() + "homeurl": "gopher://bombadillo.colorfield.space:70/1/user-guide.map", - "savelocation": userinfo.HomeDir, + "savelocation": homePath(), "searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs", "openhttp": "false", "telnetcommand": "telnet", - "configlocation": userinfo.HomeDir, + "configlocation": xdgConfigPath(), "theme": "normal", // "normal", "inverted" "terminalonly": "true", "tlscertificate": "", "tlskey": "", "lynxmode": "false", } + +// homePath will return the path to your home directory as a string +// Usage: +// "configlocation": homeConfigPath() +func homePath() string { + var userinfo, _ = user.Current() + return userinfo.HomeDir +} + +// xdgConfigPath returns the path to your XDG base directory for configuration +// i.e the contents of environment variable XDG_CONFIG_HOME, or ~/.config/ +// Usage: +// "configlocation": xdgConfigPath() +func xdgConfigPath() string { + configPath := os.Getenv("XDG_CONFIG_HOME") + if configPath == "" { + return filepath.Join(homePath(), ".config") + } + return configPath +} From 4ae093d3e3216f15eeffc77e6464cc61695cbded Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Tue, 12 Nov 2019 21:16:19 -0800 Subject: [PATCH 121/145] Adds in missing calls to draw the message --- client.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/client.go b/client.go index 699871f..e34d376 100644 --- a/client.go +++ b/client.go @@ -244,14 +244,13 @@ func (c *client) TakeControlInput() { err := c.routeCommandInput(p) if err != nil { c.SetMessage(err.Error(), true) - c.Draw() + c.DrawMessage() } } } } func (c *client) routeCommandInput(com *cmdparse.Command) error { - var err error switch com.Type { case cmdparse.SIMPLE: c.simpleCommand(com.Action) @@ -271,7 +270,8 @@ func (c *client) routeCommandInput(com *cmdparse.Command) error { return fmt.Errorf("Unknown command entry") } - return err + return nil + } func (c *client) simpleCommand(action string) { @@ -425,6 +425,7 @@ func (c *client) doCommandAs(action string, values []string) { c.DrawMessage() default: c.SetMessage(fmt.Sprintf("Unknown command structure"), true) + c.DrawMessage() } } @@ -474,6 +475,7 @@ func (c *client) doLinkCommandAs(action, target string, values []string) { c.doCommandAs(action, out) default: c.SetMessage(fmt.Sprintf("Unknown command structure"), true) + c.DrawMessage() } } @@ -618,7 +620,7 @@ func (c *client) doLinkCommand(action, target string) { } c.saveFile(u, fn) default: - c.SetMessage(fmt.Sprintf("Action %q does not exist for target %q", action, target), true) + c.SetMessage("Unknown command structure", true) c.DrawMessage() } From 0b63b85a1a35204cd6333c37593c3e990cbc72c1 Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Wed, 13 Nov 2019 11:25:13 -0800 Subject: [PATCH 122/145] HOT FIX: Solves issue where input bar disappears on empty search input --- client.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client.go b/client.go index 699871f..88dc25c 100644 --- a/client.go +++ b/client.go @@ -641,6 +641,8 @@ func (c *client) search(query, url, question string) { c.DrawMessage() return } else if strings.TrimSpace(entry) == "" { + c.ClearMessage() + c.DrawMessage() return } } else { From 002516bcd2f99509e2cf49c265b6d9fa83e6093f Mon Sep 17 00:00:00 2001 From: asdf Date: Wed, 13 Nov 2019 14:22:45 +1100 Subject: [PATCH 123/145] Final review of man page --- bombadillo.1 | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/bombadillo.1 b/bombadillo.1 index c93d642..ce200fa 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -9,7 +9,9 @@ .fam T .fi .SH DESCRIPTION -\fBbombadillo\fP is a terminal based client for a number of internet protocols. \fBbombadillo\fP will also connect links to a user's default web browser or telnet client. Commands input is loosely based on Vi and Less and is comprised of two modes: key and line input mode. +\fBbombadillo\fP is a non-web client for the terminal. It features a full terminal user interface, vim-like keybindings, document pager, configurable settings, and a robust command selection. +.TP +\fBbombadillo\fP supports the following protocols as first class citizens: gopher, gemini, finger, and local (a user’s file system). Support for telnet, http and https is also available via integration with third party applications. .SH OPTIONS .TP .B @@ -28,7 +30,7 @@ Gopher is the default protocol for \fBbombadillo\fP. Any textual item types will .TP .B gemini -Gemini is supported, but as a new protocol with an incomplete specification, features may change over time. At present Bombadillo supports TLS with a trust on first use certificate pinning system (similar to SSH). Client certificates are also supported via option configuration. Gemini maps and other text types are rendered in the client and non-text types will be downloaded. +Gemini is supported, but as a new protocol with an incomplete specification, features may change over time. At present Bombadillo supports TLS with a trust on first use certificate pinning system (similar to SSH). Client certificates are also supported as a configurable option. Gemini maps and other text types are rendered in the client and non-text types will be downloaded. .TP .B finger @@ -36,7 +38,7 @@ Basic support is provided for the finger protocol. The format is: \fIfinger://[[ .TP .B local -Local is similar to the \fIfile\fP protocol user's may be used to in web browsers or the like. The only difference is that the feature set of local may be smaller than file. User's can use the local scheme to view files on their local system. Directories are supported as viewable text object as well as any files. Wildcards and globbing are not supported. Using \fI~\fP to represent a user's home directory, as well as relative paths, are supported. +Local is similar to the \fIfile\fP protocol used in web browsers or the like, with a smaller set of features. Users can use the local scheme to view files on their local system. Directories are supported as viewable text object as well as any files. Wildcards and globbing are not supported. Using \fI~\fP to represent a user's home directory, as well as relative paths, are supported. .TP .B telnet @@ -44,7 +46,7 @@ Telnet is not supported directly, but addresses will be followed and opened as a .TP .B http, https -Neither of the world wide web protocols are supported directly. However, \fBbombadillo\fP can open web links in a user's default web browser, or display web content directly in the client via the lynx web browser. Opening http links is opt-in only, controlled by the \fIopenhttp\fP setting. +Neither of the world wide web protocols are supported directly. However, \fBbombadillo\fP can open web links in a user's default web browser, or display web content directly in the client via the lynx web browser. Opening http/https links is opt-in only, controlled by the \fIopenhttp\fP setting. .IP Opening links in a default web browser only works if a GUI environment is available. .IP @@ -209,12 +211,11 @@ The url that \fBbombadillo\fP navigates to when the program loads or when the \f .TP .B lynxmode -Will use lynx as a rendering engine for http/https requests if lynx is installed and \fIopenhttp\fP is set to \fItrue\fP. Valid values are \fItrue\fP and \fIfalse\fP. +Sets whether or not to use lynx as a rendering engine for http/https requests, and display results in \fBbombadillo\fP. Lynx must be installed, and \fIopenhttp\fP must be set to \fItrue\fP. Valid values are \fItrue\fP and \fIfalse\fP. .TP .B openhttp -Tells the client whether or not to try to follow web (http/https) links. If set to \fItrue\fP, \fBbombadillo\fP will try to open a user's default web browser to the link in question. Valid values are \fItrue\fP and \fIfalse\fP. - +Tells the client whether or not to try to follow web (http/https) links. If set to \fItrue\fP, \fBbombadillo\fP will try to open these links in a user's default web browser, or render them via lynx, depending on the status of \fIlynxmode\fP and \fIterminalonly\fP settings. Valid values are \fItrue\fP and \fIfalse\fP. .TP .B savelocation @@ -230,7 +231,7 @@ Tells the client what command to use to start a telnet session. Should be a vali .TP .B terminalonly -Sets whether or not to try to open non-text files served via gemini in GUI programs or not. If set to \fItrue\fP \fBbombadillo\fP will only attempt to use terminal programs to open files. If set to \fIfalse\fP \fBbombadillo\fP may choose from the appropriate programs installed on the system, including graphical ones. +Sets whether web links should handled within \fBbombadillo\fP only, or if they can be opened in a user's external web browser. If \fIopenhttp\fP is true, and this setting is true, web links will be handled within \fBbombadillo\fP only. If \fIlynxmode\fP is also true, web links will be rendered in bombadillo via lynx. If \fIopenhttp\fP is true, \fIlynxmode\fP is disabled, and this setting is disabled, \fBbombadillo\fP will open web links in a user's default web browser. Valid values are \fItrue\fP and \fIfalse\fP. .TP .B theme @@ -244,12 +245,12 @@ A path to a tls certificate file on a user's local filesystem. Defaults to NULL. tlskey A path to a tls key that pairs with the tlscertificate setting, on a user's local filesystem. Defaults to NULL. Both \fItlskey\fP and \fItlscertificate\fP must be set for client certificates to work in gemini. .SH BUGS -There are very likely bugs. Many known bugs can be found in the issues section of \fBbombadillo\fP's software repository (see \fIlinks\fP). +There are very likely bugs. Many known bugs can be found in the issues section of \fBbombadillo\fP's source code repository (see \fIlinks\fP). .SH LINKS \fBbombadillo\fP maintains a presence in the following locations: .TP .B -Code Repository +Source Code Repository https://tildegit.org/sloum/bombadillo .TP .B From 28c2d6b277a7001ceffb5eed64d71e62b2b17590 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Wed, 13 Nov 2019 22:23:57 -0800 Subject: [PATCH 124/145] Diversifies the web rendering backends and removes confusing configuration options --- client.go | 41 ++++++++++----------------- defaults.go | 4 +-- http/{lynx_mode.go => http_render.go} | 37 ++++++++++++------------ main.go | 1 + 4 files changed, 35 insertions(+), 48 deletions(-) rename http/{lynx_mode.go => http_render.go} (62%) diff --git a/client.go b/client.go index b590755..fa9f1ca 100644 --- a/client.go +++ b/client.go @@ -643,7 +643,7 @@ func (c *client) search(query, url, question string) { c.DrawMessage() return } else if strings.TrimSpace(entry) == "" { - c.ClearMessage() + c.ClearMessage() c.DrawMessage() return } @@ -995,17 +995,11 @@ func (c *client) handleFinger(u Url) { } func (c *client) handleWeb(u Url) { - // Following http is disabled - if strings.ToUpper(c.Options["openhttp"]) != "TRUE" { - c.SetMessage("'openhttp' is not set to true, cannot open web link", false) - c.DrawMessage() - return - } - - // Use lynxmode - if strings.ToUpper(c.Options["lynxmode"]) == "TRUE" { + wm := strings.ToLower(c.Options["webmode"]) + switch wm { + case "lynx", "w3m", "elinks": if http.IsTextFile(u.Full) { - page, err := http.Visit(u.Full, c.Width-1) + page, err := http.Visit(wm, u.Full, c.Width-1) if err != nil { c.SetMessage(fmt.Sprintf("Lynx error: %s", err.Error()), true) c.DrawMessage() @@ -1029,23 +1023,18 @@ func (c *client) handleWeb(u Url) { } c.saveFile(u, fn) } - - // Open in default web browser if available - } else { - if strings.ToUpper(c.Options["terminalonly"]) == "TRUE" { - c.SetMessage("'terminalonly' is set to true and 'lynxmode' is not enabled, cannot open web link", false) - c.DrawMessage() + case "gui": + c.SetMessage("Attempting to open in gui web browser", false) + c.DrawMessage() + msg, err := http.OpenInBrowser(u.Full) + if err != nil { + c.SetMessage(err.Error(), true) } else { - c.SetMessage("Attempting to open in web browser", false) - c.DrawMessage() - msg, err := http.OpenInBrowser(u.Full) - if err != nil { - c.SetMessage(err.Error(), true) - } else { - c.SetMessage(msg, false) - } - c.DrawMessage() + c.SetMessage(msg, false) } + default: + c.SetMessage("Current 'webmode' setting does not allow http/https", false) + c.DrawMessage() } } diff --git a/defaults.go b/defaults.go index 9da05a5..c14db8c 100644 --- a/defaults.go +++ b/defaults.go @@ -48,14 +48,12 @@ var defaultOptions = map[string]string{ "homeurl": "gopher://bombadillo.colorfield.space:70/1/user-guide.map", "savelocation": homePath(), "searchengine": "gopher://gopher.floodgap.com:70/7/v2/vs", - "openhttp": "false", "telnetcommand": "telnet", "configlocation": xdgConfigPath(), "theme": "normal", // "normal", "inverted" - "terminalonly": "true", "tlscertificate": "", "tlskey": "", - "lynxmode": "false", + "webmode": "none", // "none", "gui", "lynx", "w3m" } // homePath will return the path to your home directory as a string diff --git a/http/lynx_mode.go b/http/http_render.go similarity index 62% rename from http/lynx_mode.go rename to http/http_render.go index 782aee3..ea2e987 100644 --- a/http/lynx_mode.go +++ b/http/http_render.go @@ -13,12 +13,22 @@ type page struct { Links []string } -func Visit(url string, width int) (page, error) { +func Visit(webmode, url string, width int) (page, error) { if width > 80 { width = 80 } - w := fmt.Sprintf("-width=%d", width) - c, err := exec.Command("lynx", "-dump", w, url).Output() + var w string + switch webmode { + case "lynx": + w = "-width" + case "w3m": + w = "-cols" + case "elinks": + w = "-dump-width" + default: + return page{}, fmt.Errorf("Invalid webmode setting") + } + c, err := exec.Command(webmode, "-dump", w, fmt.Sprintf("%d", width), url).Output() if err != nil { return page{}, err } @@ -28,26 +38,16 @@ func Visit(url string, width int) (page, error) { // Returns false on err or non-text type // Else returns true func IsTextFile(url string) bool { - c, err := exec.Command("lynx", "-dump", "-head", url).Output() + resp, err := http.Head(url) if err != nil { return false } - content := string(c) - content = strings.ToLower(content) - headers := strings.Split(content, "\n") - for _, header := range headers { - if strings.Contains(header, "content-type:") && strings.Contains(header, "text") { - return true - } else if strings.Contains(header, "content-type:") { - return false - } + ctype := resp.Header.Get("content-type") + if strings.Contains(ctype, "text") || ctype == "" { + return true } - // If we made it here, there is no content-type header. - // So in the event of the unknown, lets render to the - // screen. This will allow redirects to get rendered - // as well. - return true + return false } func parseLinks(c string) page { @@ -72,7 +72,6 @@ func parseLinks(c string) page { out.Links = append(out.Links, strings.TrimSpace(ls[1])) } return out - } func Fetch(url string) ([]byte, error) { diff --git a/main.go b/main.go index 4b644bb..84627c8 100644 --- a/main.go +++ b/main.go @@ -66,6 +66,7 @@ func saveConfig() error { func validateOpt(opt, val string) bool { var validOpts = map[string][]string{ + "webmode": []string{"none", "gui", "lynx", "w3m", "elinks"}, "openhttp": []string{"true", "false"}, "theme": []string{"normal", "inverse"}, "terminalonly": []string{"true", "false"}, From e4324c68638830a997e1867a7b55b4ebb68b5401 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Wed, 13 Nov 2019 20:01:27 -0800 Subject: [PATCH 125/145] Changes references to client to browser in manpage and readme --- README.md | 8 ++++---- bombadillo.1 | 14 +++++++------- main.go | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 8a64232..688b199 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# Bombadillo - a non-web client +# Bombadillo - a non-web browser -Bombadillo is a non-web client for the terminal. +Bombadillo is a non-web browser for the terminal. -![a screenshot of the bombadillo client](bombadillo-screenshot.png) +![a screenshot of the bombadillo browser](bombadillo-screenshot.png) Bombadillo features a full terminal user interface, vim-like keybindings, document pager, configurable settings, and a robust command selection. @@ -115,7 +115,7 @@ Bombadillo development is largely handled by Sloum, with help from asdf, jboverf There are many ways to contribute to Bombadillo, including a fair few that don't require knowledge of programming: -- Try out the client and let us know if you have a suggestion for improvement, or if you find a bug. +- Try out the browser and let us know if you have a suggestion for improvement, or if you find a bug. - Read the documentation and let us know if something isn't well explained, or needs correction. - Maybe you have a cool logo or some art that you think would look nice. diff --git a/bombadillo.1 b/bombadillo.1 index ce200fa..3e58ca5 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -1,6 +1,6 @@ .TH "bombadillo" 1 "27 OCT 2019" "" "General Operation Manual" .SH NAME -\fBbombadillo \fP- a non-web client +\fBbombadillo \fP- a non-web browser .SH SYNOPSIS .nf .fam C @@ -9,7 +9,7 @@ .fam T .fi .SH DESCRIPTION -\fBbombadillo\fP is a non-web client for the terminal. It features a full terminal user interface, vim-like keybindings, document pager, configurable settings, and a robust command selection. +\fBbombadillo\fP is a non-web browser for the terminal. It features a full terminal user interface, vim-like keybindings, document pager, configurable settings, and a robust command selection. .TP \fBbombadillo\fP supports the following protocols as first class citizens: gopher, gemini, finger, and local (a user’s file system). Support for telnet, http and https is also available via integration with third party applications. .SH OPTIONS @@ -30,7 +30,7 @@ Gopher is the default protocol for \fBbombadillo\fP. Any textual item types will .TP .B gemini -Gemini is supported, but as a new protocol with an incomplete specification, features may change over time. At present Bombadillo supports TLS with a trust on first use certificate pinning system (similar to SSH). Client certificates are also supported as a configurable option. Gemini maps and other text types are rendered in the client and non-text types will be downloaded. +Gemini is supported, but as a new protocol with an incomplete specification, features may change over time. At present Bombadillo supports TLS with a trust on first use certificate pinning system (similar to SSH). Client certificates are also supported as a configurable option. Gemini maps and other text types are rendered in the browser and non-text types will be downloaded. .TP .B finger @@ -46,11 +46,11 @@ Telnet is not supported directly, but addresses will be followed and opened as a .TP .B http, https -Neither of the world wide web protocols are supported directly. However, \fBbombadillo\fP can open web links in a user's default web browser, or display web content directly in the client via the lynx web browser. Opening http/https links is opt-in only, controlled by the \fIopenhttp\fP setting. +Neither of the world wide web protocols are supported directly. However, \fBbombadillo\fP can open web links in a user's default web browser, or display web content directly in the browser via the lynx web browser. Opening http/https links is opt-in only, controlled by the \fIopenhttp\fP setting. .IP Opening links in a default web browser only works if a GUI environment is available. .IP -Opening web content directly in the client requires the lynx web browser, and is enabled using the \fIlynxmode\fP setting. Web content is processed using lynx, and then displayed in the client. +Opening web content directly in the browser requires the lynx web browser, and is enabled using the \fIlynxmode\fP setting. Web content is processed using lynx, and then displayed in \fBbombadillo\fP. .SH COMMANDS .SS KEY COMMANDS These commands work as a single keypress anytime \fBbombadillo\fP is not taking in a line based command. This is the default command mode of \fBbombadillo\fP. @@ -215,7 +215,7 @@ Sets whether or not to use lynx as a rendering engine for http/https requests, a .TP .B openhttp -Tells the client whether or not to try to follow web (http/https) links. If set to \fItrue\fP, \fBbombadillo\fP will try to open these links in a user's default web browser, or render them via lynx, depending on the status of \fIlynxmode\fP and \fIterminalonly\fP settings. Valid values are \fItrue\fP and \fIfalse\fP. +Tells the browser whether or not to try to follow web (http/https) links. If set to \fItrue\fP, \fBbombadillo\fP will try to open these links in a user's default web browser, or render them via lynx, depending on the status of \fIlynxmode\fP and \fIterminalonly\fP settings. Valid values are \fItrue\fP and \fIfalse\fP. .TP .B savelocation @@ -227,7 +227,7 @@ The url to use for the LINE COMMANDs \fI?\fP and \fIsearch\fP. Should be a valid .TP .B telnetcommand -Tells the client what command to use to start a telnet session. Should be a valid command, including any flags. The address being navigated to will be added to the end of the command. +Tells the browser what command to use to start a telnet session. Should be a valid command, including any flags. The address being navigated to will be added to the end of the command. .TP .B terminalonly diff --git a/main.go b/main.go index 4b644bb..055ee1f 100644 --- a/main.go +++ b/main.go @@ -168,7 +168,7 @@ func handleSignals(c <-chan os.Signal) { //printHelp produces a nice display message when the --help flag is used func printHelp() { - art := `Bombadillo - a non-web client + art := `Bombadillo - a non-web browser Syntax: bombadillo [url] bombadillo [options...] From 9d29acc8e895bf0a77ec5ca65bd3b072784fb8ed Mon Sep 17 00:00:00 2001 From: asdf Date: Thu, 14 Nov 2019 21:22:17 +1100 Subject: [PATCH 126/145] Review of webmode, corrections to error messages and comments --- client.go | 3 ++- defaults.go | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index fa9f1ca..23f4925 100644 --- a/client.go +++ b/client.go @@ -1001,7 +1001,7 @@ func (c *client) handleWeb(u Url) { if http.IsTextFile(u.Full) { page, err := http.Visit(wm, u.Full, c.Width-1) if err != nil { - c.SetMessage(fmt.Sprintf("Lynx error: %s", err.Error()), true) + c.SetMessage(fmt.Sprintf("%s error: %s", wm, err.Error()), true) c.DrawMessage() return } @@ -1032,6 +1032,7 @@ func (c *client) handleWeb(u Url) { } else { c.SetMessage(msg, false) } + c.DrawMessage() default: c.SetMessage("Current 'webmode' setting does not allow http/https", false) c.DrawMessage() diff --git a/defaults.go b/defaults.go index c14db8c..a89e7f5 100644 --- a/defaults.go +++ b/defaults.go @@ -53,7 +53,7 @@ var defaultOptions = map[string]string{ "theme": "normal", // "normal", "inverted" "tlscertificate": "", "tlskey": "", - "webmode": "none", // "none", "gui", "lynx", "w3m" + "webmode": "none", // "none", "gui", "lynx", "w3m", "elinks" } // homePath will return the path to your home directory as a string From 24fd98fa9b589518276939440346c985917d06b8 Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Thu, 14 Nov 2019 10:10:05 -0800 Subject: [PATCH 127/145] Added manpage updates as well as an update to using the gui for opening web content --- README.md | 8 ++++---- bombadillo.1 | 19 ++++++------------- http/open_browser_linux.go | 11 +++++++++++ http/open_browser_other.go | 2 +- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 8a64232..0ed41ae 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Bombadillo - a non-web client +# Bombadillo - a non-web browser -Bombadillo is a non-web client for the terminal. +Bombadillo is a non-web browser for the terminal. ![a screenshot of the bombadillo client](bombadillo-screenshot.png) @@ -18,7 +18,7 @@ Support for the following protocols is also available via integration with 3rd p * http/https * Web support is opt-in (turned off by default). * Links can be opened in a user's default web browser when in a graphical environment. - * Web pages can be rendered directly in Bombadillo if [Lynx](https://lynx.invisible-island.net/) is installed on the system to handle the document parsing. + * Web pages can be rendered directly in Bombadillo if [Lynx](https://lynx.invisible-island.net/), [w3m](http://w3m.sourceforge.net/), or [elinks](http://elinks.or.cz/) are installed on the system to handle the document parsing. ## Getting Started @@ -115,7 +115,7 @@ Bombadillo development is largely handled by Sloum, with help from asdf, jboverf There are many ways to contribute to Bombadillo, including a fair few that don't require knowledge of programming: -- Try out the client and let us know if you have a suggestion for improvement, or if you find a bug. +- Try out the browser and let us know if you have a suggestion for improvement, or if you find a bug. - Read the documentation and let us know if something isn't well explained, or needs correction. - Maybe you have a cool logo or some art that you think would look nice. diff --git a/bombadillo.1 b/bombadillo.1 index ce200fa..0258ae6 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -210,14 +210,6 @@ homeurl The url that \fBbombadillo\fP navigates to when the program loads or when the \fIhome\fP or \fIh\fP LINE COMMAND is issued. This should be a valid url. If a scheme/protocol is not included, gopher will be assumed. .TP .B -lynxmode -Sets whether or not to use lynx as a rendering engine for http/https requests, and display results in \fBbombadillo\fP. Lynx must be installed, and \fIopenhttp\fP must be set to \fItrue\fP. Valid values are \fItrue\fP and \fIfalse\fP. -.TP -.B -openhttp -Tells the client whether or not to try to follow web (http/https) links. If set to \fItrue\fP, \fBbombadillo\fP will try to open these links in a user's default web browser, or render them via lynx, depending on the status of \fIlynxmode\fP and \fIterminalonly\fP settings. Valid values are \fItrue\fP and \fIfalse\fP. -.TP -.B savelocation The path to the directory that \fBbombadillo\fP should write files to. This must be a valid filepath for the system, must be a directory, and must already exist. .TP @@ -227,11 +219,7 @@ The url to use for the LINE COMMANDs \fI?\fP and \fIsearch\fP. Should be a valid .TP .B telnetcommand -Tells the client what command to use to start a telnet session. Should be a valid command, including any flags. The address being navigated to will be added to the end of the command. -.TP -.B -terminalonly -Sets whether web links should handled within \fBbombadillo\fP only, or if they can be opened in a user's external web browser. If \fIopenhttp\fP is true, and this setting is true, web links will be handled within \fBbombadillo\fP only. If \fIlynxmode\fP is also true, web links will be rendered in bombadillo via lynx. If \fIopenhttp\fP is true, \fIlynxmode\fP is disabled, and this setting is disabled, \fBbombadillo\fP will open web links in a user's default web browser. Valid values are \fItrue\fP and \fIfalse\fP. +Tells the browser what command to use to start a telnet session. Should be a valid command, including any flags. The address being navigated to will be added to the end of the command. .TP .B theme @@ -244,6 +232,11 @@ A path to a tls certificate file on a user's local filesystem. Defaults to NULL. .B tlskey A path to a tls key that pairs with the tlscertificate setting, on a user's local filesystem. Defaults to NULL. Both \fItlskey\fP and \fItlscertificate\fP must be set for client certificates to work in gemini. +.TP +.B +webmode +Controls behavior when following web links. The following values are valid: \fInone\fP will disable following web links, \fIgui\fP will have the browser attempt to open web links in a user's default graphical web browser; \fIlynx\fP, \fIw3m\fP, and \fIelinks\fP will have the browser attempt to use the selected terminal web browser to handle the rendering of web pages and will display the pages directly in Bombadillo. + .SH BUGS There are very likely bugs. Many known bugs can be found in the issues section of \fBbombadillo\fP's source code repository (see \fIlinks\fP). .SH LINKS diff --git a/http/open_browser_linux.go b/http/open_browser_linux.go index dc99845..5be7640 100644 --- a/http/open_browser_linux.go +++ b/http/open_browser_linux.go @@ -5,6 +5,17 @@ package http import "os/exec" func OpenInBrowser(url string) (string, error) { + // Check for a local display server, this is + // not a silver bullet but should help ssh + // connected users on many systems get accurate + // messaging and not spin off processes needlessly + err := exec.Command("type", "Xorg").Run() + if err != nil { + return "", fmt.Errorf("No gui is available, check 'webmode' setting") + } + + // Use start rather than run or output in order + // to release the process and not block err := exec.Command("xdg-open", url).Start() if err != nil { return "", err diff --git a/http/open_browser_other.go b/http/open_browser_other.go index c6e5342..1388c6b 100644 --- a/http/open_browser_other.go +++ b/http/open_browser_other.go @@ -7,5 +7,5 @@ package http import "fmt" func OpenInBrowser(url string) (string, error) { - return "", fmt.Errorf("Unsupported os for browser detection") + return "", fmt.Errorf("Unsupported os for 'webmode' 'gui' setting") } From ef27e54d0e0d86faf259a17e21d8d7f3a59def50 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 14 Nov 2019 19:30:58 -0800 Subject: [PATCH 128/145] Fixes errors introduced by a distracted commit earlier, also handles linting --- http/http_render.go | 24 ++++++++++++++++-------- http/open_browser_linux.go | 26 ++++++++++++++++---------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/http/http_render.go b/http/http_render.go index ea2e987..f68ee2d 100644 --- a/http/http_render.go +++ b/http/http_render.go @@ -8,12 +8,16 @@ import ( "strings" ) -type page struct { +// Page represents the contents and links or an http/https document +type Page struct { Content string Links []string } -func Visit(webmode, url string, width int) (page, error) { +// Visit is the main entry to viewing a web document in bombadillo. +// It takes a url, a terminal width, and which web backend the user +// currently has set. Visit returns a Page and an error +func Visit(webmode, url string, width int) (Page, error) { if width > 80 { width = 80 } @@ -26,17 +30,18 @@ func Visit(webmode, url string, width int) (page, error) { case "elinks": w = "-dump-width" default: - return page{}, fmt.Errorf("Invalid webmode setting") + return Page{}, fmt.Errorf("Invalid webmode setting") } c, err := exec.Command(webmode, "-dump", w, fmt.Sprintf("%d", width), url).Output() if err != nil { - return page{}, err + return Page{}, err } return parseLinks(string(c)), nil } -// Returns false on err or non-text type -// Else returns true +// IsTextFile makes an http(s) head request to a given URL +// and determines if the content-type is text based. It then +// returns a bool func IsTextFile(url string) bool { resp, err := http.Head(url) if err != nil { @@ -50,8 +55,8 @@ func IsTextFile(url string) bool { return false } -func parseLinks(c string) page { - var out page +func parseLinks(c string) Page { + var out Page contentUntil := strings.LastIndex(c, "References") if contentUntil >= 1 { out.Content = c[:contentUntil] @@ -74,6 +79,9 @@ func parseLinks(c string) page { return out } +// Fetch makes an http(s) request and returns the []bytes +// for the response and an error. Fetch is used for saving +// the source file of an http(s) document func Fetch(url string) ([]byte, error) { resp, err := http.Get(url) if err != nil { diff --git a/http/open_browser_linux.go b/http/open_browser_linux.go index 5be7640..3b7dfee 100644 --- a/http/open_browser_linux.go +++ b/http/open_browser_linux.go @@ -2,21 +2,27 @@ package http -import "os/exec" +import ( + "fmt" + "os" + "os/exec" +) +// OpenInBrowser checks for the presence of a display server +// and environment variables indicating a gui is present. If found +// then xdg-open is called on a url to open said url in the default +// gui web browser for the system func OpenInBrowser(url string) (string, error) { - // Check for a local display server, this is - // not a silver bullet but should help ssh - // connected users on many systems get accurate - // messaging and not spin off processes needlessly - err := exec.Command("type", "Xorg").Run() - if err != nil { + disp := os.Getenv("DISPLAY") + wayland := os.Getenv("WAYLAND_DISPLAY") + _, err := exec.LookPath("Xorg") + if disp == "" && wayland == "" && err != nil { return "", fmt.Errorf("No gui is available, check 'webmode' setting") } - // Use start rather than run or output in order - // to release the process and not block - err := exec.Command("xdg-open", url).Start() + // Use start rather than run or output in order + // to release the process and not block + err = exec.Command("xdg-open", url).Start() if err != nil { return "", err } From 33a8c51de1a196e1d94729b7d5bd1d11fff3b2a1 Mon Sep 17 00:00:00 2001 From: asdf Date: Fri, 15 Nov 2019 15:19:47 +1100 Subject: [PATCH 129/145] Further changes to the man page for webmode --- bombadillo.1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bombadillo.1 b/bombadillo.1 index afcd4fc..7402a1d 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -46,11 +46,11 @@ Telnet is not supported directly, but addresses will be followed and opened as a .TP .B http, https -Neither of the world wide web protocols are supported directly. However, \fBbombadillo\fP can open web links in a user's default web browser, or display web content directly in the browser via the lynx web browser. Opening http/https links is opt-in only, controlled by the \fIopenhttp\fP setting. +Neither of the world wide web protocols are supported directly. \fBbombadillo\fP can be configured to open web links in a user's default graphical web browser. It is also possible to display web content directly in \fBbombadillo\fP using lynx, w3m, or elinks terminal web browsers to render pages. Opening http/https links is opt-in only, controlled by the \fIwebmode\fP setting. .IP -Opening links in a default web browser only works if a GUI environment is available. +Opening links in a default graphical web browser will only work in a GUI environment. .IP -Opening web content directly in the browser requires the lynx web browser, and is enabled using the \fIlynxmode\fP setting. Web content is processed using lynx, and then displayed in \fBbombadillo\fP. +Displaying web content directly in \fBbombadillo\fP requires lynx, w3m or elinks terminal web browsers are installed on the system. .SH COMMANDS .SS KEY COMMANDS These commands work as a single keypress anytime \fBbombadillo\fP is not taking in a line based command. This is the default command mode of \fBbombadillo\fP. From 88f26ff92b1e97b0d57d568d0f6e6626887848ea Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 14 Nov 2019 20:28:48 -0800 Subject: [PATCH 130/145] Adds bombadillo desktop settings and icon --- bombadillo-icon.png | Bin 0 -> 1351 bytes bombadillo.desktop | 6 ++++++ 2 files changed, 6 insertions(+) create mode 100644 bombadillo-icon.png create mode 100644 bombadillo.desktop diff --git a/bombadillo-icon.png b/bombadillo-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..6f10bd27eeb88abed32a57c3981de8aeec42a12f GIT binary patch literal 1351 zcmV-N1-SZ&P)EX>4Tx04R}tkv&MmKpe$iQ>CJn4t5Z6$WWauh)QwPDionYs1;guFuC*#ni!H4 z7e~Rh;NZt%)xpJCR|i)?5c~jfadlF3krMxx6k5c1aNLh~_a1le0HIN3n$4LKlt6PRh*pglEO)#`^9lSMu5;R(5ySo_p#$NPk`VvaHY5X8x3Iklk|F9 ziyZ-xZQ$a%ttorJaQ*6vsb{lY z!)|YLS;JCqE(V zE1p?t9MZ+iigN^MnWeMD`lHZNi}Wk8;z!+>R)$t`#EMOxo04mAM(~3Tez693n%|H( z!Rx1t4W-hNye*IXDN8wQ^iHyc6%1Mag1S9_SCec-=Xv!5iB)E^s6B37tY+PH2sT@A z)^t?t8+1mHGv8}|EzGCw6~1(+Aahs?dD~;?fyY8BrT1-}MKspZx8YmnBCV+0bvA>H zVQC{fRmPn@&EC_U@_naM|FUdDb=*Z)+u*t3a$_0vg_JM3=zU#_w<;=+TzI8D-i=u1 z2Cs9lDFCQkbkPaR9Wqz2q-u@cyYL3|W81t%vfNnHzgJ#+AoCB!k65tFWG#HRnZf2o zze7Jr^h~UT_6p&5O51RBAl3?tpfyj+AF;^p7K2#CA{McTMJxufh(#=75sO$1ViAj2#3I%TjbDJh>?<%{{G0#)002ov JPDHLkV1iW)ay Date: Thu, 14 Nov 2019 20:35:34 -0800 Subject: [PATCH 131/145] Removed unneeded settings --- main.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index a603682..ef01c34 100644 --- a/main.go +++ b/main.go @@ -66,11 +66,8 @@ func saveConfig() error { func validateOpt(opt, val string) bool { var validOpts = map[string][]string{ - "webmode": []string{"none", "gui", "lynx", "w3m", "elinks"}, - "openhttp": []string{"true", "false"}, - "theme": []string{"normal", "inverse"}, - "terminalonly": []string{"true", "false"}, - "lynxmode": []string{"true", "false"}, + "webmode": []string{"none", "gui", "lynx", "w3m", "elinks"}, + "theme": []string{"normal", "inverse"}, } opt = strings.ToLower(opt) @@ -89,7 +86,7 @@ func validateOpt(opt, val string) bool { func lowerCaseOpt(opt, val string) string { switch opt { - case "openhttp", "theme", "terminalonly": + case "webmode", "theme": return strings.ToLower(val) default: return val From f49f8bebdd53eac3a62dfff284e11474be978918 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 14 Nov 2019 21:46:28 -0800 Subject: [PATCH 132/145] Adds desktop entry and icon, plus build target for makefile --- Makefile | 11 ++++++++++- bombadillo.desktop | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d8d2c33..fedcd27 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ build: ${GOCMD} build ${LDFLAGS} -o ${BINARY} .PHONY: install -install: install-bin install-man clean +install: install-bin install-man install-desktop clean .PHONY: install-man install-man: bombadillo.1 @@ -34,6 +34,13 @@ install-man: bombadillo.1 install -d ${DESTDIR}${MAN1DIR} install -m 0644 ./bombadillo.1.gz ${DESTDIR}${MAN1DIR} +.PHONY: install-desktop +install-desktop: + install -d ${DESTDIR}${DATAROOTDIR}/applications + install -m 0644 ./bombadillo.desktop ${DESTDIR}${DATAROOTDIR}/applications + install -d ${DESTDIR}${DATAROOTDIR}/pixmaps + install -m 0644 ./bombadillo-icon.png ${DESTDIR}${DATAROOTDIR}/pixmaps + .PHONY: install-bin install-bin: build install -d ${DESTDIR}${BINDIR} @@ -48,6 +55,8 @@ clean: uninstall: clean rm -f ${DESTDIR}${MAN1DIR}/bombadillo.1.gz rm -f ${DESTDIR}${BINDIR}/${BINARY} + rm -f ${DESTDIR}${DATAROOTDIR}/applications/bombadillo.desktop + rm -f ${DESTDIR}${DATAROOTDIR}/pixmaps/bombadillo-icon.png .PHONY: test test: clean build diff --git a/bombadillo.desktop b/bombadillo.desktop index 1f4dd7a..6300fe7 100644 --- a/bombadillo.desktop +++ b/bombadillo.desktop @@ -1,6 +1,9 @@ [Desktop Entry] -Name=Bombadillo Type=Application +Name=Bombadillo +GenericName=Non-Web Browser +Comment=View gopher, gemini, finger, telnet, http(s) sites over the internet Terminal=true +Categories=Network;Application;WebBrowser;ConsoleOnly; Exec=bombadillo Icon=bombadillo-icon From 57ab1b085e73413a9ce3b4d6c49c7a246e6915a7 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 14 Nov 2019 22:20:12 -0800 Subject: [PATCH 133/145] Adds a default entry in the mime db for gopher, gemini, and finger --- Makefile | 3 +++ bombadillo.desktop | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index fedcd27..7da7f86 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,9 @@ install-desktop: install -m 0644 ./bombadillo.desktop ${DESTDIR}${DATAROOTDIR}/applications install -d ${DESTDIR}${DATAROOTDIR}/pixmaps install -m 0644 ./bombadillo-icon.png ${DESTDIR}${DATAROOTDIR}/pixmaps + xdg-mime default bombadillo.desktop x-scheme-handler/gopher + xdg-mime default bombadillo.desktop x-scheme-handler/gemini + xdg-mime default bombadillo.desktop x-scheme-handler/finger .PHONY: install-bin install-bin: build diff --git a/bombadillo.desktop b/bombadillo.desktop index 6300fe7..80b5c21 100644 --- a/bombadillo.desktop +++ b/bombadillo.desktop @@ -5,5 +5,6 @@ GenericName=Non-Web Browser Comment=View gopher, gemini, finger, telnet, http(s) sites over the internet Terminal=true Categories=Network;Application;WebBrowser;ConsoleOnly; -Exec=bombadillo +Exec=bombadillo %U Icon=bombadillo-icon +MimeType=x-scheme-handler/gopher;x-scheme-handler/gemini;x-scheme-handler/finger; From 35c580c9d0130c35c6ac8541e6185e88ca5265fd Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Fri, 15 Nov 2019 14:05:10 -0800 Subject: [PATCH 134/145] Removes protocol handler association for non-linux systems --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 7da7f86..c91c5a0 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,9 @@ install-man: bombadillo.1 .PHONY: install-desktop install-desktop: +ifeq ($(shell uname), Linux) + # These steps will not work on Darwin, Plan9, or Windows + # They would likely work on BSD systems install -d ${DESTDIR}${DATAROOTDIR}/applications install -m 0644 ./bombadillo.desktop ${DESTDIR}${DATAROOTDIR}/applications install -d ${DESTDIR}${DATAROOTDIR}/pixmaps @@ -43,6 +46,9 @@ install-desktop: xdg-mime default bombadillo.desktop x-scheme-handler/gopher xdg-mime default bombadillo.desktop x-scheme-handler/gemini xdg-mime default bombadillo.desktop x-scheme-handler/finger +else + @echo "* Skipping protocol handler associations and desktop file creation for non-linux system *" +endif .PHONY: install-bin install-bin: build From 3ee7bd9c7b32fc11c8c8abb8bbf677e55d4392c9 Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Fri, 15 Nov 2019 14:48:50 -0800 Subject: [PATCH 135/145] Makes local protocol navigable --- client.go | 4 ++-- local/local.go | 34 ++++++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 12 deletions(-) diff --git a/client.go b/client.go index 23f4925..ea75444 100644 --- a/client.go +++ b/client.go @@ -963,13 +963,13 @@ func (c *client) handleTelnet(u Url) { } func (c *client) handleLocal(u Url) { - content, err := local.Open(u.Resource) + content, links, err := local.Open(u.Resource) if err != nil { c.SetMessage(err.Error(), true) c.DrawMessage() return } - pg := MakePage(u, content, []string{}) + pg := MakePage(u, content, links) pg.WrapContent(c.Width - 1) c.PageState.Add(pg) c.SetPercentRead() diff --git a/local/local.go b/local/local.go index 430a499..f257cbe 100644 --- a/local/local.go +++ b/local/local.go @@ -4,39 +4,53 @@ import ( "fmt" "io/ioutil" "os" + "path/filepath" + "sort" "strings" ) -func Open(address string) (string, error) { +func Open(address string) (string, []string, error) { + links := make([]string, 0, 10) + if !pathExists(address) { - return "", fmt.Errorf("Invalid system path: %s", address) + return "", links, fmt.Errorf("Invalid system path: %s", address) } file, err := os.Open(address) if err != nil { - return "", fmt.Errorf("Unable to open file: %s", address) + return "", links, fmt.Errorf("Unable to open file: %s", address) } defer file.Close() if pathIsDir(address) { - fileList, err := file.Readdirnames(0) + fileList, err := file.Readdir(0) if err != nil { - return "", fmt.Errorf("Unable to read from directory: %s", address) + return "", links, fmt.Errorf("Unable to read from directory: %s", address) } var out strings.Builder out.WriteString(fmt.Sprintf("Current directory: %s\n\n", address)) - for _, obj := range fileList { - out.WriteString(obj) + + sort.Slice(fileList, func(i, j int) bool { + return fileList[i].Name() < fileList[j].Name() + }) + + for i, obj := range fileList { + linkNum := fmt.Sprintf("[%d]", i+1) + out.WriteString(fmt.Sprintf("%-5s ", linkNum)) + out.WriteString(fmt.Sprintf("%s ", obj.Mode().String())) + out.WriteString(obj.Name()) out.WriteString("\n") + fp := filepath.Join(address, obj.Name()) + links = append(links, fp) } - return out.String(), nil + return out.String(), links, nil } bytes, err := ioutil.ReadAll(file) if err != nil { - return "", fmt.Errorf("Unable to read file: %s", address) + return "", links ,fmt.Errorf("Unable to read file: %s", address) } - return string(bytes), nil + return string(bytes), links, nil } func pathExists(p string) bool { From c948be18dcd0e0c423f40563451c3fa366aca041 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sat, 16 Nov 2019 17:38:11 -0800 Subject: [PATCH 136/145] Adds better formatting/options for local protocol directory listings --- local/local.go | 41 +++++++++++++++++++++++++++++------------ page.go | 2 +- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/local/local.go b/local/local.go index f257cbe..1948ec7 100644 --- a/local/local.go +++ b/local/local.go @@ -4,13 +4,13 @@ import ( "fmt" "io/ioutil" "os" - "path/filepath" - "sort" + "path/filepath" + "sort" "strings" ) func Open(address string) (string, []string, error) { - links := make([]string, 0, 10) + links := make([]string, 0, 10) if !pathExists(address) { return "", links, fmt.Errorf("Invalid system path: %s", address) @@ -23,6 +23,7 @@ func Open(address string) (string, []string, error) { defer file.Close() if pathIsDir(address) { + offset := 1 fileList, err := file.Readdir(0) if err != nil { return "", links, fmt.Errorf("Unable to read from directory: %s", address) @@ -30,25 +31,41 @@ func Open(address string) (string, []string, error) { var out strings.Builder out.WriteString(fmt.Sprintf("Current directory: %s\n\n", address)) - sort.Slice(fileList, func(i, j int) bool { - return fileList[i].Name() < fileList[j].Name() - }) + if address != "/" { + offset = 2 + upFp := filepath.Join(address, "..") + upOneLevel, _ := filepath.Abs(upFp) + info, err := os.Stat(upOneLevel) + if err == nil { + out.WriteString("[1] ") + out.WriteString(fmt.Sprintf("%-12s ", info.Mode().String())) + out.WriteString("../\n") + links = append(links, upOneLevel) + } + } + + sort.Slice(fileList, func(i, j int) bool { + return fileList[i].Name() < fileList[j].Name() + }) for i, obj := range fileList { - linkNum := fmt.Sprintf("[%d]", i+1) - out.WriteString(fmt.Sprintf("%-5s ", linkNum)) - out.WriteString(fmt.Sprintf("%s ", obj.Mode().String())) + linkNum := fmt.Sprintf("[%d]", i+offset) + out.WriteString(fmt.Sprintf("%-5s ", linkNum)) + out.WriteString(fmt.Sprintf("%-12s ", obj.Mode().String())) out.WriteString(obj.Name()) + if obj.IsDir() { + out.WriteString("/") + } out.WriteString("\n") - fp := filepath.Join(address, obj.Name()) - links = append(links, fp) + fp := filepath.Join(address, obj.Name()) + links = append(links, fp) } return out.String(), links, nil } bytes, err := ioutil.ReadAll(file) if err != nil { - return "", links ,fmt.Errorf("Unable to read file: %s", address) + return "", links, fmt.Errorf("Unable to read file: %s", address) } return string(bytes), links, nil } diff --git a/page.go b/page.go index 734fab4..4c8c0d8 100644 --- a/page.go +++ b/page.go @@ -70,7 +70,7 @@ func (p *Page) WrapContent(width int) { content.WriteRune('\n') counter = 0 } - } else if ch == '\r' || ch == '\v' || ch == '\b' || ch == '\f' { + } else if ch == '\r' || ch == '\v' || ch == '\b' || ch == '\f' || ch == '\a' { // Get rid of control characters we dont want continue } else if ch == 27 { From 8e4091aac14b33687d0f82f786d0e2ca08567d1e Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 17 Nov 2019 14:58:43 -0800 Subject: [PATCH 137/145] Simplifies .. navigation and passes actual errors --- local/local.go | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/local/local.go b/local/local.go index 1948ec7..07adc57 100644 --- a/local/local.go +++ b/local/local.go @@ -18,7 +18,7 @@ func Open(address string) (string, []string, error) { file, err := os.Open(address) if err != nil { - return "", links, fmt.Errorf("Unable to open file: %s", address) + return "", links, err } defer file.Close() @@ -26,28 +26,29 @@ func Open(address string) (string, []string, error) { offset := 1 fileList, err := file.Readdir(0) if err != nil { - return "", links, fmt.Errorf("Unable to read from directory: %s", address) + return "", links, err } var out strings.Builder out.WriteString(fmt.Sprintf("Current directory: %s\n\n", address)) - if address != "/" { - offset = 2 - upFp := filepath.Join(address, "..") - upOneLevel, _ := filepath.Abs(upFp) - info, err := os.Stat(upOneLevel) - if err == nil { - out.WriteString("[1] ") - out.WriteString(fmt.Sprintf("%-12s ", info.Mode().String())) - out.WriteString("../\n") - links = append(links, upOneLevel) - } + // Handle 'addres/..' display + offset = 2 + upFp := filepath.Join(address, "..") + upOneLevel, _ := filepath.Abs(upFp) + info, err := os.Stat(upOneLevel) + if err == nil { + out.WriteString("[1] ") + out.WriteString(fmt.Sprintf("%-12s ", info.Mode().String())) + out.WriteString("../\n") + links = append(links, upOneLevel) } + // Sort the directory contents alphabetically sort.Slice(fileList, func(i, j int) bool { return fileList[i].Name() < fileList[j].Name() }) + // Handle each item in the directory for i, obj := range fileList { linkNum := fmt.Sprintf("[%d]", i+offset) out.WriteString(fmt.Sprintf("%-5s ", linkNum)) @@ -65,7 +66,7 @@ func Open(address string) (string, []string, error) { bytes, err := ioutil.ReadAll(file) if err != nil { - return "", links, fmt.Errorf("Unable to read file: %s", address) + return "", links, err } return string(bytes), links, nil } From c089041cf8a50cc0474fc152b9afa05764bd4eb7 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Sun, 17 Nov 2019 17:01:38 -0800 Subject: [PATCH 138/145] Makes xdg-mime fail without halting the makefile --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 7da7f86..0eadfe3 100644 --- a/Makefile +++ b/Makefile @@ -40,9 +40,9 @@ install-desktop: install -m 0644 ./bombadillo.desktop ${DESTDIR}${DATAROOTDIR}/applications install -d ${DESTDIR}${DATAROOTDIR}/pixmaps install -m 0644 ./bombadillo-icon.png ${DESTDIR}${DATAROOTDIR}/pixmaps - xdg-mime default bombadillo.desktop x-scheme-handler/gopher - xdg-mime default bombadillo.desktop x-scheme-handler/gemini - xdg-mime default bombadillo.desktop x-scheme-handler/finger + -xdg-mime default bombadillo.desktop x-scheme-handler/gopher + -xdg-mime default bombadillo.desktop x-scheme-handler/gemini + -xdg-mime default bombadillo.desktop x-scheme-handler/finger .PHONY: install-bin install-bin: build From 26c4b176c0980e4ec600be0e6c0a590025442c4e Mon Sep 17 00:00:00 2001 From: Brian Evans Date: Mon, 18 Nov 2019 15:44:32 -0800 Subject: [PATCH 139/145] Updates the set command to disallow configlocation and updates associated man apge entry --- bombadillo.1 | 4 ++++ client.go | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bombadillo.1 b/bombadillo.1 index 7402a1d..d716ee0 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -206,6 +206,10 @@ Writes data from a given link id in the current document to a file. The file is The following is a list of the settings that \fBbombadillo\fP recognizes, as well as a description of their valid values. .TP .B +configlocation +The path to the directory that the \fI.bombadillo.ini\fP configuration file is stored in. This is a \fBread only\fP setting and cannot be changed with the \fIset\fP command, but it can be read with the \fIcheck\fP command. +.TP +.B homeurl The url that \fBbombadillo\fP navigates to when the program loads or when the \fIhome\fP or \fIh\fP LINE COMMAND is issued. This should be a valid url. If a scheme/protocol is not included, gopher will be assumed. .TP diff --git a/client.go b/client.go index ea75444..2693ad0 100644 --- a/client.go +++ b/client.go @@ -410,7 +410,11 @@ func (c *client) doCommandAs(action string, values []string) { c.Options[values[0]] = lowerCaseOpt(values[0], val) if values[0] == "tlskey" || values[0] == "tlscertificate" { c.Certs.LoadCertificate(c.Options["tlscertificate"], c.Options["tlskey"]) - } + } else if values[0] == "configlocation" { + c.SetMessage("Cannot set READ ONLY setting 'configlocation'", true) + c.DrawMessage() + return + } err := saveConfig() if err != nil { c.SetMessage("Value set, but error saving config to file", true) From 82b47d8c86efc8a380faefd5077ea907c92cdab7 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Fri, 22 Nov 2019 19:17:21 -0800 Subject: [PATCH 140/145] Removes a deprecated category from desktop file --- bombadillo.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bombadillo.desktop b/bombadillo.desktop index 80b5c21..3ca2531 100644 --- a/bombadillo.desktop +++ b/bombadillo.desktop @@ -4,7 +4,7 @@ Name=Bombadillo GenericName=Non-Web Browser Comment=View gopher, gemini, finger, telnet, http(s) sites over the internet Terminal=true -Categories=Network;Application;WebBrowser;ConsoleOnly; +Categories=Network;WebBrowser;ConsoleOnly; Exec=bombadillo %U Icon=bombadillo-icon MimeType=x-scheme-handler/gopher;x-scheme-handler/gemini;x-scheme-handler/finger; From 0c0ce2ceb17ea9aed3eea3d8de7e7ec3cfb97600 Mon Sep 17 00:00:00 2001 From: asdf Date: Sun, 24 Nov 2019 08:19:38 +1100 Subject: [PATCH 141/145] Use update-desktop-database instead of xdg-mime --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 631b32a..5759793 100644 --- a/Makefile +++ b/Makefile @@ -43,9 +43,7 @@ ifeq ($(shell uname), Linux) install -m 0644 ./bombadillo.desktop ${DESTDIR}${DATAROOTDIR}/applications install -d ${DESTDIR}${DATAROOTDIR}/pixmaps install -m 0644 ./bombadillo-icon.png ${DESTDIR}${DATAROOTDIR}/pixmaps - -xdg-mime default bombadillo.desktop x-scheme-handler/gopher - -xdg-mime default bombadillo.desktop x-scheme-handler/gemini - -xdg-mime default bombadillo.desktop x-scheme-handler/finger + -update-desktop-database 2> /dev/null else @echo "* Skipping protocol handler associations and desktop file creation for non-linux system *" endif @@ -66,6 +64,8 @@ uninstall: clean rm -f ${DESTDIR}${BINDIR}/${BINARY} rm -f ${DESTDIR}${DATAROOTDIR}/applications/bombadillo.desktop rm -f ${DESTDIR}${DATAROOTDIR}/pixmaps/bombadillo-icon.png + -update-desktop-database 2> /dev/null + .PHONY: test test: clean build From ebd33c6dbd47046333b3c0a7ea429ccd0788b9e6 Mon Sep 17 00:00:00 2001 From: asdf Date: Tue, 26 Nov 2019 12:24:16 +1100 Subject: [PATCH 142/145] Remove unused functions getCurrentPageRawData & getCurrentPageUrl --- client.go | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/client.go b/client.go index 2693ad0..f106f8b 100644 --- a/client.go +++ b/client.go @@ -414,7 +414,7 @@ func (c *client) doCommandAs(action string, values []string) { c.SetMessage("Cannot set READ ONLY setting 'configlocation'", true) c.DrawMessage() return - } + } err := saveConfig() if err != nil { c.SetMessage("Value set, but error saving config to file", true) @@ -483,20 +483,6 @@ func (c *client) doLinkCommandAs(action, target string, values []string) { } } -func (c *client) getCurrentPageUrl() (string, error) { - if c.PageState.Length < 1 { - return "", fmt.Errorf("There are no pages in history") - } - return c.PageState.History[c.PageState.Position].Location.Full, nil -} - -func (c *client) getCurrentPageRawData() (string, error) { - if c.PageState.Length < 1 { - return "", fmt.Errorf("There are no pages in history") - } - return c.PageState.History[c.PageState.Position].RawContent, nil -} - func (c *client) saveFile(u Url, name string) { var file []byte var err error From 67293823e0be96318f404eed7a77900c2a5fc9d7 Mon Sep 17 00:00:00 2001 From: asdf Date: Wed, 27 Nov 2019 18:37:39 +1100 Subject: [PATCH 143/145] Change c.Visit(u) call to blocking, from goroutine --- client.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index 2693ad0..3675ae0 100644 --- a/client.go +++ b/client.go @@ -414,7 +414,7 @@ func (c *client) doCommandAs(action string, values []string) { c.SetMessage("Cannot set READ ONLY setting 'configlocation'", true) c.DrawMessage() return - } + } err := saveConfig() if err != nil { c.SetMessage("Value set, but error saving config to file", true) @@ -817,7 +817,7 @@ func (c *client) goToURL(u string) { return } - go c.Visit(u) + c.Visit(u) } func (c *client) goToLink(l string) { From 0f670623bd2e4941464e11f379562b30dddf1a97 Mon Sep 17 00:00:00 2001 From: sloumdrone Date: Thu, 28 Nov 2019 12:17:22 -0800 Subject: [PATCH 144/145] Corrects a word in the readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ce879ef..f965945 100644 --- a/README.md +++ b/README.md @@ -93,7 +93,7 @@ If you used a custom `PREFIX` value during install, you will need to supply it w sudo make uninstall PREFIX=/some/directory ``` -Uninstall will clean up any build files, remove the installed binary, and remove the man page from the system. If will _not_ remove any directories created as a part of the installation, nor will it remove any Bombadillo user configuration files. +Uninstall will clean up any build files, remove the installed binary, and remove the man page from the system. It will _not_ remove any directories created as a part of the installation, nor will it remove any Bombadillo user configuration files. #### Troubleshooting From 16d6b8e2437a19654928cb43615cac73b31d6ff4 Mon Sep 17 00:00:00 2001 From: asdf Date: Sun, 1 Dec 2019 13:17:03 +1100 Subject: [PATCH 145/145] Man page final review --- bombadillo.1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bombadillo.1 b/bombadillo.1 index d716ee0..e393ecc 100644 --- a/bombadillo.1 +++ b/bombadillo.1 @@ -53,7 +53,7 @@ Opening links in a default graphical web browser will only work in a GUI environ Displaying web content directly in \fBbombadillo\fP requires lynx, w3m or elinks terminal web browsers are installed on the system. .SH COMMANDS .SS KEY COMMANDS -These commands work as a single keypress anytime \fBbombadillo\fP is not taking in a line based command. This is the default command mode of \fBbombadillo\fP. +These commands work as a single keypress anytime \fBbombadillo\fP is not taking in a line based command or when the user is being prompted for action. This is the default command mode of \fBbombadillo\fP. .TP .B b @@ -93,7 +93,7 @@ Quit \fBbombadillo\fP. .TP .B R -Reload the current page (does not destroy forward history) +Reload the current page (does not destroy forward history). .TP .B u