acecalisto3 commited on
Commit
45a3d6a
·
verified ·
1 Parent(s): 7350e8f

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +97 -122
index.html CHANGED
@@ -29,75 +29,70 @@
29
  <script src="https://cdn.tailwindcss.com"></script>
30
 
31
  <style>
32
- iframe {
33
- display: block;
34
- border: none;
35
- width: 100%;
36
- height: 600px;
37
- pointer-events: none;
38
- margin-top: 48px; /* Match header height */
39
- }
40
-
41
- .grid-container {
42
- display: grid;
43
- grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
44
- grid-gap: 10px;
45
- margin-top: 3.5rem;
46
- }
47
-
48
- .grid-item {
49
- position: relative;
50
- overflow-y: hidden;
51
- border-radius: 10px;
52
- border: 1px solid rgb(55 65 81);
53
- }
54
- .grid-item:hover {
55
- filter: brightness(75%);
56
- }
57
-
58
- .grid-item a {
59
- position: absolute;
60
- top: 0;
61
- left: 0;
62
- width: 100%;
63
- height: 100%;
64
- display: block;
65
- z-index: 1;
66
- }
67
-
68
- .grid-item-header {
69
- position: absolute;
70
- top: 0;
71
- left: 0;
72
- right: 0;
73
- height: 48px;
74
- background: rgba(0,0,0,0.75);
75
- padding: 8px 16px;
76
- z-index: 10;
77
- display: flex;
78
- align-items: center;
79
- width: 100%;
80
- }
81
-
82
- .grid-item-header h2 {
83
- width: 100%;
84
- overflow-wrap: break-word;
85
- word-wrap: break-word;
86
- hyphens: auto;
87
- max-height: 32px;
88
- overflow: hidden;
89
- display: -webkit-box;
90
- -webkit-line-clamp: 2;
91
- -webkit-box-orient: vertical;
92
- line-height: 1.2;
93
- }
94
  </style>
95
 
96
  <script type="module">
97
  import Alpine from "https://cdn.skypack.dev/[email protected]";
98
  import Intersect from "https://cdn.skypack.dev/@alpinejs/intersect";
99
  Alpine.plugin(Intersect);
100
-
101
  Alpine.data("themesData", () => ({
102
  async init() {
103
  const data = await this.getThemes(this.page, this.sort, this.useTestData);
@@ -112,6 +107,8 @@
112
  useTestData: false,
113
  searchQuery: "",
114
  searchType: "keyword",
 
 
115
  buttonClass(attr, filter) {
116
  if (this[attr] === filter) {
117
  return "text-orange-600 bg-gradient-to-br from-orange-300 to-orange-100 px-2 md:px-3 py-1 rounded-full";
@@ -155,6 +152,12 @@
155
  await this.searchThemes();
156
  }
157
  },
 
 
 
 
 
 
158
  async getThemes(page, sort, useTestData) {
159
  let data;
160
  if (useTestData) {
@@ -176,8 +179,7 @@
176
  }
177
  const res = await fetch(searchUrl);
178
  data = await res.json();
179
- console.log(data)
180
- // Transform the API response to match the expected format
181
  data = data.filter(item => item.runtime?.stage === "RUNNING").map(item => ({
182
  id: item.id,
183
  subdomain: `https://${item.subdomain}.hf.space`,
@@ -185,20 +187,16 @@
185
  lastModified: item.lastModified
186
  }));
187
  }
188
-
189
  if (sort === 'likes') {
190
  data.sort((a, b) => (b.likes - a.likes));
191
  } else {
192
  data.sort((a, b) => (new Date(b.lastModified) - new Date(a.lastModified)));
193
  }
194
-
195
  const pageThemes = data.slice((page - 1) * 15, page * 15);
196
-
197
  console.log(pageThemes);
198
-
199
  return {
200
  themes: pageThemes,
201
- totalPages: Math.ceil(data.length / 15)
202
  };
203
  },
204
  async nextPage() {
@@ -209,21 +207,33 @@
209
  this.totalPages = data.totalPages;
210
  }
211
  },
 
 
 
 
 
212
  }));
