Commit Graph

9 Commits

Author SHA1 Message Date
kilyabin
56a48b4552 fix: database location
Founded a major mistake: db overwrites during install.  Now all scripts save db in special folder and don't overwrite it.
2025-12-04 23:44:21 +04:00
kilyabin
e46a2419c3 refactor: optimize project structure, migrate to SQLite, and add new features
fix:
  - Fix TypeScript type errors in api-wrapper.ts (ApiResponse type)
  - Fix backward compatibility in database.ts getSettings() for missing fields
  - Fix default value for weekNavigationEnabled (changed from true to false)
  - Fix API routes error handling with unified wrapper
  - Fix duplicate toggle switch code in admin.tsx (6 instances)
  - Fix inconsistent authentication check in API routes (unified with withAuth)
  - Fix error message text in loading-context.tsx (improved user experience)

add:
  - Add database.ts: SQLite database layer with better-sqlite3 for persistent storage
    * Groups management (CRUD operations)
    * Settings management with caching
    * Admin password hashing with bcrypt
    * Automatic database initialization and migration
  - Add api-wrapper.ts utility for unified API route handling
    * withAuth wrapper for protected routes
    * withMethods wrapper for public routes
    * Consistent error handling and method validation
  - Add validation.ts utility with centralized validation functions
    * validateCourse - course validation (1-5)
    * validateGroupId - group ID format validation
    * validatePassword - password strength validation
  - Add showAddGroupButton setting to control visibility of 'Add Group' button on homepage
  - Add toggle switch component in admin.tsx for reusable UI (replaces 6 duplicate instances)
  - Add CourseSelect component in admin.tsx for reusable course selection
  - Add DialogFooterButtons component in admin.tsx for reusable dialog footer
  - Add unified loadData function in admin.tsx to reduce code duplication
  - Add change-password.ts API endpoint for admin password management
  - Add logs.ts API endpoint for viewing error logs in admin panel
  - Add logErrorToFile function in logger.ts for persistent error logging
  - Add comprehensive error logging in schedule.ts (parsing, fetch, timeout, network errors)
  - Add comprehensive project structure documentation in README.md
  - Add architecture and code organization section in README.md
  - Add database information section in README.md
  - Add SQLite and bcrypt to tech stack documentation
  - Add better-sqlite3 and bcrypt dependencies to package.json
  - Add .gitignore rules for error.log and database files (data/, *.db, *.db-shm, *.db-wal)

refactor:
  - Refactor admin.tsx: extract reusable components (toggle, select, dialog footer)
  - Refactor API routes to use withAuth wrapper for consistent authentication
  - Refactor API routes to use validation utilities instead of inline validation
  - Refactor groups.ts and groups.json: move to old/data/ directory (deprecated, now using SQLite)
  - Refactor settings-loader.ts: migrate from JSON to SQLite database
  - Refactor groups-loader.ts: migrate from JSON to SQLite database
  - Refactor database.ts: improve backward compatibility for settings migration
  - Refactor admin.tsx: unify data loading functions (loadGroupsList, loadSettingsList)
  - Refactor index.tsx: add showAddGroupButton prop and conditional rendering
  - Refactor API routes: consistent error handling and method validation
  - Refactor README.md: update tech stack, project structure, and admin panel documentation
  - Refactor auth.ts: improve session management and cookie handling
  - Refactor schedule.ts: improve error handling with detailed logging and error types
  - Refactor logger.ts: add file-based error logging functionality
  - Refactor loading-context.tsx: improve error message clarity

remove:
  - Remove hello.ts test API endpoint
  - Remove groups.ts and groups.json (moved to old/data/, replaced by SQLite)

update:
  - Update .gitignore to exclude old data files, database files, and error logs
  - Update package.json: add better-sqlite3, bcrypt and their type definitions
  - Update README.md with new features, architecture, and database information
  - Update all API routes to use new wrapper system
  - Update admin panel with new settings and improved UI
  - Update sitemap.xml with cache usage comment
2025-12-03 21:44:07 +04:00
kilyabin
16bba463eb feat: добавлено предупреждение о fallback кэше и debug опции
Основные изменения:

- Предупреждение о неактуальности расписания:
  * Добавлен баннер предупреждения при использовании fallback кэша
  * Добавлено toast уведомление о возможной неактуальности данных
  * Баннер показывает возраст кэша в удобочитаемом формате
  * Автоскролл с учетом рендеринга баннера

