diff --git a/README.md b/README.md index c2ad1cb..a435f99 100644 --- a/README.md +++ b/README.md @@ -12,20 +12,6 @@ Simple Goal List - Ahead of time uploading of pictures and videos from external devices - USB media awareness/playback -## Home dashboard - -The homepage groups tasks into playback, adding media, and checking download -activity. **Open media library** is the main playback action; the four media -cards lead to image uploads, video uploads, stream configuration, and YouTube -requests. **View download jobs** opens the download queue. TV and screen controls -are explicitly marked coming soon rather than shown as working buttons. - -A selection panel checks the existing playback-status endpoint every five seconds. -It shows the requested selection, not proof that the player is running. If status -is unavailable, navigation still works; without JavaScript, the panel directs -users to the library. The responsive homepage uses local styles/icons and keeps -the original beige background. - ## Fullscreen player Install FFplay (usually provided by FFmpeg), then run the player in the graphical @@ -61,7 +47,7 @@ Ctrl+C or SIGTERM stops the child process; a child that ignores termination is killed after two seconds. The player does not modify the database and currently does not apply `media_playback_option` records. -Use **Open media library** from the home page to select an item in the unified library. +Use **Play Media** from the home page to select an item in the unified library. Alternatively, set selection flags directly in SQLite. For example, select media ID 3 without temporarily leaving several active rows: @@ -79,7 +65,7 @@ just an SSH shell without display access. ## Media library and playback selection -Choose **Open media library** from the homepage, or visit `/media`. All media types share +Open **Play Media** from the homepage, or visit `/media`. All media types share one page, with a **Play** button per item and image/video/stream icons. Clicking Play clears the previous active selection and activates the new item in a single database transaction; default flags are preserved. The separate player picks up @@ -134,7 +120,7 @@ an incomplete media entry. Retrying a failed upload starts it from the beginning ## Uploading local videos -Use **Upload a video** on the home page, or visit `/upload/video`. Enter a display +Use **Upload a Video** on the home page, or visit `/upload/video`. Enter a display name and select one video. The limit is 5GB (5 × 1024³ bytes), checked both in the browser and on the server. Common formats including MP4, MKV, MOV, WebM, AVI, MPEG, and WMV are accepted by extension. Before saving, FFprobe checks for a @@ -160,7 +146,7 @@ space for both Flask's temporary upload and the final video file. ## Uploading static images -Use **Upload an image** on the home page, or visit `/upload/photo`. Enter +Use **Upload a Static Image** on the home page, or visit `/upload/photo`. Enter an image name and choose one JPG/JPEG, PNG, WebP, BMP, TIFF, or GIF file. Files are checked against their extensions and decoded for validation. Images may be animated, but only the first frame is checked; dimensions are limited to 50 @@ -209,7 +195,7 @@ The default `Videos/` folder is excluded from Git. ### Web interface Start the Flask app with `python3 sc_webserver.py` and use the home page's -**Get a YouTube video** link, or visit `/youtube/download`. Enter a media name +**Get Video from YouTube** link, or visit `/youtube/download`. Enter a media name and a YouTube video URL to queue a job. Invalid submissions show an error without creating a job; successful submissions redirect to `/youtube/jobs`. @@ -276,5 +262,5 @@ WHERE youtube_download_job_id = 123 Run the database and worker tests without downloading any videos: ```sh -python3 -m unittest test.youtube_download_job_test test.youtube_download_web_test test.upload_video_test test.upload_photo_test test.player_test test.media_library_test test.submission_validation_test test.home_test -v +python3 -m unittest test.youtube_download_job_test test.youtube_download_web_test test.upload_video_test test.upload_photo_test test.player_test test.media_library_test test.submission_validation_test -v ``` \ No newline at end of file diff --git a/TODO.md b/TODO.md index 09dfb9c..007d5f1 100644 --- a/TODO.md +++ b/TODO.md @@ -9,8 +9,8 @@ an FFplay-based player with unified playback selection; device control is still - [x] Set up a Flask web server with configuration loaded from `config.json`. - [x] Organize implemented pages into Flask blueprints. -- [x] Build a responsive home dashboard with a primary playback action, grouped - media-submission cards, download activity, and a live selection summary. +- [x] Build a Bootstrap-based home page with controls grouped into common tools, + playback, and media submission. - [x] Create the configured upload directory automatically when the server starts. - [x] Upload named static images (up to 100MB) to the configurable `Images` folder, show progress and navigation warnings, and return home after saving the file @@ -29,7 +29,7 @@ an FFplay-based player with unified playback selection; device control is still - [x] Link the home page to a unified media library with Play buttons, live selection indicators, media-type icons, and cached local image/video thumbnails. -- [ ] Implement backend actions for TV and screen controls currently marked coming soon. +- [ ] Connect the existing placeholder controls to backend actions. - [x] Add input validation for media names, duplicate names, stream URLs, and uploaded files. - [ ] Ensure upload destinations remain inside the configured upload directory. diff --git a/blueprints/home/home.html b/blueprints/home/home.html index 7aa1668..8cdcd3f 100644 --- a/blueprints/home/home.html +++ b/blueprints/home/home.html @@ -1,128 +1,38 @@ -{% macro icon(name) -%} - -{%- endmacro %} - + - + Video Commander - Sanctuary Commander - - - + + + - -
-
- - {{ icon('screen') }} - Sanctuary Commander - - MEDIA CONTROL HOME -
- -
-
-
-

