shithub: hell

Download patch

ref: 3ea29357e9eb81b737771148c22b6aff39031b7e
parent: 6194f0a9b9760f22a4bc0fc27cd37c2113c89a68
author: penny <penny@limitedideas.org>
date: Tue Nov 11 17:05:37 EST 2025

primitive poll renderer

--- a/renderer.go
+++ b/renderer.go
@@ -4,6 +4,7 @@
 	"bytes"
 	"fmt"
 	"strings"
+	"math"
 
 	"github.com/k3a/html2text"
 
@@ -34,7 +35,8 @@
 	for key, plaintext := range plaintexts {
 		renderedPost = strings.Replace(renderedPost, key, plaintext, 1)
 	}
-	return renderedPost
+	poller := &poll_renderer{st}
+	return renderedPost + poller.String()
 }
 
 func (st *StatusFormatter) mediaDescriptions(reblog bool) string {
@@ -219,7 +221,25 @@
 	return usr.username_full()
 }
 
+type poll_renderer struct {
+	*StatusFormatter
+}
 
+func (poll *poll_renderer) String() string {
+	if poll.status.Poll != nil {
+		var sb strings.Builder
+		sb.WriteString("\n")
+		total := poll.status.Poll.VotesCount
+		for _, item := range poll.status.Poll.Options {
+			sb.WriteString(item.Title)
+			sb.WriteString(" ")
+			percent := math.Round(float64(item.VotesCount) / float64(total) * 100)
+			sb.WriteString(fmt.Sprintf("%v%%\n", percent))
+		}
+		return sb.String()
+	}
+	return ""
+}
 
 func (pr *postref) renderStatus(content string, index string) (string, map[string]string) {
 	doc, err := html.Parse(strings.NewReader(content))
--- a/todo.md
+++ b/todo.md
@@ -27,6 +27,7 @@
  - [ ] authorize oauth tokens
  - [ ] plaintext => self authorize oauth
  - [ ] -h and -w to specify size of output
+ - [ ] /history to view edit history
  - [x] Hashtags work in /edit
  - [x] Thread context in /cat
  - [x] label hellclient
--