retold-content-system 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +107 -0
  3. package/build-codejar-bundle.js +29 -0
  4. package/build-codemirror-bundle.js +29 -0
  5. package/codejar-entry.js +10 -0
  6. package/codemirror-entry.js +16 -0
  7. package/content/Dogs.txt.md +2 -0
  8. package/content/README.md +35 -0
  9. package/content/_sidebar.md +3 -0
  10. package/content/_topbar.md +1 -0
  11. package/content/cover.md +12 -0
  12. package/content/getting-started.md +73 -0
  13. package/css/content-system.css +42 -0
  14. package/css/github.css +118 -0
  15. package/docs/.nojekyll +0 -0
  16. package/docs/README.md +24 -0
  17. package/docs/_sidebar.md +16 -0
  18. package/docs/_topbar.md +6 -0
  19. package/docs/cli.md +119 -0
  20. package/docs/cover.md +16 -0
  21. package/docs/css/docuserve.css +73 -0
  22. package/docs/editor-guide.md +137 -0
  23. package/docs/getting-started.md +73 -0
  24. package/docs/index.html +39 -0
  25. package/docs/keyboard-shortcuts.md +40 -0
  26. package/docs/retold-catalog.json +81 -0
  27. package/docs/retold-keyword-index.json +19 -0
  28. package/docs/topics.md +83 -0
  29. package/html/codejar-bundle.js +16 -0
  30. package/html/codemirror-bundle.js +29982 -0
  31. package/html/edit.html +25 -0
  32. package/html/index.html +25 -0
  33. package/html/preview.html +19 -0
  34. package/package.json +70 -0
  35. package/server.js +43 -0
  36. package/source/Pict-Application-ContentEditor-Configuration.json +15 -0
  37. package/source/Pict-Application-ContentEditor.js +1361 -0
  38. package/source/Pict-Application-ContentReader-Configuration.json +15 -0
  39. package/source/Pict-Application-ContentReader.js +91 -0
  40. package/source/Pict-ContentSystem-Bundle.js +21 -0
  41. package/source/cli/ContentSystem-CLI-Program.js +15 -0
  42. package/source/cli/ContentSystem-CLI-Run.js +3 -0
  43. package/source/cli/ContentSystem-Server-Setup.js +405 -0
  44. package/source/cli/commands/ContentSystem-Command-Serve.js +104 -0
  45. package/source/providers/Pict-Provider-ContentEditor.js +198 -0
  46. package/source/views/PictView-Editor-CodeEditor.js +271 -0
  47. package/source/views/PictView-Editor-Layout.js +1194 -0
  48. package/source/views/PictView-Editor-MarkdownEditor.js +115 -0
  49. package/source/views/PictView-Editor-MarkdownReference.js +801 -0
  50. package/source/views/PictView-Editor-SettingsPanel.js +563 -0
  51. package/source/views/PictView-Editor-TopBar.js +366 -0
  52. package/source/views/PictView-Editor-Topics.js +1025 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Steven Velozo
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,107 @@
1
+ # Retold Content System
2
+
3
+ A markdown content editor and documentation viewer built on the [Retold](https://github.com/stevenvelozo/retold) ecosystem. Point it at any folder of markdown files and get a local editing environment with a file browser, rich markdown editor, syntax-highlighted code editor, live preview, image uploads, and documentation topics management.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g retold-content-system
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```bash
14
+ mkdir my-docs && cd my-docs
15
+ echo "# Hello" > README.md
16
+ rcs serve
17
+ ```
18
+
19
+ Open the printed URL in your browser. The reader is at `/` and the editor is at `/edit.html`.
20
+
21
+ ## CLI
22
+
23
+ The package installs two equivalent commands: `retold-content-system` and `rcs`.
24
+
25
+ ### `rcs serve [content-path] [-p port]`
26
+
27
+ Start the content system server.
28
+
29
+ | Argument / Option | Description |
30
+ |-------------------|-------------|
31
+ | `[content-path]` | Path to the content folder (default: current directory) |
32
+ | `-p, --port` | Port number (default: random 7000-7999) |
33
+
34
+ ```bash
35
+ # Serve current directory on a random port
36
+ rcs serve
37
+
38
+ # Serve a specific folder on port 8080
39
+ rcs serve ~/my-wiki -p 8080
40
+ ```
41
+
42
+ If the directory contains a `content/` subfolder, it is used automatically.
43
+
44
+ ## Editor Features
45
+
46
+ - **File Browser** -- Tree view sidebar with folder navigation, new file creation, and image uploads
47
+ - **Markdown Editor** -- CodeMirror-based editor with formatting toolbar, auto-segmentation at heading boundaries, and word wrap
48
+ - **Code Editor** -- CodeJar + highlight.js editor for JSON, HTML, CSS, YAML, and 190+ languages
49
+ - **Live Preview** -- Reference panel showing rendered markdown, toggled with F1
50
+ - **Topics Panel** -- Manage `.pict_documentation_topics.json` manifests linking topic codes to files and line numbers
51
+ - **Settings** -- Configurable segmentation depth, word wrap, media preview, hidden files, and more (persisted in localStorage)
52
+
53
+ ### Keyboard Shortcuts
54
+
55
+ | Shortcut | Action |
56
+ |----------|--------|
57
+ | `Cmd/Ctrl+S` | Save |
58
+ | `Escape` | Close file (with unsaved-changes confirmation) |
59
+ | `F1` | Toggle Reference panel |
60
+ | `F2` | Toggle sidebar |
61
+ | `F3` / `Cmd/Ctrl+Shift+U` | Upload image |
62
+ | `F4` / `Cmd/Ctrl+Shift+T` | Topics tab (creates linked topic from cursor in markdown) |
63
+
64
+ ## Documentation Reader
65
+
66
+ The root URL (`/`) serves a pict-docuserve documentation viewer. If your content folder includes `cover.md`, `_sidebar.md`, and `_topbar.md`, the reader uses them for navigation. Otherwise it renders markdown files directly.
67
+
68
+ ## Architecture
69
+
70
+ Built on these Retold modules:
71
+
72
+ - **[Orator](https://github.com/stevenvelozo/orator)** -- HTTP server with Restify
73
+ - **[Pict](https://github.com/stevenvelozo/pict)** -- MVC framework for the browser applications
74
+ - **[pict-docuserve](https://github.com/stevenvelozo/pict-docuserve)** -- Documentation reader/viewer
75
+ - **[pict-section-markdowneditor](https://github.com/stevenvelozo/pict-section-markdowneditor)** -- CodeMirror markdown editor component
76
+ - **[pict-section-code](https://github.com/stevenvelozo/pict-section-code)** -- CodeJar code editor component
77
+ - **[pict-section-filebrowser](https://github.com/stevenvelozo/pict-section-filebrowser)** -- File browser component
78
+ - **[pict-service-commandlineutility](https://github.com/stevenvelozo/pict-service-commandlineutility)** -- CLI framework
79
+
80
+ ## Development
81
+
82
+ ```bash
83
+ # Clone and install
84
+ git clone https://github.com/stevenvelozo/retold.git
85
+ cd retold/app/retold-content-system
86
+ npm install
87
+
88
+ # Build everything (CodeMirror bundle, CodeJar bundle, application bundle)
89
+ npm run build-all
90
+
91
+ # Start the dev server
92
+ npm start
93
+ ```
94
+
95
+ The build uses [Quackage](https://github.com/stevenvelozo/quackage) for the main application bundle and esbuild for the CodeMirror and CodeJar editor bundles.
96
+
97
+ ## Documentation
98
+
99
+ Full documentation is in the `docs/` folder and can be viewed with the content system itself:
100
+
101
+ ```bash
102
+ rcs serve docs/
103
+ ```
104
+
105
+ ## License
106
+
107
+ MIT
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Build script to bundle CodeJar + highlight.js into a single browser-compatible file.
4
+ * Run: node build-codejar-bundle.js
5
+ *
6
+ * This creates html/codejar-bundle.js which exposes window.CodeJarModules
7
+ * with { CodeJar, hljs }.
8
+ */
9
+ const { build } = require('esbuild');
10
+ const path = require('path');
11
+
12
+ build(
13
+ {
14
+ entryPoints: [path.join(__dirname, 'codejar-entry.js')],
15
+ bundle: true,
16
+ outfile: path.join(__dirname, 'html', 'codejar-bundle.js'),
17
+ format: 'iife',
18
+ globalName: 'CodeJarModules',
19
+ platform: 'browser',
20
+ target: ['es2018'],
21
+ minify: true
22
+ }).then(() =>
23
+ {
24
+ console.log('CodeJar + highlight.js bundle built successfully -> html/codejar-bundle.js');
25
+ }).catch((pError) =>
26
+ {
27
+ console.error('Build failed:', pError);
28
+ process.exit(1);
29
+ });
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Build script to bundle CodeMirror v6 into a single browser-compatible file.
4
+ * Run: node build-codemirror-bundle.js
5
+ *
6
+ * This creates html/codemirror-bundle.js which exposes window.CodeMirrorModules
7
+ * with { EditorView, EditorState, Decoration, ViewPlugin, WidgetType, extensions }.
8
+ */
9
+ const { build } = require('esbuild');
10
+ const path = require('path');
11
+
12
+ build(
13
+ {
14
+ entryPoints: [path.join(__dirname, 'codemirror-entry.js')],
15
+ bundle: true,
16
+ outfile: path.join(__dirname, 'html', 'codemirror-bundle.js'),
17
+ format: 'iife',
18
+ globalName: 'CodeMirrorModules',
19
+ platform: 'browser',
20
+ target: ['es2018'],
21
+ minify: false
22
+ }).then(() =>
23
+ {
24
+ console.log('CodeMirror bundle built successfully -> html/codemirror-bundle.js');
25
+ }).catch((pError) =>
26
+ {
27
+ console.error('Build failed:', pError);
28
+ process.exit(1);
29
+ });
@@ -0,0 +1,10 @@
1
+ /**
2
+ * CodeJar + highlight.js entry point for browser bundling.
3
+ *
4
+ * This file is bundled by esbuild into a single script that sets
5
+ * window.CodeJar and window.hljs for the code editor.
6
+ */
7
+ import { CodeJar } from 'codejar';
8
+ import hljs from 'highlight.js';
9
+
10
+ export { CodeJar, hljs };
@@ -0,0 +1,16 @@
1
+ /**
2
+ * CodeMirror v6 entry point for browser bundling.
3
+ *
4
+ * This file is bundled by esbuild into a single script that sets
5
+ * window.CodeMirrorModules with everything the markdown editor needs.
6
+ */
7
+ import { EditorView, basicSetup } from 'codemirror';
8
+ import { EditorState } from '@codemirror/state';
9
+ import { Decoration, ViewPlugin, WidgetType } from '@codemirror/view';
10
+ import { markdown } from '@codemirror/lang-markdown';
11
+
12
+ // Export everything the editor needs
13
+ export { EditorView, EditorState, Decoration, ViewPlugin, WidgetType, basicSetup, markdown };
14
+
15
+ // Also set up the extensions array that the editor expects
16
+ export const extensions = [basicSetup, markdown()];
@@ -0,0 +1,2 @@
1
+ # Dogs.txt
2
+
@@ -0,0 +1,35 @@
1
+ # Retold Content System
2
+
3
+ The Retold Content System is a markdown-based content management application built on the Retold ecosystem.
4
+
5
+ ## Features
6
+
7
+ - **Reader Modereo** — Renders markdown content with full styling, code highlighting, and sidebar navigation
8
+ - **Editor Mode** — Edit markdown content in-place using a segmented CodeMirror-based editor
9
+ - **Image Upload** — Drag, paste, or pick images; they upload to the server and insert as URLs
10
+ - **Live Preview** — See rendered markdown alongside the editor in real-time
11
+ - **File Management** — Browse and edit any markdown file in the content directory
12
+
13
+ ## Architecture
14
+
15
+ The system combines two Retold components:
16
+
17
+ 1. **Orator** — A Node.js web server (built on Restify) that serves static files and provides REST APIs for content management
18
+ 2. **Pict** — A browser-side MVC framework that powers both the reader and editor applications
19
+
20
+ The reader application extends `pict-docuserve` for documentation viewing. The editor application uses `pict-section-markdowneditor` for markdown editing.
21
+
22
+ ## Quick Start
23
+
24
+ ```bash
25
+ cd app/retold-content-system
26
+ npm install
27
+ npm run build-all
28
+ npm start
29
+ ```
30
+
31
+ ![Squirrel-003-Processed-10k](/uploads/1771723928061-Squirrel-003-Processed-10k.png)
32
+
33
+ Then open:
34
+ - Reader: http://localhost:8086/
35
+ - Editor: http://localhost:8086/edit.html
@@ -0,0 +1,3 @@
1
+ - Content
2
+ - [README](README.md)
3
+ - [Getting Started](getting-started.md)
@@ -0,0 +1 @@
1
+ # Content System
@@ -0,0 +1,12 @@
1
+ # Retold Content System
2
+
3
+ > A markdown content management system built on Pict and Orator
4
+
5
+ Browse and edit your documentation content through a web browser. View beautifully rendered markdown or switch to the editor for in-place editing with image upload support.
6
+
7
+ - **Reader Mode** — Clean, fast documentation viewer with sidebar navigation
8
+ - **Editor Mode** — Full markdown editor with live preview, image upload, and segment management
9
+ - **Server-Backed** — Content persisted to disk, images uploaded and served automatically
10
+
11
+ [Get Started](getting-started.md)
12
+ [View README](README.md)
@@ -0,0 +1,73 @@
1
+ # Getting Started
2
+
3
+ ## Prerequisites
4
+
5
+ - brain
6
+ - heart
7
+ - liver
8
+ - moxie
9
+
10
+ ## Installation
11
+
12
+ Clone the retold monorepo and navigate to the content system:
13
+
14
+ ```bash
15
+ cd app/retold-content-system
16
+ npm install
17
+ ```
18
+
19
+ ## Building
20
+
21
+ Build the CodeMirror bundle, reader application, and editor application:
22
+
23
+ ```bash
24
+ npm run build-all
25
+ ```
26
+
27
+ Or build components individually:
28
+
29
+ ```bash
30
+ npm run build-codemirror # Build CodeMirror bundle for the editor
31
+ npm run build # Build the reader application
32
+ npm run build-editor # Build the editor application
33
+ ```
34
+
35
+ ## Running
36
+
37
+ Start the server:
38
+
39
+ ```bash
40
+ npm start
41
+ ```
42
+
43
+ The server starts on port 8086 by default. Open your browser to:
44
+
45
+ - **Reader:** http://localhost:8086/
46
+ - **Editor:** http://localhost:8086/edit.html
47
+
48
+ ## Content Directory
49
+
50
+ Markdown files live in the `content/` directory. The reader serves them as documentation pages. The editor lets you modify them in-place.
51
+
52
+ Special files:
53
+ - `cover.md` — Splash page content
54
+ - `_sidebar.md` — Sidebar navigation structure
55
+ - `_topbar.md` — Header bar branding and navigation
56
+ - `README.md` — Default documentation page
57
+
58
+ ## Editing Content
59
+
60
+ 1. Navigate to the editor at `/edit.html`
61
+ 2. Select a file from the sidebar
62
+ 3. Edit the markdown content in the segmented editor
63
+ 4. Click Save to persist changes to disk
64
+ 5. Switch back to the reader to see the rendered result
65
+
66
+ ## Image Uploads
67
+
68
+ Images can be added to documents in the editor by:
69
+ - Dragging an image file onto the editor
70
+ - Pasting an image from the clipboard
71
+ - Clicking the image button in the editor toolbar
72
+
73
+ Images are uploaded to the server and stored in the `uploads/` directory. The editor inserts a URL reference (not base64) to keep documents lightweight.
@@ -0,0 +1,42 @@
1
+ /* Retold Content System — Base Styles */
2
+
3
+ *, *::before, *::after
4
+ {
5
+ box-sizing: border-box;
6
+ }
7
+
8
+ html
9
+ {
10
+ font-size: 16px;
11
+ -webkit-text-size-adjust: 100%;
12
+ }
13
+
14
+ body
15
+ {
16
+ margin: 0;
17
+ padding: 0;
18
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
19
+ background: #FAF8F4;
20
+ color: #423D37;
21
+ line-height: 1.6;
22
+ }
23
+
24
+ /* Scrollbar styling */
25
+ ::-webkit-scrollbar
26
+ {
27
+ width: 8px;
28
+ height: 8px;
29
+ }
30
+ ::-webkit-scrollbar-track
31
+ {
32
+ background: #F5F0E8;
33
+ }
34
+ ::-webkit-scrollbar-thumb
35
+ {
36
+ background: #C4BDB0;
37
+ border-radius: 4px;
38
+ }
39
+ ::-webkit-scrollbar-thumb:hover
40
+ {
41
+ background: #8A7F72;
42
+ }
package/css/github.css ADDED
@@ -0,0 +1,118 @@
1
+ pre code.hljs {
2
+ display: block;
3
+ overflow-x: auto;
4
+ padding: 1em
5
+ }
6
+ code.hljs {
7
+ padding: 3px 5px
8
+ }
9
+ /*!
10
+ Theme: GitHub
11
+ Description: Light theme as seen on github.com
12
+ Author: github.com
13
+ Maintainer: @Hirse
14
+ Updated: 2021-05-15
15
+
16
+ Outdated base version: https://github.com/primer/github-syntax-light
17
+ Current colors taken from GitHub's CSS
18
+ */
19
+ .hljs {
20
+ color: #24292e;
21
+ background: #ffffff
22
+ }
23
+ .hljs-doctag,
24
+ .hljs-keyword,
25
+ .hljs-meta .hljs-keyword,
26
+ .hljs-template-tag,
27
+ .hljs-template-variable,
28
+ .hljs-type,
29
+ .hljs-variable.language_ {
30
+ /* prettylights-syntax-keyword */
31
+ color: #d73a49
32
+ }
33
+ .hljs-title,
34
+ .hljs-title.class_,
35
+ .hljs-title.class_.inherited__,
36
+ .hljs-title.function_ {
37
+ /* prettylights-syntax-entity */
38
+ color: #6f42c1
39
+ }
40
+ .hljs-attr,
41
+ .hljs-attribute,
42
+ .hljs-literal,
43
+ .hljs-meta,
44
+ .hljs-number,
45
+ .hljs-operator,
46
+ .hljs-variable,
47
+ .hljs-selector-attr,
48
+ .hljs-selector-class,
49
+ .hljs-selector-id {
50
+ /* prettylights-syntax-constant */
51
+ color: #005cc5
52
+ }
53
+ .hljs-regexp,
54
+ .hljs-string,
55
+ .hljs-meta .hljs-string {
56
+ /* prettylights-syntax-string */
57
+ color: #032f62
58
+ }
59
+ .hljs-built_in,
60
+ .hljs-symbol {
61
+ /* prettylights-syntax-variable */
62
+ color: #e36209
63
+ }
64
+ .hljs-comment,
65
+ .hljs-code,
66
+ .hljs-formula {
67
+ /* prettylights-syntax-comment */
68
+ color: #6a737d
69
+ }
70
+ .hljs-name,
71
+ .hljs-quote,
72
+ .hljs-selector-tag,
73
+ .hljs-selector-pseudo {
74
+ /* prettylights-syntax-entity-tag */
75
+ color: #22863a
76
+ }
77
+ .hljs-subst {
78
+ /* prettylights-syntax-storage-modifier-import */
79
+ color: #24292e
80
+ }
81
+ .hljs-section {
82
+ /* prettylights-syntax-markup-heading */
83
+ color: #005cc5;
84
+ font-weight: bold
85
+ }
86
+ .hljs-bullet {
87
+ /* prettylights-syntax-markup-list */
88
+ color: #735c0f
89
+ }
90
+ .hljs-emphasis {
91
+ /* prettylights-syntax-markup-italic */
92
+ color: #24292e;
93
+ font-style: italic
94
+ }
95
+ .hljs-strong {
96
+ /* prettylights-syntax-markup-bold */
97
+ color: #24292e;
98
+ font-weight: bold
99
+ }
100
+ .hljs-addition {
101
+ /* prettylights-syntax-markup-inserted */
102
+ color: #22863a;
103
+ background-color: #f0fff4
104
+ }
105
+ .hljs-deletion {
106
+ /* prettylights-syntax-markup-deleted */
107
+ color: #b31d28;
108
+ background-color: #ffeef0
109
+ }
110
+ .hljs-char.escape_,
111
+ .hljs-link,
112
+ .hljs-params,
113
+ .hljs-property,
114
+ .hljs-punctuation,
115
+ .hljs-tag {
116
+ /* purposely ignored */
117
+
118
+ }
package/docs/.nojekyll ADDED
File without changes
package/docs/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # Retold Content System Documentation
2
+
3
+ This folder contains the pict-docuserve documentation for the Retold Content System.
4
+
5
+ ## Viewing the Docs
6
+
7
+ These markdown files are meant to be served by pict-docuserve or by the content system itself. To view them locally:
8
+
9
+ ```bash
10
+ rcs serve docs/ -p 8080
11
+ ```
12
+
13
+ Then open `http://localhost:8080/` in your browser.
14
+
15
+ ## Contents
16
+
17
+ - **getting-started.md** -- Installation, quick start, and server overview
18
+ - **editor-guide.md** -- Walkthrough of the editor UI: file browser, markdown editor, code editor, sidebar tabs, and settings
19
+ - **keyboard-shortcuts.md** -- Complete keyboard shortcut reference
20
+ - **cli.md** -- CLI command reference with examples and programmatic usage
21
+ - **topics.md** -- Documentation topics system for managing help manifests
22
+ - **cover.md** -- Landing page for the pict-docuserve viewer
23
+ - **_sidebar.md** -- Sidebar navigation tree
24
+ - **_topbar.md** -- Top bar navigation
@@ -0,0 +1,16 @@
1
+ - Getting Started
2
+
3
+ - [Overview](getting-started.md)
4
+
5
+ - Using the Editor
6
+
7
+ - [Editor Guide](editor-guide.md)
8
+ - [Keyboard Shortcuts](keyboard-shortcuts.md)
9
+
10
+ - Command Line
11
+
12
+ - [CLI Reference](cli.md)
13
+
14
+ - Topics System
15
+
16
+ - [Documentation Topics](topics.md)
@@ -0,0 +1,6 @@
1
+ # Content System
2
+
3
+ - [Getting Started](getting-started.md)
4
+ - [Editor Guide](editor-guide.md)
5
+ - [CLI](cli.md)
6
+ - [GitHub](https://github.com/stevenvelozo/retold)
package/docs/cli.md ADDED
@@ -0,0 +1,119 @@
1
+ # CLI Reference
2
+
3
+ The Retold Content System installs two equivalent commands: `retold-content-system` and the shorthand `rcs`. All examples below use `rcs`.
4
+
5
+ ## serve
6
+
7
+ Start the content system server for a content folder.
8
+
9
+ ```bash
10
+ rcs serve [content-path] [options]
11
+ ```
12
+
13
+ ### Arguments
14
+
15
+ | Argument | Description |
16
+ |----------|-------------|
17
+ | `[content-path]` | Path to the markdown content folder. Defaults to the current directory. |
18
+
19
+ ### Options
20
+
21
+ | Option | Description |
22
+ |--------|-------------|
23
+ | `-p, --port [port]` | Port to serve on. Defaults to a random port between 7000 and 7999. |
24
+
25
+ ### Examples
26
+
27
+ **Serve the current directory on a random port:**
28
+
29
+ ```bash
30
+ rcs serve
31
+ ```
32
+
33
+ **Serve a specific folder on port 8080:**
34
+
35
+ ```bash
36
+ rcs serve ~/my-docs -p 8080
37
+ ```
38
+
39
+ **Serve a project with a content/ subfolder:**
40
+
41
+ ```bash
42
+ cd ~/my-project
43
+ rcs serve
44
+ ```
45
+
46
+ If the current directory contains a `content/` subfolder, the server automatically uses that as the content root. No extra path argument is needed.
47
+
48
+ ### Output
49
+
50
+ On startup the server prints a banner with all relevant paths and URLs:
51
+
52
+ ```
53
+ Retold Content System running on http://localhost:7042
54
+ Content: /Users/you/my-docs
55
+ Uploads: /Users/you/my-docs/uploads
56
+ Assets: /path/to/retold-content-system/dist
57
+ Reader: http://localhost:7042/
58
+ Editor: http://localhost:7042/edit.html
59
+ ```
60
+
61
+ Press `Ctrl+C` to stop the server.
62
+
63
+ ### Server API
64
+
65
+ The server exposes a set of REST endpoints that both the reader and editor applications use:
66
+
67
+ **File Browser**
68
+
69
+ - `GET /api/filebrowser/list` -- List files and folders in the content directory
70
+ - `GET /api/filebrowser/list/*` -- List files in a subdirectory
71
+ - `PUT /api/filebrowser/settings` -- Toggle file browser options (e.g. show hidden files)
72
+
73
+ **Content**
74
+
75
+ - `GET /api/content/read/*` -- Read the raw content of a file
76
+ - `PUT /api/content/save/*` -- Save content to a file (create or overwrite)
77
+ - `POST /api/content/upload-image` -- Upload an image file into the content folder
78
+
79
+ **Static Routes**
80
+
81
+ - `/` -- The pict-docuserve documentation reader
82
+ - `/edit.html` -- The content editor application
83
+ - `/content/*` -- Raw content files served directly
84
+ - `/uploads/*` -- Uploaded image files
85
+
86
+ ## Usage with npx
87
+
88
+ If you prefer not to install globally, run directly with npx:
89
+
90
+ ```bash
91
+ npx retold-content-system serve ~/my-docs -p 9000
92
+ ```
93
+
94
+ ## Programmatic Use
95
+
96
+ The server setup is also available as a module for embedding in other Node.js applications:
97
+
98
+ ```javascript
99
+ const setupServer = require('retold-content-system/source/cli/ContentSystem-Server-Setup.js');
100
+
101
+ setupServer(
102
+ {
103
+ ContentPath: '/path/to/content',
104
+ UploadPath: '/path/to/content/uploads',
105
+ DistPath: '/path/to/retold-content-system/dist',
106
+ Port: 8080
107
+ },
108
+ function (pError, pServerInfo)
109
+ {
110
+ if (pError)
111
+ {
112
+ console.error('Failed to start:', pError);
113
+ return;
114
+ }
115
+ console.log('Server running on port', pServerInfo.Port);
116
+ });
117
+ ```
118
+
119
+ The callback receives an object with `Fable`, `Orator`, and `Port` properties for further customization.