diff --git a/dmoj/settings.py b/dmoj/settings.py index d5cfa38..e136a4d 100644 --- a/dmoj/settings.py +++ b/dmoj/settings.py @@ -485,6 +485,9 @@ META_REMOTE_ADDRESS_KEY = "REMOTE_ADDR" DEFAULT_AUTO_FIELD = "django.db.models.AutoField" +# Chunk upload +CHUNK_UPLOAD_DIR = "/tmp/chunk_upload_tmp" + try: with open(os.path.join(os.path.dirname(__file__), "local_settings.py")) as f: exec(f.read(), globals()) diff --git a/dmoj/urls.py b/dmoj/urls.py index 402a569..4e0691e 100644 --- a/dmoj/urls.py +++ b/dmoj/urls.py @@ -44,6 +44,7 @@ from judge.views import ( language, license, mailgun, + markdown_editor, notification, organization, preview, @@ -405,6 +406,11 @@ urlpatterns = [ ] ), ), + url( + r"^markdown_editor/", + markdown_editor.MarkdownEditor.as_view(), + name="markdown_editor", + ), url( r"^submission_source_file/(?P(\w|\.)+)", submission.SubmissionSourceFileView.as_view(), diff --git a/judge/comments.py b/judge/comments.py index be33a4e..65d8f7e 100644 --- a/judge/comments.py +++ b/judge/comments.py @@ -168,7 +168,7 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View): ) def _get_queryset(self, target_comment): - if target_comment != None: + if target_comment: queryset = target_comment.get_descendants(include_self=True) queryset = ( queryset.select_related("author__user") @@ -217,11 +217,11 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View): context["has_comments"] = queryset.exists() context["comment_lock"] = self.is_comment_locked() - context["comment_list"] = queryset + context["comment_list"] = list(queryset) context["vote_hide_threshold"] = settings.DMOJ_COMMENT_VOTE_HIDE_THRESHOLD if queryset.exists(): - context["comment_root_id"] = queryset[0].id + context["comment_root_id"] = context["comment_list"][0].id else: context["comment_root_id"] = 0 context["comment_parent_none"] = 1 @@ -234,4 +234,5 @@ class CommentedDetailView(TemplateResponseMixin, SingleObjectMixin, View): context["limit"] = DEFAULT_OFFSET context["comment_count"] = comment_count + context["profile"] = self.request.profile return context diff --git a/judge/utils/fine_uploader.py b/judge/utils/fine_uploader.py index a9909a7..2a22ccf 100644 --- a/judge/utils/fine_uploader.py +++ b/judge/utils/fine_uploader.py @@ -35,7 +35,7 @@ def save_upload(f, path): # pass callback function to post_upload def handle_upload(f, fileattrs, upload_dir, post_upload=None): - chunks_dir = os.path.join(tempfile.gettempdir(), "chunk_upload_tmp") + chunks_dir = settings.CHUNK_UPLOAD_DIR if not os.path.exists(os.path.dirname(chunks_dir)): os.makedirs(os.path.dirname(chunks_dir)) chunked = False diff --git a/judge/views/comment.py b/judge/views/comment.py index 03285ad..6965201 100644 --- a/judge/views/comment.py +++ b/judge/views/comment.py @@ -15,12 +15,11 @@ from django.http import ( HttpResponseBadRequest, HttpResponseForbidden, ) -from django.shortcuts import get_object_or_404 +from django.shortcuts import get_object_or_404, render from django.utils.translation import gettext as _ from django.views.decorators.http import require_POST from django.views.generic import DetailView, UpdateView from django.urls import reverse_lazy -from django.template import loader from reversion import revisions from reversion.models import Version @@ -42,11 +41,6 @@ __all__ = [ @login_required - -# def get_more_reply(request, id): -# queryset = Comment.get_pk(id) - - def vote_comment(request, delta): if abs(delta) != 1: return HttpResponseBadRequest( @@ -156,6 +150,7 @@ def get_comments(request, limit=10): revisions=Count("versions", distinct=True), )[offset : offset + limit] ) + profile = None if request.user.is_authenticated: profile = request.profile queryset = queryset.annotate( @@ -164,10 +159,11 @@ def get_comments(request, limit=10): new_offset = offset + min(len(queryset), limit) - comment_html = loader.render_to_string( + return render( + request, "comments/content-list.html", { - "request": request, + "profile": profile, "comment_root_id": comment_root_id, "comment_list": queryset, "vote_hide_threshold": settings.DMOJ_COMMENT_VOTE_HIDE_THRESHOLD, @@ -181,8 +177,6 @@ def get_comments(request, limit=10): }, ) - return HttpResponse(comment_html) - def get_show_more(request): return get_comments(request) diff --git a/judge/views/markdown_editor.py b/judge/views/markdown_editor.py new file mode 100644 index 0000000..a014ba6 --- /dev/null +++ b/judge/views/markdown_editor.py @@ -0,0 +1,14 @@ +from django.views import View +from django.shortcuts import render +from django.utils.translation import gettext_lazy as _ + + +class MarkdownEditor(View): + def get(self, request): + return render( + request, + "markdown_editor/markdown_editor.html", + { + "title": _("Markdown Editor"), + }, + ) diff --git a/locale/vi/LC_MESSAGES/django.po b/locale/vi/LC_MESSAGES/django.po index a4dde83..4497f98 100644 --- a/locale/vi/LC_MESSAGES/django.po +++ b/locale/vi/LC_MESSAGES/django.po @@ -130,6 +130,18 @@ msgstr "Thể thức" msgid "Rating" msgstr "" +#: templates/markdown_editor/markdown_editor.html:107 +msgid "Insert Image" +msgstr "Chèn hình ảnh" + +#: templates/markdown_editor/markdown_editor.html:110 +msgid "From the web" +msgstr "Từ web" + +#: templates/markdown_editor/markdown_editor.html:116 +msgid "From your computer" +msgstr "Từ máy tính của bạn" + #: judge/admin/contest.py:201 msgid "Access" msgstr "Truy cập" @@ -6255,3 +6267,4 @@ msgstr "Chọn tất cả" #~ msgid "Hard" #~ msgstr "Khó" + diff --git a/locale/vi/LC_MESSAGES/dmoj-user.po b/locale/vi/LC_MESSAGES/dmoj-user.po index ffd36e9..4ea605c 100644 --- a/locale/vi/LC_MESSAGES/dmoj-user.po +++ b/locale/vi/LC_MESSAGES/dmoj-user.po @@ -39,6 +39,12 @@ msgstr "Đăng ký tên" msgid "Report" msgstr "Báo cáo" +msgid "Insert Image" +msgstr "Chèn hình ảnh" + +msgid "Save" +msgstr "Lưu" + msgid "2sat" msgstr "" @@ -593,3 +599,4 @@ msgstr "" msgid "z-function" msgstr "" + diff --git a/resources/chatbox.scss b/resources/chatbox.scss index e4b3264..3f1a47b 100644 --- a/resources/chatbox.scss +++ b/resources/chatbox.scss @@ -78,7 +78,7 @@ #chat-container { display: flex; width: 100%; - height: calc(100vh - 3em); + height: calc(100vh - $navbar_height); border: 1px solid #ccc; /*border-radius: 0 4px 0 0;*/ border-bottom: 0; @@ -220,5 +220,6 @@ @media (max-width: 799px) { #chat-area { height: calc(100vh - $navbar_height_mobile); + max-height: -webkit-fill-available; } } diff --git a/resources/comments.scss b/resources/comments.scss index c606f26..42dc90b 100644 --- a/resources/comments.scss +++ b/resources/comments.scss @@ -214,7 +214,7 @@ a { input, textarea { min-width: 100%; max-width: 100%; - font-size: 1em; + font-size: 15px; } } diff --git a/resources/common.js b/resources/common.js index 65fb8b3..185eb7c 100644 --- a/resources/common.js +++ b/resources/common.js @@ -386,6 +386,11 @@ function onWindowReady() { }); }); $('a').click(function() { + var href = $(this).attr('href'); + if (!href || href === '#' || href.startsWith("javascript")) { + return; + } + $("#loading-bar").show(); $("#loading-bar").animate({ width: "100%" }, 2000, function() { $(this).hide().css({ width: 0}); diff --git a/resources/darkmode.css b/resources/darkmode.css index 36a4304..f9a4884 100644 --- a/resources/darkmode.css +++ b/resources/darkmode.css @@ -1712,10 +1712,10 @@ noscript #noscript { color: rgb(178, 171, 161); } #chat-icon { - color: rgb(249, 146, 97); + color: rgb(200, 196, 189); } #chat-icon:hover { - color: rgb(114, 255, 114); + color: rgb(249, 146, 97); } #nav-lang-icon { color: rgb(51, 125, 255); @@ -2471,16 +2471,13 @@ input[type="text"], input[type="password"], input[type="email"], input[type="num box-shadow: rgba(0, 0, 0, 0.07) 0px 1px 1px inset; } textarea { - color: rgb(178, 172, 162); background-image: none; background-color: rgb(24, 26, 27); border-color: rgb(62, 68, 70); box-shadow: rgba(0, 0, 0, 0.07) 0px 1px 1px inset; } textarea:hover { - border-color: rgba(16, 87, 144, 0.8); - box-shadow: rgba(0, 0, 0, 0.07) 0px 1px 1px inset, - rgba(16, 91, 150, 0.6) 0px 0px 4px; + border-color: rgb(140, 130, 115); } input[type="text"]:hover, input[type="password"]:hover { border-color: rgba(16, 87, 144, 0.8); @@ -2488,9 +2485,7 @@ input[type="text"]:hover, input[type="password"]:hover { rgba(16, 91, 150, 0.6) 0px 0px 4px; } textarea:focus { - border-color: rgba(16, 87, 144, 0.8); - box-shadow: rgba(0, 0, 0, 0.07) 0px 1px 1px inset, - rgba(16, 91, 150, 0.6) 0px 0px 8px; outline-color: initial; + border-color: rgb(140, 130, 115); outline-color: initial; } input[type="text"]:focus, input[type="password"]:focus { border-color: rgba(16, 87, 144, 0.8); @@ -2552,7 +2547,7 @@ input[type="text"]:focus, input[type="password"]:focus { ul.pagination a:hover { color: rgb(232, 230, 227); background-image: initial; - background-color: rgb(8, 128, 104); + background-color: rgb(163, 62, 18); border-color: initial; } ul.pagination > li > a, @@ -2563,14 +2558,14 @@ ul.pagination > li > span { border-color: rgb(199, 70, 8); } ul.pagination > .disabled-page > a { - color: rgb(157, 148, 136); - background-color: rgba(3, 66, 54, 0.5); - border-color: rgba(126, 117, 103, 0.5); + color: rgb(223, 220, 215); + background-color: rgb(137, 78, 57); + border-color: rgb(199, 68, 21); } ul.pagination > .disabled-page > span { - color: rgb(157, 148, 136); - background-color: rgba(3, 66, 54, 0.5); - border-color: rgba(126, 117, 103, 0.5); + color: rgb(223, 220, 215); + background-color: rgb(137, 78, 57); + border-color: rgb(199, 68, 21); } ul.pagination > .active-page > a { color: rgb(232, 230, 227); @@ -2922,8 +2917,8 @@ a.voted { color: rgb(152, 143, 129); } .list-contest { - box-shadow: rgba(3, 66, 54, 0.2) 0px 4px 8px, - rgba(3, 66, 54, 0.19) 0px 6px 20px; + box-shadow: rgb(49, 53, 55) 0px 1px 2px, + rgb(49, 53, 55) 0px 1px 5px; } #contest-calendar th { border-bottom-color: rgb(62, 68, 70); @@ -3058,7 +3053,13 @@ a.voted { } #chat-input { color: rgb(232, 230, 227); - border-color: rgb(159, 117, 19); + border-color: rgb(140, 130, 115); +} +#chat-input::-webkit-input-placeholder { + color: rgb(152, 143, 129); +} +#chat-input::placeholder { + color: rgb(152, 143, 129); } .selected-status-row { background-color: rgb(49, 53, 55); @@ -3077,15 +3078,6 @@ a.voted { #chat-info { box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 3px; } -#refresh-button { - background-image: initial; - background-color: transparent; - border-color: initial; -} -#refresh-button:hover { - background-image: initial; - background-color: rgb(40, 111, 17); -} .status-circle { stroke: rgb(232, 230, 227); } @@ -3104,11 +3096,12 @@ a.voted { color: rgb(232, 230, 227); } .chat-input-icon { - color: rgb(249, 146, 97); + color: rgb(232, 230, 227); + background-color: rgb(48, 104, 78); } .chat-input-icon:hover { background-image: initial; - background-color: rgb(49, 53, 55); + background-color: rgb(62, 136, 112); } .chat .active-span { color: rgb(169, 162, 151); @@ -3873,64 +3866,11 @@ mjx-assistive-mml { mjx-stretchy-v > mjx-ext { border-color: transparent; } -.noUi-target, -.noUi-target * { - -webkit-tap-highlight-color: transparent; +.recently-attempted ul { + list-style-image: initial; } -.noUi-target { - background-image: initial; - background-color: rgb(27, 29, 30); - border-color: rgb(60, 65, 68); - box-shadow: rgb(32, 35, 37) 0px 1px 1px inset, - rgb(62, 68, 70) 0px 3px 6px -5px; -} -.noUi-connect { - background-image: initial; - background-color: rgb(50, 147, 140); - box-shadow: rgba(38, 42, 43, 0.45) 0px 0px 3px inset; -} -.noUi-handle { - border-color: rgb(59, 64, 66); - background-image: initial; - background-color: rgb(24, 26, 27); - box-shadow: rgb(24, 26, 27) 0px 0px 1px inset, - rgb(35, 38, 40) 0px 1px 7px inset, - rgb(62, 68, 70) 0px 3px 6px -3px; -} -.noUi-active { - box-shadow: rgb(24, 26, 27) 0px 0px 1px inset, - rgb(43, 47, 49) 0px 1px 7px inset, - rgb(62, 68, 70) 0px 3px 6px -3px; -} -.noUi-handle::after, -.noUi-handle::before { - background-image: initial; - background-color: rgb(38, 41, 42); -} -[disabled] .noUi-connect { - background-image: initial; - background-color: rgb(64, 69, 72); -} -.noUi-pips { - color: rgb(168, 160, 149); -} -.noUi-value-sub { - color: rgb(200, 195, 188); -} -.noUi-marker { - background-image: initial; - background-color: rgb(53, 57, 59); -} -.noUi-marker-large, -.noUi-marker-sub { - background-image: initial; - background-color: rgb(72, 78, 81); -} -.noUi-tooltip { - border-color: rgb(59, 64, 66); - background-image: initial; - background-color: rgb(24, 26, 27); - color: rgb(232, 230, 227); +.organization-row:last-child { + border-bottom-color: initial; } /* Override Style */ diff --git a/resources/dmmd-preview.css b/resources/dmmd-preview.css index 7a7fd1d..c768a0e 100644 --- a/resources/dmmd-preview.css +++ b/resources/dmmd-preview.css @@ -13,7 +13,7 @@ div.dmmd-preview-update { } div.dmmd-preview-content { - padding: 0 7px; + padding: 0 8px; } div.dmmd-preview.dmmd-preview-has-content div.dmmd-preview-update { @@ -21,7 +21,8 @@ div.dmmd-preview.dmmd-preview-has-content div.dmmd-preview-update { } div.dmmd-preview-has-content div.dmmd-preview-content { - padding-bottom: 7px; + padding-bottom: 8px; + padding-top: 8px; } div.dmmd-no-button div.dmmd-preview-update { diff --git a/resources/pagedown_widget.css b/resources/pagedown_widget.css index f20c5e2..3601240 100644 --- a/resources/pagedown_widget.css +++ b/resources/pagedown_widget.css @@ -14,7 +14,7 @@ width: 100%; background: #fff; border: 1px solid DarkGray; - font-family: Consolas, "Liberation Mono", Monaco, "Courier New", monospace !important; + font-family: "Noto Sans",Arial,"Lucida Grande",sans-serif !important; } .wmd-preview { diff --git a/resources/pagedown_widget.scss b/resources/pagedown_widget.scss index b6d2333..fa97abe 100644 --- a/resources/pagedown_widget.scss +++ b/resources/pagedown_widget.scss @@ -14,7 +14,7 @@ width: 100%; background: #fff; border: 1px solid DarkGray; - font-family: Consolas, "Liberation Mono", Monaco, "Courier New", monospace !important; + font-family: "Noto Sans",Arial,"Lucida Grande",sans-serif !important; } .wmd-preview { @@ -174,51 +174,51 @@ /* Extra styles to allow for image upload */ .pagedown-image-upload { - display: none; - z-index: 10001; - position: fixed; - background: white; - top: 50%; - left: 50%; - padding: 10px; - width: 400px; - max-width: 90%; - transform: translate3d(-50%, -50%, 0); - box-shadow: 2px 2px 10px 0px rgba(0, 0, 0, 0.5); + display: none; + z-index: 10001; + position: fixed; + background: white; + top: 50%; + left: 50%; + padding: 10px; + width: 400px; + max-width: 90%; + transform: translate3d(-50%, -50%, 0); + box-shadow: 2px 2px 10px 0px rgba(0, 0, 0, 0.5); } .pagedown-image-upload .submit-row { - margin: 10px 0 0 0; + margin: 10px 0 0 0; } .pagedown-image-upload.show { - display: block; + display: block; } .pagedown-image-upload .submit-loading { - display: none; - vertical-align: middle; - border: 4px solid #f3f3f3; /* Light grey */ - border-top: 4px solid #79aec8; /* Blue */ - border-radius: 50%; - width: 24px; - height: 24px; - animation: spin 1s linear infinite; + display: none; + vertical-align: middle; + border: 4px solid #f3f3f3; /* Light grey */ + border-top: 4px solid #79aec8; /* Blue */ + border-radius: 50%; + width: 24px; + height: 24px; + animation: spin 1s linear infinite; } .pagedown-image-upload .submit-loading.show { - display: inline-block; + display: inline-block; } .pagedown-image-upload .submit-input { - display: none; + display: none; } .pagedown-image-upload .submit-input.show { - display: inline-block; + display: inline-block; } @keyframes spin { - 0% { transform: rotate(0deg); } - 100% { transform: rotate(360deg); } + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } } \ No newline at end of file diff --git a/resources/widgets.scss b/resources/widgets.scss index 3f2ea95..42e8c8e 100644 --- a/resources/widgets.scss +++ b/resources/widgets.scss @@ -161,8 +161,7 @@ input { } textarea { - padding: 4px 8px; - color: #555; + padding: 8px; background: #FFF none; border: 1px solid $border_gray; border-radius: $widget_border_radius; @@ -172,8 +171,7 @@ textarea { } textarea:hover { - border-color: rgba(82, 168, 236, 0.8); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 4px rgba(82, 168, 236, 0.6); + border-color: black; } input { @@ -184,8 +182,8 @@ input { } textarea:focus { - border-color: rgba(82, 168, 236, 0.8); - box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(82, 168, 236, 0.6); + border-color: black; + border-width: unset; outline: 0; } @@ -322,7 +320,7 @@ input { // Bootstrap-y pagination ul.pagination a:hover { color: #FFF; - background: #0aa082; + background: #cc4e17; border: none; } @@ -338,22 +336,6 @@ ul.pagination { li { display: inline; - // &:first-child > { - // a, span { - // margin-left: 0; - // border-top-left-radius: $widget_border_radius; - // border-bottom-left-radius: $widget_border_radius; - // } - // } - - // &:last-child > { - // a, span { - // margin-left: 0; - // border-top-right-radius: $widget_border_radius; - // border-bottom-right-radius: $widget_border_radius; - // } - // } - > { a, span { position: relative; @@ -373,15 +355,15 @@ ul.pagination { .disabled-page > { a { - color: #888; - background-color: #04534380; - border-color: #04534380; + color: #f1efef; + background-color: #ab6247; + border-color: #6a240b; } span { - color: #888; - background-color: #04534380; - border-color: #04534380; + color: #f1efef; + background-color: #ab6247; + border-color: #6a240b; } } diff --git a/templates/chat/chat_css.html b/templates/chat/chat_css.html index 01929cd..f334227 100644 --- a/templates/chat/chat_css.html +++ b/templates/chat/chat_css.html @@ -195,8 +195,8 @@ #chat-input-container { padding-left: 3%; } - #chat-area { - padding-bottom: 1.5em; + .back-button { + display: none; } .back-button { display: none; diff --git a/templates/comments/content-list.html b/templates/comments/content-list.html index c08fd46..ebf0c31 100644 --- a/templates/comments/content-list.html +++ b/templates/comments/content-list.html @@ -1,13 +1,10 @@ -{% set logged_in = request.user.is_authenticated %} -{% set profile = request.profile if logged_in else None %} - {% for node in mptt_tree(comment_list) recursive %}
  • - {% if logged_in %} + {% if profile %} {% else %} @@ -16,7 +13,7 @@ {% endif %}
    {{ node.score }}
    - {% if logged_in %} + {% if profile %} {% else %} @@ -55,7 +52,7 @@ - {% if logged_in and not comment_lock %} + {% if profile and not comment_lock %} {% set can_edit = node.author.id == profile.id and not profile.mute %} {% if can_edit %} {{ _('Comments') }} {% if can_comment %} - {{ _('Write comment') }} + {{ _('Write comment') }} {% endif %} {% if can_comment %} diff --git a/templates/comments/media-js.html b/templates/comments/media-js.html index ccae804..862dbee 100644 --- a/templates/comments/media-js.html +++ b/templates/comments/media-js.html @@ -30,7 +30,7 @@ {% endif %} + + + + + + + + + + + + + +{% endblock %} + +{% block title_row %} +{% endblock %} + +{% block title_ruler %} +{% endblock %} + +{% block body %} +
    +
    + +
    +
    +
    +
    + +
    +
    +
    {{_('Update Preview')}}
    +
    +
    +
    +

    {{_('Insert Image')}}

    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    + + +
    +
    +
    +
    +
    + +
    +
    +
    +
    +{% endblock %} +