Better interface overall

This commit is contained in:
justine 2022-03-18 01:09:12 +01:00
parent db4ee348a0
commit b789471acc
11 changed files with 70 additions and 9 deletions

View File

@ -24,6 +24,4 @@ pygmentize -S dracula -f html -a .codehilite > styles.css
* Replace all css for .codehilite in src/static/main.css with what's in styles.css * Replace all css for .codehilite in src/static/main.css with what's in styles.css
## Future features, todo ## Future features, todo
* A squirrel ascii picture somewhere in the page :3
* A link "export all in markdown"
* Replace pickle with sqlite or smth * Replace pickle with sqlite or smth

BIN
data/notes.pickle Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -2,7 +2,7 @@
#coding: utf-8 #coding: utf-8
from flask import Flask, render_template, Markup, request, redirect, url_for from flask import Flask, render_template, Markup, request, redirect, url_for
from classes import note from classes import note
from funcs import dumpnotes, getnotes, catnotes, delnote, findnote, addnote, mknotedir from funcs import dumpnotes, getnotes, catnotes, delnote, findnote, addnote, mknotedir, exportnotes
#!---------- squiNotes.py ---------- #!---------- squiNotes.py ----------
# My notes-taking app # My notes-taking app
@ -32,6 +32,11 @@ def render():
return render_template("homepage.html", nr = catnotes(getnotes())) return render_template("homepage.html", nr = catnotes(getnotes()))
#Export mode
@app.route('/export', methods=['GET'])
def rawnotes():
return render_template("export.html", rawnotes = exportnotes())
#Edition mode #Edition mode
@app.route('/edit', methods=['GET', 'POST']) @app.route('/edit', methods=['GET', 'POST'])
def edit(): def edit():

BIN
src/data/notes.pickle Normal file

Binary file not shown.

View File

@ -76,3 +76,21 @@ def addnote(mynote: note):
notes.append(mynote) notes.append(mynote)
notes = sorted(notes, key=lambda note: note.modtime, reverse=True) notes = sorted(notes, key=lambda note: note.modtime, reverse=True)
dumpnotes(notes) dumpnotes(notes)
def exportnotes():
"""
Export our notes in markdown, one after the other.
"""
notes = getnotes()
rawtext = ""
for note in notes:
rawtext += f"#{note.title}\n"
rawtext += f"* Created: {note.rendertime(note.createtime)}\n"
rawtext += f"* Modified: {note.rendertime(note.modtime)}\n"
rawtext += f"{note.text}\n"
rawtext += f"-----\n\n"
return rawtext
return

View File

@ -41,9 +41,25 @@ button {
cursor: pointer; cursor: pointer;
} }
hr {
border: 3px dotted;
}
a {
color: #8be9fd;
text-decoration: underline;
font-style: italic;
font-size: 1em;
}
.exportlink {
float: right;
}
.pagetitle { .pagetitle {
font-size: 3em; font-size: 3em;
color: #ff79c6; color: #ff79c6;
float: left;
} }
@ -71,18 +87,20 @@ button {
*/ */
.text { .text {
width: 100%;
background: #44475a; background: #44475a;
color: #f8f8f2; color: #f8f8f2;
border-radius: 5px; border-radius: 5px;
border-style: none; border-style: none;
outline: none; outline: none;
border-width: 1px; border-width: 1px;
height: 200px; height: 80%;
font-size: 15px; font-size: 15px;
-webkit-box-shadow: 0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23); -webkit-box-shadow: 0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23);
} }
.title { .title {
width: 100%;
background: #44475a; background: #44475a;
color: #f8f8f2; color: #f8f8f2;
border-radius: 5px; border-radius: 5px;
@ -95,6 +113,10 @@ button {
-webkit-box-shadow: 0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23); -webkit-box-shadow: 0 3px 6px rgba(0,0,0,.16),0 3px 6px rgba(0,0,0,.23);
} }
.rawtext {
white-space: pre-wrap;
}
/* Syntax highlighting */ /* Syntax highlighting */
pre { line-height: 125%; } pre { line-height: 125%; }
td.linenos .normal { color: #f1fa8c; background-color: #44475a; padding-left: 5px; padding-right: 5px; } td.linenos .normal { color: #f1fa8c; background-color: #44475a; padding-left: 5px; padding-right: 5px; }

View File

@ -11,7 +11,7 @@
<div class="div1"> <div class="div1">
<form action="." method="POST"> <form action="." method="POST">
<textarea type="text" name="title" class="title">{{ ntitle }}</textarea><br> <textarea type="text" name="title" class="title">{{ ntitle }}</textarea><br>
<textarea type="text" name="text" rows = "50" cols = "60*" class="text">{{ ntext }}</textarea><br> <textarea type="text" name="text" cols = "60*" class="text">{{ ntext }}</textarea><br>
<button type="submit" name="submit">OK</button> <button type="submit" name="submit">OK</button>
<div class="notetime">Note : you can drag the textbox to make it bigger.</div> <div class="notetime">Note : you can drag the textbox to make it bigger.</div>
</form> </form>

13
src/templates/export.html Normal file
View File

@ -0,0 +1,13 @@
<html>
<head>
<link rel="stylesheet" href="{{ url_for('static', filename='styles/main.css') }}" type="text/css" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<!--<link href='https://fonts.googleapis.com/css?family=Source Sans Pro' rel='stylesheet'> -->
<title>sqnotes</title>
</head>
<body>
<div class="rawtext">
{{ rawnotes }}
</div>
</body>
</html>

View File

@ -7,19 +7,24 @@
</head> </head>
<body> <body>
<h1 class="pagetitle">$ ~/sqnotes</h1> <h1 class="pagetitle">$ ~/sqnotes</h1><a class="exportlink" href="{{ url_for('rawnotes') }}">Raw notes</a>
<div class="div1">
<form action="." method="POST"> <form action="." method="POST">
<input type="text" name="title" class="title" placeholder="Title"><br> <input type="text" name="title" class="title" placeholder="Title"><br>
<textarea type="text" name="text" rows = "5" cols = "60*" class="text" placeholder="Text"></textarea><br> <textarea type="text" name="text" rows = "5" cols = "60*" class="text" placeholder="Text"></textarea><br>
<button type="submit" name="submit">Post</button> <button type="submit" name="submit">Post</button>
<div class="notetime">Note : you can drag the textbox to make it bigger.</div> <div class="notetime">Note : you can drag the textbox to make it bigger. Scroll down to see your previous notes.</div>
</form> </form>
<br> <br>
{{ nr }} {{ nr }}
<div>
</body> </body>
<footer>
<hr>
<div class="notetime">
<p>
You've reached the bottom. Made by Squip, 2022.
</p>
</div>
</meta> </meta>
</html> </html>