Created homepage

This commit is contained in:
Kristofers Solo 2022-08-06 15:23:04 +03:00
parent 1246524262
commit b5d3e8258e
14 changed files with 258 additions and 5 deletions

View File

@ -41,6 +41,7 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'main',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
@ -58,7 +59,7 @@ ROOT_URLCONF = 'kristofersxyz.urls'
TEMPLATES = [ TEMPLATES = [
{ {
'BACKEND': 'django.template.backends.django.DjangoTemplates', 'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [], 'DIRS': ['templates'],
'APP_DIRS': True, 'APP_DIRS': True,
'OPTIONS': { 'OPTIONS': {
'context_processors': [ 'context_processors': [
@ -109,7 +110,7 @@ AUTH_PASSWORD_VALIDATORS = [
LANGUAGE_CODE = 'en-us' LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC' TIME_ZONE = 'Europe/Riga'
USE_I18N = True USE_I18N = True
@ -119,8 +120,12 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.0/howto/static-files/ # https://docs.djangoproject.com/en/4.0/howto/static-files/
STATIC_URL = 'static/' STATIC_URL = '/static/'
STATICFILES_DIRS = (
Path.joinpath(BASE_DIR, 'static'),
)
# Default primary key field type # Default primary key field type
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field # https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field

View File

@ -14,8 +14,11 @@ Including another URLconf
2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
] path('', include('main.urls')),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

0
main/__init__.py Normal file
View File

3
main/admin.py Normal file
View File

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

6
main/apps.py Normal file
View File

@ -0,0 +1,6 @@
from django.apps import AppConfig
class MainConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'main'

View File

3
main/models.py Normal file
View File

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

3
main/tests.py Normal file
View File

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

6
main/urls.py Normal file
View File

@ -0,0 +1,6 @@
from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='home'),
]

6
main/views.py Normal file
View File

@ -0,0 +1,6 @@
from django.shortcuts import render
def index(request):
"""Homepage"""
return render(request, 'main/index.html', {'title': 'Homepage'})

4
requirements.txt Normal file
View File

@ -0,0 +1,4 @@
asgiref==3.5.2
Django==4.1
python-dotenv==0.20.0
sqlparse==0.4.2

162
static/css/layout.css Normal file
View File

@ -0,0 +1,162 @@
html,
body,
div,
span,
applet,
object,
iframe,
h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre,
a,
abbr,
acronym,
address,
big,
cite,
code,
del,
dfn,
em,
img,
ins,
kbd,
q,
s,
samp,
small,
strike,
strong,
sub,
sup,
tt,
var,
b,
u,
i,
center,
dl,
dt,
dd,
ol,
ul,
li,
fieldset,
form,
label,
legend,
table,
caption,
tbody,
tfoot,
thead,
tr,
th,
td,
article,
aside,
canvas,
details,
embed,
figure,
figcaption,
footer,
header,
hgroup,
menu,
nav,
output,
ruby,
section,
summary,
time,
mark,
audio,
video {
margin: 0;
padding: 0;
border: 0;
vertical-align: baseline;
}
html,
body {
font-family: 'Roboto', sans-serif;
background: #f2f2f2;
}
main {
min-height: 100%;
}
/* HEADER */
header ul {
list-style-type: none;
overflow: hidden;
background-color: #333333;
position: sticky;
position: -webkit-sticky;
top: 0;
text-align: center;
z-index: 100;
font-weight: bold;
width: 100%;
}
.material-icons {
position: relative;
top: 4px;
font-size: 25px;
}
li {
font-size: 18px;
float: left;
display: inline-block;
width: 20%;
}
li a {
display: inline-block;
color: #cccccc;
padding: 14px 16px;
text-decoration: none;
transition: transform 0.7s ease;
}
li a:hover {
text-decoration: none;
color: #fff;
transform: scale(1.05);
}
/* FOOTER */
.page-container {
position: relative;
min-height: 100vh;
}
.content-wrap {
padding-bottom: 2.5rem;
}
footer {
position: absolute;
bottom: 0;
width: 100%;
height: auto;
background-color: #333333;
color: #666666;
flex-wrap: wrap;
display: flex;
justify-content: space-around;
padding: 8px 0;
}

44
templates/layout.html Normal file
View File

@ -0,0 +1,44 @@
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0" />
<title>{% block title %}{% endblock %}</title>
<link rel="stylesheet" href="{% static 'css/layout.css' %}" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
</head>
<body>
<div class="page-container">
<div class="content-wrap">
<header>
<div>
<ul>
<li><a href="{% url 'home' %}"><span class="material-icons">home</span>Home</a></li>
<!-- <li><a href=""><span class="material-icons"></span></a></li> -->
<!-- <li><a href=""><span class="material-icons"></span></a></li> -->
</ul>
</div>
</header>
<main>{% block content %}{% endblock %}</main>
<footer>
<p>
Copyright &copy
<script>
document.write(new Date().getFullYear());
</script>
Kristofers Solo
</p>
</footer>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,8 @@
{% extends 'layout.html' %}
{% block title %} {{ title }} {% endblock %}
{% block content %}
<div>
<h1>Lorem ipsum dolor sit amet, qui minim labore adipisicing minim sint cillum sint consectetur cupidatat.</h1>
<p>Lorem ipsum dolor sit amet, officia excepteur ex fugiat reprehenderit enim labore culpa sint ad nisi Lorem pariatur mollit ex esse exercitation amet. Nisi anim cupidatat excepteur officia. Reprehenderit nostrud nostrud ipsum Lorem est aliquip amet voluptate voluptate dolor minim nulla est proident. Nostrud officia pariatur ut officia. Sit irure elit esse ea nulla sunt ex occaecat reprehenderit commodo officia dolor Lorem duis laboris cupidatat officia voluptate. Culpa proident adipisicing id nulla nisi laboris ex in Lorem sunt duis officia eiusmod. Aliqua reprehenderit commodo ex non excepteur duis sunt velit enim. Voluptate laboris sint cupidatat ullamco ut ea consectetur et est culpa et culpa duis.</p>
</div>
{% endblock %}