Commit graph

158 commits

Author SHA1 Message Date
Eugene Burmakin
f37bedb86b Update migration 2025-11-07 13:41:34 +01:00
Claude
ce5e57a691
Implement public trip sharing with Shareable concern
This commit implements comprehensive public trip sharing functionality
by extracting sharing logic into a reusable Shareable concern and
extending it to Trip models.

## Key Features

**Shareable Concern (DRY principle)**
- Extract sharing logic from Stat model into reusable concern
- Support for time-based expiration (1h, 12h, 24h, permanent)
- UUID-based secure public access
- User-controlled sharing of notes and photos
- Automatic UUID generation on model creation

**Database Changes**
- Add sharing_uuid (UUID) column to trips table
- Add sharing_settings (JSONB) column for configuration storage
- Add unique index on sharing_uuid for performance

**Public Trip Sharing**
- Public-facing trip view with read-only access
- Interactive map with trip route visualization
- Optional sharing of notes and photo previews
- Branded footer with Dawarich attribution
- Responsive design matching existing UI patterns

**Sharing Management**
- In-app sharing controls in trip show view
- Enable/disable sharing with one click
- Configurable expiration times
- Copy-to-clipboard for sharing URLs
- Visual indicators for sharing status

**Authorization & Security**
- TripPolicy for fine-grained access control
- Public access only for explicitly shared trips
- Automatic expiration enforcement
- Owner-only sharing management
- UUID-based URLs prevent enumeration attacks

**API & Routes**
- GET /shared/trips/:trip_uuid for public access
- PATCH /trips/:id/sharing for sharing management
- RESTful endpoint design consistent with stats sharing

**Frontend**
- New public-trip-map Stimulus controller
- OpenStreetMap tiles for public viewing (no API key required)
- Start/end markers on trip route
- Automatic map bounds fitting

**Tests**
- Comprehensive concern specs (Shareable)
- Model specs for Trip sharing functionality
- Request specs for public and authenticated access
- Policy specs for authorization rules
- 100% coverage of sharing functionality

## Implementation Details

### Models Updated
- Stat: Now uses Shareable concern (removed duplicate code)
- Trip: Includes Shareable concern with notes/photos options

### Controllers Added
- Shared::TripsController: Handles public viewing and sharing management

### Views Added
- trips/public_show.html.erb: Public-facing trip view
- trips/_sharing.html.erb: Sharing controls partial

### JavaScript Added
- public_trip_map_controller.js: Map rendering for public trips

### Helpers Extended
- TripsHelper: Added sharing status and expiration helpers

## Breaking Changes
None. This is a purely additive feature.

## Migration Required
Yes. Run: rails db:migrate

