Clean images and case insensitive nav.

This commit is contained in:
jmsgrogan 2024-02-18 10:51:57 +00:00
parent 6464703381
commit 288759146c
7 changed files with 59 additions and 4 deletions

View file

@ -0,0 +1,18 @@
# Generated by Django 5.0.2 on 2024-02-18 09:58
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('primary', '0009_page_pretty_name'),
]
operations = [
migrations.AddField(
model_name='page',
name='prority',
field=models.IntegerField(default=0),
),
]

View file

@ -0,0 +1,18 @@
# Generated by Django 5.0.2 on 2024-02-18 10:02
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('primary', '0010_page_prority'),
]
operations = [
migrations.RenameField(
model_name='page',
old_name='prority',
new_name='priority',
),
]

View file

@ -18,6 +18,7 @@ class Page(models.Model):
pretty_name = models.CharField(max_length=200, default="") pretty_name = models.CharField(max_length=200, default="")
published = models.BooleanField(default=False) published = models.BooleanField(default=False)
navigable = models.BooleanField(default=False) navigable = models.BooleanField(default=False)
priority = models.IntegerField(default=0)
def __str__(self): def __str__(self):
return self.name return self.name

View file

@ -33,10 +33,9 @@ body {
img { img {
margin:0 auto; margin:0 auto;
width: 100%;
display: flex; display: flex;
justify-content: center; justify-content: center;
max-height:300px; max-width:800px;
border-radius: 8px; border-radius: 8px;
box-shadow: 0 4px 8px 0; box-shadow: 0 4px 8px 0;
} }
@ -107,6 +106,10 @@ ul {
list-style-position: inside; list-style-position: inside;
} }
ul li {
padding: 5px 0px;
}
.login-input{ .login-input{
margin-top: 30px; margin-top: 30px;
text-align: center; text-align: center;

View file

@ -6,6 +6,8 @@ from django.template import Context
from django.contrib.auth import authenticate, login from django.contrib.auth import authenticate, login
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.views.defaults import page_not_found
import markdown import markdown
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
@ -24,6 +26,17 @@ _TEMPLATE = """
</html> </html>
""" """
def handler404(request, exception, template_name="404.html"):
page_names = ["home", "schedule", "thingstodo"]
working_path = request.path.lower()
if working_path and working_path[0] == "/":
working_path = working_path[1:]
if working_path and working_path[-1] == "/":
working_path = working_path[:-1]
if working_path in page_names:
return redirect(working_path)
return page_not_found(request, exception, template_name)
def get_site_header(site): def get_site_header(site):
template = Template(site.header) template = Template(site.header)
context = Context({"site": site}) context = Context({"site": site})
@ -60,7 +73,7 @@ def home(request):
def get_page_header(site: Site): def get_page_header(site: Site):
pages = site.page_set.filter(navigable=True) pages = site.page_set.order_by("priority").filter(navigable=True)
template = Template(site.page_header) template = Template(site.page_header)
context = Context({"pages" : pages}) context = Context({"pages" : pages})
return template.render(context) return template.render(context)

View file

@ -25,7 +25,7 @@ SECRET_KEY = 'django-insecure-bj9fez3qztt5e2lrzpgh%%nat@w^kn!k@l92l=+#%wm)4)p^5m
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True DEBUG = True
ALLOWED_HOSTS = [] ALLOWED_HOSTS = ["localhost"]
# Application definition # Application definition

View file

@ -23,3 +23,5 @@ urlpatterns = [
path("", include('primary.urls')), path("", include('primary.urls')),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
handler404 = 'primary.views.handler404'