WIP: Feature: Markdown preview for markdown-supported fields #1
@ -21,6 +21,7 @@ urlpatterns = [
|
||||
name='api-internal',
|
||||
),
|
||||
# Public API
|
||||
path('markdown/', api.MarkdownRenderApi.as_view(), name='markdown-rendering'),
|
||||
path('api/v1/extensions/', api.ExtensionsAPIView.as_view(), name='api'),
|
||||
path(
|
||||
'api/v1/extensions/<str:extension_id>/versions/upload/',
|
||||
|
@ -4,6 +4,7 @@ from django.core.exceptions import ValidationError
|
||||
from django.db import transaction
|
||||
from django.http import JsonResponse
|
||||
from django.utils.decorators import method_decorator
|
||||
from django.views import View
|
||||
from django.views.decorators.cache import cache_page
|
||||
from drf_spectacular.utils import OpenApiParameter, extend_schema
|
||||
from rest_framework.permissions import AllowAny
|
||||
@ -13,6 +14,7 @@ from rest_framework.views import APIView
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
|
||||
from common.compare import is_in_version_range, version
|
||||
from common.markdown import render as render_markdown
|
||||
from extensions.models import Extension, Platform
|
||||
from extensions.utils import clean_json_dictionary_from_optional_fields
|
||||
from files.forms import FileFormSkipAgreed
|
||||
@ -273,3 +275,10 @@ def extensions_awaiting_review(request):
|
||||
}
|
||||
)
|
||||
return JsonResponse(response, safe=False)
|
||||
|
||||
class MarkdownRenderApi(View):
|
||||
|
||||
def post(self, request, *args, **kwargs):
|
||||
text = request.POST.get('text')
|
||||
rendered_markdown = render_markdown(text)
|
||||
return JsonResponse({'markdown': rendered_markdown})
|
||||
|
Loading…
Reference in New Issue
Block a user