From 2bce1ea9862c70ebb69963e65bb84dcad6ebb31c Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 30 Mar 2022 13:52:24 +0800 Subject: Show messages for users if the ROOT_URL is wrong, show JavaScript errors (#18971) * ROOT_URL issues: some users did wrong to there app.ini config, then: * The assets can not be loaded (AppSubUrl != "" and users try to access http://host:3000/) *The ROOT_URL is wrong, then many URLs in Gitea are broken. Now Gitea show enough information to users. * JavaScript error issues, there are many users affected by JavaScript errors, some are caused by frontend bugs, some are caused by broken customized templates. If these JS errors can be found at first time, then maintainers do not need to ask about how bug occurs again and again. * Some people like to modify the `head.tmpl`, so we separate the script part to `head_script.tmpl`, then it's much safer. * use specialized CSS class "js-global-error", end users still have a chance to hide error messages by customized CSS styles. --- templates/base/footer.tmpl | 2 +- templates/base/head.tmpl | 45 +++------------------------------ templates/base/head_script.tmpl | 49 ++++++++++++++++++++++++++++++++++++ web_src/js/bootstrap.js | 41 ++++++++++++++++++++++++++++++ web_src/js/features/common-global.js | 20 ++++++++++++++- web_src/js/index.js | 7 ++++-- web_src/js/publicpath.js | 6 ----- 7 files changed, 118 insertions(+), 52 deletions(-) create mode 100644 templates/base/head_script.tmpl create mode 100644 web_src/js/bootstrap.js delete mode 100644 web_src/js/publicpath.js diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl index 1aabfa2f5c..9bf16f8aa5 100644 --- a/templates/base/footer.tmpl +++ b/templates/base/footer.tmpl @@ -22,7 +22,7 @@ {{end}} {{end}} - + {{template "custom/footer" .}} diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index 2a9c24255d..35157e9b95 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -19,51 +19,12 @@ {{end}} - + + {{template "base/head_script" .}} +