courseworx/backend/utils/folderNaming.js
mmabdalla 5477297914 v2.0.2 - Complete Plugin Architecture System and Multi-Currency Implementation
Major Features Added:
- Complete Plugin Architecture System with financial plugin
- Multi-currency support with exchange rates
- Course type system (online, classroom, hybrid)
- Attendance tracking and QR code scanning
- Classroom sessions management
- Course sections and content management
- Professional video player with authentication
- Secure media serving system
- Shopping cart and checkout system
- Financial dashboard and earnings tracking
- Trainee progress tracking
- User notes and assignments system

Backend Infrastructure:
- Plugin loader and registry system
- Multi-currency database models
- Secure media middleware
- Course access middleware
- Financial plugin with payment processing
- Database migrations for new features
- API endpoints for all new functionality

Frontend Components:
- Course management interface
- Content creation and editing
- Section management with drag-and-drop
- Professional video player
- QR scanner for attendance
- Shopping cart and checkout flow
- Financial dashboard
- Plugin management interface
- Trainee details and progress views

This represents a major evolution of CourseWorx from a basic LMS to a comprehensive educational platform with plugin architecture.
2025-09-14 04:20:37 +03:00

53 lines
1.7 KiB
JavaScript

const path = require('path');
/**
* Creates a safe directory name from a course title
* @param {string} title - The course title
* @param {string} language - The course language
* @returns {string} - Safe directory name
*/
const createSafeDirectoryName = (title, language = 'english') => {
if (!title || typeof title !== 'string') {
return 'course-' + Date.now();
}
let safeName;
if (language === 'arabic') {
// For Arabic courses, use first three words separated by hyphens
const words = title.trim().split(/\s+/).filter(word => word.length > 0);
safeName = words.slice(0, 3).join('-');
// Clean up any remaining special characters
safeName = safeName.replace(/[^\p{L}\p{N}\s-]/gu, '');
// If still empty, use fallback
if (!safeName || safeName.trim() === '') {
safeName = 'arabic-course-' + Date.now();
}
} else {
// For other languages, use the first 3 words approach
const words = title.trim().split(/\s+/).filter(word => word.length > 0);
safeName = words.slice(0, 3).join('-');
// Clean up special characters
safeName = safeName
.replace(/[^\p{L}\p{N}\s-]/gu, '') // Keep letters (including non-Latin), numbers, spaces, and hyphens
.replace(/\s+/g, '-') // Replace spaces with hyphens
.replace(/-+/g, '-') // Replace multiple hyphens with single hyphen
.replace(/^-+|-+$/g, '') // Remove leading/trailing hyphens
.substring(0, 100); // Limit length to prevent path issues
// If the result is empty, use a fallback
if (!safeName || safeName.trim() === '') {
safeName = 'course-' + Date.now();
}
}
return safeName;
};
module.exports = {
createSafeDirectoryName
};