Docfile commited on
Commit
e8e81cb
·
verified ·
1 Parent(s): 5181917

Update templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +57 -123
templates/index.html CHANGED
@@ -4,158 +4,92 @@
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Générateur de contenu avec Gemini et RDKit</title>
7
- <!-- Bootstrap CSS -->
8
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
9
- <!-- MathJax for LaTeX -->
10
- <script async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
11
- <!-- Markdown Parser -->
12
  <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
13
- <style>
14
- body {
15
- font-family: 'Arial', sans-serif;
16
- background-color: #f9f9f9;
17
- padding: 20px;
18
- }
19
-
20
- h1, h2 {
21
- color: #2c3e50;
22
- }
23
-
24
- .loader {
25
- border: 5px solid #f3f3f3;
26
- border-top: 5px solid #3498db;
27
- border-radius: 50%;
28
- width: 40px;
29
- height: 40px;
30
- animation: spin 1s linear infinite;
31
- margin: 20px auto;
32
- display: none;
33
- }
34
-
35
- @keyframes spin {
36
- 0% { transform: rotate(0deg); }
37
- 100% { transform: rotate(360deg); }
38
- }
39
-
40
- .resizable-image {
41
- max-width: 100%;
42
- height: auto;
43
- cursor: pointer;
44
- transition: transform 0.3s ease-in-out;
45
- }
46
-
47
- .resizable-image:hover {
48
- transform: scale(1.1);
49
- }
50
-
51
- .modal {
52
- display: none;
53
- position: fixed;
54
- z-index: 1050;
55
- left: 0;
56
- top: 0;
57
- width: 100%;
58
- height: 100%;
59
- background-color: rgba(0, 0, 0, 0.8);
60
- align-items: center;
61
- justify-content: center;
62
- }
63
-
64
- .modal img {
65
- max-width: 90%;
66
- max-height: 90%;
67
- }
68
-
69
- .modal .close-modal {
70
- position: absolute;
71
- top: 10px;
72
- right: 20px;
73
- color: #fff;
74
- font-size: 24px;
75
- font-weight: bold;
76
- cursor: pointer;
77
- }
78
-
79
- .content-wrapper {
80
- white-space: pre-wrap;
81
- word-wrap: break-word;
82
- }
83
- </style>
84
  </head>
85
- <body>
86
- <div class="container">
87
- <h1 class="text-center my-4">Générateur de contenu avec Gemini et RDKit</h1>
88
  <form method="POST" enctype="multipart/form-data" onsubmit="showLoader()">
89
- <div class="mb-3">
90
- <label for="image" class="form-label">Image :</label>
91
- <input type="file" name="image" id="image" class="form-control">
92
  </div>
93
- <div class="mb-3">
94
- <label for="text_input" class="form-label">Texte (Markdown ou LaTeX) :</label>
95
- <textarea name="text_input" id="text_input" class="form-control" rows="6" placeholder="Saisissez votre texte ici..."></textarea>
96
  </div>
97
- <button type="submit" class="btn btn-primary w-100">Générer</button>
98
  </form>
99
 
100
- <div id="loader" class="loader"></div>
 
 
 
 
 
101
 
102
  {% if generated_content %}
103
- <div class="row mt-4">
104
- <div class="col-lg-8">
105
- <h2>Contenu généré :</h2>
106
- <div class="content-wrapper" id="generatedContent">
107
- {{ generated_content | safe }}
108
- </div>
 
 
 
109
  </div>
110
- <div class="col-lg-4">
111
- <h2>Structures chimiques :</h2>
112
- {% for image_path in image_paths %}
113
- <div class="text-center my-3">
114
- <img src="{{ image_path }}" alt="Structure Chimique" class="resizable-image" onclick="toggleZoomModal('{{ image_path }}')">
 
 
 
 
 
 
115
  </div>
116
- {% endfor %}
117
  </div>
118
  </div>
119
- {% endif %}
120
- </div>
121
 
122
- <!-- Modal -->
123
- <div id="zoomModal" class="modal d-flex">
124
- <span class="close-modal" onclick="closeZoomModal()">×</span>
125
- <img id="zoomedImage" src="">
 
 
 
 
126
  </div>
127
 
128
- <!-- Scripts -->
129
  <script>
130
  function showLoader() {
131
- document.getElementById('loader').style.display = 'block';
132
  }
133
 
134
- window.onload = function () {
135
- document.getElementById('loader').style.display = 'none';
136
- };
137
-
138
  function toggleZoomModal(imagePath) {
139
  const modal = document.getElementById('zoomModal');
140
  const zoomedImage = document.getElementById('zoomedImage');
141
  zoomedImage.src = imagePath;
142
- modal.style.display = 'flex';
143
  }
144
 
145
  function closeZoomModal() {
146
- document.getElementById('zoomModal').style.display = 'none';
 
147
  }
148
 
149
- // Markdown rendering
150
- const textarea = document.getElementById('text_input');
151
- const contentWrapper = document.getElementById('generatedContent');
152
- if (textarea && contentWrapper) {
153
- textarea.addEventListener('input', () => {
154
- const markdownText = textarea.value;
155
- contentWrapper.innerHTML = marked(markdownText);
156
- MathJax.typeset(); // Re-render LaTeX
157
- });
158
- }
159
  </script>
160
  </body>
161
  </html>
 
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
  <title>Générateur de contenu avec Gemini et RDKit</title>
7
+ <script src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js" async></script>
 
 
 
 
8
  <script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
9
+ <script src="https://cdn.tailwindcss.com"></script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  </head>
11
+ <body class="bg-gray-100 text-gray-900">
12
+ <div class="container mx-auto p-6">
13
+ <h1 class="text-3xl font-bold mb-4">Générateur de contenu avec Gemini et RDKit</h1>
14
  <form method="POST" enctype="multipart/form-data" onsubmit="showLoader()">
15
+ <div class="mb-4">
16
+ <label for="image" class="block text-sm font-medium text-gray-700">Image :</label>
17
+ <input type="file" name="image" id="image" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
18
  </div>
19
+ <div class="mb-4">
20
+ <label for="text_input" class="block text-sm font-medium text-gray-700">Texte (Markdown ou LaTeX) :</label>
21
+ <textarea name="text_input" id="text_input" rows="5" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" placeholder="Écrivez ici en Markdown ou LaTeX..."></textarea>
22
  </div>
23
+ <button type="submit" class="bg-indigo-600 text-white px-4 py-2 rounded hover:bg-indigo-700">Générer</button>
24
  </form>
25
 
26
+ <div class="loader mt-6 hidden" id="loader">
27
+ <svg class="animate-spin h-8 w-8 text-indigo-600 mx-auto" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
28
+ <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
29
+ <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8v8H4z"></path>
30
+ </svg>
31
+ </div>
32
 
33
  {% if generated_content %}
34
+ <div class="mt-8 grid md:grid-cols-3 gap-6">
35
+ <!-- Contenu généré -->
36
+ <div class="md:col-span-2 bg-white shadow-md rounded-md p-6">
37
+ <h2 class="text-2xl font-semibold mb-4">Contenu généré :</h2>
38
+ <div id="renderedContent" class="prose max-w-none"></div>
39
+ <script>
40
+ document.getElementById('renderedContent').innerHTML = marked(`{{ generated_content | safe }}`);
41
+ MathJax.typesetPromise();
42
+ </script>
43
  </div>
44
+
45
+ <!-- Structures chimiques -->
46
+ <div class="bg-white shadow-md rounded-md p-6">
47
+ <h2 class="text-2xl font-semibold mb-4">Structures chimiques :</h2>
48
+ <div class="space-y-4">
49
+ {% for image_path in image_paths %}
50
+ <div class="relative group">
51
+ <img src="{{ image_path }}" alt="Structure Chimique" class="w-full h-auto rounded-md border border-gray-200 transform transition duration-200 group-hover:scale-105">
52
+ <button onclick="toggleZoomModal('{{ image_path }}')" class="absolute top-2 right-2 bg-gray-900 text-white text-xs px-2 py-1 rounded">Zoom</button>
53
+ </div>
54
+ {% endfor %}
55
  </div>
 
56
  </div>
57
  </div>
 
 
58
 
59
+ <!-- Modal pour zoom -->
60
+ <div id="zoomModal" class="fixed inset-0 bg-black bg-opacity-75 hidden z-50 flex items-center justify-center">
61
+ <div class="relative">
62
+ <img id="zoomedImage" src="" class="max-w-full max-h-screen rounded shadow-lg">
63
+ <button onclick="closeZoomModal()" class="absolute top-2 right-2 bg-gray-900 text-white text-lg px-3 py-1 rounded">&times;</button>
64
+ </div>
65
+ </div>
66
+ {% endif %}
67
  </div>
68
 
 
69
  <script>
70
  function showLoader() {
71
+ document.getElementById('loader').classList.remove('hidden');
72
  }
73
 
 
 
 
 
74
  function toggleZoomModal(imagePath) {
75
  const modal = document.getElementById('zoomModal');
76
  const zoomedImage = document.getElementById('zoomedImage');
77
  zoomedImage.src = imagePath;
78
+ modal.classList.remove('hidden');
79
  }
80
 
81
  function closeZoomModal() {
82
+ const modal = document.getElementById('zoomModal');
83
+ modal.classList.add('hidden');
84
  }
85
 
86
+ // Fermer le modal en cliquant à l'extérieur de l'image
87
+ window.addEventListener('click', function(event) {
88
+ const modal = document.getElementById('zoomModal');
89
+ if (event.target === modal) {
90
+ modal.classList.add('hidden');
91
+ }
92
+ });
 
 
 
93
  </script>
94
  </body>
95
  </html>