Fix #30: Unique CW and NSFW content togglers. (#54)

This commit is contained in:
Nicolas Perriault 2017-04-25 17:07:48 +02:00 committed by GitHub
parent e0d22ba0b6
commit b0c6bc0240

View File

@ -68,8 +68,8 @@ accountAvatarLink account =
[ img [ class "avatar", src account.avatar ] [] ]
attachmentPreview : Maybe Bool -> List Mastodon.Attachment -> Mastodon.Attachment -> Html Msg
attachmentPreview sensitive attachments ({ url, preview_url } as attachment) =
attachmentPreview : String -> Maybe Bool -> List Mastodon.Attachment -> Mastodon.Attachment -> Html Msg
attachmentPreview context sensitive attachments ({ url, preview_url } as attachment) =
let
nsfw =
case sensitive of
@ -80,7 +80,7 @@ attachmentPreview sensitive attachments ({ url, preview_url } as attachment) =
False
attId =
"att" ++ (toString attachment.id)
"att" ++ (toString attachment.id) ++ context
media =
a
@ -111,31 +111,31 @@ attachmentPreview sensitive attachments ({ url, preview_url } as attachment) =
[ media ]
attachmentListView : Mastodon.Status -> Html Msg
attachmentListView { media_attachments, sensitive } =
attachmentListView : String -> Mastodon.Status -> Html Msg
attachmentListView context { media_attachments, sensitive } =
case media_attachments of
[] ->
text ""
attachments ->
ul [ class "attachments" ] <|
List.map (attachmentPreview sensitive attachments) attachments
List.map (attachmentPreview context sensitive attachments) attachments
statusContentView : Mastodon.Status -> Html Msg
statusContentView status =
statusContentView : String -> Mastodon.Status -> Html Msg
statusContentView context status =
case status.spoiler_text of
"" ->
div [ class "status-text" ]
[ div [] <| ViewHelper.formatContent status.content status.mentions
, attachmentListView status
, attachmentListView context status
]
spoiler ->
-- Note: Spoilers are dealt with using pure CSS.
let
statusId =
"spoiler" ++ (toString status.id)
"spoiler" ++ (toString status.id) ++ context
in
div [ class "status-text spoiled" ]
[ div [ class "spoiler" ] [ text status.spoiler_text ]
@ -143,13 +143,13 @@ statusContentView status =
, label [ for statusId ] [ text "Reveal content" ]
, div [ class "spoiled-content" ]
[ div [] <| ViewHelper.formatContent status.content status.mentions
, attachmentListView status
, attachmentListView context status
]
]
statusView : Mastodon.Status -> Html Msg
statusView ({ account, content, media_attachments, reblog, mentions } as status) =
statusView : String -> Mastodon.Status -> Html Msg
statusView context ({ account, content, media_attachments, reblog, mentions } as status) =
let
accountLinkAttributes =
[ href account.url
@ -169,7 +169,7 @@ statusView ({ account, content, media_attachments, reblog, mentions } as status)
[ text <| " @" ++ account.username ]
, text " boosted"
]
, statusView reblog
, statusView context reblog
]
Nothing ->
@ -181,7 +181,7 @@ statusView ({ account, content, media_attachments, reblog, mentions } as status)
, span [ class "acct" ] [ text <| " @" ++ account.username ]
]
]
, statusContentView status
, statusContentView context status
]
@ -230,7 +230,7 @@ accountTimelineView account statuses label iconName =
List.map
(\s ->
li [ class "list-group-item status" ]
[ statusView s ]
[ statusView "account" s ]
)
statuses
]
@ -295,8 +295,8 @@ statusActionsView status =
]
statusEntryView : Mastodon.Status -> Html Msg
statusEntryView status =
statusEntryView : String -> Mastodon.Status -> Html Msg
statusEntryView context status =
let
nsfwClass =
case status.sensitive of
@ -307,13 +307,13 @@ statusEntryView status =
""
in
li [ class <| "list-group-item " ++ nsfwClass ]
[ statusView status
[ statusView context status
, statusActionsView status
]
timelineView : List Mastodon.Status -> String -> String -> Html Msg
timelineView statuses label iconName =
timelineView : String -> String -> String -> List Mastodon.Status -> Html Msg
timelineView label iconName context statuses =
div [ class "col-md-3" ]
[ div [ class "panel panel-default" ]
[ div [ class "panel-heading" ]
@ -321,7 +321,7 @@ timelineView statuses label iconName =
, text label
]
, ul [ class "list-group" ] <|
List.map statusEntryView statuses
List.map (statusEntryView context) statuses
]
]
@ -339,8 +339,8 @@ notificationHeading accounts str iconType =
]
notificationStatusView : Mastodon.Status -> Mastodon.NotificationAggregate -> Html Msg
notificationStatusView status { type_, accounts } =
notificationStatusView : String -> Mastodon.Status -> Mastodon.NotificationAggregate -> Html Msg
notificationStatusView context status { type_, accounts } =
div [ class <| "notification " ++ type_ ]
[ case type_ of
"reblog" ->
@ -351,7 +351,7 @@ notificationStatusView status { type_, accounts } =
_ ->
text ""
, statusView status
, statusView context status
, statusActionsView status
]
@ -377,7 +377,7 @@ notificationEntryView notification =
li [ class "list-group-item" ]
[ case notification.status of
Just status ->
notificationStatusView status notification
notificationStatusView "notification" status notification
Nothing ->
notificationFollowView notification
@ -414,7 +414,7 @@ draftReplyToView draft =
, text ")"
]
]
, div [ class "well" ] [ statusView status ]
, div [ class "well" ] [ statusView "draft" status ]
]
Nothing ->
@ -566,7 +566,7 @@ homepageView : Model -> Html Msg
homepageView model =
div [ class "row" ]
[ sidebarView model
, timelineView model.userTimeline "Home timeline" "home"
, timelineView "Home timeline" "home" "home" model.userTimeline
, notificationListView model.notifications
, case model.account of
Just account ->
@ -575,9 +575,9 @@ homepageView model =
Nothing ->
if model.useGlobalTimeline then
timelineView model.publicTimeline "Global timeline" "globe"
timelineView "Global timeline" "globe" "global" model.publicTimeline
else
timelineView model.localTimeline "Local timeline" "th-large"
timelineView "Local timeline" "th-large" "local" model.localTimeline
]