From 0d375ab1b11245e03b02c49232d933f6d0a3fa22 Mon Sep 17 00:00:00 2001 From: kitoy Date: Fri, 20 Mar 2026 16:04:21 +0100 Subject: [PATCH] Fix landing-page css --- base.db.bkp | Bin 0 -> 73728 bytes static/pywallter.css | 13 +-- templates/accueil.html | 4 +- templates/blog_rss.xml | 4 +- templates/edit_article.html | 50 +-------- templates/index_author_blog.html | 2 +- templates/index_blog.html | 2 +- templates/list_articles.html | 4 +- templates/update_article.html | 48 +++++++++ tools/databaseinit.py | 59 +++++++++-- views/blog.py | 167 +++++++++++++++---------------- 11 files changed, 196 insertions(+), 157 deletions(-) create mode 100644 base.db.bkp create mode 100644 templates/update_article.html diff --git a/base.db.bkp b/base.db.bkp new file mode 100644 index 0000000000000000000000000000000000000000..52a603e2c563ccc50a1810fa80f285dbb34cd388 GIT binary patch literal 73728 zcmeHwYiwLec3!tgic(WlkGwPCE(U{?D8&>tWV0WnMr^&7>_`5v<`v=0>sJR&;gtTfq^7IU<62l$*=qj3_C&M zANkIydz;-9IhwK8lUboCs@Z*S-Ksj@Id$rsQ`L3u-@9!`Qq=vxH6l^TyphRfGv5^= zlR5gQnM~$alK)5W_ig;|#sBmto4z^xFX|}#{r@vK@E~)de>~Gap8t3Ge>CWyyg2yI z$!912Tkg$)v&a7R@&9`G^ZJfPKqH_L&~^gOFd2 z%q`E)tjvp*nc3U(f-jxR3H&S?wj);NKU@(HmTumAFh9muJ;RmiYAdi^BiI%n%zu=W z5KDJf#L|P?w^dQYv5k<+s?S?)tJU$bWrX3T)p5btFd`%9xZwG2$EQ{xyDu0G)e}|w zrmTfz4p5KPl@)(odSdRz%<{QPaa3Kiy$w4uBHQ;uadT;9{`&l~cz=Fj=E3b1aju+} zBGOj_8JclI>zIgJmJ!LMyW+MVMypJKA6To=UPBiqN5@3uM=jOvBx)2j$8W60o?W-` zJa=a*y&5&8D@UJyYoLGV^y%ymo-l7_Q9fL4p^3eBC%U+_cU`e6vLh$yX*UbPxVCps zAz=EhE4`?b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q+mIm+N3tx`Im`@J zU>nr(-j+2AiDJ_|ZPuqaFJe8s>kWcIPuZ?(HwYQFYiU;%NTpq5WNC8T%WX!BgUt;PEM`@ci`=yrcb7|{MNwd{l^*-kdGIK2C!AU;`^4Sa_Yf^D)rjosn9 zFMM91q8>p)Rm_XyfodlfMobIa@vv@2RdXcvfPU^RJ$>&SZL-LP)rkq(^nh=>L~%_P zK-0vg5t+?v8&`^pvukcSe!4Vm(t7Qj3Wbxzsz5q+X3>T^bl!!iGltk6Rl_p(?h797 z3|dDY)0n%GK5Ik?n%Y{}2?-4(eBY10BB5fH6sM;3K3X;4U@dk(px(3wY~G3sxqHkV ztR{hZ@MRDs?{rRRkl`L;wT8u8A8FhXJ9*h}1mChjbenvYL@9u(g(Z@!bSEK;CIZ74 zPN4Oc#QscWjYoZLKX6-t7=(=NCrynbpud`9e%iwphxl% z?#190QnKlY(x8ob#50H>v^=eN zq|2~S>h!Gw;#Py*XP&;mC+I3#V#2OfC0(M9nW+Kj5;~!>F%1y~s2Egoc~Wp_5tyJP zZA#oG{lVXXp{kRD}P)FL&Dmg?!@Fv7Ab``BBs%u!l#UF+6 zLHs$5xHM@d^h*i;((XUOelhxP0I++A#ST)!vpyzOj49|lkdNsJ_s*YJwYJ%M`uzDE za3%Skvkf0#q2li%p<4Ln*w%~*jqaV!bwp|LeRRaYOOqX!KsByT;`{%+?+!a7v6$ID H*x>&GFxX8A literal 0 HcmV?d00001 diff --git a/static/pywallter.css b/static/pywallter.css index 7161933..deda436 100644 --- a/static/pywallter.css +++ b/static/pywallter.css @@ -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; } } diff --git a/templates/accueil.html b/templates/accueil.html index f1789fe..844ecb5 100644 --- a/templates/accueil.html +++ b/templates/accueil.html @@ -61,7 +61,9 @@ - + + + {% endfor %} {% endif %} diff --git a/templates/blog_rss.xml b/templates/blog_rss.xml index f78d80d..c78be60 100644 --- a/templates/blog_rss.xml +++ b/templates/blog_rss.xml @@ -18,8 +18,8 @@ {{ post.title }} {% if post.last_updated %} {{ post.last_updated }} {% else %} {{ post.time }} {% endif %} - {{base_url}}/blog/{{ post.status }}/{{post.author}}/{{post.title}} - {{base_url}}/blog/{{ post.status }}/{{post.author}}/{{post.title}} + {{base_url}}/blog/{{ post.status }}/{{post.author}}/{{post.title_id}} + {{base_url}}/blog/{{ post.status }}/{{post.author}}/{{post.title_id}} {{ post.subtitle }} diff --git a/templates/edit_article.html b/templates/edit_article.html index eb6eadf..6882c25 100644 --- a/templates/edit_article.html +++ b/templates/edit_article.html @@ -6,55 +6,7 @@ {% block main %} - -
-
-
-
- - -
- -

Visibilité

- -
-

Les articles brouillons ne sont visibles que par vous même

-

Les articles privés ne sont visibles que par les membres du serveur

-

Les articles public sont visibles par tout le monde

- - - {% if oldpost['status'] == 'public' or oldpost['status'] == "public_unified" %} - Brouillon - Privé - Publique - - {% elif oldpost['status'] == 'private' or oldpost['status'] == "private_unified" %} - Brouillon - Privé - Publique - {% else %} - Brouillon - Privé - Publique - - {% endif %} -
- -
- -
-
-
- -
+{% include 'update_article.html' %} {% endblock %} diff --git a/templates/index_author_blog.html b/templates/index_author_blog.html index 9cbe0d8..99b5399 100644 --- a/templates/index_author_blog.html +++ b/templates/index_author_blog.html @@ -33,7 +33,7 @@ {% endfor %} diff --git a/templates/index_blog.html b/templates/index_blog.html index 7d1fc20..61b42de 100644 --- a/templates/index_blog.html +++ b/templates/index_blog.html @@ -38,7 +38,7 @@ {% endfor %} diff --git a/templates/list_articles.html b/templates/list_articles.html index e5e720e..2891065 100644 --- a/templates/list_articles.html +++ b/templates/list_articles.html @@ -36,8 +36,8 @@

- - + + {% endfor %} diff --git a/templates/update_article.html b/templates/update_article.html new file mode 100644 index 0000000..89d30ec --- /dev/null +++ b/templates/update_article.html @@ -0,0 +1,48 @@ +
+
+
+
+
+
+ +
+

Visibilité

+ +
+

Les articles brouillons ne sont visibles que par vous même

+

Les articles privés ne sont visibles que par les membres du serveur

+

Les articles public sont visibles par tout le monde

+ + + {% if oldpost['status'] == 'public' or oldpost['status'] == "public_unified" %} + Brouillon + Privé + Publique + + {% elif oldpost['status'] == 'private' or oldpost['status'] == "private_unified" %} + Brouillon + Privé + Publique + {% else %} + Brouillon + Privé + Publique + + {% endif %} +
+ +
+ +
+
+
+ +
diff --git a/tools/databaseinit.py b/tools/databaseinit.py index b6c00cf..377567f 100755 --- a/tools/databaseinit.py +++ b/tools/databaseinit.py @@ -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,7 +84,8 @@ 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);""") @@ -152,9 +155,49 @@ def db_migrate(database): conn.commit() print ("Time renomé en creation_date") - if not(category_col): - cursor.execute("""ALTER TABLE Blog_posts ADD COLUMN category TEXT;""") - conn.commit() - print ("Ajout de la colono category") + if not(category_col): + cursor.execute("""ALTER TABLE Blog_posts ADD COLUMN category TEXT;""") + 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() diff --git a/views/blog.py b/views/blog.py index 5f6a36e..d20e3cb 100644 --- a/views/blog.py +++ b/views/blog.py @@ -32,97 +32,93 @@ MARKDOWN_EXT=["extra", "toc", "codehilite", @blog.route('/myblog/new-article/', methods=['GET', 'POST']) @login_required def new_article(): - user = '%s'% escape(session['username']) + 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/', methods=['GET', 'POST']) +@blog.route('/myblog/edit/<title_id>', methods=['GET']) @login_required -def edit(title): - 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)) - 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', +def edit(title_id): + 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_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() + + 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): - user='%s'% escape(session['username']) - folder_blog = DOSSIER_PERSO + user + "/blog/articles/" - newtitle = str(request.form['title']).encode() +def update(): + user = '%s' % escape(session['username']) + 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' - - 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)) + status = status+'_unified' + + 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 def list_articles_blog(): - user = '%s'% escape(session['username']) + 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,