This document provides a comprehensive guide to the implementation of the enhanced Scrapyard feature for 2133.lol. The Scrapyard has been transformed into a user-driven repository for art, PNGs, and web development assets with advanced features including categorization, tagging, ratings, and improved search.
File: db/enhance_scrapyard.js
This script enhances the existing database schema with:
- New
asset_tagstable for the tagging system - New
asset_ratingstable for user ratings - Updates to the
scrapyard_assetstable including:ratingfield for average ratingrating_countfield for number of ratingscategory_idfield to properly reference categories
- Performance indices for optimized queries
File: config/s3.js
This module provides S3 integration for asset storage:
- Configurable S3 client setup
- Presigned URL generation for direct uploads
- Unique filename generation with sanitization
- Fallback to local storage when S3 isn't configured
- Public URL and key management
File: routes/enhanced_scrapyard.js
This file implements all required API endpoints:
- Asset browsing with filtering, search, and sorting
- Direct S3 uploads with presigned URLs
- Local file storage fallback
- Rating system implementation
- Tag management endpoints
- Enhanced asset viewing with associated metadata
- Comment and favorite functionality
Files:
views/forum/view-asset.html: Enhanced asset detail pageviews/forum/upload-asset.html: Advanced upload interfacepublic/css/scrapyard.css: Styling for all Scrapyard features
The UI implements the cyberpunk/retro terminal aesthetic while providing:
- Rating interface with star selection
- Tag browsing and selection
- Category filtering
- Search functionality
- Drag and drop file uploads
- Asset previews
- Activity logs
File: app_scrapyard.js
This file demonstrates how to integrate the enhanced Scrapyard into the main application.
The database schema has been implemented as specified in the architecture document:
scrapyard_assets
- id INTEGER PRIMARY KEY AUTOINCREMENT
- user_id INTEGER NOT NULL REFERENCES users(id)
- title TEXT NOT NULL
- description TEXT NOT NULL
- file_path TEXT NOT NULL
- thumbnail_path TEXT
- asset_type TEXT
- category_id INTEGER REFERENCES asset_categories(id)
- tags TEXT
- download_count INTEGER DEFAULT 0
- likes_count INTEGER DEFAULT 0
- is_free INTEGER DEFAULT 1
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
- updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
- rating REAL DEFAULT 0.0
- rating_count INTEGER DEFAULT 0
asset_categories
- id INTEGER PRIMARY KEY AUTOINCREMENT
- name TEXT NOT NULL UNIQUE
- display_name TEXT NOT NULL
- description TEXT
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
asset_tags
- id INTEGER PRIMARY KEY AUTOINCREMENT
- name TEXT NOT NULL UNIQUE
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
asset_ratings
- id INTEGER PRIMARY KEY AUTOINCREMENT
- asset_id INTEGER NOT NULL REFERENCES scrapyard_assets(id)
- user_id INTEGER NOT NULL REFERENCES users(id)
- rating INTEGER NOT NULL
- created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
- UNIQUE(asset_id, user_id)
The following API endpoints have been implemented:
GET /scrapyard: List all assets with filtering optionsGET /scrapyard/asset/:id: View a specific assetPOST /scrapyard/upload: Upload a new asset (local storage)POST /scrapyard/upload-s3: Upload a new asset (S3 storage)POST /scrapyard/get-upload-url: Generate presigned S3 URLPOST /scrapyard/asset/:id/comment: Add a commentPOST /scrapyard/asset/:id/favorite: Toggle favorite statusPOST /scrapyard/asset/:id/rate: Rate an assetGET /scrapyard/categories: List all categoriesGET /scrapyard/category/:categoryId: Filter by categoryGET /scrapyard/tag/:tagId: Filter by tagGET /scrapyard/api/tags: Get tags (for autocomplete)POST /scrapyard/api/tags: Create a new tag
The implementation provides two file storage options:
-
S3 Cloud Storage (Preferred):
- Direct browser-to-S3 uploads via presigned URLs
- Separate asset and thumbnail uploads
- File URLs stored in the database
- Configurable endpoints for different S3-compatible services
-
Local Storage (Fallback):
- Traditional multipart form uploads
- Files stored in
public/uploads/assets - Relative paths stored in the database
Search is implemented through:
- Filtering by category or tag
- Text search across titles and descriptions
- Sort options (newest, rating, downloads, popularity)
- Combined filters for advanced queries
The search is implemented as database queries using the SQL LIKE operator for text searches and direct ID matching for categories and tags.
The UI/UX flow follows the cyberpunk terminal aesthetic with:
-
Asset Browsing:
- Grid layout for assets
- Filter controls
- Search bar
- Sort options
- Tag cloud
- Category listing
-
Asset Details:
- Asset display with preview
- Metadata display
- Rating interface
- Download options
- Tagging information
- Comments section
- Favorite button
-
Asset Upload:
- Form with validation
- Category selection
- Tag input with autocomplete
- File drag & drop
- Preview generation
- Upload status feedback
-
Run the database enhancement script:
node db/enhance_scrapyard.js -
Configure S3 credentials in
.env:AWS_REGION=us-east-1 AWS_ACCESS_KEY_ID=your_access_key AWS_SECRET_ACCESS_KEY=your_secret_key AWS_BUCKET_NAME=your_bucket_name -
Update app.js to include the enhanced Scrapyard routes:
const enhancedScrapyardRoutes = require('./routes/enhanced_scrapyard'); app.use('/scrapyard', enhancedScrapyardRoutes);
-
Start the application:
node app.js
-
Direct S3 Uploads:
- Bypasses server for file transfers
- Reduces server load and bandwidth costs
- Handles large files efficiently
-
Fallback Storage:
- Ensures app works without S3 configuration
- Simplifies development and testing
-
Tag Autocompletion:
- Improves organization consistency
- Enhances discoverability
-
Optimized Database Queries:
- Indices on frequently accessed columns
- Selective column loading
- Efficient filtering mechanism
-
Modular CSS Design:
- Separates scrapyard-specific styles
- Maintains consistent terminal aesthetic
- Responsive design for all screen sizes
-
Full-Text Search:
- Implement SQLite FTS extension for advanced searching
- Add support for tag and description searching
-
Asset Collections:
- Allow users to create and share collections of assets
- Add following/subscribing to junkers
-
Version Control:
- Add support for multiple versions of the same asset
- Track changes and updates
-
Analytics Dashboard:
- Provide junkers with download stats
- Show popularity trends
-
Bulk Operations:
- Support bulk uploads and downloads
- Batch categorization and tagging