Merge branch 'main' of hectabit.org:HectaBit/Burgernotes

This commit is contained in:
maaa 2024-02-27 20:21:41 +01:00
commit f22348aba5
12 changed files with 87 additions and 69 deletions

20
main
View File

@ -105,25 +105,40 @@ async def add_cors_headers(response):
return response
# Main page
@app.route("/index.html")
async def mainrdir():
return redirect("/", code=302)
@app.route("/")
async def main():
return await render_template("main.html")
# Web app
@app.route("/app/index.html")
async def apprdir():
return redirect("/app", code=302)
@app.route("/app")
async def webapp():
return await render_template("app.html")
# Login and signup
@app.route("/signup/index.html")
async def signuprdir():
return redirect("/signup", code=302)
@app.route("/signup")
async def signup():
return await render_template("signup.html")
@app.route("/login/index.html")
async def loginrdir():
return redirect("/login", code=302)
@app.route("/login")
async def login():
return await render_template("login.html")
# Privacy policy
@app.route("/privacy/index.html")
async def privacyrdir():
return redirect("/privacy", code=302)
@app.route("/privacy")
async def privacy():
return await render_template("privacy.html")
@ -508,7 +523,10 @@ def listusers(secretkey):
else:
return redirect("/")
@app.route("/api/logout")
@app.route("/logout/index.html")
async def logoutrdir():
return redirect("/logout", code=302)
@app.route("/logout")
async def apilogout():
return await render_template("logout.html")

View File