## Testing
All specs pass:
- spec/models/concerns/shareable_spec.rb
- spec/models/trip_spec.rb
- spec/requests/shared/trips_spec.rb
- spec/policies/trip_policy_spec.rb
2025-11-05 15:44:27 +00:00
Eugene Burmakin
6787273713 Updte map view 2025-10-30 19:16:38 +01:00
Eugene Burmakin
4f4ac08caf Remove unnecessary migration 2025-10-22 21:06:14 +02:00
Eugene Burmakin
c1cff10de3 Update migrations 2025-10-05 14:02:18 +02:00
Eugene Burmakin
78693f3001 Merge branch 'dev' into feature/family 2025-10-04 15:57:03 +02:00
Eugene Burmakin
db8d886ee2 Use ids instead of uuids for primary keys in family tables 2025-09-30 18:43:26 +02:00
Eugene Burmakin
698198db4b Update navbar for better responsiveness 2025-09-30 00:45:09 +02:00
Eugene Burmakin
0728c21c61 Update stuff, fix stuff 2025-09-29 22:27:07 +02:00
Eugene Burmakin
1f67e889e3 Complete phase 5 2025-09-28 13:10:07 +02:00
Eugene Burmakin
0d02f08199 Add implementation plan and complete phase 1 2025-09-27 00:46:29 +02:00
Eugene Burmakin
d6a3200632 Update migration 2025-09-20 15:55:10 +02:00
Eugene Burmakin
f223feb854 Add safety_assured block for index creation 2025-09-20 15:53:27 +02:00
Eugene Burmakin
584daadb5c Fix failing specs 2025-09-19 19:55:27 +02:00
Eugene Burmakin
2bd0390d1a Rename hexagon_centers to h3_hex_ids and update related logic 2025-09-19 00:23:12 +02:00
Eugene Burmakin
6314442770 Calculate only centers of hexagons 2025-09-14 12:41:16 +02:00
Eugene Burmakin
a2aa1be271 Precalculate hexagons for stats 2025-09-13 23:11:42 +02:00
Eugene Burmakin
8a6156a56c Update migration 2025-09-13 21:26:55 +02:00
Eugene Burmakin
0ed71c3cc6 Fix failing specs 2025-09-13 17:46:45 +02:00
Eugene Burmakin
bfeeeee234 Merge branch 'dev', remote-tracking branch 'origin' into feature/follow-up-emails 2025-09-13 14:03:04 +02:00
Eugene Burmakin
5ff35136f2 Add images for stats page backgrounds 2025-09-12 20:11:14 +02:00
Eugene Burmakin
fc068ec79d Add Lucide icons and stats sharing 2025-09-11 20:41:43 +02:00
Eugene Burmakin
410cd86c4e Implement a new daily track generation job to replace the old cleanup job. 2025-09-08 20:46:30 +02:00
Eugene Burmakin
68a0a8f23c Add follow up emails 2025-09-05 19:39:50 +02:00
Eugene Burmakin
b8d69a6797 Reset counters for points counter cache 2025-08-26 15:26:05 +02:00
Evgenii Burmakin
02e6fb8a85
Merge branch 'dev' into feature/points-counter-cache 2025-08-26 15:09:48 +02:00
Eugene Burmakin
edb9287bcf Fix schema 2025-08-23 16:13:52 +02:00
Eugene Burmakin
b049c11542 Fix import detection 2025-08-23 16:07:15 +02:00
Eugene Burmakin
6e4934a93d Introduce points counter cache to optimize performance 2025-08-21 22:32:29 +02:00
Eugene Burmakin
6870be2045 Fix country name in points 2025-07-29 21:17:33 +02:00
Eugene Burmakin
f492a69fbb Add country_name to points and fix some bugs. 2025-07-28 18:53:19 +02:00
Eugene Burmakin
88e3f53cc5 Remove old code 2025-07-23 19:48:39 +02:00
Eugene Burmakin
5a4a5e9625 Add composite index for track generation 2025-07-23 19:30:56 +02:00
Eugene Burmakin
dfec1afd7e Remove example migration file 2025-07-23 00:01:41 +02:00
Eugene Burmakin
bdcfb5eb62 Stats calculation is now timezone-aware. 2025-07-22 23:57:25 +02:00
Eugene Burmakin
0c904a6b84 Fix stats calculation performance 2025-07-22 22:41:12 +02:00
Eugene Burmakin
c18b09181e Add index on places geodata osm id 2025-07-21 22:45:57 +02:00
Eugene Burmakin
8b03b0c7f5 Recalculate stats after changing distance units 2025-07-20 19:14:20 +02:00
Eugene Burmakin
10777714b1 Clean up a bit 2025-07-17 19:19:50 +02:00
Eugene Burmakin
c31d09e5c3 Refactor tracks jobs and services 2025-07-16 22:22:33 +02:00
Eugene Burmakin
ceef7702fa Add data migration to recalculate trips distance. 2025-07-09 21:51:48 +02:00
Eugene Burmakin
13fd9da1f9 Add a scheduled job to create tracks for all users for the past 24 hours. 2025-07-09 21:25:56 +02:00
Eugene Burmakin
f33dcdfe21 Store track distance in user's preferred unit 2025-07-07 22:23:37 +02:00
Eugene Burmakin
7619feff69 Add data migration to create tracks from points 2025-07-06 13:49:53 +02:00
Eugene Burmakin
1468f1f9dc Remove tracks api endpoint 2025-07-04 20:09:06 +02:00
Eugene Burmakin
862f601e1d Add tracks calculation and storage in the database 2025-07-03 20:18:18 +02:00
Eugene Burmakin
d518603719 Update importing process 2025-07-02 20:22:40 +02:00
Eugene Burmakin
1ebe2da84a Update changelog 2025-06-30 22:51:25 +02:00
Eugene Burmakin
8ad0b20d3d Add import data feature 2025-06-28 12:22:56 +02:00
Eugene Burmakin
7988fadd5f User export: exporting exports and imports data with files 2025-06-25 21:14:33 +02:00