mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
ProxyCheckEnabled detection draft
This commit is contained in:
@@ -81,6 +81,23 @@
|
||||
proxy or one of the provided external proxy servers. If you prefer, you can
|
||||
also specify a custom proxy server by entering its URL and clicking 'Save Changes'.
|
||||
</p>
|
||||
{{ if .ProxyCheckEnabled == false }}
|
||||
<div class="alert alert-warning" role="alert">
|
||||
<p>
|
||||
<i class="bi bi-exclamation-triangle-fill"></i> This PixivFE instance has been configured to <span class="fw-bold">not</span> check the list of built-in image proxies (<a href="https://pixivfe-docs.pages.dev/hosting/environment-variables/#pixivfe_proxy_check_enabled" class="text-decoration-none"><code class="bg-dark-subtle rounded p-1">PIXIVFE_PROXY_CHECK_ENABLED=false</code></a> has been set).
|
||||
</p>
|
||||
<p class="mb-0">
|
||||
All image proxies will be shown by default, regardless of their actual state.
|
||||
</p>
|
||||
</div>
|
||||
{{- else -}}
|
||||
<p>
|
||||
This PixivFE instance has been configured to check the list of built-in image proxies every {{ .ProxyCheckInterval }}.
|
||||
</p>
|
||||
<p>
|
||||
Image proxies that fail this check will not be shown unless "Show all proxy servers" is enabled.
|
||||
</p>
|
||||
{{- end -}}
|
||||
<form action="/settings/imageServer" method="post">
|
||||
<div class="mb-3 form-check form-switch">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="show-all-proxies">
|
||||
|
||||
@@ -169,7 +169,12 @@ func resetAll(w http.ResponseWriter, _ *http.Request) error {
|
||||
}
|
||||
|
||||
func SettingsPage(w http.ResponseWriter, r *http.Request) error {
|
||||
return RenderHTML(w, r, Data_settings{WorkingProxyList: proxy_checker.GetWorkingProxies(), ProxyList: config.BuiltinProxyList})
|
||||
return RenderHTML(w, r, Data_settings{
|
||||
WorkingProxyList: proxy_checker.GetWorkingProxies(),
|
||||
ProxyList: config.BuiltinProxyList,
|
||||
ProxyCheckEnabled: config.GlobalConfig.ProxyCheckEnabled, // Used to check whether proxy_checker is enabled on the instance
|
||||
ProxyCheckInterval: config.GlobalConfig.ProxyCheckInterval, // Used to display the ProxyCheckInterval configured on the instance
|
||||
})
|
||||
}
|
||||
|
||||
func SettingsPost(w http.ResponseWriter, r *http.Request) error {
|
||||
|
||||
@@ -6,6 +6,7 @@ import (
|
||||
"codeberg.org/vnpower/pixivfe/v2/core"
|
||||
"codeberg.org/vnpower/pixivfe/v2/server/request_context"
|
||||
"codeberg.org/vnpower/pixivfe/v2/server/template"
|
||||
"time"
|
||||
)
|
||||
|
||||
func RenderHTML[T any](w http.ResponseWriter, r *http.Request, data T) error {
|
||||
@@ -129,8 +130,10 @@ type Data_rankingCalendar struct {
|
||||
ThisMonth DateWrap
|
||||
}
|
||||
type Data_settings struct {
|
||||
ProxyList []string
|
||||
WorkingProxyList []string
|
||||
ProxyList []string
|
||||
WorkingProxyList []string
|
||||
ProxyCheckEnabled bool
|
||||
ProxyCheckInterval time.Duration
|
||||
}
|
||||
type Data_tag struct {
|
||||
Title string
|
||||
|
||||
Reference in New Issue
Block a user