Work on blog

This commit is contained in:
2026-02-28 01:06:48 +01:00
parent 7c89dbcd4f
commit 9f55623807
10 changed files with 244 additions and 88 deletions

View File

@@ -118,11 +118,23 @@ ul {
} }
.text-article p { .text-article p {
padding-left: 2vw; padding-left: 2vw;
padding-right:2vw; padding-right:2vw;
} }
.text-article pre {
padding-left: 2vw;
padding-right:2vw;
}
.text-article blockquote {
padding-left: 2vw;
padding-right:2vw;
}
.text-article h2, h3, h4, h5 { .text-article h2, h3, h4, h5 {
padding-left: 1vw; padding-left: 1vw;
padding-right:1vw; padding-right:1vw;

View File

@@ -123,6 +123,16 @@ a {
padding-right:2vw; padding-right:2vw;
} }
.text-article pre {
padding-left: 2vw;
padding-right:2vw;
}
.text-article blockquote {
padding-left: 2vw;
padding-right:2vw;
}
.text-article h2, h3, h4, h5 { .text-article h2, h3, h4, h5 {
padding-left: 1vw; padding-left: 1vw;
padding-right:1vw; padding-right:1vw;

View File

@@ -124,6 +124,16 @@
padding-right:2vw; padding-right:2vw;
} }
.text-article pre {
padding-left: 2vw;
padding-right:2vw;
}
.text-article blockquote {
padding-left: 2vw;
padding-right:2vw;
}
.text-article h2, h3, h4, h5 { .text-article h2, h3, h4, h5 {
padding-left: 1vw; padding-left: 1vw;
padding-right:1vw; padding-right:1vw;

View File

@@ -123,6 +123,16 @@ a {
padding-right:2vw; padding-right:2vw;
} }
.text-article pre {
padding-left: 2vw;
padding-right:2vw;
}
.text-article blockquote {
padding-left: 2vw;
padding-right:2vw;
}
.text-article h2, h3, h4, h5 { .text-article h2, h3, h4, h5 {
padding-left: 1vw; padding-left: 1vw;
padding-right:1vw; padding-right:1vw;

View File

@@ -2,7 +2,6 @@
:root :root
{ {
--color-background: #202020; --color-background: #202020;
--color-title: #fdfdfd; --color-title: #fdfdfd;
--color-text: #dddddd; --color-text: #dddddd;
@@ -124,13 +123,23 @@ a {
padding-right:2vw; padding-right:2vw;
} }
.text-article pre {
padding-left: 2vw;
padding-right:2vw;
}
.text-article blockquote {
padding-left: 2vw;
padding-right:2vw;
}
.text-article h2, h3, h4, h5 { .text-article h2, h3, h4, h5 {
padding-left: 1vw; padding-left: 1vw;
padding-right:1vw; padding-right:1vw;
} }
.index { .index {
text-align: left; text-align: left;
} }
@@ -141,7 +150,6 @@ a {
margin-right: auto; margin-right: auto;
width: 50%; width: 50%;
margin-bottom: 2vw; margin-bottom: 2vw;
} }
.articles .description { .articles .description {
@@ -149,7 +157,6 @@ a {
font-style: italic; font-style: italic;
font-size: 1.5vw; font-size: 1.5vw;
padding-bottom: 30px; padding-bottom: 30px;
color: ;
} }

79
static/code.css Normal file
View File

@@ -0,0 +1,79 @@
pre { line-height: 125%; }
td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; }
td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; }
.codehilite .hll { background-color: #ffffcc }
.codehilite { background-color: rgba(200,200,200,0.1);
margin: 2vw;
padding-bottom: 1vw;
padding-top: 1vw;
}
.codehilite .c { color: #3D7B7B; font-style: italic } /* Comment */
.codehilite .err { border: 1px solid #F00 } /* Error */
.codehilite .k { color: #008000; font-weight: bold } /* Keyword */
.codehilite .o { color: #666 } /* Operator */
.codehilite .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */
.codehilite .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */
.codehilite .cp { color: #9C6500 } /* Comment.Preproc */
.codehilite .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */
.codehilite .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */
.codehilite .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */
.codehilite .gd { color: #A00000 } /* Generic.Deleted */
.codehilite .ge { font-style: italic } /* Generic.Emph */
.codehilite .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */
.codehilite .gr { color: #E40000 } /* Generic.Error */
.codehilite .gh { color: #077080; font-weight: bold } /* Generic.Heading */
.codehilite .gi { color: #008400 } /* Generic.Inserted */
.codehilite .go { color: #717171 } /* Generic.Output */
.codehilite .gp { color: #077080; font-weight: bold } /* Generic.Prompt */
.codehilite .gs { font-weight: bold } /* Generic.Strong */
.codehilite .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.codehilite .gt { color: #04D } /* Generic.Traceback */
.codehilite .kc { color: #008000; font-weight: bold } /* Keyword.Constant */
.codehilite .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */
.codehilite .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */
.codehilite .kp { color: #008000 } /* Keyword.Pseudo */
.codehilite .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */
.codehilite .kt { color: #B00040 } /* Keyword.Type */
.codehilite .m { color: #666 } /* Literal.Number */
.codehilite .s { color: #BA2121 } /* Literal.String */
.codehilite .na { color: #687822 } /* Name.Attribute */
.codehilite .nb { color: #008000 } /* Name.Builtin */
.codehilite .nc { color: #00F; font-weight: bold } /* Name.Class */
.codehilite .no { color: #800 } /* Name.Constant */
.codehilite .nd { color: #A2F } /* Name.Decorator */
.codehilite .ni { color: #717171; font-weight: bold } /* Name.Entity */
.codehilite .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */
.codehilite .nf { color: #00F } /* Name.Function */
.codehilite .nl { color: #767600 } /* Name.Label */
.codehilite .nn { color: #00F; font-weight: bold } /* Name.Namespace */
.codehilite .nt { color: #008000; font-weight: bold } /* Name.Tag */
.codehilite .nv { color: #79499C } /* Name.Variable */
.codehilite .ow { color: #A2F; font-weight: bold } /* Operator.Word */
.codehilite .w { color: #BBB } /* Text.Whitespace */
.codehilite .mb { color: #666 } /* Literal.Number.Bin */
.codehilite .mf { color: #666 } /* Literal.Number.Float */
.codehilite .mh { color: #666 } /* Literal.Number.Hex */
.codehilite .mi { color: #666 } /* Literal.Number.Integer */
.codehilite .mo { color: #666 } /* Literal.Number.Oct */
.codehilite .sa { color: #BA2121 } /* Literal.String.Affix */
.codehilite .sb { color: #BA2121 } /* Literal.String.Backtick */
.codehilite .sc { color: #BA2121 } /* Literal.String.Char */
.codehilite .dl { color: #BA2121 } /* Literal.String.Delimiter */
.codehilite .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */
.codehilite .s2 { color: #BA2121 } /* Literal.String.Double */
.codehilite .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */
.codehilite .sh { color: #BA2121 } /* Literal.String.Heredoc */
.codehilite .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */
.codehilite .sx { color: #008000 } /* Literal.String.Other */
.codehilite .sr { color: #A45A77 } /* Literal.String.Regex */
.codehilite .s1 { color: #BA2121 } /* Literal.String.Single */
.codehilite .ss { color: #19177C } /* Literal.String.Symbol */
.codehilite .bp { color: #008000 } /* Name.Builtin.Pseudo */
.codehilite .fm { color: #00F } /* Name.Function.Magic */
.codehilite .vc { color: #19177C } /* Name.Variable.Class */
.codehilite .vg { color: #19177C } /* Name.Variable.Global */
.codehilite .vi { color: #19177C } /* Name.Variable.Instance */
.codehilite .vm { color: #19177C } /* Name.Variable.Magic */
.codehilite .il { color: #666 } /* Literal.Number.Integer.Long */

View File

@@ -65,9 +65,10 @@ main > nav
article { article {
text-align: center; width: 44vw;
width: 30vw; max-height: 35vw;
height: 35vw; margin-left: auto;
margin-right: auto;
} }
article > header { article > header {

View File

@@ -2,7 +2,7 @@
<html> <html>
<head> <head>
<title> Article de {{ post_info.author }} </title> <title> Article de {{ post_info.author }} </title>
<link rel="stylesheet" href="/static/code.css" type="text/css">
<link rel="stylesheet" href="/{{ post_info.author }}/blog.css" type="text/css"> <link rel="stylesheet" href="/{{ post_info.author }}/blog.css" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">

View File

@@ -7,11 +7,11 @@
{% block main %} {% block main %}
<form action="" method="POST" id="postform" > <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="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="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 /> <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" id="content" placeholder="Contenu" style="height:20vw;">{{ oldpost['content'] }}</textarea> <textarea id="editeurMarkdown" class="form-control" form="postform" name="content" placeholder="Contenu" style="height:20vw;">{{ oldpost['content'] }}</textarea>
<br /> <br />
@@ -51,7 +51,8 @@
Publier cet article dans le blog général Publier cet article dans le blog général
</label> </label>
</fieldset> </fieldset>
<div class="flashed {{ categorie }}" id="confirm">
</div>
<button type="submit"> Mettre à jour </button> <button type="submit"> Mettre à jour </button>
</form> </form>
@@ -59,5 +60,6 @@
{% block js %} {% block js %}
{% include '_js_editor.html' %} {% include '_js_editor.html' %}
{% include '_js_htmx.html' %}
{% endblock %} {% endblock %}

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from flask import Blueprint, render_template, session, redirect, url_for, request, flash, abort, Flask from flask import Blueprint, render_template, session, redirect, url_for, request, flash, abort, Flask, make_response
import time import time
from markupsafe import escape from markupsafe import escape
import sqlite3 import sqlite3
@@ -24,6 +24,9 @@ DOSSIER_PERSO = app.config.get('DOSSIER_APP')+'/'
DOSSIER_PUBLIC = app.config.get('DOSSIER_PUBLIC')+'/' DOSSIER_PUBLIC = app.config.get('DOSSIER_PUBLIC')+'/'
TITLE_SERVER = app.config.get('TITLE_SERVER') TITLE_SERVER = app.config.get('TITLE_SERVER')
DESC_SERVER = app.config.get('DESC_SERVER') DESC_SERVER = app.config.get('DESC_SERVER')
MARKDOWN_EXT=["extra", "toc", "codehilite",
"nl2br", "extra", "admonition",
"sane_lists", "smarty"]
################################################################################ ################################################################################
@blog.route('/myblog/new-article/', methods=['GET', 'POST']) @blog.route('/myblog/new-article/', methods=['GET', 'POST'])
@@ -82,6 +85,28 @@ def edit(title):
oldpost=post) oldpost=post)
@blog.route('/myblog/update/<title>', methods=['POST'])
@login_required
def update(title):
user='%s'% escape(session['username'])
folder_blog = DOSSIER_PERSO + user + "/blog/articles/"
newtitle = str(request.form['title'])
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()
response = """ <p class="center success" >Article mis à jour le """+ updated +""" .</p>"""
return response
@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():
@@ -239,7 +264,7 @@ 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]), creation_date=post[3], author=post[4], status=post[5])] + 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
return render_template('blog_rss.xml', return render_template('blog_rss.xml',
base_url=BASE_URL, base_url=BASE_URL,
@@ -261,7 +286,7 @@ def viewPrivateArticle(username, title):
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=post[0], subtitle=post[1], creation_date=post[3], last_updated=post[4],author=post[5]))
content = markdown(post[2]) content = markdown(post[2], 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)
@@ -278,7 +303,7 @@ def viewArticle(username, title):
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=post[0], subtitle=post[1], creation_date=post[3], last_updated=post[4],author=post[5]))
content= markdown(post[2]) content= markdown(post[2], 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:
@@ -299,7 +324,7 @@ 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]), creation_date=post[3], author=post[4], status=post[5])] + 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
return render_template('blog_rss.xml', return render_template('blog_rss.xml',
base_url=BASE_URL, base_url=BASE_URL,