9a5720e8ad
Branch Policy Check / Verify merge target (pull_request) Has been cancelled
Universal: PR Check / Branch Policy (pull_request) Has been cancelled
PR RC Release / Build RC Release (pull_request) Has been cancelled
Universal: PR Check / Validate PR (pull_request) Has been cancelled
Branch Cleanup / Delete merged branch (pull_request) Has been cancelled
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>
93 lines
2.8 KiB
Go
93 lines
2.8 KiB
Go
// Copyright 2014 The Gogs Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package misc
|
|
|
|
import (
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/markup"
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/markup/markdown"
|
|
api "code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/structs"
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/util"
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/modules/web"
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/routers/common"
|
|
"code.mokoconsulting.tech/MokoConsulting/MokoGitea/services/context"
|
|
)
|
|
|
|
// Markup render markup document to HTML
|
|
func Markup(ctx *context.APIContext) {
|
|
// swagger:operation POST /markup miscellaneous renderMarkup
|
|
// ---
|
|
// summary: Render a markup document as HTML
|
|
// parameters:
|
|
// - name: body
|
|
// in: body
|
|
// schema:
|
|
// "$ref": "#/definitions/MarkupOption"
|
|
// consumes:
|
|
// - application/json
|
|
// produces:
|
|
// - text/html
|
|
// responses:
|
|
// "200":
|
|
// "$ref": "#/responses/MarkupRender"
|
|
// "422":
|
|
// "$ref": "#/responses/validationError"
|
|
|
|
form := web.GetForm(ctx).(*api.MarkupOption)
|
|
mode := util.Iif(form.Wiki, "wiki", form.Mode) //nolint:staticcheck // form.Wiki is deprecated
|
|
common.RenderMarkup(ctx.Base, ctx.Repo, mode, form.Text, form.Context, form.FilePath)
|
|
}
|
|
|
|
// Markdown render markdown document to HTML
|
|
func Markdown(ctx *context.APIContext) {
|
|
// swagger:operation POST /markdown miscellaneous renderMarkdown
|
|
// ---
|
|
// summary: Render a markdown document as HTML
|
|
// parameters:
|
|
// - name: body
|
|
// in: body
|
|
// schema:
|
|
// "$ref": "#/definitions/MarkdownOption"
|
|
// consumes:
|
|
// - application/json
|
|
// produces:
|
|
// - text/html
|
|
// responses:
|
|
// "200":
|
|
// "$ref": "#/responses/MarkdownRender"
|
|
// "422":
|
|
// "$ref": "#/responses/validationError"
|
|
|
|
form := web.GetForm(ctx).(*api.MarkdownOption)
|
|
mode := util.Iif(form.Wiki, "wiki", form.Mode) //nolint:staticcheck // form.Wiki is deprecated
|
|
common.RenderMarkup(ctx.Base, ctx.Repo, mode, form.Text, form.Context, "")
|
|
}
|
|
|
|
// MarkdownRaw render raw markdown HTML
|
|
func MarkdownRaw(ctx *context.APIContext) {
|
|
// swagger:operation POST /markdown/raw miscellaneous renderMarkdownRaw
|
|
// ---
|
|
// summary: Render raw markdown as HTML
|
|
// parameters:
|
|
// - name: body
|
|
// in: body
|
|
// description: Request body to render
|
|
// required: true
|
|
// schema:
|
|
// type: string
|
|
// consumes:
|
|
// - text/plain
|
|
// produces:
|
|
// - text/html
|
|
// responses:
|
|
// "200":
|
|
// "$ref": "#/responses/MarkdownRender"
|
|
// "422":
|
|
// "$ref": "#/responses/validationError"
|
|
defer ctx.Req.Body.Close()
|
|
if err := markdown.RenderRaw(markup.NewRenderContext(ctx), ctx.Req.Body, ctx.Resp); err != nil {
|
|
ctx.APIErrorInternal(err)
|
|
return
|
|
}
|
|
}
|