2023-12-07 00:01:51 +00:00
|
|
|
from .models import Page
|
|
|
|
from django.http import HttpResponse
|
2023-12-08 14:53:17 +00:00
|
|
|
from django.db import connections
|
2023-12-12 18:11:44 +00:00
|
|
|
from django.shortcuts import get_object_or_404
|
2024-03-24 18:36:48 +00:00
|
|
|
|
2023-12-07 00:01:51 +00:00
|
|
|
|
2023-12-12 18:11:44 +00:00
|
|
|
def search(request):
|
2023-12-08 14:53:17 +00:00
|
|
|
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")
|
2023-12-12 18:11:44 +00:00
|
|
|
|
2024-03-24 18:36:48 +00:00
|
|
|
|
2023-12-12 18:14:34 +00:00
|
|
|
def content(request, slug):
|
|
|
|
page = get_object_or_404(Page, slug=slug)
|
2023-12-12 18:11:44 +00:00
|
|
|
|
2024-03-24 21:59:25 +00:00
|
|
|
return HttpResponse(page.content, content_type="text/html")
|