Commit
·
1cd39cf
1
Parent(s):
55868a4
Update index.html
Browse files- index.html +26 -19
index.html
CHANGED
|
@@ -366,10 +366,10 @@
|
|
| 366 |
async loadSpaces() {
|
| 367 |
try {
|
| 368 |
console.log('Searching for spaces with reachy_mini tag...');
|
| 369 |
-
|
| 370 |
// Search for spaces with the reachy_mini tag using filter parameter
|
| 371 |
const response = await fetch('https://huggingface.co/api/spaces?filter=reachy_mini&sort=likes&direction=-1&limit=50');
|
| 372 |
-
|
| 373 |
if (!response.ok) {
|
| 374 |
throw new Error(`HTTP error! status: ${response.status}`);
|
| 375 |
}
|
|
@@ -377,17 +377,7 @@
|
|
| 377 |
const data = await response.json();
|
| 378 |
console.log('API response:', data.length, 'spaces found');
|
| 379 |
|
| 380 |
-
this.spaces = data.map(space => (
|
| 381 |
-
id: space.id,
|
| 382 |
-
title: space.id.split('/').pop().replace(/-/g, ' ').replace(/\b\w/g, l => l.toUpperCase()),
|
| 383 |
-
author: space.id.split('/')[0],
|
| 384 |
-
description: space.cardData?.short_description || 'No description available',
|
| 385 |
-
likes: space.likes || 0,
|
| 386 |
-
created: new Date(space.createdAt).getTime(),
|
| 387 |
-
url: `https://huggingface.co/spaces/${space.id}`,
|
| 388 |
-
tags: space.tags || []
|
| 389 |
-
}));
|
| 390 |
-
|
| 391 |
this.filteredSpaces = [...this.spaces];
|
| 392 |
this.updateStats();
|
| 393 |
|
|
@@ -422,6 +412,27 @@
|
|
| 422 |
`;
|
| 423 |
}
|
| 424 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 425 |
setupEventListeners() {
|
| 426 |
// Search functionality
|
| 427 |
const searchInput = document.getElementById('searchInput');
|
|
@@ -472,7 +483,7 @@
|
|
| 472 |
const total = this.spaces.length;
|
| 473 |
const totalLikes = this.spaces.reduce((sum, space) => sum + space.likes, 0);
|
| 474 |
const filtered = this.filteredSpaces.length;
|
| 475 |
-
|
| 476 |
if (total === 0) {
|
| 477 |
statsEl.innerHTML = `No spaces found with "${this.targetTag}" tag`;
|
| 478 |
} else if (filtered === total) {
|
|
@@ -547,11 +558,7 @@
|
|
| 547 |
}
|
| 548 |
|
| 549 |
getSpaceIcon(space) {
|
| 550 |
-
|
| 551 |
-
if (space.title.toLowerCase().includes('reachy') || space.tags.includes('reachy_mini')) {
|
| 552 |
-
return '🤖';
|
| 553 |
-
}
|
| 554 |
-
return space.title.charAt(0).toUpperCase();
|
| 555 |
}
|
| 556 |
|
| 557 |
formatDate(timestamp) {
|
|
|
|
| 366 |
async loadSpaces() {
|
| 367 |
try {
|
| 368 |
console.log('Searching for spaces with reachy_mini tag...');
|
| 369 |
+
|
| 370 |
// Search for spaces with the reachy_mini tag using filter parameter
|
| 371 |
const response = await fetch('https://huggingface.co/api/spaces?filter=reachy_mini&sort=likes&direction=-1&limit=50');
|
| 372 |
+
|
| 373 |
if (!response.ok) {
|
| 374 |
throw new Error(`HTTP error! status: ${response.status}`);
|
| 375 |
}
|
|
|
|
| 377 |
const data = await response.json();
|
| 378 |
console.log('API response:', data.length, 'spaces found');
|
| 379 |
|
| 380 |
+
this.spaces = await Promise.all(data.map(space => this.getSpaceInfo(space)));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 381 |
this.filteredSpaces = [...this.spaces];
|
| 382 |
this.updateStats();
|
| 383 |
|
|
|
|
| 412 |
`;
|
| 413 |
}
|
| 414 |
|
| 415 |
+
async getSpaceInfo(space) {
|
| 416 |
+
const spaceData = await fetch(`https://huggingface.co/api/spaces/${space.id}`)
|
| 417 |
+
.then(res => res.json())
|
| 418 |
+
.then(data => {
|
| 419 |
+
return data;
|
| 420 |
+
})
|
| 421 |
+
.catch(err => {
|
| 422 |
+
console.error(`Error fetching card data for ${space.id}:`, err);
|
| 423 |
+
return {};
|
| 424 |
+
});
|
| 425 |
+
|
| 426 |
+
spaceData.title = spaceData.title || space.id.split('/').pop().replace(/-/g, ' ').replace(/\b\w/g, l => l.toUpperCase());
|
| 427 |
+
spaceData.author = space.id.split('/')[0];
|
| 428 |
+
spaceData.description = spaceData.cardData?.short_description || 'No description available';
|
| 429 |
+
spaceData.created = new Date(space.createdAt).getTime();
|
| 430 |
+
spaceData.url = `https://huggingface.co/spaces/${space.id}`;
|
| 431 |
+
spaceData.tags = space.tags || [];
|
| 432 |
+
|
| 433 |
+
return spaceData;
|
| 434 |
+
}
|
| 435 |
+
|
| 436 |
setupEventListeners() {
|
| 437 |
// Search functionality
|
| 438 |
const searchInput = document.getElementById('searchInput');
|
|
|
|
| 483 |
const total = this.spaces.length;
|
| 484 |
const totalLikes = this.spaces.reduce((sum, space) => sum + space.likes, 0);
|
| 485 |
const filtered = this.filteredSpaces.length;
|
| 486 |
+
|
| 487 |
if (total === 0) {
|
| 488 |
statsEl.innerHTML = `No spaces found with "${this.targetTag}" tag`;
|
| 489 |
} else if (filtered === total) {
|
|
|
|
| 558 |
}
|
| 559 |
|
| 560 |
getSpaceIcon(space) {
|
| 561 |
+
return space.cardData.emoji || '🤖';
|
|
|
|
|
|
|
|
|
|
|
|
|
| 562 |
}
|
| 563 |
|
| 564 |
formatDate(timestamp) {
|