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 {
|
article {
|
||||||
width: 44vw;
|
min-width: 45vw;
|
||||||
max-height: 35vw;
|
max-width:50vw;
|
||||||
|
max-height: 40vw;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
article > header {
|
article > header {
|
||||||
height: 20vw;
|
height: fit-content;
|
||||||
}
|
}
|
||||||
|
|
||||||
article > .subtitle {
|
article > .subtitle {
|
||||||
height: 10vw;
|
height: fit-content;
|
||||||
}
|
|
||||||
article footer{
|
|
||||||
display: block;
|
|
||||||
height: 10vw;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,9 @@
|
|||||||
</div>
|
</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>
|
</article>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@
|
|||||||
<item>
|
<item>
|
||||||
<title> {{ post.title }} </title>
|
<title> {{ post.title }} </title>
|
||||||
<pubdate> {% if post.last_updated %} {{ post.last_updated }} {% else %} {{ post.time }} {% endif %} </pubdate>
|
<pubdate> {% if post.last_updated %} {{ post.last_updated }} {% else %} {{ post.time }} {% endif %} </pubdate>
|
||||||
<link> {{base_url}}/blog/{{ post.status }}/{{post.author}}/{{post.title}}</link>
|
<link> {{base_url}}/blog/{{ post.status }}/{{post.author}}/{{post.title_id}}</link>
|
||||||
<guid> {{base_url}}/blog/{{ post.status }}/{{post.author}}/{{post.title}}</guid>
|
<guid> {{base_url}}/blog/{{ post.status }}/{{post.author}}/{{post.title_id}}</guid>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
{{ post.subtitle }}
|
{{ post.subtitle }}
|
||||||
|
|||||||
@@ -6,55 +6,7 @@
|
|||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
|
|
||||||
|
{% include 'update_article.html' %}
|
||||||
<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>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
</small>
|
</small>
|
||||||
<div class="slug">
|
<div class="slug">
|
||||||
<p> {{ post.subtitle }} </p>
|
<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>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
</small>
|
</small>
|
||||||
<div class="slug">
|
<div class="slug">
|
||||||
<p> {{ post.subtitle }} </p>
|
<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>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -36,8 +36,8 @@
|
|||||||
<br/>
|
<br/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<a href="{{ url_for('blog.edit', title=article.title) }}"><button type="button"> Editer </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=article.title) }}"><button type="button">Supprimer</button></a>
|
<a href="{{ url_for('blog.delete', title_id=article.title_id) }}"><button type="button">Supprimer</button></a>
|
||||||
</article>
|
</article>
|
||||||
{% endfor %}
|
{% 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
|
import os
|
||||||
from tools.utils import gen_token
|
from tools.utils import gen_token
|
||||||
from flask_bcrypt import Bcrypt
|
from flask_bcrypt import Bcrypt
|
||||||
|
from markupsafe import escape
|
||||||
app = Flask( 'pywallter' )
|
app = Flask( 'pywallter' )
|
||||||
bcrypt = Bcrypt(app)
|
bcrypt = Bcrypt(app)
|
||||||
|
|
||||||
@@ -36,6 +36,7 @@ def init_db(database):
|
|||||||
|
|
||||||
cursor.execute("""
|
cursor.execute("""
|
||||||
CREATE TABLE IF NOT EXISTS Blog_posts(
|
CREATE TABLE IF NOT EXISTS Blog_posts(
|
||||||
|
title_id TEXT,
|
||||||
title TEXT NOT NULL,
|
title TEXT NOT NULL,
|
||||||
subtitle TEXT,
|
subtitle TEXT,
|
||||||
comments TEXT,
|
comments TEXT,
|
||||||
@@ -45,7 +46,7 @@ def init_db(database):
|
|||||||
category TEXT,
|
category TEXT,
|
||||||
author TEXT,
|
author TEXT,
|
||||||
status TEXT,
|
status TEXT,
|
||||||
PRIMARY KEY(title, author)
|
PRIMARY KEY(title_id, author)
|
||||||
)
|
)
|
||||||
""")
|
""")
|
||||||
conn.commit()
|
conn.commit()
|
||||||
@@ -83,6 +84,7 @@ def db_migrate(database):
|
|||||||
updated_col = False
|
updated_col = False
|
||||||
creation_date_col = False
|
creation_date_col = False
|
||||||
content_col = False
|
content_col = False
|
||||||
|
title_id_col = False
|
||||||
|
|
||||||
conn = sqlite3.connect(database)
|
conn = sqlite3.connect(database)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
@@ -111,7 +113,8 @@ def db_migrate(database):
|
|||||||
creation_date_col= True
|
creation_date_col= True
|
||||||
if "category" == col[0]:
|
if "category" == col[0]:
|
||||||
category_col= True
|
category_col= True
|
||||||
|
if "title_id" == col[0]:
|
||||||
|
title_id_col = True
|
||||||
|
|
||||||
if not(invitations_col):
|
if not(invitations_col):
|
||||||
cursor.execute("""ALTER TABLE users ADD COLUMN invitations INTEGER DEFAULT (20);""")
|
cursor.execute("""ALTER TABLE users ADD COLUMN invitations INTEGER DEFAULT (20);""")
|
||||||
@@ -152,9 +155,49 @@ def db_migrate(database):
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
print ("Time renomé en creation_date")
|
print ("Time renomé en creation_date")
|
||||||
|
|
||||||
if not(category_col):
|
if not(category_col):
|
||||||
cursor.execute("""ALTER TABLE Blog_posts ADD COLUMN category TEXT;""")
|
cursor.execute("""ALTER TABLE Blog_posts ADD COLUMN category TEXT;""")
|
||||||
conn.commit()
|
conn.commit()
|
||||||
print ("Ajout de la colono category")
|
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()
|
conn.close()
|
||||||
|
|||||||
163
views/blog.py
163
views/blog.py
@@ -32,97 +32,93 @@ MARKDOWN_EXT=["extra", "toc", "codehilite",
|
|||||||
@blog.route('/myblog/new-article/', methods=['GET', 'POST'])
|
@blog.route('/myblog/new-article/', methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def new_article():
|
def new_article():
|
||||||
user = '%s'% escape(session['username'])
|
user = '%s' % escape(session['username'])
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
title = strOB(request.form['title'].rstrip())
|
title_id = escape(request.form['title'].rstrip())
|
||||||
subtitle = str(request.form['subtitle'])
|
title = request.form['title'].rstrip()
|
||||||
category = str(request.form['category'])
|
subtitle = request.form['subtitle']
|
||||||
content = str(request.form['content'])
|
category = request.form['category']
|
||||||
status = str(request.form['status'])
|
content = request.form['content']
|
||||||
|
status = request.form['status']
|
||||||
post_date = time.strftime("%d/%m/%Y %H:%M:%S")
|
post_date = time.strftime("%d/%m/%Y %H:%M:%S")
|
||||||
if 'blog-unified' in request.form.keys():
|
if 'blog-unified' in request.form.keys():
|
||||||
status = status+'_unified'
|
status = status+'_unified'
|
||||||
|
|
||||||
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("""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()
|
conn.commit()
|
||||||
|
|
||||||
return redirect(url_for('blog.list_articles_blog'))
|
return redirect(url_for('blog.list_articles_blog'))
|
||||||
else:
|
else:
|
||||||
return render_template('new_article_blog.html')
|
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
|
@login_required
|
||||||
def edit(title):
|
def edit(title_id):
|
||||||
user='%s'% escape(session['username'])
|
user = '%s' % escape(session['username'])
|
||||||
folder_blog = DOSSIER_PERSO + user + "/blog/articles/"
|
conn = sqlite3.connect(DATABASE) # Connexion à la base de donnée
|
||||||
if request.method == 'POST' :
|
cursor = conn.cursor() # Création de l'objet "curseur"
|
||||||
newtitle = str(request.form['title'].rstrip())
|
cursor.execute("""SELECT title_id, title, subtitle, creation_date, category, content, status FROM Blog_posts WHERE title_id=? AND author=?""", (title_id, user))
|
||||||
subtitle = str(request.form['subtitle'])
|
oldpost = cursor.fetchone()
|
||||||
category = str(request.form['category'])
|
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])
|
||||||
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.close()
|
||||||
conn.commit()
|
|
||||||
conn.close()
|
return render_template('edit_article.html',
|
||||||
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))
|
|
||||||
oldpost = cursor.fetchone()
|
|
||||||
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',
|
section='Post-it',
|
||||||
oldpost=post)
|
oldpost=post)
|
||||||
|
|
||||||
|
|
||||||
@blog.route('/myblog/update/<title>', methods=['POST'])
|
@blog.route('/myblog/update_blogpost', methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def update(title):
|
def update():
|
||||||
user='%s'% escape(session['username'])
|
user = '%s' % escape(session['username'])
|
||||||
folder_blog = DOSSIER_PERSO + user + "/blog/articles/"
|
title_id = str(request.form['title_id'])
|
||||||
newtitle = str(request.form['title']).encode()
|
title = str(request.form['title'])
|
||||||
subtitle = str(request.form['subtitle'])
|
subtitle = str(request.form['subtitle'])
|
||||||
|
creation_date = str(request.form['creation_date'])
|
||||||
category = str(request.form['category'])
|
category = str(request.form['category'])
|
||||||
newcontent = str(request.form['content'])
|
content = str(request.form['content'])
|
||||||
newstatus = str(request.form['status'])
|
status = str(request.form['status'])
|
||||||
updated = time.strftime("%d/%m/%Y à %H:%M:%S")
|
updated = time.strftime("%d/%m/%Y %H:%M:%S")
|
||||||
conn = sqlite3.connect(DATABASE)
|
conn = sqlite3.connect(DATABASE)
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
if 'blog-unified' in request.form.keys():
|
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.commit()
|
||||||
conn.close()
|
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'])
|
@blog.route('/myblog/list-articles/', methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
def list_articles_blog():
|
def list_articles_blog():
|
||||||
user = '%s'% escape(session['username'])
|
user = '%s' % escape(session['username'])
|
||||||
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, 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()
|
list_posts=cursor.fetchall()
|
||||||
posts=list()
|
posts=list()
|
||||||
nb_articles=0
|
nb_articles=0
|
||||||
for post in list_posts:
|
for post in list_posts:
|
||||||
posts = [dict(title=post[0],
|
posts = [dict(title_id=post[0],
|
||||||
subtitle=post[1],
|
title=post[1],
|
||||||
time=post[2],
|
subtitle=post[2],
|
||||||
last_updated=post[3],
|
time=post[3],
|
||||||
status=post[4])] + posts
|
last_updated=post[4],
|
||||||
|
status=post[5])] + posts
|
||||||
nb_articles = nb_articles + 1
|
nb_articles = nb_articles + 1
|
||||||
|
|
||||||
return render_template('list_articles.html',
|
return render_template('list_articles.html',
|
||||||
@@ -130,16 +126,16 @@ def list_articles_blog():
|
|||||||
list_posts=posts,
|
list_posts=posts,
|
||||||
nb_articles=nb_articles )
|
nb_articles=nb_articles )
|
||||||
|
|
||||||
@blog.route('/myblog/delete/<title>')
|
@blog.route('/myblog/delete/<title_id>')
|
||||||
@login_required
|
@login_required
|
||||||
def delete(title):
|
def delete(title_id):
|
||||||
title = escape(title)
|
title_id = '%s' % str(title_id).rstrip()
|
||||||
user='%s'% escape(session['username'])
|
user='%s'% escape(session['username'])
|
||||||
folder_blog = DOSSIER_PERSO + user + "/blog/articles/"
|
folder_blog = DOSSIER_PERSO + user + "/blog/articles/"
|
||||||
folder_blog_public = DOSSIER_PUBLIC + user + "/blog/articles/"
|
folder_blog_public = DOSSIER_PUBLIC + user + "/blog/articles/"
|
||||||
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("""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.commit()
|
||||||
conn.close()
|
conn.close()
|
||||||
return redirect(url_for('blog.list_articles_blog'))
|
return redirect(url_for('blog.list_articles_blog'))
|
||||||
@@ -183,14 +179,14 @@ def viewmyblog():
|
|||||||
user='%s' % escape(session['username'])
|
user='%s' % escape(session['username'])
|
||||||
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, 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()
|
list_posts=cursor.fetchall()
|
||||||
posts=list()
|
posts=list()
|
||||||
id=0
|
id=0
|
||||||
conn.close()
|
conn.close()
|
||||||
if list_posts != None:
|
if list_posts != None:
|
||||||
for post in list_posts:
|
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)
|
return render_template('index_blog.html', section='Blog', posts=posts, author=user)
|
||||||
|
|
||||||
@@ -200,14 +196,14 @@ def viewmyblog():
|
|||||||
def view_internal():
|
def view_internal():
|
||||||
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, 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()
|
list_posts=cursor.fetchall()
|
||||||
conn.close()
|
conn.close()
|
||||||
posts=list()
|
posts=list()
|
||||||
id=0
|
id=0
|
||||||
if list_posts != None:
|
if list_posts != None:
|
||||||
for post in list_posts:
|
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:
|
else:
|
||||||
return redirect(BASE_URL, code=404)
|
return redirect(BASE_URL, code=404)
|
||||||
|
|
||||||
@@ -224,7 +220,7 @@ def view():
|
|||||||
conn.close()
|
conn.close()
|
||||||
if list_posts != None:
|
if list_posts != None:
|
||||||
for post in list_posts:
|
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)
|
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
|
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"
|
||||||
if 'username' in session :
|
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:
|
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()
|
list_posts=cursor.fetchall()
|
||||||
posts=None
|
posts=None
|
||||||
id=0
|
id=0
|
||||||
@@ -245,7 +241,7 @@ def viewuser(author):
|
|||||||
if list_posts != None:
|
if list_posts != None:
|
||||||
posts=list()
|
posts=list()
|
||||||
for post in list_posts:
|
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)
|
return render_template('index_blog.html', section='Blog', posts=posts, author=author)
|
||||||
@@ -264,7 +260,8 @@ def viewauthorrss(author):
|
|||||||
if list_posts != None:
|
if list_posts != None:
|
||||||
last_build=last_article_date[0]
|
last_build=last_article_date[0]
|
||||||
for post in list_posts:
|
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',
|
return render_template('blog_rss.xml',
|
||||||
base_url=BASE_URL,
|
base_url=BASE_URL,
|
||||||
@@ -273,37 +270,36 @@ def viewauthorrss(author):
|
|||||||
posts=posts)
|
posts=posts)
|
||||||
|
|
||||||
|
|
||||||
@blog.route('/blog/private_unified/<username>/<title>', methods=['GET'])
|
@blog.route('/blog/private_unified/<username>/<title_id>', methods=['GET'])
|
||||||
@blog.route('/blog/private/<username>/<title>', methods=['GET'])
|
@blog.route('/blog/private/<username>/<title_id>', methods=['GET'])
|
||||||
@login_required
|
@login_required
|
||||||
def viewPrivateArticle(username, title):
|
def viewPrivateArticle(username, title_id):
|
||||||
user = escape(username)
|
user = '%s' % escape(username)
|
||||||
title = escape(title)
|
|
||||||
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, 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()
|
post = cursor.fetchone()
|
||||||
conn.close()
|
conn.close()
|
||||||
if post != None:
|
if post != None:
|
||||||
post_info = (dict(title=post[0], subtitle=post[1], creation_date=post[3], last_updated=post[4],author=post[5]))
|
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[2], extensions=MARKDOWN_EXT)
|
content = markdown(post[3], extensions=MARKDOWN_EXT)
|
||||||
return render_template('blog.html', post_info=post_info, content=content)
|
return render_template('blog.html', post_info=post_info, content=content)
|
||||||
else:
|
else:
|
||||||
return redirect(url_for('blog'), code=404)
|
return redirect(url_for('blog'), code=404)
|
||||||
|
|
||||||
|
|
||||||
@blog.route('/blog/public_unified/<username>/<title>', methods=['GET'])
|
@blog.route('/blog/public_unified/<username>/<title_id>', methods=['GET'])
|
||||||
@blog.route('/blog/public/<username>/<title>', methods=['GET'])
|
@blog.route('/blog/public/<username>/<title_id>', methods=['GET'])
|
||||||
def viewArticle(username, title):
|
def viewArticle(username, title_id):
|
||||||
user = username
|
user = '%s' % escape(username)
|
||||||
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, 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()
|
post = cursor.fetchone()
|
||||||
conn.close()
|
conn.close()
|
||||||
if post != None:
|
if post != None:
|
||||||
post_info = (dict(title=post[0], subtitle=post[1], creation_date=post[3], last_updated=post[4],author=post[5]))
|
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[2], extensions=MARKDOWN_EXT)
|
content= markdown(post[3], extensions=MARKDOWN_EXT)
|
||||||
|
|
||||||
return render_template('blog.html', post_info=post_info, content=content)
|
return render_template('blog.html', post_info=post_info, content=content)
|
||||||
else:
|
else:
|
||||||
@@ -316,7 +312,7 @@ def viewrss():
|
|||||||
cursor.execute("""SELECT MAX(creation_date) FROM Blog_posts WHERE status='public_unified'""")
|
cursor.execute("""SELECT MAX(creation_date) FROM Blog_posts WHERE status='public_unified'""")
|
||||||
last_article_date = cursor.fetchone()
|
last_article_date = cursor.fetchone()
|
||||||
print (last_article_date[0])
|
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()
|
list_posts=cursor.fetchall()
|
||||||
posts=list()
|
posts=list()
|
||||||
id=0
|
id=0
|
||||||
@@ -324,7 +320,8 @@ def viewrss():
|
|||||||
if list_posts != None:
|
if list_posts != None:
|
||||||
last_build=last_article_date[0]
|
last_build=last_article_date[0]
|
||||||
for post in list_posts:
|
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',
|
return render_template('blog_rss.xml',
|
||||||
base_url=BASE_URL,
|
base_url=BASE_URL,
|
||||||
|
|||||||
Reference in New Issue
Block a user