Documentation
¶
Index ¶
- Constants
- func ConvertPrivateKeyToPKCS8(pkcs1PEM string) (string, error)
- func ConvertPublicKeyToPKIX(pkcs1PEM string) (string, error)
- func CountVisibleChars(text string) int
- func DateTimeFormat() string
- func ExtractMarkdownLinks(text string) []string
- func FormatClickableURL(url string, maxWidth int, prefix string) string
- func GetConfigDir() (string, error)
- func GetLogWriter() io.Writer
- func GetMarkdownLinkCount(text string) int
- func GetNameAndVersion() string
- func GetVersion() string
- func HashtagsToActivityPubHTML(text string, baseURL string) string
- func HighlightHashtagsHTML(text string) string
- func HighlightHashtagsTerminal(text string) string
- func HighlightMentionsHTML(text string, localDomain string) string
- func HighlightMentionsTerminal(text string, localDomain string) string
- func IsURL(text string) bool
- func IsValidWebFingerUsername(username string) (bool, string)
- func LinkifyRawURLsHTML(text string) string
- func LinkifyRawURLsTerminal(text string) string
- func LoadAvatarImage(avatarURL string) image.Image
- func LoadDefaultAvatarImage() image.Image
- func LoadRemoteAvatarImage(url string) image.Image
- func LogPublicKey(s ssh.Session)
- func MarkdownLinksToHTML(text string) string
- func MarkdownLinksToTerminal(text string) string
- func MentionsToActivityPubHTML(text string, mentionURIs map[string]string) string
- func NormalizeEmojis(text string) string
- func NormalizeInput(text string) string
- func ParseActivityPubURL(urlStr string) (username string, domain string, ok bool)
- func ParseHashtags(text string) []string
- func PkToHash(pk string) string
- func PrettyPrint(i any) string
- func PublicKeyToString(s ssh.PublicKey) string
- func RandomString(length int) string
- func RenderImageToHalfBlocks(img image.Image, cols, rows int) string
- func ReplacePlaceholders(text string, sshPort int) string
- func ResolveFilePath(filename string) string
- func ResolveFilePathWithSubdir(subdir, filename string) string
- func SanitizeRemoteContent(text string) string
- func SetupLogging(withJournald bool)
- func StripHTMLTags(html string) string
- func TruncateContent(s string, maxLen int) string
- func TruncateVisibleLength(s string, maxLen int) string
- func UnescapeHTML(text string) string
- func ValidateNoteLength(text string) error
- type AppConfig
- type ErrMsg
- type Mention
- type RsaKeyPair
Constants ¶
const (
AppConfigDir = ".config/stegodon"
)
const ConfigFileName = "config.yaml"
const Name = "stegodon"
Variables ¶
This section is empty.
Functions ¶
func ConvertPrivateKeyToPKCS8 ¶ added in v1.2.2
ConvertPrivateKeyToPKCS8 converts a PKCS#1 private key PEM to PKCS#8 format The cryptographic key material remains unchanged, only the encoding format changes
func ConvertPublicKeyToPKIX ¶ added in v1.2.2
ConvertPublicKeyToPKIX converts a PKCS#1 public key PEM to PKIX (PKCS#8 public) format The cryptographic key material remains unchanged, only the encoding format changes
func CountVisibleChars ¶ added in v1.2.1
CountVisibleChars counts only the visible characters (runes) in text, ignoring: - Markdown links [text](url) - only the 'text' portion is counted - ANSI escape sequences (SGR codes like \033[38;5;75m) - OSC 8 hyperlinks (\033]8;;url\033\\text\033]8;;\033\\) This function counts Unicode runes, not bytes, so multi-byte characters like "·" (middle dot) are counted as 1 visible character.
func DateTimeFormat ¶
func DateTimeFormat() string
func ExtractMarkdownLinks ¶ added in v1.1.0
ExtractMarkdownLinks returns a list of URLs from Markdown links in text
func FormatClickableURL ¶ added in v1.5.0
FormatClickableURL creates an OSC 8 hyperlink for a URL with optional prefix The URL is truncated to maxWidth (visible characters only) and rendered as a clickable terminal link Returns the formatted link string ready for display
func GetConfigDir ¶ added in v1.1.0
GetConfigDir returns the stegodon config directory path (~/.config/stegodon/) and creates it if it doesn't exist
func GetLogWriter ¶ added in v1.2.3
GetLogWriter returns the current log writer (for use by other packages)
func GetMarkdownLinkCount ¶ added in v1.4.2
GetMarkdownLinkCount returns the number of valid markdown links in the text
func GetNameAndVersion ¶
func GetNameAndVersion() string
func GetVersion ¶
func GetVersion() string
func HashtagsToActivityPubHTML ¶ added in v1.4.0
HashtagsToActivityPubHTML converts hashtags in text to ActivityPub-compliant HTML links. Uses the format: <a href="https://hostname/tags/tag" class="hashtag" rel="tag">#<span>tag</span></a> The baseURL should be the full https:// URL of the server (e.g., "https://example.com")
func HighlightHashtagsHTML ¶ added in v1.4.0
HighlightHashtagsHTML converts hashtags in text to clickable HTML links. Each hashtag becomes a link to /tags/{tag} page.
func HighlightHashtagsTerminal ¶ added in v1.4.0
HighlightHashtagsTerminal colors hashtags in text for terminal display. Uses secondary color for hashtags to make them visually distinct.
func HighlightMentionsHTML ¶ added in v1.4.0
HighlightMentionsHTML converts mentions in text to clickable HTML links. For local users (same domain), displays as @username and links to /users/{username}. For remote users, displays as @username@domain and links to their profile URL.
func HighlightMentionsTerminal ¶ added in v1.4.0
HighlightMentionsTerminal colors mentions in text for terminal display and makes them clickable. Uses mention color with OSC 8 hyperlinks to the user's profile. Local users are displayed as @username, remote users as @username@domain.
func IsValidWebFingerUsername ¶ added in v1.3.1
IsValidWebFingerUsername validates that a username meets WebFinger/ActivityPub requirements.
WebFinger allows these characters without percent-encoding: A-Z a-z 0-9 - . _ ~ ! $ & ' ( ) * + , ; =
Any other Unicode character (like ä, 字, 🔥) must be percent-encoded and is rejected here. Non-printable/control characters are also rejected.
Returns (true, "") if valid, or (false, "error message") if invalid.
func LinkifyRawURLsHTML ¶ added in v1.6.0
LinkifyRawURLsHTML converts raw URLs in text to HTML anchor tags. This should be called AFTER MarkdownLinksToHTML to avoid double-linkifying. URLs that are already inside <a> tags (from markdown conversion) are skipped.
func LinkifyRawURLsTerminal ¶ added in v1.6.0
LinkifyRawURLsTerminal converts raw URLs in text to OSC 8 terminal hyperlinks. This should be called AFTER MarkdownLinksToTerminal to avoid double-linkifying.
func LoadAvatarImage ¶ added in v1.6.2
LoadAvatarImage loads an avatar image from disk given a relative URL like /avatars/{uuid}.png. Returns nil if the URL is empty, the file doesn't exist, or decoding fails.
func LoadDefaultAvatarImage ¶ added in v1.6.3
LoadDefaultAvatarImage returns the embedded stegodon logo as a fallback avatar.
func LoadRemoteAvatarImage ¶ added in v1.7.0
LoadRemoteAvatarImage fetches an avatar image from a remote URL. Returns nil if the URL is empty, the request fails, or decoding fails. Uses a 5-second timeout to avoid blocking on slow/unresponsive servers.
func LogPublicKey ¶
func MarkdownLinksToHTML ¶ added in v1.1.0
MarkdownLinksToHTML converts Markdown links [text](url) to HTML <a> tags
func MarkdownLinksToTerminal ¶ added in v1.1.0
MarkdownLinksToTerminal converts Markdown links [text](url) to OSC 8 hyperlinks Format: OSC 8 wrapped link text only (no URL shown) For terminals that support OSC 8, this creates clickable links with link color
func MentionsToActivityPubHTML ¶ added in v1.4.0
MentionsToActivityPubHTML converts mentions in text to ActivityPub-compliant HTML links. Uses the format: <span class="h-card"><a href="actorURI" class="u-url mention">@<span>username</span></a></span> This requires pre-resolved actor URIs, so it takes a map of mention -> actorURI.
func NormalizeEmojis ¶ added in v1.6.2
NormalizeEmojis is an alias for SanitizeRemoteContent for backwards compatibility
func NormalizeInput ¶
func ParseActivityPubURL ¶ added in v1.5.0
ParseActivityPubURL attempts to extract username and domain from an ActivityPub profile URL. Supports common URL patterns: - https://example.com/u/username (stegodon format) - https://example.com/@username (mastodon format) - https://example.com/users/username (common activitypub format) - example.com/u/username (will automatically add https://) Returns username, domain, and true if successfully parsed; empty strings and false otherwise.
func ParseHashtags ¶ added in v1.4.0
ParseHashtags extracts hashtags from text and returns them as lowercase, deduplicated strings. Hashtags must start with a letter and can contain letters, numbers, and underscores. Examples: #hello, #Go123, #my_tag are valid; #123, #_ are not.
func PrettyPrint ¶
func PublicKeyToString ¶
func RandomString ¶
func RenderImageToHalfBlocks ¶ added in v1.6.2
RenderImageToHalfBlocks renders an image as a string using Unicode half-block characters with ANSI256 foreground/background colors. Each character cell encodes 2 vertical pixels: foreground color for the top pixel, background for the bottom.
func ReplacePlaceholders ¶ added in v1.5.0
ReplacePlaceholders replaces template placeholders in text with actual values Currently supports: {{SSH_PORT}}
func ResolveFilePath ¶ added in v1.1.0
ResolveFilePath resolves a file path with the following priority: 1. Local working directory (e.g., ./database.db) 2. User config directory (e.g., ~/.config/stegodon/database.db) 3. Returns the user config directory path if neither exists (for creation)
func ResolveFilePathWithSubdir ¶ added in v1.1.0
ResolveFilePathWithSubdir resolves a file path in a subdirectory Priority: 1. Local working directory (e.g., ./.ssh/stegodonhostkey) 2. User config directory (e.g., ~/.config/stegodon/.ssh/stegodonhostkey) 3. Returns the user config directory path if neither exists (for creation)
func SanitizeRemoteContent ¶ added in v1.6.2
SanitizeRemoteContent removes characters that cause terminal rendering issues. This includes: - Control characters (except newline, tab) - ANSI escape sequences - Carriage returns (cause line overwrites) - Skin tone modifiers (U+1F3FB to U+1F3FF): 🏻🏼🏽🏾🏿 - Variation selectors (U+FE0E text, U+FE0F emoji) - Zero Width Joiner (U+200D) - splits compound emojis into individual ones - Zero-width characters (U+200B, U+FEFF) - Unicode BiDi control characters (U+200E-200F, U+202A-202E, U+2066-2069) - Ambiguous-width characters are replaced with ASCII equivalents:
- Circled numbers (①②③...) → (1)(2)(3)...
- CJK punctuation (「」『』【】〈〉《》etc.) → ASCII quotes/brackets
This helps fix rendering issues in terminals.
func SetupLogging ¶ added in v1.2.3
func SetupLogging(withJournald bool)
SetupLogging configures the logging system based on the journald flag
func StripHTMLTags ¶ added in v1.4.2
StripHTMLTags removes HTML tags from a string and converts common HTML entities
func TruncateContent ¶ added in v1.6.2
TruncateContent truncates content to maxLen characters, adding "[more]" indicator. Users can press 'o' to view full content via original link.
func TruncateVisibleLength ¶ added in v1.2.0
TruncateVisibleLength truncates a string based on visible character count, ignoring ANSI escape sequences and OSC 8 hyperlinks. This ensures proper truncation for strings containing terminal formatting.
func UnescapeHTML ¶ added in v1.5.1
UnescapeHTML converts common HTML entities back to their characters Used to display user-entered text that was escaped during storage
func ValidateNoteLength ¶ added in v1.2.1
ValidateNoteLength checks if the full note text (including markdown syntax) exceeds the database limit. Returns an error if the text is too long.
Types ¶
type AppConfig ¶
type AppConfig struct {
Conf struct {
Host string
SshPort int `yaml:"sshPort"`
HttpPort int `yaml:"httpPort"`
SslDomain string `yaml:"sslDomain"`
WithAp bool `yaml:"withAp"`
Single bool `yaml:"single"`
Closed bool `yaml:"closed"`
NodeDescription string `yaml:"nodeDescription"`
WithJournald bool `yaml:"withJournald"`
WithPprof bool `yaml:"withPprof"`
MaxChars int `yaml:"maxChars"`
ShowGlobal bool `yaml:"showGlobal"`
SshOnly bool `yaml:"sshOnly"`
ShowTos bool `yaml:"showTos"`
}
}
type Mention ¶ added in v1.4.0
Mention represents a parsed @username@domain mention
func ParseMentions ¶ added in v1.4.0
ParseMentions extracts @username@domain mentions from text. Returns deduplicated mentions preserving order of first occurrence.
type RsaKeyPair ¶
func GeneratePemKeypair ¶
func GeneratePemKeypair() *RsaKeyPair