213
  Alpine.start();
214
  </script>
215
  </head>
216
 
217
  <body class="pb-10 pt-5 bg-white relative">
218
- <section
219
- x-data="themesData"
220
- >
221
  <section class="container px-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-14 mx-auto relative">
222
  <div class="col-span-2 lg:col-span-1 flex flex-col gap-14 row-start">
223
  <div class="flex items-center gap-2">
224
  <img src="https://camo.githubusercontent.com/a8c1f1d12aa3114010c6e74b29d47fee91d8da10a915f065c38e6d0ea7f16568/68747470733a2f2f68756767696e67666163652e636f2f64617461736574732f68756767696e67666163652f646f63756d656e746174696f6e2d696d616765732f7265736f6c76652f6d61696e2f736d6f6c6167656e74732f6d6173636f742e706e67" alt="Smolagents mascot" class="w-14 h-14 flex-shrink-0">
225
  <h1 class="text-xl font-semibold text-gray-800 break-words">smolagents and tools gallery</h1>
226
  </div>
 
 
 
 
 
 
 
 
 
227
  </div>
228
  <div class="col-span-2 md:col-span-3 flex items-center gap-14 flex flex-wrap lg-auto lg:ml-auto text-sm">
229
  <div class="flex flex-col gap-2">
@@ -235,68 +245,33 @@
235
  placeholder="Search..."
236
  class="px-3 py-1 border rounded-lg"
237
  >
238
- <!-- <div class="flex border border-l-0 rounded-r-lg overflow-hidden">
239
- <button
240
- @click="switchSearchType('semantic')"
241
- :class="searchType === 'semantic' ? 'bg-orange-300 text-white' : 'bg-white text-gray-800'"
242
- class="px-3 py-1"
243
- >
244
- Semantic
245
- </button>
246
- <button
247
- @click="switchSearchType('keyword')"
248
- :class="searchType === 'keyword' ? 'bg-orange-300 text-white' : 'bg-white text-gray-800'"
249
- class="px-3 py-1 border-l"
250
- >
251
- Keyword
252
- </button>
253
- </div> -->
254
  </div>
255
  </div>
256
  <div class="flex gap-2">
257
  <span class="md:px-3 py-1 text-gray-800">type</span>
258
- <button
259
- :class="buttonClass('filter', 'tool')"
260
- @click="filterType('tool')"
261
- >
262
- Tools
263
- </button>
264
- <button
265
- :class="buttonClass('filter', 'agent')"
266
- @click="filterType('agent')"
267
- >
268
- Agents
269
- </button>
270
  </div>
271
  <div class="flex gap-2">
272
  <span class="md:px-3 py-1 text-gray-800">sort by</span>
273
- <button
274
- :class="buttonClass('sort', 'likes')"
275
- @click="sortThemes('likes')"
276
- >
277
- Most Likes
278
- </button>
279
- <button
280
- :class="buttonClass('sort', 'recent')"
281
- @click="sortThemes('recent')"
282
- >
283
- Recent
284
- </button>
285
  </div>
286
  </div>
287
  </section>
288
- <div class="container px-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2 mx-auto my-8 relative">
289
- <template x-for="theme in themes" :key="theme.id">
290
- <div class="grid-item">
291
- <div class="grid-item-header">
292
- <h2 class="text-sm font-medium text-white" x-text="theme.id"></h2>
 
 
 
293
  </div>
294
- <iframe :src="`${theme.subdomain}?_=${new Date().getTime()}`" :alt="theme.id" scrolling="no" frameborder="0" loading="lazy"></iframe>
295
- <a :href="`https://huggingface.co/spaces/${theme.id}`" target="_blank"></a>
296
- </div>
297
- </template>
298
  </div>
299
  <div class="h-12 relative" x-intersect="nextPage" data-iframe-height></div>
 
300
  </section>
301
  </body>
302
  </html>
 
