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.
2022-03-30 00:52:24 -05:00
|
|
|
// bootstrap module must be the first one to be imported, it handles webpack lazy-loading and global errors
|
|
|
|
import './bootstrap.js';
|
2020-02-23 16:34:28 -05:00
|
|
|
|
2022-01-28 16:00:11 -05:00
|
|
|
import $ from 'jquery';
|
2021-10-14 21:35:26 -05:00
|
|
|
import {initVueEnv} from './components/VueComponentLoader.js';
|
|
|
|
import {initRepoActivityTopAuthorsChart} from './components/RepoActivityTopAuthors.vue';
|
|
|
|
import {initDashboardRepoList} from './components/DashboardRepoList.js';
|
|
|
|
|
2021-05-07 03:43:41 -05:00
|
|
|
import attachTribute from './features/tribute.js';
|
2021-10-16 12:28:04 -05:00
|
|
|
import initGlobalCopyToClipboardListener from './features/clipboard.js';
|
2020-03-11 14:34:54 -05:00
|
|
|
import initContextPopups from './features/contextpopup.js';
|
2021-11-09 04:27:25 -05:00
|
|
|
import initRepoGraphGit from './features/repo-graph.js';
|
2020-11-18 17:00:16 -05:00
|
|
|
import initHeatmap from './features/heatmap.js';
|
2021-05-07 03:43:41 -05:00
|
|
|
import initImageDiff from './features/imagediff.js';
|
2021-11-09 04:27:25 -05:00
|
|
|
import initRepoMigration from './features/repo-migration.js';
|
|
|
|
import initRepoProject from './features/repo-projects.js';
|
2020-05-21 20:45:34 -05:00
|
|
|
import initServiceWorker from './features/serviceworker.js';
|
2020-06-24 17:23:05 -05:00
|
|
|
import initTableSort from './features/tablesort.js';
|
2022-10-16 18:29:26 -05:00
|
|
|
import {initAdminUserListSearchForm} from './features/admin/users.js';
|
|
|
|
import {initAdminConfigs} from './features/admin/config.js';
|
2021-05-07 03:43:41 -05:00
|
|
|
import {initMarkupAnchors} from './markup/anchors.js';
|
2021-10-16 12:28:04 -05:00
|
|
|
import {initNotificationCount, initNotificationsTable} from './features/notification.js';
|
2021-11-09 04:27:25 -05:00
|
|
|
import {initRepoIssueContentHistory} from './features/repo-issue-content.js';
|
2021-01-21 09:51:52 -05:00
|
|
|
import {initStopwatch} from './features/stopwatch.js';
|
2022-06-09 06:15:08 -05:00
|
|
|
import {initFindFileInRepo} from './features/repo-findfile.js';
|
2021-10-16 12:28:04 -05:00
|
|
|
import {initCommentContent, initMarkupContent} from './markup/content.js';
|
2022-09-27 00:22:19 -05:00
|
|
|
import initDiffFileTree from './features/repo-diff-filetree.js';
|
2021-10-16 12:28:04 -05:00
|
|
|
|
|
|
|
import {initUserAuthLinkAccountView, initUserAuthOauth2} from './features/user-auth.js';
|
|
|
|
import {
|
|
|
|
initRepoDiffConversationForm,
|
|
|
|
initRepoDiffFileViewToggle,
|
2021-11-09 04:27:25 -05:00
|
|
|
initRepoDiffReviewButton, initRepoDiffShowMore,
|
2021-10-16 12:28:04 -05:00
|
|
|
} from './features/repo-diff.js';
|
|
|
|
import {
|
|
|
|
initRepoIssueDue,
|
|
|
|
initRepoIssueList,
|
|
|
|
initRepoIssueReferenceRepositorySearch,
|
|
|
|
initRepoIssueTimeTracking,
|
|
|
|
initRepoIssueWipTitle,
|
|
|
|
initRepoPullRequestMergeInstruction,
|
2022-04-28 10:45:33 -05:00
|
|
|
initRepoPullRequestAllowMaintainerEdit,
|
2021-10-16 12:28:04 -05:00
|
|
|
initRepoPullRequestReview,
|
|
|
|
} from './features/repo-issue.js';
|
2022-04-26 14:09:46 -05:00
|
|
|
import {
|
|
|
|
initRepoEllipsisButton,
|
|
|
|
initRepoCommitLastCommitLoader,
|
|
|
|
initCommitStatuses,
|
|
|
|
} from './features/repo-commit.js';
|
2021-10-16 12:28:04 -05:00
|
|
|
import {
|
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.
2022-03-30 00:52:24 -05:00
|
|
|
checkAppUrl,
|
2021-10-16 12:28:04 -05:00
|
|
|
initFootLanguageMenu,
|
|
|
|
initGlobalButtonClickOnEnter,
|
|
|
|
initGlobalButtons,
|
|
|
|
initGlobalCommon,
|
|
|
|
initGlobalDropzone,
|
|
|
|
initGlobalEnterQuickSubmit,
|
|
|
|
initGlobalFormDirtyLeaveConfirm,
|
|
|
|
initGlobalLinkActions,
|
|
|
|
initHeadNavbarContentToggle,
|
2022-08-09 07:37:34 -05:00
|
|
|
initGlobalTooltips,
|
2021-10-16 12:28:04 -05:00
|
|
|
} from './features/common-global.js';
|
|
|
|
import {initRepoTopicBar} from './features/repo-home.js';
|
2022-10-16 18:29:26 -05:00
|
|
|
import {initAdminEmails} from './features/admin/emails.js';
|
|
|
|
import {initAdminCommon} from './features/admin/common.js';
|
2021-10-16 12:28:04 -05:00
|
|
|
import {initRepoTemplateSearch} from './features/repo-template.js';
|
|
|
|
import {initRepoCodeView} from './features/repo-code.js';
|
|
|
|
import {initSshKeyFormParser} from './features/sshkey-helper.js';
|
|
|
|
import {initUserSettings} from './features/user-settings.js';
|
|
|
|
import {initRepoArchiveLinks} from './features/repo-common.js';
|
|
|
|
import {initRepoMigrationStatusChecker} from './features/repo-migrate.js';
|
|
|
|
import {
|
|
|
|
initRepoSettingGitHook,
|
|
|
|
initRepoSettingsCollaboration,
|
|
|
|
initRepoSettingSearchTeamBox,
|
|
|
|
} from './features/repo-settings.js';
|
2022-05-07 13:28:10 -05:00
|
|
|
import {initViewedCheckboxListenerFor} from './features/pull-view-file.js';
|
2021-10-16 12:28:04 -05:00
|
|
|
import {initOrgTeamSearchRepoBox, initOrgTeamSettings} from './features/org-team.js';
|
2022-01-14 10:03:31 -05:00
|
|
|
import {initUserAuthWebAuthn, initUserAuthWebAuthnRegister} from './features/user-auth-webauthn.js';
|
2021-10-16 12:28:04 -05:00
|
|
|
import {initRepoRelease, initRepoReleaseEditor} from './features/repo-release.js';
|
|
|
|
import {initRepoEditor} from './features/repo-editor.js';
|
2021-11-09 04:27:25 -05:00
|
|
|
import {initCompSearchUserBox} from './features/comp/SearchUserBox.js';
|
2021-10-16 12:28:04 -05:00
|
|
|
import {initInstall} from './features/install.js';
|
2021-11-09 04:27:25 -05:00
|
|
|
import {initCompWebHookEditor} from './features/comp/WebHookEditor.js';
|
2021-10-16 12:28:04 -05:00
|
|
|
import {initCommonIssue} from './features/common-issue.js';
|
|
|
|
import {initRepoBranchButton} from './features/repo-branch.js';
|
|
|
|
import {initCommonOrganization} from './features/common-organization.js';
|
|
|
|
import {initRepoWikiForm} from './features/repo-wiki.js';
|
|
|
|
import {initRepoCommentForm, initRepository} from './features/repo-legacy.js';
|
2022-06-12 07:08:23 -05:00
|
|
|
import {initFormattingReplacements} from './features/formatting.js';
|
2022-08-10 08:20:10 -05:00
|
|
|
import {initMcaptcha} from './features/mcaptcha.js';
|
2022-11-21 04:59:42 -05:00
|
|
|
import {initCopyContent} from './features/copycontent.js';
|
2022-06-12 07:08:23 -05:00
|
|
|
|
|
|
|
// Run time-critical code as soon as possible. This is safe to do because this
|
|
|
|
// script appears at the end of <body> and rendered HTML is accessible at that point.
|
|
|
|
initFormattingReplacements();
|
2019-11-13 09:52:13 -05:00
|
|
|
|
2020-01-11 21:57:32 -05:00
|
|
|
// Silence fomantic's error logging when tabs are used without a target content element
|
|
|
|
$.fn.tab.settings.silent = true;
|
2022-02-22 14:43:11 -05:00
|
|
|
// Disable the behavior of fomantic to toggle the checkbox when you press enter on a checkbox element.
|
|
|
|
$.fn.checkbox.settings.enableEnterKey = false;
|
2019-11-14 16:39:51 -05:00
|
|
|
|
2021-10-16 12:28:04 -05:00
|
|
|
initVueEnv();
|
2021-11-09 04:27:25 -05:00
|
|
|
$(document).ready(() => {
|
2021-10-16 12:28:04 -05:00
|
|
|
initGlobalCommon();
|
2021-11-09 04:27:25 -05:00
|
|
|
|
2022-08-09 07:37:34 -05:00
|
|
|
initGlobalTooltips();
|
2021-11-09 04:27:25 -05:00
|
|
|
initGlobalButtonClickOnEnter();
|
|
|
|
initGlobalButtons();
|
|
|
|
initGlobalCopyToClipboardListener();
|
2021-10-16 12:28:04 -05:00
|
|
|
initGlobalDropzone();
|
2021-11-09 04:27:25 -05:00
|
|
|
initGlobalEnterQuickSubmit();
|
|
|
|
initGlobalFormDirtyLeaveConfirm();
|
2021-10-16 12:28:04 -05:00
|
|
|
initGlobalLinkActions();
|
2021-11-09 04:27:25 -05:00
|
|
|
|
|
|
|
attachTribute(document.querySelectorAll('#content, .emoji-input'));
|
2019-11-14 16:39:51 -05:00
|
|
|
|
2021-10-16 12:28:04 -05:00
|
|
|
initCommonIssue();
|
2021-11-09 04:27:25 -05:00
|
|
|
initCommonOrganization();
|
2019-11-14 16:39:51 -05:00
|
|
|
|
2021-11-09 04:27:25 -05:00
|
|
|
initCompSearchUserBox();
|
|
|
|
initCompWebHookEditor();
|
2019-11-14 16:39:51 -05:00
|
|
|
|
|
|
|
initInstall();
|
2021-11-09 04:27:25 -05:00
|
|
|
|
|
|
|
initHeadNavbarContentToggle();
|
|
|
|
initFootLanguageMenu();
|
|
|
|
|
|
|
|
initCommentContent();
|
|
|
|
initContextPopups();
|
|
|
|
initHeatmap();
|
|
|
|
initImageDiff();
|
|
|
|
initMarkupAnchors();
|
|
|
|
initMarkupContent();
|
|
|
|
initServiceWorker();
|
|
|
|
initSshKeyFormParser();
|
|
|
|
initStopwatch();
|
|
|
|
initTableSort();
|
2022-06-09 06:15:08 -05:00
|
|
|
initFindFileInRepo();
|
2022-11-21 04:59:42 -05:00
|
|
|
initCopyContent();
|
2021-11-09 04:27:25 -05:00
|
|
|
|
2021-10-16 12:28:04 -05:00
|
|
|
initAdminCommon();
|
2021-11-09 04:27:25 -05:00
|
|
|
initAdminEmails();
|
|
|
|
initAdminUserListSearchForm();
|
2022-10-16 18:29:26 -05:00
|
|
|
initAdminConfigs();
|
2021-11-09 04:27:25 -05:00
|
|
|
|
2021-10-14 21:35:26 -05:00
|
|
|
initDashboardRepoList();
|
2021-11-09 04:27:25 -05:00
|
|
|
|
|
|
|
initNotificationCount();
|
|
|
|
initNotificationsTable();
|
|
|
|
|
|
|
|
initOrgTeamSearchRepoBox();
|
2021-10-16 12:28:04 -05:00
|
|
|
initOrgTeamSettings();
|
2021-11-09 04:27:25 -05:00
|
|
|
|
|
|
|
initRepoActivityTopAuthorsChart();
|
|
|
|
initRepoArchiveLinks();
|
|
|
|
initRepoBranchButton();
|
|
|
|
initRepoCodeView();
|
|
|
|
initRepoCommentForm();
|
2021-11-22 21:44:38 -05:00
|
|
|
initRepoEllipsisButton();
|
2021-11-09 04:27:25 -05:00
|
|
|
initRepoCommitLastCommitLoader();
|
|
|
|
initRepoDiffConversationForm();
|
|
|
|
initRepoDiffFileViewToggle();
|
|
|
|
initRepoDiffReviewButton();
|
|
|
|
initRepoDiffShowMore();
|
2022-09-27 00:22:19 -05:00
|
|
|
initDiffFileTree();
|
2021-11-09 04:27:25 -05:00
|
|
|
initRepoEditor();
|
|
|
|
initRepoGraphGit();
|
|
|
|
initRepoIssueContentHistory();
|
|
|
|
initRepoIssueDue();
|
2021-10-16 12:28:04 -05:00
|
|
|
initRepoIssueList();
|
2021-11-09 04:27:25 -05:00
|
|
|
initRepoIssueReferenceRepositorySearch();
|
2021-10-16 12:28:04 -05:00
|
|
|
initRepoIssueTimeTracking();
|
|
|
|
initRepoIssueWipTitle();
|
2021-11-09 04:27:25 -05:00
|
|
|
initRepoMigration();
|
2021-10-16 12:28:04 -05:00
|
|
|
initRepoMigrationStatusChecker();
|
2021-11-09 04:27:25 -05:00
|
|
|
initRepoProject();
|
2021-10-16 12:28:04 -05:00
|
|
|
initRepoPullRequestMergeInstruction();
|
2022-04-28 10:45:33 -05:00
|
|
|
initRepoPullRequestAllowMaintainerEdit();
|
2021-11-09 04:27:25 -05:00
|
|
|
initRepoPullRequestReview();
|
2021-10-16 12:28:04 -05:00
|
|
|
initRepoRelease();
|
2021-11-09 04:27:25 -05:00
|
|
|
initRepoReleaseEditor();
|
|
|
|
initRepoSettingGitHook();
|
|
|
|
initRepoSettingSearchTeamBox();
|
2021-10-16 12:28:04 -05:00
|
|
|
initRepoSettingsCollaboration();
|
2021-11-09 04:27:25 -05:00
|
|
|
initRepoTemplateSearch();
|
|
|
|
initRepoTopicBar();
|
|
|
|
initRepoWikiForm();
|
|
|
|
initRepository();
|
2019-11-14 16:39:51 -05:00
|
|
|
|
2022-04-26 14:09:46 -05:00
|
|
|
initCommitStatuses();
|
2022-08-10 08:20:10 -05:00
|
|
|
initMcaptcha();
|
2022-04-26 14:09:46 -05:00
|
|
|
|
2021-11-09 04:27:25 -05:00
|
|
|
initUserAuthLinkAccountView();
|
|
|
|
initUserAuthOauth2();
|
2022-01-14 10:03:31 -05:00
|
|
|
initUserAuthWebAuthn();
|
|
|
|
initUserAuthWebAuthnRegister();
|
2021-11-09 04:27:25 -05:00
|
|
|
initUserSettings();
|
2022-05-07 13:28:10 -05:00
|
|
|
initViewedCheckboxListenerFor();
|
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.
2022-03-30 00:52:24 -05:00
|
|
|
checkAppUrl();
|
2019-11-14 16:39:51 -05:00
|
|
|
});
|