Fixed notes on read page

This commit is contained in:
2025-11-28 16:52:52 +00:00
parent 18cc9d328d
commit 651b57be85
4 changed files with 70 additions and 5 deletions

View File

@@ -15,9 +15,11 @@ def readBook():
filepath = request.args.get('filepath')+"/book.md"
with open(filepath) as f:
mdtext = f.read()
notespath = request.args.get('filepath')+"/notes.txt"
with open(notespath) as f:
notestext = f.read()
renderedMd = markdown.markdown(mdtext)
finalHTML = "<a href='http://localhost:5000/'>Home</a>" + renderedMd
return finalHTML
return render_template('read.html', markdown=renderedMd, path=request.args.get('filepath'), notes=notestext)
@app.route('/notes')
def notesForBook():
@@ -28,7 +30,7 @@ def notesForBook():
@app.route('/savenotes', methods=['POST'])
def saveNotes():
path = request.form.get("path")
path = request.form.get("path")+"/notes.txt"
notes = request.form.get("notes")
with open(path, "w") as f:
f.write(notes)

View File

@@ -33,11 +33,13 @@
}
</style>
<a href="http://localhost:5000/">Home (No save)</a>
<div>
<form action="http://localhost:5000/savenotes" method="post">
<input for="path" name="path" type="hidden" value="{{ path }}" style="display: hidden;"></input>
<textarea for="notes" name="notes", style="">{{ notes }}</textarea>
<textarea for="notes" name="notes">{{ notes }}</textarea>
</br>
<input class="save" type="submit" value="Save"></input>
</form>
</div>
</body>
</html>

61
templates/read.html Normal file
View File

@@ -0,0 +1,61 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Read book</title>
</head>
<body>
<style>
#content {
display: flex;
height: 95vh;
}
#left {
height: 100%;
overflow: auto;
}
#right {
height: 100%;
overflow: auto;
}
body{
background-image: url("static/background.jpg");
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
color: white;
text-align: center;
}
a{
color: white;
}
div{
margin: auto;
}
form{
margin-top: 2vh;
}
.save{
width: 50vw;
}
textarea{
width: 50vw;
height: 80vh;
resize: none;
}
</style>
<a href="http://localhost:5000/">Home</a>
<div id="content">
<div id="left">{{ markdown | safe }}</div>
<div id="right">
<form action="http://localhost:5000/savenotes" method="post">
<input for="path" name="path" type="hidden" value="{{ path }}" style="display: hidden;"></input>
<textarea for="notes" name="notes", style="">{{ notes }}</textarea>
</br>
<input class="save" type="submit" value="Save"></input>
</form>
</div>
</div>
</body>
</html>

View File

@@ -1 +1 @@
My notes
12345