Skip to content

Commit d571e99

Browse files
Document storage mode fixes
1 parent 79bb221 commit d571e99

4 files changed

Lines changed: 35 additions & 38 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
66

77
FrameTrail is an open hypervideo environment for creating, annotating, and remixing interactive videos. It's a client-side JavaScript application with an optional PHP backend that uses **JSON files instead of a database** for all data storage. The entire system is portable — copy the `_data` directory between servers and everything works.
88

9-
FrameTrail can run in three modes: with a PHP server (full multi-user), with the File System Access API for local editing (no server needed), or as a read-only viewer.
9+
FrameTrail can run in three modes: with a PHP server (full multi-user), with the File System Access API for local editing in Chrome/Edge (no server needed), or in-memory using the Download adapter (view + edit + export, no persistence — works everywhere but requires data to be passed via init options).
1010

1111
## Repository Structure
1212

@@ -136,7 +136,7 @@ Note: Some libraries have custom/patched versions (raphael-connections.js, rapha
136136
- `'server'` — PHP backend available, data loaded/saved via AJAX to `src/_server/ajaxServer.php`
137137
- `'local'` — File System Access API active, data read/written via `StorageAdapterLocal` to a user-selected folder
138138
- `'needsFolder'` — File System Access API supported but no folder selected yet; launcher prompts user to pick a `_data` directory
139-
- `'noStorage'` — No storage backend available (Firefox/Safari on `file://`); app cannot load or save data
139+
- `'download'` — No persistent storage available (Firefox/Safari, or any browser without File System Access API and no PHP); `StorageAdapterDownload` is used, which stores data in memory and lets users export/download it. Viewing and editing work; saves persist only until page reload.
140140

141141
### Application Modes
142142

README.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ FrameTrail is an open-source platform for building non-linear, interactive video
1212

1313
## Features
1414

15-
### Three Ways to Run
15+
### Two Ways to Run
1616

1717
1. **Server mode** (Apache + PHP) — Full multi-user editing, file uploads, user management
1818
2. **Local folder mode** (Chrome/Edge) — Full editing without a server, using the File System Access API to read/write a local `_data` folder
19-
3. **Read-only mode** — Open `index.html` directly in any browser to view existing hypervideos
2019

2120
### Editing
2221

@@ -52,8 +51,8 @@ FrameTrail supports a wide range of embeddable content:
5251
### Browser Support
5352

5453
- **Desktop:** Chrome, Firefox, Edge (latest versions)
55-
- **Local folder mode:** Chrome/Edge (requires File System Access API)
56-
- **Mobile:** Player works, editing disabled
54+
- **Local folder mode:** Chrome/Edge only (requires File System Access API)
55+
- **Mobile:** Player works in server mode; editing is disabled
5756

5857
---
5958

@@ -75,11 +74,6 @@ FrameTrail supports a wide range of embeddable content:
7574
3. When prompted, select or create a `_data` folder on your computer
7675
4. Full editing — all changes saved directly to your local files
7776

78-
### Option 3: Read-Only Viewing
79-
80-
1. Open `index.html` in any modern browser
81-
2. If a `_data` folder with hypervideo data exists alongside the HTML files, it will be loaded for viewing
82-
8377
---
8478

8579
## Getting Started

docs/ARCHITECTURE.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ FrameTrail.changeState('editMode', true);
259259
| `target` | String | CSS selector for mount point |
260260
| `editMode` | Boolean/String | `false`, `'overlays'`, `'annotations'`, etc. |
261261
| `viewMode` | String | `'video'`, `'overview'`, `'resources'` |
262-
| `storageMode` | String | `'server'`, `'local'`, `'needsFolder'`, `'noStorage'` |
262+
| `storageMode` | String | `'server'`, `'local'`, `'needsFolder'`, `'download'` |
263263
| `loggedIn` | Boolean | User authentication status |
264264
| `username` | String | Current user's name |
265265
| `fullscreen` | Boolean | Fullscreen state |
@@ -293,21 +293,24 @@ FrameTrail uses a strategy pattern for data persistence. The `StorageManager` mo
293293

294294
| Adapter | Class | When Used |
295295
|---------|-------|-----------|
296-
| Server | `StorageAdapterServer` | Running on Apache+PHP (`document.location.host` exists) |
297-
| Local | `StorageAdapterLocal` | File System Access API available (Chrome/Edge, file://) |
298-
| Download | `StorageAdapterDownload` | Fallbackenables Save As/export |
296+
| Server | `StorageAdapterServer` | HTTP/HTTPS with PHP backend responding at `_server/ajaxServer.php` |
297+
| Local | `StorageAdapterLocal` | File System Access API available (Chrome/Edge) and folder selected |
298+
| Download | `StorageAdapterDownload` | Supplementalprovides Save As/export in either mode |
299299

300300
All adapters implement the same interface, so the rest of the application doesn't need to know which storage backend is active.
301301

302302
### Storage Mode Detection
303303

304-
The `PlayerLauncher` (or `ResourceManagerLauncher`) detects the environment:
304+
`StorageManager.init()` determines the storage mode at startup:
305305

306-
1. If `document.location.host` is set → `'server'` mode (PHP backend available)
307-
2. If File System Access API is supported → `'needsFolder'` (prompt user to select `_data` folder)
308-
3. Otherwise → `'noStorage'` (read-only fallback)
306+
1. If on HTTP/HTTPS **and** PHP backend responds at `_server/ajaxServer.php``'server'`
307+
2. If on HTTP/HTTPS **but** PHP is unreachable, or on `file://` protocol:
308+
- If File System Access API is supported (Chrome/Edge) → try to restore a previously saved folder handle
309+
- Handle restored → `'local'`
310+
- No handle saved → `'needsFolder'` (folder picker dialog is shown)
311+
- File System Access API not supported (Firefox/Safari) → `'download'`
309312

310-
Once a folder is selected in `'needsFolder'` mode, the state transitions to `'local'`.
313+
In `'download'` mode the `StorageAdapterDownload` is used: data is stored in memory, and users can export their work as JSON via the Save As dialog. Viewing and editing both work. Once a folder is selected in `'needsFolder'` mode, the state transitions to `'local'`.
311314

312315
## Data Model
313316

docs/DEPLOYMENT.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,11 @@ The `StorageAdapterLocal` class uses the File System Access API (`showDirectoryP
5858
- No PHP-based file processing (image optimization, video transcoding)
5959
- Browser must support File System Access API (Chrome/Edge only)
6060

61-
### Option 3: Read-Only Viewing
61+
### Save As / Export
6262

63-
View existing hypervideos without any editing capability.
63+
The `StorageAdapterDownload` is used as the fallback storage backend when no PHP server and no local folder are available (`storageMode: 'download'`). It stores all data in memory and exposes a Save As dialog that downloads a JSON snapshot of the current state.
6464

65-
**Steps:**
66-
67-
1. Open `index.html` in any modern browser
68-
2. If a `_data` folder with hypervideo data exists alongside the HTML files, FrameTrail loads it for viewing
69-
3. No editing, no saving — purely a viewer
70-
71-
**Note:** Firefox supports loading local files via AJAX when opening `index.html` from the filesystem. Chrome blocks this by default.
72-
73-
### Option 4: Save As / Download Mode
74-
75-
When neither a server nor the File System Access API is available, FrameTrail falls back to the `StorageAdapterDownload`. Users can still create and edit hypervideos, then export the data as downloadable files via the browser's download mechanism. This is useful for one-off editing or as a fallback on unsupported browsers.
65+
In server and local modes, Save As is also available as a supplemental export tool — useful for archiving or migrating content between instances.
7666

7767
## Embedding FrameTrail
7868

@@ -105,12 +95,15 @@ $(document).ready(function() {
10595
</script>
10696
```
10797

108-
### With Inline Data (No Server)
98+
### With Inline Data
99+
100+
When running in server mode, you can pass all hypervideo and resource data directly via init options, bypassing the `_data/` directory entirely. This is useful for embedding a specific hypervideo on a page without managing the data folder.
109101

110102
```javascript
111103
FrameTrail.init({
112104
target: '#container',
113105
startID: '0',
106+
config: { theme: 'dark' },
114107
contents: [{
115108
hypervideo: {
116109
meta: { name: 'My Video', creator: 'Anonymous', creatorId: 'anon',
@@ -121,14 +114,21 @@ FrameTrail.init({
121114
subtitles: {},
122115
globalEvents: {},
123116
customCSS: ''
124-
}
117+
},
118+
annotations: []
125119
}],
126-
resources: {
127-
'my-video': { name: 'Main Video', type: 'youtube', src: 'dQw4w9WgXcQ' }
128-
}
120+
resources: [{
121+
label: 'Inline resources',
122+
type: 'frametrail',
123+
data: {
124+
'my-video': { name: 'Main Video', type: 'youtube', src: 'dQw4w9WgXcQ' }
125+
}
126+
}]
129127
}, 'PlayerLauncher');
130128
```
131129

130+
**Note:** When no PHP server and no local folder are available, FrameTrail falls back to `storageMode: 'download'` — the `StorageAdapterDownload` holds data in memory. Inline data init options work fully in this mode: viewing and editing are both functional, and changes can be exported via the Save As dialog. Nothing persists past a page reload unless exported.
131+
132132
See [docs/ARCHITECTURE.md](ARCHITECTURE.md) for the full initialization options reference.
133133

134134
## Building from Source

0 commit comments

Comments
 (0)