Prepare for emoji support
This commit is contained in:
parent
b30c66356a
commit
51b1fa2b17
@ -329,6 +329,7 @@ statusDecoder =
|
||||
, voted = False
|
||||
, options = []
|
||||
}
|
||||
|> Pipe.optional "emojis" (Decode.list emojiDecoder) []
|
||||
|> Pipe.optional "pinned" Decode.bool False -- Not a real value, used to show pinned indicator
|
||||
|
||||
|
||||
|
@ -314,6 +314,7 @@ type alias Status =
|
||||
, visibility : String
|
||||
, pleroma : Maybe Pleroma
|
||||
, poll : Poll
|
||||
, emojis : List Emoji
|
||||
, pinned : Bool -- Not a real value, used to show pinned indicator
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ movedIndicator account =
|
||||
, span [ class "acct" ] [ text <| "@" ++ account.moved.acct ]
|
||||
]
|
||||
, div [ class "status-text" ]
|
||||
( formatContent account.moved.note [] )
|
||||
( formatContent account.moved.note [] [] )
|
||||
]
|
||||
]
|
||||
]
|
||||
@ -314,7 +314,7 @@ makeField field =
|
||||
[ dt [ title field.name ] [ text field.name ]
|
||||
, dd [ title (textContent field.value)
|
||||
, class dd_class ]
|
||||
(checkmark :: (formatContent field.value []))
|
||||
(checkmark :: (formatContent field.value [] []))
|
||||
]
|
||||
|
||||
fields : CurrentAccountView -> Account -> Html Msg
|
||||
@ -396,7 +396,7 @@ accountView subView currentUser accountInfo =
|
||||
else
|
||||
text ""
|
||||
]
|
||||
, span [ class "account-note" ] (formatContent account.note [])
|
||||
, span [ class "account-note" ] (formatContent account.note [] [])
|
||||
]
|
||||
]
|
||||
, fields subView account
|
||||
|
@ -85,7 +85,7 @@ currentUserView currentUser =
|
||||
, text ")"
|
||||
]
|
||||
]
|
||||
, p [ class "status-text" ] <| formatContent currentUser.note []
|
||||
, p [ class "status-text" ] <| formatContent currentUser.note [] []
|
||||
]
|
||||
|
||||
Nothing ->
|
||||
|
@ -13,14 +13,14 @@ import Types exposing (..)
|
||||
import View.Events exposing (..)
|
||||
|
||||
|
||||
formatContent : String -> List Mention -> List (Html Msg)
|
||||
formatContent content mentions =
|
||||
formatContent : String -> List Mention -> List Emoji -> List (Html Msg)
|
||||
formatContent content mentions emojis =
|
||||
content
|
||||
|> replace " ?" " ?"
|
||||
|> replace " !" " !"
|
||||
|> replace " :" " :"
|
||||
|> HtmlParser.parse
|
||||
|> toVirtualDom mentions
|
||||
|> toVirtualDom mentions emojis
|
||||
|
||||
|
||||
textContent : String -> String
|
||||
@ -30,9 +30,9 @@ textContent html =
|
||||
|
||||
{-| Converts nodes to virtual dom nodes.
|
||||
-}
|
||||
toVirtualDom : List Mention -> List HtmlParser.Node -> List (Html Msg)
|
||||
toVirtualDom mentions nodes =
|
||||
List.map (toVirtualDomEach mentions) nodes
|
||||
toVirtualDom : List Mention -> List Emoji-> List HtmlParser.Node -> List (Html Msg)
|
||||
toVirtualDom mentions emojis nodes =
|
||||
List.map (toVirtualDomEach mentions emojis) nodes
|
||||
|
||||
|
||||
replaceHref : String -> List ( String, String ) -> List (Attribute Msg)
|
||||
@ -48,21 +48,21 @@ createLinkNode attrs children mentions =
|
||||
Just mention ->
|
||||
Html.node "a"
|
||||
(replaceHref ("#account/" ++ mention.id) attrs)
|
||||
(toVirtualDom mentions children)
|
||||
(toVirtualDom mentions [] children)
|
||||
|
||||
Nothing ->
|
||||
case getHashtagForLink attrs of
|
||||
Just hashtag ->
|
||||
Html.node "a"
|
||||
(replaceHref ("#hashtag/" ++ hashtag) attrs)
|
||||
(toVirtualDom mentions children)
|
||||
(toVirtualDom mentions [] children)
|
||||
|
||||
Nothing ->
|
||||
Html.node "a"
|
||||
((List.map toAttribute attrs)
|
||||
++ [ onClickWithStop NoOp, target "_blank" ]
|
||||
)
|
||||
(toVirtualDom mentions children)
|
||||
(toVirtualDom mentions [] children)
|
||||
|
||||
|
||||
getHrefLink : List ( String, String ) -> Maybe String
|
||||
@ -103,22 +103,27 @@ getMentionForLink attrs mentions =
|
||||
Nothing
|
||||
|
||||
|
||||
toVirtualDomEach : List Mention -> HtmlParser.Node -> Html Msg
|
||||
toVirtualDomEach mentions node =
|
||||
toVirtualDomEach : List Mention -> List Emoji -> HtmlParser.Node -> Html Msg
|
||||
toVirtualDomEach mentions emoji node =
|
||||
case node of
|
||||
HtmlParser.Element "a" attrs children ->
|
||||
createLinkNode attrs children mentions
|
||||
|
||||
HtmlParser.Element name attrs children ->
|
||||
Html.node name (List.map toAttribute attrs) (toVirtualDom mentions children)
|
||||
Html.node name (List.map toAttribute attrs) (toVirtualDom mentions emoji children)
|
||||
|
||||
HtmlParser.Text s ->
|
||||
Elmoji.text_ s
|
||||
handleEmoji s emoji
|
||||
|
||||
HtmlParser.Comment _ ->
|
||||
text ""
|
||||
|
||||
|
||||
handleEmoji : String -> List Emoji -> Html Msg
|
||||
handleEmoji s emoji =
|
||||
Elmoji.text_ s -- todo
|
||||
|
||||
|
||||
toAttribute : ( String, String ) -> Attribute msg
|
||||
toAttribute ( name, value ) =
|
||||
attribute name value
|
||||
|
0
src/View/NewFile
Normal file
0
src/View/NewFile
Normal file
@ -116,7 +116,7 @@ notificationFollowView currentUser { type_, accounts } =
|
||||
, span [ class "btn-sm follow-profile-date" ]
|
||||
[ Common.icon "time", text <| Common.formatDate created_at ]
|
||||
]
|
||||
, formatContent account.note []
|
||||
, formatContent account.note [] []
|
||||
|> div
|
||||
[ class "status-text"
|
||||
, onClick <| Navigate ("#account/" ++ account.id)
|
||||
|
@ -17,7 +17,7 @@ accountListView accounts =
|
||||
li [ class "list-group-item status follow-profile" ]
|
||||
[ Common.accountAvatarLink False account
|
||||
, div [ class "username" ] [ Common.accountLinkLarge False account ]
|
||||
, formatContent account.note []
|
||||
, formatContent account.note [] []
|
||||
|> div
|
||||
[ class "status-text"
|
||||
, onClick <| Navigate ("#account/" ++ account.id)
|
||||
|
@ -250,7 +250,7 @@ statusContentView context status =
|
||||
"" ->
|
||||
div [ class "status-text" ]
|
||||
[ mentionsView status.mentions
|
||||
, div [] <| formatContent status.content status.mentions
|
||||
, div [] <| formatContent status.content status.mentions status.emojis
|
||||
, pollView status
|
||||
, attachmentListView context status
|
||||
, quoteView status
|
||||
@ -263,13 +263,12 @@ statusContentView context status =
|
||||
"spoiler" ++ extractStatusId status.id ++ context
|
||||
in
|
||||
div [ class "status-text spoiled" ]
|
||||
[ div [ class "spoiler" ]
|
||||
[ text status.spoiler_text ]
|
||||
[ div [ class "spoiler" ] <| formatContent status.spoiler_text status.mentions status.emojis
|
||||
, input [ onClickWithStop NoOp, type_ "checkbox", id statusId, class "spoiler-toggler" ] []
|
||||
, label [ onClickWithStop NoOp, for statusId ] [ text "Reveal content" ]
|
||||
, div [ class "spoiled-content" ]
|
||||
[ mentionsView status.mentions
|
||||
, div [] <| formatContent status.content status.mentions
|
||||
, div [] <| formatContent status.content status.mentions status.emojis
|
||||
, pollView status
|
||||
, attachmentListView context status
|
||||
, quoteView status
|
||||
|
Loading…
Reference in New Issue
Block a user