diff --git a/README.md b/README.md index b2e4907db..ccc0e23ce 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ This project is the core community building portion of the Better Together platf For system overviews, flows, and diagrams, see the docs index: - docs: docs/README.md -- Exchange (Joatu), Notifications, Models & Concerns, and more with Mermaid diagrams (PNG rendered). ## Dependencies diff --git a/app/helpers/better_together/application_helper.rb b/app/helpers/better_together/application_helper.rb index 44b4b03bd..04713f3f3 100644 --- a/app/helpers/better_together/application_helper.rb +++ b/app/helpers/better_together/application_helper.rb @@ -7,6 +7,14 @@ module BetterTogether module ApplicationHelper # rubocop:todo Metrics/ModuleLength include MetricsHelper + # Returns the page title for the current page, combining any page-specific title with the platform name + def page_title(title = nil) + title_parts = [] + title_parts << title if title.present? + title_parts << host_platform.name if host_platform.present? && !turbo_native_app? + title_parts.compact.join(' | ') + end + # Returns the base URL configured for BetterTogether. def base_url ::BetterTogether.base_url @@ -205,6 +213,10 @@ def better_together_url_helper?(method) method.to_s.end_with?('_path', '_url') && BetterTogether::Engine.routes.url_helpers.respond_to?(method) end + def turbo_native_app? + request.user_agent.to_s.include?('Turbo Native') + end + # Returns the appropriate icon and color for an event based on the person's relationship to it def event_relationship_icon(person, event) # rubocop:todo Metrics/MethodLength relationship = person.event_relationship_for(event) diff --git a/app/models/better_together/navigation_item.rb b/app/models/better_together/navigation_item.rb index f7ac0f367..93300d1b7 100644 --- a/app/models/better_together/navigation_item.rb +++ b/app/models/better_together/navigation_item.rb @@ -214,13 +214,15 @@ def self.permitted_attributes(id: false, destroy: false) # rubocop:todo Metrics/ super + attrs end - def url + def url(path_only: false) fallback_url = "##{identifier}" if linkable.present? linkable.url elsif route_name.present? # If the route_name is present, use the dynamic route - retrieve_route(route_name) + route = route_name + route = route_name.sub('url', 'path') if path_only + retrieve_route(route) else read_attribute(:url) or fallback_url end diff --git a/app/views/layouts/better_together/_navbar_brand.html.erb b/app/views/layouts/better_together/_navbar_brand.html.erb index fdb707265..8d5015c81 100644 --- a/app/views/layouts/better_together/_navbar_brand.html.erb +++ b/app/views/layouts/better_together/_navbar_brand.html.erb @@ -1,7 +1,7 @@ <%= cache ['header_branding', host_community.cache_key_with_version] do %> - <%= link_to base_url_with_locale, class: 'navbar-brand' do %> + <%= link_to base_path_with_locale, class: 'navbar-brand' do %> <% if host_community_logo_url %> <%= image_tag host_community_logo_url, class: "#{dom_class(host_community, :host)}_logo", title: host_community.name, alt: host_community.name %> <% else %> diff --git a/app/views/layouts/better_together/application.html.erb b/app/views/layouts/better_together/application.html.erb index 5a40356a7..5952c1aec 100644 --- a/app/views/layouts/better_together/application.html.erb +++ b/app/views/layouts/better_together/application.html.erb @@ -9,7 +9,7 @@ <%= render 'layouts/better_together/custom_head_javascript' %> - <%= (yield(:page_title) + ' | ') if content_for?(:page_title) %><%= host_platform.name %> + <%= page_title(content_for(:page_title) || nil) %> <%= open_graph_meta_tags %> <%= seo_meta_tags %> <%= robots_meta_tag %>