From 592607835ab8d251955b171e817db82286d8d87e Mon Sep 17 00:00:00 2001 From: Ryan Fox Date: Wed, 1 Dec 2021 00:50:51 -0800 Subject: [PATCH] Make instance icons more prevalent --- src/View/Account.elm | 2 +- src/View/Common.elm | 59 +++++++++++++++++++++++++++++++++++--------- src/View/Status.elm | 13 +--------- 3 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/View/Account.elm b/src/View/Account.elm index a7ebb2f..08a357b 100644 --- a/src/View/Account.elm +++ b/src/View/Account.elm @@ -107,7 +107,7 @@ followView currentUser relationship account = ] ] , br [] [] - , text <| "@" ++ account.acct + , Common.accountAcctView True account ] , muteButton currentUser relationship account , followButton currentUser relationship account diff --git a/src/View/Common.elm b/src/View/Common.elm index 0a59384..f246c77 100644 --- a/src/View/Common.elm +++ b/src/View/Common.elm @@ -1,10 +1,12 @@ module View.Common exposing - ( accountAvatar + ( accountAcctView + , accountAvatar , accountAvatarLink , accountLink , accountLinkSmall , accountLinkLarge + , instanceIconsView , appLink , closeablePanelheading , icon @@ -31,20 +33,32 @@ accountAvatar avatarClass account = img [ class avatarClass, src account.avatar ] [] +accountDisplayName : Account -> String +accountDisplayName account = + if account.display_name == "" then + account.username + else + account.display_name + + accountLink : Bool -> Account -> Html Msg accountLink external account = - let - accountHref = - if external then - target "_blank" - else - href <| "#account/" ++ account.id - in + if external then a [ href account.url - , accountHref + , target "_blank" + ] + [ text <| "@" ++ account.acct + , instanceIconsView <| account.url + ] + else + a + [ href account.url + , href <| "#account/" ++ account.id + ] + [ text <| accountDisplayName <| account + , accountAcctView False account ] - [ text <| "@" ++ account.acct ] accountLinkSmall : Bool -> Account -> Html Msg @@ -86,10 +100,33 @@ accountLinkLarge external account = else account.display_name , br [] [] - , span [ class "acct" ] [ text <| "@" ++ account.acct ] + , accountAcctView True account ] +instanceIconsView : String -> Html Msg +instanceIconsView url = + let + instUrl = String.join "/" ( List.take 3 ( String.split "/" url ) ) + instIcon = img [ class "acct-instance-icon", src ( instUrl ++ "/favicon.png" ), alt "" ] [] + instIcon2 = img [ class "acct-instance-icon", src ( instUrl ++ "/favicon.ico" ), alt "" ] [] + in + span [] [ instIcon, instIcon2 ] + + +accountAcctView : Bool -> Account -> Html Msg +accountAcctView showIcons account = + let + acctText = text <| " @" ++ account.acct + icons = + if showIcons then + instanceIconsView <| account.url + else + text "" + in + span [ class "acct" ] [ acctText, icons ] + + accountAvatarLink : Bool -> Account -> Html Msg accountAvatarLink external account = let diff --git a/src/View/Status.elm b/src/View/Status.elm index 96f9fd7..66042f6 100644 --- a/src/View/Status.elm +++ b/src/View/Status.elm @@ -260,17 +260,6 @@ statusEntryView context className currentUser status = ] -statusAcctView : Account -> Html Msg -statusAcctView account = - let - acctText = text <| " @" ++ account.acct - instUrl = String.join "/" ( List.take 3 ( String.split "/" account.url ) ) - instIcon = img [ class "acct-instance-icon", src ( instUrl ++ "/favicon.png" ), alt "" ] [] - instIcon2 = img [ class "acct-instance-icon", src ( instUrl ++ "/favicon.ico" ), alt "" ] [] - in - span [ class "acct" ] [ acctText, instIcon, instIcon2 ] - - statusView : String -> Status -> Bool -> Html Msg statusView context ({ account, content, media_attachments, reblog, mentions, pinned } as status) clickOpen = let @@ -316,7 +305,7 @@ statusView context ({ account, content, media_attachments, reblog, mentions, pin , div [ class "username" ] [ a accountLinkAttributes [ text (if account.display_name=="" then account.username else account.display_name) - , statusAcctView <| account + , Common.accountAcctView True account ] ] , Lazy.lazy2 statusContentView context status