mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 14:24:27 +01:00
snake case to camel case in some places.
This commit is contained in:
22
utils.go
22
utils.go
@@ -253,15 +253,15 @@ func replaceNostrURLsWithTags(matcher *regexp.Regexp, input string) string {
|
|||||||
// match and replace npup1, nprofile1, note1, nevent1, etc
|
// match and replace npup1, nprofile1, note1, nevent1, etc
|
||||||
return matcher.ReplaceAllStringFunc(input, func(match string) string {
|
return matcher.ReplaceAllStringFunc(input, func(match string) string {
|
||||||
nip19 := match[len("nostr:"):]
|
nip19 := match[len("nostr:"):]
|
||||||
first_chars := nip19[:8]
|
firstChars := nip19[:8]
|
||||||
last_chars := nip19[len(nip19)-4:]
|
lastChars := nip19[len(nip19)-4:]
|
||||||
if strings.HasPrefix(nip19, "npub1") || strings.HasPrefix(nip19, "nprofile1") {
|
if strings.HasPrefix(nip19, "npub1") || strings.HasPrefix(nip19, "nprofile1") {
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*4)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*4)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
name, _ := getNameFromNip19(ctx, nip19)
|
name, _ := getNameFromNip19(ctx, nip19)
|
||||||
return fmt.Sprintf(`<a href="/%s" class="bg-lavender dark:prose:text-neutral-50 dark:text-neutral-50 dark:bg-garnet px-1"><span>%s</span> (<span class="italic">%s</span>)</a>`, nip19, name, first_chars+"…"+last_chars)
|
return fmt.Sprintf(`<a href="/%s" class="bg-lavender dark:prose:text-neutral-50 dark:text-neutral-50 dark:bg-garnet px-1"><span>%s</span> (<span class="italic">%s</span>)</a>`, nip19, name, firstChars+"…"+lastChars)
|
||||||
} else {
|
} else {
|
||||||
return fmt.Sprintf(`<a href="/%s" class="bg-lavender dark:prose:text-neutral-50 dark:text-neutral-50 dark:bg-garnet px-1">%s</a>`, nip19, first_chars+"…"+last_chars)
|
return fmt.Sprintf(`<a href="/%s" class="bg-lavender dark:prose:text-neutral-50 dark:text-neutral-50 dark:bg-garnet px-1">%s</a>`, nip19, firstChars+"…"+lastChars)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -270,12 +270,12 @@ func shortenNostrURLs(input string) string {
|
|||||||
// match and replace npup1, nprofile1, note1, nevent1, etc
|
// match and replace npup1, nprofile1, note1, nevent1, etc
|
||||||
return nostrEveryMatcher.ReplaceAllStringFunc(input, func(match string) string {
|
return nostrEveryMatcher.ReplaceAllStringFunc(input, func(match string) string {
|
||||||
nip19 := match[len("nostr:"):]
|
nip19 := match[len("nostr:"):]
|
||||||
first_chars := nip19[:8]
|
firstChars := nip19[:8]
|
||||||
last_chars := nip19[len(nip19)-4:]
|
lastChars := nip19[len(nip19)-4:]
|
||||||
if strings.HasPrefix(nip19, "npub1") || strings.HasPrefix(nip19, "nprofile1") {
|
if strings.HasPrefix(nip19, "npub1") || strings.HasPrefix(nip19, "nprofile1") {
|
||||||
return "@" + first_chars + "…" + last_chars
|
return "@" + firstChars + "…" + lastChars
|
||||||
} else {
|
} else {
|
||||||
return "#" + first_chars + "…" + last_chars
|
return "#" + firstChars + "…" + lastChars
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -342,9 +342,9 @@ func renderQuotesAsHTML(ctx context.Context, input string, usingTelegramInstantV
|
|||||||
func linkQuotes(input string) string {
|
func linkQuotes(input string) string {
|
||||||
return nostrNoteNeventMatcher.ReplaceAllStringFunc(input, func(match string) string {
|
return nostrNoteNeventMatcher.ReplaceAllStringFunc(input, func(match string) string {
|
||||||
nip19 := match[len("nostr:"):]
|
nip19 := match[len("nostr:"):]
|
||||||
first_chars := nip19[:8]
|
firstChars := nip19[:8]
|
||||||
last_chars := nip19[len(nip19)-4:]
|
lastChars := nip19[len(nip19)-4:]
|
||||||
return fmt.Sprintf(`<a href="/%s">%s</a>`, nip19, first_chars+"…"+last_chars)
|
return fmt.Sprintf(`<a href="/%s">%s</a>`, nip19, firstChars+"…"+lastChars)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user