Install et HTMLization de markdown pour les articles de blog
This commit is contained in:
parent
eda47f57a6
commit
489ec21bc4
23
README.md
23
README.md
|
@ -1,7 +1,28 @@
|
||||||
Salut, donc pour activer l'environnement virtuel :
|
# Pywallter est un projet pour partagé des fichiers avec ses potes.
|
||||||
|
Ça demande juste un identifiant et voila.
|
||||||
|
on pourrait ajoute de la double authentification mais bon ...
|
||||||
|
|
||||||
|
|
||||||
|
##Pour démarrer le programme
|
||||||
|
|
||||||
|
### Sur OpenBSD (7.1)
|
||||||
|
Il faut installé FLask et quelques dépendances
|
||||||
|
pkg_add py3-werkzeug py3-jinja2 py3-Pillow py3-wtforms py3-flask-wtf py3-flask \
|
||||||
|
py3-bcrypt py3-markdown
|
||||||
|
|
||||||
|
### Sur Debian
|
||||||
|
apt install truc_much
|
||||||
|
|
||||||
|
### Ensuite dans le dossier du projet tu fais :
|
||||||
|
|
||||||
|
$ export FLASK_APP=pywallter.py
|
||||||
|
$ flask run
|
||||||
|
|
||||||
|
Et ça devrait démarrer sans soucis.
|
||||||
|
|
||||||
|
Au premier démarage il créé un dossier pour les données et la base de données sqlite puis il s'arrête,
|
||||||
|
il faut donc le redémarrer (c'est un peu con faudra changer ça )
|
||||||
|
|
||||||
|
flask run
|
||||||
|
|
||||||
|
Suffit pour le faire redémarrer
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from flask import Flask, request, flash, render_template, url_for, session, redirect, abort, make_response, send_file, escape, send_from_directory
|
from flask import Flask, request, flash, render_template, url_for, session, redirect, abort, make_response, send_file, escape, send_from_directory
|
||||||
from werkzeug.utils import secure_filename
|
from werkzeug.utils import secure_filename
|
||||||
from wand.image import Image
|
|
||||||
from wtforms import BooleanField, StringField, IntegerField, PasswordField, validators
|
from wtforms import BooleanField, StringField, IntegerField, PasswordField, validators
|
||||||
import sqlite3
|
import sqlite3
|
||||||
from flask_bcrypt import Bcrypt
|
from flask_bcrypt import Bcrypt
|
||||||
|
|
|
@ -55,11 +55,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<br />
|
<br />
|
||||||
<p class="lead">
|
|
||||||
|
|
||||||
<form method="POST" action="{{ url_for('blog.racine_blog') }}" id="postform">
|
<form method="POST" action="{{ url_for('blog.racine_blog') }}" id="postform">
|
||||||
<!--<input type="text" name="category" id="category" placeholder="Catégorie" class="form-control"><br />-->
|
<!--<input type="text" name="category" id="category" placeholder="Catégorie" class="form-control"><br />-->
|
||||||
<input type="text" name="title" id="title" placeholder="Titre" class="form-control"><br />
|
<input type="text" name="title" id="title" placeholder="Titre" class="form-control"><br />
|
||||||
<textarea class="form-control" form="postform" name="content" id="content" placeholder="Contenu"></textarea><br />
|
<textarea class="form-control" form="postform" name="content" id="content" placeholder="Contenu" style="height:30vw;"></textarea><br />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-4"></div>
|
<div class="col-sm-4"></div>
|
||||||
<div class="col-sm-1"><input type="radio" name="status" value="prive" checked>Privé</div>
|
<div class="col-sm-1"><input type="radio" name="status" value="prive" checked>Privé</div>
|
||||||
|
@ -70,7 +71,7 @@
|
||||||
<br />
|
<br />
|
||||||
<button id="tada" class="btn btn-default btn-primary" type="submit">Publier</button>
|
<button id="tada" class="btn btn-default btn-primary" type="submit">Publier</button>
|
||||||
</form>
|
</form>
|
||||||
</p>
|
|
||||||
<br>
|
<br>
|
||||||
{% for post in posts %}
|
{% for post in posts %}
|
||||||
<div class="well">
|
<div class="well">
|
||||||
|
@ -85,7 +86,9 @@
|
||||||
<div class="well">
|
<div class="well">
|
||||||
<h6>{{ post.time }}</h6>
|
<h6>{{ post.time }}</h6>
|
||||||
<h2>{{ post.title }}</h2>
|
<h2>{{ post.title }}</h2>
|
||||||
<p>{{ post.content }}</p>
|
|
||||||
|
{{ post.content|safe }}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
<p class="lead">
|
<p class="lead">
|
||||||
<form action="" method="POST" id="postform">
|
<form action="" method="POST" id="postform">
|
||||||
<input type="text" name="title" id="title" placeholder="Titre" class="form-control" value="{{ oldpost[0] }}"><br />
|
<input type="text" name="title" id="title" placeholder="Titre" class="form-control" value="{{ oldpost[0] }}"><br />
|
||||||
<textarea class="form-control" form="postform" name="content" id="content" placeholder="Contenu">{{ oldpost[1] }}</textarea><br />
|
<textarea class="form-control" form="postform" name="content" id="content" placeholder="Contenu" style="height: 50%;">{{ oldpost[1] }}</textarea><br />
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-4"></div>
|
<div class="col-sm-4"></div>
|
||||||
<div class="col-sm-1"><input type="radio" name="status" value="prive" checked>Privé</div>
|
<div class="col-sm-1"><input type="radio" name="status" value="prive" checked>Privé</div>
|
||||||
|
|
|
@ -29,7 +29,9 @@
|
||||||
<div class="well">
|
<div class="well">
|
||||||
<h6>{{ post.time }}</h6>
|
<h6>{{ post.time }}</h6>
|
||||||
<h2>{{ post.title }}</h2>
|
<h2>{{ post.title }}</h2>
|
||||||
<p>{{ post.content }}<br><h6>Auteur : {{ post.author }}</h6></p>
|
{{ post.content|safe }}
|
||||||
|
|
||||||
|
<h6>Auteur : {{ post.author }}</h6>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-1">
|
<div class="col-sm-1">
|
||||||
|
|
|
@ -26,7 +26,9 @@
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<h6>{{ post.time }}</h6>
|
<h6>{{ post.time }}</h6>
|
||||||
<h2>{{ post.title }}</h2>
|
<h2>{{ post.title }}</h2>
|
||||||
<p>{{ post.content }}<br><h6>Auteur : {{ post.author }}</h6></p>
|
{{ post.content|safe }}
|
||||||
|
|
||||||
|
<br><h6>Auteur : {{ post.author }}</h6>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-1">
|
<div class="col-sm-1">
|
||||||
{% if post.author == session['username'] %}
|
{% if post.author == session['username'] %}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
from flask import Blueprint, escape, render_template, session, redirect, url_for, request, flash, abort
|
from flask import Blueprint, escape, render_template, session, redirect, url_for, request, flash, abort
|
||||||
import time
|
import time
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
from markdown import markdown
|
||||||
blog = Blueprint('blog', __name__, template_folder='templates')
|
blog = Blueprint('blog', __name__, template_folder='templates')
|
||||||
|
|
||||||
# Un bon gros bug de flask il ne faut pas mettre le meme nom d'une parti ici
|
# Un bon gros bug de flask il ne faut pas mettre le meme nom d'une parti ici
|
||||||
|
@ -19,7 +19,7 @@ def racine_blog():
|
||||||
UTILISATEUR='%s'% escape(session['username'])
|
UTILISATEUR='%s'% escape(session['username'])
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
title= request.form['title']
|
title= request.form['title']
|
||||||
content = request.form['content']
|
content = markdown(request.form['content'])
|
||||||
#category = request.form['category']
|
#category = request.form['category']
|
||||||
status = request.form['status']
|
status = request.form['status']
|
||||||
TIME=time.strftime("%A %d %B %Y %H:%M:%S")
|
TIME=time.strftime("%A %d %B %Y %H:%M:%S")
|
||||||
|
@ -84,11 +84,12 @@ def edit(post):
|
||||||
if 'username' in session :
|
if 'username' in session :
|
||||||
if request.method == 'POST' :
|
if request.method == 'POST' :
|
||||||
newtitle = request.form['title']
|
newtitle = request.form['title']
|
||||||
newcontent = request.form['content']
|
newcontent = markdown(request.form['content'])
|
||||||
newstatus = request.form['status']
|
newstatus = request.form['status']
|
||||||
conn = sqlite3.connect('base.db')
|
conn = sqlite3.connect('base.db')
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
cursor.execute("""UPDATE posts SET title=?, content=?, status=? WHERE title=?""", (newtitle, newcontent, newstatus, post,))
|
cursor.execute("""UPDATE posts SET title=?, content=?, status=? WHERE title=?""",
|
||||||
|
(newtitle, newcontent, newstatus, post,))
|
||||||
conn.commit()
|
conn.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
return redirect(url_for('blog.racine_blog'))
|
return redirect(url_for('blog.racine_blog'))
|
||||||
|
@ -101,5 +102,3 @@ def edit(post):
|
||||||
return render_template('postedit.html', oldpost=oldpost)
|
return render_template('postedit.html', oldpost=oldpost)
|
||||||
else:
|
else:
|
||||||
return redirect(url_for('loginlogout.login', _external=True)) # sinon on redirige vers login)
|
return redirect(url_for('loginlogout.login', _external=True)) # sinon on redirige vers login)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue