Skip to content

biomassives/video-library-manager-vanilla

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

APPROVIDEO Technical Documentation

System Architecture

APPROVIDEO is a modern web application built with the following technology stack:

  • Vanilla JavaScript for core functionality
  • Tailwind CSS for styling
  • LocalForage for client-side data persistence
  • Supabase as the backend database and video storage solution

Core Components

1. Frontend Architecture

  • UI Framework: Vanilla JavaScript with Tailwind CSS
    • Custom components built without framework dependencies
    • Responsive design using Tailwind utility classes
    • Gradient-based theming for visual consistency

2. Data Management

  • Client-side Storage:

    • LocalForage implementation for offline-capable data access
    • Caching strategy for frequently accessed video metadata
    • State management for category and tag filtering
  • Backend Integration:

    • Supabase real-time database connection
    • Video metadata synchronization
    • Category and tag relationship management

Key Features

Category Navigation System

  • Header-based navigation with icon categories
  • Dynamic content loading based on category selection
  • Fallback views for empty category states
  • Subcategory filtering capability

Video Panel System

  • Metadata display panels for video information
  • Tag integration within panels
  • Expandable/collapsible panel design
  • Efficient loading patterns for video lists

Tag System

  • Hierarchical tag structure
  • Category-tag relationships
  • Tag-based filtering and search
  • Click-through navigation via tags

Data Flow

  1. Initial Load:

    Supabase -> LocalForage Cache -> UI Display
    
  2. Category Navigation:

    User Click -> Category Filter -> LocalForage Query -> UI Update
    
  3. Video Loading:

    Panel Selection -> Video Metadata Fetch -> Player Initialization
    

Implementation Guidelines

Category Implementation

// Example category loading implementation
async function loadCategory(categoryId) {
  try {
    // Check local cache first
    const cachedData = await localforage.getItem(`category_${categoryId}`);
    if (cachedData) {
      return renderVideoList(cachedData);
    }
    
    // Fetch from Supabase if not in cache
    const { data, error } = await supabase
      .from('videos')
      .select('*')
      .eq('category', categoryId);
      
    if (error) throw error;
    
    // Cache the results
    await localforage.setItem(`category_${categoryId}`, data);
    return renderVideoList(data);
  } catch (error) {
    handleEmptyState(categoryId);
  }
}

Empty State Handling

function handleEmptyState(categoryId) {
  const container = document.querySelector('.video-container');
  container.innerHTML = `
    <div class="empty-state">
      <p>No videos available in this category</p>
      <button onclick="showRecommended()">
        View Recommended Videos
      </button>
    </div>
  `;
}

Performance Considerations

  1. Caching Strategy:

    • Implement aggressive caching for video metadata
    • Use LocalForage for offline-first capability
    • Regular cache invalidation for fresh content
  2. Loading Optimization:

    • Lazy loading for video panels
    • Progressive loading for category views
    • Preloading for anticipated user actions
  3. Resource Management:

    • Efficient video player initialization
    • Memory management for video instances
    • Cleanup routines for unused resources

Future Enhancements

  1. Planned Features:

    • Enhanced tag navigation system
    • Advanced filtering capabilities
    • Improved category failover handling
    • User preference persistence
  2. Technical Debt:

    • Refactor category loading for better performance
    • Implement comprehensive error handling
    • Optimize LocalForage usage patterns

Maintenance Guidelines

  1. Regular Tasks:

    • Cache cleanup routines
    • Database synchronization checks
    • Performance monitoring
    • Error logging and analysis
  2. Update Procedures:

    • Document version control
    • Database schema migrations
    • Client-side cache invalidation
    • Feature flag management

PublicVideoPortal Class Methods

Core Methods

  • constructor() - Initialize properties and start app
  • init() - Setup initial state and load videos
  • setupEventListeners() - Attach event handlers

Loading and Display

  • loadVideos() - Fetch videos from Supabase
  • showSkeletonLoader() - Show loading placeholder
  • createSkeletonCard() - Create loading placeholder card
  • renderVideos(videos) - Display video grid
  • createVideoCard(video) - Create single video card
  • renderPanels(panels) - Render video panels section
  • renderTags(tags) - Render video tags
  • showError(message) - Display error message

UI Interaction

  • setupInfiniteScroll() - Handle infinite scrolling
  • handleCategoryClick(button) - Handle category selection
  • resetAndReload() - Reset view and reload videos
  • getCategoryIcon(category) - Get icon for category

External Functions (Outside Class)

Event Handlers

  • filterAndSortVideos() - Filter and sort video list
  • renderCategories(videos) - Render category sections
  • handleVideoDetailClick(e) - Handle video detail view
  • closeVideoDetail() - Close video detail view
  • handleCategoryClick(e) - Handle category selection

UI Utility Functions

  • getRandomColor() - Get random color for UI elements
  • getRandomSize() - Get random size for UI elements
  • updateURLAndFilter(category, tag) - Update URL parameters and filter
  • clearSearchAndFilter(category, tag) - Clear search and filter state

DOM Ready Handlers

document.addEventListener('DOMContentLoaded', () => {
  // Initialize PublicVideoPortal
  new PublicVideoPortal();
  
  // Setup category navigation
  const mainCategories = document.querySelectorAll('.group > a');
  const mondrianBox = document.getElementById('mondrian-box');
  const subcategoryLinks = document.getElementById('subcategory-links');
  // ... setup event listeners
});

Required Utility Functions/Objects

Safety/Sanitization

  • safeHtml.escape(str) - Escape HTML special characters
  • safeHtml.escapeObject(obj) - Escape object properties

Database

  • Supabase client configuration and setup

Event Listeners to Implement

  1. Search input changes
  2. Category button clicks
  3. Sort select changes
  4. Infinite scroll detection
  5. Profile dropdown toggle
  6. Dark mode toggle
  7. Subcategory selection
  8. Video detail view
  9. URL parameter handling

Notes

  • Each function should handle one specific task
  • Event listeners should be properly cleaned up when needed
  • Error handling should be consistent throughout
  • DOM queries should be cached when possible
  • Performance considerations for infinite scroll
  • Proper sanitization of user input and database data

This structure follows these design patterns:

  1. Single Responsibility Principle
  2. Event Delegation
  3. Progressive Enhancement
  4. Responsive Loading
  5. Error Boundary Pattern

SAFEUTILS

-________________

The provided SafeHtmlUtils class is a well-written utility for safely handling HTML content and preventing XSS attacks. Here's a breakdown and some potential areas for improvement:

Breakdown:

Constructor: Creates a map of HTML entity equivalents for efficient escaping.
escape(str): Escapes special characters in a string using a regular expression and the character map. Handles potential null/undefined inputs and errors.
escapeObject(obj): Recursively escapes string properties within an object. Catches errors and returns the original object if an error occurs.
createElement(tag, attributes, content): Creates a safe HTML element with escaped content, attributes, and optional content (which can be a string or an array of strings). Handles errors.
createLink(url, text, attributes): Creates a safe anchor tag with escaped URL, text content, and additional attributes. Adds rel="noopener noreferrer" for security.
sanitizeClasses(classes): Validates and sanitizes a CSS class string by removing any non-alphanumeric characters, underscores, hyphens, and spaces. Handles errors.TILS

-________________

The provided SafeHtmlUtils class is a well-written utility for safely handling HTML content and preventing XSS attacks. Here's a breakdown and some potential areas for improvement:

Breakdown:

Constructor: Creates a map of HTML entity equivalents for efficient escaping.
escape(str): Escapes special characters in a string using a regular expression and the character map. Handles potential null/undefined inputs and errors.
escapeObject(obj): Recursively escapes string properties within an object. Catches errors and returns the original object if an error occurs.
createElement(tag, attributes, content): Creates a safe HTML element with escaped content, attributes, and optional content (which can be a string or an array of strings). Handles errors.
createLink(url, text, attributes): Creates a safe anchor tag with escaped URL, text content, and additional attributes. Adds rel="noopener noreferrer" for security.
sanitizeClasses(classes): Validates and sanitizes a CSS class string by removing any non-alphanumeric characters, underscores, hyphens, and spaces. Handles errors.

About

supabase tailwind vanilla js for sortable tagged categorized youtube (for now) videos

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published