Fixed notes on read page
This commit is contained in:
8
main.py
8
main.py
@@ -15,9 +15,11 @@ def readBook():
|
|||||||
filepath = request.args.get('filepath')+"/book.md"
|
filepath = request.args.get('filepath')+"/book.md"
|
||||||
with open(filepath) as f:
|
with open(filepath) as f:
|
||||||
mdtext = f.read()
|
mdtext = f.read()
|
||||||
|
notespath = request.args.get('filepath')+"/notes.txt"
|
||||||
|
with open(notespath) as f:
|
||||||
|
notestext = f.read()
|
||||||
renderedMd = markdown.markdown(mdtext)
|
renderedMd = markdown.markdown(mdtext)
|
||||||
finalHTML = "<a href='http://localhost:5000/'>Home</a>" + renderedMd
|
return render_template('read.html', markdown=renderedMd, path=request.args.get('filepath'), notes=notestext)
|
||||||
return finalHTML
|
|
||||||
|
|
||||||
@app.route('/notes')
|
@app.route('/notes')
|
||||||
def notesForBook():
|
def notesForBook():
|
||||||
@@ -28,7 +30,7 @@ def notesForBook():
|
|||||||
|
|
||||||
@app.route('/savenotes', methods=['POST'])
|
@app.route('/savenotes', methods=['POST'])
|
||||||
def saveNotes():
|
def saveNotes():
|
||||||
path = request.form.get("path")
|
path = request.form.get("path")+"/notes.txt"
|
||||||
notes = request.form.get("notes")
|
notes = request.form.get("notes")
|
||||||
with open(path, "w") as f:
|
with open(path, "w") as f:
|
||||||
f.write(notes)
|
f.write(notes)
|
||||||
|
|||||||
@@ -33,11 +33,13 @@
|
|||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<a href="http://localhost:5000/">Home (No save)</a>
|
<a href="http://localhost:5000/">Home (No save)</a>
|
||||||
|
<div>
|
||||||
<form action="http://localhost:5000/savenotes" method="post">
|
<form action="http://localhost:5000/savenotes" method="post">
|
||||||
<input for="path" name="path" type="hidden" value="{{ path }}" style="display: hidden;"></input>
|
<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>
|
</br>
|
||||||
<input class="save" type="submit" value="Save"></input>
|
<input class="save" type="submit" value="Save"></input>
|
||||||
</form>
|
</form>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
61
templates/read.html
Normal file
61
templates/read.html
Normal 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>
|
||||||
@@ -1 +1 @@
|
|||||||
My notes
|
12345
|
||||||
Reference in New Issue
Block a user