- Make css clean
This commit is contained in:
madegryc pc
2024-08-13 14:50:52 +02:00
13 changed files with 311 additions and 22 deletions

View File

@ -2,9 +2,8 @@ FROM debian:bullseye
RUN apt update && apt upgrade -y
RUN apt install -y python
RUN apt install -y python3-pip
RUN pip3 install django
RUN apt install -y python3 python3-pip postgresql-client
RUN pip3 install django psycopg
RUN mkdir -p /var/www/djangoserver/
@ -16,4 +15,5 @@ RUN chown -R www-data:www-data /var/www/djangoserver/
WORKDIR /var/www/djangoserver
STOPSIGNAL SIGKILL
ENTRYPOINT [ "python", "/var/www/djangoserver/server/main.py" ]
#ENTRYPOINT [ "python3", "/var/www/djangoserver/server/manage.py","runserver" ]
ENTRYPOINT ["sleep","inf"]

View File

@ -1,5 +0,0 @@
import time
while True:
print("Update")
time.sleep(20)

View File

@ -0,0 +1,22 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

View File

@ -0,0 +1,16 @@
"""
ASGI config for server project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
application = get_asgi_application()

View File

@ -0,0 +1,127 @@
"""
Django settings for server project.
Generated by 'django-admin startproject' using Django 4.2.15.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/4.2/ref/settings/
"""
from pathlib import Path
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-vgcqdf^%(+@t*+cof@755e#q9p)myir%z2s*e*ea*v^i(4pta9'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'server.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'server.wsgi.application'
# Database
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
DATABASES = {
"default": {
"ENGINE": "django.db.backends.postgresql",
"HOST":"postgresql",
"PORT":5432,
"NAME":"patate_douce",
"USER":"tmlp",
"PASSWORD":"password"
}
}
# Password validation
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/4.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/
STATIC_URL = 'static/'
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

View File

@ -0,0 +1,22 @@
"""
URL configuration for server project.
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/4.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
urlpatterns = [
path('admin/', admin.site.urls),
]

View File

