Content Library
The Content Library provides a centralized repository for reusable content blocks in SPEAR. Teams can create, manage, and insert standardized content across multiple reports while maintaining version history and optional real-time synchronization.
Overview
Section titled “Overview”The Content Library enables:
- Centralized storage of reusable content blocks
- Version history with rollback capabilities
- Import/export for content portability
- Usage tracking across reports
- Linked content that auto-updates when source changes
- Bulk operations for efficient management
Content Types
Section titled “Content Types”Global Content
Section titled “Global Content”Content blocks available across all reports regardless of service type:
- Executive summary templates
- Standard methodology descriptions
- Compliance boilerplate
- Legal disclaimers
- Company introductions
Service Content
Section titled “Service Content”Content specific to service types (e.g., Web Application Testing, Network Penetration):
- Service-specific methodology sections
- Standard scope definitions
- Technology-specific findings templates
- Remediation guidance by service area
Snippets
Section titled “Snippets”Small, frequently-used text fragments:
- Standard phrases
- Severity definitions
- Risk rating explanations
- Technical terminology definitions
Key Features
Section titled “Key Features”Version History
Section titled “Version History”Every content block maintains a complete version history:
| Field | Description |
|---|---|
| Version Number | Sequential version identifier |
| Created At | Timestamp of version creation |
| Created By | User who made the change |
| Content | Full content at that version |
| Change Notes | Optional description of changes |
Version Operations
Section titled “Version Operations”// Get version historyconst history = await contentLibraryService.getHistory(contentId);
// Restore previous versionawait contentLibraryService.restoreVersion(contentId, versionId);Import/Export
Section titled “Import/Export”Content can be exported and imported as JSON for:
- Backup and recovery
- Sharing between SPEAR instances
- Template distribution
- Migration workflows
Export Format:
{ "version": "1.0", "exportDate": "2024-01-15T10:30:00Z", "content": [ { "id": "abc123", "title": "Executive Summary Template", "type": "global", "content": "<p>HTML content...</p>", "tags": ["executive", "summary"], "metadata": {} } ]}Usage Tracking
Section titled “Usage Tracking”Track where content blocks are used across reports:
- Count of reports using each block
- List of specific report references
- Last used timestamp
- Usage frequency metrics
Bulk Operations
Section titled “Bulk Operations”Efficiently manage multiple content blocks:
| Operation | Description |
|---|---|
| Bulk Duplicate | Copy multiple blocks at once |
| Bulk Archive | Move to archive state |
| Bulk Restore | Restore from archive |
| Bulk Delete | Permanently remove multiple blocks |
Linked Content Blocks
Section titled “Linked Content Blocks”How Linking Works
Section titled “How Linking Works”When content from the library is inserted into a report, it can be:
- Copied - Content is duplicated, no ongoing connection
- Linked - Content maintains connection to source
Linked content displays visual indicators and can auto-update when the source changes.
Link States
Section titled “Link States”| State | Description | Visual |
|---|---|---|
| Linked | Connected to source, auto-updates | Chain icon |
| Unlinked | Was linked, now independent | Broken chain |
| Locked | Linked but protected from auto-update | Lock icon |
Auto-Update Behavior
Section titled “Auto-Update Behavior”When source content changes:
- Linked blocks update automatically
- Locked blocks retain current content
- Unlinked blocks are not affected
Manual Unlink
Section titled “Manual Unlink”Users can manually unlink content to:
- Make local modifications
- Prevent unwanted updates
- Create independent variations
Implementation Reference
Section titled “Implementation Reference”frontend/src/lib/components/edra/extensions/linked-content/LinkedContent.js
Content Library Button
Section titled “Content Library Button”The editor toolbar includes a Content Library button for inserting content.
Features
Section titled “Features”- Quick access from editor toolbar
- Tabbed interface: Global | Service-specific
- Search and filter functionality
- Preview before insertion
- Link or copy options
Component Reference
Section titled “Component Reference”frontend/src/lib/components/edra/shadcn/components/toolbar/ContentLibraryButton.svelte
Usage Flow
Section titled “Usage Flow”- Click Content Library button in toolbar
- Browse or search available content
- Preview selected content
- Choose “Insert Linked” or “Insert Copy”
- Content inserted at cursor position
API Operations
Section titled “API Operations”Content Library Service
Section titled “Content Library Service”Located at frontend/src/lib/services/content-library.service.ts:
import { contentLibraryService } from '$lib/services/content-library.service';
// Get all content blocksconst content = await contentLibraryService.list();
// Get single block with historyconst block = await contentLibraryService.getById(id);
// Create new contentawait contentLibraryService.create({ title: 'New Template', content: '<p>Content here</p>', type: 'global', tags: ['template']});
// Update content (creates new version)await contentLibraryService.update(id, { content: '<p>Updated content</p>', changeNotes: 'Fixed typo in paragraph 2'});
// Get version historyconst history = await contentLibraryService.getHistory(id);
// Restore versionawait contentLibraryService.restoreVersion(id, versionId);
// Bulk operationsawait contentLibraryService.bulkDuplicate([id1, id2, id3]);await contentLibraryService.bulkArchive([id1, id2]);await contentLibraryService.bulkRestore([id1, id2]);await contentLibraryService.bulkDelete([id1, id2]);
// Export/Importconst exported = await contentLibraryService.exportContent([id1, id2]);await contentLibraryService.importContent(exportedJson);
// Preview content (with shortcode resolution)const preview = await contentLibraryService.previewContent(id, context);
// Track usageawait contentLibraryService.trackUsage(contentId, reportId);Backend API
Section titled “Backend API”Backend routes at backend/api/content_library/:
| Endpoint | Method | Description |
|---|---|---|
/api/content-library | GET | List all content |
/api/content-library | POST | Create content |
/api/content-library/{id} | GET | Get single content |
/api/content-library/{id} | PATCH | Update content |
/api/content-library/{id} | DELETE | Delete content |
/api/content-library/{id}/history | GET | Get version history |
/api/content-library/{id}/restore/{versionId} | POST | Restore version |
/api/content-library/bulk/duplicate | POST | Bulk duplicate |
/api/content-library/bulk/archive | POST | Bulk archive |
/api/content-library/bulk/restore | POST | Bulk restore |
/api/content-library/bulk/delete | POST | Bulk delete |
/api/content-library/export | POST | Export content |
/api/content-library/import | POST | Import content |
Management Interface
Section titled “Management Interface”Content Library Page
Section titled “Content Library Page”Access via Reports > Content Library
Features:
- Grid/list view toggle
- Filter by type (global, service, snippet)
- Search by title and tags
- Sort by name, date, usage
- Bulk selection and operations
Routes
Section titled “Routes”- Management:
frontend/src/routes/console/reports/content-library/+page.svelte
Creating Content
Section titled “Creating Content”- Click New Content
- Select content type
- Enter title and tags
- Edit content in rich text editor
- Save to create first version
Editing Content
Section titled “Editing Content”- Select content block from list
- Click Edit
- Make changes in editor
- Optionally add change notes
- Save to create new version
Viewing History
Section titled “Viewing History”- Select content block
- Click History tab
- View list of versions with metadata
- Click version to preview
- Click Restore to revert
Shortcode Support
Section titled “Shortcode Support”Content blocks support shortcodes for dynamic values:
<p>This report was prepared for {{client.name}} on {{report.date}}.</p>Available Shortcodes
Section titled “Available Shortcodes”| Category | Examples |
|---|---|
| Client | {{client.name}}, {{client.contact}} |
| Project | {{project.name}}, {{project.dates}} |
| Report | {{report.title}}, {{report.date}} |
| Organization | {{org.name}}, {{org.address}} |
Resolution
Section titled “Resolution”Shortcodes are resolved:
- During PDF export
- In preview mode
- When viewing in report context
Best Practices
Section titled “Best Practices”Organize with Tags
Section titled “Organize with Tags”Use consistent tagging:
- Content type:
template,boilerplate,snippet - Service area:
webapp,network,physical - Section:
executive,methodology,findings
Write for Reuse
Section titled “Write for Reuse”Content should be:
- Generic enough to apply across reports
- Use shortcodes for variable data
- Avoid report-specific references
Version Strategically
Section titled “Version Strategically”- Add change notes for significant updates
- Review impact before updating linked content
- Consider duplicating before major changes
Monitor Usage
Section titled “Monitor Usage”- Regularly review usage statistics
- Archive unused content
- Update frequently-used content carefully
Link vs. Copy
Section titled “Link vs. Copy”Use Linking when:
- Content should stay synchronized
- Updates should propagate automatically
- Consistency is critical
Use Copying when:
- Content will be customized
- Independence is preferred
- Historical accuracy matters
Technical References
Section titled “Technical References”| Resource | Location |
|---|---|
| Content library service | frontend/src/lib/services/content-library.service.ts |
| LinkedContent extension | frontend/src/lib/components/edra/extensions/linked-content/LinkedContent.js |
| ContentLibraryButton | frontend/src/lib/components/edra/shadcn/components/toolbar/ContentLibraryButton.svelte |
| Backend API | backend/api/content_library/ |
| Management page | frontend/src/routes/console/reports/content-library/+page.svelte |