pict-section-inlinedocumentation 0.0.1
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.
- package/README.md +107 -0
- package/docs/.nojekyll +0 -0
- package/docs/README.md +83 -0
- package/docs/_cover.md +15 -0
- package/docs/_sidebar.md +24 -0
- package/docs/_topbar.md +8 -0
- package/docs/_version.json +7 -0
- package/docs/api-reference.md +185 -0
- package/docs/architecture.md +103 -0
- package/docs/css/docuserve.css +327 -0
- package/docs/embedding-level1-sidebar.md +92 -0
- package/docs/embedding-level2-routes.md +86 -0
- package/docs/embedding-level3-tooltips.md +97 -0
- package/docs/embedding-level4-autogen.md +126 -0
- package/docs/index.html +39 -0
- package/docs/overview.md +42 -0
- package/docs/quickstart.md +95 -0
- package/docs/reference.md +73 -0
- package/docs/retold-catalog.json +181 -0
- package/docs/retold-keyword-index.json +4374 -0
- package/example_applications/basic/docs/README.md +40 -0
- package/example_applications/basic/docs/_sidebar.md +4 -0
- package/example_applications/basic/docs/_topics.json +10 -0
- package/example_applications/basic/docs/advanced-topics.md +47 -0
- package/example_applications/basic/docs/getting-started.md +70 -0
- package/example_applications/basic/index.html +100 -0
- package/example_applications/bookshop/.quackage.json +10 -0
- package/example_applications/bookshop/Pict-Application-Bookshop-Configuration.json +15 -0
- package/example_applications/bookshop/Pict-Application-Bookshop.js +218 -0
- package/example_applications/bookshop/data/BookshopData.json +65 -0
- package/example_applications/bookshop/data/pict_documentation_topics.json +46 -0
- package/example_applications/bookshop/docs/_sidebar.md +6 -0
- package/example_applications/bookshop/docs/book-detail.md +21 -0
- package/example_applications/bookshop/docs/book-list.md +21 -0
- package/example_applications/bookshop/docs/search-filter.md +18 -0
- package/example_applications/bookshop/docs/store.md +29 -0
- package/example_applications/bookshop/docs/welcome.md +23 -0
- package/example_applications/bookshop/html/index.html +236 -0
- package/example_applications/bookshop/package.json +34 -0
- package/example_applications/bookshop/views/PictView-Bookshop-BookList.js +324 -0
- package/example_applications/bookshop/views/PictView-Bookshop-HelpToggle.js +44 -0
- package/example_applications/bookshop/views/PictView-Bookshop-Store.js +271 -0
- package/package.json +55 -0
- package/source/Pict-Section-InlineDocumentation.js +10 -0
- package/source/providers/Pict-Provider-InlineDocumentation.js +1995 -0
- package/source/views/Pict-View-InlineDocumentation-Content.js +542 -0
- package/source/views/Pict-View-InlineDocumentation-Layout.js +206 -0
- package/source/views/Pict-View-InlineDocumentation-Nav.js +475 -0
- package/source/views/Pict-View-InlineDocumentation-TopicManager.js +1623 -0
- package/test/Browser_Integration_tests.js +1449 -0
- package/test/Pict-Section-InlineDocumentation_test.js +1285 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Inline Documentation Example
|
|
2
|
+
|
|
3
|
+
Welcome to the inline documentation browser example. This demonstrates embedding a documentation viewer inside a Pict application.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Markdown Rendering** — Full markdown support including code blocks, tables, and blockquotes
|
|
8
|
+
- **Sidebar Navigation** — Hierarchical document navigation loaded from `_sidebar.md`
|
|
9
|
+
- **Topic Filtering** — Scope navigation to specific topics for contextual help
|
|
10
|
+
- **Internal Links** — Click links to navigate between documents without leaving the page
|
|
11
|
+
|
|
12
|
+
## Getting Started
|
|
13
|
+
|
|
14
|
+
See the [Getting Started](getting-started.md) guide for setup instructions.
|
|
15
|
+
|
|
16
|
+
## Architecture
|
|
17
|
+
|
|
18
|
+
The inline documentation provider manages all views and state. You interact with it through a simple API:
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
let tmpProvider = pict.providers['Pict-InlineDocumentation'];
|
|
22
|
+
tmpProvider.loadDocument('getting-started.md');
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Code Example
|
|
26
|
+
|
|
27
|
+
Here is a simple code block:
|
|
28
|
+
|
|
29
|
+
```javascript
|
|
30
|
+
const libPict = require('pict');
|
|
31
|
+
const libInlineDoc = require('pict-section-inlinedocumentation');
|
|
32
|
+
|
|
33
|
+
let tmpPict = new libPict({ Product: 'MyApp' });
|
|
34
|
+
|
|
35
|
+
tmpPict.addProvider('Pict-InlineDocumentation',
|
|
36
|
+
libInlineDoc.default_configuration,
|
|
37
|
+
libInlineDoc);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
> This is a blockquote demonstrating the markdown rendering capabilities.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Advanced Topics
|
|
2
|
+
|
|
3
|
+
This page covers advanced usage of the inline documentation system.
|
|
4
|
+
|
|
5
|
+
## Custom Container
|
|
6
|
+
|
|
7
|
+
By default the layout renders into an element with id `InlineDoc-Container`. You can override this:
|
|
8
|
+
|
|
9
|
+
```javascript
|
|
10
|
+
tmpDocProvider.initializeDocumentation({
|
|
11
|
+
DocsBaseURL: 'docs/',
|
|
12
|
+
ContainerAddress: '#my-custom-container'
|
|
13
|
+
});
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Programmatic Navigation
|
|
17
|
+
|
|
18
|
+
The navigation sidebar is loaded from `_sidebar.md`, but you can also set it programmatically via AppData:
|
|
19
|
+
|
|
20
|
+
```javascript
|
|
21
|
+
pict.AppData.InlineDocumentation.SidebarGroups = [
|
|
22
|
+
{
|
|
23
|
+
Name: 'Guide',
|
|
24
|
+
Key: 'guide',
|
|
25
|
+
Path: 'README.md',
|
|
26
|
+
Items: [
|
|
27
|
+
{ Name: 'Getting Started', Path: 'getting-started.md' },
|
|
28
|
+
{ Name: 'Advanced', Path: 'advanced-topics.md' }
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
];
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Content Caching
|
|
35
|
+
|
|
36
|
+
Documents are cached after first load. To clear the cache (e.g. after docs are updated), change the base URL or create a new provider instance.
|
|
37
|
+
|
|
38
|
+
## Upcoming Features
|
|
39
|
+
|
|
40
|
+
These features are planned for future releases:
|
|
41
|
+
|
|
42
|
+
- **Edit Mode** — In-place markdown editing
|
|
43
|
+
- **Tooltips** — Hover documentation for terms and concepts
|
|
44
|
+
- **Localization** — Multi-language document support
|
|
45
|
+
- **Search** — Full-text search across documents
|
|
46
|
+
- **AI Integration** — Contextual AI assistance
|
|
47
|
+
- **Advanced Docking** — Resizable, detachable documentation panels
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Getting Started
|
|
2
|
+
|
|
3
|
+
This guide walks you through embedding the inline documentation browser in your application.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install pict-section-inlinedocumentation
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Basic Setup
|
|
12
|
+
|
|
13
|
+
1. Add the provider to your Pict instance
|
|
14
|
+
2. Call `initializeDocumentation()` with your docs base URL
|
|
15
|
+
3. Load a document
|
|
16
|
+
|
|
17
|
+
```javascript
|
|
18
|
+
const libPict = require('pict');
|
|
19
|
+
const libInlineDoc = require('pict-section-inlinedocumentation');
|
|
20
|
+
|
|
21
|
+
let tmpPict = new libPict({ Product: 'MyApp' });
|
|
22
|
+
|
|
23
|
+
// Add the inline documentation provider
|
|
24
|
+
let tmpDocProvider = tmpPict.addProvider(
|
|
25
|
+
'Pict-InlineDocumentation',
|
|
26
|
+
libInlineDoc.default_configuration,
|
|
27
|
+
libInlineDoc);
|
|
28
|
+
|
|
29
|
+
// Initialize with your docs folder URL
|
|
30
|
+
tmpDocProvider.initializeDocumentation(
|
|
31
|
+
{ DocsBaseURL: 'docs/' },
|
|
32
|
+
() =>
|
|
33
|
+
{
|
|
34
|
+
// Load the first document
|
|
35
|
+
tmpDocProvider.loadDocument('README.md');
|
|
36
|
+
});
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Topics
|
|
40
|
+
|
|
41
|
+
Topics let you scope the navigation sidebar to a subset of documents. Define topics in a `_topics.json` file:
|
|
42
|
+
|
|
43
|
+
```json
|
|
44
|
+
{
|
|
45
|
+
"getting-started": {
|
|
46
|
+
"Name": "Getting Started",
|
|
47
|
+
"Documents": ["README.md", "getting-started.md"]
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Then activate a topic:
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
tmpDocProvider.setTopic('getting-started');
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## API Reference
|
|
59
|
+
|
|
60
|
+
| Method | Description |
|
|
61
|
+
|--------|-------------|
|
|
62
|
+
| `initializeDocumentation(options, callback)` | Initialize the documentation system |
|
|
63
|
+
| `loadDocument(path, callback)` | Load and display a document |
|
|
64
|
+
| `setTopic(topicKey)` | Filter navigation to a topic |
|
|
65
|
+
| `clearTopic()` | Show all navigation |
|
|
66
|
+
| `navigateBack(callback)` | Go to previous document |
|
|
67
|
+
| `setDocsBaseURL(url)` | Change the docs root URL |
|
|
68
|
+
| `getNavigationHistory()` | Get visited document paths |
|
|
69
|
+
|
|
70
|
+
Back to [Home](README.md).
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<title>Inline Documentation Example</title>
|
|
7
|
+
<style>
|
|
8
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
9
|
+
body {
|
|
10
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
11
|
+
background: #F5F3EE;
|
|
12
|
+
color: #3D3229;
|
|
13
|
+
padding: 2em;
|
|
14
|
+
}
|
|
15
|
+
h1 {
|
|
16
|
+
margin-bottom: 0.5em;
|
|
17
|
+
font-size: 1.5em;
|
|
18
|
+
}
|
|
19
|
+
.controls {
|
|
20
|
+
margin-bottom: 1em;
|
|
21
|
+
display: flex;
|
|
22
|
+
gap: 0.5em;
|
|
23
|
+
flex-wrap: wrap;
|
|
24
|
+
}
|
|
25
|
+
.controls button {
|
|
26
|
+
padding: 0.4em 0.8em;
|
|
27
|
+
border: 1px solid #C4BAA8;
|
|
28
|
+
border-radius: 4px;
|
|
29
|
+
background: #fff;
|
|
30
|
+
color: #3D3229;
|
|
31
|
+
cursor: pointer;
|
|
32
|
+
font-size: 0.9em;
|
|
33
|
+
}
|
|
34
|
+
.controls button:hover {
|
|
35
|
+
background: #F0ECE4;
|
|
36
|
+
}
|
|
37
|
+
.controls button.active {
|
|
38
|
+
background: #2E7D74;
|
|
39
|
+
color: #fff;
|
|
40
|
+
border-color: #2E7D74;
|
|
41
|
+
}
|
|
42
|
+
#InlineDoc-Container {
|
|
43
|
+
height: 600px;
|
|
44
|
+
}
|
|
45
|
+
</style>
|
|
46
|
+
</head>
|
|
47
|
+
<body>
|
|
48
|
+
<h1>Inline Documentation Browser</h1>
|
|
49
|
+
<div class="controls">
|
|
50
|
+
<button onclick="loadDoc('README.md')">Home</button>
|
|
51
|
+
<button onclick="loadDoc('getting-started.md')">Getting Started</button>
|
|
52
|
+
<button onclick="loadDoc('advanced-topics.md')">Advanced Topics</button>
|
|
53
|
+
<button onclick="setTopic('getting-started')">Topic: Getting Started</button>
|
|
54
|
+
<button onclick="setTopic('advanced')">Topic: Advanced</button>
|
|
55
|
+
<button onclick="clearTopic()">Clear Topic</button>
|
|
56
|
+
<button onclick="goBack()">Back</button>
|
|
57
|
+
</div>
|
|
58
|
+
<div id="InlineDoc-Container"></div>
|
|
59
|
+
|
|
60
|
+
<script src="../../dist/pict-section-inlinedocumentation.js"></script>
|
|
61
|
+
<script src="https://cdn.jsdelivr.net/npm/pict@1/dist/pict.min.js"></script>
|
|
62
|
+
<script>
|
|
63
|
+
var _Pict = new Pict({ Product: 'InlineDocExample' });
|
|
64
|
+
|
|
65
|
+
var InlineDocProvider = require('pict-section-inlinedocumentation');
|
|
66
|
+
|
|
67
|
+
var _DocProvider = _Pict.addProvider(
|
|
68
|
+
'Pict-InlineDocumentation',
|
|
69
|
+
InlineDocProvider.default_configuration,
|
|
70
|
+
InlineDocProvider);
|
|
71
|
+
|
|
72
|
+
_DocProvider.initializeDocumentation(
|
|
73
|
+
{ DocsBaseURL: 'docs/' },
|
|
74
|
+
function ()
|
|
75
|
+
{
|
|
76
|
+
_DocProvider.loadDocument('README.md');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
function loadDoc(pPath)
|
|
80
|
+
{
|
|
81
|
+
_DocProvider.loadDocument(pPath);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function setTopic(pKey)
|
|
85
|
+
{
|
|
86
|
+
_DocProvider.setTopic(pKey);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function clearTopic()
|
|
90
|
+
{
|
|
91
|
+
_DocProvider.clearTopic();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function goBack()
|
|
95
|
+
{
|
|
96
|
+
_DocProvider.navigateBack();
|
|
97
|
+
}
|
|
98
|
+
</script>
|
|
99
|
+
</body>
|
|
100
|
+
</html>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Name": "Bookshop",
|
|
3
|
+
"Hash": "Bookshop",
|
|
4
|
+
|
|
5
|
+
"MainViewportViewIdentifier": "Bookshop-BookList",
|
|
6
|
+
|
|
7
|
+
"AutoSolveAfterInitialize": true,
|
|
8
|
+
"AutoRenderMainViewportViewAfterInitialize": false,
|
|
9
|
+
"AutoRenderViewsAfterInitialize": false,
|
|
10
|
+
|
|
11
|
+
"pict_configuration":
|
|
12
|
+
{
|
|
13
|
+
"Product": "Bookshop-Pict-Application"
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
const libPictApplication = require('pict-application');
|
|
2
|
+
|
|
3
|
+
const libInlineDocumentation = require('../../source/Pict-Section-InlineDocumentation.js');
|
|
4
|
+
|
|
5
|
+
const libViewBookList = require('./views/PictView-Bookshop-BookList.js');
|
|
6
|
+
const libViewStore = require('./views/PictView-Bookshop-Store.js');
|
|
7
|
+
const libViewHelpToggle = require('./views/PictView-Bookshop-HelpToggle.js');
|
|
8
|
+
|
|
9
|
+
const _BookshopData = require('./data/BookshopData.json');
|
|
10
|
+
const _TopicsData = require('./data/pict_documentation_topics.json');
|
|
11
|
+
|
|
12
|
+
class BookshopApplication extends libPictApplication
|
|
13
|
+
{
|
|
14
|
+
constructor(pFable, pOptions, pServiceHash)
|
|
15
|
+
{
|
|
16
|
+
super(pFable, pOptions, pServiceHash);
|
|
17
|
+
|
|
18
|
+
// Add the inline documentation provider
|
|
19
|
+
this.pict.addProvider('Pict-InlineDocumentation', libInlineDocumentation.default_configuration, libInlineDocumentation);
|
|
20
|
+
|
|
21
|
+
// Add application views
|
|
22
|
+
this.pict.addView('Bookshop-BookList', libViewBookList.default_configuration, libViewBookList);
|
|
23
|
+
this.pict.addView('Bookshop-Store', libViewStore.default_configuration, libViewStore);
|
|
24
|
+
this.pict.addView('Bookshop-HelpToggle', libViewHelpToggle.default_configuration, libViewHelpToggle);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
onAfterInitializeAsync(fCallback)
|
|
28
|
+
{
|
|
29
|
+
// Initialize application state
|
|
30
|
+
this.pict.AppData.Bookshop =
|
|
31
|
+
{
|
|
32
|
+
Books: _BookshopData.Books,
|
|
33
|
+
CurrentBook: null,
|
|
34
|
+
CurrentView: 'BookList',
|
|
35
|
+
GenreFilter: '',
|
|
36
|
+
HelpVisible: false,
|
|
37
|
+
HelpTopicCode: 'BOOKSHOP-WELCOME'
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Pre-load topics into the inline documentation state
|
|
41
|
+
if (!this.pict.AppData.InlineDocumentation)
|
|
42
|
+
{
|
|
43
|
+
this.pict.AppData.InlineDocumentation = {};
|
|
44
|
+
}
|
|
45
|
+
this.pict.AppData.InlineDocumentation.Topics = _TopicsData;
|
|
46
|
+
|
|
47
|
+
// Initialize inline documentation
|
|
48
|
+
let tmpDocProvider = this.pict.providers['Pict-InlineDocumentation'];
|
|
49
|
+
tmpDocProvider.initializeDocumentation(
|
|
50
|
+
{
|
|
51
|
+
DocsBaseURL: 'docs/',
|
|
52
|
+
onSave: (pSaveData, fSaveCallback) =>
|
|
53
|
+
{
|
|
54
|
+
// Demo save handler — log to console
|
|
55
|
+
this.log.info(`Bookshop: Saving document [${pSaveData.Path}] (${pSaveData.Content.length} chars)`);
|
|
56
|
+
// In a real app, this would PUT to an API
|
|
57
|
+
return fSaveCallback(null);
|
|
58
|
+
},
|
|
59
|
+
onTopicsSave: (pTopics, fSaveCallback) =>
|
|
60
|
+
{
|
|
61
|
+
// Demo topics save handler — log to console
|
|
62
|
+
this.log.info(`Bookshop: Saving topics (${Object.keys(pTopics).length} topics)`);
|
|
63
|
+
// In a real app, this would PUT to an API
|
|
64
|
+
return fSaveCallback(null);
|
|
65
|
+
},
|
|
66
|
+
onImageUpload: (pFile, pDocumentPath, fCallback) =>
|
|
67
|
+
{
|
|
68
|
+
// Demo image upload handler — log to console
|
|
69
|
+
this.log.info(`Bookshop: Image upload [${pFile.name}] (${pFile.size} bytes) for document [${pDocumentPath}]`);
|
|
70
|
+
// In a real app, this would POST the file to a server
|
|
71
|
+
// and return a relative URL for the markdown reference.
|
|
72
|
+
// For the demo, fall back to base64 by returning an error.
|
|
73
|
+
return fCallback('Demo mode: no upload server configured');
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
() =>
|
|
77
|
+
{
|
|
78
|
+
// Enable edit mode for demo
|
|
79
|
+
tmpDocProvider.setEditEnabled(true);
|
|
80
|
+
|
|
81
|
+
// Render the main book list
|
|
82
|
+
this.pict.views['Bookshop-BookList'].render();
|
|
83
|
+
|
|
84
|
+
// Load help for the initial route
|
|
85
|
+
tmpDocProvider.navigateToRoute('/books');
|
|
86
|
+
|
|
87
|
+
// Set up F1 keyboard listener
|
|
88
|
+
this._setupKeyboardShortcuts();
|
|
89
|
+
|
|
90
|
+
return super.onAfterInitializeAsync(fCallback);
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Set up the F1 keyboard shortcut for toggling help.
|
|
96
|
+
*/
|
|
97
|
+
_setupKeyboardShortcuts()
|
|
98
|
+
{
|
|
99
|
+
if (typeof document === 'undefined')
|
|
100
|
+
{
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
document.addEventListener('keydown', (pEvent) =>
|
|
105
|
+
{
|
|
106
|
+
if (pEvent.key === 'F1')
|
|
107
|
+
{
|
|
108
|
+
pEvent.preventDefault();
|
|
109
|
+
this.toggleHelp();
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Toggle the help panel visibility.
|
|
116
|
+
*/
|
|
117
|
+
toggleHelp()
|
|
118
|
+
{
|
|
119
|
+
let tmpState = this.pict.AppData.Bookshop;
|
|
120
|
+
tmpState.HelpVisible = !tmpState.HelpVisible;
|
|
121
|
+
|
|
122
|
+
let tmpHelpPanel = document.getElementById('Bookshop-Help-Panel');
|
|
123
|
+
let tmpContentArea = document.getElementById('Bookshop-Content-Area');
|
|
124
|
+
|
|
125
|
+
if (tmpState.HelpVisible)
|
|
126
|
+
{
|
|
127
|
+
if (tmpHelpPanel) { tmpHelpPanel.classList.add('visible'); }
|
|
128
|
+
if (tmpContentArea) { tmpContentArea.classList.add('help-open'); }
|
|
129
|
+
}
|
|
130
|
+
else
|
|
131
|
+
{
|
|
132
|
+
if (tmpHelpPanel) { tmpHelpPanel.classList.remove('visible'); }
|
|
133
|
+
if (tmpContentArea) { tmpContentArea.classList.remove('help-open'); }
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Show contextual help for a specific topic code.
|
|
139
|
+
*
|
|
140
|
+
* @param {string} pTopicCode - The TopicCode from pict_documentation_topics.json
|
|
141
|
+
*/
|
|
142
|
+
showHelp(pTopicCode)
|
|
143
|
+
{
|
|
144
|
+
let tmpState = this.pict.AppData.Bookshop;
|
|
145
|
+
let tmpDocProvider = this.pict.providers['Pict-InlineDocumentation'];
|
|
146
|
+
|
|
147
|
+
tmpState.HelpTopicCode = pTopicCode;
|
|
148
|
+
|
|
149
|
+
// Ensure help panel is visible
|
|
150
|
+
if (!tmpState.HelpVisible)
|
|
151
|
+
{
|
|
152
|
+
tmpState.HelpVisible = true;
|
|
153
|
+
let tmpHelpPanel = document.getElementById('Bookshop-Help-Panel');
|
|
154
|
+
let tmpContentArea = document.getElementById('Bookshop-Content-Area');
|
|
155
|
+
if (tmpHelpPanel) { tmpHelpPanel.classList.add('visible'); }
|
|
156
|
+
if (tmpContentArea) { tmpContentArea.classList.add('help-open'); }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
// Load the topic document
|
|
160
|
+
tmpDocProvider.loadTopicDocument(pTopicCode);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Navigate to a specific book's store page.
|
|
165
|
+
*
|
|
166
|
+
* @param {number} pBookID - The book ID
|
|
167
|
+
*/
|
|
168
|
+
showBook(pBookID)
|
|
169
|
+
{
|
|
170
|
+
let tmpState = this.pict.AppData.Bookshop;
|
|
171
|
+
let tmpDocProvider = this.pict.providers['Pict-InlineDocumentation'];
|
|
172
|
+
|
|
173
|
+
for (let i = 0; i < tmpState.Books.length; i++)
|
|
174
|
+
{
|
|
175
|
+
if (tmpState.Books[i].IDBook === pBookID)
|
|
176
|
+
{
|
|
177
|
+
tmpState.CurrentBook = tmpState.Books[i];
|
|
178
|
+
tmpState.CurrentView = 'Store';
|
|
179
|
+
this.pict.views['Bookshop-Store'].render();
|
|
180
|
+
|
|
181
|
+
// Update help for the store route
|
|
182
|
+
tmpDocProvider.navigateToRoute('/books/store/' + pBookID);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* Navigate back to the book list.
|
|
190
|
+
*/
|
|
191
|
+
showBookList()
|
|
192
|
+
{
|
|
193
|
+
let tmpState = this.pict.AppData.Bookshop;
|
|
194
|
+
let tmpDocProvider = this.pict.providers['Pict-InlineDocumentation'];
|
|
195
|
+
|
|
196
|
+
tmpState.CurrentBook = null;
|
|
197
|
+
tmpState.CurrentView = 'BookList';
|
|
198
|
+
this.pict.views['Bookshop-BookList'].render();
|
|
199
|
+
|
|
200
|
+
// Update help for the book list route
|
|
201
|
+
tmpDocProvider.navigateToRoute('/books');
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Filter books by genre.
|
|
206
|
+
*
|
|
207
|
+
* @param {string} pGenre - The genre to filter by (empty for all)
|
|
208
|
+
*/
|
|
209
|
+
filterByGenre(pGenre)
|
|
210
|
+
{
|
|
211
|
+
this.pict.AppData.Bookshop.GenreFilter = pGenre || '';
|
|
212
|
+
this.pict.views['Bookshop-BookList'].render();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
module.exports = BookshopApplication;
|
|
217
|
+
|
|
218
|
+
module.exports.default_configuration = require('./Pict-Application-Bookshop-Configuration.json');
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
{
|
|
2
|
+
"Books":
|
|
3
|
+
[
|
|
4
|
+
{
|
|
5
|
+
"IDBook": 1,
|
|
6
|
+
"Title": "The Pragmatic Programmer",
|
|
7
|
+
"Author": "David Thomas & Andrew Hunt",
|
|
8
|
+
"Price": 49.99,
|
|
9
|
+
"Genre": "Software Engineering",
|
|
10
|
+
"Cover": "https://picsum.photos/seed/pragprog/120/180",
|
|
11
|
+
"Description": "A classic guide to software craftsmanship covering topics from personal responsibility to architectural techniques.",
|
|
12
|
+
"InStock": true
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"IDBook": 2,
|
|
16
|
+
"Title": "Designing Data-Intensive Applications",
|
|
17
|
+
"Author": "Martin Kleppmann",
|
|
18
|
+
"Price": 44.99,
|
|
19
|
+
"Genre": "Distributed Systems",
|
|
20
|
+
"Cover": "https://picsum.photos/seed/dataintensive/120/180",
|
|
21
|
+
"Description": "The big ideas behind reliable, scalable, and maintainable systems, with detailed analysis of the algorithms and protocols.",
|
|
22
|
+
"InStock": true
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"IDBook": 3,
|
|
26
|
+
"Title": "Structure and Interpretation of Computer Programs",
|
|
27
|
+
"Author": "Harold Abelson & Gerald Jay Sussman",
|
|
28
|
+
"Price": 39.99,
|
|
29
|
+
"Genre": "Computer Science",
|
|
30
|
+
"Cover": "https://picsum.photos/seed/sicp/120/180",
|
|
31
|
+
"Description": "The legendary MIT textbook introducing core concepts of computation through Scheme.",
|
|
32
|
+
"InStock": false
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"IDBook": 4,
|
|
36
|
+
"Title": "Clean Code",
|
|
37
|
+
"Author": "Robert C. Martin",
|
|
38
|
+
"Price": 37.99,
|
|
39
|
+
"Genre": "Software Engineering",
|
|
40
|
+
"Cover": "https://picsum.photos/seed/cleancode/120/180",
|
|
41
|
+
"Description": "A handbook of agile software craftsmanship with practical advice for writing better code.",
|
|
42
|
+
"InStock": true
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"IDBook": 5,
|
|
46
|
+
"Title": "The Art of Computer Programming",
|
|
47
|
+
"Author": "Donald E. Knuth",
|
|
48
|
+
"Price": 79.99,
|
|
49
|
+
"Genre": "Computer Science",
|
|
50
|
+
"Cover": "https://picsum.photos/seed/taocp/120/180",
|
|
51
|
+
"Description": "Knuth's monumental multi-volume work covering fundamental algorithms and data structures.",
|
|
52
|
+
"InStock": true
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"IDBook": 6,
|
|
56
|
+
"Title": "Refactoring",
|
|
57
|
+
"Author": "Martin Fowler",
|
|
58
|
+
"Price": 42.99,
|
|
59
|
+
"Genre": "Software Engineering",
|
|
60
|
+
"Cover": "https://picsum.photos/seed/refactoring/120/180",
|
|
61
|
+
"Description": "Improving the design of existing code through systematic transformations with catalog of refactoring patterns.",
|
|
62
|
+
"InStock": true
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"BOOKSHOP-WELCOME": {
|
|
3
|
+
"TopicCode": "BOOKSHOP-WELCOME",
|
|
4
|
+
"TopicHelpFilePath": "welcome.md",
|
|
5
|
+
"TopicTitle": "Welcome to the Bookshop",
|
|
6
|
+
"Routes": ["/"]
|
|
7
|
+
},
|
|
8
|
+
"BOOKSHOP-BOOKLIST": {
|
|
9
|
+
"TopicCode": "BOOKSHOP-BOOKLIST",
|
|
10
|
+
"TopicHelpFilePath": "book-list.md",
|
|
11
|
+
"TopicTitle": "Browsing the Book Catalog",
|
|
12
|
+
"Routes": ["/books", "/books/catalog"],
|
|
13
|
+
"Tooltips": {
|
|
14
|
+
"catalog-title": { "Content": "Browse our full collection of books. Click any book to view details and purchase.\n\nSee [Book Catalog Help](help:book-list.md) for the full guide." },
|
|
15
|
+
"catalog-info": { "Content": "**Tip:** Use the genre filter to narrow results, or click a book card to visit its store page.\n\nLearn more: [Searching & Filtering](help:search-filter.md)" },
|
|
16
|
+
"genre-filter": { "Content": "Filter the catalog by literary genre. Select **All Genres** to see everything.\n\nFor advanced filtering tips, see [Search & Filter Guide](help:search-filter.md)." },
|
|
17
|
+
"book-price": { "Content": "All prices are in **USD** and include tax.\n\nSee [Store Page Help → Pricing](help:store.md#pricing) for details." },
|
|
18
|
+
"stock-status": { "Content": "**In Stock** means the book is available for immediate purchase. **Out of Stock** items cannot be added to cart.\n\nMore info: [Store Help → Availability](help:store.md#availability)" }
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"BOOKSHOP-BOOKDETAIL": {
|
|
22
|
+
"TopicCode": "BOOKSHOP-BOOKDETAIL",
|
|
23
|
+
"TopicHelpFilePath": "book-detail.md",
|
|
24
|
+
"TopicTitle": "Book Details & Purchasing",
|
|
25
|
+
"Routes": ["/books/detail/*"]
|
|
26
|
+
},
|
|
27
|
+
"BOOKSHOP-STORE": {
|
|
28
|
+
"TopicCode": "BOOKSHOP-STORE",
|
|
29
|
+
"TopicHelpFilePath": "store.md",
|
|
30
|
+
"TopicTitle": "The Store Page",
|
|
31
|
+
"Routes": ["/books/store/*"],
|
|
32
|
+
"Tooltips": {
|
|
33
|
+
"genre-badge": { "Content": "Books are categorized by genre to help you find similar titles.\n\nSee the [full catalog](help:book-list.md) to browse by genre." },
|
|
34
|
+
"store-price": { "Content": "The listed price is the final price in **USD**, tax included.\n\n[Pricing details](help:store.md#pricing)" },
|
|
35
|
+
"store-stock": { "Content": "Real-time availability. Out of stock items may be restocked — check back later.\n\n[Availability info](help:store.md#availability)" },
|
|
36
|
+
"add-to-cart": { "Content": "Adds this book to your shopping cart. You can review your cart before checkout.\n\nSee [Store Help](help:store.md) for the full purchasing guide." },
|
|
37
|
+
"cart-info": { "Content": "**Shopping Cart:** Items stay in your cart until you complete checkout or remove them.\n\nFor help: [Store Guide](help:store.md) | [Book Details](help:book-detail.md)" }
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"BOOKSHOP-SEARCH": {
|
|
41
|
+
"TopicCode": "BOOKSHOP-SEARCH",
|
|
42
|
+
"TopicHelpFilePath": "search-filter.md",
|
|
43
|
+
"TopicTitle": "Searching & Filtering",
|
|
44
|
+
"Routes": ["/books/search", "/books/filter"]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Book Details & Purchasing
|
|
2
|
+
|
|
3
|
+
When you click on a book in the catalog, you are taken to the store page which shows the full details for that book.
|
|
4
|
+
|
|
5
|
+
## Detail View
|
|
6
|
+
|
|
7
|
+
The detail view shows:
|
|
8
|
+
|
|
9
|
+
- **Large cover image** on the left
|
|
10
|
+
- **Full title and author** on the right
|
|
11
|
+
- **Genre badge** indicating the book's category
|
|
12
|
+
- **Description** — A summary of the book's content
|
|
13
|
+
- **Price** displayed prominently
|
|
14
|
+
- **Stock status** — Whether the book is available
|
|
15
|
+
|
|
16
|
+
## Actions
|
|
17
|
+
|
|
18
|
+
- **Back to Catalog** — Returns you to the full book list
|
|
19
|
+
- **Add to Cart** — Adds the book to your shopping cart (available for in-stock items)
|
|
20
|
+
|
|
21
|
+
> This is a demo application. The "Add to Cart" button simulates the action but does not process a real transaction.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Browsing the Book Catalog
|
|
2
|
+
|
|
3
|
+
The book catalog displays all available titles in a card layout. Each card shows the book's cover, title, author, genre, price, and availability.
|
|
4
|
+
|
|
5
|
+
## Card Information
|
|
6
|
+
|
|
7
|
+
- **Cover Image** — A thumbnail of the book cover
|
|
8
|
+
- **Title & Author** — The book's title and author(s)
|
|
9
|
+
- **Genre** — The category the book belongs to
|
|
10
|
+
- **Price** — The current retail price
|
|
11
|
+
- **Availability** — Whether the book is currently in stock
|
|
12
|
+
|
|
13
|
+
## Interacting with Books
|
|
14
|
+
|
|
15
|
+
Click on any book card to navigate to the **Store** page where you can see full details about the book and add it to your cart.
|
|
16
|
+
|
|
17
|
+
> Books that are out of stock will show a red "Out of Stock" badge. You can still view their details but purchasing may be unavailable.
|
|
18
|
+
|
|
19
|
+
## Filtering
|
|
20
|
+
|
|
21
|
+
Use the genre filter dropdown above the book list to narrow the catalog to a specific genre. Select "All Genres" to see the full catalog again.
|