Commit graph

55 commits

Author SHA1 Message Date
Deco Vander
6be1dc4667 Update server.js
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-04 14:03:07 -04:00
Deco Vander
4dd48627d0 mplement proper async initialization for ProfanityFilter
- Add async initialize() method for reliable initialization waiting
- Add static create() factory method for easy async creation
- Add initialization state tracking with isInitialized flag
- Add warning system for methods called before full initialization
- Update server.js to use proper async initialization pattern
- Maintain backward compatibility with constructor-only usage
- Add accessibility improvement for reduced motion preferences in CSS

Fixes the race condition issue where consumers relied on arbitrary
timeouts instead of properly waiting for async initialization to complete.
2025-07-04 13:59:57 -04:00
Deco Vander
542415cccd Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-04 13:30:45 -04:00
Deco Vander
b1073ce7b8 Fix critical security risk: implement complete fallback profanity filter
- Add comprehensive no-op fallback profanity filter with all required methods
- Prevent runtime errors when profanity filter initialization fails
- Add startup logging to clearly indicate profanity filter status
- Include _isFallback property for monitoring and debugging
- Ensure all routes continue to function even with fallback filter
- Maintain security awareness with clear warning messages
2025-07-04 13:25:25 -04:00
Deco Vander
a063d5a2c9 Create shared utility module to eliminate function duplication
- Create public/utils.js with shared frontend utility functions
- Extract parseUTCDate, getTimeAgo, getTimeRemaining, getRemainingClass to utils.js
- Remove duplicate functions from admin.js, app-mapbox.js, app-google.js, and app.js
- Add utils.js script import to index.html and admin.html
- Add comprehensive JSDoc documentation for all utility functions
- Ensure consistent UTC timestamp parsing across all frontend scripts

This addresses Copilot AI feedback about function duplication across multiple frontend scripts.
Now all timestamp and time calculation logic is centralized in one maintainable module.

Benefits:
- Single source of truth for time-related utilities
- Easier maintenance and updates
- Consistent behavior across all frontend components
- Better code organization and documentation
- Reduced bundle size through deduplication
2025-07-04 13:22:17 -04:00
Deco Vander
c0dc1f3c6d Fix critical error handling for ProfanityFilter initialization
- Add proper error handling to prevent undefined profanityFilter from being passed to routes
- Implement fallback no-op profanity filter strategy when initialization fails
- Add validation check before setupRoutes() to ensure profanityFilter is defined
- Provide clear error messages and security warnings when fallback is used
- Update graceful shutdown to safely handle both real and fallback profanity filters

Fallback profanity filter:
- Allows all content to pass through (security risk but prevents crash)
- Provides proper method signatures for API compatibility
- Logs prominent security warnings about disabled filtering
- Returns appropriate error messages for admin operations

This prevents runtime errors while maintaining service availability, with clear warnings about the security implications.
2025-07-04 13:16:33 -04:00
Deco Vander
45a8d67362 Refactor: Extract UTC parsing logic to parseUTCDate helper function
- Add parseUTCDate helper function to handle timestamp UTC parsing consistently
- Eliminates code duplication across getTimeAgo, getTimeRemaining, and expiry functions
- Applied to admin.js, app-mapbox.js, app-google.js, and app.js
- Ensures consistent UTC timezone handling throughout all frontend JavaScript
- Addresses Copilot AI feedback for better code maintainability and DRY principles

The parseUTCDate function handles the logic:
timestamp.includes('T') ? timestamp : timestamp + 'Z'