@ -0,0 +1,16 @@
"""
WSGI config for server project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'server.settings')
application = get_wsgi_application()

View File

@ -1,4 +1,4 @@
FROM nginx:bullseye
FROM nginx:latest
RUN mkdir -p /etc/nginx/ssl
RUN apt install -y openssl

View File

@ -3,16 +3,17 @@
/* ::: :::::::: */
/* createConnectDiv.js :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: marvin <marvin@student.42.fr> +#+ +:+ +#+ */
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/07 18:14:53 by edbernar #+# #+# */
/* Updated: 2024/08/10 17:00:39 by marvin ### ########.fr */
/* Updated: 2024/08/13 00:21:02 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
import { userMeInfo, waitForLogin } from "../typeResponse/typeLogin.js";
import { createNotification as CN } from "../notification/main.js";
import { sendRequest } from "../websocket.js";
import { showLoginDiv, showMenu } from "./main.js";
/*
Todo (Eddy) :
@ -23,9 +24,10 @@ import { sendRequest } from "../websocket.js";
- Empecher les requetes de connexion si un champ est vide
- Ajouter un message d'erreur si le mail est invalide
- Connexion par 42
*/
let url42 = "https://api.intra.42.fr/oauth/authorize?client_id=u-s4t2ud-d9d6d46bd0be36dc13718981df4bfcf37e574ea364a07fcb5c39658be0f5706c&redirect_uri=http%3A%2F%2F127.0.0.1%3A5500%2Fsite%2F&response_type=code";
function createConnectDiv(divLogin)
{
const form = document.createElement("form");
@ -92,7 +94,7 @@ function createConnectDiv(divLogin)
});
buttonConnect42.addEventListener('click', (e) => {
e.preventDefault();
window.location.replace("https://api.intra.42.fr/oauth/authorize?client_id=u-s4t2ud-d9d6d46bd0be36dc13718981df4bfcf37e574ea364a07fcb5c39658be0f5706c&redirect_uri=http%3A%2F%2F127.0.0.1%3A5500%2Fsite%2F&response_type=code");
window.location.replace(url42);
});
return (divConnect);
}
@ -136,6 +138,8 @@ function createButton(inputLogin, inputPass)
document.getElementById("loginDiv").remove();
document.getElementById("globalBg").remove();
document.cookie = "token={" + token + "}; path=/; Secure; SameSite=Strict; max-age=3600";
document.getElementById('loginButton').removeEventListener('click', showLoginDiv);
document.getElementById('loginButton').addEventListener('click', showMenu);
});
}).catch((err) => {
CN.new("Error", "An error occured while trying to connect", CN.defaultIcon.error);

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/07 17:40:15 by edbernar #+# #+# */
/* Updated: 2024/08/10 18:40:40 by edbernar ### ########.fr */
/* Updated: 2024/08/13 00:01:42 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -29,7 +29,10 @@ function login()
document.cookie = "token={" + token + "}; path=/; Secure; SameSite=Strict; max-age=3600";
}
if (userMeInfo.id !== -1)
{
loginButton.replaceChild(nodeText, pLoginButton);
loginButton.addEventListener('click', showMenu);
}
else
loginButton.addEventListener('click', showLoginDiv);
});
@ -47,5 +50,47 @@ function showLoginDiv()
document.body.appendChild(divLogin);
}
function showMenu()
{
const loginButton = document.getElementById('loginButton');
const divMenu = document.createElement("div");
const ul = document.createElement("ul");
const li1 = document.createElement("li");
const li2 = document.createElement("li");
let already_activated = false;
export { login };
divMenu.setAttribute("id", "menuDiv");
li1.innerHTML = "Profile";
li2.innerHTML = "Logout";
li1.addEventListener('click', (e) => {
console.log("profile");
});
li2.addEventListener('click', (e) => {
document.cookie = "token=; path=/; Secure; SameSite=Strict; max-age=0";
window.location.href = "/";
location.reload();
});
ul.appendChild(li1);
ul.appendChild(li2);
divMenu.appendChild(ul);
divMenu.style.position = "absolute";
divMenu.style.width = loginButton.offsetWidth + "px";
divMenu.style.top = loginButton.offsetTop + loginButton.offsetHeight + "px";
divMenu.style.left = loginButton.offsetLeft + "px";
document.body.appendChild(divMenu);
loginButton.removeEventListener('click', showMenu);
loginButton.addEventListener('click', () => {
if (!already_activated)
{
setTimeout(() => {
document.getElementById("menuDiv").remove();
loginButton.addEventListener('click', showMenu);
already_activated = true;
}, 199);
document.getElementById("menuDiv").style.animation = "animHideMenuDiv 0.21s";
}
});
}
export { login, showLoginDiv, showMenu };

View File

@ -3,13 +3,38 @@
/* ::: :::::::: */
/* home.css :+: :+: :+: */
/* +:+ +:+ +:+ */
<<<<<<< HEAD
/* By: marvin <marvin@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/07 12:00:55 by edbernar #+# #+# */
/* Updated: 2024/08/13 13:11:42 by marvin ### ########.fr */
=======
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/08/07 12:00:55 by edbernar #+# #+# */
/* Updated: 2024/08/13 00:03:27 by edbernar ### ########.fr */
>>>>>>> 298711bf505242792e7b73b7a42271903a979d1f
/* */
/* ************************************************************************** */
@keyframes animShowMenuDiv {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
@keyframes animHideMenuDiv {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
* {
margin: 0;
padding: 0;
@ -100,7 +125,29 @@ body {
cursor: pointer;
}
<<<<<<< HEAD
.homeSection{
color: white;
min-height: 100svh;
=======
#menuDiv {
display: flex;
flex-direction: column;
align-items: right;
font-family: "Poppins", sans-serif;
background-color: #ffffff;
animation: animShowMenuDiv 0.5s;
}
#menuDiv li {
list-style-type: none;
text-align: center;
font-size: 16px;
padding: 10px;
cursor: pointer;
}
#menuDiv li:hover {
background-color: #f0f0f0;
>>>>>>> 298711bf505242792e7b73b7a42271903a979d1f
}

View File

@ -6,7 +6,7 @@
/* By: edbernar <edbernar@student.42angouleme. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/31 22:17:24 by edbernar #+# #+# */
/* Updated: 2024/08/10 16:05:26 by edbernar ### ########.fr */
/* Updated: 2024/08/13 00:12:26 by edbernar ### ########.fr */
/* */
/* ************************************************************************** */
@ -56,14 +56,9 @@ socket.onopen = () => {
status = 1;
console.log('Connected');
if (token)
{
console.log("token :" + token);
sendRequest("login", {type: "byToken", token: token});
}
else
{
connectedWith42Func();
}
};
socket.onmessage = (event) => {