Commit graph

71 commits

Author SHA1 Message Date
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
cd303bce01 Clean up some code 2025-10-04 23:19:00 +02:00
Eugene Burmakin
54661a1d52 Update some tests and svg icons 2025-10-04 22:52:08 +02:00
Eugene Burmakin
9bc0e2accc Use family path instead of families/id 2025-10-04 22:39:47 +02:00
Eugene Burmakin
1f67e889e3 Complete phase 5 2025-09-28 13:10:07 +02:00
Eugene Burmakin
54a2a29c18 Fix quietest_week to correctly calculate the quietest week in a month 2025-09-22 22:40:00 +02:00
Eugene Burmakin
5b3fe84933 Update onborading popup 2025-09-18 18:29:46 +02:00
Eugene Burmakin
1394d6202c Fix potential sql injection 2025-09-13 17:04:48 +02:00
Eugene Burmakin
dcd1c7ab2b Add some refactorings 2025-09-13 16:41:28 +02:00
Eugene Burmakin
774860220e Add missing email templates for post-trial reminders 2025-09-13 15:37:09 +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
1426fa53df Add header gradient based on month 2025-09-11 22:22:08 +02:00
Eugene Burmakin
d3bbd08890 Make year page more colorful and add month page 2025-09-11 22:12:44 +02:00
Eugene Burmakin
e8c5b3dfdc Update stats page 2025-09-11 21:41:52 +02:00
Eugene Burmakin
acd3b20ef5 Add stats month page 2025-09-11 00:19:34 +02:00
Eugene Burmakin
68a0a8f23c Add follow up emails 2025-09-05 19:39:50 +02:00
Eugene Burmakin
ed5e4d1664 Update qr code 2025-08-30 21:32:25 +02:00
Eugene Burmakin
6e4934a93d Introduce points counter cache to optimize performance 2025-08-21 22:32:29 +02:00
Eugene Burmakin
71488c9fb1 Add trial mode 2025-08-13 20:25:48 +02:00
Eugene Burmakin
f4687a101c Remove unused helper methods 2025-07-08 20:51:51 +02:00
Eugene Burmakin
f1720b859b Store distance in meters in the database and convert to user's preferred unit on the fly. 2025-07-08 18:10:10 +02:00
Eugene Burmakin
34c82e82a5 Update trips page and dockerfiles 2025-05-19 19:00:34 +02:00
Eugene Burmakin
ce0c38e6e8 Remove comments 2025-05-18 11:19:01 +02:00
Eugene Burmakin
168e33dedd Use iso_a2 from the countries table 2025-05-18 11:17:25 +02:00
Eugene Burmakin
605ceee820 Add modal to show countries and cities visited in a year 2025-05-18 00:15:25 +02:00
Eugene Burmakin
06aee05602 Move distance unit settings to user settings 2025-05-17 20:35:38 +02:00
Eugene Burmakin
72927379b7 Show datetime with seconds in the Points page. 2025-05-02 20:43:53 +02:00
Eugene Burmakin
85d04eb75c Show subscription expiration date nicely 2025-04-04 22:31:15 +02:00
Eugene Burmakin
4fcfdc7bd7 Update timestamps 2025-04-04 20:15:05 +02:00
Eugene Burmakin
8997d10658 Fix speed units on the Points page 2025-02-11 21:38:41 +01:00
Eugene Burmakin
b364f33db1 Remove event handler 2024-12-11 16:23:34 +01:00
Eugene Burmakin
9713bd7afd Fix deleting points on the map 2024-12-11 16:18:40 +01:00
Eugene Burmakin
b1c48076e4 Add some minor changes 2024-12-11 14:21:44 +01:00
Eugene Burmakin
d6b88ae9cb Move photos fetching for trips to a separate service 2024-12-10 19:31:52 +01:00
Eugene Burmakin
b336172b31 Show photoprism photos on a trip page 2024-12-10 18:49:37 +01:00
Eugene Burmakin
5c09e5b0f9 Move trip to partial 2024-11-28 16:11:04 +01:00
Eugene Burmakin
b712332277 Update link to Immich search on the trip page 2024-11-28 10:51:11 +01:00
Eugene Burmakin
9522f81abf Move fetchAndDisplayPhotos to maps/helpers.js 2024-11-27 21:37:21 +01:00
Eugene Burmakin
198bf3128a Add trips model and scaffold controller 2024-11-27 20:14:17 +01:00
Eugene Burmakin
79bf74add4 Move APP_VERSION to a constant 2024-11-24 14:56:20 +01:00
Eugene Burmakin
d3f6d0da7b Rework the app version checking to be performed in the background and update docker compose file to use different directories for gems cache 2024-10-29 11:53:44 +01:00
Guillaume Boudreau
644b7f489d Bugfix: when calculating the timestamp (for months and years), ignore the Timezone
Fixes GH-194
2024-09-22 07:32:33 -04:00
Eugene Burmakin
d5cbae620e Update immich data importing service 2024-09-08 16:52:35 +02:00
Eugene Burmakin
5d14b406bd Add DISTANCE_UNIT environment variable 2024-08-28 23:54:00 +02:00
Eugene Burmakin
7d7005063b Add places page 2024-08-25 20:19:02 +02:00
Eugene Burmakin
87258df41e Fix route popup distance and add areas swagger test 2024-07-27 12:22:56 +02:00
Eugene Burmakin
f080b4c6ce Add tests for background jobs stuff 2024-07-12 21:59:03 +02:00
Eugene Burmakin
b648c18f9d Scaffold background jobs settings 2024-07-09 20:28:59 +02:00
Eugene Burmakin
b7f648dc07 Add titles 2024-06-12 21:10:53 +02:00