This ensures all timestamp parsing uses the same UTC interpretation logic.
2025-07-04 13:16:33 -04:00
Deco Vander
544766e5dc Apply suggestions from code review
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-07-04 13:13:52 -04:00
Deco Vander
58b6a13106 Fix timezone handling for accurate 48-hour expiry display
- Fixed getTimeAgo(), getTimeRemaining(), and getRemainingClass() functions
- Database stores UTC timestamps but frontend was treating them as local time
- Added logic to append 'Z' to timestamps without timezone info to force UTC interpretation
- Now properly shows 48-hour countdown instead of incorrect 52-hour or 28-hour values
- Affects both main app (app-mapbox.js) and admin panel (admin.js)
2025-07-04 11:16:18 -04:00
Deco Vander
276dc65195 Fix location expiry display to show correct 48-hour timeframe
- Updated getTimeRemaining() function to use 48 hours instead of 24 hours
- Updated getRemainingClass() function to calculate remaining time based on 48 hours
- Frontend now matches backend 48-hour expiration policy
- Time remaining display will now show up to ~47h instead of ~23h for new reports
2025-07-04 11:12:09 -04:00
Deco Vander
e32dfd849f Fix profanity filter admin UI API endpoints
- Corrected API endpoint URLs from /api/admin/profanity/words to /api/admin/profanity-words
- Fixed profanity test endpoint from /api/admin/profanity/test to /api/admin/test-profanity
- Updated data handling to match actual API response format
- Fixed profanity test results display to match API analysis structure
- All CRUD operations for profanity words now working correctly
2025-07-04 11:09:28 -04:00
Deco Vander
b8e1bc9aa8 Merge branch 'main' into feature/profanity-filter-isolation 2025-07-04 11:03:03 -04:00
Deco Vander
71ddcc9a5c Complete profanity filter UI integration
- Added tab-based admin interface with separate Profanity Filter tab
- Implemented custom word management (add/delete words with severity levels)
- Added profanity filter testing interface for real-time validation
- Integrated with profanity database API endpoints
- Added comprehensive CSS styling for new UI components
- Full admin interface for managing custom profanity words and categories
2025-07-04 00:07:03 -04:00
Deco Vander
c7f39e4939 feat: isolate profanity filter with separate database
- Create dedicated ProfanityFilter class with isolated SQLite database
- Separate profanity.db from main application database to prevent SQLITE_MISUSE errors
- Add comprehensive custom word management (CRUD operations)
- Implement advanced profanity detection with leetspeak and pattern matching
- Add admin UI for managing custom profanity words
- Add extensive test suites for both profanity filter and API routes
- Update server.js to use isolated profanity filter
- Add proper database initialization and cleanup methods
- Support in-memory databases for testing

Breaking changes:
- Profanity filter now uses separate database file
- Updated admin API endpoints for profanity management
- Enhanced profanity detection capabilities
2025-07-04 00:03:24 -04:00
Deco Vander
49be81e29b Merge pull request #4 from derekslenk/update-readme-urls-20250704-025536
Update deployment URLs in README
2025-07-03 22:56:18 -04:00
GitHub Action
41d658ddc1 Update deployment URLs
- Updated S3 URLs in README.md
    - Deploy script URL: https://ice-puremichigan-lol.s3.amazonaws.com/scripts/deploy.sh
2025-07-04 02:55:36 +00:00
Deco Vander
e44d363685 Merge pull request #3 from derekslenk/auto-readme
Update deploy scripts to create a PR
2025-07-03 22:55:22 -04:00
Deco Vander
d7afbe15f0 Merge branch 'main' into auto-readme 2025-07-03 22:54:38 -04:00
Deco Vander
d766f08338 Update deploy scripts to create a PR 2025-07-03 22:53:53 -04:00
Deco Vander
cf86727acd Merge pull request #2 from derekslenk/actions-contents-update
Update deploy-scripts.yml
2025-07-03 22:46:46 -04:00
Deco Vander
d6df2f9237 Update deploy-scripts.yml 2025-07-03 22:46:10 -04:00
Deco Vander
fd6d5853ff Merge pull request #1 from derekslenk/derekslenk-patch-1
more ice
2025-07-03 22:43:53 -04:00
Deco Vander
af535c9f5d more ice 2025-07-03 22:39:59 -04:00
Deco Vander
d19cd2766c Fix dark mode table visibility and security improvements
- Add dark mode overrides for table cell text colors to ensure visibility
- Remove Google Maps API key exposure from /api/config endpoint (security fix)
- Update privacy policy to clarify international server hosting
- Switch from CDN resources to local files for better control
- Add SCSS build system for future styling improvements
2025-07-03 22:21:59 -04:00
Deco Vander
8d5ac00bc8 Remove unused Sass/SCSS setup
- Remove sass and concurrently dependencies (31 packages)
- Remove SCSS files and src/styles directory
- Remove Sass-related npm scripts (build-css, watch-css, dev-with-css)
- Remove CSS source map file
- Keep hand-crafted style.css which is actually being used
2025-07-03 21:56:26 -04:00
Deco Vander
7daced0cea Fix reports table text color with explicit th,td selector
Applied the exact same selector pattern as admin table:
- .reports-table th, .reports-table td { color: var(--text-color); }

