From b4288f3c47a9ff9254b933dcb9ee7274d4a4135c Mon Sep 17 00:00:00 2001 From: Tobi Smethurst <31960611+tsmethurst@users.noreply.github.com> Date: Sun, 13 Jun 2021 18:42:28 +0200 Subject: Timeline manager (#40) * start messing about with timeline manager * i have no idea what i'm doing * i continue to not know what i'm doing * it's coming along * bit more progress * update timeline with new posts as they come in * lint and fmt * Select accounts where empty string * restructure a bunch, get unfaves working * moving stuff around * federate status deletes properly * mention regex better but not 100% there * fix regex * some more hacking away at the timeline code phew * fix up some little things * i can't even * more timeline stuff * move to ulid * fiddley * some lil fixes for kibou compatibility * timelines working pretty alright! * tidy + lint --- internal/util/statustools.go | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) (limited to 'internal/util/statustools.go') diff --git a/internal/util/statustools.go b/internal/util/statustools.go index 8f9cb795c..b51f2c80c 100644 --- a/internal/util/statustools.go +++ b/internal/util/statustools.go @@ -35,7 +35,7 @@ func DeriveMentionsFromStatus(status string) []string { for _, m := range mentionFinderRegex.FindAllStringSubmatch(status, -1) { mentionedAccounts = append(mentionedAccounts, m[1]) } - return lower(unique(mentionedAccounts)) + return unique(mentionedAccounts) } // DeriveHashtagsFromStatus takes a plaintext (ie., not html-formatted) status, @@ -47,7 +47,7 @@ func DeriveHashtagsFromStatus(status string) []string { for _, m := range hashtagFinderRegex.FindAllStringSubmatch(status, -1) { tags = append(tags, m[1]) } - return lower(unique(tags)) + return unique(tags) } // DeriveEmojisFromStatus takes a plaintext (ie., not html-formatted) status, @@ -59,7 +59,7 @@ func DeriveEmojisFromStatus(status string) []string { for _, m := range emojiFinderRegex.FindAllStringSubmatch(status, -1) { emojis = append(emojis, m[1]) } - return lower(unique(emojis)) + return unique(emojis) } // ExtractMentionParts extracts the username test_user and the domain example.org @@ -94,24 +94,3 @@ func unique(s []string) []string { } return list } - -// lower lowercases all strings in a given string slice -func lower(s []string) []string { - new := []string{} - for _, i := range s { - new = append(new, strings.ToLower(i)) - } - return new -} - -// HTMLFormat takes a plaintext formatted status string, and converts it into -// a nice HTML-formatted string. -// -// This includes: -// - Replacing line-breaks with

-// - Replacing URLs with hrefs. -// - Replacing mentions with links to that account's URL as stored in the database. -func HTMLFormat(status string) string { - // TODO: write proper HTML formatting logic for a status - return status -} -- cgit v1.2.3