seawolf2357 commited on
Commit
ec2806b
ยท
verified ยท
1 Parent(s): b6c1706

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -62
app.py CHANGED
@@ -469,6 +469,7 @@ def load_session_history(selected_session=None):
469
  transition: all 0.3s ease;
470
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
471
  min-height: 300px;
 
472
  }
473
  .prompt-card:hover {
474
  transform: translateY(-2px);
@@ -476,7 +477,7 @@ def load_session_history(selected_session=None):
476
  }
477
  .card-image {
478
  width: 100%;
479
- height: 200px;
480
  object-fit: cover;
481
  border-radius: 4px;
482
  margin-bottom: 10px;
@@ -485,87 +486,38 @@ def load_session_history(selected_session=None):
485
  font-weight: bold;
486
  margin-bottom: 8px;
487
  font-size: 16px;
 
488
  }
489
  .card-prompt {
490
- font-size: 0.9em;
 
491
  color: #666;
492
- margin-bottom: 10px;
493
- }
494
- .copy-button {
495
- padding: 5px 10px;
496
- background: #f0f0f0;
497
- border: 1px solid #ddd;
 
 
498
  border-radius: 4px;
499
- cursor: pointer;
500
- font-size: 0.9em;
501
- transition: all 0.2s ease;
502
- }
503
- .copy-button:hover {
504
- background: #e0e0e0;
505
  }
506
  </style>
507
  <div class="prompt-grid">
508
  """
509
 
510
  for item in json_data:
511
- # JSON์œผ๋กœ ์ง๋ ฌํ™”ํ•˜์—ฌ JavaScript ๋ฌธ์ž์—ด๋กœ ์•ˆ์ „ํ•˜๊ฒŒ ๋ณ€ํ™˜
512
- prompt_json = json.dumps(item.get('prompt', ''))
513
  html_content += f"""
514
  <div class="prompt-card">
515
  <img src="{item.get('image_url', '')}" class="card-image" alt="{html.escape(item.get('name', ''))}">
516
  <div class="card-name">{html.escape(item.get('name', ''))}</div>
517
  <div class="card-prompt">{html.escape(item.get('prompt', ''))}</div>
518
- <button class="copy-button" data-prompt={prompt_json}>
519
- ๐Ÿ“‹ ๋ณต์‚ฌ
520
- </button>
521
  </div>
522
  """
523
 
524
  html_content += """
525
  </div>
526
- <script>
527
- // ๋ชจ๋“  ๋ณต์‚ฌ ๋ฒ„ํŠผ์— ์ด๋ฒคํŠธ ๋ฆฌ์Šค๋„ˆ ์ถ”๊ฐ€
528
- document.addEventListener('DOMContentLoaded', function() {
529
- document.querySelectorAll('.copy-button').forEach(button => {
530
- button.addEventListener('click', async function(e) {
531
- e.preventDefault();
532
- e.stopPropagation();
533
-
534
- const promptText = this.dataset.prompt;
535
-
536
- try {
537
- // ํ…์ŠคํŠธ ์˜์—ญ ์ƒ์„ฑ ๋ฐ ์„ค์ •
538
- const textarea = document.createElement('textarea');
539
- textarea.value = promptText;
540
- textarea.style.position = 'fixed';
541
- textarea.style.left = '-9999px';
542
- document.body.appendChild(textarea);
543
- textarea.select();
544
-
545
- // ๋ณต์‚ฌ ์‹œ๋„
546
- document.execCommand('copy');
547
- document.body.removeChild(textarea);
548
-
549
- // ๋ฒ„ํŠผ ์ƒํƒœ ์—…๋ฐ์ดํŠธ
550
- this.textContent = 'โœ“ ๋ณต์‚ฌ๋จ';
551
- this.style.backgroundColor = '#52c41a';
552
- this.style.color = 'white';
553
-
554
- // 2์ดˆ ํ›„ ์›๋ž˜ ์ƒํƒœ๋กœ ๋ณต๊ตฌ
555
- setTimeout(() => {
556
- this.textContent = '๐Ÿ“‹ ๋ณต์‚ฌ';
557
- this.style.backgroundColor = '#f0f0f0';
558
- this.style.color = 'inherit';
559
- }, 2000);
560
-
561
- } catch (err) {
562
- console.error('๋ณต์‚ฌ ์‹คํŒจ:', err);
563
- alert('๋ณต์‚ฌ์— ์‹คํŒจํ–ˆ์Šต๋‹ˆ๋‹ค. ์ง์ ‘ ํ…์ŠคํŠธ๋ฅผ ์„ ํƒํ•˜์—ฌ ๋ณต์‚ฌํ•ด์ฃผ์„ธ์š”.');
564
- }
565
- });
566
- });
567
- });
568
- </script>
569
  """
570
 
571
  return gr.HTML(value=html_content)
 
469
  transition: all 0.3s ease;
470
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
471
  min-height: 300px;
472
+ cursor: pointer;
473
  }
474
  .prompt-card:hover {
475
  transform: translateY(-2px);
 
477
  }
478
  .card-image {
479
  width: 100%;
480
+ height: 180px;
481
  object-fit: cover;
482
  border-radius: 4px;
483
  margin-bottom: 10px;
 
486
  font-weight: bold;
487
  margin-bottom: 8px;
488
  font-size: 16px;
489
+ color: #333;
490
  }
491
  .card-prompt {
492
+ font-size: 11px;
493
+ line-height: 1.4;
494
  color: #666;
495
+ display: -webkit-box;
496
+ -webkit-line-clamp: 6;
497
+ -webkit-box-orient: vertical;
498
+ overflow: hidden;
499
+ text-overflow: ellipsis;
500
+ height: 90px;
501
+ background-color: #f8f9fa;
502
+ padding: 8px;
503
  border-radius: 4px;
504
+ border: 1px solid #eee;
 
 
 
 
 
505
  }
506
  </style>
507
  <div class="prompt-grid">
508
  """
509
 
510
  for item in json_data:
 
 
511
  html_content += f"""
512
  <div class="prompt-card">
513
  <img src="{item.get('image_url', '')}" class="card-image" alt="{html.escape(item.get('name', ''))}">
514
  <div class="card-name">{html.escape(item.get('name', ''))}</div>
515
  <div class="card-prompt">{html.escape(item.get('prompt', ''))}</div>
 
 
 
516
  </div>
517
  """
518
 
519
  html_content += """
520
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
521
  """
522
 
523
  return gr.HTML(value=html_content)