diff --git a/content/core.page/test2.md b/content/core.page/test2.md index 95decfc..3ba7a60 100644 --- a/content/core.page/test2.md +++ b/content/core.page/test2.md @@ -2,4 +2,6 @@ title: Test --- +# Heading + My content diff --git a/requirements.txt b/requirements.txt index d5939a9..d9fbf0c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ django git+https://github.com/andrewgodwin/yamdl gunicorn +markdown diff --git a/yamdl_playground/core/views.py b/yamdl_playground/core/views.py index 6e080c0..dfd0b76 100644 --- a/yamdl_playground/core/views.py +++ b/yamdl_playground/core/views.py @@ -1,10 +1,17 @@ from .models import Page from django.http import HttpResponse from django.db import connections +from django.shortcuts import get_object_or_404 +import markdown -def test(request): +def search(request): with connections["default"].cursor() as cursor: cursor.execute("SELECT rowid FROM search_index WHERE search_index = %s;", ["content"]) row = cursor.fetchone() pages = Page.objects.filter(id__in=row) return HttpResponse(str(pages), content_type="text/plain") + +def content(request, id): + page = get_object_or_404(Page, id=id) + + return HttpResponse(markdown.markdown(page.content), content_type="text/html") diff --git a/yamdl_playground/urls.py b/yamdl_playground/urls.py index 0e0a667..ee13129 100644 --- a/yamdl_playground/urls.py +++ b/yamdl_playground/urls.py @@ -18,5 +18,6 @@ from django.urls import path from .core import views urlpatterns = [ - path("test/", views.test) + path("search/", views.search), + path("content//", views.content) ]