Skip to content

Commit

Permalink
Cloned DMOJ
Browse files Browse the repository at this point in the history
  • Loading branch information
thanhluong committed Jan 21, 2020
1 parent f623974 commit 49dc9ff
Show file tree
Hide file tree
Showing 513 changed files with 132,349 additions and 39 deletions.
1 change: 1 addition & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cover 97%
24 changes: 24 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[flake8]
max-line-length = 120
application-import-names = dmoj,judge,django_ace,event_socket_server
import-order-style = pycharm
enable-extensions = G
ignore =
W504, # line break occurred after a binary operator
# allow only generator_stop and annotations future imports
FI10,FI11,FI12,FI13,FI14,FI15,FI16,FI17,FI18,FI55,FI58,
C814, # missing trailing comma in Python 2 only
per-file-ignores =
# F401: unused imports, ignore in all __init__.py
# F403: import *
./*/__init__.py:F401,F403
# F405: name comes from import *
./event_socket_server/__init__.py:F401,F403,F405
./judge/management/commands/runmoss.py:F403,F405
# E501: line too long, ignore in migrations
./judge/migrations/*.py:E501
# E303: too many blank lines
# PyCharm likes to have double lines between class/def in an if statement.
./judge/widgets/pagedown.py:E303
exclude =
./dmoj/local_settings.py, # belongs to the user
17 changes: 17 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Install flake8
run: pip install flake8 flake8-import-order flake8-future-import flake8-commas flake8-logging-format
- name: Lint with flake8
run: |
flake8 --version
flake8
40 changes: 40 additions & 0 deletions .github/workflows/compilemessages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: compilemessages
on:
push:
paths:
- 'locale/**'
pull_request:
paths:
- 'locale/**'
jobs:
compilemessages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Checkout submodules
run: |
git submodule init
git submodule update
- name: Install requirements
run: |
sudo apt-get install gettext
pip install -r requirements.txt
pip install pymysql
- name: Check .po file validity
run: |
fail=0
while read -r file; do
if ! msgfmt --check-format "$file"; then
fail=$((fail + 1))
fi
done < <(find locale -name '*.po')
exit "$fail"
shell: bash
- name: Compile messages
run: |
echo "STATIC_ROOT = '/tmp'" > dmoj/local_settings.py
python manage.py compilemessages
53 changes: 53 additions & 0 deletions .github/workflows/makemessages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: makemessages
on:
push:
branches:
- master
jobs:
makemessages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Checkout submodules
run: |
git submodule init
git submodule update
- name: Install requirements
run: |
sudo apt-get install gettext
curl -O https://artifacts.crowdin.com/repo/deb/crowdin.deb
sudo dpkg -i crowdin.deb
pip install -r requirements.txt
pip install pymysql
- name: Collect localizable strings
run: |
echo "STATIC_ROOT = '/tmp'" > dmoj/local_settings.py
python manage.py makemessages -l en -e py,html,txt
python manage.py makemessages -l en -d djangojs
- name: Upload strings to Crowdin
env:
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}
run: |
cat > crowdin.yaml <<EOF
project_identifier: dmoj
files:
- source: /locale/en/LC_MESSAGES/django.po
translation: /locale/%two_letters_code%/LC_MESSAGES/django.po
languages_mapping:
two_letters_code:
zh-CN: zh_Hans
sr-CS: sr_Latn
- source: /locale/en/LC_MESSAGES/djangojs.po
translation: /locale/%two_letters_code%/LC_MESSAGES/djangojs.po
languages_mapping:
two_letters_code:
zh-CN: zh_Hans
sr-CS: sr_Latn
EOF
echo "api_key: ${CROWDIN_API_TOKEN}" >> crowdin.yaml
crowdin upload sources
67 changes: 67 additions & 0 deletions .github/workflows/updatemessages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: updatemessages
on:
schedule:
- cron: '0 * * * *'
jobs:
updatemessages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Checkout submodules
run: |
git submodule init
git submodule update
- name: Install requirements
run: |
sudo apt-get install gettext
curl -O https://artifacts.crowdin.com/repo/deb/crowdin.deb
sudo dpkg -i crowdin.deb
pip install -r requirements.txt
pip install pymysql
- name: Download strings from Crowdin
env:
CROWDIN_API_TOKEN: ${{ secrets.CROWDIN_API_TOKEN }}
run: |
cat > crowdin.yaml <<EOF
project_identifier: dmoj
files:
- source: /locale/en/LC_MESSAGES/django.po
translation: /locale/%two_letters_code%/LC_MESSAGES/django.po
languages_mapping:
two_letters_code:
zh-CN: zh_Hans
zh-TW: zh_Hant
sr-CS: sr_Latn
- source: /locale/en/LC_MESSAGES/djangojs.po
translation: /locale/%two_letters_code%/LC_MESSAGES/djangojs.po
languages_mapping:
two_letters_code:
zh-CN: zh_Hans
zh-TW: zh_Hant
sr-CS: sr_Latn
EOF
echo "api_key: ${CROWDIN_API_TOKEN}" >> crowdin.yaml
crowdin download
rm crowdin.yaml
- name: Cleanup
run: |
rm -rf src/
git add locale
git checkout .
git clean -fd
- name: Create pull request
uses: peter-evans/create-pull-request@v1.4.1-multi
env:
GITHUB_TOKEN: ${{ secrets.REPO_SCOPED_TOKEN }}
COMMIT_MESSAGE: 'i18n: update translations from Crowdin'
PULL_REQUEST_TITLE: 'Update translations from Crowdin'
PULL_REQUEST_BODY: This PR has been auto-generated to pull in latest translations from [Crowdin](https://translate.dmoj.ca).
PULL_REQUEST_LABELS: i18n, enhancement
PULL_REQUEST_REVIEWERS: Xyene, quantum5
PULL_REQUEST_BRANCH: update-i18n
BRANCH_SUFFIX: none
52 changes: 13 additions & 39 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,39 +1,13 @@
# History files
.Rhistory
.Rapp.history

# Session Data files
.RData

# User-specific files
.Ruserdata

# Example code in package build process
*-Ex.R

# Output files from R CMD build
/*.tar.gz

# Output files from R CMD check
/*.Rcheck/

# RStudio files
.Rproj.user/

# produced vignettes
vignettes/*.html
vignettes/*.pdf

# OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
.httr-oauth

# knitr and R markdown default cache directories
*_cache/
/cache/

# Temporary files created by R markdown
*.utf8.md
*.knit.md

# R Environment Variables
.Renviron
.idea
.vscode
.sass-cache
*.sqlite3
*.py[co]
*.mo
*~
dmoj/local_settings.py
resources/style.css
resources/content-description.css
resources/ranks.css
resources/table.css
sass_processed
8 changes: 8 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[submodule "resources/pagedown"]
path = resources/pagedown
url = https://github.com/DMOJ/dmoj-pagedown.git
branch = master
[submodule "resources/libs"]
path = resources/libs
url = https://github.com/DMOJ/site-assets.git
branch = master
62 changes: 62 additions & 0 deletions 502.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>502 bad gateway - DMOJ</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<style type="text/css">
hr {
margin: 0 22em;
}

body {
background: #f5f5f5;
padding-top: 3em;
}

.popup {
width: 30%;
display: table;
text-align: center;
margin: 0px auto;
border: 3px solid rgb(41, 128, 185);
border-radius: 30px;
box-shadow: 5px 5px 10px rgb(85, 85, 85);
}

.display {
position: fixed;
text-align: center;
width: 100%;
}

.logo {
top: 25%;
width: 115px;
text-align: center;
padding-top: 1em;
}

.msg {
font-size: 1.2em;
color: rgb(85, 85, 85);
}
</style>
</head>

<body>
<div class="display">
<hr>
<br>
<div class="popup">
<div>
<img class="logo" src="/logo.png" alt="DMOJ">
</div>
<h1 style="width: 100%;">Oops, the DMOJ is down.</h1>
</div>
<br>
<hr>
<br>
<h2 class="msg">But don't worry, we'll be back soon.</h2>
</div>
</body>
</html>
17 changes: 17 additions & 0 deletions django_2_2_pymysql_patch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import django
from django.utils.encoding import force_text

if (2, 2) <= django.VERSION < (3,):
# Django 2.2.x is incompatible with PyMySQL.
# This monkey patch backports the Django 3.0+ code.

from django.db.backends.mysql.operations import DatabaseOperations

def last_executed_query(self, cursor, sql, params):
# With MySQLdb, cursor objects have an (undocumented) "_executed"
# attribute where the exact query sent to the database is saved.
# See MySQLdb/cursors.py in the source distribution.
# MySQLdb returns string, PyMySQL bytes.
return force_text(getattr(cursor, '_executed', None), errors='replace')

DatabaseOperations.last_executed_query = last_executed_query
5 changes: 5 additions & 0 deletions django_ace/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Django-ace originally from https://github.com/bradleyayers/django-ace.
"""

from .widgets import AceWidget
Binary file added django_ace/static/django_ace/img/contract.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added django_ace/static/django_ace/img/expand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 49dc9ff

Please sign in to comment.