From c946ba3faeddd181d23a75342a487fbcf992f027 Mon Sep 17 00:00:00 2001 From: ThibG Date: Thu, 20 Sep 2018 22:53:30 +0200 Subject: Add rel=me to moved accounts' link (#8742) --- app/views/accounts/_moved.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/views/accounts') diff --git a/app/views/accounts/_moved.html.haml b/app/views/accounts/_moved.html.haml index f99328dbd..7a777bfea 100644 --- a/app/views/accounts/_moved.html.haml +++ b/app/views/accounts/_moved.html.haml @@ -6,7 +6,7 @@ = t('accounts.moved_html', name: content_tag(:bdi, content_tag(:strong, display_name(account, custom_emojify: true), class: :emojify)), new_profile_link: link_to(content_tag(:strong, safe_join(['@', content_tag(:span, moved_to_account.acct)])), TagManager.instance.url_for(moved_to_account), class: 'mention')) .moved-account-widget__card - = link_to TagManager.instance.url_for(moved_to_account), class: 'detailed-status__display-name p-author h-card', target: '_blank', rel: 'noopener' do + = link_to TagManager.instance.url_for(moved_to_account), class: 'detailed-status__display-name p-author h-card', target: '_blank', rel: 'me noopener' do .detailed-status__display-avatar .account__avatar-overlay .account__avatar-overlay-base{ style: "background-image: url('#{moved_to_account.avatar.url(:original)}')" } -- cgit From c39183cc628ea9556db53af5059656d6b63609ba Mon Sep 17 00:00:00 2001 From: ThibG Date: Sun, 23 Sep 2018 20:42:13 +0200 Subject: Refactor active_nav_class for use with multiple paths (#8757) --- app/helpers/application_helper.rb | 4 ++-- app/views/accounts/_header.html.haml | 2 +- spec/helpers/application_helper_spec.rb | 8 ++++++++ 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'app/views/accounts') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 758f864d7..f8e2c0e11 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -7,8 +7,8 @@ module ApplicationHelper follow ).freeze - def active_nav_class(path) - current_page?(path) ? 'active' : '' + def active_nav_class(*paths) + paths.any? { |path| current_page?(path) } ? 'active' : '' end def active_link_to(label, path, **options) diff --git a/app/views/accounts/_header.html.haml b/app/views/accounts/_header.html.haml index 3da270d27..9ceae007d 100644 --- a/app/views/accounts/_header.html.haml +++ b/app/views/accounts/_header.html.haml @@ -16,7 +16,7 @@ = fa_icon('lock') if account.locked? .public-account-header__tabs__tabs .details-counters - .counter{ class: active_nav_class(short_account_url(account)) + active_nav_class(short_account_with_replies_url(account)) + active_nav_class(short_account_media_url(account)) } + .counter{ class: active_nav_class(short_account_url(account), short_account_with_replies_url(account), short_account_media_url(account)) } = link_to short_account_url(account), class: 'u-url u-uid', title: number_with_delimiter(account.statuses_count) do %span.counter-number= number_to_human account.statuses_count, strip_insignificant_zeros: true %span.counter-label= t('accounts.posts', count: account.statuses_count) diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb index 3ccd96f44..61780b46b 100644 --- a/spec/helpers/application_helper_spec.rb +++ b/spec/helpers/application_helper_spec.rb @@ -9,6 +9,14 @@ describe ApplicationHelper do expect(result).to eq "active" end + it 'returns active when on a current page' do + allow(helper).to receive(:current_page?).with('/foo').and_return(false) + allow(helper).to receive(:current_page?).with('/test').and_return(true) + + result = helper.active_nav_class('/foo', '/test') + expect(result).to eq "active" + end + it 'returns empty string when not on current page' do allow(helper).to receive(:current_page?).and_return(false) -- cgit