- Debug опции в админ-панели:
  * Добавлена секция с аккордеоном для debug опций (только в dev режиме)
  * Опции: принудительное использование кэша, пустое расписание, ошибка, таймаут, информация о кэше
  * Все опции с тумблерами для удобного управления
  * API endpoint обновлен для поддержки debug настроек

- Структурные изменения:
  * Создан компонент Accordion для shadcn/ui
  * Расширены типы AppSettings для поддержки debug опций
  * Компонент баннера размещен внутри Schedule компонента (следуя правилам проекта)
  * Добавлен файл .cursorrules с правилами для AI ассистента

- Исправления:
  * Исправлена сериализация undefined значений в getServerSideProps
  * Улучшена логика автоскролла при использовании fallback кэша
  * Убраны лишние отступы у баннера предупреждения

- Зависимости:
  * Добавлен @radix-ui/react-accordion для компонента аккордеона

- Прочие изменения:
  * Обновлены настройки в settings.json
  * Изменения в старых файлах (old/README.md, old/old-schedule.txt)
  * Обновления в API endpoints админ-панели
2025-12-02 01:05:36 +04:00
kilyabin
24bb531dfb feat(ui): improve lesson cards and theme button, optimize dependency checks
UI Improvements:
- Highlight classroom number in lesson cards using Badge component
  * Applied to both mobile and desktop views
  * Improved visual distinction for classroom information

- Fix theme switcher button layout on mobile
  * Add "Тема" text label inside the button (visible on all devices)
  * Remove redundant absolute positioned span below button
  * Fix text overflow issues on mobile devices
  * Improve button isolation to prevent text escaping

Performance Optimization:
- Optimize dependency installation check in deployment scripts
  * Replace timestamp-based check with content hash comparison
  * Use MD5 hash of package.json and lock files to detect real changes
  * Save hash after successful installation for future comparisons
  * Significantly reduce unnecessary npm install runs during updates
  * Add .dependencies.hash to .gitignore

Files changed:
- src/widgets/schedule/lesson.tsx - Added Badge for classroom
- src/features/theme-switch/index.tsx - Added text label to button
- src/widgets/navbar/index.tsx - Improved button container structure
- src/pages/index.tsx - Removed redundant theme label span
- scripts/manage.sh - Optimized dependency check logic
- scripts/install.sh - Optimized dependency check logic
- .gitignore - Added .dependencies.hash exclusion
2025-11-26 01:09:46 +04:00
kilyabin
e5262f8203 feat: добавлена админ-панель и главная страница с навигацией по курсам
Основные изменения:

Админ-панель:
- Создана защищенная паролем админ-панель по пути /admin
- Реализована система авторизации с сессионными куками
- Добавлен CRUD для управления группами (создание, редактирование, удаление)
- Добавлено поле "курс" (1-5) для каждой группы с возможностью редактирования

Структура данных:
- Миграция групп из TypeScript файла в JSON формат (groups.json)
- Обновлена структура данных: добавлено поле course
- Реализована автоматическая миграция старых данных в новый формат
- Создан groups-loader для работы с JSON файлом

Главная страница:
- Создана главная страница с аккордеоном по курсам (1-5)
- Группы сгруппированы по курсам для удобной навигации
- Добавлены кнопки: "Добавить группу", переключение темы и GitHub
- Убрана верхняя навигация с главной страницы

Навигация:
- Добавлена кнопка "К группам" в начало навигации на страницах расписания
- На мобильных устройствах скрыты кнопки групп, оставлена только кнопка возврата
- Улучшена адаптивность навигации

Технические улучшения:
- Исправлена проблема с tailwind-scrollbar-hide (заменен плагин на CSS класс)
- Обновлены все компоненты для работы с новой структурой данных групп
- Добавлена поддержка переменных окружения ADMIN_PASSWORD и ADMIN_SESSION_SECRET
2025-11-23 00:58:58 +04:00
VityaSchel
9ae56a82a8 Fix sitemap.xml dynamic generation 2023-10-12 18:45:24 +04:00
VityaSchel
813fa218e9 It seems that next-sitemap is unable to produce sitemaps for dynamic paths, so we're switching back to dynamic server-side sitemap generation 2023-10-12 18:35:39 +04:00
VityaSchel
a4667f57c7 Added parser 2023-10-01 21:28:53 +04:00
VityaSchel
0bb5f022e9 Initial commit 2023-10-01 18:53:04 +04:00