Views and routes for search
This commit is contained in:
parent
e05601db22
commit
d2de96fceb
|
@ -45,5 +45,7 @@ urlpatterns = [
|
||||||
path('fav/<int:id>', views.fav, name='fav'),
|
path('fav/<int:id>', views.fav, name='fav'),
|
||||||
path('boost/<int:id>', views.boost, name='boost'),
|
path('boost/<int:id>', views.boost, name='boost'),
|
||||||
path('delete/<int:id>', views.delete, name='delete'),
|
path('delete/<int:id>', views.delete, name='delete'),
|
||||||
|
path('search', views.search, name='search'),
|
||||||
|
path('search_results', views.search_results, name='search_results'),
|
||||||
path('', views.home),
|
path('', views.home),
|
||||||
]
|
]
|
||||||
|
|
|
@ -418,6 +418,24 @@ def delete(request, id):
|
||||||
{"toot": toot, 'confirm_page': True,
|
{"toot": toot, 'confirm_page': True,
|
||||||
"fullbrutalism": fullbrutalism_p(request)})
|
"fullbrutalism": fullbrutalism_p(request)})
|
||||||
|
|
||||||
|
|
||||||
|
def search(request):
|
||||||
|
return render(request, 'search.html',
|
||||||
|
{"fullbrutalism": fullbrutalism_p(request)})
|
||||||
|
|
||||||
|
def search_results(request):
|
||||||
|
if request.method == 'GET':
|
||||||
|
query = request.GET.get('q', '')
|
||||||
|
elif request.method == 'POST':
|
||||||
|
query = request.POST.get('q', '')
|
||||||
|
else:
|
||||||
|
query = ''
|
||||||
|
mastodon = get_mastodon(request)
|
||||||
|
results = mastodon.search(query)
|
||||||
|
return render(request, 'search_results.html',
|
||||||
|
{"results": results,
|
||||||
|
"fullbrutalism": fullbrutalism_p(request)})
|
||||||
|
|
||||||
def about(request):
|
def about(request):
|
||||||
return render(request, 'about.html',
|
return render(request, 'about.html',
|
||||||
{"fullbrutalism": fullbrutalism_p(request)})
|
{"fullbrutalism": fullbrutalism_p(request)})
|
||||||
|
|
Loading…
Reference in New Issue