parent
11e8ce972a
commit
6218f7222c
|
@ -82,6 +82,7 @@ body {
|
|||
|
||||
#blocks-timeline,
|
||||
#favorite-timeline,
|
||||
#hashtag-timeline,
|
||||
#global-timeline,
|
||||
#local-timeline,
|
||||
#mutes-timeline {
|
||||
|
|
|
@ -15,6 +15,7 @@ module Command
|
|||
, loadGlobalTimeline
|
||||
, loadAccountTimeline
|
||||
, loadFavoriteTimeline
|
||||
, loadHashtagTimeline
|
||||
, loadMutes
|
||||
, loadBlocks
|
||||
, loadNextTimeline
|
||||
|
@ -338,6 +339,20 @@ loadFavoriteTimeline client url =
|
|||
Cmd.none
|
||||
|
||||
|
||||
loadHashtagTimeline : Maybe Client -> String -> Maybe String -> Cmd Msg
|
||||
loadHashtagTimeline client hashtag url =
|
||||
case client of
|
||||
Just client ->
|
||||
HttpBuilder.get (Maybe.withDefault (ApiUrl.hashtag hashtag) url)
|
||||
|> withClient client
|
||||
|> withBodyDecoder (Decode.list statusDecoder)
|
||||
|> withQueryParams [ ( "limit", "60" ) ]
|
||||
|> send (MastodonEvent << HashtagTimeline (url /= Nothing))
|
||||
|
||||
Nothing ->
|
||||
Cmd.none
|
||||
|
||||
|
||||
loadMutes : Maybe Client -> Maybe String -> Cmd Msg
|
||||
loadMutes client url =
|
||||
case client of
|
||||
|
@ -394,6 +409,14 @@ loadNextTimeline client currentView id next =
|
|||
"favorite-timeline" ->
|
||||
loadFavoriteTimeline client (Just next)
|
||||
|
||||
"hashtag-timeline" ->
|
||||
case currentView of
|
||||
HashtagView hashtag ->
|
||||
loadHashtagTimeline client hashtag (Just next)
|
||||
|
||||
_ ->
|
||||
Cmd.none
|
||||
|
||||
"account-timeline" ->
|
||||
case currentView of
|
||||
AccountView account ->
|
||||
|
|
|
@ -18,6 +18,7 @@ init { registration, clients } location =
|
|||
, localTimeline = Update.Timeline.empty "local-timeline"
|
||||
, globalTimeline = Update.Timeline.empty "global-timeline"
|
||||
, favoriteTimeline = Update.Timeline.empty "favorite-timeline"
|
||||
, hashtagTimeline = Update.Timeline.empty "hashtag-timeline"
|
||||
, mutes = Update.Timeline.empty "mutes-timeline"
|
||||
, blocks = Update.Timeline.empty "blocks-timeline"
|
||||
, accountTimeline = Update.Timeline.empty "account-timeline"
|
||||
|
|
|
@ -12,6 +12,7 @@ module Mastodon.ApiUrl
|
|||
, homeTimeline
|
||||
, publicTimeline
|
||||
, favouriteTimeline
|
||||
, hashtag
|
||||
, mutes
|
||||
, blocks
|
||||
, notifications
|
||||
|
@ -139,6 +140,11 @@ favouriteTimeline =
|
|||
apiPrefix ++ "/favourites"
|
||||
|
||||
|
||||
hashtag : String -> String
|
||||
hashtag tag =
|
||||
apiPrefix ++ "/timelines/tag/" ++ tag
|
||||
|
||||
|
||||
mutes : String
|
||||
mutes =
|
||||
apiPrefix ++ "/mutes"
|
||||
|
|
|
@ -63,6 +63,7 @@ type MastodonMsg
|
|||
| FavoriteRemoved (MastodonResult Status)
|
||||
| FavoriteTimeline Bool (MastodonResult (List Status))
|
||||
| GlobalTimeline Bool (MastodonResult (List Status))
|
||||
| HashtagTimeline Bool (MastodonResult (List Status))
|
||||
| HomeTimeline Bool (MastodonResult (List Status))
|
||||
| LocalTimeline Bool (MastodonResult (List Status))
|
||||
| Mutes Bool (MastodonResult (List Account))
|
||||
|
@ -136,6 +137,7 @@ type CurrentView
|
|||
| BlocksView
|
||||
| FavoriteTimelineView
|
||||
| GlobalTimelineView
|
||||
| HashtagView String
|
||||
| LocalTimelineView
|
||||
| MutesView
|
||||
| ThreadView Thread
|
||||
|
@ -211,6 +213,7 @@ type alias Model =
|
|||
, localTimeline : Timeline Status
|
||||
, globalTimeline : Timeline Status
|
||||
, favoriteTimeline : Timeline Status
|
||||
, hashtagTimeline : Timeline Status
|
||||
, mutes : Timeline Account
|
||||
, blocks : Timeline Account
|
||||
, accountTimeline : Timeline Status
|
||||
|
|
|
@ -80,6 +80,13 @@ update msg model =
|
|||
}
|
||||
! [ Command.loadMutes (List.head model.clients) Nothing ]
|
||||
|
||||
HashtagView hashtag ->
|
||||
{ model
|
||||
| currentView = view
|
||||
, hashtagTimeline = Update.Timeline.setLoading True model.hashtagTimeline
|
||||
}
|
||||
! [ Command.loadHashtagTimeline (List.head model.clients) hashtag Nothing ]
|
||||
|
||||
_ ->
|
||||
{ model | currentView = view } ! []
|
||||
|
||||
|
|
|
@ -153,6 +153,14 @@ update msg model =
|
|||
Err error ->
|
||||
{ model | errors = addErrorNotification (errorText error) model } ! []
|
||||
|
||||
HashtagTimeline append result ->
|
||||
case result of
|
||||
Ok { decoded, links } ->
|
||||
{ model | hashtagTimeline = Update.Timeline.update append decoded links model.hashtagTimeline } ! []
|
||||
|
||||
Err error ->
|
||||
{ model | errors = addErrorNotification (errorText error) model } ! []
|
||||
|
||||
LocalTimeline append result ->
|
||||
case result of
|
||||
Ok { decoded, links } ->
|
||||
|
|
|
@ -160,6 +160,9 @@ markAsLoading loading id model =
|
|||
"favorite-timeline" ->
|
||||
{ model | favoriteTimeline = mark model.favoriteTimeline }
|
||||
|
||||
"hashtag-timeline" ->
|
||||
{ model | hashtagTimeline = mark model.hashtagTimeline }
|
||||
|
||||
"account-timeline" ->
|
||||
case model.currentView of
|
||||
AccountView account ->
|
||||
|
|
|
@ -12,6 +12,10 @@ import View.Blocks exposing (blocksView)
|
|||
import View.Common as Common
|
||||
import View.Draft exposing (draftView)
|
||||
import View.Error exposing (errorsListView)
|
||||
|
||||
|
||||
-- import View.HashTag exposing (hashtagView)
|
||||
|
||||
import View.Mutes exposing (mutesView)
|
||||
import View.Notification exposing (notificationListView)
|
||||
import View.Thread exposing (threadView)
|
||||
|
@ -108,6 +112,14 @@ homepageView model =
|
|||
"star"
|
||||
currentUser
|
||||
model.favoriteTimeline
|
||||
|
||||
HashtagView hashtag ->
|
||||
contextualTimelineView
|
||||
(HashtagView hashtag)
|
||||
("#" ++ hashtag)
|
||||
"tags"
|
||||
currentUser
|
||||
model.hashtagTimeline
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
module View.Formatter exposing (formatContent)
|
||||
|
||||
import Dict
|
||||
import Elmoji
|
||||
import Html exposing (..)
|
||||
import Html.Attributes exposing (..)
|
||||
import HtmlParser
|
||||
import String.Extra exposing (replace)
|
||||
import Http
|
||||
import Mastodon.Model exposing (..)
|
||||
import String.Extra exposing (replace, rightOf)
|
||||
import Types exposing (..)
|
||||
import View.Events exposing (..)
|
||||
|
||||
|
||||
-- Custom Events
|
||||
-- Views
|
||||
|
||||
|
||||
formatContent : String -> List Mention -> List (Html Msg)
|
||||
formatContent content mentions =
|
||||
content
|
||||
|
@ -42,11 +40,20 @@ createLinkNode attrs children mentions =
|
|||
(toVirtualDom mentions children)
|
||||
|
||||
Nothing ->
|
||||
Html.node "a"
|
||||
((List.map toAttribute attrs)
|
||||
++ [ onClickWithStop NoOp, target "_blank" ]
|
||||
)
|
||||
(toVirtualDom mentions children)
|
||||
case getHashtagForLink attrs of
|
||||
Just hashtag ->
|
||||
Html.node "a"
|
||||
((List.map toAttribute attrs)
|
||||
++ [ onClickWithPreventAndStop (SetView (HashtagView hashtag)) ]
|
||||
)
|
||||
(toVirtualDom mentions children)
|
||||
|
||||
Nothing ->
|
||||
Html.node "a"
|
||||
((List.map toAttribute attrs)
|
||||
++ [ onClickWithStop NoOp, target "_blank" ]
|
||||
)
|
||||
(toVirtualDom mentions children)
|
||||
|
||||
|
||||
getHrefLink : List ( String, String ) -> Maybe String
|
||||
|
@ -57,6 +64,24 @@ getHrefLink attrs =
|
|||
|> List.head
|
||||
|
||||
|
||||
getHashtagForLink : List ( String, String ) -> Maybe String
|
||||
getHashtagForLink attrs =
|
||||
let
|
||||
hashtag =
|
||||
attrs
|
||||
|> Dict.fromList
|
||||
|> Dict.get "href"
|
||||
|> Maybe.withDefault ""
|
||||
|> rightOf "/tags/"
|
||||
|> Http.decodeUri
|
||||
|> Maybe.withDefault ""
|
||||
in
|
||||
if hashtag /= "" then
|
||||
Just hashtag
|
||||
else
|
||||
Nothing
|
||||
|
||||
|
||||
getMentionForLink : List ( String, String ) -> List Mention -> Maybe Mention
|
||||
getMentionForLink attrs mentions =
|
||||
case getHrefLink attrs of
|
||||
|
|
Loading…
Reference in New Issue