29
  <script src="https://cdn.tailwindcss.com"></script>
30
 
31
  <style>
32
+ /* Existing styles remain unchanged */
33
+ iframe {
34
+ display: block;
35
+ border: none;
36
+ width: 100%;
37
+ height: 600px;
38
+ pointer-events: none;
39
+ margin-top: 48px; /* Match header height */
40
+ }
41
+ .grid-container {
42
+ display: grid;
43
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
44
+ grid-gap: 10px;
45
+ margin-top: 3.5rem;
46
+ }
47
+ .grid-item {
48
+ position: relative;
49
+ overflow-y: hidden;
50
+ border-radius: 10px;
51
+ border: 1px solid rgb(55 65 81);
52
+ }
53
+ .grid-item:hover {
54
+ filter: brightness(75%);
55
+ }
56
+ .grid-item a {
57
+ position: absolute;
58
+ top: 0;
59
+ left: 0;
60
+ width: 100%;
61
+ height: 100%;
62
+ display: block;
63
+ z-index: 1;
64
+ }
65
+ .grid-item-header {
66
+ position: absolute;
67
+ top: 0;
68
+ left: 0;
69
+ right: 0;
70
+ height: 48px;
71
+ background: rgba(0,0,0,0.75);
72
+ padding: 8px 16px;
73
+ z-index: 10;
74
+ display: flex;
75
+ align-items: center;
76
+ width: 100%;
77
+ }
78
+ .grid-item-header h2 {
79
+ width: 100%;
80
+ overflow-wrap: break-word;
81
+ word-wrap: break-word;
82
+ hyphens: auto;
83
+ max-height: 32px;
84
+ overflow: hidden;
85
+ display: -webkit-box;
86
+ -webkit-line-clamp: 2;
87
+ -webkit-box-orient: vertical;
88
+ line-height: 1.2;
89
+ }
 
 
 
 
90
  </style>
91
 
92
  <script type="module">
93
  import Alpine from "https://cdn.skypack.dev/[email protected]";
94
  import Intersect from "https://cdn.skypack.dev/@alpinejs/intersect";
95
  Alpine.plugin(Intersect);
 
96
  Alpine.data("themesData", () => ({
97
  async init() {
98
  const data = await this.getThemes(this.page, this.sort, this.useTestData);
 
107
  useTestData: false,
108
  searchQuery: "",
109
  searchType: "keyword",
110
+ hfToken: "", // New property for Hugging Face token
111
+ userSpaces: [], // New property to store user spaces
112
  buttonClass(attr, filter) {
113
  if (this[attr] === filter) {
114
  return "text-orange-600 bg-gradient-to-br from-orange-300 to-orange-100 px-2 md:px-3 py-1 rounded-full";
 
152
  await this.searchThemes();
153
  }
154
  },
155
+ async getUser Spaces() {
156
+ if (!this.hfToken) return;
157
+ const res = await fetch(`https://huggingface.co/api/spaces?token=${this.hfToken}`);
158
+ const data = await res.json();
159
+ this.userSpaces = data; // Store user spaces
160
+ },
161
  async getThemes(page, sort, useTestData) {
162
  let data;
163
  if (useTestData) {
 
179
  }
180
  const res = await fetch(searchUrl);
181
  data = await res.json();
182
+ console.log(data);
 
183
  data = data.filter(item => item.runtime?.stage === "RUNNING").map(item => ({
184
  id: item.id,
185
  subdomain: `https://${item.subdomain}.hf.space`,
 
187
  lastModified: item.lastModified
188
  }));
189
  }
 
190
  if (sort === 'likes') {
191
  data.sort((a, b) => (b.likes - a.likes));
192
  } else {
193
  data.sort((a, b) => (new Date(b.lastModified) - new Date(a.lastModified)));
194
  }
 
195
  const pageThemes = data.slice((page - 1) * 15, page * 15);
 
196
  console.log(pageThemes);
 
197
  return {
198
  themes: pageThemes,
199
+ totalPages: Math.ceil(data.length / 15)
200
  };
201
  },
202
  async nextPage() {
 
207
  this.totalPages = data.totalPages;
208
  }
209
  },
210
+ publishSelected() {
211
+ // Logic to publish selected spaces
212
+ const selectedSpaces = this.userSpaces.filter(space => space.selected);
213
+ // Implement the publish functionality here
214
+ },
215
  }));
