Fix landing-page css
This commit is contained in:
BIN
base.db.bkp
Normal file
BIN
base.db.bkp
Normal file
Binary file not shown.
@@ -64,22 +64,19 @@ main > nav
|
||||
}
|
||||
|
||||
article {
|
||||
width: 44vw;
|
||||
max-height: 35vw;
|
||||
min-width: 45vw;
|
||||
max-width:50vw;
|
||||
max-height: 40vw;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
article > header {
|
||||
height: 20vw;
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
article > .subtitle {
|
||||
height: 10vw;
|
||||
}
|
||||
article footer{
|
||||
display: block;
|
||||
height: 10vw;
|
||||
height: fit-content;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,7 +61,9 @@
|
||||
</div>
|
||||
|
||||
|
||||
<footer><a href="/blog//public_unified/{{ article.author }}/{{ article.title }}"> <button> Lire la suite </button> </a></footer>
|
||||
<a href="/blog/public_unified/{{ article.author }}/{{ article.title_id }}"> <button> Lire la suite </button> </a>
|
||||
|
||||
|
||||
</article>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
@@ -18,8 +18,8 @@
|
||||
<item>
|
||||
<title> {{ post.title }} </title>
|
||||
<pubdate> {% if post.last_updated %} {{ post.last_updated }} {% else %} {{ post.time }} {% endif %} </pubdate>
|
||||
<link> {{base_url}}/blog/{{ post.status }}/{{post.author}}/{{post.title}}</link>
|
||||
<guid> {{base_url}}/blog/{{ post.status }}/{{post.author}}/{{post.title}}</guid>
|
||||
<link> {{base_url}}/blog/{{ post.status }}/{{post.author}}/{{post.title_id}}</link>
|
||||
<guid> {{base_url}}/blog/{{ post.status }}/{{post.author}}/{{post.title_id}}</guid>
|
||||
|
||||
<description>
|
||||
{{ post.subtitle }}
|
||||
|
||||
@@ -6,55 +6,7 @@
|
||||
|
||||
{% block main %}
|
||||
|
||||
|
||||
<form action="" method="POST" id="postform" hx-post="/myblog/update/{{ oldpost['title'] }}" hx-target="#confirm">
|
||||
<input type="text" name="title" id="title" placeholder="titre" class="form-control" value="{{ oldpost['title'] }}"><br />
|
||||
<input type="text" name="subtitle" id="subtitle" placeholder="sous-titre" class="form-control" value="{{ oldpost['subtitle'] }}"><br />
|
||||
<input type="text" name="category" id="category" placeholder="Catégorie" class="form-control" value="{{ oldpost['category'] }}"><br />
|
||||
<textarea id="editeurMarkdown" class="form-control" form="postform" name="content" placeholder="Contenu" style="height:20vw;">{{ oldpost['content'] }}</textarea>
|
||||
|
||||
<br />
|
||||
|
||||
<h3> Visibilité </h3>
|
||||
|
||||
<div class="center">
|
||||
<p> Les articles brouillons ne sont visibles que par vous même</p>
|
||||
<p> Les articles privés ne sont visibles que par les membres du serveur </p>
|
||||
<p> Les articles public sont visibles par tout le monde </p>
|
||||
|
||||
|
||||
{% if oldpost['status'] == 'public' or oldpost['status'] == "public_unified" %}
|
||||
<input type="radio" name="status" value="draft"> Brouillon
|
||||
<input type="radio" name="status" value="private"> Privé
|
||||
<input type="radio" name="status" value="public" checked> Publique
|
||||
|
||||
{% elif oldpost['status'] == 'private' or oldpost['status'] == "private_unified" %}
|
||||
<input type="radio" name="status" value="draft"> Brouillon
|
||||
<input type="radio" name="status" value="private" checked> Privé
|
||||
<input type="radio" name="status" value="public"> Publique
|
||||
{% else %}
|
||||
<input type="radio" name="status" value="draft" checked> Brouillon
|
||||
<input type="radio" name="status" value="private"> Privé
|
||||
<input type="radio" name="status" value="public"> Publique
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<fieldset>
|
||||
<label>
|
||||
|
||||
{% if oldpost['status'] == "private_unified" or oldpost['status'] == "public_unified" %}
|
||||
<input id="blog-unified" name="blog-unified" type="checkbox" role="switch" checked />
|
||||
{% else %}
|
||||
<input id="blog-unified" name="blog-unified" type="checkbox" role="switch" />
|
||||
{% endif %}
|
||||
Publier cet article dans le blog général
|
||||
</label>
|
||||
</fieldset>
|
||||
<div class="flashed {{ categorie }}" id="confirm">
|
||||
</div>
|
||||
<button type="submit"> Mettre à jour </button>
|
||||
</form>
|
||||
{% include 'update_article.html' %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
</small>
|
||||
<div class="slug">
|
||||
<p> {{ post.subtitle }} </p>
|
||||
<p class="readmore"> <a style="margin-right:2rem;" href="/blog/{{ post.status }}/{{post.author}}/{{post.title}}"> Lire la suite... </a></p>
|
||||
<p class="readmore"> <a style="margin-right:2rem;" href="/blog/{{ post.status }}/{{post.author}}/{{post.title_id}}"> Lire la suite... </a></p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
</small>
|
||||
<div class="slug">
|
||||
<p> {{ post.subtitle }} </p>
|
||||
<p class="readmore"> <a style="margin-right:2rem;" href="/blog/{{ post.status }}/{{post.author}}/{{post.title}}"> Lire la suite... </a></p>
|
||||
<p class="readmore"> <a style="margin-right:2rem;" href="/blog/{{ post.status }}/{{post.author}}/{{post.title_id}}"> Lire la suite... </a></p>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<a href="{{ url_for('blog.edit', title=article.title) }}"><button type="button"> Editer </button></a>
|
||||
<a href="{{ url_for('blog.delete', title=article.title) }}"><button type="button">Supprimer</button></a>
|
||||
<a href="{{ url_for('blog.edit', title_id=article.title_id) }}"><button type="button"> Editer </button></a>
|
||||
<a href="{{ url_for('blog.delete', title_id=article.title_id) }}"><button type="button">Supprimer</button></a>
|
||||
</article>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
48
templates/update_article.html
Normal file
48
templates/update_article.html
Normal file
@@ -0,0 +1,48 @@
|
||||
<form action="{{ url_for('blog.update') }}" method="POST" id="postform">
|
||||
<input type="text" name="title_id" id="title_id" value="{{ oldpost['title_id'] }}" style="display:none"><br />
|
||||
<input type="text" name="creation_date" id="creation_date" value="{{ oldpost['creation_date'] }}" style="display:none"><br />
|
||||
<input type="text" name="title" id="title" placeholder="titre" class="form-control" value="{{ oldpost['title'] }}"><br />
|
||||
<input type="text" name="subtitle" id="subtitle" placeholder="sous-titre" class="form-control" value="{{ oldpost['subtitle'] }}"><br />
|
||||
<input type="text" name="category" id="category" placeholder="Catégorie" class="form-control" value="{{ oldpost['category'] }}"><br />
|
||||
<textarea id="editeurMarkdown" class="form-control" form="postform" name="content" placeholder="Contenu" style="height:20vw;">{{ oldpost['content'] }}</textarea>
|
||||
<br />
|
||||
<h3> Visibilité </h3>
|
||||
|
||||
<div class="center">
|
||||
<p> Les articles brouillons ne sont visibles que par vous même</p>
|
||||
<p> Les articles privés ne sont visibles que par les membres du serveur </p>
|
||||
<p> Les articles public sont visibles par tout le monde </p>
|
||||
|
||||
|
||||
{% if oldpost['status'] == 'public' or oldpost['status'] == "public_unified" %}
|
||||
<input type="radio" name="status" value="draft"> Brouillon
|
||||
<input type="radio" name="status" value="private"> Privé
|
||||
<input type="radio" name="status" value="public" checked> Publique
|
||||
|
||||
{% elif oldpost['status'] == 'private' or oldpost['status'] == "private_unified" %}
|
||||
<input type="radio" name="status" value="draft"> Brouillon
|
||||
<input type="radio" name="status" value="private" checked> Privé
|
||||
<input type="radio" name="status" value="public"> Publique
|
||||
{% else %}
|
||||
<input type="radio" name="status" value="draft" checked> Brouillon
|
||||
<input type="radio" name="status" value="private"> Privé
|
||||
<input type="radio" name="status" value="public"> Publique
|
||||
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<fieldset>
|
||||
<label>
|
||||
|
||||
{% if oldpost['status'] == "private_unified" or oldpost['status'] == "public_unified" %}
|
||||
<input id="blog-unified" name="blog-unified" type="checkbox" role="switch" checked />
|
||||
{% else %}
|
||||
<input id="blog-unified" name="blog-unified" type="checkbox" role="switch" />
|
||||
{% endif %}
|
||||
Publier cet article dans le blog général
|
||||
</label>
|
||||
</fieldset>
|
||||
<div class="flashed {{ categorie }}" id="confirm">
|
||||
</div>
|
||||
<button type="submit"> Mettre à jour </button>
|
||||
</form>
|
||||
@@ -3,7 +3,7 @@ import sqlite3
|
||||
import os
|
||||
from tools.utils import gen_token
|
||||
from flask_bcrypt import Bcrypt
|
||||
|
||||
from markupsafe import escape
|
||||
app = Flask( 'pywallter' )
|
||||
bcrypt = Bcrypt(app)
|
||||
|
||||
@@ -36,6 +36,7 @@ def init_db(database):
|
||||
|
||||
cursor.execute("""
|
||||
CREATE TABLE IF NOT EXISTS Blog_posts(
|
||||
title_id TEXT,
|
||||
title TEXT NOT NULL,
|
||||
subtitle TEXT,
|
||||
comments TEXT,
|
||||
@@ -45,7 +46,7 @@ def init_db(database):
|
||||
category TEXT,
|
||||
author TEXT,
|
||||
status TEXT,
|
||||
PRIMARY KEY(title, author)
|
||||
PRIMARY KEY(title_id, author)
|
||||
)
|
||||
""")
|
||||
conn.commit()
|
||||
@@ -83,6 +84,7 @@ def db_migrate(database):
|
||||
updated_col = False
|
||||
creation_date_col = False
|
||||
content_col = False
|
||||
title_id_col = False
|
||||
|
||||
conn = sqlite3.connect(database)
|
||||
cursor = conn.cursor()
|
||||
@@ -111,7 +113,8 @@ def db_migrate(database):
|
||||
creation_date_col= True
|
||||
if "category" == col[0]:
|
||||
category_col= True
|
||||
|
||||
if "title_id" == col[0]:
|
||||
title_id_col = True
|
||||
|
||||
if not(invitations_col):
|
||||
cursor.execute("""ALTER TABLE users ADD COLUMN invitations INTEGER DEFAULT (20);""")
|
||||
@@ -157,4 +160,44 @@ def db_migrate(database):
|
||||
conn.commit()
|
||||
print ("Ajout de la colono category")
|
||||
|
||||
|
||||
if not(title_id_col):
|
||||
cursor.execute("""SELECT title, subtitle, content, creation_date, category, comments, last_updated, author, status FROM Blog_posts;""")
|
||||
list_posts=cursor.fetchall()
|
||||
cursor.execute("""DROP TABLE Blog_posts""")
|
||||
conn.commit()
|
||||
cursor.execute("""
|
||||
CREATE TABLE Blog_posts(
|
||||
title_id TEXT,
|
||||
title TEXT NOT NULL,
|
||||
subtitle TEXT,
|
||||
comments TEXT,
|
||||
content TEXT,
|
||||
creation_date TEXT,
|
||||
last_updated TEXT,
|
||||
category TEXT,
|
||||
author TEXT,
|
||||
status TEXT,
|
||||
PRIMARY KEY(title_id, author)
|
||||
)
|
||||
""")
|
||||
conn.commit()
|
||||
if list_posts != None:
|
||||
for post in list_posts:
|
||||
title_id=escape(post[0])
|
||||
title = post[0]
|
||||
subtitle = post[1]
|
||||
content = post[2]
|
||||
creation_date = post[3]
|
||||
category = post[4]
|
||||
comments = post[5]
|
||||
last_updated = post[6]
|
||||
author = post[7]
|
||||
status = post[8]
|
||||
cursor.execute("""INSERT INTO Blog_posts(title_id, title, subtitle, category, content, creation_date, last_updated, author, status)
|
||||
VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)""", (title_id, title, subtitle, category, content, creation_date, last_updated, author, status))
|
||||
#Après le for on commit les transations
|
||||
conn.commit()
|
||||
print ("migration de l'anciene base de donnée de blog")
|
||||
|
||||
conn.close()
|
||||
|
||||
147
views/blog.py
147
views/blog.py
@@ -33,79 +33,74 @@ MARKDOWN_EXT=["extra", "toc", "codehilite",
|
||||
@login_required
|
||||
def new_article():
|
||||
user = '%s' % escape(session['username'])
|
||||
|
||||
if request.method == 'POST':
|
||||
title = strOB(request.form['title'].rstrip())
|
||||
subtitle = str(request.form['subtitle'])
|
||||
category = str(request.form['category'])
|
||||
content = str(request.form['content'])
|
||||
status = str(request.form['status'])
|
||||
title_id = escape(request.form['title'].rstrip())
|
||||
title = request.form['title'].rstrip()
|
||||
subtitle = request.form['subtitle']
|
||||
category = request.form['category']
|
||||
content = request.form['content']
|
||||
status = request.form['status']
|
||||
post_date = time.strftime("%d/%m/%Y %H:%M:%S")
|
||||
if 'blog-unified' in request.form.keys():
|
||||
status = status+'_unified'
|
||||
|
||||
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
|
||||
cursor = conn.cursor() # Création de l'objet "curseur"
|
||||
cursor.execute("""INSERT INTO Blog_posts(title, subtitle, category, content, creation_date, author, status) VALUES(?, ?, ?, ?, ?, ?, ?)""", (title, subtitle, category, content, post_date, user, status)) # Insérer des valeurs
|
||||
cursor.execute("""INSERT INTO Blog_posts(title_id, title, subtitle, category, content, creation_date, author, status) VALUES(?, ?, ?, ?, ?, ?, ?, ?)""", (title_id, title, subtitle, category, content, post_date, user, status)) # Insérer des valeurs
|
||||
conn.commit()
|
||||
|
||||
return redirect(url_for('blog.list_articles_blog'))
|
||||
else:
|
||||
return render_template('new_article_blog.html')
|
||||
|
||||
@blog.route('/myblog/edit/<title>', methods=['GET', 'POST'])
|
||||
@blog.route('/myblog/edit/<title_id>', methods=['GET'])
|
||||
@login_required
|
||||
def edit(title):
|
||||
def edit(title_id):
|
||||
user = '%s' % escape(session['username'])
|
||||
folder_blog = DOSSIER_PERSO + user + "/blog/articles/"
|
||||
if request.method == 'POST' :
|
||||
newtitle = str(request.form['title'].rstrip())
|
||||
subtitle = str(request.form['subtitle'])
|
||||
category = str(request.form['category'])
|
||||
newcontent = str(request.form['content'])
|
||||
newstatus = str(request.form['status'])
|
||||
updated = time.strftime("%d/%m/%Y %H:%M:%S")
|
||||
conn = sqlite3.connect(DATABASE)
|
||||
cursor = conn.cursor()
|
||||
if 'blog-unified' in request.form.keys():
|
||||
newstatus = newstatus+'_unified'
|
||||
|
||||
cursor.execute("""UPDATE Blog_posts SET title=?, subtitle=?, category=?, last_updated=?, status=?, content=? WHERE title=? AND author=?""", (newtitle, subtitle, category, updated, newstatus, newcontent, title, user))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return redirect(url_for('blog.list_articles_blog'))
|
||||
else:
|
||||
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
|
||||
cursor = conn.cursor() # Création de l'objet "curseur"
|
||||
cursor.execute("""SELECT title, subtitle, category, content, status FROM Blog_posts WHERE title=? AND author=?""", (title, user))
|
||||
cursor.execute("""SELECT title_id, title, subtitle, creation_date, category, content, status FROM Blog_posts WHERE title_id=? AND author=?""", (title_id, user))
|
||||
oldpost = cursor.fetchone()
|
||||
post = dict(title_id=oldpost[0], title=oldpost[1], subtitle=oldpost[2], creation_date=oldpost[3], category=oldpost[4], content=oldpost[5], status=oldpost[6])
|
||||
|
||||
conn.close()
|
||||
post = dict(title=oldpost[0], subtitle=oldpost[1], category=oldpost[2], content=oldpost[3], status=oldpost[4])
|
||||
|
||||
return render_template('edit_article.html',
|
||||
section='Post-it',
|
||||
oldpost=post)
|
||||
|
||||
|
||||
@blog.route('/myblog/update/<title>', methods=['POST'])
|
||||
@blog.route('/myblog/update_blogpost', methods=['POST'])
|
||||
@login_required
|
||||
def update(title):
|
||||
def update():
|
||||
user = '%s' % escape(session['username'])
|
||||
folder_blog = DOSSIER_PERSO + user + "/blog/articles/"
|
||||
newtitle = str(request.form['title']).encode()
|
||||
title_id = str(request.form['title_id'])
|
||||
title = str(request.form['title'])
|
||||
subtitle = str(request.form['subtitle'])
|
||||
creation_date = str(request.form['creation_date'])
|
||||
category = str(request.form['category'])
|
||||
newcontent = str(request.form['content'])
|
||||
newstatus = str(request.form['status'])
|
||||
updated = time.strftime("%d/%m/%Y à %H:%M:%S")
|
||||
content = str(request.form['content'])
|
||||
status = str(request.form['status'])
|
||||
updated = time.strftime("%d/%m/%Y %H:%M:%S")
|
||||
conn = sqlite3.connect(DATABASE)
|
||||
cursor = conn.cursor()
|
||||
if 'blog-unified' in request.form.keys():
|
||||
newstatus = newstatus+'_unified'
|
||||
status = status+'_unified'
|
||||
|
||||
cursor.execute("""UPDATE Blog_posts SET title=?, subtitle=?, category=?, last_updated=?, status=?, content=? WHERE title=? AND author=?""", (newtitle, subtitle, category, updated, newstatus, newcontent, title, user))
|
||||
cursor.execute("""DELETE FROM Blog_posts WHERE title_id=? AND author=?""", (title_id, user))
|
||||
cursor.execute("""INSERT INTO Blog_posts(title_id, title, subtitle, category, content, creation_date, last_updated, author, status)VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)""",
|
||||
(title_id, title, subtitle, category, content, creation_date, updated, user, status))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
response = """ <p class="center success" >Article mis à jour le """+ updated +""" .</p>"""
|
||||
return response
|
||||
|
||||
post = dict(title_id=title_id, title=title, subtitle=subtitle, category=category, content=content, status=status)
|
||||
flash(u'Article mis à jour avec succès le: '+ updated , 'success' )
|
||||
return render_template('edit_article.html',
|
||||
section='Post-it',
|
||||
oldpost=post)
|
||||
|
||||
|
||||
|
||||
@blog.route('/myblog/list-articles/', methods=['GET'])
|
||||
@login_required
|
||||
@@ -113,16 +108,17 @@ def list_articles_blog():
|
||||
user = '%s' % escape(session['username'])
|
||||
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
|
||||
cursor = conn.cursor() # Création de l'objet "curseur"
|
||||
cursor.execute("""SELECT title, subtitle, creation_date, last_updated, status FROM Blog_posts WHERE author=? """, (user,) )
|
||||
cursor.execute("""SELECT title_id, title, subtitle, creation_date, last_updated, status FROM Blog_posts WHERE author=? """, (user,) )
|
||||
list_posts=cursor.fetchall()
|
||||
posts=list()
|
||||
nb_articles=0
|
||||
for post in list_posts:
|
||||
posts = [dict(title=post[0],
|
||||
subtitle=post[1],
|
||||
time=post[2],
|
||||
last_updated=post[3],
|
||||
status=post[4])] + posts
|
||||
posts = [dict(title_id=post[0],
|
||||
title=post[1],
|
||||
subtitle=post[2],
|
||||
time=post[3],
|
||||
last_updated=post[4],
|
||||
status=post[5])] + posts
|
||||
nb_articles = nb_articles + 1
|
||||
|
||||
return render_template('list_articles.html',
|
||||
@@ -130,16 +126,16 @@ def list_articles_blog():
|
||||
list_posts=posts,
|
||||
nb_articles=nb_articles )
|
||||
|
||||
@blog.route('/myblog/delete/<title>')
|
||||
@blog.route('/myblog/delete/<title_id>')
|
||||
@login_required
|
||||
def delete(title):
|
||||
title = escape(title)
|
||||
def delete(title_id):
|
||||
title_id = '%s' % str(title_id).rstrip()
|
||||
user='%s'% escape(session['username'])
|
||||
folder_blog = DOSSIER_PERSO + user + "/blog/articles/"
|
||||
folder_blog_public = DOSSIER_PUBLIC + user + "/blog/articles/"
|
||||
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
|
||||
cursor = conn.cursor() # Création de l'objet "curseur"
|
||||
cursor.execute("""DELETE FROM Blog_posts WHERE title=? AND author=?""", (title, user))
|
||||
cursor.execute("""DELETE FROM Blog_posts WHERE title_id=? AND author=?""", (title_id, user))
|
||||
conn.commit()
|
||||
conn.close()
|
||||
return redirect(url_for('blog.list_articles_blog'))
|
||||
@@ -183,14 +179,14 @@ def viewmyblog():
|
||||
user='%s' % escape(session['username'])
|
||||
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
|
||||
cursor = conn.cursor() # Création de l'objet "curseur"
|
||||
cursor.execute("""SELECT title, subtitle, creation_date, author, status FROM Blog_posts WHERE author=? AND status!='draft'""", (user,))
|
||||
cursor.execute("""SELECT title_id, title, subtitle, creation_date, author, status FROM Blog_posts WHERE author=? AND status!='draft'""", (user,))
|
||||
list_posts=cursor.fetchall()
|
||||
posts=list()
|
||||
id=0
|
||||
conn.close()
|
||||
if list_posts != None:
|
||||
for post in list_posts:
|
||||
posts=[dict(title=post[0], subtitle=post[1], creation_date=post[2], author=post[3], status=post[4])] + posts
|
||||
posts=[dict(title_id=post[0], title=post[1], subtitle=post[2], creation_date=post[3], author=post[4], status=post[5])] + posts
|
||||
|
||||
return render_template('index_blog.html', section='Blog', posts=posts, author=user)
|
||||
|
||||
@@ -200,14 +196,14 @@ def viewmyblog():
|
||||
def view_internal():
|
||||
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
|
||||
cursor = conn.cursor() # Création de l'objet "curseur"
|
||||
cursor.execute("""SELECT title, subtitle, content, creation_date, last_updated, author, status FROM Blog_posts WHERE status='private_unified' OR status='public_unified' """ )
|
||||
cursor.execute("""SELECT title_id, title, subtitle, content, creation_date, last_updated, author, status FROM Blog_posts WHERE status='private_unified' OR status='public_unified' """ )
|
||||
list_posts=cursor.fetchall()
|
||||
conn.close()
|
||||
posts=list()
|
||||
id=0
|
||||
if list_posts != None:
|
||||
for post in list_posts:
|
||||
posts = [dict(title=post[0], subtitle=post[1], content=post[2], creation_date=post[3], last_updated=post[4], author=post[5], status=post[6] )] + posts
|
||||
posts = [dict(title_id=[0], title=post[1], subtitle=post[2], content=post[3], creation_date=post[4], last_updated=post[5], author=post[6], status=post[7] )] + posts
|
||||
else:
|
||||
return redirect(BASE_URL, code=404)
|
||||
|
||||
@@ -224,7 +220,7 @@ def view():
|
||||
conn.close()
|
||||
if list_posts != None:
|
||||
for post in list_posts:
|
||||
posts=[dict(title=post[0], subtitle=post[1], creation_date=post[2], author=post[3], status=post[4])] + posts
|
||||
posts=[dict(title_id=post[0], title=post[1], subtitle=post[2], creation_date=post[3], author=post[4], status=post[5])] + posts
|
||||
|
||||
return render_template('index_blog.html', section='Blog', posts=posts)
|
||||
|
||||
@@ -235,9 +231,9 @@ def viewuser(author):
|
||||
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
|
||||
cursor = conn.cursor() # Création de l'objet "curseur"
|
||||
if 'username' in session :
|
||||
cursor.execute("""SELECT title, subtitle, creation_date, last_updated, author, status FROM Blog_posts WHERE author=? AND status != 'draft' """, (author,))
|
||||
cursor.execute("""SELECT title_id, title, subtitle, creation_date, last_updated, author, status FROM Blog_posts WHERE author=? AND status != 'draft' """, (author,))
|
||||
else:
|
||||
cursor.execute("""SELECT title, subtitle, creation_date, last_updated, author, status FROM Blog_posts WHERE author=? AND status='public' OR status='public_unified' """, (author,))
|
||||
cursor.execute("""SELECT title_id, title, subtitle, creation_date, last_updated, author, status FROM Blog_posts WHERE author=? AND status='public' OR status='public_unified' """, (author,))
|
||||
list_posts=cursor.fetchall()
|
||||
posts=None
|
||||
id=0
|
||||
@@ -245,7 +241,7 @@ def viewuser(author):
|
||||
if list_posts != None:
|
||||
posts=list()
|
||||
for post in list_posts:
|
||||
posts=[dict(title=post[0], subtitle=post[1], creation_date=post[2], last_updated=post[3], author=post[4], status=post[5])] + posts
|
||||
posts=[dict(title_id=post[0], title=post[1], subtitle=post[2], creation_date=post[3], last_updated=post[4], author=post[5], status=post[6])] + posts
|
||||
|
||||
|
||||
return render_template('index_blog.html', section='Blog', posts=posts, author=author)
|
||||
@@ -264,7 +260,8 @@ def viewauthorrss(author):
|
||||
if list_posts != None:
|
||||
last_build=last_article_date[0]
|
||||
for post in list_posts:
|
||||
posts=[dict(title=post[0], subtitle=post[1], content=markdown(post[2], extensions=MARKDOWN_EXT), creation_date=post[3], author=post[4], status=post[5])] + posts
|
||||
posts=[dict(title_id[0], title=post[1], subtitle=post[2], content=markdown(post[3], extensions=MARKDOWN_EXT), creation_date=post[4],
|
||||
author=post[5], status=post[6])] + posts
|
||||
|
||||
return render_template('blog_rss.xml',
|
||||
base_url=BASE_URL,
|
||||
@@ -273,37 +270,36 @@ def viewauthorrss(author):
|
||||
posts=posts)
|
||||
|
||||
|
||||
@blog.route('/blog/private_unified/<username>/<title>', methods=['GET'])
|
||||
@blog.route('/blog/private/<username>/<title>', methods=['GET'])
|
||||
@blog.route('/blog/private_unified/<username>/<title_id>', methods=['GET'])
|
||||
@blog.route('/blog/private/<username>/<title_id>', methods=['GET'])
|
||||
@login_required
|
||||
def viewPrivateArticle(username, title):
|
||||
user = escape(username)
|
||||
title = escape(title)
|
||||
def viewPrivateArticle(username, title_id):
|
||||
user = '%s' % escape(username)
|
||||
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
|
||||
cursor = conn.cursor() # Création de l'objet "curseur"
|
||||
cursor.execute("""SELECT title, subtitle, content, creation_date, last_updated, author, status FROM Blog_posts WHERE author=? AND title=? AND status!='draft' """, (user, title))
|
||||
cursor.execute("""SELECT title_id, title, subtitle, content, creation_date, last_updated, author, status FROM Blog_posts WHERE author=? AND title_id=? AND status!='draft' """, (user, title_id))
|
||||
post = cursor.fetchone()
|
||||
conn.close()
|
||||
if post != None:
|
||||
post_info = (dict(title=post[0], subtitle=post[1], creation_date=post[3], last_updated=post[4],author=post[5]))
|
||||
content = markdown(post[2], extensions=MARKDOWN_EXT)
|
||||
post_info = (dict(title_id=post[0], title=post[1], subtitle=post[2], creation_date=post[4], last_updated=post[5],author=post[6]))
|
||||
content = markdown(post[3], extensions=MARKDOWN_EXT)
|
||||
return render_template('blog.html', post_info=post_info, content=content)
|
||||
else:
|
||||
return redirect(url_for('blog'), code=404)
|
||||
|
||||
|
||||
@blog.route('/blog/public_unified/<username>/<title>', methods=['GET'])
|
||||
@blog.route('/blog/public/<username>/<title>', methods=['GET'])
|
||||
def viewArticle(username, title):
|
||||
user = username
|
||||
@blog.route('/blog/public_unified/<username>/<title_id>', methods=['GET'])
|
||||
@blog.route('/blog/public/<username>/<title_id>', methods=['GET'])
|
||||
def viewArticle(username, title_id):
|
||||
user = '%s' % escape(username)
|
||||
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
|
||||
cursor = conn.cursor() # Création de l'objet "curseur"
|
||||
cursor.execute("""SELECT title, subtitle, content, creation_date, last_updated, author FROM Blog_posts WHERE author=? AND title=? AND status='public_unified' """, (user, title) )
|
||||
cursor.execute("""SELECT title_id, title, subtitle, content, creation_date, last_updated, author FROM Blog_posts WHERE author=? AND title=? AND status='public_unified' """, (user, title_id) )
|
||||
post = cursor.fetchone()
|
||||
conn.close()
|
||||
if post != None:
|
||||
post_info = (dict(title=post[0], subtitle=post[1], creation_date=post[3], last_updated=post[4],author=post[5]))
|
||||
content= markdown(post[2], extensions=MARKDOWN_EXT)
|
||||
post_info = (dict(title_id=post[0], title=post[1], subtitle=post[2], creation_date=post[4], last_updated=post[5],author=post[6]))
|
||||
content= markdown(post[3], extensions=MARKDOWN_EXT)
|
||||
|
||||
return render_template('blog.html', post_info=post_info, content=content)
|
||||
else:
|
||||
@@ -316,7 +312,7 @@ def viewrss():
|
||||
cursor.execute("""SELECT MAX(creation_date) FROM Blog_posts WHERE status='public_unified'""")
|
||||
last_article_date = cursor.fetchone()
|
||||
print (last_article_date[0])
|
||||
cursor.execute("""SELECT title, subtitle, content, creation_date, author, status FROM Blog_posts WHERE status='public_unified'""" )
|
||||
cursor.execute("""SELECT title_id, title, subtitle, content, creation_date, author, status FROM Blog_posts WHERE status='public_unified'""" )
|
||||
list_posts=cursor.fetchall()
|
||||
posts=list()
|
||||
id=0
|
||||
@@ -324,7 +320,8 @@ def viewrss():
|
||||
if list_posts != None:
|
||||
last_build=last_article_date[0]
|
||||
for post in list_posts:
|
||||
posts=[dict(title=post[0], subtitle=post[1], content=markdown(post[2], extensions=MARKDOWN_EXT), creation_date=post[3], author=post[4], status=post[5])] + posts
|
||||
posts=[dict(title_id=post[0], title=post[1], subtitle=post[2], content=markdown(post[3], extensions=MARKDOWN_EXT), creation_date=post[4],
|
||||
author=post[5], status=post[6])] + posts
|
||||
|
||||
return render_template('blog_rss.xml',
|
||||
base_url=BASE_URL,
|
||||
|
||||
Reference in New Issue
Block a user