Fix links to github sources (#232)
This commit is contained in:
parent
8dd69e68c1
commit
ecf71f5932
|
@ -33,6 +33,7 @@ import Html.Attributes
|
||||||
( class
|
( class
|
||||||
, colspan
|
, colspan
|
||||||
, href
|
, href
|
||||||
|
, target
|
||||||
)
|
)
|
||||||
import Html.Events
|
import Html.Events
|
||||||
exposing
|
exposing
|
||||||
|
@ -218,7 +219,9 @@ viewResultItemDetails channel item =
|
||||||
case Search.channelDetailsFromId channel of
|
case Search.channelDetailsFromId channel of
|
||||||
Just channelDetails ->
|
Just channelDetails ->
|
||||||
a
|
a
|
||||||
[ href <| githubUrlPrefix channelDetails.branch ++ (value |> String.replace ":" "#L") ]
|
[ href <| githubUrlPrefix channelDetails.branch ++ (value |> String.replace ":" "#L")
|
||||||
|
, target "_blank"
|
||||||
|
]
|
||||||
[ text <| value ]
|
[ text <| value ]
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
|
|
|
@ -34,6 +34,7 @@ import Html.Attributes
|
||||||
( class
|
( class
|
||||||
, colspan
|
, colspan
|
||||||
, href
|
, href
|
||||||
|
, target
|
||||||
)
|
)
|
||||||
import Html.Events
|
import Html.Events
|
||||||
exposing
|
exposing
|
||||||
|
@ -248,18 +249,18 @@ viewResultItemDetails channel item =
|
||||||
githubUrlPrefix branch =
|
githubUrlPrefix branch =
|
||||||
"https://github.com/NixOS/nixpkgs/blob/" ++ branch ++ "/"
|
"https://github.com/NixOS/nixpkgs/blob/" ++ branch ++ "/"
|
||||||
|
|
||||||
cleanPosition value =
|
cleanPosition =
|
||||||
if String.startsWith "source/" value then
|
Regex.fromString "^[0-9a-f]+\\.tar\\.gz\\/"
|
||||||
String.dropLeft 7 value
|
|> Maybe.withDefault Regex.never
|
||||||
|
>> (\reg -> Regex.replace reg (\_ -> ""))
|
||||||
else
|
|
||||||
value
|
|
||||||
|
|
||||||
asGithubLink value =
|
asGithubLink value =
|
||||||
case Search.channelDetailsFromId channel of
|
case Search.channelDetailsFromId channel of
|
||||||
Just channelDetails ->
|
Just channelDetails ->
|
||||||
a
|
a
|
||||||
[ href <| githubUrlPrefix channelDetails.branch ++ (value |> String.replace ":" "#L" |> cleanPosition) ]
|
[ href <| githubUrlPrefix channelDetails.branch ++ (value |> String.replace ":" "#L" |> cleanPosition)
|
||||||
|
, target "_blank"
|
||||||
|
]
|
||||||
[ text <| cleanPosition value ]
|
[ text <| cleanPosition value ]
|
||||||
|
|
||||||
Nothing ->
|
Nothing ->
|
||||||
|
|
|
@ -264,6 +264,9 @@ type Channel
|
||||||
| Release_20_09
|
| Release_20_09
|
||||||
|
|
||||||
|
|
||||||
|
{-| TODO: we should consider using more dynamic approach here
|
||||||
|
and load channels from apis similar to what status page does
|
||||||
|
-}
|
||||||
type alias ChannelDetails =
|
type alias ChannelDetails =
|
||||||
{ id : String
|
{ id : String
|
||||||
, title : String
|
, title : String
|
||||||
|
|
Loading…
Reference in a new issue