added Core for core pages, added static files & templates.
Some checks failed
Gitea Test. / tests (push) Failing after 3s

This commit is contained in:
Wouter Vermeer
2026-04-30 17:48:33 +02:00
parent bef2577746
commit 33661e14da
17 changed files with 825 additions and 1 deletions

0
src/core/__init__.py Normal file
View File

3
src/core/admin.py Normal file
View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

5
src/core/apps.py Normal file
View File

@@ -0,0 +1,5 @@
from django.apps import AppConfig
class CoreConfig(AppConfig):
name = 'core'

View File

3
src/core/models.py Normal file
View File

@@ -0,0 +1,3 @@
from django.db import models
# Create your models here.

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 KiB

View File

@@ -0,0 +1,13 @@
{% extends "base.html" %}
{% load static %}
{% block title %}Home{% endblock %}
{% block content %}
<h1>Welcome</h1>
<div>
{% include "components/carousel.html" with carousel_id="hero" carousel_images=carousel_images %}
</div>
{% endblock %}

3
src/core/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

9
src/core/urls.py Normal file
View File

@@ -0,0 +1,9 @@
from django.urls import path
from . import views
app_name = "core"
urlpatterns = [
path("", views.index, name="index"),
]

10
src/core/views.py Normal file
View File

@@ -0,0 +1,10 @@
from django.shortcuts import render
from django.templatetags.static import static
def index(request):
return render(
request,
"core/index.html",
{"carousel_images": [static("/core/img/5x5-2023-11-16-at-14.56.56-1.jpeg")]},
)

File diff suppressed because one or more lines are too long

1
src/static/css/input.css Normal file
View File

@@ -0,0 +1 @@
@import "tailwindcss"

68
src/static/js/carousel.js Normal file
View File

@@ -0,0 +1,68 @@
function initCarousel(id) {
document.addEventListener("DOMContentLoaded", function () {
const track = document.getElementById(id);
const originalSlides = Array.from(track.children);
const total = originalSlides.length;
if (total <= 1) {
return;
}
const firstClone = originalSlides[0].cloneNode(true);
const lastClone = originalSlides[total - 1].cloneNode(true);
track.appendChild(firstClone);
track.insertBefore(lastClone, originalSlides[0]);
let current = 1;
let isTransitioning = false;
track.style.transform = `translateX(-${current * 100}%)`;
const dots = document.querySelectorAll(`.${id}_dot`);
function updateDots(index) {
const realIndex = (index - 1 + total) % total;
dots.forEach((d, i) => {
d.classList.toggle("opacity-100", i === realIndex);
d.classList.toggle("opacity-50", i !== realIndex);
});
}
function goTo(index) {
if (isTransitioning) return;
isTransitioning = true;
track.style.transition = "transform 500ms ease-in-out";
current = index;
track.style.transform = `translateX(-${current * 100}%)`;
updateDots(current);
}
function next() {
goTo(current + 1);
}
function prev() {
goTo(current - 1);
}
track.addEventListener("transitionend", function () {
if (current === 0) {
track.style.transition = "none";
current = total;
track.style.transform = `translateX(-${current * 100}%)`;
}
if (current === total + 1) {
track.style.transition = "none";
current = 1;
track.style.transform = `translateX(-${current * 100}%)`;
}
isTransitioning = false;
});
setInterval(next, 5000);
updateDots(current);
window[`${id}_goTo`] = (i) => goTo(i + 1);
window[`${id}_next`] = next;
window[`${id}_prev`] = prev;
});
}

18
src/templates/base.html Normal file
View File

@@ -0,0 +1,18 @@
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
{% block title %}My Site{% endblock %}
</title>
<link rel="stylesheet" href="{% static 'css/output.css' %}">
</head>
<body>
{% include "components/topbar.html" %}
<main>
{% block content %}{% endblock %}
</main>
</body>
</html>

View File

@@ -0,0 +1,28 @@
{% load static %}
<div class="relative w-full overflow-hidden">
<div id="{{ carousel_id }}" class="flex w-full">
{% for image in carousel_images %}
<div class="w-full flex-shrink-0">
<img src="{{ image }}" class="w-full object-cover">
</div>
{% endfor %}
</div>
{% if carousel_images|length > 1 %}
<button onclick="{{ carousel_id }}_prev()"
class="absolute left-2 top-1/2 -translate-y-1/2 bg-black/50 text-white px-3 py-1 rounded-full">
&#8592;
</button>
<button onclick="{{ carousel_id }}_next()"
class="absolute right-2 top-1/2 -translate-y-1/2 bg-black/50 text-white px-3 py-1 rounded-full">
&#8594;
</button>
<div class="absolute bottom-2 w-full flex justify-center gap-2">
{% for image in carousel_images %}
<span class="{{ carousel_id }}_dot w-2 h-2 rounded-full bg-white opacity-50 cursor-pointer"
onclick="{{ carousel_id }}_goTo({{ forloop.counter0 }})"></span>
{% endfor %}
</div>
{% endif %}
</div>
<script src="{% static 'js/carousel.js' %}"></script>
<script>initCarousel('{{ carousel_id }}');</script>

View File

@@ -0,0 +1,4 @@
<nav>
<a href="{% url 'core:index' %}">Home</a>
<!-- rest of your topbar -->
</nav>

View File

@@ -21,10 +21,11 @@ from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path("", include("core.urls")),
path("polls/", include("polls.urls")),
path("admin/doc/", include("django.contrib.admindocs.urls")),
path("admin/", admin.site.urls),
]
if os.getenv("DJANGO_RELOAD", "False") == "True":
if os.getenv("DJANGO_RELOAD", "false") == "true":
urlpatterns.append(path("__reload__/", include("django_browser_reload.urls")))