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
|
e711ff25fe
|
Refactor family invitations and memberships into separate models and controllers
|
2025-10-07 18:38:06 +02:00 |
|
Eugene Burmakin
|
018760812a
|
Extract family functionality to a concern
|
2025-10-05 14:24:45 +02:00 |
|
Eugene Burmakin
|
5ab382936d
|
Merge branch 'dev', remote-tracking branch 'origin' into feature/tracks-on-ruby
|
2025-08-29 10:57:08 +02:00 |
|
Eugene Burmakin
|
74112c0d04
|
Calculate trip's visited countries from points
|
2025-08-02 00:06:09 +02:00 |
|
Eugene Burmakin
|
599af37109
|
Implement language-sided tracks generation
|
2025-07-28 22:30:36 +02:00 |
|
Eugene Burmakin
|
9c7084a10b
|
Fix request to a user in partial
|
2025-07-26 12:37:46 +02:00 |
|
Eugene Burmakin
|
9fb251fa4a
|
Sanitize input in distanceable
|
2025-07-23 20:52:02 +02:00 |
|
Eugene Burmakin
|
7920209187
|
Return tailwind.css
|
2025-07-23 20:35:42 +02:00 |
|
Eugene Burmakin
|
2e46069fcc
|
Clean up code a bit
|
2025-07-23 20:08:24 +02:00 |
|
Eugene Burmakin
|
d8033a1e27
|
Update track generation
|
2025-07-23 18:21:21 +02:00 |
|
Eugene Burmakin
|
f969d5d3e6
|
Clean up some mess
|
2025-07-20 18:57:53 +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
|
a66f41d9fb
|
Add documentation
|
2025-07-07 23:12:02 +02:00 |
|
Eugene Burmakin
|
f33dcdfe21
|
Store track distance in user's preferred unit
|
2025-07-07 22:23:37 +02:00 |
|
Eugene Burmakin
|
15be46b604
|
Fix tests
|
2025-07-04 20:55:05 +02:00 |
|
Eugene Burmakin
|
1468f1f9dc
|
Remove tracks api endpoint
|
2025-07-04 20:09:06 +02:00 |
|
Eugene Burmakin
|
565f92c463
|
Add tracks to map
|
2025-07-04 19:49:56 +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
|
41604d71a6
|
Add brakeman and some tests
|
2025-04-04 22:16:52 +02:00 |
|
Eugene Burmakin
|
99bb982792
|
Merge from dev
|
2025-04-04 20:14:44 +02:00 |
|
Eugene Burmakin
|
4a859fb350
|
Add bunch of tests and refactor some stuff
|
2025-03-09 14:58:30 +01:00 |
|
Eugene Burmakin
|
adf923542d
|
Move visits to different panes
|
2025-03-06 00:13:47 +01:00 |
|
Eugene Burmakin
|
70d754b397
|
Fix some tests
|
2025-03-03 22:39:43 +01:00 |
|
Eugene Burmakin
|
217d6249e2
|
Use lonlat in maps controller
|
2025-02-23 22:59:14 +01:00 |
|
Eugene Burmakin
|
4fa3c35fb8
|
Calculate distance using PostGIS ST_Distance with LAG
|
2025-02-22 00:02:13 +01:00 |
|
Eugene Burmakin
|
d9eac91834
|
Introduce latlon to Points and use it instead of latitude and longitude.
|
2025-02-21 23:45:36 +01:00 |
|
Eugene Burmakin
|
0722e2d991
|
Initial Rails 7.0.2.3 template w/ rspec, tailwind, and devise user
|
2022-04-06 22:46:10 +04:00 |
|