This ensures both header and data cells explicitly inherit the correct
text color variable, matching the admin table behavior exactly.

Should resolve the white text visibility issue in dark mode.
2025-07-03 21:12:11 -04:00
Deco Vander
83173da778 Apply admin table styling to reports table for consistency
Updated reports table to use the same robust styling as admin table:

 Added:
- border-radius: 8px and overflow: hidden for rounded corners
- box-shadow: 0 2px 4px var(--shadow) for elevation
- color: var(--text-color) on table element for inheritance
- Consistent border styling with 1px borders
- font-weight: bold for headers (matching admin)

 Improved:
- Better dark mode support with proper color inheritance
- Consistent visual appearance between admin and public tables
- Removed duplicate box-shadow from table-container
- Simplified header borders (removed 2px, sticky positioning complexity)

Both tables now share the same visual design language and dark mode behavior.
2025-07-03 21:09:12 -04:00
Deco Vander
ebb5c06773 Fix reports table text color in dark mode
The admin table was working correctly because it explicitly sets 'color: var(--text-color)'
on all table cells, but the main reports table (Table View on homepage) was missing this.

Added 'color: var(--text-color)' to '.reports-table td' to ensure all table cells
use the proper text color in both light and dark modes.

This fixes the gray-on-gray readability issue in the details table view.
2025-07-03 21:06:33 -04:00
Deco Vander
f276c5e270 Improve dark mode text contrast by using dedicated color variables
Problem: Text with opacity created gray-on-gray which was hard to read in dark mode.

Solution: Added dedicated color variables for text hierarchy:
- --text-color: Primary text (bright)
- --text-secondary: Secondary text (medium brightness)
- --text-tertiary: Tertiary text (dimmer but still readable)

Dark mode colors:
- Primary: #e0e0e0 (bright white-ish)
- Secondary: #b0b0b0 (medium gray)
- Tertiary: #909090 (dimmer gray)

Light mode colors:
- Primary: #333 (dark)
- Secondary: #666 (medium gray)
- Tertiary: #999 (light gray)

This provides much better contrast and readability in dark mode while maintaining the visual hierarchy.
2025-07-03 21:02:47 -04:00
Deco Vander
4bcbb9134d Fix dark mode text readability in table view and other elements
- Updated table cell colors to use CSS variables instead of hardcoded values
- Fixed location-cell, details-cell, time-cell text colors for dark mode
- Improved contrast with opacity adjustments for secondary text
- Updated status colors (urgent/warning/normal) to work better in dark mode
- Fixed autocomplete, input-help, disclaimer, and table-info text colors
- All text now properly adapts to both light and dark themes
2025-07-03 20:59:10 -04:00
Deco Vander
fd3cbe686d Fix persistent locations not showing on homepage
The public /api/locations endpoint was only returning locations within 48 hours,
but it should also include persistent locations regardless of their age.

Updated SQL query to: 'WHERE created_at > ? OR persistent = 1'

