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