Simple markdown support
This commit is contained in:
parent
8eea39ea07
commit
fba3ebebff
@ -6,8 +6,8 @@ This is a *very* basic notes-taking program. It uses python with flask and pickl
|
||||
|
||||

|
||||
|
||||
## Future features
|
||||
* Allow for notes modification
|
||||
* Markdown interface
|
||||
## Future features, todo
|
||||
* Allow for notes modification and deletion
|
||||
* A squirrel ascii picture somewhere in the page :3
|
||||
* Less ugly colors and font
|
||||
* Better syntax coloring and markdown rendering in general
|
||||
|
BIN
squipnotes.png
BIN
squipnotes.png
Binary file not shown.
Before Width: | Height: | Size: 74 KiB After Width: | Height: | Size: 40 KiB |
13
src/app.py
13
src/app.py
@ -1,12 +1,13 @@
|
||||
#!/usr/bin/env python3
|
||||
#coding: utf-8
|
||||
from flask import Flask, render_template, Markup, request
|
||||
from os.path import exists
|
||||
import datetime, time, pickle
|
||||
import markdown
|
||||
|
||||
#!---------- squiNotes.py ----------
|
||||
# My notes-taking app
|
||||
#-----------------------------!
|
||||
|
||||
|
||||
class note:
|
||||
def __init__(self, createtime: int, modtime: int, title: str, text: str):
|
||||
"""
|
||||
@ -22,6 +23,7 @@ class note:
|
||||
"""
|
||||
Render the given timestamp as dd/mm/yyyy-hh:mm
|
||||
"""
|
||||
import datetime
|
||||
timestamp = datetime.datetime.fromtimestamp(pretimestamp)
|
||||
timestamp = timestamp.strftime("%d/%m/%Y-%H:%M:%S")
|
||||
return timestamp
|
||||
@ -34,7 +36,7 @@ class note:
|
||||
<hr>
|
||||
<div class="notetitle">{Markup.escape(self.title)}</div><br>
|
||||
<div class="notetime">Created : {self.rendertime(self.createtime)} Modified : {self.rendertime(self.modtime)}</div><br>
|
||||
<div class="notetext">{Markup.escape(self.text)}</div><br>"""
|
||||
<div class="notetext">{markdown.markdown(self.text)}</div><br>"""
|
||||
return Markup(rendered)
|
||||
|
||||
def __str__(self):
|
||||
@ -54,6 +56,7 @@ def dumpnotes(notes):
|
||||
"""
|
||||
Get our notes list and save them as pickle to notes.pickle
|
||||
"""
|
||||
import pickle
|
||||
with open('notes.pickle', 'wb') as mpf:
|
||||
pickle.dump(notes, mpf)
|
||||
|
||||
@ -63,6 +66,9 @@ def getnotes():
|
||||
"""
|
||||
Get our notes from the file notes.pickle
|
||||
"""
|
||||
from os.path import exists
|
||||
import pickle
|
||||
|
||||
if exists("./notes.pickle"):
|
||||
with open('notes.pickle', 'rb') as mpf:
|
||||
notes = pickle.load(mpf)
|
||||
@ -82,6 +88,7 @@ def render():
|
||||
|
||||
@app.route('/', methods=['POST'])
|
||||
def homepage():
|
||||
import time
|
||||
notetitle = request.form['title']
|
||||
notetext = request.form['text']
|
||||
rightnow = int(time.time())
|
||||
|
BIN
src/notes.pickle
BIN
src/notes.pickle
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user