This ensures that:
- Regular reports show for 48 hours (as intended)
- Persistent reports show indefinitely (as intended)
- Both types appear on the public map and homepage
2025-07-03 20:56:27 -04:00
Deco Vander
570fd92d00 Add comprehensive session security to admin panel
Security improvements:
- Auto-logout after 30 minutes of inactivity
- Session warning 5 minutes before expiry with option to extend
- Activity-based session extension on user interaction
- Session validation on page load and API calls
- Periodic session validity checks every minute
- Secure cleanup of tokens and timers on logout
- Protection against expired session usage

This prevents unauthorized access if admin leaves session open or if tokens are compromised.
2025-07-03 20:53:44 -04:00
Deco Vander
d9559f71fe Update HTML files to use Bunny.net CDN for static assets
- Updated all static asset URLs to use iceymi.b-cdn.net CDN
- Changed favicon, CSS, and JS file references in index.html, admin.html, and privacy.html
- API calls remain pointed to origin server for dynamic content
- Ready for CDN deployment with proper cache separation
2025-07-03 20:44:16 -04:00
Deco Vander
f73221e5cc Add custom map icons for persistent vs. temporary reports
- Created custom map markers with distinct colors and symbols:
  - 🔒 Green circles with lock icon for persistent reports
  - ⚠️ Red circles with warning icon for temporary reports
- Updated popup text to indicate persistent status
- Applied consistent styling to both MapBox and Nominatim versions
- Enhanced visual distinction between report types on the map
2025-07-03 01:34:39 -04:00
Deco Vander
a8a5523dd4 Show 'Persistent' in table view for persistent reports
- Updated getTimeRemaining() to return 'Persistent' for persistent reports
- Modified getRemainingClass() to handle persistent report styling
- Table view now clearly indicates which reports are persistent vs. expiring
- Maintains color coding for non-persistent reports based on time remaining
2025-07-03 01:32:28 -04:00
Deco Vander
12fd378e8c Fix CSP to allow Leaflet marker icons from unpkg.com
- Updated Content-Security-Policy img-src directive to include unpkg.com
- Resolves CSP violation preventing Leaflet marker icons from loading
- Maintains security while allowing necessary external image resources
2025-07-03 01:24:51 -04:00
Deco Vander
a3b450de1a Add mobile responsiveness and persistent reports feature
- Enhanced mobile responsiveness across entire site and admin panel
  - Optimized layouts, font sizes, and spacing for screens ≤768px and ≤480px
  - Made forms, tables, maps, and buttons touch-friendly
  - Added responsive breakpoints for better mobile experience

- Added persistent reports functionality
  - Added 'persistent' column to database with automatic migration
  - Updated cleanup logic to preserve persistent reports (no auto-expiration)
  - Added admin panel toggle for marking reports as persistent
  - Added persistent report count to admin dashboard stats
  - Visual indicators with lock/unlock icons for persistent status

- Improved admin panel UI
  - Standardized header button styling and sizing
  - Added 'Return to Homepage' button for better navigation
  - Enhanced mobile responsiveness for admin interface
  - Fixed table layouts and button arrangements for mobile devices

- Backend API enhancements
  - New PATCH endpoint for toggling persistent status
  - Updated admin routes to include persistent field
  - Backwards compatible database migration
2025-07-03 01:17:41 -04:00
Deco Vander
5e56d59bbd Add map/table toggle view for current reports
 New Features:
- Toggle between map and table view for current reports
- Table view shows location, details, reported time, and time remaining
- Color-coded time remaining: urgent (red), warning (orange), normal (green)
- Responsive design with mobile-optimized table layout
- Real-time updates work in both map and table views
- Sorted by most recent reports first

🎨 UI Improvements:
- Professional toggle buttons with active state
- Clean table design with hover effects
- Accessibility-friendly with proper titles and tooltips
- Mobile-responsive layout adjustments

