|
| 1 | +# Design Feature Switch |
| 2 | + |
| 3 | +LibreSpeed now supports switching between the classic design and the new modern design. |
| 4 | + |
| 5 | +## Default Behavior |
| 6 | + |
| 7 | +By default, LibreSpeed uses the **classic design** (located in `index-classic.html`). |
| 8 | + |
| 9 | +## Architecture |
| 10 | + |
| 11 | +### File Structure (Non-Docker) |
| 12 | +- **`index.html`** - Entry point (lightweight switcher) |
| 13 | +- **`index-classic.html`** - Classic design at root |
| 14 | +- **`index-modern.html`** - Modern design at root (references assets in subdirectories) |
| 15 | +- **`frontend/`** - Directory containing modern design assets (CSS, JS, images, fonts) - kept for non-Docker deployments |
| 16 | + |
| 17 | +### File Structure (Docker) |
| 18 | +In Docker deployments, the frontend assets are flattened to root-level subdirectories: |
| 19 | +- **`index.html`** - Entry point (lightweight switcher) |
| 20 | +- **`index-classic.html`** - Classic design |
| 21 | +- **`index-modern.html`** - Modern design |
| 22 | +- **`styling/`** - CSS files for modern design |
| 23 | +- **`javascript/`** - JS files for modern design |
| 24 | +- **`images/`** - Images for modern design |
| 25 | +- **`fonts/`** - Fonts for modern design |
| 26 | +- **No `frontend/` directory** - Assets are copied directly to root subdirectories |
| 27 | + |
| 28 | +### Benefits of Root-Level Design Files |
| 29 | +✅ Both designs at same level - no path confusion |
| 30 | +✅ `results/` accessible from both designs with same relative path |
| 31 | +✅ `backend/` accessible from both designs with same relative path |
| 32 | +✅ No subdirectory nesting issues |
| 33 | +✅ Clean separation of concerns |
| 34 | +✅ Docker containers have no `frontend/` parent directory |
| 35 | + |
| 36 | +## Browser Compatibility |
| 37 | + |
| 38 | +The feature switch uses modern JavaScript features (URLSearchParams, fetch API). It is compatible with all modern browsers. The new design itself requires modern browser features and has no backwards compatibility with older browsers (see `frontend/README.md`). |
| 39 | + |
| 40 | +## Enabling the New Design |
| 41 | + |
| 42 | +There are two ways to enable the new design: |
| 43 | + |
| 44 | +### Method 1: Configuration File (Persistent) |
| 45 | + |
| 46 | +Edit the `config.json` file in the root directory and set `useNewDesign` to `true`: |
| 47 | + |
| 48 | +```json |
| 49 | +{ |
| 50 | + "useNewDesign": true |
| 51 | +} |
| 52 | +``` |
| 53 | + |
| 54 | +This will make the new design the default for all users visiting your site. |
| 55 | + |
| 56 | +### Method 2: URL Parameter (Temporary Override) |
| 57 | + |
| 58 | +You can override the configuration by adding a URL parameter: |
| 59 | + |
| 60 | +- To use the new design: `http://yoursite.com/?design=new` |
| 61 | +- To use the old design: `http://yoursite.com/?design=old` |
| 62 | + |
| 63 | +URL parameters take precedence over the configuration file, making them useful for testing or allowing users to choose their preferred design. |
| 64 | + |
| 65 | +## Design Locations |
| 66 | + |
| 67 | +### Non-Docker Deployments |
| 68 | +- **Entry Point**: Root `index.html` file (lightweight redirect page) |
| 69 | +- **Old Design**: `index-classic.html` at root |
| 70 | +- **New Design**: `index-modern.html` at root (references assets in `frontend/` subdirectory) |
| 71 | +- **Assets**: Frontend assets (CSS, JS, images, fonts) in `frontend/` subdirectory |
| 72 | + |
| 73 | +### Docker Deployments |
| 74 | +- **Entry Point**: Root `index.html` file (lightweight redirect page) |
| 75 | +- **Old Design**: `index-classic.html` at root |
| 76 | +- **New Design**: `index-modern.html` at root (references assets in root subdirectories) |
| 77 | +- **Assets**: Frontend assets copied directly to root subdirectories (`styling/`, `javascript/`, `images/`, `fonts/`) |
| 78 | +- **No `frontend/` directory** - Assets are flattened to root level |
| 79 | + |
| 80 | +Both designs are at the same directory level, ensuring that relative paths to shared resources like `backend/` and `results/` work correctly for both. |
| 81 | + |
| 82 | +## Technical Details |
| 83 | + |
| 84 | +The feature switch is implemented in `design-switch.js`, which is loaded by the root `index.html`. It checks: |
| 85 | + |
| 86 | +1. First, URL parameters (`?design=new` or `?design=old`) |
| 87 | +2. Then, the `config.json` configuration file |
| 88 | +3. Redirects to either `index-classic.html` or `index-modern.html` |
| 89 | + |
| 90 | +Both design HTML files are at the root level, eliminating path issues. |
| 91 | + |
| 92 | +### Non-Docker |
| 93 | +The modern design references assets from the `frontend/` subdirectory (e.g., `frontend/styling/index.css`), while both designs can access shared resources like `backend/` and `results/` using the same relative paths. |
| 94 | + |
| 95 | +### Docker |
| 96 | +In Docker deployments, the `frontend/` directory is flattened during container startup. Assets are copied directly to root-level subdirectories (`styling/`, `javascript/`, `images/`, `fonts/`), and `index-modern.html` references these root-level paths. This eliminates the `frontend/` parent directory in the container. |
0 commit comments