diff --git a/.flake8 b/.flake8 index 55650c87fe..be5d5515c8 100644 --- a/.flake8 +++ b/.flake8 @@ -18,9 +18,6 @@ per-file-ignores = ./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 = # belongs to the user ./dmoj/local_settings.py, diff --git a/.gitmodules b/.gitmodules index 0bea662553..655fd766d9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,7 +1,3 @@ -[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 diff --git a/dmoj/settings.py b/dmoj/settings.py index 612b63e56c..94ed4e17a7 100644 --- a/dmoj/settings.py +++ b/dmoj/settings.py @@ -262,7 +262,6 @@ 'social_django', 'compressor', 'django_ace', - 'pagedown', 'sortedm2m', 'statici18n', 'impersonate', diff --git a/judge/widgets/__init__.py b/judge/widgets/__init__.py index ec7b776dda..99099399c0 100644 --- a/judge/widgets/__init__.py +++ b/judge/widgets/__init__.py @@ -1,5 +1,4 @@ from judge.widgets.checkbox import CheckboxSelectMultipleWithSelectAll from judge.widgets.martor import * from judge.widgets.mixins import CompressorWidgetMixin -from judge.widgets.pagedown import * from judge.widgets.select2 import * diff --git a/judge/widgets/pagedown.py b/judge/widgets/pagedown.py deleted file mode 100644 index dc07359215..0000000000 --- a/judge/widgets/pagedown.py +++ /dev/null @@ -1,67 +0,0 @@ -from django.forms.utils import flatatt -from django.template.loader import get_template -from django.utils.encoding import force_str -from django.utils.html import conditional_escape - -from judge.widgets.mixins import CompressorWidgetMixin - -__all__ = ['PagedownWidget', 'MathJaxPagedownWidget', 'HeavyPreviewPageDownWidget'] - -try: - from pagedown.widgets import PagedownWidget as OldPagedownWidget -except ImportError: - PagedownWidget = None - MathJaxPagedownWidget = None - HeavyPreviewPageDownWidget = None -else: - class PagedownWidget(CompressorWidgetMixin, OldPagedownWidget): - # The goal here is to compress all the pagedown JS into one file. - # We do not want any further compress down the chain, because - # 1. we'll create multiple large JS files to download. - # 2. this is not a problem here because all the pagedown JS files will be used together. - compress_js = True - - def __init__(self, *args, **kwargs): - kwargs.setdefault('css', ()) - super(PagedownWidget, self).__init__(*args, **kwargs) - - - class MathJaxPagedownWidget(PagedownWidget): - class Media: - js = [ - 'mathjax_config.js', - 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-chtml.min.js', - 'pagedown_math.js', - ] - - - class HeavyPreviewPageDownWidget(PagedownWidget): - def __init__(self, *args, **kwargs): - kwargs.setdefault('template', 'pagedown.html') - self.preview_url = kwargs.pop('preview') - self.preview_timeout = kwargs.pop('preview_timeout', None) - self.hide_preview_button = kwargs.pop('hide_preview_button', False) - super(HeavyPreviewPageDownWidget, self).__init__(*args, **kwargs) - - def render(self, name, value, attrs=None, renderer=None): - if value is None: - value = '' - final_attrs = self.build_attrs(attrs, {'name': name}) - if 'class' not in final_attrs: - final_attrs['class'] = '' - final_attrs['class'] += ' wmd-input' - return get_template(self.template).render(self.get_template_context(final_attrs, value)) - - def get_template_context(self, attrs, value): - return { - 'attrs': flatatt(attrs), - 'body': conditional_escape(force_str(value)), - 'id': attrs['id'], - 'show_preview': self.show_preview, - 'preview_url': self.preview_url, - 'preview_timeout': self.preview_timeout, - 'extra_classes': 'dmmd-no-button' if self.hide_preview_button else None, - } - - class Media: - js = ['dmmd-preview.js'] diff --git a/requirements.txt b/requirements.txt index db098fab3d..42d50c0dfa 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,6 @@ Django>=3.2,<4 django_compressor>=3 django-mptt>=0.13 -django-pagedown<2 django-registration-redux>=2.10 django-reversion>=3.0.5,<4 django-social-share diff --git a/resources/admin/css/pagedown.css b/resources/admin/css/pagedown.css deleted file mode 100644 index 4aae8e45a5..0000000000 --- a/resources/admin/css/pagedown.css +++ /dev/null @@ -1,10 +0,0 @@ -.wmd-wrapper { - padding-right: 15px !important; -} - - -.wmd-preview { - margin-top: 15px; - padding: 15px; - word-break: break-word; -} diff --git a/resources/dmmd-preview.js b/resources/dmmd-preview.js deleted file mode 100644 index 420faa988a..0000000000 --- a/resources/dmmd-preview.js +++ /dev/null @@ -1,99 +0,0 @@ -$(function () { - window.register_dmmd_preview = function ($preview) { - var $form = $preview.parents('form').first(); - var $update = $preview.find('.dmmd-preview-update'); - var $content = $preview.find('.dmmd-preview-content'); - var preview_url = $preview.attr('data-preview-url'); - var $textarea = $('#' + $preview.attr('data-textarea-id')); - - // Submit the form if Ctrl+Enter is pressed in pagedown textarea. - $textarea.keydown(function (ev) { - // Ctrl+Enter pressed (metaKey used to support command key on mac). - if ((ev.metaKey || ev.ctrlKey) && ev.which == 13) { - $form.submit(); - } - }); - - $update.click(function () { - var text = $textarea.val(); - if (text) { - $preview.addClass('dmmd-preview-stale'); - $.post(preview_url, { - content: text, - csrfmiddlewaretoken: $.cookie('csrftoken') - }, function (result) { - $content.html(result); - $preview.addClass('dmmd-preview-has-content').removeClass('dmmd-preview-stale'); - - var $jax = $content.find('.require-mathjax-support'); - if ($jax.length) { - if (!('MathJax' in window)) { - $.ajax({ - type: 'GET', - url: $jax.attr('data-config'), - dataType: 'script', - cache: true, - success: function () { - $.ajax({ - type: 'GET', - url: 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-chtml.min.js', - dataType: 'script', - cache: true, - success: function () { - MathJax.typesetPromise([$content[0]]).then(function () { - $content.find('.tex-image').hide(); - $content.find('.tex-text').show(); - }); - } - }); - } - }); - } else { - MathJax.typesetPromise([$content[0]]).then(function () { - $content.find('.tex-image').hide(); - $content.find('.tex-text').show(); - }); - } - } - }); - } else { - $content.empty(); - $preview.removeClass('dmmd-preview-has-content').removeClass('dmmd-preview-stale'); - } - }).click(); - - var timeout = $preview.attr('data-timeout'); - var last_event = null; - var last_text = $textarea.val(); - if (timeout) { - $textarea.on('keyup paste', function () { - var text = $textarea.val(); - if (last_text == text) return; - last_text = text; - - $preview.addClass('dmmd-preview-stale'); - if (last_event) - clearTimeout(last_event); - last_event = setTimeout(function () { - $update.click(); - last_event = null; - }, timeout); - }); - } - }; - - $('.dmmd-preview').each(function () { - register_dmmd_preview($(this)); - }); - - if ('django' in window && 'jQuery' in window.django) - django.jQuery(document).on('formset:added', function(event, $row) { - var $preview = $row.find('.dmmd-preview'); - if ($preview.length) { - var id = $row.attr('id'); - id = id.substr(id.lastIndexOf('-') + 1); - $preview.attr('data-textarea-id', $preview.attr('data-textarea-id').replace('__prefix__', id)); - register_dmmd_preview($preview); - } - }); -}); diff --git a/resources/dmmd-preview.scss b/resources/dmmd-preview.scss deleted file mode 100644 index 30285ef70d..0000000000 --- a/resources/dmmd-preview.scss +++ /dev/null @@ -1,43 +0,0 @@ -@import "vars"; - -div.dmmd-preview { - padding: 0; -} - -div.dmmd-preview-update { - background: $color_primary25; - color: $color_primary75; - text-align: center; - cursor: pointer; - border-radius: 4px; - height: 2em; - line-height: 2em; -} - -div.dmmd-preview-content { - padding: 0 7px; -} - -div.dmmd-preview.dmmd-preview-has-content div.dmmd-preview-update { - border-radius: 4px 4px 0 0; -} - -div.dmmd-preview-has-content div.dmmd-preview-content { - padding-bottom: 7px; -} - -div.dmmd-no-button div.dmmd-preview-update { - display: none; -} - -div.dmmd-no-button div.dmmd-preview-content { - padding-bottom: 0; -} - -div.dmmd-no-button:not(.dmmd-preview-has-content) { - display: none; -} - -div.dmmd-preview-stale { - background: repeating-linear-gradient(-45deg, $color_primary0, $color_primary0 10px, $color_primary5 10px, $color_primary5 20px); -} diff --git a/resources/pagedown b/resources/pagedown deleted file mode 160000 index 6e5eac4388..0000000000 --- a/resources/pagedown +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6e5eac43883a314d1e0dbc5e70069798859eacbc diff --git a/resources/pagedown-widget.scss b/resources/pagedown-widget.scss deleted file mode 100644 index 8e585c3fe9..0000000000 --- a/resources/pagedown-widget.scss +++ /dev/null @@ -1,125 +0,0 @@ -@import "vars"; - -.wmd-panel { - margin: 0; - width: 100%; - min-width: 0; -} - -.wmd-button-bar { - width: 100%; - background-color: Silver; -} - -.wmd-input { - height: 300px; - width: 100%; - max-width: 100%; - background: $color_primary0; - border: 1px solid $color_primary50; - font-family: Consolas, "Liberation Mono", Monaco, "Courier New", monospace !important; -} - -.wmd-preview { - background: none; - word-break: break-word; -} - -.wmd-button-row { - margin: 5px; - padding: 0; - line-height: 0; -} - -.wmd-spacer { - width: 15px; - height: 20px; - display: inline-block; - list-style: none; -} - -.wmd-button { - width: 20px; - height: 20px; - padding-left: 2px; - padding-right: 3px; - display: inline-block; - list-style: none; - cursor: pointer; -} - -.wmd-button > span { - @include vars-img; - background: url($path_to_root + '/pagedown/wmd-buttons.png') no-repeat 0 0; - width: 20px; - height: 20px; - display: inline-block; -} - -.wmd-prompt-background { - background-color: Black; -} - -.wmd-prompt-dialog { - border: 1px solid $color_primary25; - background-color: $color_primary5; -} - -.wmd-prompt-dialog > div { - font-size: 0.8em; - font-family: arial, helvetica, sans-serif; -} - -.wmd-prompt-dialog > form > input[type="text"] { - border: 1px solid $color_primary25; - color: $color_primary100; -} - -.wmd-prompt-dialog > form > input[type="button"] { - border: 1px solid $color_primary50; - font-family: trebuchet MS, helvetica, sans-serif; - font-size: 0.8em; - font-weight: bold; -} - -.wmd-wrapper { - padding-right: 0 !important; -} - -.wmd-preview { - margin-top: 15px; - padding: 7px; - background: $color_primary0; - line-height: 1.5em; - font-size: 1em; - border: 1px solid $color_primary50; - border-radius: 5px; - box-sizing: border-box; -} - -.wmd-preview:empty { - display: none; -} - -.wmd-preview h1, .wmd-preview h2, .wmd-preview h3, .wmd-preview h4, .wmd-preview h5, .wmd-preview h6 { - font-weight: bold !important; - margin-left: 0 !important; -} - -.wmd-preview:not(.dmmd-preview) h1 { - font-size: 1.6em !important; - margin: 0 !important; - padding: 0 !important; -} - -.wmd-preview:not(.dmmd-preview) h2 { - font-size: 1.4em !important -} - -.wmd-preview:not(.dmmd-preview) h3 { - font-size: 1em !important -} - -.wmd-preview:not(.dmmd-preview) h4, .wmd-preview:not(.dmmd-preview) h5, .wmd-preview:not(.dmmd-preview) h6 { - font-size: .9em !important -} diff --git a/resources/pagedown_math.js b/resources/pagedown_math.js deleted file mode 100644 index 83fa22737a..0000000000 --- a/resources/pagedown_math.js +++ /dev/null @@ -1,19 +0,0 @@ -function mathjax_pagedown($) { - if ('MathJax' in window) { - $.each(window.editors, function (id, editor) { - var preview = $('div.wmd-preview#' + id + '_wmd_preview')[0]; - if (preview) { - editor.hooks.chain('onPreviewRefresh', function () { - MathJax.typeset([preview]); - }); - MathJax.typeset([preview]); - } - }); - } -} - -window.mathjax_pagedown = mathjax_pagedown; - -$(window).on('load', function () { - (mathjax_pagedown)('$' in window ? $ : django.jQuery); -}); diff --git a/resources/style.scss b/resources/style.scss index bd206063d1..788287c22d 100644 --- a/resources/style.scss +++ b/resources/style.scss @@ -14,8 +14,6 @@ @import "widgets"; @import "featherlight"; @import "comments"; -@import "pagedown-widget"; -@import "dmmd-preview"; @import "submission"; @import "contest"; @import "misc"; diff --git a/resources/wpadmin/css/wpadmin.site.css b/resources/wpadmin/css/wpadmin.site.css index d2fe84e5b1..0542adfbff 100644 --- a/resources/wpadmin/css/wpadmin.site.css +++ b/resources/wpadmin/css/wpadmin.site.css @@ -6,18 +6,6 @@ line-height: unset !important; } -.wmd-wrapper { - padding-top: 2em; -} - -.wmd-wrapper ul.wmd-button-row { - margin-left: 0; -} - -.wmd-input { - width: 100% !important; -} - #content .content-description h1, #content .content-description h2, #content .content-description h3, @@ -65,8 +53,3 @@ select#id_tags.django-select2 { max-width: unset; } } - -.dmmd-preview-update { - position: sticky; - top: 38px; -} diff --git a/templates/blog/content.html b/templates/blog/content.html index 062e19e7ca..9337592a24 100644 --- a/templates/blog/content.html +++ b/templates/blog/content.html @@ -48,5 +48,4 @@ {% if REQUIRE_JAX %} {% include "mathjax-load.html" %} {% endif %} - {% include "comments/math.html" %} {% endblock %} diff --git a/templates/comments/math.html b/templates/comments/math.html deleted file mode 100644 index 8bf58d1c30..0000000000 --- a/templates/comments/math.html +++ /dev/null @@ -1,3 +0,0 @@ -{% compress js, inline %} - -{% endcompress %} diff --git a/templates/contest/contest.html b/templates/contest/contest.html index 2c8768472f..32a02ea024 100644 --- a/templates/contest/contest.html +++ b/templates/contest/contest.html @@ -244,8 +244,3 @@

