Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 28, 2025

User description

Implements a toggle mechanism to enable the new frontend design while keeping the classic design as default. Supports both standalone deployments and Docker containers.

Both designs are placed at root level to ensure correct relative paths to shared resources like backend/ and results/. In Docker containers, frontend assets are flattened to eliminate the frontend/ parent directory.

Changes

  • config.json: Site-wide setting (useNewDesign: false by default)
  • design-switch.js: Client-side redirect logic with priority: URL params → config → default (old design)
  • DESIGN_SWITCH.md: Usage documentation
  • index.html: Lightweight entry point that loads design switcher
  • index-classic.html: Classic design at root level
  • index-modern.html: Modern design at root level (references assets from subdirectories)
  • frontend/index.html: Unchanged for non-Docker deployments
  • Dockerfile & Dockerfile.alpine: Copy design switch files and both design HTML files
  • docker/entrypoint.sh: Handle design switch setup, USE_NEW_DESIGN environment variable, and flatten frontend assets to root subdirectories in Docker
  • doc_docker.md: Document new USE_NEW_DESIGN environment variable

Architecture

Non-Docker Deployments

  • Both index-classic.html and index-modern.html at root
  • Modern design references assets from frontend/ subdirectory
  • Both designs access backend/ and results/ with same relative paths

Docker Deployments

  • Both index-classic.html and index-modern.html at root
  • Frontend assets flattened to root subdirectories: styling/, javascript/, images/, fonts/
  • No frontend/ parent directory in containers
  • Both designs access backend/ and results/ with same relative paths

Usage

Non-Docker Deployments

// config.json - enable new design site-wide
{
  "useNewDesign": true
}
// URL override (takes precedence over config)
?design=new   // force new design
?design=old   // force classic design

Docker Deployments

# Enable new design via environment variable
docker run -e USE_NEW_DESIGN=true -p 80:8080 ghcr.io/librespeed/speedtest

Or in docker-compose.yml:

environment:
  MODE: standalone
  USE_NEW_DESIGN: "true"

Error Handling

  • Malformed JSON falls back to old design
  • Path detection prevents redirect loops
  • Config fetch failures default to old design

Screenshots

Classic Design (Default)

New Design


PR Type

Enhancement


Description

  • Implements feature switch for new design with multiple configuration methods

  • Supports URL parameters, config file, and Docker environment variables

  • Includes client-side redirect logic with infinite loop prevention

  • Adds comprehensive documentation and Docker integration

Copilot AI and others added 2 commits December 28, 2025 22:21
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
@sstidl
Copy link
Collaborator

sstidl commented Dec 28, 2025

@copilot look into the Dockerfiles and adjust entrypoint logic

Copilot AI changed the title [WIP] Add feature switch for enabling new design Add feature switch for new design via config file and URL parameters Dec 28, 2025
Copilot AI requested a review from sstidl December 28, 2025 22:27
Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 28, 2025

@copilot look into the Dockerfiles and adjust entrypoint logic

Updated Dockerfiles and entrypoint.sh to support the design feature switch (commit 90cf3e5).

Changes:

  • Both Dockerfile and Dockerfile.alpine now copy config.json, root index.html, and design-switch.js
  • entrypoint.sh copies these files to /var/www/html/ and supports the new USE_NEW_DESIGN environment variable
  • In standalone mode, the root index.html (with feature switch) is used by default, with the frontend directory available for the new design
  • Added documentation to doc_docker.md for the USE_NEW_DESIGN environment variable

Docker Usage:

# Default (old design)
docker run -p 80:8080 ghcr.io/librespeed/speedtest

# Enable new design
docker run -e USE_NEW_DESIGN=true -p 80:8080 ghcr.io/librespeed/speedtest

Tested successfully with Docker build and runtime.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pecl.php.net
    • Triggering command: /usr/local/bin/php /usr/local/bin/php -C -q -d include_path=/usr/local/lib/php -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv=On /usr/local/lib/php/peclcmd.php channel-update pecl.php.net (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title Add feature switch for new design via config file and URL parameters Add feature switch for new design via config file, URL parameters, and Docker Dec 28, 2025
@sstidl sstidl marked this pull request as ready for review December 28, 2025 22:41
sstidl and others added 2 commits December 28, 2025 23:54
Co-authored-by: qodo-free-for-open-source-projects[bot] <189517486+qodo-free-for-open-source-projects[bot]@users.noreply.github.com>
Copy link
Collaborator

@sstidl sstidl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot the solution has a big flaw. the frontend now lives in two places.
with old design it is in the root of the server, with new design it is in subdir frontend.
this has the effect that the results/ folder isnt found in new design mode.
a better solution would be to put old and new design side by side into the docker container, both at the same level. no additional paths needed.

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Dec 29, 2025

@copilot the solution has a big flaw. the frontend now lives in two places.
with old design it is in the root of the server, with new design it is in subdir frontend.
this has the effect that the resu...

Fixed in commit 9de1131. Both designs are now at root level side by side.

Architecture:

  • index.html - Entry point (lightweight switcher)
  • index-classic.html - Classic design at root
  • index-modern.html - Modern design at root (references frontend/ for assets)
  • Both designs can access results/ and backend/ with same relative paths

Screenshots:

Classic Design (Default):
Classic

Modern Design:
Modern

The path issue is resolved - both designs are at the same directory level, so relative paths to shared resources work correctly.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • pecl.php.net
    • Triggering command: /usr/local/bin/php /usr/local/bin/php -C -q -d include_path=/usr/local/lib/php -d date.timezone=UTC -d output_buffering=1 -d variables_order=EGPCS -d safe_mode=0 -d register_argc_argv=On /usr/local/lib/php/peclcmd.php channel-update pecl.php.net (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Co-authored-by: sstidl <12804296+sstidl@users.noreply.github.com>
Copilot AI requested a review from sstidl December 29, 2025 21:58
@sstidl sstidl merged commit 235fa63 into newdesign Dec 29, 2025
@sstidl sstidl deleted the copilot/add-feature-switch-for-design branch December 29, 2025 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants