Spaces:
Running
Running
Fix Space startup: sync full app source
Browse files- src/display/css_html_js.py +11 -124
src/display/css_html_js.py
CHANGED
|
@@ -1,131 +1,18 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
from __future__ import annotations
|
| 4 |
-
|
| 5 |
-
import time
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
def build_custom_css() -> str:
|
| 9 |
-
return """
|
| 10 |
.markdown-text { font-size: 16px !important; }
|
| 11 |
.tab-buttons button { font-size: 20px; }
|
| 12 |
#leaderboard-table { margin-top: 15px; }
|
| 13 |
-
.
|
| 14 |
-
margin:
|
| 15 |
-
|
|
|
|
|
|
|
| 16 |
}
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
color: #94a3b8;
|
| 20 |
-
margin-bottom: 0.45rem;
|
| 21 |
-
}
|
| 22 |
-
.eval-countdown-track {
|
| 23 |
-
width: 100%;
|
| 24 |
-
height: 8px;
|
| 25 |
-
border-radius: 999px;
|
| 26 |
-
background: rgba(148, 163, 184, 0.2);
|
| 27 |
-
overflow: hidden;
|
| 28 |
}
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
border-radius: 999px;
|
| 33 |
-
background: linear-gradient(90deg, #f97316, #fb923c);
|
| 34 |
-
transition: width 1s linear;
|
| 35 |
}
|
| 36 |
"""
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
def _format_remaining(total_seconds: int) -> str:
|
| 40 |
-
total_seconds = max(0, total_seconds)
|
| 41 |
-
hours = total_seconds // 3600
|
| 42 |
-
minutes = (total_seconds % 3600) // 60
|
| 43 |
-
seconds = total_seconds % 60
|
| 44 |
-
if hours > 0:
|
| 45 |
-
return f"{hours}h {minutes}m {seconds}s"
|
| 46 |
-
if minutes > 0:
|
| 47 |
-
return f"{minutes}m {seconds}s"
|
| 48 |
-
return f"{seconds}s"
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
def eval_countdown_markup(next_eval_at_unix: int, interval_seconds: int, running: bool = False) -> str:
|
| 52 |
-
if running:
|
| 53 |
-
label = "Evaluation in progress…"
|
| 54 |
-
progress = 0
|
| 55 |
-
else:
|
| 56 |
-
remaining = max(0, next_eval_at_unix - int(time.time()))
|
| 57 |
-
elapsed = max(0, interval_seconds - remaining)
|
| 58 |
-
progress = min(100, (elapsed / interval_seconds) * 100) if interval_seconds > 0 else 0
|
| 59 |
-
label = f"Next eval in {_format_remaining(remaining)}"
|
| 60 |
-
|
| 61 |
-
return f"""
|
| 62 |
-
<div class="eval-countdown-wrap" id="tsfm-eval-countdown"
|
| 63 |
-
data-next-at="{next_eval_at_unix}"
|
| 64 |
-
data-interval="{interval_seconds}"
|
| 65 |
-
data-running="{'1' if running else '0'}">
|
| 66 |
-
<div class="eval-countdown-label" id="tsfm-eval-countdown-label">{label}</div>
|
| 67 |
-
<div class="eval-countdown-track">
|
| 68 |
-
<div class="eval-countdown-fill" id="tsfm-eval-countdown-fill" style="width: {progress:.2f}%;"></div>
|
| 69 |
-
</div>
|
| 70 |
-
</div>
|
| 71 |
-
"""
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
def eval_countdown_head_js() -> str:
|
| 75 |
-
"""Countdown to next eval cycle; uses server-persisted absolute deadline."""
|
| 76 |
-
return """
|
| 77 |
-
<script>
|
| 78 |
-
(function () {
|
| 79 |
-
function formatRemaining(totalSeconds) {
|
| 80 |
-
const h = Math.floor(totalSeconds / 3600);
|
| 81 |
-
const m = Math.floor((totalSeconds % 3600) / 60);
|
| 82 |
-
const s = totalSeconds % 60;
|
| 83 |
-
if (h > 0) {
|
| 84 |
-
return h + "h " + m + "m " + s + "s";
|
| 85 |
-
}
|
| 86 |
-
if (m > 0) {
|
| 87 |
-
return m + "m " + s + "s";
|
| 88 |
-
}
|
| 89 |
-
return s + "s";
|
| 90 |
-
}
|
| 91 |
-
|
| 92 |
-
function tick() {
|
| 93 |
-
const root = document.getElementById("tsfm-eval-countdown");
|
| 94 |
-
const label = document.getElementById("tsfm-eval-countdown-label");
|
| 95 |
-
const fill = document.getElementById("tsfm-eval-countdown-fill");
|
| 96 |
-
if (!root || !label || !fill) return;
|
| 97 |
-
|
| 98 |
-
if (root.dataset.running === "1") {
|
| 99 |
-
label.textContent = "Evaluation in progress…";
|
| 100 |
-
fill.style.width = "0%";
|
| 101 |
-
return;
|
| 102 |
-
}
|
| 103 |
-
|
| 104 |
-
const nextAt = parseInt(root.dataset.nextAt || "0", 10);
|
| 105 |
-
const interval = parseInt(root.dataset.interval || "3600", 10);
|
| 106 |
-
const remaining = Math.max(0, nextAt - Math.floor(Date.now() / 1000));
|
| 107 |
-
const elapsed = Math.max(0, interval - remaining);
|
| 108 |
-
const pct = interval > 0 ? Math.min(100, (elapsed / interval) * 100) : 0;
|
| 109 |
-
|
| 110 |
-
label.textContent = "Next eval in " + formatRemaining(remaining);
|
| 111 |
-
fill.style.width = pct + "%";
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
function startInterval() {
|
| 115 |
-
if (window.__tsfmEvalCountdownId) return;
|
| 116 |
-
window.__tsfmEvalCountdownId = setInterval(tick, 1000);
|
| 117 |
-
}
|
| 118 |
-
|
| 119 |
-
function boot() {
|
| 120 |
-
tick();
|
| 121 |
-
startInterval();
|
| 122 |
-
}
|
| 123 |
-
|
| 124 |
-
if (document.readyState === "loading") {
|
| 125 |
-
document.addEventListener("DOMContentLoaded", boot);
|
| 126 |
-
} else {
|
| 127 |
-
boot();
|
| 128 |
-
}
|
| 129 |
-
})();
|
| 130 |
-
</script>
|
| 131 |
-
"""
|
|
|
|
| 1 |
+
custom_css = """
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
.markdown-text { font-size: 16px !important; }
|
| 3 |
.tab-buttons button { font-size: 20px; }
|
| 4 |
#leaderboard-table { margin-top: 15px; }
|
| 5 |
+
.domain-heading {
|
| 6 |
+
margin-top: 1.75rem;
|
| 7 |
+
margin-bottom: 0.5rem;
|
| 8 |
+
font-size: 1.15rem;
|
| 9 |
+
font-weight: 600;
|
| 10 |
}
|
| 11 |
+
#refresh-progress input[type="range"] {
|
| 12 |
+
accent-color: #f97316;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
}
|
| 14 |
+
#refresh-progress label span {
|
| 15 |
+
font-size: 0.9rem;
|
| 16 |
+
color: #64748b;
|
|
|
|
|
|
|
|
|
|
| 17 |
}
|
| 18 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|