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"
|
||||
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)
|
||||
|
||||
@@ -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
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