From c5736935b2de9f80c6b9fc8fbe8c291b74bd4da3 Mon Sep 17 00:00:00 2001 From: Rick Date: Wed, 21 Oct 2020 09:55:15 +0200 Subject: [PATCH] Ajout de la recherche dans la page index.html --- app.py | 20 +++++++------ templates/index.html | 5 ++++ templates/recherche.html | 61 ---------------------------------------- 3 files changed, 16 insertions(+), 70 deletions(-) delete mode 100644 templates/recherche.html diff --git a/app.py b/app.py index 415c263..50689c5 100644 --- a/app.py +++ b/app.py @@ -18,13 +18,20 @@ listeCategorie = ["autres", "informatique", "musique"] manip = Manip(fichierJson) #generateurHml = GenerationHtml(fichierJson, listeCategorie) -@app.route('/') -def slash(): +def renderIndex(recherche=False): with open(fichierJson, 'r') as fichier: liens = json.load(fichier) listeLiens = liens["liens"] listeLiens.reverse() - response = make_response(render_template("index.html", listeLiens=listeLiens)) + response = make_response(render_template( + "index.html", + listeLiens=listeLiens, + recherche=recherche)) + return response + +@app.route('/') +def slash(): + response = renderIndex() response.headers["Content-Security-Policy"] = "default-src 'self'" return response @@ -46,12 +53,7 @@ def ajout(): @app.route("/recherche") def recherche(): - with open(fichierJson, 'r') as fichier: - liens = json.load(fichier) - listeLiens = liens["liens"] - listeLiens.reverse() - response = make_response(render_template("recherche.html", listeLiens=listeLiens)) - return response + return renderIndex(True) @app.route("/apropos") def apropos(): diff --git a/templates/index.html b/templates/index.html index 021a47b..67bdaea 100644 --- a/templates/index.html +++ b/templates/index.html @@ -15,6 +15,7 @@ A propos + {% if not recherche %}
+ {% endif %}

Rafraichissez la page pour voir les derniers liens ajoutés.


{% for lien in listeLiens %} @@ -43,5 +45,8 @@
Version Alpha + {% if recherche %} + + {% endif %} diff --git a/templates/recherche.html b/templates/recherche.html deleted file mode 100644 index 8662855..0000000 --- a/templates/recherche.html +++ /dev/null @@ -1,61 +0,0 @@ - - - - - - - Partage de liens - - - -
- -
- -
-

Recherche

-
- - -
-
- -
- {% for lien in listeLiens %} -
-

{{lien.titre}}

-

{{lien.url}}

-
-

{{lien.desc}}

-

Tags:

- -
- {% endfor %} - - - -