From 067214b587670e508f52cc5968ca0c4b7a5fcd05 Mon Sep 17 00:00:00 2001 From: Bao Le <127121163+BaoLe106@users.noreply.github.com> Date: Tue, 3 Oct 2023 02:30:46 +0800 Subject: [PATCH] Markdown Editor (#85) --- dmoj/urls.py | 6 + judge/views/markdown_editor.py | 14 ++ locale/vi/LC_MESSAGES/django.po | 13 ++ locale/vi/LC_MESSAGES/dmoj-user.po | 7 + .../markdown_editor/markdown_editor.html | 134 ++++++++++++++++++ 5 files changed, 174 insertions(+) create mode 100644 judge/views/markdown_editor.py create mode 100644 templates/markdown_editor/markdown_editor.html 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/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/templates/markdown_editor/markdown_editor.html b/templates/markdown_editor/markdown_editor.html new file mode 100644 index 0000000..04418e4 --- /dev/null +++ b/templates/markdown_editor/markdown_editor.html @@ -0,0 +1,134 @@ +{% extends "base.html" %} + +{% block media %} + +{% endblock %} + +{% block js_media %} + + + + + + + + + + + + + + +{% endblock %} + +{% block title_row %} +{% endblock %} + +{% block body %} +
+ +
+
+
+
+ +
+
+
{{_('Update Preview')}}
+
+
+
+

{{_('Insert Image')}}

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