diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 99ce2e97d67af..43edd14cecaaa 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -3,6 +3,7 @@ reportUnusedDisableDirectives: true ignorePatterns: - /web_src/js/vendor + - /web_src/fomantic parserOptions: sourceType: module diff --git a/.github/labeler.yml b/.github/labeler.yml index 4acdb6f6f5bdb..d1b4d00d80209 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -4,13 +4,6 @@ modifies/docs: - "**/*.md" - "docs/**" -modifies/frontend: - - changed-files: - - any-glob-to-any-file: - - "web_src/**" - - "tailwind.config.js" - - "webpack.config.js" - modifies/templates: - changed-files: - all-globs-to-any-file: diff --git a/modules/markup/markdown/markdown_test.go b/modules/markup/markdown/markdown_test.go index ebac3fbe9e8e0..c664758a277a0 100644 --- a/modules/markup/markdown/markdown_test.go +++ b/modules/markup/markdown/markdown_test.go @@ -436,6 +436,10 @@ func TestColorPreview(t *testing.T) { testcase string expected string }{ + { // do not render color names + "The CSS class `red` is there", + "

The CSS class red is there

\n", + }, { // hex "`#FF0000`", `

#FF0000

` + nl, @@ -445,8 +449,8 @@ func TestColorPreview(t *testing.T) { `

rgb(16, 32, 64)

` + nl, }, { // short hex - "This is the color white `#000`", - `

This is the color white #000

` + nl, + "This is the color white `#0a0`", + `

This is the color white #0a0

` + nl, }, { // hsl "HSL stands for hue, saturation, and lightness. An example: `hsl(0, 100%, 50%)`.", diff --git a/modules/markup/markdown/transform_codespan.go b/modules/markup/markdown/transform_codespan.go index bfff2897b0a8e..5b07d7299955b 100644 --- a/modules/markup/markdown/transform_codespan.go +++ b/modules/markup/markdown/transform_codespan.go @@ -49,9 +49,28 @@ func (r *HTMLRenderer) renderCodeSpan(w util.BufWriter, source []byte, n ast.Nod return ast.WalkContinue, nil } +// cssColorHandler checks if a string is a render-able CSS color value. +// The code is from "github.com/microcosm-cc/bluemonday/css.ColorHandler", except that it doesn't handle color words like "red". +func cssColorHandler(value string) bool { + value = strings.ToLower(value) + if css.HexRGB.MatchString(value) { + return true + } + if css.RGB.MatchString(value) { + return true + } + if css.RGBA.MatchString(value) { + return true + } + if css.HSL.MatchString(value) { + return true + } + return css.HSLA.MatchString(value) +} + func (g *ASTTransformer) transformCodeSpan(ctx *markup.RenderContext, v *ast.CodeSpan, reader text.Reader) { colorContent := v.Text(reader.Source()) - if css.ColorHandler(strings.ToLower(string(colorContent))) { + if cssColorHandler(string(colorContent)) { v.AppendChild(v, NewColorPreview(colorContent)) } } diff --git a/stylelint.config.js b/stylelint.config.js index c34181233e1ce..523b18841ed21 100644 --- a/stylelint.config.js +++ b/stylelint.config.js @@ -16,6 +16,7 @@ export default { ], ignoreFiles: [ '**/*.go', + '/web_src/fomantic', ], overrides: [ { diff --git a/templates/devtest/gitea-ui.tmpl b/templates/devtest/gitea-ui.tmpl index 76de4a93d7178..bb4fc77a74a81 100644 --- a/templates/devtest/gitea-ui.tmpl +++ b/templates/devtest/gitea-ui.tmpl @@ -102,7 +102,7 @@

Loading

-
loading ...
+
loading ...

loading ...

loading ...

diff --git a/templates/repo/home.tmpl b/templates/repo/home.tmpl index 4241f77eaddde..ab37f7e318139 100644 --- a/templates/repo/home.tmpl +++ b/templates/repo/home.tmpl @@ -18,22 +18,21 @@
-
- {{range .Topics}}{{.Name}}{{end}} +
+ {{/* it should match the code in issue-home.js */}} + {{range .Topics}}{{.Name}}{{end}} {{if and .Permission.IsAdmin (not .Repository.IsArchived)}}{{end}}
{{end}} {{if and .Permission.IsAdmin (not .Repository.IsArchived)}} -
-
- +
+
diff --git a/templates/repo/issue/labels/label_list.tmpl b/templates/repo/issue/labels/label_list.tmpl index d84f14242a147..8d7fc2c3dbfc3 100644 --- a/templates/repo/issue/labels/label_list.tmpl +++ b/templates/repo/issue/labels/label_list.tmpl @@ -8,7 +8,7 @@ {{ctx.Locale.Tr "repo.issues.filter_sort"}} {{svg "octicon-triangle-down" 14 "dropdown icon"}} -