216
  Alpine.start();
217
  </script>
218
  </head>
219
 
220
  <body class="pb-10 pt-5 bg-white relative">
221
+ <section x-data="themesData">
 
 
222
  <section class="container px-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-14 mx-auto relative">
223
  <div class="col-span-2 lg:col-span-1 flex flex-col gap-14 row-start">
224
  <div class="flex items-center gap-2">
225
  <img src="https://camo.githubusercontent.com/a8c1f1d12aa3114010c6e74b29d47fee91d8da10a915f065c38e6d0ea7f16568/68747470733a2f2f68756767696e67666163652e636f2f64617461736574732f68756767696e67666163652f646f63756d656e746174696f6e2d696d616765732f7265736f6c76652f6d61696e2f736d6f6c6167656e74732f6d6173636f742e706e67" alt="Smolagents mascot" class="w-14 h-14 flex-shrink-0">
226
  <h1 class="text-xl font-semibold text-gray-800 break-words">smolagents and tools gallery</h1>
227
  </div>
228
+ <div class="flex items-center gap-2">
229
+ <input
230
+ type="text"
231
+ x-model="hfToken"
232
+ placeholder="Enter your Hugging Face Token"
233
+ class="px-3 py-1 border rounded-lg"
234
+ >
235
+ <button @click="getUser Spaces()" class="px-3 py-1 bg-blue-500 text-white rounded-lg">Import Spaces</button>
236
+ </div>
237
  </div>
238
  <div class="col-span-2 md:col-span-3 flex items-center gap-14 flex flex-wrap lg-auto lg:ml-auto text-sm">
239
  <div class="flex flex-col gap-2">
 
245
  placeholder="Search..."
246
  class="px-3 py-1 border rounded-lg"
247
  >
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
248
  </div>
249
  </div>
250
  <div class="flex gap-2">
251
  <span class="md:px-3 py-1 text-gray-800">type</span>
252
+ <button :class="buttonClass('filter', 'tool')" @click="filterType('tool')">Tools</button>
253
+ <button :class="buttonClass('filter', 'agent')" @click="filterType('agent')">Agents</button>
 
 
 
 
 
 
 
 
 
 
254
  </div>
255
  <div class="flex gap-2">
256
  <span class="md:px-3 py-1 text-gray-800">sort by</span>
257
+ <button :class="buttonClass('sort', 'likes')" @click="sortThemes('likes')">Most Likes</button>
258
+ <button :class="buttonClass('sort', 'recent')" @click="sortThemes('recent')">Recent</button>
 
 
 
 
 
 
 
 
 
 
259
  </div>
260
  </div>
261
  </section>
262
+ <div class="container px-6 grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2 mx-auto my-8 relative">
263
+ <template x-for="theme in themes" :key="theme.id">
264
+ <div class="grid-item">
265
+ <div class="grid-item-header">
266
+ <h2 class="text-sm font-medium text-white" x-text="theme.id"></h2>
267
+ </div>
268
+ <iframe :src="`${theme.subdomain}?_=${new Date().getTime()}`" :alt="theme.id" scrolling="no" frameborder="0" loading="lazy"></iframe>
269
+ <a :href="`https://huggingface.co/spaces/${theme.id}`" target="_blank"></a>
270
  </div>
271
+ </template>
 
 
 
272
  </div>
273
  <div class="h-12 relative" x-intersect="nextPage" data-iframe-height></div>
274
+ <button @click="publishSelected()" class="px-4 py -2 bg-green-500 text-white rounded-lg">Publish Selected Spaces</button>
275
  </section>
276
  </body>
277
  </html>