From 3f53c62d4d5280a5e71d9e35a038bfd9e19a806b Mon Sep 17 00:00:00 2001 From: cuom1999 Date: Mon, 26 Feb 2024 14:31:33 -0600 Subject: [PATCH] Fix random frontend (problem info, lazy load img, comment pagedown) --- judge/markdown.py | 7 +- locale/vi/LC_MESSAGES/django.po | 151 ++++++++++++++++------------- resources/common.js | 8 +- resources/dmmd-preview.js | 6 -- resources/problem.scss | 2 +- templates/comments/media-js.html | 2 +- templates/organization/list.html | 2 +- templates/pagedown.html | 11 ++- templates/problem/problem.html | 30 ++++++ templates/problem/search-form.html | 6 +- templates/recent-organization.html | 2 +- 11 files changed, 131 insertions(+), 96 deletions(-) diff --git a/judge/markdown.py b/judge/markdown.py index 96e3539..9fd81aa 100644 --- a/judge/markdown.py +++ b/judge/markdown.py @@ -88,6 +88,7 @@ ALLOWED_ATTRS = [ "frameborder", "allow", "allowfullscreen", + "loading", ] @@ -105,11 +106,9 @@ def markdown(value, lazy_load=False): soup = BeautifulSoup(html, features="html.parser") for img in soup.findAll("img"): if img.get("src"): - img["data-src"] = img["src"] - img["src"] = "" + img["loading"] = "lazy" for img in soup.findAll("iframe"): if img.get("src"): - img["data-src"] = img["src"] - img["src"] = "" + img["loading"] = "lazy" html = str(soup) return '
%s
' % html diff --git a/locale/vi/LC_MESSAGES/django.po b/locale/vi/LC_MESSAGES/django.po index 8140c87..6e75ad7 100644 --- a/locale/vi/LC_MESSAGES/django.po +++ b/locale/vi/LC_MESSAGES/django.po @@ -2,7 +2,7 @@ msgid "" msgstr "" "Project-Id-Version: lqdoj2\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-02-20 06:20+0700\n" +"POT-Creation-Date: 2024-02-27 03:20+0700\n" "PO-Revision-Date: 2021-07-20 03:44\n" "Last-Translator: Icyene\n" "Language-Team: Vietnamese\n" @@ -18,23 +18,23 @@ msgstr "" "X-Crowdin-Project-ID: 466004\n" "X-Crowdin-File-ID: 5\n" -#: chat_box/models.py:22 chat_box/models.py:87 +#: chat_box/models.py:22 chat_box/models.py:83 msgid "last seen" msgstr "xem lần cuối" -#: chat_box/models.py:58 chat_box/models.py:83 chat_box/models.py:99 +#: chat_box/models.py:54 chat_box/models.py:79 chat_box/models.py:95 #: judge/admin/interface.py:150 judge/models/contest.py:647 #: judge/models/contest.py:853 judge/models/course.py:129 -#: judge/models/profile.py:430 judge/models/profile.py:504 +#: judge/models/profile.py:419 judge/models/profile.py:493 msgid "user" msgstr "người dùng" -#: chat_box/models.py:60 judge/models/comment.py:44 +#: chat_box/models.py:56 judge/models/comment.py:44 #: judge/models/notification.py:17 msgid "posted time" msgstr "thời gian đăng" -#: chat_box/models.py:62 judge/models/comment.py:49 +#: chat_box/models.py:58 judge/models/comment.py:49 msgid "body of comment" msgstr "nội dung bình luận" @@ -42,11 +42,11 @@ msgstr "nội dung bình luận" msgid "LQDOJ Chat" msgstr "" -#: chat_box/views.py:441 +#: chat_box/views.py:444 msgid "Recent" msgstr "Gần đây" -#: chat_box/views.py:445 templates/base.html:192 +#: chat_box/views.py:448 templates/base.html:192 #: templates/comments/content-list.html:77 #: templates/contest/contest-list-tabs.html:4 #: templates/contest/ranking-table.html:47 templates/course/left_sidebar.html:8 @@ -2046,7 +2046,7 @@ msgid "" msgstr "Ảnh này sẽ thay thế logo mặc định khi ở trong tổ chức." #: judge/models/profile.py:148 judge/models/profile.py:178 -#: judge/models/profile.py:436 judge/models/profile.py:511 +#: judge/models/profile.py:425 judge/models/profile.py:500 msgid "organization" msgstr "" @@ -2152,35 +2152,35 @@ msgstr "Background tự chọn" msgid "CSS custom background properties: url(\"image_url\"), color, etc" msgstr "CSS background tự chọn. Ví dụ: url(\"image_url\"), white, ..." -#: judge/models/profile.py:423 +#: judge/models/profile.py:412 msgid "user profile" msgstr "thông tin người dùng" -#: judge/models/profile.py:424 +#: judge/models/profile.py:413 msgid "user profiles" msgstr "thông tin người dùng" -#: judge/models/profile.py:440 +#: judge/models/profile.py:429 msgid "request time" msgstr "thời gian đăng ký" -#: judge/models/profile.py:443 +#: judge/models/profile.py:432 msgid "state" msgstr "trạng thái" -#: judge/models/profile.py:450 +#: judge/models/profile.py:439 msgid "reason" msgstr "lý do" -#: judge/models/profile.py:453 +#: judge/models/profile.py:442 msgid "organization join request" msgstr "đơn đăng ký tham gia" -#: judge/models/profile.py:454 +#: judge/models/profile.py:443 msgid "organization join requests" msgstr "đơn đăng ký tham gia" -#: judge/models/profile.py:516 +#: judge/models/profile.py:505 #, fuzzy #| msgid "last seen" msgid "last visit" @@ -3224,7 +3224,7 @@ msgstr "Bạn không được phép chỉnh sửa tổ chức này." #: templates/contest/tag-title.html:9 templates/flatpages/admin_link.html:3 #: templates/license.html:10 templates/problem/editorial.html:15 #: templates/problem/feed/problems.html:50 -#: templates/test_formatter/download_test_formatter.html:77 +#: templates/test_formatter/download_test_formatter.html:83 msgid "Edit" msgstr "Chỉnh sửa" @@ -3458,50 +3458,50 @@ msgstr "Bài nộp của %(user)s cho bài %(problem)s" msgid "All submissions" msgstr "Tất cả bài nộp" -#: judge/views/submission.py:545 judge/views/submission.py:550 +#: judge/views/submission.py:546 judge/views/submission.py:551 msgid "All my submissions" msgstr "Tất cả bài nộp của tôi" -#: judge/views/submission.py:546 +#: judge/views/submission.py:547 #, python-format msgid "All submissions by %s" msgstr "Tất cả bài nộp của %s" -#: judge/views/submission.py:552 +#: judge/views/submission.py:553 #, python-brace-format msgid "All submissions by {0}" msgstr "Tất cả bài nộp của {0}" -#: judge/views/submission.py:573 +#: judge/views/submission.py:574 #, fuzzy #| msgid "All submissions" msgid "All friend submissions" msgstr "Tất cả bài nộp" -#: judge/views/submission.py:602 +#: judge/views/submission.py:603 #, python-format msgid "All submissions for %s" msgstr "Tất cả bài nộp cho %s" -#: judge/views/submission.py:630 +#: judge/views/submission.py:631 msgid "Must pass a problem" msgstr "Phải làm được một bài" -#: judge/views/submission.py:688 +#: judge/views/submission.py:689 #, python-format msgid "My submissions for %(problem)s" msgstr "Bài nộp của tôi cho %(problem)s" -#: judge/views/submission.py:689 +#: judge/views/submission.py:690 #, python-format msgid "%(user)s's submissions for %(problem)s" msgstr "Các bài nộp của %(user)s cho %(problem)s" -#: judge/views/submission.py:825 +#: judge/views/submission.py:826 msgid "Must pass a contest" msgstr "Phải qua một kỳ thi" -#: judge/views/submission.py:855 +#: judge/views/submission.py:856 #, python-brace-format msgid "" "{0}'s submissions for {2} in {0} cho {2} trong {4}" -#: judge/views/submission.py:867 +#: judge/views/submission.py:868 #, python-brace-format msgid "" "{0}'s submissions for problem {2} in {3}" @@ -3519,15 +3519,15 @@ msgstr "" "Các bài nộp của {0} cho bài {2} trong {3}" "" -#: judge/views/submission.py:1001 +#: judge/views/submission.py:1002 #, fuzzy #| msgid "You do not have the permission to rejudge submissions." msgid "You don't have permission to access." msgstr "Bạn không có quyền chấm lại bài." -#: judge/views/test_formatter/test_formatter.py:61 -#: judge/views/test_formatter/test_formatter.py:104 -#: judge/views/test_formatter/test_formatter.py:187 +#: judge/views/test_formatter/test_formatter.py:64 +#: judge/views/test_formatter/test_formatter.py:107 +#: judge/views/test_formatter/test_formatter.py:190 #, fuzzy #| msgid "contest format" msgid "Test Formatter" @@ -3628,7 +3628,7 @@ msgstr "Chỉnh sửa thông tin" msgid "Leaderboard" msgstr "Xếp hạng" -#: judge/views/user.py:543 +#: judge/views/user.py:542 msgid "Import Users" msgstr "" @@ -3812,7 +3812,7 @@ msgid "You have no ticket" msgstr "Bạn không có báo cáo" #: templates/blog/list.html:72 templates/problem/list.html:150 -#: templates/problem/problem.html:390 +#: templates/problem/problem.html:408 msgid "Clarifications" msgstr "Thông báo" @@ -3821,7 +3821,7 @@ msgid "Add" msgstr "Thêm mới" #: templates/blog/list.html:97 templates/problem/list.html:172 -#: templates/problem/problem.html:401 +#: templates/problem/problem.html:419 msgid "No clarifications have been made at this time." msgstr "Không có thông báo nào." @@ -4441,7 +4441,7 @@ msgstr "Vui lòng sửa các lỗi bên dưới" #: templates/organization/blog/edit.html:36 #: templates/organization/contest/add.html:36 #: templates/organization/contest/edit.html:86 -#: templates/organization/form.html:23 +#: templates/organization/form.html:23 templates/pagedown.html:31 msgid "Save" msgstr "Lưu" @@ -4503,6 +4503,7 @@ msgstr "Tải file lên" #: templates/fine_uploader/script.html:23 #: templates/markdown_editor/markdown_editor.html:124 +#: templates/pagedown.html:32 msgid "Cancel" msgstr "Hủy" @@ -4572,14 +4573,17 @@ msgid "Update Preview" msgstr "Cập nhật xem trước" #: templates/markdown_editor/markdown_editor.html:108 +#: templates/pagedown.html:15 msgid "Insert Image" msgstr "Chèn hình ảnh" #: templates/markdown_editor/markdown_editor.html:111 +#: templates/pagedown.html:18 msgid "From the web" msgstr "Từ web" #: templates/markdown_editor/markdown_editor.html:117 +#: templates/pagedown.html:25 msgid "From your computer" msgstr "Từ máy tính của bạn" @@ -4761,7 +4765,7 @@ msgstr "Xem YAML" msgid "Autofill testcases" msgstr "Tự động điền test" -#: templates/problem/data.html:506 templates/problem/problem.html:249 +#: templates/problem/data.html:506 templates/problem/problem.html:267 msgid "Problem type" msgid_plural "Problem types" msgstr[0] "Dạng bài" @@ -5043,66 +5047,66 @@ msgstr "Quản lý bài nộp" msgid "Clone problem" msgstr "Nhân bản bài" -#: templates/problem/problem.html:234 +#: templates/problem/problem.html:252 msgid "Author:" msgid_plural "Authors:" msgstr[0] "Tác giả:" -#: templates/problem/problem.html:262 +#: templates/problem/problem.html:280 msgid "Allowed languages" msgstr "Ngôn ngữ cho phép" -#: templates/problem/problem.html:270 +#: templates/problem/problem.html:288 #, python-format msgid "No %(lang)s judge online" msgstr "Không có máy chấm cho %(lang)s" -#: templates/problem/problem.html:282 +#: templates/problem/problem.html:300 #: templates/status/judge-status-table.html:2 msgid "Judge" msgid_plural "Judges" msgstr[0] "Máy chấm" -#: templates/problem/problem.html:300 +#: templates/problem/problem.html:318 msgid "none available" msgstr "Bài này chưa có máy chấm" -#: templates/problem/problem.html:312 +#: templates/problem/problem.html:330 #, python-format msgid "This problem has %(length)s clarification(s)" msgstr "Bài này có %(length)s thông báo" -#: templates/problem/problem.html:320 +#: templates/problem/problem.html:338 msgid "Points:" msgstr "Điểm:" -#: templates/problem/problem.html:331 +#: templates/problem/problem.html:349 msgid "Time limit:" msgstr "Thời gian:" -#: templates/problem/problem.html:336 +#: templates/problem/problem.html:354 msgid "Memory limit:" msgstr "Bộ nhớ:" -#: templates/problem/problem.html:341 templates/problem/raw.html:67 +#: templates/problem/problem.html:359 templates/problem/raw.html:67 #: templates/submission/status-testcases.html:155 msgid "Input:" msgstr "Input:" -#: templates/problem/problem.html:343 templates/problem/raw.html:67 +#: templates/problem/problem.html:361 templates/problem/raw.html:67 msgid "stdin" msgstr "bàn phím" -#: templates/problem/problem.html:348 templates/problem/raw.html:70 +#: templates/problem/problem.html:366 templates/problem/raw.html:70 #: templates/submission/status-testcases.html:159 msgid "Output:" msgstr "Output:" -#: templates/problem/problem.html:349 templates/problem/raw.html:70 +#: templates/problem/problem.html:367 templates/problem/raw.html:70 msgid "stdout" msgstr "màn hình" -#: templates/problem/problem.html:376 +#: templates/problem/problem.html:394 msgid "Request clarification" msgstr "Yêu cầu làm rõ đề" @@ -5152,16 +5156,16 @@ msgstr "Hiển thị hướng dẫn" msgid "All" msgstr "Tất cả" -#: templates/problem/search-form.html:87 +#: templates/problem/search-form.html:88 msgid "Point range" msgstr "Mốc điểm" -#: templates/problem/search-form.html:93 templates/submission/list.html:355 +#: templates/problem/search-form.html:95 templates/submission/list.html:355 #: templates/ticket/list.html:250 msgid "Go" msgstr "Lọc" -#: templates/problem/search-form.html:94 +#: templates/problem/search-form.html:96 msgid "Random" msgstr "Ngẫu nhiên" @@ -5690,43 +5694,49 @@ msgstr "pretests" msgid "main tests" msgstr "test chính thức" -#: templates/test_formatter/download_test_formatter.html:69 -#: templates/test_formatter/download_test_formatter.html:76 -#: templates/test_formatter/edit_test_formatter.html:128 +#: templates/test_formatter/download_test_formatter.html:75 +#: templates/test_formatter/download_test_formatter.html:82 +#: templates/test_formatter/edit_test_formatter.html:134 msgid "Download" msgstr "Tải xuống" -#: templates/test_formatter/edit_test_formatter.html:99 +#: templates/test_formatter/download_test_formatter.html:86 +#: templates/test_formatter/edit_test_formatter.html:137 +#: templates/test_formatter/test_formatter.html:20 +msgid "Copyright" +msgstr "" + +#: templates/test_formatter/edit_test_formatter.html:105 msgid "Before" msgstr "Trước" -#: templates/test_formatter/edit_test_formatter.html:100 -#: templates/test_formatter/edit_test_formatter.html:108 +#: templates/test_formatter/edit_test_formatter.html:106 +#: templates/test_formatter/edit_test_formatter.html:114 msgid "Input format" msgstr "Định dạng đầu vào" -#: templates/test_formatter/edit_test_formatter.html:102 -#: templates/test_formatter/edit_test_formatter.html:110 +#: templates/test_formatter/edit_test_formatter.html:108 +#: templates/test_formatter/edit_test_formatter.html:116 msgid "Output format" msgstr "Định dạng đầu ra" -#: templates/test_formatter/edit_test_formatter.html:107 +#: templates/test_formatter/edit_test_formatter.html:113 msgid "After" msgstr "Sau" -#: templates/test_formatter/edit_test_formatter.html:116 +#: templates/test_formatter/edit_test_formatter.html:122 msgid "Preview" msgstr "Xem trước" -#: templates/test_formatter/edit_test_formatter.html:123 +#: templates/test_formatter/edit_test_formatter.html:129 msgid "File name" msgstr "Tên file" -#: templates/test_formatter/edit_test_formatter.html:127 +#: templates/test_formatter/edit_test_formatter.html:133 msgid "Convert" msgstr "Chuyển đổi" -#: templates/test_formatter/test_formatter.html:8 +#: templates/test_formatter/test_formatter.html:17 msgid "Upload" msgstr "Tải lên" @@ -6071,6 +6081,11 @@ msgstr "Thông tin" msgid "Check all" msgstr "Chọn tất cả" +#, fuzzy +#~| msgid "From the web" +#~ msgid "From the Web" +#~ msgstr "Từ web" + #~ msgid "on {time}" #~ msgstr "vào {time}" diff --git a/resources/common.js b/resources/common.js index 333635a..8584905 100644 --- a/resources/common.js +++ b/resources/common.js @@ -400,14 +400,8 @@ function onWindowReady() { }); setTimeout(() => { - $("[data-src]img").each(function() { - $(this).attr("src", $(this).attr("data-src")); - }) - $("[data-src]iframe").each(function() { - $(this).attr("src", $(this).attr("data-src")); - }) register_markdown_editors(); - }, "100"); + }, 100); $('form').submit(function (evt) { // Prevent multiple submissions of forms, see #565 diff --git a/resources/dmmd-preview.js b/resources/dmmd-preview.js index 4efdc88..2646503 100644 --- a/resources/dmmd-preview.js +++ b/resources/dmmd-preview.js @@ -23,12 +23,6 @@ $(function () { csrfmiddlewaretoken: $.cookie('csrftoken') }, function (result) { $content.html(result); - $(".dmmd-preview-content [data-src]img").each(function() { - $(this).attr("src", $(this).attr("data-src")); - }) - $(".dmmd-preview-content [data-src]iframe").each(function() { - $(this).attr("src", $(this).attr("data-src")); - }) $preview.addClass('dmmd-preview-has-content').removeClass('dmmd-preview-stale'); renderKatex($content[0]); }); diff --git a/resources/problem.scss b/resources/problem.scss index ff2d615..446bb22 100644 --- a/resources/problem.scss +++ b/resources/problem.scss @@ -73,7 +73,7 @@ } .filter-form-group { - margin-top: 5px; + margin-top: 15px; } } diff --git a/templates/comments/media-js.html b/templates/comments/media-js.html index b374efb..a862607 100644 --- a/templates/comments/media-js.html +++ b/templates/comments/media-js.html @@ -211,10 +211,10 @@ $comments.find('a.edit-link').featherlight({ afterOpen: function () { register_dmmd_preview($('#id-edit-comment-body-preview')); + register_markdown_editors(); if ('DjangoPagedown' in window) { var $wmd = $('.featherlight .wmd-wrapper'); if ($wmd.length) { - window.DjangoPagedown.createEditor($wmd.get(0)); if ('MathJax' in window) { var preview = $('.featherlight div.wmd-preview')[0]; renderKatex(preview); diff --git a/templates/organization/list.html b/templates/organization/list.html index 65debd0..e387daa 100644 --- a/templates/organization/list.html +++ b/templates/organization/list.html @@ -32,7 +32,7 @@
{% for org in queryset %} - + {{ org.name }} {{ org.member_count }} {{_('members')}} diff --git a/templates/pagedown.html b/templates/pagedown.html index 294b77d..c02c941 100644 --- a/templates/pagedown.html +++ b/templates/pagedown.html @@ -12,23 +12,24 @@ {% endif %} {% if image_upload_enabled %}
-

