···
"github.com/go-chi/chi/v5"
"battleship-arena/internal/storage"
···
+
padding: 0.5rem 0.875rem;
font-family: 'Monaco', 'Courier New', monospace;
+
border: 1px solid #1e3a8a;
+
border: 1px solid #1e3a8a;
+
justify-content: space-between;
+
border-bottom: 1px solid #1e3a8a;
+
text-transform: uppercase;
+
letter-spacing: 0.05em;
+
padding: 0.25rem 0.75rem;
+
border-radius: 0.25rem;
+
transition: background 0.2s;
+
.code-block-copy:hover {
+
.code-block-copy.copied {
+
background: transparent;
+
.code-block .token-command {
+
.code-block .token-flag {
+
.code-block .token-string {
+
.code-block .token-comment {
···
window.addEventListener('DOMContentLoaded', () => {
+
function copyCode(button, text) {
+
// Decode HTML entities in template variables
+
const tempDiv = document.createElement('div');
+
tempDiv.innerHTML = text;
+
const decodedText = tempDiv.textContent || tempDiv.innerText;
+
navigator.clipboard.writeText(decodedText).then(() => {
+
const originalText = button.textContent;
+
button.textContent = 'Copied!';
+
button.classList.add('copied');
+
button.textContent = originalText;
+
button.classList.remove('copied');
+
console.error('Failed to copy:', err);
···
<p><strong>First time?</strong> Connect via SSH to create your account:</p>
+
<div class="code-block">
+
<div class="code-block-header">
+
<span class="code-block-lang">bash</span>
+
<button class="code-block-copy" onclick="copyCode(this, 'ssh -p 2222 {{.ServerURL}}')">Copy</button>
+
<pre><code><span class="token-command">ssh</span> <span class="token-flag">-p</span> <span class="token-string">2222</span> <span class="token-string">{{.ServerURL}}</span></code></pre>
<p style="margin-top: 0.5rem; color: #94a3b8;">You'll be prompted for your name, bio, and link. Your SSH key will be registered.</p>
<p style="margin-top: 1rem;"><strong>Upload your AI:</strong></p>
+
<div class="code-block">
+
<div class="code-block-header">
+
<span class="code-block-lang">bash</span>
+
<button class="code-block-copy" onclick="copyCode(this, 'scp -P 2222 memory_functions_yourname.cpp {{.ServerURL}}:~/')">Copy</button>
+
<pre><code><span class="token-command">scp</span> <span class="token-flag">-P</span> <span class="token-string">2222</span> <span class="token-string">memory_functions_yourname.cpp</span> <span class="token-string">{{.ServerURL}}:~/</span></code></pre>
<p style="margin-top: 1rem; color: #94a3b8;">
<a href="/users" style="color: #60a5fa;">View all players →</a>
···
entries = []storage.LeaderboardEntry{}
// Get matches for bracket
matches, err := storage.GetAllMatches()
···
json.NewEncoder(w).Encode(entries)
func calculateTotalGames(entries []storage.LeaderboardEntry) int {
for _, e := range entries {
···
http.Error(w, "Username required", http.StatusBadRequest)
// Get submission ID for this username
err := storage.DB.QueryRow(
"SELECT id FROM submissions WHERE username = ? AND is_active = 1",
http.Error(w, "Player not found", http.StatusNotFound)
history, err := storage.GetRatingHistory(submissionID)
http.Error(w, fmt.Sprintf("Failed to get rating history: %v", err), http.StatusInternalServerError)
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(history)
···
http.Redirect(w, r, "/", http.StatusSeeOther)
tmpl := template.Must(template.New("player").Parse(playerPageHTML))
tmpl.Execute(w, map[string]string{"Username": username})
···