mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-12 02:01:39 -05:00
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 |
||
|---|---|---|
| .. | ||
| 20220325100310_devise_create_users.rb | ||
| 20231021104256_add_service_name_to_active_storage_blobs.active_storage.rb | ||
| 20231021104257_create_active_storage_variant_records.active_storage.rb | ||
| 20231021104258_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb | ||
| 20240315213523_create_points.rb | ||
| 20240315215423_create_imports.rb | ||
| 20240317171559_add_indicies_to_points_latitude_longitude.rb | ||
| 20240323125126_add_raw_points_and_doubles_to_import.rb | ||
| 20240323160300_create_stats.rb | ||
| 20240323161049_add_index_to_points_timestamp.rb | ||
| 20240323190039_add_user_id_to_stat.rb | ||
| 20240324161309_create_active_storage_tables.active_storage.rb | ||
| 20240324161800_add_processed_to_imports.rb | ||
| 20240324173315_add_daily_distance_to_stat.rb | ||
| 20240404154959_add_api_key_to_users.rb | ||
| 20240425200155_add_raw_data_to_imports.rb | ||
| 20240518095848_add_theme_to_users.rb | ||
| 20240525110244_add_user_id_to_points.rb | ||
| 20240612152451_create_exports.rb | ||
| 20240620205120_add_settings_to_users.rb | ||
| 20240630093005_add_fog_of_war_to_default_settings.rb | ||
| 20240703105734_create_notifications.rb | ||
| 20240712141303_add_geodata_to_points.rb | ||
| 20240713103051_add_admin_to_users.rb | ||
| 20240721165313_create_areas.rb | ||
| 20240721183005_create_visits.rb | ||
| 20240721183116_add_visit_id_to_points.rb | ||
| 20240805150111_create_places.rb | ||
| 20240808102348_add_place_id_to_visits.rb | ||
| 20240808102425_make_area_id_optional_in_visits.rb | ||
| 20240808121027_create_place_visits.rb | ||
| 20240822092405_add_points_count_to_imports.rb | ||
| 20241127161621_create_trips.rb | ||
| 20241128095325_create_action_text_tables.action_text.rb | ||
| 20241202114820_add_reverse_geocoded_at_to_points.rb | ||
| 20241205160055_add_devise_trackable_columns_to_users.rb | ||
| 20241211113119_add_started_at_index_to_visits.rb | ||
| 20241226202204_add_database_users_constraints.rb | ||
| 20241226202831_validate_add_database_users_constraints.rb | ||
| 20250120152014_add_course_and_course_accuracy_to_points.rb | ||
| 20250120152540_add_external_track_id_to_points.rb | ||
| 20250120154555_add_unique_index_to_points.rb | ||
| 20250123145155_enable_postgis_extension.rb | ||
| 20250123151657_add_path_to_trips.rb | ||
| 20250219195822_add_status_to_users.rb | ||
| 20250221181805_add_lonlat_to_points.rb | ||
| 20250221185032_add_lonlat_index.rb | ||
| 20250221194430_remove_points_latitude_longitude_uniqueness_index.rb | ||
| 20250221194509_add_unique_lon_lat_index_to_points.rb | ||
| 20250303194009_add_lonlat_to_places.rb | ||
| 20250303194043_add_lonlat_index_to_places.rb | ||
| 20250324180755_add_format_start_at_end_at_to_exports.rb | ||
| 20250404182437_add_active_until_to_users.rb | ||
| 20250513164521_add_visited_countries_to_trips.rb | ||
| 20250515190752_create_countries.rb | ||
| 20250515192211_add_country_id_to_points.rb | ||
| 20250625185030_add_file_type_to_exports.rb | ||
| 20250627184017_add_status_to_imports.rb | ||
| 20250703193656_create_tracks.rb | ||
| 20250703193657_add_track_id_to_points.rb | ||
| 20250721204404_add_index_on_places_geodata_osm_id.rb | ||
| 20250723164055_add_track_generation_composite_index.rb | ||
| 20250728191359_add_country_name_to_points.rb | ||
| 20250821192219_add_points_count_to_users.rb | ||
| 20250823125940_remove_default_from_imports_source.rb | ||
| 20250905120121_add_user_country_composite_index_to_points.rb | ||
| 20250910224538_add_sharing_fields_to_stats.rb | ||
| 20250910224714_add_index_to_stats_share_uuid.rb | ||
| 20250918215512_add_h3_hex_ids_to_stats.rb | ||
| 20250926220114_create_families.rb | ||
| 20250926220135_create_family_memberships.rb | ||
| 20250926220158_create_family_invitations.rb | ||
| 20250926220345_validate_family_foreign_keys.rb | ||
| 20251030190924_add_utm_parameters_to_users.rb | ||
| 20251105153510_add_sharing_to_trips.rb | ||