YOUR CONTROL CENTER

-

Your media,
ready for the moment.

-

Choose what’s on screen, prepare content ahead of time, and keep everything in one place.

- - Open media library {{ icon('arrow') }} - -
- - -
- -
-
-
-

BUILD YOUR LIBRARY

-

Add something new.

-
-

Get your content ready before you need it.

-
- -
- -
- {{ icon('download') }} -
-

DOWNLOAD ACTIVITY

-

YouTube downloads

-

Review pending, in-progress, and failed downloads.

-
- - View download jobs {{ icon('arrow') }} - -
- -
- {{ icon('screen') }} -
-

TV & screen controls

COMING SOON
-

TV power, disable video, and blackout controls aren’t available yet.

-
-
-
- - + +
+

Sanctuary Commander

+
+

Common Tools

+
+ + + +
+
+

Play Something

+ +
+

Add Something

+ +
- + \ No newline at end of file diff --git a/static/home.css b/static/home.css deleted file mode 100644 index bbeb78f..0000000 --- a/static/home.css +++ /dev/null @@ -1,250 +0,0 @@ -/* Homepage styles are scoped to .home-page; the rest of the app keeps its own layout. */ -.home-page { - color: #293b34; - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; - margin: 0; - -webkit-font-smoothing: antialiased; -} - -.home-page *, .home-page *::before, .home-page *::after { - box-sizing: border-box; -} - -.home-page a { - color: inherit; - text-decoration: none; -} - -.home-page a:focus-visible { - outline: 3px solid #8a5735; - outline-offset: 4px; -} - -.home-shell { - width: min(100% - 80px, 1220px); - margin: 0 auto; -} - -.home-header { - display: flex; - justify-content: space-between; - align-items: center; - min-height: 94px; - border-bottom: 1px solid rgba(65, 68, 52, .19); -} - -.brand { - display: inline-flex; - gap: 12px; - align-items: center; -} - -.brand-mark, .action-icon, .download-icon, .upcoming-icon { - display: grid; - place-items: center; - flex: none; -} - -.brand-mark { - width: 39px; - height: 39px; - border-radius: 11px; - background: #344c40; - color: #fffaf0; -} - -.brand-mark svg { width: 22px; height: 22px; } -.brand-name { font-family: Georgia, "Times New Roman", serif; font-weight: 700; font-size: 19px; letter-spacing: -.5px; } -.brand-name span { font-weight: 400; } -.header-label { color: #6b6858; font-size: 10px; letter-spacing: .16em; font-weight: 700; } -.header-label span { margin: 0 9px; color: #9d8f75; } - -.hero { - display: grid; - grid-template-columns: minmax(0, 1fr) minmax(300px, 405px); - gap: clamp(40px, 7vw, 110px); - align-items: center; - padding: 74px 0 82px; -} - -.eyebrow { - margin: 0; - color: #756b56; - font-size: 10px; - font-weight: 750; - letter-spacing: .16em; - line-height: 1.4; -} - -.hero-copy > .eyebrow { display: flex; align-items: center; gap: 10px; } -.eyebrow-line { width: 25px; height: 2px; background: #a17d55; } - -.hero h1, .section-heading h2 { - font-family: Georgia, "Times New Roman", serif; - font-weight: 400; - letter-spacing: -.045em; -} - -.hero h1 { - margin: 24px 0 20px; - color: #293c32; - font-size: clamp(42px, 5.35vw, 72px); - line-height: 1.06; -} - -.hero h1 em { color: #8a694d; font-weight: 400; } -.hero-description { max-width: 460px; margin: 0 0 30px; color: #5e6255; font-size: 17px; line-height: 1.7; } - -.primary-link, .secondary-link { - display: inline-flex; - align-items: center; - justify-content: center; - gap: 24px; - min-height: 52px; - padding: 13px 17px 13px 20px; - border-radius: 8px; - font-size: 14px; - font-weight: 700; - transition: background-color .18s ease, transform .18s ease; -} - -.home-page .primary-link { background: #344c40; color: #fffdf7; } -.primary-link:hover { background: #22372c; transform: translateY(-2px); } -.link-arrow, .action-arrow { display: inline-flex; flex: none; } -.link-arrow svg, .action-arrow svg { width: 18px; height: 18px; } - -.selection-card { - position: relative; - overflow: hidden; - min-width: 0; - padding: 26px 29px 28px; - border: 1px solid rgba(255, 255, 255, .12); - border-radius: 16px; - background: #334b3f; - box-shadow: 0 18px 36px rgba(63, 57, 39, .13); - color: #fff9ec; -} - -.selection-card::after { - content: ""; - position: absolute; - width: 250px; - height: 250px; - right: -105px; - top: -150px; - border: 1px solid rgba(237, 228, 202, .13); - border-radius: 50%; - box-shadow: 0 0 0 38px rgba(237, 228, 202, .025), 0 0 0 76px rgba(237, 228, 202, .025); - pointer-events: none; -} - -.selection-topline { display: flex; align-items: center; justify-content: space-between; } -.selection-label, .selection-caption { font-size: 10px; font-weight: 700; letter-spacing: .16em; } -.selection-label { color: #e4d9bc; } -.selection-sparkle { color: #dbc998; font-size: 23px; line-height: 1; } -.selection-visual { display: flex; flex-direction: column; align-items: center; padding: 27px 0 21px; } -.screen-art { position: relative; display: grid; place-items: center; width: 138px; height: 83px; border: 1px solid rgba(240, 231, 205, .44); border-radius: 7px; background: rgba(255, 255, 255, .035); } -.screen-art-play { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid rgba(240, 231, 205, .48); border-radius: 50%; color: #eee2c7; } -.screen-art-play svg { width: 15px; height: 15px; margin-left: 2px; } -.screen-art-line { position: absolute; right: 8px; bottom: 8px; left: 8px; height: 1px; background: rgba(240, 231, 205, .25); } -.screen-art-base { width: 44px; height: 7px; border-bottom: 1px solid rgba(240, 231, 205, .45); border-left: 1px solid rgba(240, 231, 205, .45); border-right: 1px solid rgba(240, 231, 205, .45); } -.selection-content { border-top: 1px solid rgba(240, 231, 205, .17); padding-top: 17px; } -.selection-caption { margin: 0 0 7px; color: #dfd0b1; } -.selection-name { margin: 0; color: #fffdf6; font-size: 17px; font-weight: 650; line-height: 1.35; overflow-wrap: anywhere; } -.selection-detail { margin: 7px 0 0; color: #e0e4d6; font-size: 12px; line-height: 1.55; } - -.prepare-section { padding-bottom: 22px; } -.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 25px; } -.section-heading h2 { margin: 7px 0 0; color: #293c32; font-size: clamp(30px, 3vw, 40px); line-height: 1.15; } -.heading-period { color: #a47a54; } -.section-heading > p { margin: 0 0 4px; color: #646758; font-size: 14px; line-height: 1.5; } -.action-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; } - -.home-page .action-card { - position: relative; - display: flex; - flex-direction: column; - min-height: 198px; - padding: 21px; - border: 1px solid rgba(105, 99, 80, .16); - border-radius: 12px; - background: #f8f5ec; - box-shadow: 0 3px 10px rgba(73, 66, 49, .035); - transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; -} - -.action-card:hover { transform: translateY(-3px); border-color: #a6a289; box-shadow: 0 10px 20px rgba(73, 66, 49, .09); } -.action-icon { width: 43px; height: 43px; margin-bottom: 19px; border-radius: 10px; } -.action-icon svg, .download-icon svg, .upcoming-icon svg { width: 22px; height: 22px; } -.icon-image { background: #e5eadc; color: #46664c; } -.icon-video { background: #e7e3d8; color: #655b4c; } -.icon-stream { background: #e0e9e3; color: #41675a; } -.icon-youtube { background: #f0e1d7; color: #94563f; } -.action-card-copy { display: flex; flex-direction: column; padding-right: 12px; } -.action-title { color: #2c3d34; font-size: 15px; font-weight: 700; line-height: 1.35; } -.action-description { max-width: 190px; margin-top: 7px; color: #666c5e; font-size: 13px; line-height: 1.5; } -.action-arrow { position: absolute; right: 20px; bottom: 20px; color: #697a67; } - -.download-panel { - display: flex; - align-items: center; - gap: 18px; - padding: 22px 24px; - border: 1px solid rgba(105, 99, 80, .16); - border-radius: 12px; - background: #f2ede0; -} - -.download-icon { width: 45px; height: 45px; border-radius: 10px; background: #e1ded0; color: #4d6150; } -.download-copy { flex: 1; min-width: 0; } -.download-copy h2 { margin: 5px 0 3px; font-size: 16px; line-height: 1.3; } -.download-copy > p:last-child { margin: 0; color: #64695b; font-size: 13px; line-height: 1.5; } -.home-page .secondary-link { flex: none; gap: 14px; border: 1px solid #a2a394; background: transparent; color: #344c40; font-size: 13px; } -.secondary-link:hover { background: #e5e5d8; } - -.upcoming-panel { display: flex; align-items: flex-start; gap: 12px; margin-top: 29px; padding: 0 2px; } -.upcoming-icon { width: 24px; height: 24px; color: #777b6c; } -.upcoming-icon svg { width: 20px; height: 20px; } -.upcoming-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; } -.upcoming-title-row h2 { margin: 0; color: #525c50; font-size: 13px; line-height: 24px; } -.upcoming-tag { padding: 3px 7px; border: 1px solid #b6ac95; border-radius: 4px; color: #6d695b; font-size: 9px; font-weight: 700; letter-spacing: .09em; } -.upcoming-panel p { margin: 2px 0 0; color: #666b5e; font-size: 12px; line-height: 1.5; } -.home-footer { display: flex; justify-content: space-between; gap: 16px; margin-top: 45px; padding: 21px 0 28px; border-top: 1px solid rgba(65, 68, 52, .19); color: #6e6c5d; font-size: 11px; } -.home-footer span:last-child { font-size: 9px; font-weight: 700; letter-spacing: .14em; } - -@media (max-width: 900px) { - .hero { gap: 35px; } - .action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } - .action-card { min-height: 178px; } -} - -@media (max-width: 640px) { - .home-shell { width: min(100% - 36px, 500px); } - .home-header { min-height: 76px; } - .header-label { display: none; } - .hero { grid-template-columns: 1fr; gap: 32px; padding: 48px 0 52px; } - .hero h1 { margin-top: 20px; font-size: clamp(40px, 10vw, 55px); } - .hero-description { font-size: 16px; } - .selection-card { padding: 22px; } - .selection-visual { padding: 20px 0; } - .section-heading { display: block; } - .section-heading > p { margin-top: 9px; } - .action-grid { gap: 10px; } - .home-page .action-card { min-height: 190px; padding: 16px; } - .action-arrow { right: 15px; bottom: 15px; } - .download-panel { flex-wrap: wrap; gap: 13px; padding: 18px; } - .download-copy { flex: 1 1 calc(100% - 60px); } - .home-page .secondary-link { width: 100%; } - .home-footer { margin-top: 35px; } -} - -@media (max-width: 360px) { - .action-grid { grid-template-columns: 1fr; } - .home-page .action-card { min-height: 156px; } - .home-footer span:last-child { display: none; } -} - -@media (prefers-reduced-motion: reduce) { - .home-page .primary-link, .home-page .secondary-link, .home-page .action-card { transition: none; } - .home-page .primary-link:hover, .home-page .action-card:hover { transform: none; } -} diff --git a/static/home.js b/static/home.js deleted file mode 100644 index fde6cd7..0000000 --- a/static/home.js +++ /dev/null @@ -1,27 +0,0 @@ -const selectionCard = document.querySelector('[data-selection-url]') -const selectionName = document.getElementById('home-selection') -const selectionDetail = document.getElementById('home-selection-detail') - -function updateSelectionText(element, text) { - // Avoid repeated screen-reader announcements when the selection hasn't changed. - if (element.textContent !== text) element.textContent = text -} - -async function refreshHomeSelection() { - try { - const response = await fetch(selectionCard.dataset.selectionUrl, {cache: 'no-store'}) - if (!response.ok) throw new Error('Selection unavailable') - const state = await response.json() - updateSelectionText(selectionName, state.blank ? 'Blank screen selected' : state.selected_name) - updateSelectionText(selectionDetail, state.using_default && !state.blank - ? 'Default selection. The player runs separately on your display.' - : 'This is the requested selection; the player runs separately on your display.') - } catch (error) { - updateSelectionText(selectionName, 'Selection unavailable') - updateSelectionText(selectionDetail, 'Open the media library to try again.') - } finally { - window.setTimeout(refreshHomeSelection, 5000) - } -} - -refreshHomeSelection() diff --git a/test/home_test.py b/test/home_test.py deleted file mode 100644 index 4fba0a5..0000000 --- a/test/home_test.py +++ /dev/null @@ -1,99 +0,0 @@ -from html.parser import HTMLParser -import json -import os -from pathlib import Path -import runpy -import subprocess -import sys -import tempfile -import unittest - - -ROOT = Path(__file__).resolve().parents[1] - - -class HomeElements(HTMLParser): - def __init__(self): - super().__init__() - self.links = [] - self.buttons = [] - self.headings = [] - self.selection_url = None - - def handle_starttag(self, tag, attrs): - attrs = dict(attrs) - if tag == 'a': - self.links.append(attrs.get('href')) - if tag == 'button': - self.buttons.append(attrs) - if tag in ('h1', 'h2'): - self.headings.append(tag) - if 'data-selection-url' in attrs: - self.selection_url = attrs['data-selection-url'] - - -class HomeTest(unittest.TestCase): - def setUp(self): - self.directory = tempfile.TemporaryDirectory() - self.addCleanup(self.directory.cleanup) - self.workdir = Path(self.directory.name) - (self.workdir / 'config.json').write_text(json.dumps({ - 'database': {'type': 'SQLite', 'name': 'test.db'}, - 'upload_location': 'uploads' - })) - subprocess.run([sys.executable, str(ROOT / 'sc_database_generator.py')], - cwd=self.workdir, check=True, capture_output=True) - original = Path.cwd() - try: - os.chdir(self.workdir) - self.app = runpy.run_path(str(ROOT / 'sc_webserver.py'))['app'] - finally: - os.chdir(original) - self.app.config['TESTING'] = True - self.client = self.app.test_client() - - def test_working_actions_are_grouped_and_all_destinations_work(self): - response = self.client.get('/') - self.assertEqual(response.status_code, 200) - elements = HomeElements() - elements.feed(response.get_data(as_text=True)) - self.assertCountEqual(elements.links, ['/', '/media', '/upload/photo', '/upload/video', - '/configure/stream', '/youtube/download', '/youtube/jobs']) - self.assertEqual(elements.buttons, []) # No deceptively enabled placeholder controls. - self.assertEqual(elements.headings.count('h1'), 1) - self.assertEqual(elements.selection_url, '/media/status') - for link in elements.links: - with self.subTest(link=link): - self.assertEqual(self.client.get(link).status_code, 200) - self.assertIn(b'COMING SOON', response.data) - self.assertIn(b'TV & screen controls', response.data) - self.assertIn(b'Sanctuary Commander', response.data) - - def test_home_uses_local_assets_and_preserves_original_background(self): - home = self.client.get('/') - for asset in ('style.css', 'home.css', 'home.js'): - self.assertIn(f'/static/{asset}'.encode(), home.data) - with self.client.get(f'/static/{asset}') as response: - self.assertEqual(response.status_code, 200) - self.assertNotIn(b'cdn.jsdelivr', home.data) - with self.client.get('/static/style.css') as response: - self.assertIn(b'background-color: #ebe1c7 !important', response.data) - with self.client.get('/static/home.css') as response: - self.assertIn(b'@media (max-width: 640px)', response.data) - self.assertIn(b'prefers-reduced-motion', response.data) - self.assertIn(b':focus-visible', response.data) - - def test_home_navigation_survives_database_failure(self): - # Only the optional status panel depends on the database, not navigation. - from unittest.mock import patch - import sqlite3 - with patch('utilities.database.sqlite.SQLite.query', side_effect=sqlite3.OperationalError('Unavailable')): - self.assertEqual(self.client.get('/').status_code, 200) - with self.assertLogs(self.app.logger, level='ERROR'): - response = self.client.get('/media/status') - self.assertEqual(response.status_code, 503) - self.assertEqual(response.json['status'], 'FAILED') - - -if __name__ == '__main__': - unittest.main()