modified: templates/blog.html

modified:   templates/board.html
	modified:   templates/profil.html
	modified:   templates/up_up.html
	modified:   views/blog.py
	modified:   views/profil.py
This commit is contained in:
kitoy 2022-08-07 08:32:21 +02:00
parent aef308e3fd
commit 3451259a57
6 changed files with 17 additions and 38 deletions

View File

@ -20,7 +20,7 @@
Une page <a href="/postit/board"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> Une page <a href="/postit/board"><span class="glyphicon glyphicon-star" aria-hidden="true"></span>
est là pour consulter le tableau public du serveur</a>. est là pour consulter le tableau public du serveur</a>.
Celui-ci regroupe tout les post-it public des utilisateurs inscrits sur le serveur.<br> Celui-ci regroupe tout les post-it public des utilisateurs inscrits sur le serveur.<br>
Vous pouvez aussi écrire des post-its privé que vous seul pourrait consulter.</div> Vous pouvez aussi écrire des post-its privé que vous seul pourrez consulter.</div>
</div> </div>
</div> </div>
<br /> <br />
@ -47,7 +47,7 @@
<div class="row"> <div class="row">
<div class="col-sm-2"> <div class="col-sm-2">
<img src="/static/usersprofil/{{ post.avatar }}" class="img-rounded" alt=""/><br><br> <img src="/profil/{{ post.author }}/{{ post.avatar }}" height="100" width="100" class="img-rounded" alt=""/><br><br>
<p>{% if post.author != None %}{{ post.author }} {%endif%} <br />{% if post.prenom != None %}{{ post.prenom }}{%endif%} <br/>{% if post.age != None %}{{ post.age }} ans {%endif%}<br /></p> <p>{% if post.author != None %}{{ post.author }} {%endif%} <br />{% if post.prenom != None %}{{ post.prenom }}{%endif%} <br/>{% if post.age != None %}{{ post.age }} ans {%endif%}<br /></p>
</div> </div>

View File

@ -6,11 +6,12 @@
{% for post in posts %} {% for post in posts %}
{% if post.nom != None %}
<div class="well"> <div class="well">
<div class="row"> <div class="row">
<div class="col-sm-2"> <div class="col-sm-2">
<img src="/static/usersprofil/{{ post.avatar }}" class="img-rounded" alt=""/><br><br> <img src="/profil/{{post.author}}/{{ post.avatar }}" height="100" width="100" class="img-rounded" alt=""/><br><br>
<p>{% if post.author != None %}{{ post.author }} {%endif%} <br />{% if post.prenom != None %}{{ post.prenom }}{%endif%} <br/>{% if post.age != None %}{{ post.age }} ans {%endif%}<br /></p> <p>{% if post.author != None %}{{ post.author }} {%endif%} <br />{% if post.prenom != None %}{{ post.prenom }}{%endif%} <br/>{% if post.age != None %}{{ post.age }} ans {%endif%}<br /></p>
</div> </div>
@ -24,20 +25,9 @@
</div> </div>
<div class="col-sm-1">
{% if post.author == session['username'] %}
{% if post.status == 'prive' %}
<h4><span class="label label-danger">Privé</span></h4>
{% else %}
<h4><span class="label label-success">Public</span></h4>
{% endif %}
<br /><br>
<a href="{{ url_for('post-it.edit', post=post.title) }}"><button type="button" class="btn btn-sm btn-primary"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span></button></a><br /><br>
<a href="{{ url_for('post-it.delete', post=post.title) }}"><button type="button" class="btn btn-sm btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></button></a><br /><br>
{% endif %}
</div>
</div> </div>
</div> </div>
{% endif %}
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}

View File

@ -20,7 +20,7 @@
<div id="fic"> <div id="fic">
<label> Photo de profil </label> <label> Photo de profil </label>
<input type="file" name="fic" id="fic"/><br> <input type="file" name="fic" id="fic"/><br>
<img id="fic" src="/profil/{{ profil['avatar'] }}" class="img-rounded" alt=""/> <img id="fic" src="/profil/{{ username }}/{{ profil['avatar'] }}" class="img-rounded" alt=""/>
</div> </div>
<br> <br>
<label>Nom </label> <label>Nom </label>

