Security: - Add authentication to /api/documents/archived endpoint (admin-only) - Prevent public exposure of 108 archived/internal documents Documentation UI: - Remove duplicate hardcoded Resources section from docs.html - Add Resources category to docs-app.js for implementation guides - Move 3 implementation guides from Getting Started to Resources - Move Glossary from Technical Reference to Getting Started - Set Research & Theory section to collapsed by default - Update service worker cache version to 0.1.4 Migration Scripts: - Add scripts for document category reorganization - Add scripts for research document migration to production - Add scripts for glossary verification and comparison Files changed: - public/docs.html: Remove duplicate Resources section - public/js/docs-app.js: Add Resources category, collapse Research - public/service-worker.js: Bump cache to v0.1.4 - src/routes/documents.routes.js: Secure /archived endpoint - scripts/*: Add 10 migration/diagnostic scripts 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
92 lines
3.1 KiB
JavaScript
92 lines
3.1 KiB
JavaScript
/**
|
|
* Unarchive and publish the best Glossary document
|
|
*/
|
|
const { MongoClient } = require('mongodb');
|
|
require('dotenv').config({ path: '/var/www/tractatus/.env' });
|
|
|
|
async function run() {
|
|
const MONGODB_URI = process.env.MONGODB_URI || 'mongodb://localhost:27017';
|
|
const DB_NAME = process.env.MONGODB_DB || 'tractatus_prod';
|
|
|
|
const client = new MongoClient(MONGODB_URI);
|
|
await client.connect();
|
|
|
|
console.log('═══════════════════════════════════════════════════════════');
|
|
console.log(' UNARCHIVING GLOSSARY');
|
|
console.log('═══════════════════════════════════════════════════════════\n');
|
|
|
|
const db = client.db(DB_NAME);
|
|
const collection = db.collection('documents');
|
|
|
|
// Find all glossary documents
|
|
const glossaries = await collection.find({
|
|
slug: { $regex: 'glossary', $options: 'i' }
|
|
}).toArray();
|
|
|
|
console.log(`Found ${glossaries.length} glossary document(s)\n`);
|
|
|
|
// Pick the one with most sections
|
|
let best = null;
|
|
let bestSections = 0;
|
|
|
|
glossaries.forEach((doc, idx) => {
|
|
const sections = doc.sections?.length || 0;
|
|
console.log(`${idx + 1}. ${doc.slug}`);
|
|
console.log(` Title: ${doc.title}`);
|
|
console.log(` Sections: ${sections}`);
|
|
console.log(` Visibility: ${doc.visibility}`);
|
|
console.log(` Category: ${doc.category || 'none'}`);
|
|
console.log('');
|
|
|
|
if (sections > bestSections) {
|
|
best = doc;
|
|
bestSections = sections;
|
|
}
|
|
});
|
|
|
|
if (!best) {
|
|
console.log('❌ No glossary documents found');
|
|
await client.close();
|
|
return;
|
|
}
|
|
|
|
console.log(`✅ Best version: ${best.slug} (${bestSections} sections)\n`);
|
|
|
|
// Unarchive it
|
|
if (best.visibility !== 'public') {
|
|
console.log('📝 Updating to public...\n');
|
|
|
|
const result = await collection.updateOne(
|
|
{ _id: best._id },
|
|
{
|
|
$set: {
|
|
visibility: 'public',
|
|
category: 'technical-reference',
|
|
order: 100, // Place at end of technical reference
|
|
updated_at: new Date()
|
|
}
|
|
}
|
|
);
|
|
|
|
console.log(`✅ Updated: ${result.modifiedCount} document(s)`);
|
|
|
|
// Verify
|
|
const updated = await collection.findOne(
|
|
{ _id: best._id },
|
|
{ projection: { slug: 1, title: 1, visibility: 1, category: 1, order: 1 } }
|
|
);
|
|
|
|
console.log('\n🔍 Verification:');
|
|
console.log(JSON.stringify(updated, null, 2));
|
|
} else {
|
|
console.log('✅ Already public - no update needed');
|
|
}
|
|
|
|
await client.close();
|
|
|
|
console.log('\n═══════════════════════════════════════════════════════════');
|
|
console.log(' COMPLETE');
|
|
console.log('═══════════════════════════════════════════════════════════\n');
|
|
}
|
|
|
|
run().catch(console.error);
|