9a5720e8ad
Universal: PR Check / Branch Policy (pull_request) Successful in 1s
Branch Policy Check / Verify merge target (pull_request) Successful in 1s
PR RC Release / Build RC Release (pull_request) Successful in 3s
Universal: PR Check / Validate PR (pull_request) Failing after 6s
Branch Cleanup / Delete merged branch (pull_request) Successful in 1s
Universal: PR Check / Build RC Package (pull_request) Has been cancelled
Full namespace migration: update the Go module path and all import statements from git.mokoconsulting.tech to code.mokoconsulting.tech. Also updates all URL references in templates, workflows, configs, tests, and documentation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package markup
|
|
|
|
import (
|
|
"fmt"
|
|
"strings"
|
|
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/references"
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/util"
|
|
|
|
"golang.org/x/net/html"
|
|
)
|
|
|
|
func mentionProcessor(ctx *RenderContext, node *html.Node) {
|
|
start := 0
|
|
nodeStop := node.NextSibling
|
|
for node != nodeStop {
|
|
found, loc := references.FindFirstMentionBytes(util.UnsafeStringToBytes(node.Data[start:]))
|
|
if !found {
|
|
node = node.NextSibling
|
|
start = 0
|
|
continue
|
|
}
|
|
loc.Start += start
|
|
loc.End += start
|
|
mention := node.Data[loc.Start:loc.End]
|
|
teams, ok := ctx.RenderOptions.Metas["teams"]
|
|
|
|
if ok && strings.Contains(mention, "/") {
|
|
mentionOrgAndTeam := strings.Split(mention, "/")
|
|
if mentionOrgAndTeam[0][1:] == ctx.RenderOptions.Metas["org"] && strings.Contains(teams, ","+strings.ToLower(mentionOrgAndTeam[1])+",") {
|
|
link := fmt.Sprintf("/:root/org/%s/teams/%s", ctx.RenderOptions.Metas["org"], mentionOrgAndTeam[1])
|
|
replaceContent(node, loc.Start, loc.End, createLink(ctx, link, mention, "" /*mention*/))
|
|
node = node.NextSibling.NextSibling
|
|
start = 0
|
|
continue
|
|
}
|
|
start = loc.End
|
|
continue
|
|
}
|
|
mentionedUsername := mention[1:]
|
|
|
|
if DefaultRenderHelperFuncs != nil && DefaultRenderHelperFuncs.IsUsernameMentionable(ctx, mentionedUsername) {
|
|
link := "/:root/" + mentionedUsername
|
|
replaceContent(node, loc.Start, loc.End, createLink(ctx, link, mention, "" /*mention*/))
|
|
node = node.NextSibling.NextSibling
|
|
start = 0
|
|
} else {
|
|
start = loc.End
|
|
}
|
|
}
|
|
}
|