Fix demo site auto-enhancement and content persistence
- Restructure demo directory from test-sites/ to demos/ with flattened layout - Add auto-enhancement on server startup for all sites with auto_enhance: true - Fix inconsistent content ID generation that prevented dan-eden-portfolio content persistence - Update server configuration to enhance from source to separate output directories - Remove manual enhancement from justfile in favor of automatic server enhancement - Clean up legacy test files and unused restore command - Update build system to use CDN endpoint instead of file copying
This commit is contained in:
71
demos/scripts/download-site.js
Executable file
71
demos/scripts/download-site.js
Executable file
@@ -0,0 +1,71 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/**
|
||||
* Script to download a website with its assets for insertr testing
|
||||
* Usage: node download-site.js <url> <output-directory>
|
||||
*/
|
||||
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
async function downloadSite(url, outputDir) {
|
||||
console.log(`Downloading ${url} to ${outputDir}`);
|
||||
|
||||
// Create output directory
|
||||
if (!fs.existsSync(outputDir)) {
|
||||
fs.mkdirSync(outputDir, { recursive: true });
|
||||
}
|
||||
|
||||
try {
|
||||
// Use wget to download the site with assets
|
||||
// --page-requisites: download all files needed to display page
|
||||
// --convert-links: convert links to work locally
|
||||
// --adjust-extension: add proper extensions
|
||||
// --no-parent: don't ascend to parent directory
|
||||
// --no-host-directories: don't create host directories
|
||||
// --cut-dirs=1: cut directory levels
|
||||
const wgetCmd = `wget --page-requisites --convert-links --adjust-extension --no-parent --no-host-directories --directory-prefix="${outputDir}" --user-agent="Mozilla/5.0 (compatible; insertr-test-bot)" "${url}"`;
|
||||
|
||||
execSync(wgetCmd, { stdio: 'inherit' });
|
||||
|
||||
console.log('✅ Download completed successfully');
|
||||
|
||||
// Create README for the site
|
||||
const readmeContent = `# ${path.basename(outputDir)}
|
||||
|
||||
## Original URL
|
||||
${url}
|
||||
|
||||
## Downloaded
|
||||
${new Date().toISOString()}
|
||||
|
||||
## Testing Notes
|
||||
- Site downloaded with assets for insertr testing
|
||||
- Check HTML structure for suitable content sections
|
||||
- Add insertr classes to editable sections
|
||||
|
||||
## Insertr Enhancement Status
|
||||
- [ ] Content sections identified
|
||||
- [ ] Insertr classes added
|
||||
- [ ] Enhanced version tested
|
||||
- [ ] Results documented
|
||||
`;
|
||||
|
||||
fs.writeFileSync(path.join(outputDir, 'README.md'), readmeContent);
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Download failed:', error.message);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Parse command line arguments
|
||||
const args = process.argv.slice(2);
|
||||
if (args.length < 2) {
|
||||
console.log('Usage: node download-site.js <url> <output-directory>');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
const [url, outputDir] = args;
|
||||
downloadSite(url, outputDir);
|
||||
43
demos/scripts/test-demo.js
Executable file
43
demos/scripts/test-demo.js
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env node
|
||||
/**
|
||||
* Test script to verify demo sites are working correctly
|
||||
*/
|
||||
|
||||
import { execSync } from 'child_process';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
console.log('🧪 Testing Insertr Demo Infrastructure');
|
||||
console.log('=====================================\n');
|
||||
|
||||
// Test 1: Check if enhanced sites exist
|
||||
console.log('📁 Checking enhanced test sites...');
|
||||
|
||||
const danEdenPath = './demos/simple/dan-eden-portfolio-enhanced';
|
||||
if (fs.existsSync(danEdenPath)) {
|
||||
console.log('✅ Dan Eden enhanced site exists');
|
||||
|
||||
// Check if it has insertr elements
|
||||
const indexPath = path.join(danEdenPath, 'index.html');
|
||||
if (fs.existsSync(indexPath)) {
|
||||
const content = fs.readFileSync(indexPath, 'utf8');
|
||||
const insertrElements = content.match(/data-content-id="[^"]+"/g);
|
||||
if (insertrElements && insertrElements.length > 0) {
|
||||
console.log(`✅ Found ${insertrElements.length} insertr-enhanced elements`);
|
||||
} else {
|
||||
console.log('❌ No insertr elements found in enhanced site');
|
||||
}
|
||||
} else {
|
||||
console.log('❌ index.html not found in enhanced site');
|
||||
}
|
||||
} else {
|
||||
console.log('❌ Dan Eden enhanced site not found');
|
||||
console.log(' Run: just enhance-demos');
|
||||
}
|
||||
|
||||
console.log('\n🎯 Demo Commands Available:');
|
||||
console.log(' just demo - Default demo');
|
||||
console.log(' just demo dan-eden - Dan Eden portfolio demo');
|
||||
console.log(' just list-demos - List all available demos');
|
||||
|
||||
console.log('\n🚀 Testing complete!');
|
||||
Reference in New Issue
Block a user