Skip to content

Handle JS libraries with webpack #488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
5538947
Handle jquery and bootstrap using webpack, update to jquery 1.12.4
stopnoanime Mar 15, 2025
3166b16
Handle typeahead, clipboard and highlight in webpack
stopnoanime Mar 15, 2025
2fada7a
Use js-cookie instead of jquery.cookie
stopnoanime Mar 15, 2025
f4ff05f
remove unnecessary timeline dependencies
stopnoanime Mar 15, 2025
f41d62c
Handle jqtree with webpack
stopnoanime Mar 15, 2025
6d38bf8
Use native colorPicker in ColorWidget
stopnoanime Mar 16, 2025
c3b0cb5
Fix timeline.js wrong date function name
stopnoanime Mar 16, 2025
cd4a1b4
Download bootstrap-markdown and marked with npm
stopnoanime Mar 19, 2025
7aeca0e
Add eslint
stopnoanime Mar 19, 2025
1f05e65
Use only .css to load fontawesome
stopnoanime Mar 23, 2025
6d6816f
Update highcharts.js to 4.1.10 (earliest version in npm)
stopnoanime Mar 23, 2025
543244c
Cleanup and split some js scripts
stopnoanime Mar 23, 2025
714f278
Revert timeline.js changes (will fix it in separate PR)
stopnoanime Mar 23, 2025
1747ed2
Remove jshint in favour of eslint
stopnoanime Mar 24, 2025
f9ea4f6
Make webpack run on container start, add easytoolbox webpack command
stopnoanime Mar 26, 2025
e798dbb
Make django server and webpack run in a single shell
stopnoanime Mar 27, 2025
a436deb
Cypress Github Action timeout not failing fix
stopnoanime Mar 27, 2025
0c2d6d5
Add webpack docs
stopnoanime Mar 29, 2025
66119a5
Change Docker compose setup to use doccker's node_modules
stopnoanime Apr 3, 2025
639501b
Install concurrently with npm
stopnoanime Apr 9, 2025
fb70679
Fix balloons loading old jquery bundle
stopnoanime May 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .csslintrc
Original file line number Diff line number Diff line change
@@ -7,9 +7,6 @@
"overqualified-elements"
],
"exclude-list": [
"oioioi/base/static/bootstrap-datetimepicker-oioioi",
"oioioi/base/static/bootstrap-markdown",
"oioioi/portals/static/portals/jqtree.css",
"oioioi/timeline/static/jquery-ui"
"oioioi/base/static/bootstrap-datetimepicker-oioioi"
]
}
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -24,6 +24,10 @@
/deployment/
/venv*/
/.idea/
/.vscode/
/.fleet/
/dist_webpack/
/node_modules/

# docker specific

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -26,3 +26,5 @@
/.idea/
/.vscode/
/.fleet/
/dist_webpack/
/node_modules/
17 changes: 0 additions & 17 deletions .jshintignore

This file was deleted.

18 changes: 0 additions & 18 deletions .jshintrc

This file was deleted.

11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -25,7 +25,9 @@ RUN apt-get update && \
sox \
flite \
locales \
python3-pip && \
python3-pip \
nodejs \
npm && \
apt-get clean

# 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]
COPY --chown=oioioi:oioioi requirements_static.txt ./
RUN pip3 install -r requirements_static.txt --user

# Installing node dependencies
ENV PATH $PATH:/sio2/oioioi/node_modules/.bin

COPY --chown=oioioi:oioioi package.json package-lock.json ./
RUN npm ci

COPY --chown=oioioi:oioioi . /sio2/oioioi

RUN npm run build
RUN oioioi-create-config /sio2/deployment

WORKDIR /sio2/deployment
5 changes: 4 additions & 1 deletion INSTALL.rst
Original file line number Diff line number Diff line change
@@ -13,6 +13,7 @@ First, ensure that all dependencies are installed:
* latex packages (*texlive-latex-extra*, *texlive-fonts-recommended*, *tex-gyre*,
*texlive-pstricks*, *lmodern*),
* Berkeley DB library (Ubuntu package: *libdb-dev*)
* Node.js and npm (Ubuntu packages: *nodejs*, *npm*),

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

