Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -224,23 +224,26 @@ def get_vercel_deployments():
|
|
224 |
return []
|
225 |
|
226 |
def get_vercel_card(deployment, index):
|
227 |
-
"""Generate HTML card for a Vercel deployment"""
|
228 |
-
# URL์์ ์ฒซ 6๊ธ์๋ง ์ถ์ถํ์ฌ vercel.app ๋๋ฉ์ธ ๊ตฌ์ฑ
|
229 |
raw_url = deployment.get('url', '')
|
230 |
-
project_name = raw_url[:6] if len(raw_url) >= 6 else raw_url
|
231 |
-
url = f"{project_name}.vercel.app"
|
232 |
|
233 |
created = format_timestamp(deployment.get('created'))
|
234 |
name = deployment.get('name', 'Unnamed Project')
|
235 |
state = deployment.get('state', 'N/A')
|
236 |
|
237 |
-
|
|
|
238 |
|
|
|
239 |
tech_emojis = ['โก', '๐', '๐', 'โจ', '๐ซ', '๐ฅ', '๐', '๐ฏ', '๐จ', '๐ฎ']
|
240 |
random_emojis = random.sample(tech_emojis, 3)
|
241 |
|
242 |
return f"""
|
243 |
-
<div
|
|
|
|
|
244 |
padding: 25px;
|
245 |
margin: 15px;
|
246 |
border-radius: 20px;
|
@@ -251,35 +254,15 @@ def get_vercel_card(deployment, index):
|
|
251 |
overflow: hidden;'
|
252 |
onmouseover='this.style.transform="translateY(-5px) scale(1.02)"; this.style.boxShadow="0 8px 25px rgba(0,0,0,0.15)"'
|
253 |
onmouseout='this.style.transform="translateY(0) scale(1)"; this.style.boxShadow="0 4px 15px rgba(0,0,0,0.1)"'>
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
<span style='font-size: 1.3em'>{random_emojis[1]}</span>
|
264 |
-
<a href='https://{url}' target='_blank'
|
265 |
-
style='text-decoration: none; color: #2d2d2d;'>
|
266 |
-
{name}
|
267 |
-
</a>
|
268 |
-
<span style='font-size: 1.3em'>{random_emojis[2]}</span>
|
269 |
-
</h3>
|
270 |
-
<div style='margin: 15px 0; color: #444; background: rgba(255,255,255,0.5);
|
271 |
-
padding: 15px; border-radius: 12px;'>
|
272 |
-
<p style='margin: 8px 0;'>
|
273 |
-
<strong>Status:</strong> โ
{state}
|
274 |
-
</p>
|
275 |
-
<p style='margin: 8px 0;'>
|
276 |
-
<strong>Created:</strong> ๐
{created}
|
277 |
-
</p>
|
278 |
-
<p style='margin: 8px 0;'>
|
279 |
-
<strong>URL:</strong> ๐ https://{url}
|
280 |
-
</p>
|
281 |
-
</div>
|
282 |
-
<div style='margin-top: 20px;'>
|
283 |
<a href='https://{url}' target='_blank'
|
284 |
style='background: linear-gradient(45deg, #0084ff, #00a3ff);
|
285 |
color: white;
|
@@ -291,9 +274,7 @@ def get_vercel_card(deployment, index):
|
|
291 |
gap: 8px;
|
292 |
font-weight: 500;
|
293 |
transition: all 0.3s;
|
294 |
-
box-shadow: 0 2px 8px rgba(0,132,255,0.3);'
|
295 |
-
onmouseover='this.style.transform="scale(1.05)"; this.style.boxShadow="0 4px 12px rgba(0,132,255,0.4)"'
|
296 |
-
onmouseout='this.style.transform="scale(1)"; this.style.boxShadow="0 2px 8px rgba(0,132,255,0.3)"'>
|
297 |
<span>View Deployment</span> ๐
|
298 |
</a>
|
299 |
</div>
|
@@ -339,18 +320,68 @@ def get_user_spaces():
|
|
339 |
</p>
|
340 |
</div>
|
341 |
|
342 |
-
<!-- Vercel Deployments
|
343 |
<h3 style='color: #333; margin: 20px 0;'>โก Vercel Deployments</h3>
|
344 |
-
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
345 |
{"".join(get_vercel_card(dep, idx) for idx, dep in enumerate(vercel_deployments))}
|
346 |
</div>
|
347 |
|
348 |
-
<!-- Hugging Face Spaces
|
349 |
<h3 style='color: #333; margin: 20px 0;'>๐ค Hugging Face Spaces</h3>
|
350 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
351 |
{"".join(get_space_card(space, idx) for idx, space in enumerate(user_spaces))}
|
352 |
</div>
|
353 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
"""
|
355 |
|
356 |
return html_content
|
|
|
224 |
return []
|
225 |
|
226 |
def get_vercel_card(deployment, index):
|
227 |
+
"""Generate HTML card for a Vercel deployment with like button"""
|
|
|
228 |
raw_url = deployment.get('url', '')
|
229 |
+
project_name = raw_url[:6] if len(raw_url) >= 6 else raw_url
|
230 |
+
url = f"{project_name}.vercel.app"
|
231 |
|
232 |
created = format_timestamp(deployment.get('created'))
|
233 |
name = deployment.get('name', 'Unnamed Project')
|
234 |
state = deployment.get('state', 'N/A')
|
235 |
|
236 |
+
# ๊ณ ์ ID ์์ฑ (์นด๋ ์๋ณ์ฉ)
|
237 |
+
card_id = f"vercel-card-{project_name}"
|
238 |
|
239 |
+
bg_color = get_pastel_color(index + 20)
|
240 |
tech_emojis = ['โก', '๐', '๐', 'โจ', '๐ซ', '๐ฅ', '๐', '๐ฏ', '๐จ', '๐ฎ']
|
241 |
random_emojis = random.sample(tech_emojis, 3)
|
242 |
|
243 |
return f"""
|
244 |
+
<div id="{card_id}" class="vercel-card"
|
245 |
+
data-likes="0"
|
246 |
+
style='border: none;
|
247 |
padding: 25px;
|
248 |
margin: 15px;
|
249 |
border-radius: 20px;
|
|
|
254 |
overflow: hidden;'
|
255 |
onmouseover='this.style.transform="translateY(-5px) scale(1.02)"; this.style.boxShadow="0 8px 25px rgba(0,0,0,0.15)"'
|
256 |
onmouseout='this.style.transform="translateY(0) scale(1)"; this.style.boxShadow="0 4px 15px rgba(0,0,0,0.1)"'>
|
257 |
+
<!-- ... (๊ธฐ์กด ์นด๋ ๋ด์ฉ) ... -->
|
258 |
+
<div style='margin-top: 20px; display: flex; justify-content: space-between; align-items: center;'>
|
259 |
+
<div class="like-section" style="display: flex; align-items: center; gap: 10px;">
|
260 |
+
<button onclick="toggleLike('{card_id}')" class="like-button"
|
261 |
+
style="background: none; border: none; cursor: pointer; font-size: 1.5em;">
|
262 |
+
๐ค
|
263 |
+
</button>
|
264 |
+
<span class="like-count" style="font-size: 1.2em;">0</span>
|
265 |
+
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
266 |
<a href='https://{url}' target='_blank'
|
267 |
style='background: linear-gradient(45deg, #0084ff, #00a3ff);
|
268 |
color: white;
|
|
|
274 |
gap: 8px;
|
275 |
font-weight: 500;
|
276 |
transition: all 0.3s;
|
277 |
+
box-shadow: 0 2px 8px rgba(0,132,255,0.3);'>
|
|
|
|
|
278 |
<span>View Deployment</span> ๐
|
279 |
</a>
|
280 |
</div>
|
|
|
320 |
</p>
|
321 |
</div>
|
322 |
|
323 |
+
<!-- Vercel Deployments -->
|
324 |
<h3 style='color: #333; margin: 20px 0;'>โก Vercel Deployments</h3>
|
325 |
+
<div id="vercel-container" style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
326 |
{"".join(get_vercel_card(dep, idx) for idx, dep in enumerate(vercel_deployments))}
|
327 |
</div>
|
328 |
|
329 |
+
<!-- Hugging Face Spaces -->
|
330 |
<h3 style='color: #333; margin: 20px 0;'>๐ค Hugging Face Spaces</h3>
|
331 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
332 |
{"".join(get_space_card(space, idx) for idx, space in enumerate(user_spaces))}
|
333 |
</div>
|
334 |
</div>
|
335 |
+
|
336 |
+
<script>
|
337 |
+
// ์ข์์ ์ํ ๋ก๋
|
338 |
+
function loadLikes() {
|
339 |
+
const cards = document.querySelectorAll('.vercel-card');
|
340 |
+
cards.forEach(card => {
|
341 |
+
const cardId = card.id;
|
342 |
+
const likes = localStorage.getItem(cardId) || 0;
|
343 |
+
card.querySelector('.like-count').textContent = likes;
|
344 |
+
card.dataset.likes = likes;
|
345 |
+
updateLikeButton(card, likes > 0);
|
346 |
+
});
|
347 |
+
sortCards();
|
348 |
+
}
|
349 |
+
|
350 |
+
// ์ข์์ ๋ฒํผ ํ ๊ธ
|
351 |
+
function toggleLike(cardId) {
|
352 |
+
const card = document.getElementById(cardId);
|
353 |
+
const likeCount = parseInt(localStorage.getItem(cardId) || 0);
|
354 |
+
const newCount = likeCount > 0 ? 0 : 1;
|
355 |
+
|
356 |
+
localStorage.setItem(cardId, newCount);
|
357 |
+
card.querySelector('.like-count').textContent = newCount;
|
358 |
+
card.dataset.likes = newCount;
|
359 |
+
updateLikeButton(card, newCount > 0);
|
360 |
+
|
361 |
+
sortCards();
|
362 |
+
}
|
363 |
+
|
364 |
+
// ์ข์์ ๋ฒํผ ์ํ ์
๋ฐ์ดํธ
|
365 |
+
function updateLikeButton(card, isLiked) {
|
366 |
+
const button = card.querySelector('.like-button');
|
367 |
+
button.textContent = isLiked ? 'โค๏ธ' : '๐ค';
|
368 |
+
}
|
369 |
+
|
370 |
+
// ์นด๋ ์ ๋ ฌ
|
371 |
+
function sortCards() {
|
372 |
+
const container = document.getElementById('vercel-container');
|
373 |
+
const cards = Array.from(container.children);
|
374 |
+
|
375 |
+
cards.sort((a, b) => {
|
376 |
+
return parseInt(b.dataset.likes) - parseInt(a.dataset.likes);
|
377 |
+
});
|
378 |
+
|
379 |
+
cards.forEach(card => container.appendChild(card));
|
380 |
+
}
|
381 |
+
|
382 |
+
// ํ์ด์ง ๋ก๋ ์ ์คํ
|
383 |
+
document.addEventListener('DOMContentLoaded', loadLikes);
|
384 |
+
</script>
|
385 |
"""
|
386 |
|
387 |
return html_content
|