@ -1,4 +1,4 @@
@import url("/static/fonts/inter.css");
@import url("../fonts/inter.css");
:root {
--invertdm: 0%;
@ -170,7 +170,7 @@ body {
filter: invert(var(--invertdm));
padding-left: 17.5px;
padding-right: 17.5px;
background-image: url("/static/svg/delete.svg");
background-image: url("../static/svg/delete.svg");
background-position: center;
background-repeat: no-repeat;
background-size: 55%;

View File

@ -1,10 +1,10 @@
if (localStorage.getItem("DONOTSHARE-secretkey") !== null) {
window.location.replace("/app")
window.location.replace("../app/index.html")
document.body.innerHTML = "Redirecting..."
throw new Error();
}
if (localStorage.getItem("DONOTSHARE-password") !== null) {
window.location.replace("/app")
window.location.replace("../app/index.html")
document.body.innerHTML = "Redirecting..."
throw new Error();
}
@ -109,7 +109,7 @@ signupButton.addEventListener("click", (event) => {
return key
};
fetch("/api/login", {
fetch("https://notes.hectabit.org/api/login", {
method: "POST",
body: JSON.stringify({
username: username,
@ -118,7 +118,7 @@ signupButton.addEventListener("click", (event) => {
newpass: "null"
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
"Content-Type": "application/json; charset=UTF-8"
}
})
.then((response) => response)
@ -129,11 +129,11 @@ signupButton.addEventListener("click", (event) => {
localStorage.setItem("DONOTSHARE-secretkey", responseData["key"])
localStorage.setItem("DONOTSHARE-password", await hashwasm.sha512(password))
window.location.href = "/app"
window.location.href = "../app/index.html"
}
else if (response.status == 401) {
console.log("Trying oldhash")
fetch("/api/login", {
fetch("https://notes.hectabit.org/api/login", {
method: "POST",
body: JSON.stringify({
username: username,
@ -142,7 +142,7 @@ signupButton.addEventListener("click", (event) => {
newpass: await hashpass(password)
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
"Content-Type": "application/json; charset=UTF-8"
}
})
.then((response) => response)
@ -153,7 +153,7 @@ signupButton.addEventListener("click", (event) => {
localStorage.setItem("DONOTSHARE-secretkey", responseData["key"])
localStorage.setItem("DONOTSHARE-password", await hashwasm.sha512(password))
window.location.href = "/app"
window.location.href = "../app/index.html"
}
else if (response.status == 401) {
statusBox.innerText = "Wrong username or password..."

View File

@ -1,10 +1,10 @@
if (localStorage.getItem("DONOTSHARE-secretkey") === null) {
window.location.replace("/login")
window.location.replace("../login/index.html")
document.body.innerHTML = "Redirecting..."
throw new Error();
}
if (localStorage.getItem("DONOTSHARE-password") === null) {
window.location.replace("/login")
window.location.replace("../login/index.html")
document.body.innerHTML = "Redirecting..."
throw new Error();
}
@ -197,13 +197,13 @@ textMinusBox.addEventListener("click", (event) => {
function updateUserInfo() {
fetch("/api/userinfo", {
fetch("https://notes.hectabit.org/api/userinfo", {
method: "POST",
body: JSON.stringify({
secretKey: secretkey
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
"Content-Type": "application/json; charset=UTF-8"
}
})
.then((response) => response)
@ -214,7 +214,7 @@ function updateUserInfo() {
closeErrorButton.classList.add("hidden")
usernameBox.innerText = ""
setTimeout(function () {
window.location.replace("/api/logout")
window.location.replace("../logout/index.html")
}, 2500);
} else {
let responseData = await response.json()
@ -236,7 +236,7 @@ usernameBox.addEventListener("click", (event) => {
updateUserInfo()
});
logOutButton.addEventListener("click", (event) => {
window.location.replace("/api/logout")
window.location.replace("/logout/index.html")
});
exitThing.addEventListener("click", (event) => {
optionsDiv.classList.add("hidden")
@ -244,19 +244,19 @@ exitThing.addEventListener("click", (event) => {
});
deleteMyAccountButton.addEventListener("click", (event) => {
if (confirm("Are you REALLY sure that you want to delete your account? There's no going back!") == true) {
fetch("/api/deleteaccount", {
fetch("https://notes.hectabit.org/api/deleteaccount", {
method: "POST",
body: JSON.stringify({
secretKey: secretkey
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
"Content-Type": "application/json; charset=UTF-8"
}
})
.then((response) => response)
.then((response) => {
if (response.status == 200) {
window.location.href = "/api/logout"
window.location.href = "https://notes.hectabit.org/api/logout"
} else {
displayError("Failed to delete account (HTTP error code " + response.status + ")")
}
@ -267,13 +267,13 @@ sessionManagerButton.addEventListener("click", (event) => {
optionsDiv.classList.add("hidden")
sessionManagerDiv.classList.remove("hidden")
fetch("/api/sessions/list", {
fetch("https://notes.hectabit.org/api/sessions/list", {
method: "POST",
body: JSON.stringify({
secretKey: secretkey
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
"Content-Type": "application/json; charset=UTF-8"
}
})
.then((response) => response)
@ -307,20 +307,20 @@ sessionManagerButton.addEventListener("click", (event) => {
}
sessionRemoveButton.addEventListener("click", (event) => {
fetch("/api/sessions/remove", {
fetch("https://notes.hectabit.org/api/sessions/remove", {
method: "POST",
body: JSON.stringify({
secretKey: secretkey,
sessionId: responseData[i]["id"]
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
"Content-Type": "application/json; charset=UTF-8"
}
})
.then((response) => response)
.then((response) => {
if (responseData[i]["thisSession"] == true) {
window.location.replace("/api/logout")
window.location.replace("https://notes.hectabit.org/api/logout")
}
});
sessionElement.remove()
@ -358,14 +358,14 @@ function selectNote(nameithink) {
let thingArray = Array.from(document.querySelectorAll(".noteButton")).find(el => el.id == nameithink);
thingArray.classList.add("selected")
fetch("/api/readnote", {
fetch("https://notes.hectabit.org/api/readnote", {
method: "POST",
body: JSON.stringify({
secretKey: secretkey,
noteId: nameithink,
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
"Content-Type": "application/json; charset=UTF-8"
}
})
.catch((error) => {
@ -396,7 +396,7 @@ function selectNote(nameithink) {
let encryptedText = CryptoJS.AES.encrypt(noteBox.value, password).toString();
if (selectedNote == nameithink) {
fetch("/api/editnote", {
fetch("https://notes.hectabit.org/api/editnote", {
method: "POST",
body: JSON.stringify({
secretKey: secretkey,
@ -404,7 +404,7 @@ function selectNote(nameithink) {
content: encryptedText,
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
"Content-Type": "application/json; charset=UTF-8"
}
})
.then((response) => response)
@ -425,13 +425,13 @@ function selectNote(nameithink) {
}
function updateNotes() {
fetch("/api/listnotes", {
fetch("https://notes.hectabit.org/api/listnotes", {
method: "POST",
body: JSON.stringify({
secretKey: secretkey
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
"Content-Type": "application/json; charset=UTF-8"
}
})
.then((response) => response)
@ -459,14 +459,14 @@ function updateNotes() {
noteButton.addEventListener("click", (event) => {
if (event.ctrlKey) {
fetch("/api/removenote", {
fetch("https://notes.hectabit.org/api/removenote", {
method: "POST",
body: JSON.stringify({
secretKey: secretkey,
noteId: responseData[i]["id"]
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
"Content-Type": "application/json; charset=UTF-8"
}
})
.then((response) => response)
@ -499,14 +499,14 @@ newNote.addEventListener("click", (event) => {
}
let encryptedName = CryptoJS.AES.encrypt(noteName, password).toString();
fetch("/api/newnote", {
fetch("https://notes.hectabit.org/api/newnote", {
method: "POST",
body: JSON.stringify({
secretKey: secretkey,
noteName: encryptedName,
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
"Content-Type": "application/json; charset=UTF-8"
}
})
.catch((error) => {
@ -535,13 +535,13 @@ function downloadObjectAsJson(exportObj, exportName) {
function exportNotes() {
let noteExport = []
fetch("/api/exportnotes", {
fetch("https://notes.hectabit.org/api/exportnotes", {
method: "POST",
body: JSON.stringify({
secretKey: secretkey
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
"Content-Type": "application/json; charset=UTF-8"
}
})
.then((response) => response)
@ -594,14 +594,14 @@ removeBox.addEventListener("click", (event) => {
if (selectedNote == 0) {
displayError("You need to select a note first!")
} else {
fetch("/api/removenote", {
fetch("https://notes.hectabit.org/api/removenote", {
method: "POST",
body: JSON.stringify({
secretKey: secretkey,
noteId: selectedNote
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
"Content-Type": "application/json; charset=UTF-8"
}
})
.then((response) => response)

View File

@ -1,10 +1,10 @@
if (localStorage.getItem("DONOTSHARE-secretkey") !== null) {
window.location.replace("/app")
window.location.replace("../app/index.html")
document.body.innerHTML = "Redirecting..."
throw new Error();
}
if (localStorage.getItem("DONOTSHARE-password") !== null) {
window.location.replace("/app")
window.location.replace("../app/index.html")
document.body.innerHTML = "Redirecting..."
throw new Error();
}
@ -61,14 +61,14 @@ signupButton.addEventListener("click", (event) => {
};
fetch("/api/signup", {
fetch("https://notes.hectabit.org/api/signup", {
method: "POST",
body: JSON.stringify({
username: username,
password: await hashpass(password)
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
"Content-Type": "application/json; charset=UTF-8"
}
})
.then((response) => response)
@ -81,7 +81,7 @@ signupButton.addEventListener("click", (event) => {
localStorage.setItem("DONOTSHARE-secretkey", responseData["key"])
localStorage.setItem("DONOTSHARE-password", await hashwasm.sha512(password))
window.location.href = "/app"
window.location.href = "../app/index.html"
}
else if (response.status == 409) {
statusBox.innerText = "Username already taken!"

View File

@ -6,8 +6,8 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" type="text/css" href="/static/css/style.css" />
<script type="text/javascript" src="/static/js/crypto-js.js"></script>
<link rel="stylesheet" type="text/css" href="../static/css/style.css" />
<script type="text/javascript" src="../static/js/crypto-js.js"></script>
</head>
<body>
@ -28,7 +28,7 @@
<div id="notesBar" class="notesBar">
<button id="newNote" class="newNote"><img id="newNoteImage" draggable="false" alt=""
src="/static/svg/add.svg">New note</button>
src="../static/svg/add.svg">New note</button>
<div id="notesDiv" class="notesDiv">
<button class="loadingStuff" id="loadingStuff"></button>
</div>
@ -46,10 +46,10 @@
<p id="storageThing"></p>
<div class="section"></div>
<p>Account managment</p>
<button id="deleteMyAccountButton"><img src="/static/svg/delete_forever.svg">Delete my account</button>
<button id="exportNotesButton"><img src="/static/svg/download.svg">Export notes</button>
<button id="sessionManagerButton"><img src="/static/svg/list.svg">Session manager</button>
<button class="lastButton" id="logOutButton"><img src="/static/svg/logout.svg">Log out</button>
<button id="deleteMyAccountButton"><img src="../static/svg/delete_forever.svg">Delete my account</button>
<button id="exportNotesButton"><img src="../static/svg/download.svg">Export notes</button>
<button id="sessionManagerButton"><img src="../static/svg/list.svg">Session manager</button>
<button class="lastButton" id="logOutButton"><img src="../static/svg/logout.svg">Log out</button>
</div>
<div id="sessionManagerDiv" class="optionsDiv hidden">
<button class="exit" id="exitSessionsThing">X</button>
@ -70,7 +70,7 @@
<textarea id="noteBox" class="noteBox"></textarea>
<script type="text/javascript" src="/static/js/main.js"></script>
<script type="text/javascript" src="../static/js/main.js"></script>
<script>
for (let i = 0; i < 40; i++) {
notesDiv.appendChild(loadingStuff.cloneNode())

View File

@ -6,7 +6,7 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" type="text/css" href="/static/css/style.css" />
<link rel="stylesheet" type="text/css" href="../static/css/style.css" />
</head>
<body>

View File

@ -6,8 +6,8 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" type="text/css" href="/static/css/style.css" />
<script src="/static/js/hash-wasm.js"></script>
<link rel="stylesheet" type="text/css" href="../static/css/style.css" />
<script src="../static/js/hash-wasm.js"></script>
</head>
@ -19,8 +19,8 @@
<input id="passwordBox" class="hidden" type="password" placeholder="Enter your password">
<button id="signupButton">Next</button>
<button id="backButton" class="hidden">Back</button><br><br>
<p>Don't have an account? If so, <a href="/signup">Create one here!</a></p>
<p>Don't have an account? If so, <a href="../signup/index.html">Create one here!</a></p>
</div>
<script type="text/javascript" src="/static/js/login.js"></script>
<script type="text/javascript" src="../static/js/login.js"></script>
</body>

View File

@ -11,5 +11,5 @@ Logging out..
localStorage.removeItem("DONOTSHARE-secretkey")
localStorage.removeItem("DONOTSHARE-password")
localStorage.removeItem("CACHE-username")
window.location.replace("/")
window.location.replace("../index.html")
</script>

View File

@ -6,7 +6,7 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" type="text/css" href="/static/css/style.css" />
<link rel="stylesheet" type="text/css" href="./static/css/style.css" />
<meta content="Burgernotes" property="og:title" />
<meta content="A simple note-taking app!" property="og:description" />
</head>
@ -17,12 +17,12 @@
<h1 class="w300">Burgernotes</h1>
<p>A simple note-taking service!</p>
<br>
<a href="/app">Open in your browser</a>
<a href="./app/index.html">Open in your browser</a>
<a href="/static/burgernotes.mobileconfig" style="margin-top: 5px;">Download for iOS</a>
<a href="./static/burgernotes.mobileconfig" style="margin-top: 5px;">Download for iOS</a>
<a style="padding: 0; padding-bottom: 0; margin-top: 5px; background-color: rgba(0, 0, 0, 0);" href="https://flathub.org/apps/org.hectabit.burgernotes">
<img class="flathubLogo" style="height: 55px;"src="/static/svg/flathublight.svg">
<img class="flathubLogo" style="height: 55px;"src="./static/svg/flathublight.svg">
</a>
</div>
<br>
@ -37,7 +37,7 @@
</div>
<div class="links">
<a href="https://centrifuge.hectabit.org/hectabit/burgernotes">Source code</a>
<a href="/privacy">Privacy policy</a>
<a href="./privacy/index.html">Privacy policy</a>
</div>
</body>

View File

@ -6,7 +6,7 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" type="text/css" href="/static/css/style.css" />
<link rel="stylesheet" type="text/css" href="../static/css/style.css" />
</head>
<body>

View File

@ -6,8 +6,8 @@
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" type="text/css" href="/static/css/style.css" />
<script src="/static/js/hash-wasm.js"></script>
<link rel="stylesheet" type="text/css" href="../static/css/style.css" />
<script src="../static/js/hash-wasm.js"></script>
</head>
@ -20,8 +20,8 @@
<input id="passwordBox" type="password" placeholder="Password">
<button id="signupButton">Signup</button><br><br>
<p>Please note that it's impossible to reset your password, do not forget it!</p>
<p>Already have an account? If so, <a href="/login">Login</a> instead!</p>
<p>Already have an account? If so, <a href="../login/index.html">Login</a> instead!</p>
</div>
<script type="text/javascript" src="/static/js/signup.js"></script>
<script type="text/javascript" src="../static/js/signup.js"></script>
</body>