Skip to content

Commit 332f119

Browse files
committed
Merge branch 'feature/cdi-previewer'
2 parents d73f46e + 5d481c7 commit 332f119

16 files changed

Lines changed: 467 additions & 3652 deletions
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# CDI Previewer - Bundle Integration
2+
3+
## Changes Made (November 2025)
4+
5+
### ✅ Migrated to Single Bundle Architecture
6+
7+
**What changed:**
8+
- Replaced 10+ individual JavaScript files with a single optimized bundle
9+
- Updated to use custom shacl-engine with SPARQL target support
10+
- Simplified HTML file to use single script tag
11+
12+
### 📦 New Files
13+
14+
1. **`lib/cdi-viewer.bundle.min.js`** (1.2 MB)
15+
- Complete CDI viewer application
16+
- Includes: N3.js, JSON-LD library, shacl-engine (with SPARQL targets)
17+
- Minified and optimized for production
18+
- Expects jQuery and Bootstrap to be loaded externally
19+
20+
2. **`shapes/cdif-core.ttl`** (Updated)
21+
- CDIF Discovery shapes with SPARQL target support
22+
- Validates only root-level datasets (not nested ones)
23+
- Uses `sh:SPARQLTarget` for advanced node selection
24+
25+
3. **`css/cdi-preview.css`** (Updated)
26+
- Latest styling for the viewer
27+
28+
4. **`test-cdi-bundle.html`**
29+
- Test page to verify bundle loads correctly
30+
- Can test with example CDI files
31+
32+
### 🗑️ Removed Files
33+
34+
- `js/cdi-preview/` folder (10 files) - now bundled
35+
- `lib/rdf-validate-shacl.bundle.min.js` - replaced with shacl-engine
36+
37+
### 📝 Modified Files
38+
39+
- **`CdiPreview.html`**
40+
- Removed individual script tags
41+
- Added single `<script src="lib/cdi-viewer.bundle.min.js"></script>`
42+
- Removed external CDN links for N3.js and JSON-LD (now bundled)
43+
44+
## How to Update the Bundle
45+
46+
When the cdi-viewer source is updated:
47+
48+
```bash
49+
# Build in cdi-viewer project
50+
cd /path/to/cdi-viewer
51+
npm run build
52+
53+
# Copy to dataverse-previewers
54+
cp dist/cdi-viewer.bundle.js /path/to/dataverse-previewers/previewers/betatest/lib/cdi-viewer.bundle.min.js
55+
56+
# Copy updated shapes if changed
57+
cp shapes/cdif-core.ttl /path/to/dataverse-previewers/previewers/betatest/shapes/cdif-core.ttl
58+
59+
# Copy CSS if changed
60+
cp css/cdi-preview.css /path/to/dataverse-previewers/previewers/betatest/css/cdi-preview.css
61+
```
62+
63+
## Testing
64+
65+
1. **Test page:** Open `test-cdi-bundle.html` in a browser
66+
2. **Full previewer:** Open `CdiPreview.html` with a CDI JSON-LD file
67+
3. **With Dataverse:** Test with `?fileUrl=...` or `?fileid=...&siteUrl=...` parameters
68+
69+
## Key Features Now Available
70+
71+
**SPARQL Target Support** - Validates only root datasets using SPARQL queries
72+
**Property Recognition** - Blue badges for SHACL-defined properties
73+
**Faster Loading** - Single bundle, fewer HTTP requests
74+
**Offline Capable** - No external CDN dependencies for core functionality
75+
**Easier Deployment** - Just copy one bundle file
76+
77+
## Bundle Contents
78+
79+
The `cdi-viewer.bundle.min.js` includes:
80+
81+
- **JSON-LD processor** - For expanding/compacting JSON-LD
82+
- **N3.js parser** - For parsing Turtle SHACL shapes
83+
- **shacl-engine** - Modified version with SPARQL target support
84+
- **All viewer modules** - Validation, rendering, editing, suggestions
85+
- **RDF utilities** - Dataset manipulation, term handling
86+
87+
**External dependencies (not bundled):**
88+
- jQuery 3.6.0
89+
- Bootstrap 3.3.7
90+
91+
These must be loaded before the bundle.
92+
93+
## Size Comparison
94+
95+
**Before:**
96+
- 10 individual JS files: ~200 KB (uncompressed)
97+
- External CDN dependencies: ~300 KB (N3.js + JSON-LD)
98+
- rdf-validate-shacl: ~800 KB
99+
- **Total:** ~1.3 MB + HTTP overhead (12 requests)
100+
101+
**After:**
102+
- 1 bundle: 1.2 MB
103+
- **Total:** 1.2 MB (1 request)
104+
105+
**Benefits:**
106+
- Fewer HTTP requests → faster loading
107+
- No CDN dependencies → works offline
108+
- All code versioned together → easier updates
109+
110+
## Troubleshooting
111+
112+
### Bundle doesn't load
113+
- Check browser console for errors
114+
- Verify jQuery and Bootstrap are loaded first
115+
- Check file path is correct: `lib/cdi-viewer.bundle.min.js`
116+
117+
### Validation doesn't work
118+
- Check if SHACL shapes file exists: `shapes/cdif-core.ttl`
119+
- Verify network requests show shapes loading successfully
120+
- Check console for SPARQL target execution logs
121+
122+
### Properties show as "EXTRA" instead of "SHACL-defined"
123+
- Verify namespace in JSON-LD matches shapes (http:// not https://)
124+
- Check if shape has `sh:targetClass` or `sh:target` for the node type
125+
- Enable debug logging to see shape matching details

previewers/betatest/CdiPreview.html

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<title>CDI Data Viewer & Editor</title>
77

8-
<!-- Favicon -->
9-
<link rel="icon" type="image/x-icon" href="/dataverse-previewers/favicon.ico">
10-
118
<!-- External CSS -->
129
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
1310
<link rel="stylesheet" href="css/cdi-preview.css">
@@ -144,23 +141,8 @@ <h4 class="modal-title">
144141
<!-- External JavaScript Libraries -->
145142
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
146143
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
147-
<script src="https://cdn.jsdelivr.net/npm/n3/browser/n3.min.js"></script>
148-
<script src="https://cdn.jsdelivr.net/npm/jsonld/dist/jsonld.min.js"></script>
149-
150-
<!-- SHACL validation engine (rdf-validate-shacl browser bundle - Core SHACL only) -->
151-
<script src="lib/rdf-validate-shacl.bundle.min.js"></script>
152144

153-
<!-- Application JavaScript -->
154-
<script src="js/cdi-preview/cdi-shacl-loader.js"></script>
155-
<script src="js/cdi-preview/core.js"></script>
156-
<script src="js/cdi-preview/cdi-json-ld-helpers.js"></script>
157-
<!-- SHACL UI helpers (classifyProperty, enums) used by render & suggestions -->
158-
<script src="js/cdi-preview/cdi-shacl-helpers.js"></script>
159-
<script src="js/cdi-preview/validation.js"></script>
160-
<script src="js/cdi-preview/render.js"></script>
161-
<script src="js/cdi-preview/property-suggestions.js"></script>
162-
<script src="js/cdi-preview/data-extraction.js"></script>
163-
<script src="js/cdi-preview/event-handlers.js"></script>
164-
<script src="js/cdi-preview/cdi-graph-helpers.js"></script>
145+
<!-- CDI Viewer Bundle - includes all viewer code, validation, N3.js, JSON-LD, and SHACL engine with SPARQL target support -->
146+
<script src="lib/cdi-viewer.bundle.min.js"></script>
165147
</body>
166148
</html>

0 commit comments

Comments
 (0)