@shzlx/ui-default 4.58.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/api.ts +61 -0
- package/backendlib/builder.ts +182 -0
- package/backendlib/markdown-it-imsize.ts +235 -0
- package/backendlib/markdown-it-katex.ts +139 -0
- package/backendlib/markdown-it-media.ts +163 -0
- package/backendlib/markdown-it-xss.ts +200 -0
- package/backendlib/markdown.js +64 -0
- package/backendlib/misc.ts +54 -0
- package/backendlib/template.ts +279 -0
- package/breakpoints.json +5 -0
- package/components/DOMAttachedObject.ts +128 -0
- package/components/autocomplete/AssignSelectAutoComplete.tsx +22 -0
- package/components/autocomplete/CustomSelectAutoComplete.tsx +23 -0
- package/components/autocomplete/DomainSelectAutoComplete.tsx +18 -0
- package/components/autocomplete/FileSelectAutoComplete.tsx +26 -0
- package/components/autocomplete/LanguageSelectAutoComplete.tsx +24 -0
- package/components/autocomplete/ProblemSelectAutoComplete.tsx +18 -0
- package/components/autocomplete/UserSelectAutoComplete.tsx +23 -0
- package/components/autocomplete/components/AssignSelectAutoComplete.tsx +118 -0
- package/components/autocomplete/components/DomainSelectAutoComplete.tsx +53 -0
- package/components/autocomplete/components/FileSelectAutoComplete.tsx +50 -0
- package/components/autocomplete/components/LanguageSelectAutoComplete.tsx +48 -0
- package/components/autocomplete/components/ProblemSelectAutoComplete.tsx +54 -0
- package/components/autocomplete/components/UserSelectAutoComplete.tsx +54 -0
- package/components/autocomplete/domainselectautocomplete.page.styl +6 -0
- package/components/autocomplete/index.tsx +110 -0
- package/components/autocomplete/problemselectautocomplete.page.styl +6 -0
- package/components/autocomplete/userselectautocomplete.page.styl +6 -0
- package/components/browser-update.page.ts +27 -0
- package/components/calendar/calendar.page.styl +129 -0
- package/components/calendar/index.js +367 -0
- package/components/clipboard.page.ts +23 -0
- package/components/contest/contest.page.styl +119 -0
- package/components/contest/contest.page.ts +23 -0
- package/components/contest/contest_sidebar.page.styl +21 -0
- package/components/contest/problem-contest-bg.png +0 -0
- package/components/contest/problem-contest-bg@2x.png +0 -0
- package/components/customFont.page.tsx +90 -0
- package/components/datepicker/datepicker.page.tsx +94 -0
- package/components/dialog/DomDialog.ts +145 -0
- package/components/dialog/dialog.page.styl +40 -0
- package/components/dialog/index.tsx +285 -0
- package/components/discussion/CommentBox.js +103 -0
- package/components/discussion/collapsible.page.styl +40 -0
- package/components/discussion/collapsible.page.tsx +62 -0
- package/components/discussion/comments.page.styl +142 -0
- package/components/discussion/comments.page.tsx +192 -0
- package/components/discussion/discussion.page.styl +17 -0
- package/components/discussion/history.page.tsx +81 -0
- package/components/discussion/reaction.page.styl +30 -0
- package/components/discussion/reaction.page.tsx +103 -0
- package/components/drop/drop.page.styl +40 -0
- package/components/dropdown/Dropdown.js +50 -0
- package/components/dropdown/dropdown.page.styl +33 -0
- package/components/dropdown/dropdown.page.ts +8 -0
- package/components/editor/cmeditor.page.ts +23 -0
- package/components/editor/cmeditor.styl +10 -0
- package/components/editor/index.tsx +293 -0
- package/components/editor/mdeditor.ts +60 -0
- package/components/editor/textareaHandler.ts +29 -0
- package/components/footer/footer.page.styl +94 -0
- package/components/footer/footer.page.ts +26 -0
- package/components/form/button.page.default.styl +59 -0
- package/components/form/button.page.styl +36 -0
- package/components/form/checkbox.page.styl +89 -0
- package/components/form/form.page.styl +200 -0
- package/components/form/form.page.ts +20 -0
- package/components/form/multiSelectCheckbox.page.js +46 -0
- package/components/form/radiobox.page.styl +62 -0
- package/components/form/select.page.styl +29 -0
- package/components/form/textbox.page.styl +79 -0
- package/components/form/textbox.page.ts +21 -0
- package/components/form/var.inc.styl +14 -0
- package/components/header/header.page.styl +79 -0
- package/components/highlighter/code-example.js +111 -0
- package/components/highlighter/highlighter.page.styl +99 -0
- package/components/highlighter/highlighter.page.ts +72 -0
- package/components/highlighter/meta.js +15 -0
- package/components/highlighter/prismjs.js +122 -0
- package/components/hint.page.styl +9 -0
- package/components/hint.ts +19 -0
- package/components/hitokoto/index.page.js +21 -0
- package/components/hotkey/hotkey.page.js +83 -0
- package/components/katex/katex.page.js +26 -0
- package/components/katex/katex.page.styl +2 -0
- package/components/languageselect.tsx +94 -0
- package/components/loader/loader.page.styl +40 -0
- package/components/mantine.page.tsx +39 -0
- package/components/marker/Marker.js +192 -0
- package/components/marker/MarkerReactive.js +55 -0
- package/components/marker/marker.page.js +8 -0
- package/components/marker/marker.page.styl +57 -0
- package/components/media/media.page.js +46 -0
- package/components/menu/menu-heading.page.js +28 -0
- package/components/menu/menu.page.js +18 -0
- package/components/menu/menu.page.styl +68 -0
- package/components/message/index.page.ts +166 -0
- package/components/message/worker.ts +110 -0
- package/components/messagepad/DialogueListItem.page.styl +28 -0
- package/components/messagepad/DialogueListItemComponent.jsx +39 -0
- package/components/messagepad/Message.page.styl +64 -0
- package/components/messagepad/MessageComponent.jsx +33 -0
- package/components/messagepad/MessagePad.page.styl +99 -0
- package/components/messagepad/MessagePadDialogueContentContainer.jsx +104 -0
- package/components/messagepad/MessagePadDialogueListContainer.jsx +49 -0
- package/components/messagepad/MessagePadInputContainer.jsx +100 -0
- package/components/messagepad/index.jsx +49 -0
- package/components/messagepad/reducers/activeId.ts +36 -0
- package/components/messagepad/reducers/dialogues.js +53 -0
- package/components/messagepad/reducers/index.ts +14 -0
- package/components/messagepad/reducers/inputs.js +43 -0
- package/components/messagepad/reducers/isPosting.ts +49 -0
- package/components/monaco/index.ts +178 -0
- package/components/monaco/languages/markdown.ts +97 -0
- package/components/monaco/languages/typescript.ts +45 -0
- package/components/monaco/languages/yaml.ts +22 -0
- package/components/monaco/loader.ts +96 -0
- package/components/monaco/monaco.styl +30 -0
- package/components/monaco/nls.js +31 -0
- package/components/monaco/schema/problemconfig.ts +123 -0
- package/components/navigation/hamburgers.page.styl +87 -0
- package/components/navigation/nav-logo-small_dark.png +0 -0
- package/components/navigation/navigation.page.js +203 -0
- package/components/navigation/navigation.page.styl +211 -0
- package/components/notification/index.ts +105 -0
- package/components/notification/notification.page.js +14 -0
- package/components/notification/notification.page.styl +84 -0
- package/components/nprogress.page.styl +50 -0
- package/components/omnisearch/index.page.tsx +124 -0
- package/components/omnisearch/omnibar.page.styl +138 -0
- package/components/pager/pager.page.styl +57 -0
- package/components/preview/preview.page.ts +187 -0
- package/components/problem/create.page.js +12 -0
- package/components/problem/list.page.js +9 -0
- package/components/problem/rp.page.styl +4 -0
- package/components/problem/tag.page.styl +84 -0
- package/components/problemconfig/BasicForm.tsx +92 -0
- package/components/problemconfig/ProblemConfigEditor.tsx +170 -0
- package/components/problemconfig/ProblemConfigForm.tsx +140 -0
- package/components/problemconfig/ProblemConfigTree.tsx +163 -0
- package/components/problemconfig/ProblemType.tsx +165 -0
- package/components/problemconfig/index.tsx +91 -0
- package/components/problemconfig/reducer/config.ts +173 -0
- package/components/problemconfig/reducer/index.ts +11 -0
- package/components/problemconfig/reducer/testdata.ts +16 -0
- package/components/problemconfig/tree/AddTestcase.tsx +137 -0
- package/components/problemconfig/tree/SelectionManager.tsx +140 -0
- package/components/problemconfig/tree/SubtaskSettings.tsx +180 -0
- package/components/problemconfig/tree/Testcase.tsx +98 -0
- package/components/profile/backgrounds/1.jpg +0 -0
- package/components/profile/backgrounds/10.jpg +0 -0
- package/components/profile/backgrounds/11.jpg +0 -0
- package/components/profile/backgrounds/12.jpg +0 -0
- package/components/profile/backgrounds/13.jpg +0 -0
- package/components/profile/backgrounds/14.jpg +0 -0
- package/components/profile/backgrounds/15.jpg +0 -0
- package/components/profile/backgrounds/16.jpg +0 -0
- package/components/profile/backgrounds/17.jpg +0 -0
- package/components/profile/backgrounds/18.jpg +0 -0
- package/components/profile/backgrounds/19.jpg +0 -0
- package/components/profile/backgrounds/2.jpg +0 -0
- package/components/profile/backgrounds/20.jpg +0 -0
- package/components/profile/backgrounds/21.jpg +0 -0
- package/components/profile/backgrounds/3.jpg +0 -0
- package/components/profile/backgrounds/4.jpg +0 -0
- package/components/profile/backgrounds/5.jpg +0 -0
- package/components/profile/backgrounds/6.jpg +0 -0
- package/components/profile/backgrounds/7.jpg +0 -0
- package/components/profile/backgrounds/8.jpg +0 -0
- package/components/profile/backgrounds/9.jpg +0 -0
- package/components/profile/backgrounds/gen_thumbnails.sh +7 -0
- package/components/profile/backgrounds/thumbnail/1.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/10.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/11.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/12.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/13.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/14.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/15.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/16.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/17.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/18.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/19.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/2.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/20.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/21.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/3.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/4.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/5.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/6.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/7.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/8.jpg +0 -0
- package/components/profile/backgrounds/thumbnail/9.jpg +0 -0
- package/components/profile/profile.page.styl +23 -0
- package/components/react/DomComponent.tsx +14 -0
- package/components/react/IconComponent.tsx +20 -0
- package/components/record/record.page.styl +26 -0
- package/components/rotator/index.js +75 -0
- package/components/rotator/rotator.page.styl +20 -0
- package/components/scratchpad/DataInput.page.styl +17 -0
- package/components/scratchpad/DataInputComponent.jsx +45 -0
- package/components/scratchpad/Editor.page.styl +13 -0
- package/components/scratchpad/Panel.page.styl +18 -0
- package/components/scratchpad/PanelButton.page.styl +15 -0
- package/components/scratchpad/PanelButtonComponent.jsx +19 -0
- package/components/scratchpad/PanelComponent.jsx +25 -0
- package/components/scratchpad/ScratchpadEditorContainer.tsx +137 -0
- package/components/scratchpad/ScratchpadPretestContainer.jsx +57 -0
- package/components/scratchpad/ScratchpadRecordsContainer.jsx +45 -0
- package/components/scratchpad/ScratchpadRecordsRowContainer.jsx +83 -0
- package/components/scratchpad/ScratchpadSettings.tsx +48 -0
- package/components/scratchpad/ScratchpadToolbarContainer.jsx +190 -0
- package/components/scratchpad/Tab.page.styl +24 -0
- package/components/scratchpad/Toolbar.page.styl +53 -0
- package/components/scratchpad/ToolbarComponent.jsx +85 -0
- package/components/scratchpad/index.tsx +132 -0
- package/components/scratchpad/reducers/editor.ts +24 -0
- package/components/scratchpad/reducers/index.ts +17 -0
- package/components/scratchpad/reducers/pretest.ts +34 -0
- package/components/scratchpad/reducers/records.ts +40 -0
- package/components/scratchpad/reducers/state.ts +10 -0
- package/components/scratchpad/reducers/ui.ts +152 -0
- package/components/scratchpad/scratchpad.page.styl +55 -0
- package/components/scratchpad/var.inc.styl +2 -0
- package/components/selectUser.tsx +16 -0
- package/components/signin/signInDialog.page.js +84 -0
- package/components/signin/signin_dialog.page.styl +57 -0
- package/components/smoothscroll/smoothscroll.page.js +44 -0
- package/components/socket/index.ts +68 -0
- package/components/star/star.page.styl +20 -0
- package/components/star/star.page.ts +58 -0
- package/components/sticky/sticky.page.js +66 -0
- package/components/tab/Tab.js +168 -0
- package/components/tab/tab.page.js +9 -0
- package/components/tab/tab.page.styl +105 -0
- package/components/tab/var.inc.styl +3 -0
- package/components/table/StyledTable.js +51 -0
- package/components/table/styledTable.page.js +8 -0
- package/components/table/table.page.styl +73 -0
- package/components/time/time.page.js +47 -0
- package/components/tooltip/Tooltip.js +49 -0
- package/components/tooltip/tooltip.page.js +29 -0
- package/components/tooltip/tooltip.page.styl +69 -0
- package/components/training/training.page.styl +25 -0
- package/components/upload.tsx +103 -0
- package/components/vote/vote.page.js +43 -0
- package/components/zipDownloader/index.ts +157 -0
- package/constant/domain.js +21 -0
- package/constant/message.js +5 -0
- package/constant/record.js +52 -0
- package/context.ts +11 -0
- package/entry.js +72 -0
- package/hydro.ts +112 -0
- package/index.ts +226 -0
- package/lazyload.ts +69 -0
- package/locales/en.yaml +71 -0
- package/locales/ko.yaml +823 -0
- package/locales/zh.yaml +1137 -0
- package/locales/zh_TW.yaml +1133 -0
- package/misc/Page.ts +49 -0
- package/misc/PageLoader.js +31 -0
- package/misc/float.styl +14 -0
- package/misc/grid.styl +1048 -0
- package/misc/immersive-background.jpg +0 -0
- package/misc/immersive-background@2x.jpg +0 -0
- package/misc/immersive.styl +23 -0
- package/misc/nothing.styl +13 -0
- package/misc/puzzled_twd2.svg +1 -0
- package/misc/section.styl +105 -0
- package/misc/slideout.styl +46 -0
- package/misc/structure.styl +158 -0
- package/misc/textalign.styl +11 -0
- package/misc/typography.styl +485 -0
- package/package.json +148 -0
- package/polyfill.ts +90 -0
- package/postcss.config.js +15 -0
- package/sentry.ts +26 -0
- package/service-worker.ts +265 -0
- package/setting.yaml +98 -0
- package/templates/about.html +14 -0
- package/templates/bsod.html +35 -0
- package/templates/components/comments_discussion.html +165 -0
- package/templates/components/comments_solution.html +171 -0
- package/templates/components/contest.html +12 -0
- package/templates/components/form.html +214 -0
- package/templates/components/home.html +20 -0
- package/templates/components/homework.html +8 -0
- package/templates/components/md_hint.html +39 -0
- package/templates/components/noscript_note.html +15 -0
- package/templates/components/nothing.html +6 -0
- package/templates/components/paginator.html +25 -0
- package/templates/components/problem.html +33 -0
- package/templates/components/record.html +21 -0
- package/templates/components/sidemenu.html +11 -0
- package/templates/components/user.html +49 -0
- package/templates/contest_balloon.html +48 -0
- package/templates/contest_clarification.html +103 -0
- package/templates/contest_detail.html +56 -0
- package/templates/contest_edit.html +259 -0
- package/templates/contest_main.html +146 -0
- package/templates/contest_manage.html +80 -0
- package/templates/contest_print.html +27 -0
- package/templates/contest_problemlist.html +231 -0
- package/templates/contest_scoreboard.html +46 -0
- package/templates/contest_scoreboard_download_html.html +71 -0
- package/templates/contest_user.html +47 -0
- package/templates/discussion_create.html +28 -0
- package/templates/discussion_detail.html +149 -0
- package/templates/discussion_edit.html +30 -0
- package/templates/discussion_main_or_node.html +47 -0
- package/templates/domain_base.html +26 -0
- package/templates/domain_create.html +55 -0
- package/templates/domain_dashboard.html +45 -0
- package/templates/domain_edit.html +6 -0
- package/templates/domain_group.html +51 -0
- package/templates/domain_join.html +47 -0
- package/templates/domain_join_applications.html +67 -0
- package/templates/domain_permission.html +66 -0
- package/templates/domain_role.html +71 -0
- package/templates/domain_user.html +86 -0
- package/templates/domain_user_raw.html +5 -0
- package/templates/error.html +25 -0
- package/templates/home_domain.html +64 -0
- package/templates/home_files.html +16 -0
- package/templates/home_messages.html +9 -0
- package/templates/home_security.html +224 -0
- package/templates/home_settings.html +21 -0
- package/templates/homework_detail.html +82 -0
- package/templates/homework_edit.html +138 -0
- package/templates/homework_files.html +24 -0
- package/templates/homework_main.html +76 -0
- package/templates/layout/basic.html +27 -0
- package/templates/layout/home_base.html +13 -0
- package/templates/layout/html5.html +74 -0
- package/templates/layout/immersive.html +22 -0
- package/templates/layout/mail.html +31 -0
- package/templates/layout/simple.html +4 -0
- package/templates/layout/wiki_base.html +16 -0
- package/templates/main.html +22 -0
- package/templates/manage_base.html +24 -0
- package/templates/manage_config.html +6 -0
- package/templates/manage_dashboard.html +27 -0
- package/templates/manage_script.html +56 -0
- package/templates/manage_setting.html +6 -0
- package/templates/manage_user_import.html +23 -0
- package/templates/manage_user_priv.html +76 -0
- package/templates/partials/category.html +19 -0
- package/templates/partials/contest.html +3 -0
- package/templates/partials/contest_balloon.html +37 -0
- package/templates/partials/contest_sidebar.html +150 -0
- package/templates/partials/contest_sidebar_management.html +56 -0
- package/templates/partials/contest_user.html +19 -0
- package/templates/partials/discussion_edit_form.html +45 -0
- package/templates/partials/discussion_list.html +50 -0
- package/templates/partials/discussion_nodes_widget.html +17 -0
- package/templates/partials/files.html +49 -0
- package/templates/partials/footer.html +108 -0
- package/templates/partials/hamburger.html +7 -0
- package/templates/partials/header_mobile.html +12 -0
- package/templates/partials/homepage/bulletin.html +7 -0
- package/templates/partials/homepage/contest.html +48 -0
- package/templates/partials/homepage/discussion.html +13 -0
- package/templates/partials/homepage/discussion_nodes.html +4 -0
- package/templates/partials/homepage/error.html +5 -0
- package/templates/partials/homepage/hitokoto.html +6 -0
- package/templates/partials/homepage/homework.html +45 -0
- package/templates/partials/homepage/problem_search.html +13 -0
- package/templates/partials/homepage/ranking.html +39 -0
- package/templates/partials/homepage/recent_problems.html +17 -0
- package/templates/partials/homepage/starred_problems.html +15 -0
- package/templates/partials/homepage/suggestion.html +34 -0
- package/templates/partials/homepage/training.html +50 -0
- package/templates/partials/homework.html +3 -0
- package/templates/partials/homework_default_penalty_rules.yaml +6 -0
- package/templates/partials/homework_sidebar.html +93 -0
- package/templates/partials/login_dialog.html +56 -0
- package/templates/partials/manage_user_priv.html +78 -0
- package/templates/partials/nav.html +138 -0
- package/templates/partials/problem-sidebar-information.html +25 -0
- package/templates/partials/problem.html +2 -0
- package/templates/partials/problem_category_dialog.html +43 -0
- package/templates/partials/problem_default.md +26 -0
- package/templates/partials/problem_description.html +33 -0
- package/templates/partials/problem_files.html +63 -0
- package/templates/partials/problem_list.html +68 -0
- package/templates/partials/problem_lucky.html +10 -0
- package/templates/partials/problem_sidebar.html +14 -0
- package/templates/partials/problem_sidebar_contest.html +43 -0
- package/templates/partials/problem_sidebar_homework.html +42 -0
- package/templates/partials/problem_sidebar_normal.html +152 -0
- package/templates/partials/problem_stat.html +3 -0
- package/templates/partials/scoreboard.html +79 -0
- package/templates/partials/setting.html +92 -0
- package/templates/partials/training_default.json +14 -0
- package/templates/partials/training_detail.html +153 -0
- package/templates/partials/user.html +2 -0
- package/templates/partials/user_detail/activity.html +18 -0
- package/templates/partials/user_detail/solution.html +29 -0
- package/templates/problem_config.html +39 -0
- package/templates/problem_detail.html +150 -0
- package/templates/problem_edit.html +111 -0
- package/templates/problem_files.html +91 -0
- package/templates/problem_hack.html +41 -0
- package/templates/problem_import.html +58 -0
- package/templates/problem_main.html +100 -0
- package/templates/problem_solution.html +55 -0
- package/templates/problem_statistics.html +96 -0
- package/templates/problem_submit.html +40 -0
- package/templates/ranking.html +81 -0
- package/templates/record_detail.html +134 -0
- package/templates/record_detail_status.html +93 -0
- package/templates/record_detail_summary.html +19 -0
- package/templates/record_main.html +142 -0
- package/templates/record_main_tr.html +35 -0
- package/templates/status.html +75 -0
- package/templates/training_detail.html +120 -0
- package/templates/training_edit.html +68 -0
- package/templates/training_files.html +64 -0
- package/templates/training_main.html +107 -0
- package/templates/user_changemail_mail.html +6 -0
- package/templates/user_changemail_mail_sent.html +9 -0
- package/templates/user_delete_pending.html +10 -0
- package/templates/user_detail.html +181 -0
- package/templates/user_login.html +46 -0
- package/templates/user_logout.html +13 -0
- package/templates/user_lostpass.html +27 -0
- package/templates/user_lostpass_mail.html +6 -0
- package/templates/user_lostpass_mail_sent.html +9 -0
- package/templates/user_lostpass_with_code.html +29 -0
- package/templates/user_register.html +22 -0
- package/templates/user_register_mail.html +6 -0
- package/templates/user_register_mail_sent.html +9 -0
- package/templates/user_register_with_code.html +35 -0
- package/templates/user_sudo.html +54 -0
- package/templates/user_sudo_redirect.html +18 -0
- package/templates/wiki_help.html +189 -0
- package/theme/bp6-compat.css +48 -0
- package/theme/dark.styl +397 -0
- package/theme/default.js +33 -0
- package/typed.d.ts +20 -0
- package/utils/base.ts +209 -0
- package/utils/base64.js +104 -0
- package/utils/db.ts +32 -0
- package/utils/index.ts +73 -0
- package/utils/loadReactRedux.ts +32 -0
- package/utils/mediaQuery.ts +13 -0
- package/utils/pjax.js +148 -0
- package/utils/slide.ts +57 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Please note that accepted < others, rp system uses this feature.
|
|
2
|
+
import { STATUS } from '@hydrooj/common';
|
|
3
|
+
export { STATUS, STATUS_TEXTS } from '@hydrooj/common';
|
|
4
|
+
|
|
5
|
+
export const STATUS_CODES = {
|
|
6
|
+
[STATUS.STATUS_WAITING]: 'pending',
|
|
7
|
+
[STATUS.STATUS_ACCEPTED]: 'pass',
|
|
8
|
+
[STATUS.STATUS_WRONG_ANSWER]: 'fail',
|
|
9
|
+
[STATUS.STATUS_TIME_LIMIT_EXCEEDED]: 'fail',
|
|
10
|
+
[STATUS.STATUS_MEMORY_LIMIT_EXCEEDED]: 'fail',
|
|
11
|
+
[STATUS.STATUS_OUTPUT_LIMIT_EXCEEDED]: 'fail',
|
|
12
|
+
[STATUS.STATUS_RUNTIME_ERROR]: 'fail',
|
|
13
|
+
[STATUS.STATUS_COMPILE_ERROR]: 'fail',
|
|
14
|
+
[STATUS.STATUS_SYSTEM_ERROR]: 'fail',
|
|
15
|
+
[STATUS.STATUS_CANCELED]: 'ignored',
|
|
16
|
+
[STATUS.STATUS_ETC]: 'fail',
|
|
17
|
+
[STATUS.STATUS_JUDGING]: 'progress',
|
|
18
|
+
[STATUS.STATUS_COMPILING]: 'progress',
|
|
19
|
+
[STATUS.STATTUS_FETCHED]: 'progress',
|
|
20
|
+
[STATUS.STATUS_IGNORED]: 'ignored',
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Whether to show detail about each test case for a submission status
|
|
25
|
+
*/
|
|
26
|
+
export const STATUS_SCRATCHPAD_SHOW_DETAIL_FLAGS = {
|
|
27
|
+
[STATUS.STATUS_WAITING]: false,
|
|
28
|
+
[STATUS.STATUS_ACCEPTED]: true,
|
|
29
|
+
[STATUS.STATUS_WRONG_ANSWER]: true,
|
|
30
|
+
[STATUS.STATUS_TIME_LIMIT_EXCEEDED]: true,
|
|
31
|
+
[STATUS.STATUS_MEMORY_LIMIT_EXCEEDED]: true,
|
|
32
|
+
[STATUS.STATUS_RUNTIME_ERROR]: true,
|
|
33
|
+
[STATUS.STATUS_COMPILE_ERROR]: false,
|
|
34
|
+
[STATUS.STATUS_SYSTEM_ERROR]: false,
|
|
35
|
+
[STATUS.STATUS_CANCELED]: false,
|
|
36
|
+
[STATUS.STATUS_ETC]: false,
|
|
37
|
+
[STATUS.STATUS_JUDGING]: false,
|
|
38
|
+
[STATUS.STATUS_COMPILING]: false,
|
|
39
|
+
[STATUS.STATUS_FETCHED]: false,
|
|
40
|
+
[STATUS.STATUS_IGNORED]: false,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Short text to show in Scratchpad mode
|
|
45
|
+
*/
|
|
46
|
+
export const STATUS_SCRATCHPAD_SHORT_TEXTS = {
|
|
47
|
+
[STATUS.STATUS_ACCEPTED]: 'AC',
|
|
48
|
+
[STATUS.STATUS_WRONG_ANSWER]: 'WA',
|
|
49
|
+
[STATUS.STATUS_TIME_LIMIT_EXCEEDED]: 'TLE',
|
|
50
|
+
[STATUS.STATUS_MEMORY_LIMIT_EXCEEDED]: 'MLE',
|
|
51
|
+
[STATUS.STATUS_RUNTIME_ERROR]: 'RTE',
|
|
52
|
+
};
|
package/context.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Context } from 'cordis';
|
|
2
|
+
import type { EventMap } from './api';
|
|
3
|
+
|
|
4
|
+
declare module 'cordis' {
|
|
5
|
+
export interface Events extends EventMap { }
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type { Disposable, Plugin } from 'cordis';
|
|
9
|
+
export { Context, Fiber, FiberState, Service } from 'cordis';
|
|
10
|
+
|
|
11
|
+
export const ctx = new Context();
|
package/entry.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import './polyfill';
|
|
2
|
+
|
|
3
|
+
import $ from 'jquery';
|
|
4
|
+
|
|
5
|
+
window.Hydro = {
|
|
6
|
+
extraPages: [],
|
|
7
|
+
components: {},
|
|
8
|
+
version: process.env.VERSION,
|
|
9
|
+
};
|
|
10
|
+
window.externalModules = {};
|
|
11
|
+
window.lazyModuleResolver = {};
|
|
12
|
+
|
|
13
|
+
console.log(
|
|
14
|
+
'%c%s%c%s',
|
|
15
|
+
'color:red;font-size:24px;',
|
|
16
|
+
' Welcome to\n',
|
|
17
|
+
'color:blue;font-weight:bold;',
|
|
18
|
+
`\
|
|
19
|
+
__ __ __
|
|
20
|
+
/ / / /_ ______/ /________
|
|
21
|
+
/ /_/ / / / / __ / ___/ __ \\
|
|
22
|
+
/ __ / /_/ / /_/ / / / /_/ /
|
|
23
|
+
/_/ /_/\\__, /\\__,_/_/ \\____/
|
|
24
|
+
/____/
|
|
25
|
+
`,
|
|
26
|
+
);
|
|
27
|
+
|
|
28
|
+
window.UiContext = JSON.parse(window.UiContext);
|
|
29
|
+
window.UserContext = JSON.parse(window.UserContext);
|
|
30
|
+
try {
|
|
31
|
+
__webpack_public_path__ = UiContext.cdn_prefix;
|
|
32
|
+
} catch (e) { }
|
|
33
|
+
if ('serviceWorker' in navigator) {
|
|
34
|
+
const sendConfig = () => fetch('/service-worker-config', {
|
|
35
|
+
method: 'POST',
|
|
36
|
+
headers: { 'Content-Type': 'application/json' },
|
|
37
|
+
body: JSON.stringify(UiContext.SWConfig),
|
|
38
|
+
});
|
|
39
|
+
navigator.serviceWorker.register('/service-worker.js').then((registration) => {
|
|
40
|
+
console.log('SW registered: ', registration);
|
|
41
|
+
const sw = registration.active || registration.waiting || registration.installing;
|
|
42
|
+
if (sw.state === 'activated') sendConfig();
|
|
43
|
+
else {
|
|
44
|
+
sw.addEventListener('statechange', (e) => {
|
|
45
|
+
if (e.target.state === 'activated') sendConfig();
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}).catch((registrationError) => {
|
|
49
|
+
console.log('SW registration failed: ', registrationError);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const PageLoader = '<div class="page-loader nojs--hide" style="display:none;"><div class="loader"></div></div>';
|
|
54
|
+
$('body').prepend(PageLoader);
|
|
55
|
+
$('.page-loader').fadeIn(500);
|
|
56
|
+
if (process.env.NODE_ENV === 'production' && UiContext.sentry_dsn) {
|
|
57
|
+
window._sentryEvents = [];
|
|
58
|
+
window.captureException = (e) => {
|
|
59
|
+
if (!e.isUserFacingError) window._sentryEvents.push(e);
|
|
60
|
+
};
|
|
61
|
+
const script = document.createElement('script');
|
|
62
|
+
script.src = '/sentry.js';
|
|
63
|
+
document.body.appendChild(script);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
document.addEventListener('DOMContentLoaded', async () => {
|
|
67
|
+
Object.assign(window.UiContext, JSON.parse(window.UiContextNew));
|
|
68
|
+
Object.assign(window.UserContext, JSON.parse(window.UserContextNew));
|
|
69
|
+
window.HydroExports = await import('./api');
|
|
70
|
+
await window._hydroLoad();
|
|
71
|
+
await window.HydroExports.initPageLoader();
|
|
72
|
+
}, false);
|
package/hydro.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import 'jquery.transit';
|
|
2
|
+
|
|
3
|
+
import $ from 'jquery';
|
|
4
|
+
import _ from 'lodash';
|
|
5
|
+
import Notification from 'vj/components/notification';
|
|
6
|
+
import PageLoader from 'vj/misc/PageLoader';
|
|
7
|
+
import { delay } from 'vj/utils';
|
|
8
|
+
|
|
9
|
+
declare global {
|
|
10
|
+
interface Window {
|
|
11
|
+
UserContext: any;
|
|
12
|
+
UiContext: any;
|
|
13
|
+
Hydro: any;
|
|
14
|
+
/** @deprecated */
|
|
15
|
+
externalModules: Record<string, string>;
|
|
16
|
+
captureException?: (e: Error) => void;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const start = new Date();
|
|
21
|
+
|
|
22
|
+
function buildSequence(pages, type) {
|
|
23
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
24
|
+
if (!['before', 'after'].includes(type)) {
|
|
25
|
+
throw new Error("'type' should be one of 'before' or 'after'");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return pages
|
|
29
|
+
.filter((p) => p && p[`${type}Loading`])
|
|
30
|
+
.map((p) => ({
|
|
31
|
+
page: p,
|
|
32
|
+
func: p[`${type}Loading`],
|
|
33
|
+
type,
|
|
34
|
+
}));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function rounded() {
|
|
38
|
+
if (!UserContext.rounded) return;
|
|
39
|
+
const style = document.createElement('style');
|
|
40
|
+
style.innerHTML = `
|
|
41
|
+
.section { border-radius: 8px; }
|
|
42
|
+
.section__table-header { border-radius: 8px 8px 0 0; }
|
|
43
|
+
`;
|
|
44
|
+
document.head.append(style);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function animate() {
|
|
48
|
+
if (UserContext.skipAnimate) return;
|
|
49
|
+
const style = document.createElement('style');
|
|
50
|
+
style.innerHTML = `.section {
|
|
51
|
+
transition: transform .5s, opacity .5s;
|
|
52
|
+
transition-timing-function: ease-out-cubic;
|
|
53
|
+
}`;
|
|
54
|
+
document.head.append(style);
|
|
55
|
+
const sections = _.map($('.section').get(), (section, idx) => ({
|
|
56
|
+
shouldDelay: idx < 5, // only animate first 5 sections
|
|
57
|
+
$element: $(section),
|
|
58
|
+
}));
|
|
59
|
+
for (const { $element, shouldDelay } of sections) {
|
|
60
|
+
$element.addClass('visible');
|
|
61
|
+
if (shouldDelay) await delay(50);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export async function initPageLoader() {
|
|
66
|
+
const pageLoader = new PageLoader();
|
|
67
|
+
rounded();
|
|
68
|
+
|
|
69
|
+
const currentPageName = document.documentElement.getAttribute('data-page');
|
|
70
|
+
const currentPage = pageLoader.getNamedPage(currentPageName);
|
|
71
|
+
const includedPages = pageLoader.getAutoloadPages();
|
|
72
|
+
const loadSequence = [
|
|
73
|
+
...buildSequence(includedPages, 'before'),
|
|
74
|
+
...buildSequence(currentPage, 'before'),
|
|
75
|
+
...buildSequence(includedPages, 'after'),
|
|
76
|
+
...buildSequence(currentPage, 'after'),
|
|
77
|
+
];
|
|
78
|
+
const loadPage = (depth: number, type: 'before' | 'after') => async (name: string) => {
|
|
79
|
+
if (depth > 32) {
|
|
80
|
+
console.error('loadPage depth', depth);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
for (const { func } of buildSequence(pageLoader.getPage(name), type)) {
|
|
84
|
+
await func(name, loadPage(depth + 1, type));
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
for (const { page, func, type } of loadSequence) {
|
|
88
|
+
const ts = Date.now();
|
|
89
|
+
try {
|
|
90
|
+
await func(currentPageName, loadPage(1, type));
|
|
91
|
+
} catch (e) {
|
|
92
|
+
(window as any).captureException?.(e);
|
|
93
|
+
Notification.warn(`Failed to call '${type}Loading' of ${page.name}`);
|
|
94
|
+
console.error(`Failed to call '${type}Loading' of ${page.name}\n${e.stack}`);
|
|
95
|
+
console.error(e);
|
|
96
|
+
}
|
|
97
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
98
|
+
console.time(`${page.name}: ${type}Loading`);
|
|
99
|
+
}
|
|
100
|
+
const time = Date.now() - ts;
|
|
101
|
+
if ((process.env.NODE_ENV !== 'production' && time > 16) || time > 256) {
|
|
102
|
+
console.log(`${page.name}: ${type}Loading took ${time}ms`);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
console.log('done! %d ms', Date.now() - start.getTime());
|
|
106
|
+
$('.page-loader').hide();
|
|
107
|
+
await animate();
|
|
108
|
+
$('.section').addClass('visible');
|
|
109
|
+
await delay(500);
|
|
110
|
+
$('.section').trigger('vjLayout');
|
|
111
|
+
$(document).trigger('vjPageFullyInitialized');
|
|
112
|
+
}
|
package/index.ts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { readFileSync } from 'fs';
|
|
2
|
+
import { join } from 'path';
|
|
3
|
+
import {
|
|
4
|
+
ContestModel, Context, Handler, ObjectId, param, PERM, PRIV, ProblemModel, Schema,
|
|
5
|
+
SettingModel, SystemModel, Types, UserModel, yaml,
|
|
6
|
+
} from 'hydrooj';
|
|
7
|
+
import convert from 'schemastery-jsonschema';
|
|
8
|
+
import markdown from './backendlib/markdown';
|
|
9
|
+
import { TemplateService } from './backendlib/template';
|
|
10
|
+
|
|
11
|
+
class WikiHelpHandler extends Handler {
|
|
12
|
+
noCheckPermView = true;
|
|
13
|
+
|
|
14
|
+
async get() {
|
|
15
|
+
this.response.template = 'wiki_help.html';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class WikiAboutHandler extends Handler {
|
|
20
|
+
noCheckPermView = true;
|
|
21
|
+
|
|
22
|
+
async get() {
|
|
23
|
+
let raw = SystemModel.get('ui-default.about') || '';
|
|
24
|
+
// TODO template engine
|
|
25
|
+
raw = raw.replace(/\{\{ name \}\}/g, this.domain.ui?.name || SystemModel.get('server.name')).trim();
|
|
26
|
+
const lines = raw.split('\n');
|
|
27
|
+
const sections: { id: string, title: string, content: string }[] = [];
|
|
28
|
+
for (const line of lines) {
|
|
29
|
+
if (line.startsWith('# ')) {
|
|
30
|
+
const id = line.split(' ')[1];
|
|
31
|
+
sections.push({
|
|
32
|
+
id,
|
|
33
|
+
title: line.split(id)[1].trim(),
|
|
34
|
+
content: '',
|
|
35
|
+
});
|
|
36
|
+
} else sections[sections.length - 1].content += `${line}\n`;
|
|
37
|
+
}
|
|
38
|
+
this.response.template = 'about.html';
|
|
39
|
+
this.response.body = { sections };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
class SetThemeHandler extends Handler {
|
|
44
|
+
noCheckPermView = true;
|
|
45
|
+
|
|
46
|
+
async get({ theme }) {
|
|
47
|
+
this.checkPriv(PRIV.PRIV_USER_PROFILE);
|
|
48
|
+
await UserModel.setById(this.user._id, { theme });
|
|
49
|
+
this.back();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
class LegacyModeHandler extends Handler {
|
|
54
|
+
noCheckPermView = true;
|
|
55
|
+
|
|
56
|
+
@param('legacy', Types.Boolean)
|
|
57
|
+
@param('nohint', Types.Boolean)
|
|
58
|
+
async get({ }, legacy = false, nohint = false) {
|
|
59
|
+
this.session.legacy = legacy;
|
|
60
|
+
this.session.nohint = nohint;
|
|
61
|
+
this.back();
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
class MarkdownHandler extends Handler {
|
|
66
|
+
noCheckPermView = true;
|
|
67
|
+
|
|
68
|
+
async post({ text, inline = false }) {
|
|
69
|
+
this.response.body = inline
|
|
70
|
+
? markdown.renderInline(text)
|
|
71
|
+
: markdown.render(text);
|
|
72
|
+
this.response.type = 'text/html';
|
|
73
|
+
this.response.status = 200;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
class SystemConfigSchemaHandler extends Handler {
|
|
78
|
+
async get() {
|
|
79
|
+
const schema = convert(Schema.intersect(this.ctx.setting.settings) as any, true);
|
|
80
|
+
this.response.body = schema;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
class RichMediaHandler extends Handler {
|
|
85
|
+
async renderUser(domainId, payload) {
|
|
86
|
+
let d = payload.domainId || domainId;
|
|
87
|
+
const cur = payload.domainId ? await UserModel.getById(payload.domainId, this.user._id) : this.user;
|
|
88
|
+
if (!cur.hasPerm(PERM.PERM_VIEW)) d = domainId;
|
|
89
|
+
const udoc = Number.isNaN(+payload.id) ? await UserModel.getByUname(d, payload.id) : await UserModel.getById(d, +payload.id);
|
|
90
|
+
return await this.renderHTML('partials/user.html', { udoc });
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
async renderProblem(domainId, payload) {
|
|
94
|
+
const cur = payload.domainId ? await UserModel.getById(payload.domainId, this.user._id) : this.user;
|
|
95
|
+
let pdoc = cur.hasPerm(PERM.PERM_VIEW | PERM.PERM_VIEW_PROBLEM)
|
|
96
|
+
? await ProblemModel.get(payload.domainId || domainId, payload.id) || ProblemModel.default
|
|
97
|
+
: ProblemModel.default;
|
|
98
|
+
if (pdoc.hidden && !cur.own(pdoc) && !cur.hasPerm(PERM.PERM_VIEW_PROBLEM_HIDDEN)) pdoc = ProblemModel.default;
|
|
99
|
+
return await this.renderHTML('partials/problem.html', { pdoc });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async renderContest(domainId, payload) {
|
|
103
|
+
const cur = payload.domainId ? await UserModel.getById(payload.domainId, this.user._id) : this.user;
|
|
104
|
+
const tdoc = cur.hasPerm(PERM.PERM_VIEW | PERM.PERM_VIEW_CONTEST)
|
|
105
|
+
? await ContestModel.get(payload.domainId || domainId, new ObjectId(payload.id))
|
|
106
|
+
: null;
|
|
107
|
+
if (tdoc) return await this.renderHTML('partials/contest.html', { tdoc });
|
|
108
|
+
return '';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
async renderHomework(domainId, payload) {
|
|
112
|
+
const cur = payload.domainId ? await UserModel.getById(payload.domainId, this.user._id) : this.user;
|
|
113
|
+
const tdoc = cur.hasPerm(PERM.PERM_VIEW | PERM.PERM_VIEW_HOMEWORK)
|
|
114
|
+
? await ContestModel.get(payload.domainId || domainId, new ObjectId(payload.id))
|
|
115
|
+
: null;
|
|
116
|
+
if (tdoc) return await this.renderHTML('partials/homework.html', { tdoc });
|
|
117
|
+
return '';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
async post({ domainId, items }) {
|
|
121
|
+
const res: any[] = [];
|
|
122
|
+
for (const item of items || []) {
|
|
123
|
+
if (item.domainId && item.domainId === domainId) delete item.domainId;
|
|
124
|
+
if (item.type === 'user') res.push(this.renderUser(domainId, item).catch(() => ''));
|
|
125
|
+
else if (item.type === 'problem') res.push(this.renderProblem(domainId, item).catch(() => ''));
|
|
126
|
+
else if (item.type === 'contest') res.push(this.renderContest(domainId, item).catch(() => ''));
|
|
127
|
+
else if (item.type === 'homework') res.push(this.renderHomework(domainId, item).catch(() => ''));
|
|
128
|
+
else res.push('');
|
|
129
|
+
}
|
|
130
|
+
this.response.body = await Promise.all(res);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/* eslint-disable style/quote-props */
|
|
135
|
+
const fontRange = {
|
|
136
|
+
'Open Sans': 'Open Sans',
|
|
137
|
+
'Seravek': 'Seravek',
|
|
138
|
+
'Segoe UI': 'Segoe UI',
|
|
139
|
+
'Verdana': 'Verdana',
|
|
140
|
+
'PingFang SC': 'PingFang SC',
|
|
141
|
+
'Hiragino Sans GB': 'Hiragino Sans GB',
|
|
142
|
+
'Microsoft Yahei': 'Microsoft Yahei',
|
|
143
|
+
'WenQuanYi Micro Hei': 'WenQuanYi Micro Hei',
|
|
144
|
+
'sans': 'sans',
|
|
145
|
+
'XiaoLai SC': '小赖 SC',
|
|
146
|
+
};
|
|
147
|
+
const codeFontRange = {
|
|
148
|
+
'monaco': 'Monaco',
|
|
149
|
+
'Source Code Pro': 'Source Code Pro',
|
|
150
|
+
'Consolas': 'Consolas',
|
|
151
|
+
'Lucida Console': 'Lucida Console',
|
|
152
|
+
'Fira Code': 'Fira Code',
|
|
153
|
+
'Roboto Mono': 'Roboto Mono',
|
|
154
|
+
'Inconsolata': 'Inconsolata',
|
|
155
|
+
'Hack': 'Hack',
|
|
156
|
+
'Jetbrains Mono': 'Jetbrains Mono',
|
|
157
|
+
'DM Mono': 'DM Mono',
|
|
158
|
+
'Ubuntu Mono': 'Ubuntu Mono',
|
|
159
|
+
'PT Mono': 'PT Mono',
|
|
160
|
+
'SF Mono': 'SF Mono',
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
const defaultAbout = (yaml.load(readFileSync(join(__dirname, 'setting.yaml'), 'utf-8')) as any).about.value;
|
|
164
|
+
|
|
165
|
+
export const name = 'ui-default';
|
|
166
|
+
export const Config = Schema.object({
|
|
167
|
+
serviceWorker: Schema.object({
|
|
168
|
+
preload: Schema.string().default(''),
|
|
169
|
+
assets: Schema.array(Schema.string()).default([]),
|
|
170
|
+
domains: Schema.array(Schema.string()).default([]),
|
|
171
|
+
}).description('Service worker optimization settings').experimental(),
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
export function apply(ctx: Context, config: ReturnType<typeof Config>) {
|
|
175
|
+
ctx.inject(['setting'], (c) => {
|
|
176
|
+
c.setting.PreferenceSetting(
|
|
177
|
+
SettingModel.Setting('setting_display', 'rounded', false, 'boolean', 'Rounded Corners'),
|
|
178
|
+
SettingModel.Setting('setting_display', 'skipAnimate', false, 'boolean', 'Skip Animation'),
|
|
179
|
+
SettingModel.Setting('setting_display', 'showTimeAgo', true, 'boolean', 'Enable Time Ago'),
|
|
180
|
+
SettingModel.Setting('setting_display', 'fontFamily', 'Open Sans', fontRange, 'Font Family'),
|
|
181
|
+
SettingModel.Setting('setting_display', 'codeFontFamily', 'Source Code Pro', codeFontRange, 'Code Font Family'),
|
|
182
|
+
SettingModel.Setting('setting_display', 'theme', 'light', { light: 'Light', dark: 'Dark' }, 'Theme'),
|
|
183
|
+
SettingModel.Setting('setting_markdown', 'preferredEditorType', 'sv', { sv: 'Split View', monaco: 'Monaco Editor' }, 'Preferred Editor Type'),
|
|
184
|
+
SettingModel.Setting('setting_highlight', 'showInvisibleChar', false, 'boolean', 'Show Invisible Characters'),
|
|
185
|
+
SettingModel.Setting('setting_highlight', 'formatCode', true, 'boolean', 'Auto Format Code'),
|
|
186
|
+
);
|
|
187
|
+
c.setting.SystemSetting(Schema.object({
|
|
188
|
+
'ui-default': Schema.object({
|
|
189
|
+
footer_extra_html: Schema.string().role('textarea').default(''),
|
|
190
|
+
nav_logo_dark: Schema.string().default('/components/navigation/nav-logo-small_dark.png'),
|
|
191
|
+
domainNavigation: Schema.boolean().default(true).description('Show Domain Navigation'),
|
|
192
|
+
about: Schema.string().role('markdown').default(defaultAbout),
|
|
193
|
+
enableScratchpad: Schema.boolean().default(true).description('Enable Scratchpad Mode'),
|
|
194
|
+
}),
|
|
195
|
+
}));
|
|
196
|
+
ctx.Route('config_schema', '/manage/config/schema.json', SystemConfigSchemaHandler, PRIV.PRIV_EDIT_SYSTEM);
|
|
197
|
+
});
|
|
198
|
+
if (process.env.HYDRO_CLI) return;
|
|
199
|
+
ctx.Route('wiki_help', '/wiki/help', WikiHelpHandler);
|
|
200
|
+
ctx.Route('wiki_about', '/wiki/about', WikiAboutHandler);
|
|
201
|
+
ctx.Route('set_theme', '/set_theme/:theme', SetThemeHandler);
|
|
202
|
+
ctx.Route('set_legacy', '/legacy', LegacyModeHandler);
|
|
203
|
+
ctx.Route('markdown', '/markdown', MarkdownHandler);
|
|
204
|
+
ctx.Route('media', '/media', RichMediaHandler);
|
|
205
|
+
ctx.on('handler/after/DiscussionRaw', async (that) => {
|
|
206
|
+
if (that.args.render && that.response.type === 'text/markdown') {
|
|
207
|
+
that.response.type = 'text/html';
|
|
208
|
+
that.response.body = await markdown.render(that.response.body);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
ctx.on('handler/after', async (that) => {
|
|
212
|
+
that.UiContext.SWConfig = {
|
|
213
|
+
preload: config.serviceWorker.preload,
|
|
214
|
+
hosts: [
|
|
215
|
+
`http://${that.request.host}`,
|
|
216
|
+
`https://${that.request.host}`,
|
|
217
|
+
SystemModel.get('server.url'),
|
|
218
|
+
SystemModel.get('server.cdn'),
|
|
219
|
+
],
|
|
220
|
+
assets: config.serviceWorker.assets,
|
|
221
|
+
domains: config.serviceWorker.domains,
|
|
222
|
+
};
|
|
223
|
+
});
|
|
224
|
+
ctx.plugin(TemplateService);
|
|
225
|
+
ctx.plugin(require('./backendlib/builder'));
|
|
226
|
+
}
|
package/lazyload.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const lazyModules = {};
|
|
2
|
+
const features: Record<string, string | (() => Promise<any>)> = {};
|
|
3
|
+
const host = UiContext.cdn_dynamic ? UiContext.cdn_prefix : '/';
|
|
4
|
+
export default async function load(name: string) {
|
|
5
|
+
if (name === 'echarts') return import('echarts');
|
|
6
|
+
if (name === 'moment') return import('moment');
|
|
7
|
+
if (!window.lazyloadMetadata?.[`${name}.lazy.js`]) throw new Error(`Module ${name} not found`);
|
|
8
|
+
if (lazyModules[name]) return lazyModules[name];
|
|
9
|
+
const tag = document.createElement('script');
|
|
10
|
+
tag.src = `${host}lazy/${window.lazyloadMetadata[`${name}.lazy.js`]}/${name}.lazy.js`;
|
|
11
|
+
console.log('loading module: ', name);
|
|
12
|
+
lazyModules[name] = new Promise((resolve, reject) => {
|
|
13
|
+
tag.onerror = reject;
|
|
14
|
+
const timeout = setTimeout(reject, 30000);
|
|
15
|
+
window.lazyModuleResolver[name] = (item) => {
|
|
16
|
+
clearTimeout(timeout);
|
|
17
|
+
resolve(item);
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
document.body.appendChild(tag);
|
|
21
|
+
return lazyModules[name];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const val: Record<string, any> = {};
|
|
25
|
+
/** @deprecated */
|
|
26
|
+
async function legacyLoadExternalModule(target: string) {
|
|
27
|
+
if (val[target]) return val[target];
|
|
28
|
+
const ele = document.createElement('script');
|
|
29
|
+
ele.src = target;
|
|
30
|
+
await new Promise((resolve, reject) => {
|
|
31
|
+
ele.onload = resolve;
|
|
32
|
+
ele.onerror = reject;
|
|
33
|
+
document.head.appendChild(ele);
|
|
34
|
+
});
|
|
35
|
+
val[target] = window.exports;
|
|
36
|
+
return val[target];
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { load };
|
|
40
|
+
export async function getFeatures(name: string) {
|
|
41
|
+
const legacy = Object.keys(window.externalModules).filter((i) => i === name || i.startsWith(`${name}@`))
|
|
42
|
+
.map((i) => window.externalModules[i]);
|
|
43
|
+
const c = Object.keys(features).filter((i) => i === name || i.startsWith(`${name}@`))
|
|
44
|
+
.map((i) => features[i]);
|
|
45
|
+
console.log('query features for:', name, 'legacy:', legacy, 'selected:', c, 'all:', features);
|
|
46
|
+
return [...c, ...legacy];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export const loaded = [];
|
|
50
|
+
export async function loadFeatures(name: string, ...args: any[]) {
|
|
51
|
+
if (loaded.includes(name)) return;
|
|
52
|
+
loaded.push(name);
|
|
53
|
+
for (const item of await getFeatures(name)) {
|
|
54
|
+
let apply = typeof item === 'function'
|
|
55
|
+
? item
|
|
56
|
+
: (item.startsWith('http') || item.startsWith('/'))
|
|
57
|
+
? await legacyLoadExternalModule(item)
|
|
58
|
+
: (await load(item)).apply;
|
|
59
|
+
if (typeof apply !== 'function') apply = apply.default || apply.apply;
|
|
60
|
+
if (typeof apply === 'function') await apply(...args);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function provideFeature(name: string, content: string | (() => Promise<any>)) {
|
|
65
|
+
console.debug('Providing feature', name);
|
|
66
|
+
if (features[name]) console.warn('Feature', name, 'already provided');
|
|
67
|
+
features[name] = content;
|
|
68
|
+
if (loaded.includes(name)) console.warn('Feature', name, 'already loaded');
|
|
69
|
+
}
|
package/locales/en.yaml
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
__langname: English
|
|
2
|
+
'File IO: {0}': 'File IO: {0}'
|
|
3
|
+
'Tip: You are entering sudo mode.': 'Tip: You are entering <a href="https://docs.github.com/articles/sudo-mode">sudo mode</a>.'
|
|
4
|
+
Can be Extended For: Extension
|
|
5
|
+
Current Status: Status
|
|
6
|
+
Handled Requests: Req
|
|
7
|
+
Hint::icon::difficulty: The difficulty of the problems in Hydro will be calculated by algorithm, depending on current submission, sometimes the difficulty may not so exact.
|
|
8
|
+
Hint::icon::switch_account: As a superadmin, you can switch to anyone's account.
|
|
9
|
+
manage: System Manage
|
|
10
|
+
no_translation_warn: <blockquote class="warn">This part of content is under translation.</blockquote>
|
|
11
|
+
page.problem_detail.sidebar.show_category: Click to Show
|
|
12
|
+
page.training_detail.invalid_when_not_enrolled: You cannot view problem details unless enrolled.
|
|
13
|
+
pager_first: « First
|
|
14
|
+
pager_last: Last »
|
|
15
|
+
pager_next: Next ›
|
|
16
|
+
pager_previous: ‹ Previous
|
|
17
|
+
perm_contest: Contests
|
|
18
|
+
perm_discussion: Discussions
|
|
19
|
+
perm_general: General
|
|
20
|
+
perm_problem_solution: Problem Solutions
|
|
21
|
+
perm_problem: Problems
|
|
22
|
+
perm_record: Records
|
|
23
|
+
perm_training: Trainings
|
|
24
|
+
preferredPrefix_hint: This is used for re-organizing problem IDs. For example, if the ID of the problem in the problemset are P1001, P1002, P1003, and you set "T" in this option, those problem will be imported with ID T1001, T1002 and T1003.
|
|
25
|
+
problem_create: Problem Create
|
|
26
|
+
problem_edit: Problem Edit
|
|
27
|
+
problem_import: Import Problem
|
|
28
|
+
problem_main: Problem Set
|
|
29
|
+
problem_solution: Problem Solution
|
|
30
|
+
problem_submit: Problem Submit
|
|
31
|
+
problem_type.communication: 'Type: Communication'
|
|
32
|
+
problem_type.default: 'Type: Default'
|
|
33
|
+
problem_type.interactive: 'Type: Interactive'
|
|
34
|
+
problem_type.objective: 'Type: Objective'
|
|
35
|
+
problem_type.remote_judge: 'Type: RemoteJudge'
|
|
36
|
+
problem_type.submit_answer: 'Type: SubmitAnswer'
|
|
37
|
+
problem-category-delim: '|'
|
|
38
|
+
problem-subcategory-delim: ', '
|
|
39
|
+
problem.import.additional_file: '## Additional Files'
|
|
40
|
+
problem.import.hint: '## Hint'
|
|
41
|
+
problem.import.input_format: '## Input Format'
|
|
42
|
+
problem.import.limit_and_hint: '## Limits'
|
|
43
|
+
problem.import.output_format: '## Output Format'
|
|
44
|
+
problem.import.problem_description: '## Description'
|
|
45
|
+
ranking: Ranking
|
|
46
|
+
record_detail: Record Detail
|
|
47
|
+
record_main: Record
|
|
48
|
+
rpDetailText_contest: Contest
|
|
49
|
+
rpDetailText_problem: Problem
|
|
50
|
+
setting_customize: Customize
|
|
51
|
+
setting_display: Display Preference
|
|
52
|
+
setting_function: Function
|
|
53
|
+
setting_info_domain: Personal Info
|
|
54
|
+
setting_info: Personal Info
|
|
55
|
+
setting_preference: Preference
|
|
56
|
+
setting_privacy: Privacy
|
|
57
|
+
setting_usage: Usage Preference
|
|
58
|
+
sort::default: Default
|
|
59
|
+
sort::recent: Recent
|
|
60
|
+
tasks_list: Task list
|
|
61
|
+
timeago_locale: en_US
|
|
62
|
+
training_create: Training Create
|
|
63
|
+
training_edit: Training Edit
|
|
64
|
+
training_main: Training
|
|
65
|
+
user_detail: User Detail
|
|
66
|
+
user_login: Login
|
|
67
|
+
user_logout: Logout
|
|
68
|
+
user_lostpass: Lost Password
|
|
69
|
+
user_register: Register
|
|
70
|
+
wiki_help: Help
|
|
71
|
+
You can also upload your avatar to Gravatar and it will be automatically updated here.: You can also upload your avatar to <a href="https://gravatar.com/">Gravatar</a> and it will be automatically updated here.
|