@@ -29,7 +30,9 @@ Then OIOIOI and its dependencies can be installed using the following commands::
git clone git://github.com/sio2project/oioioi.git
cd oioioi
pip install -r requirements.txt

npm install
npm run build

OIOIOI is a set of Django applications, therefore you need to create a folder with
Django settings and other deployment configuration::

5 changes: 5 additions & 0 deletions docker-compose-dev.yml
Original file line number Diff line number Diff line change
@@ -40,6 +40,9 @@ services:
# - "7887:7887"
volumes:
- .:/sio2/oioioi
# use docker's node_modules and dist_webpack instead of the host ones
- node_modules-dev:/sio2/oioioi/node_modules
- dist_webpack-dev:/sio2/oioioi/dist_webpack
- filetracker-data-dev:/sio2/deployment/media
# - ./deployment:/sio2/deployment
stop_grace_period: 3m
@@ -68,3 +71,5 @@ services:
volumes:
postgress-data-dev:
filetracker-data-dev:
node_modules-dev:
dist_webpack-dev:
5 changes: 4 additions & 1 deletion easy_toolbox.py
Original file line number Diff line number Diff line change
@@ -27,7 +27,8 @@
("up", "Run all SIO2 containers", "up -d"),
("down", "Stop and remove all SIO2 containers", "down"),
("wipe", "Stop all SIO2 containers and DESTROY all data", "down -v", True),
("run", "Run server", "{exec} web python3 manage.py runserver 0.0.0.0:8000"),
("run", "Run django server and webpack",
'{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"'),
("stop", "Stop all SIO2 containers", "stop"),
("bash", "Open command prompt on web container.", "{exec} web bash"),
("exec", "Run a command in the web container.", "{exec} web {extra_args}"),
@@ -42,6 +43,8 @@
"{exec} 'web' ../oioioi/test.sh oioioi/problems --cov-report term --cov-report xml:coverage.xml --cov=oioioi {extra_args}"),
("cypress-apply-settings", "Apply settings for CyPress.",
'{exec} web bash -c "echo CAPTCHA_TEST_MODE=True >> settings.py"'),
("npm", "Run npm command.", "{exec} web npm --prefix ../oioioi {extra_args}"),
("eslint", "Run javascript linter.", "{exec} web npm --prefix ../oioioi run lint"),
]

longest_command_arg = max([len(command[0]) for command in RAW_COMMANDS])
33 changes: 33 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { defineConfig } from "eslint/config";
import globals from "globals";
import js from "@eslint/js";


export default defineConfig([
{
files: ["oioioi/**/*.js"],
ignores: [
"**/*.min.js",
"oioioi/liveranking/**",
"oioioi/notifications/server/**",
],
languageOptions: {
globals: {
...globals.browser,
$: "readonly",
jQuery: "readonly",
Cookies: "readonly",
Highcharts: "readonly",

django: "readonly",
gettext: "readonly",
ngettext: "readonly",
interpolate: "readonly",

oioioi_base_url: "readonly",
}
},
plugins: { js },
extends: ["js/recommended"]
},
]);
2 changes: 1 addition & 1 deletion oioioi/balloons/static/balloons/delivery-panel.js
Original file line number Diff line number Diff line change
@@ -89,7 +89,7 @@ $(function() {
data: {
id: id,
new_delivered: newDelivered,
csrfmiddlewaretoken: $.cookie('csrftoken')
csrfmiddlewaretoken: Cookies.get('csrftoken')
},
url: setDeliveredUrl,
success: function(data) { afterRequest(btn, data, moveRow); },
1 change: 0 additions & 1 deletion oioioi/balloons/static/balloons/refresh.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* jshint unused:false */
function startRefreshingBalloons(body_url) {
var prev_body;
setInterval(function() {
4 changes: 2 additions & 2 deletions oioioi/balloons/templates/balloons/balloons.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
{% load compress %}
{% load compress static %}
<html>
<head>
<title>{% block title %}OIOIOI{% endblock %}</title>
@@ -25,8 +25,8 @@
text-align: center;
}
</style>
<script src="{% static 'jquery.bundle.js' %}"></script>
{% compress js %}
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="{{ STATIC_URL }}balloons/refresh.js"></script>
{% endcompress %}
<script>
Loading