diff --git a/site b/site deleted file mode 160000 index f98dac50..00000000 --- a/site +++ /dev/null @@ -1 +0,0 @@ -Subproject commit f98dac50da2456cb43cead86f999817cd8e93fbe diff --git a/site/.gitignore b/site/.gitignore new file mode 100644 index 00000000..e0b45ff3 --- /dev/null +++ b/site/.gitignore @@ -0,0 +1,14 @@ +# Build output +dist/ + +# Dependencies +node_modules/ +package-lock.json + +# Logs +*.log +npm-debug.log* + +# OS files +.DS_Store +Thumbs.db diff --git a/site/README.md b/site/README.md new file mode 100644 index 00000000..b01c798a --- /dev/null +++ b/site/README.md @@ -0,0 +1,63 @@ +# System Prompts Site Generator + +This directory contains a static site generator for the System Prompts repository. + +## Quick Start + +```bash +# Build the site +npm run build + +# Preview locally +npm run preview + +# Development mode (build + preview) +npm run dev +``` + +## Features + +- šŸ” Scans the repository for `.txt`, `.json`, and `.md` files +- šŸ“„ Generates individual pages for each file with syntax highlighting +- šŸ“Š Creates an organized index page with statistics +- šŸŽØ GitHub-inspired dark theme +- šŸ“± Responsive design + +## Project Structure + +``` +site/ +ā”œā”€ā”€ package.json # Project dependencies and scripts +ā”œā”€ā”€ build.js # Static site generator +ā”œā”€ā”€ .gitignore # Git ignore rules +ā”œā”€ā”€ README.md # This file +└── dist/ # Generated site (created on build) + ā”œā”€ā”€ index.html # Main index page + └── files/ # Individual file pages +``` + +## How It Works + +1. **Scanning**: The build script recursively scans the parent directory for relevant files +2. **Processing**: Each file is processed and converted to an HTML page +3. **Generation**: An index page is created with the directory structure +4. **Output**: All files are written to the `dist/` directory + +## Configuration + +The build script can be customized by editing `build.js`: + +- **EXCLUDED_DIRS**: Directories to skip during scanning +- **INCLUDED_EXTENSIONS**: File extensions to include +- **Styling**: Modify the embedded CSS in the HTML generation functions + +## Deployment + +The generated `dist/` directory can be deployed to: + +- GitHub Pages +- Vercel +- Netlify +- Any static hosting service + +See the main [INSTALL.md](../INSTALL.md) for detailed deployment instructions. diff --git a/site/build.js b/site/build.js new file mode 100644 index 00000000..85667cd1 --- /dev/null +++ b/site/build.js @@ -0,0 +1,468 @@ +const fs = require('fs'); +const path = require('path'); + +// Configuration +const ROOT_DIR = path.join(__dirname, '..'); +const DIST_DIR = path.join(__dirname, 'dist'); +const FILES_DIR = path.join(DIST_DIR, 'files'); + +// Directories to exclude from scanning +const EXCLUDED_DIRS = ['.git', 'node_modules', 'site', 'assets']; + +// File extensions to include +const INCLUDED_EXTENSIONS = ['.txt', '.json', '.md']; + +// Utility function to escape HTML +function escapeHtml(text) { + const map = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''' + }; + return text.replace(/[&<>"']/g, m => map[m]); +} + +// Generate HTML for individual file pages +function generateFileHTML(filePath, content, fileInfo) { + const relativePath = path.relative(ROOT_DIR, filePath); + const extension = path.extname(filePath); + const language = extension === '.json' ? 'json' : extension === '.md' ? 'markdown' : 'text'; + + return ` + + + + + ${escapeHtml(relativePath)} - System Prompts + + + +
+
+

${escapeHtml(path.basename(filePath))}

+ +
+ +
+
Path: ${escapeHtml(relativePath)}
+
Size: ${fileInfo.size} bytes
+
Lines: ${content.split('\\n').length}
+
+ +
${escapeHtml(content)}
+ + ← Back to Index +
+ +`; +} + +// Generate HTML for index page +function generateIndexHTML(fileTree, stats) { + return ` + + + + + System Prompts and Models of AI Tools + + + +
+
+

šŸ“œ System Prompts and Models of AI Tools

+

A comprehensive collection of system prompts and configurations

