giteabot backport / giteabot (push) Canceled after 0s
giteabot / giteabot (push) Canceled after 0s
release-nightly / nightly-binary (push) Canceled after 0s
release-nightly / nightly-container (push) Canceled after 0s
cache-seeder / gobuild (push) Canceled after 0s
cache-seeder / lint (bindata, lint-backend) (push) Canceled after 0s
release-nightly-snapcraft / build-and-publish (push) Canceled after 0s
Includes direct password setup links in registration emails. Assisted-by: Codex:GPT-5
36 lines
906 B
Go
36 lines
906 B
Go
// Copyright 2024 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package renderhelper
|
|
|
|
import (
|
|
"context"
|
|
|
|
"gitea.dev/modules/markup"
|
|
)
|
|
|
|
type SimpleDocument struct {
|
|
*markup.SimpleRenderHelper
|
|
ctx *markup.RenderContext
|
|
baseLink string
|
|
}
|
|
|
|
func (r *SimpleDocument) ResolveLink(link, preferLinkType string) string {
|
|
linkType, link := markup.ParseRenderedLink(link, preferLinkType)
|
|
switch linkType {
|
|
case markup.LinkTypeRoot:
|
|
return r.ctx.ResolveLinkRoot(link)
|
|
default:
|
|
return r.ctx.ResolveLinkRelative(r.baseLink, "", link)
|
|
}
|
|
}
|
|
|
|
var _ markup.RenderHelper = (*SimpleDocument)(nil)
|
|
|
|
func NewRenderContextSimpleDocument(ctx context.Context, baseLink string) *markup.RenderContext {
|
|
helper := &SimpleDocument{baseLink: baseLink}
|
|
rctx := markup.NewRenderContext(ctx).WithHelper(helper).WithMetas(markup.ComposeSimpleDocumentMetas())
|
|
helper.ctx = rctx
|
|
return rctx
|
|
}
|