feat: add weblink playlists, SSH player deployment, Caddy HTTPS, build player page

- Content model: add url column + is_weblink() for web page content items
- Player model: add deployment tracking fields (status, timestamps, message)
- Content blueprint: add add_weblink and add_weblink_to_playlist routes;
  weblinks auto-deleted when removed from playlist
- Players blueprint: add SSH deploy mode in add_player; weblink-aware playlist
- API blueprint: weblink URL served directly in playlist response;
  add /api/deploy/test-ssh and /api/deploy/player endpoints
- Admin blueprint: add build-player page (clone from Gitea, write base config);
  replace nginx status card with Caddy status on HTTPS config page
- caddy_manager: rewritten to generate proper HTTPS/internal-CA Caddyfiles
  and reload Caddy via admin API (/load) for live config updates
- ssh_deploy, background_tasks, player_build: new utils for SSH deployment
- background_tasks: push Flask app context into background thread so DB
  updates after deployment complete correctly
- ssh_deploy: robust install script detection with passwordless sudo injection
  (uses SSH credentials, cleaned up after install)
- Dockerfile: add git, sshpass, openssh-client, rsync
- docker-compose: switch nginx to Caddy on ports 80/443; add port 5000 for dev
- Templates: add_player deploy mode UI, weblink form in playlist/upload pages,
  build_player admin page, Caddy status on HTTPS config page
- Migrations: add_url_to_content, add_deployment_fields_to_player
- app.py: call db.create_all() on startup for schema bootstrap
- config.py: add PLAYER_CODE_DIR and PLAYER_REPO_URL settings
This commit is contained in:
2026-07-13 16:46:19 +03:00
parent ae3b82862d
commit 2af04e1db3
24 changed files with 2571 additions and 248 deletions
+98
View File
@@ -317,6 +317,66 @@
</form>
</div>
<!-- ── Web Link Card ─────────────────────────────────────────────────────── -->
<div class="card" style="margin-top: 20px;">
<h2 style="margin-bottom: 15px; font-size: 18px; display: flex; align-items: center; gap: 0.5rem;">
🌐 Add Web Page Link
</h2>
<p style="color: #6c757d; font-size: 13px; margin-bottom: 16px;">
Add a website URL to display on the player (e.g. a dashboard, live feed, or any public web page).
</p>
<form id="weblink-form" method="POST" action="{{ request.script_root }}/content/add-weblink">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 16px;">
<!-- URL -->
<div class="form-group" style="grid-column: 1 / -1;">
<label for="wl-url">Web Page URL <span style="color:#e53e3e;">*</span></label>
<input type="url" id="wl-url" name="url" class="form-control"
placeholder="https://example.com" required>
<small style="color:#6c757d; font-size:11px;">Must start with http:// or https://</small>
</div>
<!-- Description -->
<div class="form-group">
<label for="wl-description">Label / Description</label>
<input type="text" id="wl-description" name="description" class="form-control"
placeholder="e.g. Live Dashboard">
<small style="color:#6c757d; font-size:11px;">Optional — shown in the media library</small>
</div>
<!-- Duration -->
<div class="form-group">
<label for="wl-duration">Display Duration (seconds)</label>
<input type="number" id="wl-duration" name="duration" class="form-control"
value="30" min="5" max="3600">
<small style="color:#6c757d; font-size:11px;">How long to show the page per loop</small>
</div>
<!-- Playlist -->
<div class="form-group" style="grid-column: 1 / -1;">
<label for="wl-playlist">Add to Playlist (Optional)</label>
<select id="wl-playlist" name="playlist_id" class="form-control">
<option value="">-- Media Library Only --</option>
{% for playlist in playlists %}
<option value="{{ playlist.id }}">
{{ playlist.name }} ({{ playlist.orientation }}) — {{ playlist.content_count }} items
</option>
{% endfor %}
</select>
</div>
</div>
<div style="display:flex; align-items:center; gap:12px; margin-top:8px;">
<button type="submit" class="btn-upload" id="wl-submit-btn"
style="display:inline-flex; align-items:center; gap:0.5rem; padding:10px 24px;">
🌐 Add Web Link
</button>
<span id="wl-status" style="font-size:13px; display:none;"></span>
</div>
</form>
</div>
<script>
const uploadZone = document.getElementById('upload-zone');
const fileInput = document.getElementById('file-input');
@@ -509,6 +569,44 @@
uploadBtn.disabled = true;
uploadBtn.innerHTML = '⏳ Uploading...';
});
// ── Web Link form — AJAX submit ────────────────────────────────────────
const wlForm = document.getElementById('weblink-form');
const wlBtn = document.getElementById('wl-submit-btn');
const wlStatus = document.getElementById('wl-status');
wlForm.addEventListener('submit', async (e) => {
e.preventDefault();
wlBtn.disabled = true;
wlBtn.textContent = '⏳ Adding…';
wlStatus.style.display = 'none';
try {
const resp = await fetch(wlForm.action, {
method: 'POST',
headers: { 'X-Requested-With': 'XMLHttpRequest' },
body: new FormData(wlForm),
});
const data = await resp.json();
if (data.success) {
wlStatus.style.color = '#38a169';
wlStatus.textContent = '✓ ' + data.message;
wlForm.reset();
document.getElementById('wl-duration').value = 30;
} else {
wlStatus.style.color = '#e53e3e';
wlStatus.textContent = '✗ ' + (data.error || 'Failed to add web link.');
}
} catch (err) {
wlStatus.style.color = '#e53e3e';
wlStatus.textContent = '✗ Network error — please try again.';
}
wlStatus.style.display = 'inline';
wlBtn.disabled = false;
wlBtn.innerHTML = '🌐 Add Web Link';
});
</script>
{% endblock %}