Compare commits
No commits in common. "9947ea37e2069b2297beecb6c1814f127b244e5b" and "b95bed88946a267f4a6b7bcfe33c7b6ae8ee4bad" have entirely different histories.
9947ea37e2
...
b95bed8894
@ -20,11 +20,6 @@ source .env/bin/activate
|
|||||||
``` bash
|
``` bash
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
- Setup database
|
|
||||||
```
|
|
||||||
python manage.py runserver makemigrations profiles
|
|
||||||
python manage.py migrate profiles
|
|
||||||
```
|
|
||||||
- Start the developpement server
|
- Start the developpement server
|
||||||
```
|
```
|
||||||
python manage.py runserver 0.0.0.0:8000
|
python manage.py runserver 0.0.0.0:8000
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
|
||||||
from .views import register, login, logout, delete, change_password, logged
|
from .views import register, login, logout, delete, change_password
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("register", register.RegisterView.as_view(), name="register"),
|
path("register", register.RegisterView.as_view(), name="register"),
|
||||||
path("login", login.LoginView.as_view(), name="login"),
|
path("login", login.LoginView.as_view(), name="login"),
|
||||||
path("logout", logout.LogoutView.as_view(), name="logout"),
|
path("logout", logout.LogoutView.as_view(), name="logout"),
|
||||||
path("logged", logged.LoggedView.as_view(), name="logged"),
|
|
||||||
path("delete", delete.DeleteView.as_view(), name="delete"),
|
path("delete", delete.DeleteView.as_view(), name="delete"),
|
||||||
path("change_password", change_password.ChangePasswordView.as_view(), name="change_password")
|
path("change_password", change_password.ChangePasswordView.as_view(), name="change_password")
|
||||||
|
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
from rest_framework.views import APIView
|
|
||||||
from rest_framework.response import Response
|
|
||||||
from rest_framework import permissions, status
|
|
||||||
from django.http import HttpRequest
|
|
||||||
from django.contrib.auth import login
|
|
||||||
from rest_framework.authentication import SessionAuthentication
|
|
||||||
|
|
||||||
from ..serializers.login import LoginSerializer
|
|
||||||
|
|
||||||
class LoggedView(APIView):
|
|
||||||
|
|
||||||
permission_classes = (permissions.AllowAny,)
|
|
||||||
authentication_classes = (SessionAuthentication,)
|
|
||||||
|
|
||||||
def get(self, request: HttpRequest):
|
|
||||||
return Response(str(request.user.is_authenticated), status=status.HTTP_200_OK)
|
|
@ -8,6 +8,6 @@ from rest_framework.authentication import SessionAuthentication
|
|||||||
class LogoutView(APIView):
|
class LogoutView(APIView):
|
||||||
permission_classes = (permissions.IsAuthenticated,)
|
permission_classes = (permissions.IsAuthenticated,)
|
||||||
authentication_classes = (SessionAuthentication,)
|
authentication_classes = (SessionAuthentication,)
|
||||||
def get(self, request: HttpRequest):
|
def post(self, request: HttpRequest):
|
||||||
logout(request)
|
logout(request)
|
||||||
return Response("user unlogged", status=status.HTTP_200_OK)
|
return Response("user unlogged", status=status.HTTP_200_OK)
|
@ -1,3 +0,0 @@
|
|||||||
from django.contrib import admin
|
|
||||||
|
|
||||||
# Register your models here.
|
|
@ -1,6 +0,0 @@
|
|||||||
from django.apps import AppConfig
|
|
||||||
|
|
||||||
|
|
||||||
class ChatConfig(AppConfig):
|
|
||||||
default_auto_field = 'django.db.models.BigAutoField'
|
|
||||||
name = 'chat'
|
|
@ -1,36 +0,0 @@
|
|||||||
import json
|
|
||||||
from channels.generic.websocket import WebsocketConsumer
|
|
||||||
from asgiref.sync import async_to_sync
|
|
||||||
|
|
||||||
class ChatConsumer(WebsocketConsumer):
|
|
||||||
def connect(self):
|
|
||||||
self.room_group_name = 'test'
|
|
||||||
|
|
||||||
async_to_sync(self.channel_layer.group_add)(
|
|
||||||
self.room_group_name,
|
|
||||||
self.channel_name
|
|
||||||
)
|
|
||||||
|
|
||||||
self.accept()
|
|
||||||
|
|
||||||
|
|
||||||
def receive(self, text_data):
|
|
||||||
text_data_json = json.loads(text_data)
|
|
||||||
message = text_data_json['message']
|
|
||||||
|
|
||||||
async_to_sync(self.channel_layer.group_send)(
|
|
||||||
self.room_group_name,
|
|
||||||
{
|
|
||||||
'type':'chat_message',
|
|
||||||
'message':message
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
def chat_message(self, event):
|
|
||||||
message = event['message']
|
|
||||||
|
|
||||||
self.send(text_data=json.dumps({
|
|
||||||
'type':'chat',
|
|
||||||
'username':self.scope["user"].username,
|
|
||||||
'message':message
|
|
||||||
}))
|
|
@ -1,3 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
|
|
||||||
# Create your models here.
|
|
@ -1,6 +0,0 @@
|
|||||||
from django.urls import re_path
|
|
||||||
from . import consumers
|
|
||||||
|
|
||||||
websocket_urlpatterns = [
|
|
||||||
re_path(r'ws/socket-server/', consumers.ChatConsumer.as_asgi())
|
|
||||||
]
|
|
@ -1,3 +0,0 @@
|
|||||||
from django.test import TestCase
|
|
||||||
|
|
||||||
# Create your tests here.
|
|
@ -1,3 +0,0 @@
|
|||||||
from django.shortcuts import render
|
|
||||||
|
|
||||||
# Create your views here.
|
|
@ -1,12 +0,0 @@
|
|||||||
#app .form {
|
|
||||||
background-color: red;
|
|
||||||
width: 300px;
|
|
||||||
height: 300px;
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(1, 1fr);
|
|
||||||
grid-gap: 10px;
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
margin-top: 90px;
|
|
||||||
border: 15px black solid;
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
#app .form {
|
|
||||||
background-color: red;
|
|
||||||
width: 300px;
|
|
||||||
height: 300px;
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(1, 1fr);
|
|
||||||
grid-gap: 10px;
|
|
||||||
margin-left: auto;
|
|
||||||
margin-right: auto;
|
|
||||||
margin-top: 90px;
|
|
||||||
border: 15px black solid;
|
|
||||||
}
|
|
@ -1,9 +1,37 @@
|
|||||||
body {
|
body {
|
||||||
margin: 10;
|
--nav-width: 200px;
|
||||||
|
margin: 0 0 0 var(--nav-width);
|
||||||
font-family: 'Quicksand', sans-serif;
|
font-family: 'Quicksand', sans-serif;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.nav {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: var(--nav-width);
|
||||||
|
height: 100vh;
|
||||||
|
background: #222222;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav__link {
|
||||||
|
display: block;
|
||||||
|
padding: 12px 18px;
|
||||||
|
text-decoration: none;
|
||||||
|
color: #eeeeee;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nav__link:hover {
|
||||||
|
background: rgba(255, 255, 255, 0.05);
|
||||||
|
}
|
||||||
|
|
||||||
|
#app {
|
||||||
|
margin: 2em;
|
||||||
|
line-height: 1.5;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: #009579;
|
color: #009579;
|
||||||
}
|
}
|
@ -1,15 +0,0 @@
|
|||||||
class Accounts
|
|
||||||
{
|
|
||||||
constructor (client)
|
|
||||||
{
|
|
||||||
this.client = client;
|
|
||||||
}
|
|
||||||
|
|
||||||
async create(username, password)
|
|
||||||
{
|
|
||||||
let response = await this.client._post("/api/accounts/register", {username: username, password: password});
|
|
||||||
return response
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export { Accounts }
|
|
@ -1,65 +0,0 @@
|
|||||||
import { Accounts } from "./accounts.js";
|
|
||||||
|
|
||||||
class Client
|
|
||||||
{
|
|
||||||
constructor(url)
|
|
||||||
{
|
|
||||||
this._url = url;
|
|
||||||
this.accounts = new Accounts(this);
|
|
||||||
this._logged = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
async isAuthentificate()
|
|
||||||
{
|
|
||||||
if (this._logged == undefined)
|
|
||||||
this.logged = await this._test_logged();
|
|
||||||
return this.logged;
|
|
||||||
}
|
|
||||||
|
|
||||||
async _get(uri)
|
|
||||||
{
|
|
||||||
let response = await fetch(this._url + uri, {
|
|
||||||
method: "GET",
|
|
||||||
});
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
async _post(uri, data)
|
|
||||||
{
|
|
||||||
let response = await fetch(this._url + uri, {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
},
|
|
||||||
body: JSON.stringify(data),
|
|
||||||
});
|
|
||||||
return response;
|
|
||||||
}
|
|
||||||
|
|
||||||
async login(username, password)
|
|
||||||
{
|
|
||||||
let response = await this._post("/api/accounts/login", {username: username, password: password})
|
|
||||||
let data = await response.json();
|
|
||||||
if (data == "user connected")
|
|
||||||
{
|
|
||||||
this.logged = true;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
async logout()
|
|
||||||
{
|
|
||||||
await this._get("/api/accounts/logout");
|
|
||||||
this.logged = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
async _test_logged()
|
|
||||||
{
|
|
||||||
let response = await this._get("/api/accounts/logged");
|
|
||||||
let data = await response.json();
|
|
||||||
return data === "True";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export {Client}
|
|
@ -1,18 +1,7 @@
|
|||||||
import LoginView from "./views/accounts/LoginView.js";
|
|
||||||
import Dashboard from "./views/Dashboard.js";
|
import Dashboard from "./views/Dashboard.js";
|
||||||
import Posts from "./views/Posts.js";
|
import Posts from "./views/Posts.js";
|
||||||
import PostView from "./views/PostView.js";
|
import PostView from "./views/PostView.js";
|
||||||
import Settings from "./views/Settings.js";
|
import Settings from "./views/Settings.js";
|
||||||
import Chat from "./views/Chat.js";
|
|
||||||
import HomeView from "./views/HomeView.js";
|
|
||||||
import RegisterView from "./views/accounts/RegisterView.js";
|
|
||||||
import LogoutView from "./views/accounts/LogoutView.js";
|
|
||||||
|
|
||||||
import { Client } from "./api/client.js";
|
|
||||||
|
|
||||||
let client = new Client(location.protocol + "//" + location.host)
|
|
||||||
|
|
||||||
let lastView = undefined
|
|
||||||
|
|
||||||
const pathToRegex = path => new RegExp("^" + path.replace(/\//g, "\\/").replace(/:\w+/g, "(.+)") + "$");
|
const pathToRegex = path => new RegExp("^" + path.replace(/\//g, "\\/").replace(/:\w+/g, "(.+)") + "$");
|
||||||
|
|
||||||
@ -25,29 +14,24 @@ const getParams = match => {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
const navigateTo = async (uri) => {
|
const navigateTo = url => {
|
||||||
if (await router(uri) === 0)
|
history.pushState(null, null, url);
|
||||||
history.pushState(null, null, uri);
|
router();
|
||||||
};
|
};
|
||||||
|
|
||||||
const router = async (uri = "") => {
|
const router = async () => {
|
||||||
const routes = [
|
const routes = [
|
||||||
{ path: "/", view: Dashboard },
|
{ path: "/", view: Dashboard },
|
||||||
{ path: "/posts", view: Posts },
|
{ path: "/posts", view: Posts },
|
||||||
{ path: "/posts/:id", view: PostView },
|
{ path: "/posts/:id", view: PostView },
|
||||||
{ path: "/settings", view: Settings },
|
{ path: "/settings", view: Settings }
|
||||||
{ path: "/login", view: LoginView },
|
|
||||||
{ path: "/logout", view: LogoutView },
|
|
||||||
{ path: "/register", view: RegisterView },
|
|
||||||
{ path: "/chat", view: Chat },
|
|
||||||
{ path: "/home", view: HomeView },
|
|
||||||
];
|
];
|
||||||
|
|
||||||
// Test each route for potential match
|
// Test each route for potential match
|
||||||
const potentialMatches = routes.map(route => {
|
const potentialMatches = routes.map(route => {
|
||||||
return {
|
return {
|
||||||
route: route,
|
route: route,
|
||||||
result: uri.match(pathToRegex(route.path))
|
result: location.pathname.match(pathToRegex(route.path))
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -56,24 +40,13 @@ const router = async (uri = "") => {
|
|||||||
if (!match) {
|
if (!match) {
|
||||||
match = {
|
match = {
|
||||||
route: routes[0],
|
route: routes[0],
|
||||||
result: [uri]
|
result: [location.pathname]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastView !== undefined)
|
|
||||||
await lastView.leavePage();
|
|
||||||
|
|
||||||
const view = new match.route.view(getParams(match));
|
const view = new match.route.view(getParams(match));
|
||||||
lastView = view;
|
|
||||||
|
|
||||||
let content = await view.getHtml();
|
document.querySelector("#app").innerHTML = await view.getHtml();
|
||||||
if (content == null)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
document.querySelector("#app").innerHTML = content
|
|
||||||
|
|
||||||
await view.postInit();
|
|
||||||
return 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
window.addEventListener("popstate", router);
|
window.addEventListener("popstate", router);
|
||||||
@ -82,10 +55,9 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||||||
document.body.addEventListener("click", e => {
|
document.body.addEventListener("click", e => {
|
||||||
if (e.target.matches("[data-link]")) {
|
if (e.target.matches("[data-link]")) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
navigateTo(e.target.href.slice(location.origin.length));
|
navigateTo(e.target.href);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
router(location.pathname);
|
|
||||||
});
|
|
||||||
|
|
||||||
export { client, navigateTo }
|
router();
|
||||||
|
});
|
@ -3,12 +3,6 @@ export default class {
|
|||||||
this.params = params;
|
this.params = params;
|
||||||
}
|
}
|
||||||
|
|
||||||
async postInit() {
|
|
||||||
}
|
|
||||||
|
|
||||||
async leavePage() {
|
|
||||||
}
|
|
||||||
|
|
||||||
setTitle(title) {
|
setTitle(title) {
|
||||||
document.title = title;
|
document.title = title;
|
||||||
}
|
}
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
import AbstractView from "./AbstractView.js";
|
|
||||||
|
|
||||||
export default class extends AbstractView {
|
|
||||||
constructor(params) {
|
|
||||||
super(params);
|
|
||||||
this.setTitle("Chat");
|
|
||||||
|
|
||||||
let url = `ws://${window.location.host}/ws/socket-server/`
|
|
||||||
|
|
||||||
this.chatSocket = new WebSocket(url)
|
|
||||||
this.chatSocket.onmessage = function(e){
|
|
||||||
let data = JSON.parse(e.data)
|
|
||||||
console.log('Data:', data)
|
|
||||||
if (data.type === 'chat') {
|
|
||||||
let messages = document.getElementById('messages')
|
|
||||||
|
|
||||||
let username = data.username === null || data.username.length <= 0 ? "NoName" : data.username;
|
|
||||||
messages.insertAdjacentHTML('beforeend', `
|
|
||||||
<div><p>${username}: ${data.message}</p></div>
|
|
||||||
`)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async postInit() {
|
|
||||||
let form = document.getElementById('form')
|
|
||||||
form.addEventListener('submit', (e)=> {
|
|
||||||
e.preventDefault()
|
|
||||||
let message = e.target.message.value
|
|
||||||
this.chatSocket.send(JSON.stringify({
|
|
||||||
'message':message
|
|
||||||
}))
|
|
||||||
form.reset()
|
|
||||||
})
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
async leavePage() {
|
|
||||||
this.chatSocket.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
async getHtml() {
|
|
||||||
return `
|
|
||||||
<h1>Chat</h1>
|
|
||||||
|
|
||||||
<form id="form">
|
|
||||||
<input type="text" name="message" />
|
|
||||||
</form>
|
|
||||||
|
|
||||||
<div id="messages">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
import AbstractView from "./AbstractView.js";
|
|
||||||
import { client, navigateTo } from "../index.js";
|
|
||||||
|
|
||||||
export default class extends AbstractView {
|
|
||||||
constructor(params) {
|
|
||||||
super(params);
|
|
||||||
this.setTitle("Home");
|
|
||||||
}
|
|
||||||
|
|
||||||
async getHtml() {
|
|
||||||
if (await client.isAuthentificate() === false)
|
|
||||||
{
|
|
||||||
navigateTo("/login");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return `
|
|
||||||
<h1>HOME</h1>
|
|
||||||
<a href="/logout" class="nav__link" data-link>Logout</a>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,61 +0,0 @@
|
|||||||
import AbstractView from "../AbstractView.js";
|
|
||||||
import { client, navigateTo } from "../../index.js";
|
|
||||||
|
|
||||||
async function login()
|
|
||||||
{
|
|
||||||
let username = document.getElementById("username").value;
|
|
||||||
let password = document.getElementById("password").value;
|
|
||||||
|
|
||||||
let response_data = await client.login(username, password);
|
|
||||||
|
|
||||||
if (response_data == null)
|
|
||||||
{
|
|
||||||
navigateTo("/home");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
["username", "user", "password"].forEach(error_field => {
|
|
||||||
let error_display = document.getElementById(`error_${error_field}`);
|
|
||||||
if (error_display != null)
|
|
||||||
error_display.innerHTML = "";
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.keys(response_data).forEach(error_field => {
|
|
||||||
let error_display = document.getElementById(`error_${error_field}`);
|
|
||||||
if (error_display != null)
|
|
||||||
error_display.innerHTML = response_data[error_field];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class extends AbstractView {
|
|
||||||
constructor(params) {
|
|
||||||
super(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
async postInit()
|
|
||||||
{
|
|
||||||
this.setTitle("Login");
|
|
||||||
document.getElementById("button").onclick = login;
|
|
||||||
}
|
|
||||||
|
|
||||||
async getHtml() {
|
|
||||||
if (await client.isAuthentificate())
|
|
||||||
{
|
|
||||||
navigateTo("/home")
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return `
|
|
||||||
<div class=form>
|
|
||||||
<label>Login</label>
|
|
||||||
<link rel="stylesheet" href="static/css/accounts/login.css">
|
|
||||||
<input type="text" id="username" placeholder="username">
|
|
||||||
<span id="error_username"></span>
|
|
||||||
<input type="password" id="password" placeholder="password">
|
|
||||||
<span id="error_password"></span>
|
|
||||||
<input type="button" value="login" id="button">
|
|
||||||
<span id="error_user"></span>
|
|
||||||
<a href="/register" class="nav__link" data-link>Register</a>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
import { client, navigateTo } from "../../index.js";
|
|
||||||
import AbstractView from "../AbstractView.js";
|
|
||||||
|
|
||||||
export default class extends AbstractView
|
|
||||||
{
|
|
||||||
constructor(params) {
|
|
||||||
super(params);
|
|
||||||
this.setTitle("Logout");
|
|
||||||
if (client.logged)
|
|
||||||
client.logout();
|
|
||||||
navigateTo("/login")
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
import AbstractView from "../AbstractView.js";
|
|
||||||
import { client, navigateTo } from "../../index.js";
|
|
||||||
|
|
||||||
async function register()
|
|
||||||
{
|
|
||||||
let username = document.getElementById("username").value;
|
|
||||||
let password = document.getElementById("password").value;
|
|
||||||
|
|
||||||
let response = await client.accounts.create(username, password);
|
|
||||||
let response_data = await response.json();
|
|
||||||
|
|
||||||
["username", "user", "password"].forEach(error_field => {
|
|
||||||
let error_display = document.getElementById(`error_${error_field}`);
|
|
||||||
if (error_display != null)
|
|
||||||
error_display.innerHTML = "";
|
|
||||||
});
|
|
||||||
|
|
||||||
Object.keys(response_data).forEach(error_field => {
|
|
||||||
let error_display = document.getElementById(`error_${error_field}`);
|
|
||||||
if (error_display != null)
|
|
||||||
error_display.innerHTML = response_data[error_field];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export default class extends AbstractView {
|
|
||||||
constructor(params) {
|
|
||||||
super(params);
|
|
||||||
}
|
|
||||||
|
|
||||||
async postInit()
|
|
||||||
{
|
|
||||||
this.setTitle("register");
|
|
||||||
document.getElementById("button").onclick = register;
|
|
||||||
}
|
|
||||||
|
|
||||||
async getHtml() {
|
|
||||||
if (await client.isAuthentificate())
|
|
||||||
{
|
|
||||||
navigateTo("/home")
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
return `
|
|
||||||
<div class=form>
|
|
||||||
<label>Register</label>
|
|
||||||
<link rel="stylesheet" href="static/css/accounts/register.css">
|
|
||||||
<input type="text" id="username" placeholder="username">
|
|
||||||
<span id="error_username"></span>
|
|
||||||
<input type="password" id="password" placeholder="password">
|
|
||||||
<span id="error_password"></span>
|
|
||||||
<input type="button" value="register" id="button">
|
|
||||||
<span id="error_user"></span>
|
|
||||||
<a href="/login" class="nav__link" data-link>Login</a>
|
|
||||||
</div>
|
|
||||||
`;
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,9 +12,6 @@
|
|||||||
<a href="/" class="nav__link" data-link>Dashboard</a>
|
<a href="/" class="nav__link" data-link>Dashboard</a>
|
||||||
<a href="/posts" class="nav__link" data-link>Posts</a>
|
<a href="/posts" class="nav__link" data-link>Posts</a>
|
||||||
<a href="/settings" class="nav__link" data-link>Settings</a>
|
<a href="/settings" class="nav__link" data-link>Settings</a>
|
||||||
<a href="/login" class="nav__link" data-link>Login</a>
|
|
||||||
<a href="/register" class="nav__link" data-link>Register</a>
|
|
||||||
<a href="/chat" class="nav__link" data-link>Chat</a>
|
|
||||||
</nav>
|
</nav>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script type="module" src="{% static 'js/index.js' %}"></script>
|
<script type="module" src="{% static 'js/index.js' %}"></script>
|
||||||
|
@ -2,6 +2,5 @@ from django.shortcuts import render
|
|||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
|
||||||
|
|
||||||
def index_view(req):
|
def index_view(req):
|
||||||
return render(req, 'index.html');
|
return render(req, 'index.html');
|
||||||
|
@ -6,5 +6,4 @@ djangorestframework==3.14.0
|
|||||||
install==1.3.5
|
install==1.3.5
|
||||||
pytz==2023.3.post1
|
pytz==2023.3.post1
|
||||||
sqlparse==0.4.4
|
sqlparse==0.4.4
|
||||||
channels==4.0.0
|
channels==3.0.5
|
||||||
daphne
|
|
||||||
|
@ -8,20 +8,9 @@ https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
from channels.routing import ProtocolTypeRouter, URLRouter
|
|
||||||
from channels.auth import AuthMiddlewareStack
|
|
||||||
import chat.routing
|
|
||||||
|
|
||||||
from django.core.asgi import get_asgi_application
|
from django.core.asgi import get_asgi_application
|
||||||
|
|
||||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'trancendence.settings')
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'trancendence.settings')
|
||||||
|
|
||||||
application = ProtocolTypeRouter({
|
application = get_asgi_application()
|
||||||
'http':get_asgi_application(),
|
|
||||||
'websocket':AuthMiddlewareStack(
|
|
||||||
URLRouter(
|
|
||||||
chat.routing.websocket_urlpatterns
|
|
||||||
)
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
|
@ -38,9 +38,6 @@ CORS_ORIGIN_WHITELIST = (
|
|||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'channels',
|
|
||||||
'daphne',
|
|
||||||
|
|
||||||
'accounts.apps.AccountsConfig',
|
'accounts.apps.AccountsConfig',
|
||||||
'profiles.apps.ProfilesConfig',
|
'profiles.apps.ProfilesConfig',
|
||||||
'frontend.apps.FrontendConfig',
|
'frontend.apps.FrontendConfig',
|
||||||
@ -55,14 +52,6 @@ INSTALLED_APPS = [
|
|||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
]
|
]
|
||||||
|
|
||||||
ASGI_APPLICATION = 'trancendence.asgi.application'
|
|
||||||
|
|
||||||
CHANNEL_LAYERS = {
|
|
||||||
'default' :{
|
|
||||||
'BACKEND':'channels.layers.InMemoryChannelLayer'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
'corsheaders.middleware.CorsMiddleware',
|
'corsheaders.middleware.CorsMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
|
Loading…
Reference in New Issue
Block a user