Skip to content

Commit a04f8c0

Browse files
authored
Move the captcha script loader to the template which really needs it (#28718)
It improves the maintainability for the templates. Now `base/footer.tmpl` doesn't need to depend on "captcha" feature.
1 parent 79da4bb commit a04f8c0

File tree

2 files changed

+3
-12
lines changed

2 files changed

+3
-12
lines changed

templates/base/footer.tmpl

-12
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,6 @@
1313

1414
{{template "base/footer_content" .}}
1515

16-
<!-- Third-party libraries -->
17-
{{if .EnableCaptcha}}
18-
{{if eq .CaptchaType "recaptcha"}}
19-
<script src='{{URLJoin .RecaptchaURL "api.js"}}'></script>
20-
{{end}}
21-
{{if eq .CaptchaType "hcaptcha"}}
22-
<script src='https://hcaptcha.com/1/api.js'></script>
23-
{{end}}
24-
{{if eq .CaptchaType "cfturnstile"}}
25-
<script src='https://challenges.cloudflare.com/turnstile/v0/api.js'></script>
26-
{{end}}
27-
{{end}}
2816
<script src="{{AssetUrlPrefix}}/js/index.js?v={{AssetVersion}}" onerror="alert('Failed to load asset files from ' + this.src + '. Please make sure the asset files can be accessed.')"></script>
2917

3018
{{template "custom/footer" .}}

templates/user/auth/captcha.tmpl

+3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@
1111
<div class="inline field required">
1212
<div id="captcha" data-captcha-type="g-recaptcha" class="g-recaptcha-style" data-sitekey="{{.RecaptchaSitekey}}"></div>
1313
</div>
14+
<script src='{{URLJoin .RecaptchaURL "api.js"}}'></script>
1415
{{else if eq .CaptchaType "hcaptcha"}}
1516
<div class="inline field required">
1617
<div id="captcha" data-captcha-type="h-captcha" class="h-captcha-style" data-sitekey="{{.HcaptchaSitekey}}"></div>
1718
</div>
19+
<script src='https://hcaptcha.com/1/api.js'></script>
1820
{{else if eq .CaptchaType "mcaptcha"}}
1921
<div class="inline field">
2022
<label></label>
@@ -25,4 +27,5 @@
2527
<div class="inline field gt-text-center">
2628
<div id="captcha" data-captcha-type="cf-turnstile" data-sitekey="{{.CfTurnstileSitekey}}"></div>
2729
</div>
30+
<script src='https://challenges.cloudflare.com/turnstile/v0/api.js'></script>
2831
{{end}}{{end}}

0 commit comments

Comments
 (0)