From b023459600abee74432cf775f0a1b82fffa0c2d9 Mon Sep 17 00:00:00 2001 From: James Mason Date: Wed, 28 May 2014 13:44:37 -0700 Subject: [PATCH] Use a single entry for navigation branding: Allow a view to override the brand (esp. for conference splash pages), Use the app name link for the admin control panel, use the conference short title for end user content within a conference, fall back to the app name link. Visually, there are two substantial changes: (1) the conference title (or short title) serves as the brand when viewing conference content; (2) the short title isn't shown redundantly on the navbar and the top of the sidebar when editing a conf. --- app/helpers/application_helper.rb | 22 ++++++++++++++++++++-- app/views/conference/show.html.haml | 6 +++--- app/views/layouts/_navigation.html.haml | 13 ++++--------- 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9e699b23..befc56a4 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,5 +1,4 @@ module ApplicationHelper - def bootstrap_class_for(flash_type) logger.debug "flash_type is #{flash_type}" case flash_type @@ -31,7 +30,7 @@ module ApplicationHelper registration.send(field.to_sym).strftime("%d %b %H:%M") if registration.send(field.to_sym) end end - + def getdate(var) if var.kind_of?(String) DateTime.parse(var).strftime("%a, %d %b") @@ -112,4 +111,23 @@ module ApplicationHelper result end + + def default_brand + link_to CONFIG['name'], root_path, + class: 'navbar-brand', + title: 'Open Source Event Manager' + end + + def short_title_brand(conference) + link_to conference.short_title, conference_path(conference.short_title), + class: 'navbar-brand', + title: conference.title + end + + def brand + content_for(:brand) || + (default_brand if controller.class.parent == Admin) || + (short_title_brand(@conference) if @conference) || + default_brand + end end diff --git a/app/views/conference/show.html.haml b/app/views/conference/show.html.haml index 021d213f..fab08020 100644 --- a/app/views/conference/show.html.haml +++ b/app/views/conference/show.html.haml @@ -1,3 +1,3 @@ -= content_for :splash_logo do - = link_to @conference.title, "#", :class => 'navbar-brand' -= render :partial => "home/conference_details", :locals => {:conference => @conference} \ No newline at end of file += content_for :brand do + = link_to @conference.title, conference_url(@conference.short_title), class: 'navbar-brand' += render :partial => "home/conference_details", :locals => {:conference => @conference} diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index 6210f209..3db20007 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -7,20 +7,15 @@ %span.icon-bar %span.icon-bar %span.icon-bar - = yield(:splash_logo) - = link_to CONFIG['name'], root_path, :class => 'navbar-brand', :title => "Open Source Event Manager" + = brand .collapse.navbar-collapse - = yield(:splash_header) - - if @conference && !@conference.short_title.nil? - %p.navbar-text - = @conference.short_title -if user_signed_in? %ul.nav.navbar-nav.navbar-right %li.dropdown %a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#", id: "current-user-detail"} - if not current_user.person.public_name.empty? #{current_user.person.public_name} - -else + -else #{current_user.email} = image_tag(current_user.person.gravatar_url(size: '18'), title: "Yo #{current_user.person.public_name}!", :alt => '') %b.caret @@ -37,7 +32,7 @@ %li = link_to(new_registration_path('user')) do %span.glyphicon.glyphicon-heart - Sign Up + Sign Up %li.dropdown.visible-desktop %a.dropdown-toggle{"data-toggle" => "dropdown", :href => "#"} %span.glyphicon.glyphicon-user @@ -54,4 +49,4 @@ %br = link_to "Forgot your password?", new_password_path('user') %li.hidden-lg - = link_to('Sign In', new_user_session_path) \ No newline at end of file + = link_to('Sign In', new_user_session_path)