{{ _ {% endblock %} {% block description_end %}{% endblock %} - -{% block bodyend %} - {{ super() }} - {% include "comments/math.html" %} -{% endblock %} diff --git a/templates/pagedown.html b/templates/pagedown.html deleted file mode 100644 index 0fd6b9f2d0..0000000000 --- a/templates/pagedown.html +++ /dev/null @@ -1,14 +0,0 @@ -
-
-
- {{ body }} -
- - {% if show_preview %} -
-
{{ _('Update preview') }}
-
-
- {% endif %} -
diff --git a/templates/pagedown/widgets/default.html b/templates/pagedown/widgets/default.html deleted file mode 100644 index 607e4f18a3..0000000000 --- a/templates/pagedown/widgets/default.html +++ /dev/null @@ -1,9 +0,0 @@ -
-
-
- {{ body }} -
- {% if show_preview %} -
- {% endif %} -
\ No newline at end of file diff --git a/templates/problem/editorial.html b/templates/problem/editorial.html index 820182bf6a..5b022b644e 100644 --- a/templates/problem/editorial.html +++ b/templates/problem/editorial.html @@ -46,5 +46,4 @@ {% if REQUIRE_JAX %} {% include "mathjax-load.html" %} {% endif %} - {% include "comments/math.html" %} {% endblock %} diff --git a/templates/problem/problem.html b/templates/problem/problem.html index d9909d9845..106b23c4ee 100644 --- a/templates/problem/problem.html +++ b/templates/problem/problem.html @@ -346,8 +346,3 @@

{{ _('Clarifications') }}

{% include "comments/list.html" %} {% endif %} {% endblock %} - -{% block bodyend %} - {{ super() }} - {% include "comments/math.html" %} -{% endblock %}