Update app-backup.py
Browse files- app-backup.py +80 -13
app-backup.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;
|
|
@@ -254,18 +257,24 @@ def get_vercel_card(deployment, index):
|
|
| 254 |
<div style='position: absolute; top: -15px; right: -15px; font-size: 100px; opacity: 0.1;'>
|
| 255 |
{random_emojis[0]}
|
| 256 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
<h3 style='color: #2d2d2d;
|
| 258 |
margin: 0 0 20px 0;
|
| 259 |
font-size: 1.4em;
|
| 260 |
display: flex;
|
| 261 |
align-items: center;
|
| 262 |
gap: 10px;'>
|
| 263 |
-
<span style='font-size: 1.3em'>{random_emojis[
|
| 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[
|
| 269 |
</h3>
|
| 270 |
<div style='margin: 15px 0; color: #444; background: rgba(255,255,255,0.5);
|
| 271 |
padding: 15px; border-radius: 12px;'>
|
|
@@ -279,7 +288,14 @@ def get_vercel_card(deployment, index):
|
|
| 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;
|
|
@@ -294,7 +310,7 @@ def get_vercel_card(deployment, index):
|
|
| 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>
|
| 300 |
</div>
|
|
@@ -339,18 +355,69 @@ 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;
|
|
|
|
| 257 |
<div style='position: absolute; top: -15px; right: -15px; font-size: 100px; opacity: 0.1;'>
|
| 258 |
{random_emojis[0]}
|
| 259 |
</div>
|
| 260 |
+
<div style='position: absolute; top: 10px; right: 10px; font-size: 20px;'>
|
| 261 |
+
{random_emojis[1]}
|
| 262 |
+
</div>
|
| 263 |
+
<div style='position: absolute; bottom: 10px; left: 10px; font-size: 20px;'>
|
| 264 |
+
{random_emojis[2]}
|
| 265 |
+
</div>
|
| 266 |
<h3 style='color: #2d2d2d;
|
| 267 |
margin: 0 0 20px 0;
|
| 268 |
font-size: 1.4em;
|
| 269 |
display: flex;
|
| 270 |
align-items: center;
|
| 271 |
gap: 10px;'>
|
| 272 |
+
<span style='font-size: 1.3em'>{random_emojis[0]}</span>
|
| 273 |
<a href='https://{url}' target='_blank'
|
| 274 |
style='text-decoration: none; color: #2d2d2d;'>
|
| 275 |
{name}
|
| 276 |
</a>
|
| 277 |
+
<span style='font-size: 1.3em'>{random_emojis[1]}</span>
|
| 278 |
</h3>
|
| 279 |
<div style='margin: 15px 0; color: #444; background: rgba(255,255,255,0.5);
|
| 280 |
padding: 15px; border-radius: 12px;'>
|
|
|
|
| 288 |
<strong>URL:</strong> ๐ https://{url}
|
| 289 |
</p>
|
| 290 |
</div>
|
| 291 |
+
<div style='margin-top: 20px; display: flex; justify-content: space-between; align-items: center;'>
|
| 292 |
+
<div class="like-section" style="display: flex; align-items: center; gap: 10px;">
|
| 293 |
+
<button onclick="toggleLike('{card_id}')" class="like-button"
|
| 294 |
+
style="background: none; border: none; cursor: pointer; font-size: 1.5em; padding: 5px 10px;">
|
| 295 |
+
๐ค
|
| 296 |
+
</button>
|
| 297 |
+
<span class="like-count" style="font-size: 1.2em; color: #666;">0</span>
|
| 298 |
+
</div>
|
| 299 |
<a href='https://{url}' target='_blank'
|
| 300 |
style='background: linear-gradient(45deg, #0084ff, #00a3ff);
|
| 301 |
color: white;
|
|
|
|
| 310 |
box-shadow: 0 2px 8px rgba(0,132,255,0.3);'
|
| 311 |
onmouseover='this.style.transform="scale(1.05)"; this.style.boxShadow="0 4px 12px rgba(0,132,255,0.4)"'
|
| 312 |
onmouseout='this.style.transform="scale(1)"; this.style.boxShadow="0 2px 8px rgba(0,132,255,0.3)"'>
|
| 313 |
+
<span>View Deployment</span> ๐ {random_emojis[0]}
|
| 314 |
</a>
|
| 315 |
</div>
|
| 316 |
</div>
|
|
|
|
| 355 |
</p>
|
| 356 |
</div>
|
| 357 |
|
| 358 |
+
<!-- Vercel Deployments -->
|
| 359 |
<h3 style='color: #333; margin: 20px 0;'>โก Vercel Deployments</h3>
|
| 360 |
+
<div id="vercel-container" style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
| 361 |
{"".join(get_vercel_card(dep, idx) for idx, dep in enumerate(vercel_deployments))}
|
| 362 |
</div>
|
| 363 |
|
| 364 |
+
<!-- Hugging Face Spaces -->
|
| 365 |
<h3 style='color: #333; margin: 20px 0;'>๐ค Hugging Face Spaces</h3>
|
| 366 |
<div style='display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;'>
|
| 367 |
{"".join(get_space_card(space, idx) for idx, space in enumerate(user_spaces))}
|
| 368 |
</div>
|
| 369 |
</div>
|
| 370 |
+
<script>
|
| 371 |
+
document.addEventListener('DOMContentLoaded', function() {{
|
| 372 |
+
// ์ข์์ ์ํ ๋ก๋
|
| 373 |
+
function loadLikes() {{
|
| 374 |
+
const cards = document.querySelectorAll('.vercel-card');
|
| 375 |
+
cards.forEach(card => {{
|
| 376 |
+
const cardId = card.id;
|
| 377 |
+
const likes = localStorage.getItem(cardId) || 0;
|
| 378 |
+
card.querySelector('.like-count').textContent = likes;
|
| 379 |
+
card.dataset.likes = likes;
|
| 380 |
+
updateLikeButton(card, likes > 0);
|
| 381 |
+
}});
|
| 382 |
+
sortCards();
|
| 383 |
+
}}
|
| 384 |
+
|
| 385 |
+
// ์ข์์ ๋ฒํผ ํ ๊ธ
|
| 386 |
+
window.toggleLike = function(cardId) {{
|
| 387 |
+
const card = document.getElementById(cardId);
|
| 388 |
+
const likeCount = parseInt(localStorage.getItem(cardId) || 0);
|
| 389 |
+
const newCount = likeCount > 0 ? 0 : 1;
|
| 390 |
+
|
| 391 |
+
localStorage.setItem(cardId, newCount);
|
| 392 |
+
card.querySelector('.like-count').textContent = newCount;
|
| 393 |
+
card.dataset.likes = newCount;
|
| 394 |
+
updateLikeButton(card, newCount > 0);
|
| 395 |
+
|
| 396 |
+
sortCards();
|
| 397 |
+
}}
|
| 398 |
+
|
| 399 |
+
// ์ข์์ ๋ฒํผ ์ํ ์
๋ฐ์ดํธ
|
| 400 |
+
function updateLikeButton(card, isLiked) {{
|
| 401 |
+
const button = card.querySelector('.like-button');
|
| 402 |
+
button.textContent = isLiked ? 'โค๏ธ' : '๐ค';
|
| 403 |
+
}}
|
| 404 |
+
|
| 405 |
+
// ์นด๋ ์ ๋ ฌ
|
| 406 |
+
function sortCards() {{
|
| 407 |
+
const container = document.getElementById('vercel-container');
|
| 408 |
+
const cards = Array.from(container.children);
|
| 409 |
+
|
| 410 |
+
cards.sort((a, b) => {{
|
| 411 |
+
return parseInt(b.dataset.likes) - parseInt(a.dataset.likes);
|
| 412 |
+
}});
|
| 413 |
+
|
| 414 |
+
cards.forEach(card => container.appendChild(card));
|
| 415 |
+
}}
|
| 416 |
+
|
| 417 |
+
// ์ด๊ธฐ ๋ก๋
|
| 418 |
+
loadLikes();
|
| 419 |
+
}});
|
| 420 |
+
</script>
|
| 421 |
"""
|
| 422 |
|
| 423 |
return html_content
|