diff --git a/aggreg.py b/aggreg.py index 493b77543e2bad2252749ef0fc2c4feafdf3083d..0760fdc6eb7daf9a996b29e7f3947c16b5a4c9b5 100644 --- a/aggreg.py +++ b/aggreg.py @@ -36,19 +36,8 @@ def fusion_flux(liste_url, liste_flux): return sortie def genere_html(liste_evenements, chemin_html): - - for i in range(0,len(liste_evenements)): - date_actu = datetime.today().strftime('%Y-%m-%d %H:%M') - title=liste_evenements[i]['Titre'] - serveur = liste_evenements[i]['serveur'] - pubDate = liste_evenements[i]['date_publi'] - category = liste_evenements[i]['categorie'] - link=liste_evenements[i]['lien'] - guid=liste_evenements[i]['guid'] - description=liste_evenements[i]['description'] - file = open(chemin_html,'w') - - html_code = f""" + file = open(chemin_html,'w') + html_code_debut = """ <!DOCTYPE html> <html lang="en"> <head> @@ -62,6 +51,27 @@ def genere_html(liste_evenements, chemin_html): <header> <h1>Events log</h1> </header> + """ + html_code_fin = """<!-- etc. si autres articles --> + </article> + </body> +</html> """ + file.write(html_code_debut) + + + for i in range(0,len(liste_evenements)): + date_actu = datetime.today().strftime('%Y-%m-%d %H:%M') + title=liste_evenements[i]['Titre'] + serveur = liste_evenements[i]['serveur'] + pubDate = liste_evenements[i]['date_publi'] + category = liste_evenements[i]['categorie'] + link=liste_evenements[i]['lien'] + guid=liste_evenements[i]['guid'] + description=liste_evenements[i]['description'] + + html_code = f""" + + <p>{date_actu}</p> <!-- liste des événements (items du flux RSS). Un bloc <article> par item dans le flux --> @@ -78,12 +88,9 @@ def genere_html(liste_evenements, chemin_html): <p>{description}</p> - </article> + </article> """ + - <!-- etc. si autres articles --> - </article> - </body> -</html> """ html_code.format(date_actu=date_actu, title=title, serveur = serveur, pubDate = pubDate, @@ -93,7 +100,94 @@ def genere_html(liste_evenements, chemin_html): file.write(html_code) - file.close + file.write(html_code_fin) + file.close + + css_code = """ + header{ +float:left; + width:100%; + background-color: #F0F8FF; + margin-bottom: 10px; + color: #000; + + } + +article{ + float: left; + width: 75%; + padding: 5px; + min-height: 300px; + background-color:#FFFFFF; + margin:20px; +} + +body{ +background-color:#F0F8FF; +width:100%; +margin: 0; + +} + +p{ + text-align: justify; + margin-left: 0px; + margin-right: 0px; + padding-right: 10px; + padding-left: 10px; + padding-top: 0px; + padding-bottom: 0px; + font-family:Arial; + } + +.critical{ +color:#f50000; +} + +.minor{ +color:#5eff4e; +} + +.major{ +color:#ffb057; +} + +header > nav { + float: right; + display: block; + list-style: none; + margin:0 auto 0 0; + margin-right: 20px; + font-size: 14px; + text-transform:uppercase; + overflow: hidden; + } +h2{ +font-size:40px; +font-family:Arial; +} + +h1,h3{ +text-shadow:5px 5px 5px #777; + font-family:Arial; + font-size:60px; +} +main { + width: 90%; + margin-top: 0; + margin-bottom: 0; + margin-right: auto; + margin-left: auto; + } +@media only screen and (max-width: 768px) { + /* For mobile phones: */ + [class*="col-"] { + width: 100%; + } + """ + file = open("feed.css",'w') + file.write(css_code) + file.close def main(): liste_url = sys.argv