Merge branch 'master' of github.com:kristoferssolo/kristofersxyz

This commit is contained in:
Kristofers Solo 2023-01-30 13:27:35 +02:00
commit 5c05fea77b
15 changed files with 19 additions and 178 deletions

View File

@ -9,3 +9,7 @@ Install packages from `requirements.txt`.
pip install --upgrade pip -r requirements.txt
```
Start `localhost`.
```shell
./manage.py runserver
```

View File

@ -6,5 +6,4 @@ urlpatterns = [
path("", views.index, name="home"),
path("karbs", views.karbs, name="karbs"),
path("lightsaber", views.lightsaber, name="lightsaber"),
path("validation", views.validation, name="validation"),
]

View File

@ -16,7 +16,3 @@ def projects(request):
def karbs(request):
"""Karbs install script"""
return redirect("/projects/karbs")
def validation(request):
return render(request, "main/validation.html", {"title": "Validation"})

View File

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

View File

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

View File

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

View File

@ -1,21 +0,0 @@
.valid {
color: green;
}
.not-valid {
color: red;
}
#check-list li {
list-style: square;
}
#register-form {
display: grid;
place-items: center;
margin-top: 5rem;
}
#register-form > input {
margin-top: 1rem;
}

View File

@ -1,95 +0,0 @@
$(document).ready(function () {
let register_form = $("#register-form")
let username = $("#username")
let password = $("#password")
let confirm_password = $("#confirm-password")
let check_block = $("#check-block")
let valid_username = false
let valid_password = false
let valid_password_match = false
const CHECKS = {
length: "^.{10,}",
uppercase: "[A-Z]",
lowercase: "[a-z]",
numbers: "[0-9]",
symbol: "[^A-Za-z0-9]",
}
const TEXT = {
length: "10 Characters",
uppercase: "1 Uppercase Letter",
lowercase: "1 Lowercase Letter",
numbers: "1 Digit",
symbol: "1 Symbol",
}
username.change(function () {
if (username.val() === "") {
valid_username = false
} else {
valid_username = true
}
submit()
})
password.change(function () {
valid_password = true
check_block.empty()
check_block.append($("<p>").text("Password must consist of:"))
check_block.append($("<ul>", {id: "check-list"}))
for (let item in CHECKS) {
if (!new RegExp(CHECKS[item]).test(password.val())) {
$("#check-list").append(
$("<li>", {id: item, class: "not-valid"}).text(TEXT[item])
)
valid_password = false
} else {
$("#check-list").append(
$("<li>", {id: item, class: "valid"}).text(TEXT[item])
)
}
}
check_password_match()
submit()
})
confirm_password.change(function () {
check_password_match()
})
function check_password_match() {
$("#password-match").remove()
if (password.val() != confirm_password.val()) {
check_block.append(
$("<p>", {id: "password-match", class: "not-valid"}).text(
"Passwords do not match"
)
)
valid_password_match = false
} else {
valid_password_match = true
}
submit()
}
function submit() {
$("#submit-btn").remove()
if (valid_username && valid_password && valid_password_match) {
register_form.append(
$("<input>", {
type: "submit",
value: "Register",
id: "submit-btn",
class: "btn btn-primary",
})
)
} else {
$("#submit-btn").remove()
}
}
$("#submit-btn").click(function () {
$("#register-form").submit()
})
})

View File

@ -3,8 +3,8 @@
<html lang="en" data-color-mode="dark">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="icon" href="{% static 'main/img/icons/logo.svg' %}" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="{% static 'main/img/icons/logo.svg' %}">
<link href="https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&display=swap"
rel="stylesheet">
<title>
@ -12,19 +12,19 @@
</title>
<link rel="stylesheet"
type="text/css"
href="{% static 'main/css/reset.css' %}"/>
href="{% static 'main/css/reset.css' %}">
<link rel="stylesheet"
type="text/css"
href="{% static 'main/css/colors.css' %}"/>
href="{% static 'main/css/colors.css' %}">
<link rel="stylesheet"
type="text/css"
href="{% static 'main/css/navigation_button.css' %}"/>
href="{% static 'main/css/navigation_button.css' %}">
<link rel="stylesheet"
type="text/css"
href="{% static 'main/css/button.css' %}"/>
href="{% static 'main/css/button.css' %}">
<link rel="stylesheet"
type="text/css"
href="{% static 'main/css/layout.css' %}"/>
href="{% static 'main/css/layout.css' %}">
<script src="{% static 'main/js/navigation.js' %}" defer></script>
<script src="{% static 'main/js/lightmode.js' %}" defer></script>
{% block meta %}{% endblock %}

View File

@ -4,7 +4,7 @@
{% block meta %}
<link rel="stylesheet"
type="text/css"
href="{% static 'main/css/index.css' %}"/>
href="{% static 'main/css/index.css' %}">
<link href="{% static 'fontawesomefree/css/all.min.css' %}"
rel="stylesheet"
type="text/css">

View File

@ -4,7 +4,7 @@
{% block meta %}
<link rel="stylesheet"
type="text/css"
href="{% static 'main/css/lightsaber.css' %}"/>
href="{% static 'main/css/lightsaber.css' %}">
<script src="{% static 'main/js/lightsaber.js' %}" defer></script>
{% endblock %}
{% block content %}

View File

@ -1,33 +0,0 @@
{% extends "layout.html" %}
{% load static %}
{% block title %}{{ title }}{% endblock %}
{% block meta %}
<link rel="stylesheet"
type="text/css"
href="{% static 'main/css/validation.css' %}"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<script src="{% static 'main/js/validation.js' %}" defer></script>
{% endblock %}
{% block content %}
<form id="register-form" action="https://www.w3schools.com/action_page.php">
<input type="text"
id="username"
name="username"
placeholder="Username"
class="btn">
<br>
<input type="password"
id="password"
name="password"
placeholder="Password"
class="btn">
<br>
<input type="password"
id="confirm-password"
name="confirm-password"
placeholder="Repeat password"
class="btn">
<br>
<div id="check-block"></div>
</form>
{% endblock %}

View File

@ -4,7 +4,7 @@
{% block meta %}
<link rel="stylesheet"
type="text/css"
href="{% static 'main/css/markdown.css' %}"/>
href="{% static 'main/css/markdown.css' %}">
{% endblock %}
{% block content %}
<div class="block">

View File

@ -4,7 +4,7 @@
{% block meta %}
<link rel="stylesheet"
type="text/css"
href="{% static 'projects/css/projects.css' %}"/>
href="{% static 'projects/css/projects.css' %}">
<script src="{% static 'projects/js/projects.js' %}" defer></script>
{% endblock %}
{% block content %}
@ -88,18 +88,6 @@
</div>
</div>
</a>
<a class="card" href="{% url 'validation' %}">
<div class="card-content">
<div class="card-info-wrapper">
<div class="card-info-title">
<h2>Register</h2>
</div>
<div class="card-info-text">
<p>Subject to change.</p>
</div>
</div>
</div>
</a>
</div>
</div>
{% endblock %}

View File

@ -4,7 +4,7 @@
{% block meta %}
<link rel="stylesheet"
type="text/css"
href="{% static 'main/css/markdown.css' %}"/>
href="{% static 'main/css/markdown.css' %}">
{% endblock %}
{% block content %}
<div class="block">