Claude
b1cbb5555f
Refactor: Apply Rails best practices to trip sharing implementation
...
- Remove unused @is_public_view variable from controller
- Simplify conditionals by leveraging methods that return [] when empty
- Move public view from trips/public_show to shared/trips/show (Rails conventions)
- Refactor trips#update to be HTML-only (remove JSON responses)
- Convert sharing form to use proper Rails form helpers
- Move JS controller to shared/ subdirectory with proper namespacing
- Create RSpec shared examples for Shareable concern to eliminate duplication
- Update request specs to match HTML-only controller behavior
- Apply 'render/redirect ... and return' pattern for early returns
2025-11-07 12:05:34 +00: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
Evgenii Burmakin
99281317d7
Merge branch 'dev' into feature/family
2025-10-13 12:30:27 +02:00
Eugene Burmakin
ab4786d7b9
Fix minor bugs in Stat model related to sharing settings
2025-10-07 21:24:38 +02:00
Eugene Burmakin
e711ff25fe
Refactor family invitations and memberships into separate models and controllers
2025-10-07 18:38:06 +02:00
Eugene Burmakin
e17f732706
Minor changes
2025-09-27 21:14:40 +02:00
Eugene Burmakin
0d02f08199
Add implementation plan and complete phase 1
2025-09-27 00:46:29 +02:00
Eugene Burmakin
4287fee93d
Fix tests after updating rubyzip
2025-09-26 23:31:45 +02:00
Eugene Burmakin
63aa197a29
Update error message
2025-09-23 21:16:25 +02:00
Eugene Burmakin
6a0cc112dc
Introduce limit for trial users: max 5 imports, 10MB per file
2025-09-23 21:14:55 +02:00
Eugene Burmakin
6e44425e4e
Recalculate stats when an import is deleted.
2025-09-22 20:30:10 +02:00
Eugene Burmakin
2fe36f02d6
Fix failing model spec
2025-09-19 22:12:34 +02:00
Eugene Burmakin
88e9c85766
Extract hexagon query to separate class
2025-09-12 21:38:25 +02:00
Eugene Burmakin
57ecda2b1b
Extract stats sharing logic to its own controller
2025-09-12 21:08:45 +02:00
Eugene Burmakin
34e71b5d17
Add specs for hexagon API and public sharing; remove debug logs
2025-09-12 20:44:53 +02:00
Eugene Burmakin
22daed7291
Move welcome emails placement
2025-08-26 16:37:21 +02:00
Eugene Burmakin
6e4934a93d
Introduce points counter cache to optimize performance
2025-08-21 22:32:29 +02:00
Eugene Burmakin
efc7ffa579
Extract visit creation to a service
2025-08-21 18:58:59 +02:00
Evgenii Burmakin
ead1673cc5
Merge branch 'dev' into feature/trial
2025-08-19 20:58:00 +02:00
Eugene Burmakin
b9764d39c3
Skip trial emails for active users
2025-08-19 18:55:22 +02:00
Eugene Burmakin
6708e11ab3
Add limits for import size for trial users
2025-08-14 20:50:22 +02:00
Eugene Burmakin
71488c9fb1
Add trial mode
2025-08-13 20:25:48 +02:00
Eugene Burmakin
74112c0d04
Calculate trip's visited countries from points
2025-08-02 00:06:09 +02:00
Eugene Burmakin
6870be2045
Fix country name in points
2025-07-29 21:17:33 +02:00
Eugene Burmakin
0bfddd932f
Disable specs for track generation
2025-07-22 20:28:46 +02:00
Eugene Burmakin
f969d5d3e6
Clean up some mess
2025-07-20 18:57:53 +02:00
Eugene Burmakin
c31d09e5c3
Refactor tracks jobs and services
2025-07-16 22:22:33 +02:00
Eugene Burmakin
9a326733c7
Return missing map buttons
2025-07-09 00:58:33 +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
f33dcdfe21
Store track distance in user's preferred unit
2025-07-07 22:23:37 +02:00
Eugene Burmakin
92a15c8ad3
Handle unfinished tracks
2025-07-07 18:59:42 +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
862f601e1d
Add tracks calculation and storage in the database
2025-07-03 20:18:18 +02:00
Eugene Burmakin
8ad0b20d3d
Add import data feature
2025-06-28 12:22:56 +02:00
Eugene Burmakin
8dd7ba8363
Fix specs
2025-06-26 20:05:26 +02:00
Eugene Burmakin
631ee0e64c
Clean up specs a bit
2025-06-26 19:48:42 +02:00
Eugene Burmakin
2088b769d7
Add tests
2025-06-26 19:24:40 +02:00
Eugene Burmakin
7988fadd5f
User export: exporting exports and imports data with files
2025-06-25 21:14:33 +02:00
Eugene Burmakin
c69d4f45f1
Update views and specs
2025-05-16 19:53:42 +02:00
Eugene Burmakin
5be5c1e584
Put countries into database
2025-05-16 18:51:48 +02:00
Eugene Burmakin
96108b12d0
Update tests a bit
2025-05-15 22:58:04 +02:00
Eugene Burmakin
79f2522f54
Fetch countries for a trip via geocoding service
2025-05-13 19:43:02 +02:00
Eugene Burmakin
ed7b6d6d24
Add a STORE_GEODATA environment variable to control whether to store geodata in the database.
2025-05-12 22:33:47 +02:00
Eugene Burmakin
37c95d966e
Remove sample points
2025-05-02 20:05:12 +02:00
Eugene Burmakin
e433ed4d1c
Use secure file downloader for imports
2025-04-23 23:27:55 +02:00
Eugene Burmakin
41604d71a6
Add brakeman and some tests
2025-04-04 22:16:52 +02:00
Eugene Burmakin
67916c10c4
Fix tests
2025-04-04 21:39:59 +02:00
Eugene Burmakin
600c88ae01
Merge remote-tracking branch 'origin/dev' into feature/subscription
2025-04-04 21:28:13 +02:00