🚀 Better UX:
- Easy switching between visual map and detailed table
- Time remaining countdown helps prioritize urgent reports
- Searchable and scannable table format for quick review
- Maintains all existing functionality while adding new view
2025-07-03 01:07:17 -04:00
Deco Vander
3581ea219d Fix rate limiting block syntax for caddy-ratelimit plugin
- Use proper rate_limit block syntax with key, rate, and window
- Rate 30 requests per minute for general API
- Rate 5 requests per minute for location submissions
- Should resolve 'wrong argument count' error
2025-07-03 01:00:07 -04:00
Deco Vander
118261a0bd Fix duplicate @submit matcher in Caddyfile
- Combined @submit matcher conditions into single block
- Fixed 'matcher is defined more than once' error
- Proper Caddyfile syntax for combining path and method matchers
2025-07-03 00:58:30 -04:00
Deco Vander
18fb9e5a73 Fix rate limiting syntax in Caddyfile
- Simplified rate limiting syntax to use 30r/m and 5r/m format
- Fixed matcher syntax for submission rate limiting
- Should resolve 'wrong argument count' error in Caddy
- Compatible with caddy-ratelimit plugin syntax
2025-07-03 00:56:26 -04:00
Deco Vander
c95d159a95 Install Caddy with rate limiting plugin for ARM64 deployment
- Install Go 1.21.5 for ARM64 architecture
- Use xcaddy to build Caddy with caddy-ratelimit plugin
- Create custom systemd service for plugin-enabled Caddy
- Restore rate limiting configuration in Caddyfile
- Production-ready setup with proper security and rate limiting
- Automatic SSL with enhanced protection against API abuse
2025-07-03 00:44:29 -04:00
Deco Vander
3d3eb2fd3b Enhance Caddyfile with explicit HTTPS and security features
- Added explicit HTTP to HTTPS redirects for clarity
- Improved security headers including CSP for MapBox/OSM
- Added health checks for reverse proxy
- Implemented rate limiting for API protection
- Added structured logging for security monitoring
- Enhanced compression with gzip and zstd
- Comprehensive www/non-www redirect handling
- Production-ready configuration for ICE Watch
2025-07-03 00:31:41 -04:00
Deco Vander
c203cdcbeb Update clone URLs to use SSH and correct repository name
- Changed all git clone URLs to use SSH (git@github.com:)
- Fixed repository name to derekslenk/ice (correct repo name)
- Updated both deployment script and README
- Provides better security for server deployments
2025-07-03 00:24:01 -04:00
Deco Vander
0af3b7eeea Update service user and group for icewatch service 2025-07-03 00:19:40 -04:00
Deco Vander
e35eb6c788 Update deployment instructions and service user/group 2025-07-03 00:14:42 -04:00
Deco Vander
2cda43edc9 Fix S3 upload: remove ACL parameters for bucket without ACL support
- Removed --acl public-read parameters from GitHub Action
- S3 bucket policy handles public access instead of ACLs
- Should resolve AccessControlListNotSupported error
2025-07-03 00:11:08 -04:00
Deco Vander
5b9c9f7396 Fix S3 bucket name and create deployment bucket
- Created S3 bucket: ice-puremichigan-lol
- Updated all references to use correct bucket name
- Applied public access policy for scripts/* path
- Ready for automated deployment via GitHub Actions
2025-07-03 00:02:52 -04:00
Deco Vander
e58e89ac72 Update S3 paths to use scripts folder with proper permissions
- Changed deployment URLs from /icewatch to /scripts
- Added cache control headers for better performance
- Updated bucket policy for scripts/* public access
- All deployment files now use consistent scripts/ path
2025-07-03 00:00:02 -04:00
Deco Vander
38ccd6d533 Update deployment URLs to use ice.puremichigan.lol S3 bucket
- Updated deployment script S3 URLs
- Updated README with correct bucket name
- Ready for automated S3 deployment via GitHub Actions
2025-07-02 23:57:27 -04:00