View File

@ -4,20 +4,6 @@
{% block main %} {% block main %}
<div class="container theme-showcase" role="main">
<!-- Main jumbotron for a primary marketing message or call to action -->
<!--<div class="jumbotron">
<h1>Hello, {{ session['username'] }} !</h1>
<p>Hébergeur de fichiers basé sur Flask + Bootstrap 3 et hébergé sur une Orange Pi, vise à promouvoir l'informatique libre. Site en construction.</p>
<p><a href="http://flask.pocoo.org/" class="btn btn-primary btn-lg" role="button">En savoir plus &raquo;</a></p>
</div>-->
<!--<div class="page-header">
<h1>Upload</h1>
</div>-->
<div class="row"> <div class="row">
<div class="col-sm-3"></div> <div class="col-sm-3"></div>
@ -63,6 +49,5 @@
</div> <!-- /container -->
{% endblock %} {% endblock %}

View File

@ -32,7 +32,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 = markdown(request.form['content']) content = 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")
@ -55,6 +55,8 @@ def racine_blog():
status=row[4], avatar=row[5], nom=row[6], prenom=row[7], age=row[8]) status=row[4], avatar=row[5], nom=row[6], prenom=row[7], age=row[8])
for row in reversed(cursor.fetchall())] for row in reversed(cursor.fetchall())]
conn.close() conn.close()
for post in posts:
post['content'] = markdown(post['content'])
return render_template('blog.html', section='Post-it', posts=posts) return render_template('blog.html', section='Post-it', posts=posts)
else: else:
return redirect(BASE_URL, code=401) return redirect(BASE_URL, code=401)
@ -78,7 +80,7 @@ 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 = markdown(request.form['content']) newcontent = request.form['content']
newstatus = request.form['status'] newstatus = request.form['status']
conn = sqlite3.connect(DATABASE) conn = sqlite3.connect(DATABASE)
cursor = conn.cursor() cursor = conn.cursor()
@ -105,11 +107,13 @@ def viewsheet():
if 'username' in session: if 'username' in session:
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
cursor = conn.cursor() # Création de l'objet "curseur" cursor = conn.cursor() # Création de l'objet "curseur"
cursor.execute("""SELECT title, content, time, author, status, avatar, nom, prenom, age FROM posts INNER JOIN users ON author = name""") cursor.execute("""SELECT title, content, time, author, status, avatar, nom, prenom, age FROM posts INNER JOIN users where status='public' """)
posts = [dict(title=row[0], content=row[1], time=row[2], author=row[3], posts = [dict(title=row[0], content=row[1], time=row[2], author=row[3],
status=row[4], avatar=row[5], nom=row[6], prenom=row[7], age=row[8]) status=row[4], avatar=row[5], nom=row[6], prenom=row[7], age=row[8])
for row in reversed(cursor.fetchall())] for row in reversed(cursor.fetchall())]
conn.close() conn.close()
for post in posts:
post['content'] = markdown(post['content'])
return render_template('board.html', section='Post-it', posts=posts) return render_template('board.html', section='Post-it', posts=posts)
else: else:
return redirect(BASE_URL, code=401) return redirect(BASE_URL, code=401)

View File

@ -30,11 +30,11 @@ BASE_URL = app.config['BASE_URL']
################################################################################################## ##################################################################################################
@profil.route( '/profil/<img>', methods=['GET'] ) @profil.route( '/profil/<user>/<img>', methods=['GET'] )
def profil_img(img) : def profil_img(user, img) :
if 'username' in session : if 'username' in session :
UTILISATEUR='%s' % escape(session['username'])
return send_from_directory( os.path.join(DOSSIER_PERSO, UTILISATEUR, 'profile'), img ) return send_from_directory( os.path.join(DOSSIER_PERSO, user, 'profile'), img )
else: else:
return redirect(BASE_URL, code=401) return redirect(BASE_URL, code=401)