+
+ +
+
+ ${stats.totalFiles} + Total Files +
+
+ ${stats.totalDirectories} + Directories +
+
+ ${Math.round(stats.totalSize / 1024)}KB + Total Size +
+
+ +
+ ${generateFileTreeHTML(fileTree)} +
+ + +
+ +`; +} + +// Generate HTML for file tree +function generateFileTreeHTML(tree) { + let html = ''; + + const sortedDirs = Object.keys(tree).sort(); + + for (const dir of sortedDirs) { + const files = tree[dir]; + if (files.length === 0) continue; + + html += `
+
šŸ“ ${escapeHtml(dir)}
+
`; + } + + return html; +} + +// Scan directory recursively +function scanDirectory(dir, baseDir = dir, fileTree = {}, stats = { totalFiles: 0, totalDirectories: 0, totalSize: 0 }) { + const items = fs.readdirSync(dir); + + for (const item of items) { + const fullPath = path.join(dir, item); + const relativePath = path.relative(baseDir, fullPath); + + // Skip excluded directories + if (EXCLUDED_DIRS.some(excluded => relativePath.startsWith(excluded))) { + continue; + } + + const stat = fs.statSync(fullPath); + + if (stat.isDirectory()) { + stats.totalDirectories++; + scanDirectory(fullPath, baseDir, fileTree, stats); + } else if (stat.isFile()) { + const ext = path.extname(fullPath); + + if (INCLUDED_EXTENSIONS.includes(ext)) { + const dirName = path.dirname(relativePath); + const displayDir = dirName === '.' ? 'Root' : dirName; + + if (!fileTree[displayDir]) { + fileTree[displayDir] = []; + } + + stats.totalFiles++; + stats.totalSize += stat.size; + + fileTree[displayDir].push({ + name: path.basename(fullPath), + path: fullPath, + relativePath: relativePath, + id: Buffer.from(relativePath).toString('base64').replace(/[^a-zA-Z0-9]/g, '_'), + size: stat.size + }); + } + } + } + + return { fileTree, stats }; +} + +// Main build function +function build() { + console.log('šŸš€ Starting build process...\n'); + + // Clean and create dist directories + if (fs.existsSync(DIST_DIR)) { + fs.rmSync(DIST_DIR, { recursive: true }); + } + fs.mkdirSync(DIST_DIR, { recursive: true }); + fs.mkdirSync(FILES_DIR, { recursive: true }); + + console.log('šŸ“‚ Scanning repository...'); + const { fileTree, stats } = scanDirectory(ROOT_DIR); + + console.log(`\nšŸ“Š Statistics:`); + console.log(` - Total files: ${stats.totalFiles}`); + console.log(` - Total directories: ${stats.totalDirectories}`); + console.log(` - Total size: ${Math.round(stats.totalSize / 1024)}KB\n`); + + // Generate individual file pages + console.log('šŸ“ Generating file pages...'); + let generatedPages = 0; + + for (const dir in fileTree) { + for (const file of fileTree[dir]) { + try { + const content = fs.readFileSync(file.path, 'utf-8'); + const html = generateFileHTML(file.path, content, { size: file.size }); + const outputPath = path.join(FILES_DIR, `${file.id}.html`); + fs.writeFileSync(outputPath, html); + generatedPages++; + } catch (error) { + console.error(` āš ļø Error processing ${file.relativePath}: ${error.message}`); + } + } + } + + console.log(` āœ“ Generated ${generatedPages} file pages`); + + // Generate index page + console.log('\nšŸ“„ Generating index page...'); + const indexHTML = generateIndexHTML(fileTree, stats); + fs.writeFileSync(path.join(DIST_DIR, 'index.html'), indexHTML); + console.log(' āœ“ Index page generated'); + + console.log('\n✨ Build completed successfully!'); + console.log(`\nšŸ“ Output directory: ${DIST_DIR}`); + console.log('🌐 Run "npm run preview" to view the site locally\n'); +} + +// Run build +try { + build(); +} catch (error) { + console.error('āŒ Build failed:', error); + process.exit(1); +} diff --git a/site/package.json b/site/package.json new file mode 100644 index 00000000..f5aa6eb1 --- /dev/null +++ b/site/package.json @@ -0,0 +1,19 @@ +{ + "name": "system-prompts-site", + "version": "1.0.0", + "description": "Static site generator for System Prompts repository", + "main": "build.js", + "scripts": { + "build": "node build.js", + "preview": "python3 -m http.server 8000 --directory dist 2>/dev/null || python -m http.server 8000 --directory dist", + "dev": "node build.js && npm run preview" + }, + "keywords": [ + "static-site", + "generator", + "documentation" + ], + "author": "", + "license": "ISC", + "dependencies": {} +}