Display blog article on landing page

This commit is contained in:
kitoy 2025-12-30 21:37:15 +01:00
parent 9baeb3736b
commit d6b4d64390
4 changed files with 65 additions and 3 deletions

3
.gitignore vendored
View File

@ -6,4 +6,5 @@ users/
sys
*~
*#*
.*
.*
base.db.new

View File

@ -54,6 +54,36 @@ main > nav
color: var(--pico-color-green-500);
}
@media (min-width: 1200px)
{
.list-articles{
padding-top: 2vw;
display: inline-flex;
gap:30px;
flex-wrap: wrap;
}
article {
text-align: center;
width: 30vw;
height: 35vw;
}
article > header {
height: 15vw;
}
article > .subtitle {
height: 10vw;
article footer{
display: block;
height: 5vw;
}
}
@media only screen and (max-width: 600px)
{
body {

View File

@ -41,8 +41,27 @@
<p class="center"><a href="{{ url_for('loginlogout.lost_password') }}"> Mouarf j'ai perdu mon mot de passe </a> </p>
<button class="btn btn-default btn-primary" type="submit"> Login </button>
</form>
<h2> Les derniers articles de blog sur le serveur </h2>
<div class="list-articles" >
{% for article in list_posts %}
<article>
<header>
<h3> {{ article.title }} </h3>
<h5> par <a href="/blog/{{ article.author }}/">/{{ article.author }}</a> </h5>
<br/>
<small> Créé le : {{ article.creation_date }} </small> <br/>
{% if article.last_updated %}
<small> Modifié le : {{ article.last_updated }}</small><br/>
{% endif %}
</header>
<div class="subtitle">
<p> {{ article.subtitle }} </p>
</div>
<footer><a href="/blog//public_unified/{{ article.author }}/{{ article.title }}"> <button> Lire la suite </button> </a></footer>
</article>
{% endfor %}
{% endblock %}
</main>

View File

@ -88,10 +88,22 @@ def login():
else:
flash(u"L'utilisateur n'existe pas", 'error')
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, creation_date, last_updated, author FROM Blog_posts WHERE status='public_unified'""" )
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], last_updated=post[3], author=post[4])] + posts
resp = render_template('accueil.html',
server_title=SERVER_TITLE,
server_desc=SERVER_DESC,
mail_server=MAIL_SERVER,
list_posts=posts,
signin_enable=app.config['SIGNIN_ENABLE'])
return resp