Skip to content

Commit eef822a

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Call MultipartForm.RemoveAll when request finishes (go-gitea#19606) Remove `RequireHighlightJS` field, update plantuml example. (go-gitea#19615) [skip ci] Updated translations via Crowdin PullService lock via pullID (go-gitea#19520)
2 parents e28028d + 04fc4b7 commit eef822a

File tree

26 files changed

+367
-31
lines changed

26 files changed

+367
-31
lines changed

docs/content/doc/advanced/customizing-gitea.en-us.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -132,15 +132,18 @@ copy javascript files from https://gitea.com/davidsvantesson/plantuml-code-highl
132132
`$GITEA_CUSTOM/public` folder. Then add the following to `custom/footer.tmpl`:
133133

134134
```html
135-
{{if .RequireHighlightJS}}
136-
<script src="https://your-server.com/deflate.js"></script>
137-
<script src="https://your-server.com/encode.js"></script>
138-
<script src="https://your-server.com/plantuml_codeblock_parse.js"></script>
139135
<script>
140-
<!-- Replace call with address to your plantuml server-->
141-
parsePlantumlCodeBlocks("http://www.plantuml.com/plantuml");
136+
$(async () => {
137+
if (!$('.language-plantuml').length) return;
138+
await Promise.all([
139+
$.getScript('https://your-server.com/deflate.js'),
140+
$.getScript('https://your-server.com/encode.js'),
141+
$.getScript('https://your-server.com/plantuml_codeblock_parse.js'),
142+
]);
143+
// Replace call with address to your plantuml server
144+
parsePlantumlCodeBlocks("https://www.plantuml.com/plantuml");
145+
});
142146
</script>
143-
{{end}}
144147
```
145148

146149
You can then add blocks like the following to your markdown:

modules/context/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ func APIContexter() func(http.Handler) http.Handler {
256256
},
257257
Org: &APIOrganization{},
258258
}
259+
defer ctx.Close()
259260

260261
ctx.Req = WithAPIContext(WithContext(req, ctx.Context), &ctx)
261262

modules/context/context.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,16 @@ type Context struct {
7575
Package *Package
7676
}
7777

78+
// Close frees all resources hold by Context
79+
func (ctx *Context) Close() error {
80+
var err error
81+
if ctx.Req != nil && ctx.Req.MultipartForm != nil {
82+
err = ctx.Req.MultipartForm.RemoveAll() // remove the temp files buffered to tmp directory
83+
}
84+
// TODO: close opened repo, and more
85+
return err
86+
}
87+
7888
// TrHTMLEscapeArgs runs Tr but pre-escapes all arguments with html.EscapeString.
7989
// This is useful if the locale message is intended to only produce HTML content.
8090
func (ctx *Context) TrHTMLEscapeArgs(msg string, args ...string) string {
@@ -693,6 +703,8 @@ func Contexter() func(next http.Handler) http.Handler {
693703
"RunModeIsProd": setting.IsProd,
694704
},
695705
}
706+
defer ctx.Close()
707+
696708
// PageData is passed by reference, and it will be rendered to `window.config.pageData` in `head.tmpl` for JavaScript modules
697709
ctx.PageData = map[string]interface{}{}
698710
ctx.Data["PageData"] = ctx.PageData

modules/context/package.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ func PackageContexter() func(next http.Handler) http.Handler {
100100
Resp: NewResponse(resp),
101101
Data: map[string]interface{}{},
102102
}
103+
defer ctx.Close()
103104

104105
ctx.Req = WithContext(req, &ctx)
105106

modules/context/private.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ func PrivateContexter() func(http.Handler) http.Handler {
6666
Data: map[string]interface{}{},
6767
},
6868
}
69+
defer ctx.Close()
70+
6971
ctx.Req = WithPrivateContext(req, ctx)
7072
ctx.Data["Context"] = ctx
7173
next.ServeHTTP(ctx.Resp, ctx.Req)

modules/test/context_tests.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func MockContext(t *testing.T, path string) *context.Context {
3838
Resp: context.NewResponse(resp),
3939
Locale: &mockLocale{},
4040
}
41+
defer ctx.Close()
4142

4243
requestURL, err := url.Parse(path)
4344
assert.NoError(t, err)

options/locale/locale_cs-CZ.ini

Lines changed: 314 additions & 0 deletions
Large diffs are not rendered by default.

options/locale/locale_pt-BR.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ theme_desc=Este será o seu tema padrão em todo o site.
602602
primary=Principal
603603
activated=Ativado
604604
requires_activation=Requer ativação
605-
primary_email=Tornar Primário
605+
primary_email=Tornar Principal
606606
activate_email=Enviar Ativação
607607
activations_pending=Ativações pendentes
608608
delete_email=Remover

routers/api/v1/misc/markdown_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ func createContext(req *http.Request) (*context.Context, *httptest.ResponseRecor
3737
Render: rnd,
3838
Data: make(map[string]interface{}),
3939
}
40+
defer c.Close()
41+
4042
return c, resp
4143
}
4244

routers/install/install.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ func Init(next http.Handler) http.Handler {
7979
"PasswordHashAlgorithms": user_model.AvailableHashAlgorithms,
8080
},
8181
}
82+
defer ctx.Close()
83+
8284
ctx.Req = context.WithContext(req, &ctx)
8385
next.ServeHTTP(resp, ctx.Req)
8486
})

0 commit comments

Comments
 (0)