shithub: hell

Download patch

ref: ca2ae011d88d237ecd88afcb26a69bf137d3eb57
parent: a20b17aaece69ffc9854e3b35ccea5162019e7ff
author: penny <penny@limitedideas.org>
date: Wed Oct 8 18:18:18 EDT 2025

break everything

--- a/hellclient.go
+++ b/hellclient.go
@@ -20,6 +20,7 @@
 	prefix  string
 	ref     string
 	postmap map[string]*mastodon.Status
+	urlmap  map[string][]string
 }
 
 type Hellclient struct {
@@ -44,7 +45,6 @@
 	homeref *postref
 	//Contextual indexes for commands
 	ctxref       *postref
-	urlMap       map[string][]string
 	debugMap     map[string]any
 	actionBuffer []func()
 
@@ -155,16 +155,20 @@
 	}()
 
 	homeMap := make(map[string]*mastodon.Status)
+	urlMap := make(map[string][]string)
 
 	ctxref := &postref{
 		prefix:  "?",
 		ref:     "a",
 		postmap: homeMap,
+		urlmap:  urlMap,
+		
 	}
 
 	homeref := &postref{
 		ref:     "a",
 		postmap: homeMap,
+		urlmap:  urlMap,
 	}
 
 	prompt := &PromptBar{prompt: "Hell> ", rl: rl}
@@ -179,7 +183,6 @@
 	}
 
 	debugMap := make(map[string]any)
-	urlMap := make(map[string][]string)
 	prefs := &account.Preferences
 	hc = Hellclient{rl: rl,
 		homeMap:     homeMap,
@@ -188,7 +191,6 @@
 		prompt:      prompt,
 		debugMap:    debugMap,
 		isPaused:    false,
-		urlMap:      urlMap,
 		client:      client,
 		currentuser: currentuser,
 		dispatch:    dispatch,
--- a/main.go
+++ b/main.go
@@ -303,11 +303,11 @@
 				if err != nil {
 					urlindex = 1
 				}
-				if urlindex > len(hc.urlMap[index]) {
+				if urlindex > len(hc.homeref.urlmap[index]) {
 					fmt.Printf("Bad url index\n")
 					return
 				}
-				openItemInOS(hc.preferences.Browser, hc.urlMap[index][urlindex-1])
+				openItemInOS(hc.preferences.Browser, hc.homeref.urlmap[index][urlindex-1])
 				return
 			case "view":
 				err := hc.previewPostImages(postItem, hc.preferences.ImageViewer)
--- a/renderer.go
+++ b/renderer.go
@@ -12,7 +12,6 @@
 )
 
 type StatusFormatter struct {
-	hc          *Hellclient
 	status      *mastodon.Status
 	postContext *postref
 	notif       *mastodon.Notification
@@ -29,7 +28,7 @@
 
 // Returns the rendered content of a status
 func (st *StatusFormatter) statusContent(status *mastodon.Status) string {
-	renderedPost, plaintexts := st.hc.renderStatus(status.Content, st.postContext.ref)
+	renderedPost, plaintexts := st.postContext.renderStatus(status.Content, st.postContext.ref)
 	for key, plaintext := range plaintexts {
 		renderedPost = strings.Replace(renderedPost, key, plaintext, 1)
 	}
@@ -181,7 +180,7 @@
 	return usr.username()
 }
 
-func (hc *Hellclient) renderStatus(content string, index string) (string, map[string]string) {
+func (pr *postref) renderStatus(content string, index string) (string, map[string]string) {
 	doc, err := html.Parse(strings.NewReader(content))
 	if err != nil {
 		fmt.Printf("Failed to parse status\n")
@@ -189,13 +188,13 @@
 	}
 
 	//clear out the url map
-	hc.urlMap[index] = []string{}
+	pr.urlmap[index] = []string{}
 	preformats := make(map[string]string)
 
 	for node := range doc.Descendants() {
 		if (node.Data == "pre" || node.Data == "") && node.FirstChild != nil {
-			preformats[fmt.Sprintf("%p%p", hc, node.FirstChild)] = node.FirstChild.Data
-			node.FirstChild.Data = fmt.Sprintf("%p%p", hc, node.FirstChild)
+			preformats[fmt.Sprintf("%p%p", pr, node.FirstChild)] = node.FirstChild.Data
+			node.FirstChild.Data = fmt.Sprintf("%p%p", pr, node.FirstChild)
 		}
 		if node.Data == "a" && node.Type == html.ElementNode {
 			ismention := false
@@ -218,10 +217,10 @@
 				}
 			}
 			if !ismention {
-				hc.urlMap[index] = append(hc.urlMap[index], href)
+				pr.urlmap[index] = append(pr.urlmap[index], href)
 				refnode := &html.Node{
 					Type: html.TextNode,
-					Data: fmt.Sprintf(" [%v]", len(hc.urlMap[index]))}
+					Data: fmt.Sprintf(" [%v]", len(pr.urlmap[index]))}
 				if node.Parent != nil {
 					node.Parent.InsertBefore(refnode, node.NextSibling)
 				}
--