diff --git a/thinks/templates/thinks/index.html b/thinks/templates/thinks/index.html
index 85322de..80ce8b3 100644
--- a/thinks/templates/thinks/index.html
+++ b/thinks/templates/thinks/index.html
@@ -7,6 +7,15 @@
{% endblock header %}
{% block main %}
+
+
+
Templates
diff --git a/thinks/urls.py b/thinks/urls.py
index 930fb4d..bdaf6ee 100644
--- a/thinks/urls.py
+++ b/thinks/urls.py
@@ -18,5 +18,6 @@ urlpatterns = [
path('think//jj/commit', JJCommitView.as_view(), name='jj_commit'),
path('new', CreateThinkView.as_view(), name='new_think'),
path('new/', RemixThinkView.as_view(), name='remix_think'),
+ path('search', search, name='search'),
]
diff --git a/thinks/views.py b/thinks/views.py
index bbb1dc1..4dbd075 100644
--- a/thinks/views.py
+++ b/thinks/views.py
@@ -4,6 +4,7 @@ from django.http import HttpResponse, JsonResponse
from django.shortcuts import render, redirect
from django.views import generic
from django.urls import reverse
+from django.utils.timezone import now
from itertools import groupby
import json
import mimetypes
@@ -32,6 +33,10 @@ class ThinkMixin(LoginRequiredMixin):
model = Think
context_object_name = 'think'
+def search(request, *args, **kwargs):
+ query = request.GET.get('query','')
+ think = Think.objects.get(slug__icontains=query)
+ return redirect(think.get_absolute_url())
class IndexView(ThinkMixin, generic.ListView):
template_name = 'thinks/index.html'
@@ -41,7 +46,7 @@ class IndexView(ThinkMixin, generic.ListView):
context['templates'] = Think.objects.filter(is_template=True)
- context['recent_thinks'] = Think.objects.filter(is_template=False).order_by('-creation_time')[:3]
+ context['recent_thinks'] = Think.objects.all().order_by('-last_edited', '-creation_time')[:3]
context['thinks'] = sorted(Think.objects.filter(is_template=False), key=lambda t: (t.category if t.category else '', -t.creation_time.timestamp()))
@@ -100,6 +105,9 @@ class ThinkView(ThinkMixin, generic.DetailView):
think = self.object
+ think.last_edited = now()
+ think.save(update_fields=('last_edited',))
+
root = think.root
strpath = self.request.GET.get('path')