Insert Image

+

{{_("Insert Image")}}

- +
+
- +
{% endif %} diff --git a/templates/problem/problem.html b/templates/problem/problem.html index 348ffdf..b550602 100644 --- a/templates/problem/problem.html +++ b/templates/problem/problem.html @@ -224,6 +224,36 @@
{% endif %} +{% if problem.language_time_limit or problem.language_memory_limit %} +
+{% endif %} +{% if problem.language_time_limit %} +
+ {{ _('Time limit:') }} +
+
+ {% for name, limit in problem.language_time_limit %} +
+ {{ name }} + {{ limit }}s +
+ {% endfor %} +
+{% endif %} +{% if problem.language_memory_limit %} +
+ {{ _('Memory limit:') }} +
+
+ {% for name, limit in problem.language_memory_limit %} +
+ {{ name }} + {{ limit|kbsimpleformat }} +
+ {% endfor %} +
+{% endif%} +
{% cache 86400 'problem_authors' problem.id LANGUAGE_CODE %} diff --git a/templates/problem/search-form.html b/templates/problem/search-form.html index 97a3c35..81dfa4c 100644 --- a/templates/problem/search-form.html +++ b/templates/problem/search-form.html @@ -84,8 +84,10 @@ {% if point_values %} -
{{ _('Point range') }}
-
+
+
{{ _('Point range') }}
+
+
{% endif %} diff --git a/templates/recent-organization.html b/templates/recent-organization.html index 54f938f..95b5ee1 100644 --- a/templates/recent-organization.html +++ b/templates/recent-organization.html @@ -22,7 +22,7 @@