Compare commits
2 commits
94643dc2c7
...
c12f637d17
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c12f637d17 | ||
![]() |
4f92cbf450 |
8 changed files with 54 additions and 4 deletions
|
@ -32,6 +32,9 @@ class JJController:
|
||||||
if force or not (self.root / '.jj').exists():
|
if force or not (self.root / '.jj').exists():
|
||||||
self.run(['jj','git','init'])
|
self.run(['jj','git','init'])
|
||||||
self.ignore_paths(['.make.*'])
|
self.ignore_paths(['.make.*'])
|
||||||
|
self.set_git_url()
|
||||||
|
|
||||||
|
def set_git_url(self):
|
||||||
git_url = settings.GIT_REPO_URL_TEMPLATE.format(name=self.think.slug)
|
git_url = settings.GIT_REPO_URL_TEMPLATE.format(name=self.think.slug)
|
||||||
self.run(['jj','git','remote','add','origin', git_url])
|
self.run(['jj','git','remote','add','origin', git_url])
|
||||||
|
|
||||||
|
|
18
thinks/migrations/0005_think_last_edited.py
Normal file
18
thinks/migrations/0005_think_last_edited.py
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
# Generated by Django 5.0.3 on 2025-04-26 07:50
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('thinks', '0004_think_creation_time'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='think',
|
||||||
|
name='last_edited',
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
|
@ -13,6 +13,7 @@ class Think(models.Model):
|
||||||
slug = models.SlugField()
|
slug = models.SlugField()
|
||||||
category = models.CharField(max_length=100, blank=True, null=True)
|
category = models.CharField(max_length=100, blank=True, null=True)
|
||||||
creation_time = models.DateTimeField(auto_now_add=True)
|
creation_time = models.DateTimeField(auto_now_add=True)
|
||||||
|
last_edited = models.DateTimeField(blank=True, null=True)
|
||||||
|
|
||||||
is_template = models.BooleanField(default=False)
|
is_template = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,8 @@ body {
|
||||||
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-rows: auto 1fr;
|
grid-template-rows: auto 1fr;
|
||||||
min-height: 100vh;
|
min-height: 100svh;
|
||||||
|
max-height: 100svh;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: var(--half-spacing);
|
padding: var(--half-spacing);
|
||||||
|
|
||||||
|
@ -128,8 +129,8 @@ input[type="file"] {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
--col-1-width: auto;
|
--col-1-width: auto;
|
||||||
grid-template:
|
grid-template:
|
||||||
"nav editor preview" min-content
|
"nav editor preview" 1fr
|
||||||
"log editor preview" 1fr
|
"log log log" min-content
|
||||||
/ var(--col-1-width) var(--editor-size) var(--preview-size)
|
/ var(--col-1-width) var(--editor-size) var(--preview-size)
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,15 @@
|
||||||
{% endblock header %}
|
{% endblock header %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
|
|
||||||
|
<form id="search" method="GET" action="{% url 'search' %}">
|
||||||
|
<label for="query">Search</label>
|
||||||
|
<input type="search" id="query" name="query" list="slugs">
|
||||||
|
<datalist id="slugs">
|
||||||
|
{% for think in thinks %}<option value="{{think.slug}}"/>{% endfor %}
|
||||||
|
</datalist>
|
||||||
|
</form>
|
||||||
|
|
||||||
<section id="templates">
|
<section id="templates">
|
||||||
<h2>Templates</h2>
|
<h2>Templates</h2>
|
||||||
<ul id="templates-list">
|
<ul id="templates-list">
|
||||||
|
|
9
thinks/templates/thinks/think_form.html
Normal file
9
thinks/templates/thinks/think_form.html
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<form method="POST" enctype="multipart/form-data">
|
||||||
|
{% csrf_token %}
|
||||||
|
{{form}}
|
||||||
|
<button type="submit">Submit</button>
|
||||||
|
</form>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -18,5 +18,6 @@ urlpatterns = [
|
||||||
path('think/<slug:slug>/jj/commit', JJCommitView.as_view(), name='jj_commit'),
|
path('think/<slug:slug>/jj/commit', JJCommitView.as_view(), name='jj_commit'),
|
||||||
path('new', CreateThinkView.as_view(), name='new_think'),
|
path('new', CreateThinkView.as_view(), name='new_think'),
|
||||||
path('new/<slug:slug>', RemixThinkView.as_view(), name='remix_think'),
|
path('new/<slug:slug>', RemixThinkView.as_view(), name='remix_think'),
|
||||||
|
path('search', search, name='search'),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ from django.http import HttpResponse, JsonResponse
|
||||||
from django.shortcuts import render, redirect
|
from django.shortcuts import render, redirect
|
||||||
from django.views import generic
|
from django.views import generic
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
from django.utils.timezone import now
|
||||||
from itertools import groupby
|
from itertools import groupby
|
||||||
import json
|
import json
|
||||||
import mimetypes
|
import mimetypes
|
||||||
|
@ -32,6 +33,10 @@ class ThinkMixin(LoginRequiredMixin):
|
||||||
model = Think
|
model = Think
|
||||||
context_object_name = '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):
|
class IndexView(ThinkMixin, generic.ListView):
|
||||||
template_name = 'thinks/index.html'
|
template_name = 'thinks/index.html'
|
||||||
|
@ -41,7 +46,7 @@ class IndexView(ThinkMixin, generic.ListView):
|
||||||
|
|
||||||
context['templates'] = Think.objects.filter(is_template=True)
|
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()))
|
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 = self.object
|
||||||
|
|
||||||
|
think.last_edited = now()
|
||||||
|
think.save(update_fields=('last_edited',))
|
||||||
|
|
||||||
root = think.root
|
root = think.root
|
||||||
|
|
||||||
strpath = self.request.GET.get('path')
|
strpath = self.request.GET.get('path')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue