gismap 0.2.1__py3-none-any.whl → 0.3.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
gismap/lab/vis.py DELETED
@@ -1,329 +0,0 @@
1
- from string import Template
2
- import uuid
3
- import json
4
-
5
-
6
- vis_template = Template("""
7
- <div class="gismap-content">
8
- <div id="${container_id}"></div>
9
- <a
10
- href="https://balouf.github.io/gismap/"
11
- target="_blank"
12
- id="gismap-brand"
13
- style="position: absolute; left: 10px; bottom: 10px; text-decoration: none; color: #888; font-size: min(2vw, 10px);
14
- z-index: 10; pointer-events: auto;"
15
- >
16
- &copy; Gismap 2025
17
- </a>
18
- <div id="${modal_id}" class="modal">
19
- <div class="modal-content">
20
- <span class="close" id="${modal_close_id}">&times;</span>
21
- <div id="${modal_body_id}"></div>
22
- </div>
23
- </div>
24
- </div>
25
- <style>
26
- .gismap-content {
27
- position: relative;
28
- width: 100%;
29
- height: 80vh !important;
30
- max-width: 100vw;
31
- max-height: 100vh !important;
32
- }
33
- /* Styles adaptatifs pour dark/light */
34
- /* Default: dark mode styles */
35
- #${container_id} {
36
- width: 100%;
37
- height: 100%;
38
- box-sizing: border-box;
39
- border: 1px solid #444;
40
- background: #181818;
41
- }
42
-
43
- .modal {
44
- display: none;
45
- position: fixed;
46
- z-index: 1000;
47
- left: 0; top: 0;
48
- width: 100%; height: 100%;
49
- overflow: auto;
50
- background-color: rgba(10,10,10,0.85);
51
- }
52
-
53
- .modal-content {
54
- background-color: #23272e;
55
- color: #f0f0f0;
56
- margin: 10% auto;
57
- padding: 24px;
58
- border: 1px solid #888;
59
- width: 50%;
60
- border-radius: 8px;
61
- box-shadow: 0 5px 15px rgba(0,0,0,.6);
62
- }
63
-
64
- .close {
65
- color: #aaa;
66
- float: right;
67
- font-size: 28px;
68
- font-weight: bold;
69
- cursor: pointer;
70
- }
71
-
72
- .close:hover, .close:focus {
73
- color: #fff;
74
- text-decoration: none;
75
- cursor: pointer;
76
- }
77
-
78
- /* PyData Sphinx Light Theme */
79
- html[data-theme="light"] #${container_id},
80
- body[data-jp-theme-light="true"] #${container_id} {
81
- background: #fff;
82
- border: 1px solid #ccc;
83
- }
84
-
85
- html[data-theme="light"] .modal,
86
- body[data-jp-theme-light="true"] .modal {
87
- background-color: rgba(220,220,220,0.85);
88
- }
89
-
90
- html[data-theme="light"] .modal-content,
91
- body[data-jp-theme-light="true"] .modal-content {
92
- background: #fff;
93
- color: #222;
94
- border: 1px solid #888;
95
- }
96
-
97
- html[data-theme="light"] .close,
98
- body[data-jp-theme-light="true"] .close {
99
- color: #222;
100
- }
101
-
102
- html[data-theme="light"] .close:hover, html[data-theme="light"] .close:focus,
103
- body[data-jp-theme-light="true"] .close:hover, body[data-jp-theme-light="true"] .close:focus {
104
- color: #555;
105
- }
106
-
107
- /* Fallback: system light mode */
108
- @media (prefers-color-scheme: light) {
109
- #${container_id} {
110
- background: #fff;
111
- border: 1px solid #ccc;
112
- }
113
- .modal {
114
- background-color: rgba(220,220,220,0.85);
115
- }
116
- .modal-content {
117
- background: #fff;
118
- color: #222;
119
- border: 1px solid #888;
120
- }
121
- .close {
122
- color: #222;
123
- }
124
- .close:hover, .close:focus {
125
- color: #555;
126
- }
127
- }
128
- </style>
129
- <script type="text/javascript">
130
- (function() {
131
- // Détection du thème
132
- function getTheme() {
133
- // Try PyData Sphinx theme on <html>
134
- const pydataTheme = document.documentElement.getAttribute("data-theme");
135
- if (pydataTheme === "dark" || pydataTheme === "light") {
136
- return pydataTheme;
137
- }
138
-
139
- // Try JupyterLab theme on <body>
140
- const jupyterLabTheme = document.body.getAttribute("data-jp-theme-name");
141
- if (jupyterLabTheme) {
142
- // Simplify theme name to 'dark' or 'light'
143
- const lowerName = jupyterLabTheme.toLowerCase();
144
- if (lowerName.includes("dark")) {
145
- return "dark";
146
- }
147
- if (lowerName.includes("light")) {
148
- return "light";
149
- }
150
- }
151
-
152
- // Fallback to system preference
153
- return window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches ? "dark" : "light";
154
- };
155
- function getVisOptions(theme) {
156
- if (theme === 'dark') {
157
- return {
158
- nodes: {
159
- shape: 'circle', size: 20,
160
- font: { size: 16, color: '#f0f0f0' },
161
- color: {
162
- background: '#222e3c',
163
- border: '#5d90f5',
164
- highlight: { background: '#2f3d4d', border: '#f5a25d' }
165
- },
166
- borderWidth: 2
167
- },
168
- edges: {
169
- width: 2,
170
- color: { color: '#888', highlight: '#f5a25d' },
171
- smooth: { type: 'continuous' }
172
- },
173
- interaction: { hover: true }
174
- };
175
- } else {
176
- return {
177
- nodes: {
178
- shape: 'circle', size: 20,
179
- font: { size: 16, color: '#222' },
180
- color: {
181
- background: '#e3eaff',
182
- border: '#3d6cf7',
183
- highlight: { background: '#fffbe6', border: '#f5a25d' }
184
- },
185
- borderWidth: 2
186
- },
187
- edges: {
188
- width: 2,
189
- color: { color: '#848484', highlight: '#f5a25d' },
190
- smooth: { type: 'continuous' }
191
- },
192
- interaction: { hover: true }
193
- };
194
- }
195
- };
196
-
197
- var physics = {
198
- physics: {
199
- solver: "forceAtlas2Based",
200
- forceAtlas2Based: {
201
- gravitationalConstant: -50,
202
- centralGravity: 0.01,
203
- springLength: 200,
204
- springConstant: 0.08,
205
- damping: 0.98,
206
- avoidOverlap: 1
207
- },
208
- maxVelocity: 10,
209
- minVelocity: 0.9,
210
- stabilization: {
211
- enabled: true,
212
- iterations: 2000,
213
- updateInterval: 50,
214
- onlyDynamicEdges: false,
215
- fit: true
216
- },
217
- timestep: 0.25
218
- }
219
- };
220
-
221
- function renderNetwork() {
222
- const nodes = new vis.DataSet(${nodes_json});
223
- const edges = new vis.DataSet(${edges_json});
224
- const container = document.getElementById('${container_id}');
225
- let network = null;
226
- const theme = getTheme();
227
- const options = getVisOptions(theme);
228
- network = new vis.Network(container, { nodes: nodes, edges: edges }, options);
229
- network.setOptions(physics)
230
- // Tooltip survol
231
- network.on("hoverNode", function(params) {
232
- const node = nodes.get(params.node);
233
- network.body.container.title = node.hover || '';
234
- });
235
- network.on("blurNode", function(params) {
236
- network.body.container.title = '';
237
- });
238
- network.on("hoverEdge", function(params) {
239
- const edge = edges.get(params.edge);
240
- network.body.container.title = edge.hover || '';
241
- });
242
- network.on("blurEdge", function(params) {
243
- network.body.container.title = '';
244
- });
245
- // Modal overlay
246
- const modal = document.getElementById('${modal_id}');
247
- const modalBody = document.getElementById('${modal_body_id}');
248
- const modalClose = document.getElementById('${modal_close_id}');
249
- network.on("click", function(params) {
250
- if (params.nodes.length === 1) {
251
- const node = nodes.get(params.nodes[0]);
252
- modalBody.innerHTML = node.overlay || '';
253
- modal.style.display = "block";
254
- } else if (params.edges.length === 1) {
255
- const edge = edges.get(params.edges[0]);
256
- modalBody.innerHTML = edge.overlay || '';
257
- modal.style.display = "block";
258
- } else {
259
- modal.style.display = "none";
260
- }
261
- });
262
- modalClose.onclick = function() { modal.style.display = "none"; };
263
- window.onclick = function(event) {
264
- if (event.target == modal) { modal.style.display = "none"; }
265
- };
266
- };
267
-
268
- function loadVisAndRender() {
269
- if (typeof vis === 'undefined') {
270
- var script = document.createElement('script');
271
- script.src = "https://unpkg.com/vis-network/standalone/umd/vis-network.min.js";
272
- script.type = "text/javascript";
273
- script.onload = function() {
274
- console.log("vis-network loaded dynamically");
275
- renderNetwork(); // Graph init after vis is loaded
276
- };
277
- document.head.appendChild(script);
278
- } else {
279
- console.log("vis-network already loaded");
280
- renderNetwork(); // Graph init immediately
281
- }
282
- }
283
- loadVisAndRender();
284
-
285
- // Adapter dynamiquement si le thème change
286
- window.addEventListener("theme-changed", () => loadVisAndRender());
287
- const observer = new MutationObserver(mutations => {
288
- for (const mutation of mutations) {
289
- if (mutation.type === "attributes" && mutation.attributeName === "data-jp-theme-name") {
290
- loadVisAndRender();
291
- }
292
- }
293
- });
294
- observer.observe(document.body, { attributes: true });
295
- if (window.matchMedia) {
296
- window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => loadVisAndRender());
297
- };
298
- })();
299
- </script>
300
- """)
301
-
302
-
303
- def generate_html(nodes, edges):
304
- """
305
- Parameters
306
- ----------
307
- nodes: :class:`list`
308
- edges: :class:`list`
309
-
310
- Returns
311
- -------
312
- :class:`str`
313
- """
314
- uid = str(uuid.uuid4())[:8] # identifiant unique pour éviter les collisions
315
- container_id = f"mynetwork_{uid}"
316
- modal_id = f"modal_{uid}"
317
- modal_body_id = f"modal_body_{uid}"
318
- modal_close_id = f"modal_close_{uid}"
319
- nodes_json = json.dumps(nodes)
320
- edges_json = json.dumps(edges)
321
- dico = {
322
- "container_id": container_id,
323
- "modal_id": modal_id,
324
- "modal_body_id": modal_body_id,
325
- "modal_close_id": modal_close_id,
326
- "nodes_json": nodes_json,
327
- "edges_json": edges_json,
328
- }
329
- return vis_template.substitute(dico) # html_template
@@ -1,29 +0,0 @@
1
- gismap/__init__.py,sha256=wZhnsqnlouh2Ugsb4L36K9QG8IEGrvI7s9biEv6LjRw,735
2
- gismap/author.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- gismap/gismap.py,sha256=h0hwdogXGFqerm-5ZPeT-irPn91pCcQRjiHThXsRzEk,19
4
- gismap/gismo.py,sha256=kBzvlo-fqcvEgwQt-c_hHkfI1oTjBbKKb54vM8il_nI,6295
5
- gismap/search.py,sha256=nsUoDsFGeEtvCZ0dB7ooRPC_6qsazkiWx_oM7dHdNV4,4932
6
- gismap/lab/__init__.py,sha256=WeJkoNZmFnLoEgK_nwXqZrA4nQtpeTLPf6PPMFIGb4k,415
7
- gismap/lab/egomap.py,sha256=L5OKeZR7RCfX3EPm859-jZ1jnqlC3kpa0jybofhLPPc,1328
8
- gismap/lab/expansion.py,sha256=fYcUvkGi3W1GTx2gnFT1z3cI-jlZFFAicDM99wi2wzE,6186
9
- gismap/lab/filters.py,sha256=LL3jeCqLBpLeaz1lz5IvduV4G1xBPaty9SHiBxoYgak,486
10
- gismap/lab/graph.py,sha256=8fzxohyUWqayLKaOC7CpBaKDN63eZK6oYp7nrfDDosw,6680
11
- gismap/lab/lab.py,sha256=Uc9Qg7Okf3L5K8gHTlnOv7lPbeA9OBfivCmZwRPwzp8,5331
12
- gismap/lab/lab_author.py,sha256=jQhq1spZP5P-Bpzr5E_OP73gWy3SG6UjiVCGotjm57s,2439
13
- gismap/lab/lip6.py,sha256=LLLjV8zNqwdkvtuV4nfmScCDlaeeGw79I0KQuOQ1_Yo,1443
14
- gismap/lab/toulouse.py,sha256=Ex3lBPdYhAzAnPQw9Driho7joJNTHLpE_nNMooQH_nc,1495
15
- gismap/lab/vis.py,sha256=YwMkoSa3-IsoNooQgZbluvIrQsYRbti1dlVRewypBNY,8734
16
- gismap/sources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
- gismap/sources/dblp.py,sha256=_AgPgDbHYYaeJVam43eExv1VsglvAV46eP77RL7o9Fo,5278
18
- gismap/sources/hal.py,sha256=3VjiUH5amNfJYV5uAtX-JcGWMNKUkmjfXU0Osca9CC8,10021
19
- gismap/sources/models.py,sha256=yJPBXcJO6MgOrSXgpGPepHDDtniJP1OsK8OSz__VzYc,543
20
- gismap/sources/multi.py,sha256=HQMQ4kcDwg0rZ42av98DZ17o83dpR2fD4KtP1yFX14c,4352
21
- gismap/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
- gismap/utils/common.py,sha256=nx1f60yNwFpl1oz08h-R5o0xK9CbJv9tmYLDk61dwYA,2898
23
- gismap/utils/logger.py,sha256=1YALIaNYKTqeIyyCnYxzvZTK7x4FTSfYYl5CP9IMw8E,86
24
- gismap/utils/requests.py,sha256=DA-ifVMdcOtipDSqYdVRQi-7CGR5WCTYiGyZ7Xu78q0,1291
25
- gismap/utils/text.py,sha256=1_9DlduAYh7Nz-yAg-MaCTmdKbPPmuIY20bb87t7JAQ,3810
26
- gismap-0.2.1.dist-info/METADATA,sha256=ZKER11xqoYCNSMmLpe-E7BdBbiLRMrAQuFEqct3ofuk,2542
27
- gismap-0.2.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
- gismap-0.2.1.dist-info/licenses/AUTHORS.md,sha256=oDR4mptVUBMq0WKIpt19Km1Bdfz3cO2NAOVgwVfTO8g,131
29
- gismap-0.2.1.dist-info/RECORD,,
File without changes