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 -*-
|
||||
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 wand.image import Image
|
||||
from wtforms import BooleanField, StringField, IntegerField, PasswordField, validators
|
||||
import sqlite3
|
||||
from flask_bcrypt import Bcrypt
|
||||
|
|
|
@ -55,11 +55,12 @@
|
|||
</div>
|
||||
</div>
|
||||
<br />
|
||||
<p class="lead">
|
||||
|
||||
|
||||
<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="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="col-sm-4"></div>
|
||||
<div class="col-sm-1"><input type="radio" name="status" value="prive" checked>Privé</div>
|
||||
|
@ -70,7 +71,7 @@
|
|||
<br />
|
||||
<button id="tada" class="btn btn-default btn-primary" type="submit">Publier</button>
|
||||
</form>
|
||||
</p>
|
||||
|
||||
<br>
|
||||
{% for post in posts %}
|
||||
<div class="well">
|
||||
|
@ -85,7 +86,9 @@
|
|||
<div class="well">
|
||||
<h6>{{ post.time }}</h6>
|
||||
<h2>{{ post.title }}</h2>
|
||||
<p>{{ post.content }}</p>
|
||||
|
||||
{{ post.content|safe }}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
<p class="lead">
|
||||
<form action="" method="POST" id="postform">
|
||||
<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="col-sm-4"></div>
|
||||
<div class="col-sm-1"><input type="radio" name="status" value="prive" checked>Privé</div>
|
||||
|
|
|
@ -29,7 +29,9 @@
|
|||
<div class="well">
|
||||
<h6>{{ post.time }}</h6>
|
||||
<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 class="col-sm-1">
|
||||
|
|
|
@ -26,7 +26,9 @@
|
|||
<div class="col-sm-10">
|
||||
<h6>{{ post.time }}</h6>
|
||||
<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 class="col-sm-1">
|
||||
{% if post.author == session['username'] %}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
from flask import Blueprint, escape, render_template, session, redirect, url_for, request, flash, abort
|
||||
import time
|
||||
import sqlite3
|
||||
|
||||
from markdown import markdown
|
||||
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
|
||||
|
@ -19,7 +19,7 @@ def racine_blog():
|
|||
UTILISATEUR='%s'% escape(session['username'])
|
||||
if request.method == 'POST':
|
||||
title= request.form['title']
|
||||
content = request.form['content']
|
||||
content = markdown(request.form['content'])
|
||||
#category = request.form['category']
|
||||
status = request.form['status']
|
||||
TIME=time.strftime("%A %d %B %Y %H:%M:%S")
|
||||
|
@ -84,11 +84,12 @@ def edit(post):
|
|||
if 'username' in session :
|
||||
if request.method == 'POST' :
|
||||
newtitle = request.form['title']
|
||||
newcontent = request.form['content']
|
||||
newcontent = markdown(request.form['content'])
|
||||
newstatus = request.form['status']
|
||||
conn = sqlite3.connect('base.db')
|
||||
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.close()
|
||||
return redirect(url_for('blog.racine_blog'))
|
||||
|
@ -101,5 +102,3 @@ def edit(post):
|
|||
return render_template('postedit.html', oldpost=oldpost)
|
||||
else:
|
||||
return redirect(url_for('loginlogout.login', _external=True)) # sinon on redirige vers login)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue