Skip to content

Commit

Permalink
refactor: migrate websocket to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
DuCanhGH committed Sep 11, 2023
1 parent faadb0b commit 0756cb0
Show file tree
Hide file tree
Showing 13 changed files with 1,774 additions and 341 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*.mo
*~
*.swp
dmojsite/
dmoj/local_settings.py
dmoj-site.pid
dmoj-site.sock
Expand All @@ -33,11 +34,9 @@ language_voj.json
/static
backup*.json
custom_script_*
websocket/config.js
node_modules/
package-lock.json
db.json
tmp.sh
*.sql
fc_*
local_urls.py
local_urls.py
12 changes: 12 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.DS_Store
node_modules
/build
/package
.env
.env.*
!.env.example

# Ignore files for PNPM, NPM and YARN
pnpm-lock.yaml
package-lock.json
yarn.lock
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"semi": true,
"useTabs": false,
"tabWidth": 2,
"printWidth": 100,
"singleQuote": false,
"trailingComma": "all",
"bracketSameLine": false
}
4 changes: 2 additions & 2 deletions 502.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>502 bad gateway - VNOJ</title>
<title>502 Bad Gateway - VNOJ</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
hr {
Expand Down Expand Up @@ -51,7 +51,7 @@
<div>
<img class="logo" src="/logo.png" alt="VNOJ">
</div>
<h1 style="width: 100%;">Oops, the VNOJ is down.</h1>
<h1 style="width: 100%;">Oops, VNOJ is down.</h1>
</div>
<br>
<hr>
Expand Down
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
# VNOJ: VNOI Online Judge [![Build Status](https://github.com/VNOI-Admin/OJ/workflows/build/badge.svg)](https://github.com/VNOI-Admin/OJ/actions/) [![AGPL License](https://img.shields.io/badge/license-AGPLv3.0-blue.svg)](http://www.gnu.org/licenses/agpl-3.0) [![Discord link](https://img.shields.io/discord/660930260405190688?color=%237289DA&label=Discord&logo=Discord)](https://discord.com/invite/TDyYVyd)

As a fork of [DMOJ](https://github.com/DMOJ/online-judge), VNOJ serves as the official online judge and programming contests of [VNOI](https://vnoi.info/).
As a fork of [DMOJ](https://github.com/DMOJ/online-judge), VNOJ serves as [VNOI](https://vnoi.info/)'s official online judge and hosts its programming contests.

See it live at [oj.vnoi.info](http://oj.vnoi.info/)!
See it live at [oj.vnoi.info](https://oj.vnoi.info/)!

## Features

Checkout the features listed [here](https://github.com/DMOJ/online-judge#features).
Check out its features [here](https://github.com/DMOJ/online-judge#features).

Addition features:
Additional features:

- Beside Python checkers [here](https://docs.dmoj.ca/#/problem_format/custom_checkers), we can write custom C++ checker using `testlib.h`.
- Aside from Python checkers [here](https://docs.dmoj.ca/#/problem_format/custom_checkers), we can also write a custom C++ checker using `testlib.h`.

## Installation

Check out the install documentation at [docs.dmoj.ca](https://docs.dmoj.ca/#/site/installation). Almost all installation steps is the same as the docs, there is one minor change: clone this repo instead of dmoj repo.
Refer to the install documentation at [docs.dmoj.ca](https://docs.dmoj.ca/#/site/installation). Almost all installation steps remain the same as the docs, but there are several minor differences, including cloning this repo instead of DMOJ's repo.

### Additional step in installation:

- You **have to** define `DMOJ_PROBLEM_DATA_ROOT` in `local_settings.py`, this is path to your problems tests folder.
- You **have to** define `DMOJ_PROBLEM_DATA_ROOT` in `local_settings.py`, which should be the path to the directory that contains your problems' tests.

- Considering to disable Full text search, please check [this issuse](https://github.com/VNOI-Admin/OJ/issues/4) for more information.
- Regarding disabling full-text search, please read [this issue](https://github.com/VNOI-Admin/OJ/issues/4) for more information.

- To sync the caching of judge server and site, change cache framework (`CACHES`) to `memcached` or `redis` instead of the default (local-memory caching).
- To sync the judge server and the site's cache, change the cache framework (`CACHES`) to `memcached` or `redis` instead of the default (local-memory caching).

- The "home button" the admin dashboard (/admin) will redirect to `localhost:8081` if you use `python3 manage.py loaddata demo`, there is 2 ways to fix it:
- The home button in the admin dashboard (/admin) will redirect to `localhost:8081` if you use `python3 manage.py loaddata demo`, there are 2 ways to change that:

1. You can change that in [demo.json](judge/fixtures/demo.json)
2. You can go to the admin page, scoll down to find the `Sites` settings and change `localhost:8081` to your domain.
1. You can change that in [demo.json](/judge/fixtures/demo.json)
2. You can go to the admin page, scroll down to find the `Sites` setting and change `localhost:8081` to your domain.

- To support `testlib.h`, you need to copy the [testlib.h](https://github.com/MikeMirzayanov/testlib/blob/master/testlib.h) to g++ include path in judge server. To speed up compiler time, you may create the precompiled header to `testlib.h`.
- To support `testlib.h`, you need to copy [testlib.h](https://github.com/MikeMirzayanov/testlib/blob/master/testlib.h) to `g++`'s include path in the judge server. To speed up compile time, you can also create a precompiled header for `testlib.h`.

## Contributing ![PR's Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat)

Take a look at [our contribution guideline](contributing.md).

If you found any bug, please feel free to contact us via Discord [![Discord Chat](https://img.shields.io/discord/660930260405190688?color=%237289DA&label=Discord&logo=Discord)](https://discord.gg/TDyYVyd) or open an issue.
If you find any bug, please feel free to contact us via Discord [![Discord Chat](https://img.shields.io/discord/660930260405190688?color=%237289DA&label=Discord&logo=Discord)](https://discord.gg/TDyYVyd) or open an issue.

Pull requests are welcome as well. Before you submitting your PR, please check your code with [flake8](https://flake8.pycqa.org/en/latest/) and format it if needed.
Pull requests are welcome as well. Before you submit your PR, please check your code with [flake8](https://flake8.pycqa.org/en/latest/) and format it if needed. There's also `prettier` if you need to format JS code (in `websocket/`).

Translation contributions are also welcome.
10 changes: 5 additions & 5 deletions make_style.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#!/bin/bash
if ! [ -x "$(command -v sass)" ]; then
if ! [ -x "$(command -v npx sass)" ]; then
echo 'Error: sass is not installed.' >&2
exit 1
fi

if ! [ -x "$(command -v postcss)" ]; then
if ! [ -x "$(command -v npx postcss)" ]; then
echo 'Error: postcss is not installed.' >&2
exit 1
fi

if ! [ -x "$(command -v autoprefixer)" ]; then
if ! [ -x "$(command -v npx autoprefixer)" ]; then
echo 'Error: autoprefixer is not installed.' >&2
exit 1
fi
Expand All @@ -19,8 +19,8 @@ cd "$(dirname "$0")" || exit
build_style() {
echo "Creating $1 style..."
cp resources/vars-$1.scss resources/vars.scss
sass resources:sass_processed
postcss sass_processed/style.css sass_processed/martor-description.css sass_processed/select2-dmoj.css --verbose --use autoprefixer -d $2
npx sass resources:sass_processed
npx postcss sass_processed/style.css sass_processed/martor-description.css sass_processed/select2-dmoj.css --verbose --use autoprefixer -d $2
}

build_style 'default' 'resources'
Expand Down
Loading

0 comments on commit 0756cb0

Please sign in to comment.