Skip to content

Commit 1d7c23f

Browse files
authored
Handle JS libraries with webpack (#488)
* Handle jquery and bootstrap using webpack, update to jquery 1.12.4 * Handle typeahead, clipboard and highlight in webpack * Use js-cookie instead of jquery.cookie * remove unnecessary timeline dependencies * Handle jqtree with webpack * Use native colorPicker in ColorWidget * Fix timeline.js wrong date function name * Download bootstrap-markdown and marked with npm * Add eslint * Use only .css to load fontawesome * Update highcharts.js to 4.1.10 (earliest version in npm) * Cleanup and split some js scripts * Revert timeline.js changes (will fix it in separate PR) * Remove jshint in favour of eslint * Make webpack run on container start, add easytoolbox webpack command * Make django server and webpack run in a single shell * Cypress Github Action timeout not failing fix * Add webpack docs * Change Docker compose setup to use doccker's node_modules * Install concurrently with npm * Fix balloons loading old jquery bundle * Refactor DateTimePicker widget to use Tempus Dominus * datetimepicker use language setting * Change DateTimePicker format to match js time picker * Use tempus dominus in timeline.js * Change how we call datetimepicker setValue * Share code between datetimepicker.js and timeline.js * Readd custom_undo * Load select2 using npm * Remove unnecessary csslintrc entry
1 parent 5cce632 commit 1d7c23f

File tree

230 files changed

+3931
-62819
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+3931
-62819
lines changed

.csslintrc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,5 @@
55
"ids",
66
"order-alphabetical",
77
"overqualified-elements"
8-
],
9-
"exclude-list": [
10-
"oioioi/base/static/bootstrap-datetimepicker-oioioi",
11-
"oioioi/base/static/bootstrap-markdown",
12-
"oioioi/portals/static/portals/jqtree.css",
13-
"oioioi/timeline/static/jquery-ui"
148
]
159
}

.dockerignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
/deployment/
2525
/venv*/
2626
/.idea/
27+
/.vscode/
28+
/.fleet/
29+
/dist_webpack/
30+
/node_modules/
2731

2832
# docker specific
2933

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@
2626
/.idea/
2727
/.vscode/
2828
/.fleet/
29+
/dist_webpack/
30+
/node_modules/

.jshintignore

Lines changed: 0 additions & 17 deletions
This file was deleted.

.jshintrc

Lines changed: 0 additions & 18 deletions
This file was deleted.

Dockerfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ RUN apt-get update && \
2525
sox \
2626
flite \
2727
locales \
28-
python3-pip && \
28+
python3-pip \
29+
nodejs \
30+
npm && \
2931
apt-get clean
3032

3133
# This is oioioi user linux uid. Setting it is useful in development.
@@ -64,8 +66,15 @@ RUN pip3 install -r requirements.txt --user filetracker[server]
6466
COPY --chown=oioioi:oioioi requirements_static.txt ./
6567
RUN pip3 install -r requirements_static.txt --user
6668

69+
# Installing node dependencies
70+
ENV PATH $PATH:/sio2/oioioi/node_modules/.bin
71+
72+
COPY --chown=oioioi:oioioi package.json package-lock.json ./
73+
RUN npm ci
74+
6775
COPY --chown=oioioi:oioioi . /sio2/oioioi
6876

77+
RUN npm run build
6978
RUN oioioi-create-config /sio2/deployment
7079

7180
WORKDIR /sio2/deployment

INSTALL.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ First, ensure that all dependencies are installed:
1313
* latex packages (*texlive-latex-extra*, *texlive-fonts-recommended*, *tex-gyre*,
1414
*texlive-pstricks*, *lmodern*),
1515
* Berkeley DB library (Ubuntu package: *libdb-dev*)
16+
* Node.js and npm (Ubuntu packages: *nodejs*, *npm*),
1617

1718
It should be easier to begin with a separate folder at first::
1819

@@ -29,7 +30,9 @@ Then OIOIOI and its dependencies can be installed using the following commands::
2930
git clone git://github.com/sio2project/oioioi.git
3031
cd oioioi
3132
pip install -r requirements.txt
32-
33+
npm install
34+
npm run build
35+
3336
OIOIOI is a set of Django applications, therefore you need to create a folder with
3437
Django settings and other deployment configuration::
3538

docker-compose-dev.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ services:
4040
# - "7887:7887"
4141
volumes:
4242
- .:/sio2/oioioi
43+
# use docker's node_modules and dist_webpack instead of the host ones
44+
- node_modules-dev:/sio2/oioioi/node_modules
45+
- dist_webpack-dev:/sio2/oioioi/dist_webpack
4346
- filetracker-data-dev:/sio2/deployment/media
4447
# - ./deployment:/sio2/deployment
4548
stop_grace_period: 3m
@@ -68,3 +71,5 @@ services:
6871
volumes:
6972
postgress-data-dev:
7073
filetracker-data-dev:
74+
node_modules-dev:
75+
dist_webpack-dev:

easy_toolbox.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
("up", "Run all SIO2 containers", "up -d"),
2828
("down", "Stop and remove all SIO2 containers", "down"),
2929
("wipe", "Stop all SIO2 containers and DESTROY all data", "down -v", True),
30-
("run", "Run server", "{exec} web python3 manage.py runserver 0.0.0.0:8000"),
30+
("run", "Run django server and webpack",
31+
'{exec} web conc -n js,py -c yellow,green -k "npm --prefix ../oioioi run -s watch" "python3 manage.py runserver 0.0.0.0:8000"'),
3132
("stop", "Stop all SIO2 containers", "stop"),
3233
("bash", "Open command prompt on web container.", "{exec} web bash"),
3334
("exec", "Run a command in the web container.", "{exec} web {extra_args}"),
@@ -42,6 +43,8 @@
4243
"{exec} 'web' ../oioioi/test.sh oioioi/problems --cov-report term --cov-report xml:coverage.xml --cov=oioioi {extra_args}"),
4344
("cypress-apply-settings", "Apply settings for CyPress.",
4445
'{exec} web bash -c "echo CAPTCHA_TEST_MODE=True >> settings.py"'),
46+
("npm", "Run npm command.", "{exec} web npm --prefix ../oioioi {extra_args}"),
47+
("eslint", "Run javascript linter.", "{exec} web npm --prefix ../oioioi run lint"),
4548
]
4649

4750
longest_command_arg = max([len(command[0]) for command in RAW_COMMANDS])

eslint.config.mjs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { defineConfig } from "eslint/config";
2+
import globals from "globals";
3+
import js from "@eslint/js";
4+
5+
6+
export default defineConfig([
7+
{
8+
files: ["oioioi/**/*.js"],
9+
ignores: [
10+
"**/*.min.js",
11+
"oioioi/liveranking/**",
12+
"oioioi/notifications/server/**",
13+
],
14+
languageOptions: {
15+
globals: {
16+
...globals.browser,
17+
$: "readonly",
18+
jQuery: "readonly",
19+
Cookies: "readonly",
20+
Highcharts: "readonly",
21+
22+
django: "readonly",
23+
gettext: "readonly",
24+
ngettext: "readonly",
25+
interpolate: "readonly",
26+
27+
oioioi_base_url: "readonly",
28+
}
29+
},
30+
plugins: { js },
31+
extends: ["js/recommended"]
32+
},
33+
]);

0 commit comments

Comments
 (0)