require log in to edit thinks

This commit is contained in:
Christian Lawson-Perfect 2024-03-05 10:13:14 +00:00
parent 52ab7aa331
commit 46c9f0a447
4 changed files with 29 additions and 13 deletions

View file

@ -1,5 +1,6 @@
:root { :root {
--spacing: 1em; --spacing: 1em;
--half-spacing: calc(0.5 * var(--spacing));
} }
* { * {
@ -20,7 +21,7 @@ body.index {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: var(--spacing); gap: var(--spacing);
& > .think { & > .think {
& .readme { & .readme {
max-width: 80ch; max-width: 80ch;
@ -41,23 +42,23 @@ body.thing-editor {
; ;
gap: var(--spacing); gap: var(--spacing);
/*! overflow: hidden; */ /*! overflow: hidden; */
& main { & main {
display: grid; display: grid;
gap: var(--spacing); gap: var(--spacing);
grid-template: "nav editor preview" / auto 3fr 2fr; grid-template: "nav editor preview" / auto 3fr 2fr;
height: 100%; height: 100%;
& > nav { & > nav {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: var(--spacing); gap: var(--spacing);
& #file-tree { & #file-tree {
margin: 0; margin: 0;
overflow: auto; overflow: auto;
} }
& form { & form {
display: grid; display: grid;
grid-template-columns: 1fr 6em; grid-template-columns: 1fr 6em;
@ -65,20 +66,32 @@ body.thing-editor {
align-items: start; align-items: start;
} }
} }
& #editor { & #editor {
& #editor-controls { & #editor-controls {
display: flex; display: flex;
gap: var(--spacing); gap: var(--spacing);
justify-content: space-between; justify-content: space-between;
& > details {
text-align: right;
& > summary {
user-select: none;
}
& button {
margin: var(--half-spacing) 0;
}
}
} }
& #code-editor { & #code-editor {
display: block; display: block;
max-width: 50vw; max-width: 50vw;
} }
} }
& #preview { & #preview {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -90,7 +103,7 @@ body.thing-editor {
} }
} }
} }
#file-form { #file-form {
overflow: auto; overflow: auto;
/*! max-height: 100%; */ /*! max-height: 100%; */
@ -104,13 +117,13 @@ body.thing-editor {
& main { & main {
grid-template: grid-template:
"nav" min-content "editor" 40vh "preview"; "nav" min-content "editor" 40vh "preview";
& nav { & nav {
flex-direction: row; flex-direction: row;
flex-wrap: wrap; flex-wrap: wrap;
& form { & form {
flex-grow: 1; flex-grow: 1;
} }
} }
} }

View file

@ -1,4 +1,5 @@
from django.conf import settings from django.conf import settings
from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import HttpResponse, JsonResponse 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
@ -11,7 +12,7 @@ from . import forms
from .models import Think from .models import Think
from .random_slug import random_slug from .random_slug import random_slug
class ThinkMixin: class ThinkMixin(LoginRequiredMixin):
model = Think model = Think
context_object_name = 'think' context_object_name = 'think'

View file

@ -117,6 +117,7 @@ USE_TZ = True
# https://docs.djangoproject.com/en/5.0/howto/static-files/ # https://docs.djangoproject.com/en/5.0/howto/static-files/
STATIC_URL = 'static/' STATIC_URL = 'static/'
STATIC_ROOT = '/srv/think.somethingorotherwhatever.com/public/static'
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/5.0/ref/settings/#default-auto-field
@ -126,4 +127,4 @@ DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
THINKS_DIR = Path('think_data') THINKS_DIR = Path('think_data')
THINKS_DIR.mkdir(parents=True, exist_ok=True) THINKS_DIR.mkdir(parents=True, exist_ok=True)
THINKS_STATIC_URL = 'http://{slug}.thinks.localhost' THINKS_STATIC_URL = 'http://{slug}.think.somethingorotherwhatever.com'

View file

@ -19,5 +19,6 @@ from django.urls import path, include
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path("accounts/", include("django.contrib.auth.urls")),
path("", include('thinks.urls')), path("", include('thinks.urls')),
] ]