forked from go-gitea/gitea
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Refactor image diff (go-gitea#31444) [skip ci] Updated translations via Crowdin Support relative paths to videos from Wiki pages (go-gitea#31061) Fix deprecated Dockerfile ENV format (go-gitea#31450) README Badge maintenance (go-gitea#31441) Improve markdown textarea for indentation and lists (go-gitea#31406) Split common-global.js into separate files (go-gitea#31438)
- Loading branch information
Showing
24 changed files
with
910 additions
and
726 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright 2024 The Gitea Authors. All rights reserved. | ||
// SPDX-License-Identifier: MIT | ||
|
||
package markup | ||
|
||
import ( | ||
"code.gitea.io/gitea/modules/util" | ||
|
||
"golang.org/x/net/html" | ||
) | ||
|
||
func visitNodeImg(ctx *RenderContext, img *html.Node) (next *html.Node) { | ||
next = img.NextSibling | ||
for i, attr := range img.Attr { | ||
if attr.Key != "src" { | ||
continue | ||
} | ||
|
||
if IsNonEmptyRelativePath(attr.Val) { | ||
attr.Val = util.URLJoin(ctx.Links.ResolveMediaLink(ctx.IsWiki), attr.Val) | ||
|
||
// By default, the "<img>" tag should also be clickable, | ||
// because frontend use `<img>` to paste the re-scaled image into the markdown, | ||
// so it must match the default markdown image behavior. | ||
hasParentAnchor := false | ||
for p := img.Parent; p != nil; p = p.Parent { | ||
if hasParentAnchor = p.Type == html.ElementNode && p.Data == "a"; hasParentAnchor { | ||
break | ||
} | ||
} | ||
if !hasParentAnchor { | ||
imgA := &html.Node{Type: html.ElementNode, Data: "a", Attr: []html.Attribute{ | ||
{Key: "href", Val: attr.Val}, | ||
{Key: "target", Val: "_blank"}, | ||
}} | ||
parent := img.Parent | ||
imgNext := img.NextSibling | ||
parent.RemoveChild(img) | ||
parent.InsertBefore(imgA, imgNext) | ||
imgA.AppendChild(img) | ||
} | ||
} | ||
attr.Val = camoHandleLink(attr.Val) | ||
img.Attr[i] = attr | ||
} | ||
return next | ||
} | ||
|
||
func visitNodeVideo(ctx *RenderContext, node *html.Node) (next *html.Node) { | ||
next = node.NextSibling | ||
for i, attr := range node.Attr { | ||
if attr.Key != "src" { | ||
continue | ||
} | ||
if IsNonEmptyRelativePath(attr.Val) { | ||
attr.Val = util.URLJoin(ctx.Links.ResolveMediaLink(ctx.IsWiki), attr.Val) | ||
} | ||
attr.Val = camoHandleLink(attr.Val) | ||
node.Attr[i] = attr | ||
} | ||
return next | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.