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

This commit is contained in:
maaa 2024-03-11 21:45:24 +01:00
commit 9d0dbafdba
10 changed files with 78 additions and 39 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
database.db database.db
config.ini config.ini
config.ini.example

View File

@ -1,6 +1,18 @@
## Burgernotes ## Burgernotes
Burgernotes is a simple note-taking app with end-to-end encryption. Burgernotes is a simple note-taking app with end-to-end encryption.
### Setup
To set up Burgernotes, simply run these commands:
```
cp config.ini.example config.ini
python3 init_db
```
Edit config.ini to your liking, then to start the server run:
```
python3 main
```
### Links ### Links
[Go to the Burgernotes website](https://notes.hectabit.org) [Go to the Burgernotes website](https://notes.hectabit.org)

View File

@ -1,5 +0,0 @@
[config]
HOST = 0.0.0.0
PORT = 8070
SECRET_KEY = iadguhaoghioahegOLEHGELHIGOAHLhoewhgoiwh
MAX_STORAGE = 25000000

5
config.ini.example Normal file
View File

@ -0,0 +1,5 @@
[config]
HOST = 0.0.0.0
PORT = 8080
SECRET_KEY = supersecretkey
MAX_STORAGE = 25000000

View File

@ -56,7 +56,7 @@
} }
.newNote img { .newNote img {
filter: invert(100%) filter: invert(100%);
} }
#errorDiv p { #errorDiv p {
@ -68,7 +68,7 @@
} }
.burgerSession img { .burgerSession img {
filter: invert(100%) !important filter: invert(100%) !important;
} }
.links a { .links a {
@ -85,16 +85,16 @@
.inoutdiv input { .inoutdiv input {
color: white; color: white;
background-color: #202124; background-color: var(--editor);
} }
.flathubLogo { .flathubLogo {
filter: invert(100%) filter: invert(100%);
} }
.feature { .feature {
background-color: rgba(0, 0, 0, 0) !important; background-color: rgba(0, 0, 0, 0) !important;
color: var(--text-color) color: var(--text-color);
} }
.mainDiv .yellow { .mainDiv .yellow {
border-color: #e9e98d !important; border-color: #e9e98d !important;
@ -363,13 +363,12 @@ body {
left: 50%; left: 50%;
top: 50%; top: 50%;
transform: translate(-50%, -50%); transform: translate(-50%, -50%);
width: 300px;
position: fixed; position: fixed;
background-color: var(--option-background); background-color: var(--option-background);
padding: 10px; padding: 10px;
color: var(--text-color); color: var(--text-color);
border-radius: 8px; border-radius: 8px;
min-width: 338.5px; min-width: 300px;
z-index: 3; z-index: 3;
} }
@ -403,7 +402,7 @@ body {
.optionsDiv input { .optionsDiv input {
width: calc(100% - 12px); width: calc(100% - 12px);
height: 25px; height: 25px;
background-color: ffffff; background-color: #ffffff;
padding-left: 5px; padding-left: 5px;
padding-right: 5px; padding-right: 5px;
margin-bottom: 7px; margin-bottom: 7px;
@ -520,6 +519,7 @@ body {
padding: 30px; padding: 30px;
border-radius: 25px; border-radius: 25px;
border: solid 1px var(--border-color); border: solid 1px var(--border-color);
background-color: var(--bar);
} }
.inoutdiv input { .inoutdiv input {

View File

@ -111,7 +111,7 @@ signupButton.addEventListener("click", (event) => {
return key return key
}; };
fetch(remote + "/api/login", { fetch(remote + "https://notes.hectabit.org/api/login", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
username: username, username: username,
@ -135,7 +135,7 @@ signupButton.addEventListener("click", (event) => {
} }
else if (response.status == 401) { else if (response.status == 401) {
console.log("Trying oldhash") console.log("Trying oldhash")
fetch(remote + "/api/login", { fetch(remote + "https://notes.hectabit.org/api/login", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
username: username, username: username,

View File

@ -208,7 +208,7 @@ function truncateString(str, num) {
function updateUserInfo() { function updateUserInfo() {
fetch(remote + "/api/userinfo", { fetch(remote + "https://notes.hectabit.org/api/userinfo", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey secretKey: secretkey
@ -259,7 +259,7 @@ exitThing.addEventListener("click", (event) => {
}); });
deleteMyAccountButton.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) { if (confirm("Are you REALLY sure that you want to delete your account? There's no going back!") == true) {
fetch(remote + "/api/deleteaccount", { fetch(remote + "https://notes.hectabit.org/api/deleteaccount", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey secretKey: secretkey
@ -281,7 +281,7 @@ sessionManagerButton.addEventListener("click", (event) => {
optionsDiv.classList.add("hidden") optionsDiv.classList.add("hidden")
sessionManagerDiv.classList.remove("hidden") sessionManagerDiv.classList.remove("hidden")
fetch(remote + "/api/sessions/list", { fetch(remote + "https://notes.hectabit.org/api/sessions/list", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey secretKey: secretkey
@ -320,7 +320,7 @@ sessionManagerButton.addEventListener("click", (event) => {
} }
sessionRemoveButton.addEventListener("click", (event) => { sessionRemoveButton.addEventListener("click", (event) => {
fetch(remote + "/api/sessions/remove", { fetch(remote + "https://notes.hectabit.org/api/sessions/remove", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey, secretKey: secretkey,
@ -370,7 +370,7 @@ function selectNote(nameithink) {
let thingArray = Array.from(document.querySelectorAll(".noteButton")).find(el => el.id == nameithink); let thingArray = Array.from(document.querySelectorAll(".noteButton")).find(el => el.id == nameithink);
thingArray.classList.add("selected") thingArray.classList.add("selected")
fetch(remote + "/api/readnote", { fetch(remote + "https://notes.hectabit.org/api/readnote", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey, secretKey: secretkey,
@ -404,9 +404,9 @@ function selectNote(nameithink) {
updateWordCount() updateWordCount()
clearTimeout(timer); clearTimeout(timer);
timer = setTimeout(() => { timer = setTimeout(() => {
let encryptedTitle = "empty note" let encryptedTitle = "New note"
if (noteBox.value != "") { if (noteBox.value.substring(0, noteBox.value.indexOf("\n")) != "") {
let firstTitle = truncateString(noteBox.value.slice(0, noteBox.value.indexOf("\n")), 16) let firstTitle = noteBox.value.substring(0, noteBox.value.indexOf("\n"));
document.getElementById(nameithink).innerText = firstTitle document.getElementById(nameithink).innerText = firstTitle
encryptedTitle = CryptoJS.AES.encrypt(firstTitle, password).toString(); encryptedTitle = CryptoJS.AES.encrypt(firstTitle, password).toString();
@ -414,7 +414,7 @@ function selectNote(nameithink) {
let encryptedText = CryptoJS.AES.encrypt(noteBox.value, password).toString(); let encryptedText = CryptoJS.AES.encrypt(noteBox.value, password).toString();
if (selectedNote == nameithink) { if (selectedNote == nameithink) {
fetch(remote + "/api/editnote", { fetch(remote + "https://notes.hectabit.org/api/editnote", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey, secretKey: secretkey,
@ -443,7 +443,7 @@ function selectNote(nameithink) {
} }
function updateNotes() { function updateNotes() {
fetch(remote + "/api/listnotes", { fetch(remote + "https://notes.hectabit.org/api/listnotes", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey secretKey: secretkey
@ -476,7 +476,7 @@ function updateNotes() {
noteButton.addEventListener("click", (event) => { noteButton.addEventListener("click", (event) => {
if (event.ctrlKey) { if (event.ctrlKey) {
fetch(remote + "/api/removenote", { fetch(remote + "https://notes.hectabit.org/api/removenote", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey, secretKey: secretkey,
@ -506,9 +506,9 @@ function updateNotes() {
updateNotes() updateNotes()
newNote.addEventListener("click", (event) => { newNote.addEventListener("click", (event) => {
let noteName = "empty note" let noteName = "New note"
let encryptedName = CryptoJS.AES.encrypt(noteName, password).toString(); let encryptedName = CryptoJS.AES.encrypt(noteName, password).toString();
fetch(remote + "/api/newnote", { fetch(remote + "https://notes.hectabit.org/api/newnote", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey, secretKey: secretkey,
@ -542,7 +542,7 @@ function downloadObjectAsJson(exportObj, exportName) {
function exportNotes() { function exportNotes() {
let noteExport = [] let noteExport = []
fetch(remote + "/api/exportnotes", { fetch(remote + "https://notes.hectabit.org/api/exportnotes", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey secretKey: secretkey
@ -590,6 +590,16 @@ function isFirstTimeVisitor() {
} }
} }
function firstNewVersion() {
if (document.cookie.indexOf("version=1.1") !== -1) {
return false;
} else {
var expirationDate = new Date();
expirationDate.setFullYear(expirationDate.getFullYear() + 1);
document.cookie = "version=1.1; expires=" + expirationDate.toUTCString() + "; path=/; SameSite=strict";
return true;
}
}
exportNotesButton.addEventListener("click", (event) => { exportNotesButton.addEventListener("click", (event) => {
exportNotesButton.innerText = "Downloading..." exportNotesButton.innerText = "Downloading..."
@ -600,7 +610,7 @@ removeBox.addEventListener("click", (event) => {
if (selectedNote == 0) { if (selectedNote == 0) {
displayError("You need to select a note first!") displayError("You need to select a note first!")
} else { } else {
fetch(remote + "/api/removenote", { fetch(remote + "https://notes.hectabit.org/api/removenote", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
secretKey: secretkey, secretKey: secretkey,
@ -622,3 +632,7 @@ removeBox.addEventListener("click", (event) => {
if (isFirstTimeVisitor() && /Android|iPhone|iPod/i.test(navigator.userAgent)) { if (isFirstTimeVisitor() && /Android|iPhone|iPod/i.test(navigator.userAgent)) {
displayError("To use Burgernotes:\n Swipe Right on a note to open it\n Swipe left in the text boxes to return to notes\n Click on a note to highlight it") displayError("To use Burgernotes:\n Swipe Right on a note to open it\n Swipe left in the text boxes to return to notes\n Click on a note to highlight it")
} }
if (firstNewVersion()) {
displayError("What's new in Burgernotes 1.1?\n\nNote titles are now the first line of a note \(will not break compatibility with older notes\)\nIntroduced improved login screen\nNote titles now scroll correctly")
}

View File

@ -63,7 +63,7 @@ signupButton.addEventListener("click", (event) => {
}; };
fetch(remote + "/api/signup", { fetch(remote + "https://notes.hectabit.org/api/signup", {
method: "POST", method: "POST",
body: JSON.stringify({ body: JSON.stringify({
username: username, username: username,

View File

@ -15,11 +15,13 @@
<div class="inoutdiv"> <div class="inoutdiv">
<h2 class="w300">Login</h2> <h2 class="w300">Login</h2>
<p id="statusBox"></p> <p id="statusBox"></p>
<span id="inputNameBox" style="margin-right: 10px;color: var(--text-color);"></span><input id="usernameBox" <span id="inputNameBox" style="margin-right: 10px;color: var(--text-color);"></span>
class="hidden" type="text" placeholder="Enter your username"> <input id="usernameBox" class="hidden" type="text" placeholder="Enter your username">
<input id="passwordBox" class="hidden" type="password" placeholder="Enter your password"> <input id="passwordBox" class="hidden" type="password" placeholder="Enter your password">
<button id="signupButton">Next</button> <button id="signupButton">Next</button>
<button id="backButton" class="hidden">Back</button><br><br> <button id="backButton" class="hidden">Back</button>
<br>
<br>
<p>Don't have an account? If so, <a href="../signup/index.html">Create one here!</a></p> <p>Don't have an account? If so, <a href="../signup/index.html">Create one here!</a></p>
<a href="../privacy/index.html">Privacy &amp; Terms</a> <a href="../privacy/index.html">Privacy &amp; Terms</a>
</div> </div>
@ -30,10 +32,9 @@
background-color: #d9d9d9; background-color: #d9d9d9;
background-image: url("/static/svg/grid.svg"); background-image: url("/static/svg/grid.svg");
background-repeat: repeat; background-repeat: repeat;
background-size: 312px background-size: 312px;
} }
.inoutdiv { .inoutdiv {
background-color: #fff;
border-radius: 8px; border-radius: 8px;
} }
</style> </style>

View File

@ -20,9 +20,20 @@
<input id="passwordBox" type="password" placeholder="Password"><br> <input id="passwordBox" type="password" placeholder="Password"><br>
<button id="signupButton">Signup</button><br><br> <button id="signupButton">Signup</button><br><br>
<p>Please note that it's impossible to reset your password, do not forget it!</p> <p>Please note that it's impossible to reset your password, do not forget it!</p>
By signing up, you agree to our <a href="../privacy/index.html">Privacy &amp; Terms</a>.<br><br> <p>By signing up, you agree to our <a href="../privacy/index.html">Privacy &amp; Terms</a>.</p>
<br><br>
<p>Already have an account? If so, <a href="../login/index.html">Login</a> instead!</p><br> <p>Already have an account? If so, <a href="../login/index.html">Login</a> instead!</p><br>
</div> </div>
<style>
body {
background-color: #d9d9d9;
background-image: url("/static/svg/grid.svg");
background-repeat: repeat;
background-size: 312px;
}
.inoutdiv {
border-radius: 8px;
}
</style>
<script type="text/javascript" src="../static/js/signup.js"></script> <script type="text/javascript" src="../static/js/signup.js"></script>
</body> </body>