From ecf71f5932fbd39550278e3b47dc6a15e43d8f85 Mon Sep 17 00:00:00 2001 From: Marek Fajkus Date: Tue, 24 Nov 2020 00:06:41 +0100 Subject: [PATCH] Fix links to github sources (#232) --- src/Page/Options.elm | 5 ++++- src/Page/Packages.elm | 15 ++++++++------- src/Search.elm | 3 +++ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/Page/Options.elm b/src/Page/Options.elm index 41409bd..ca5f649 100644 --- a/src/Page/Options.elm +++ b/src/Page/Options.elm @@ -33,6 +33,7 @@ import Html.Attributes ( class , colspan , href + , target ) import Html.Events exposing @@ -218,7 +219,9 @@ viewResultItemDetails channel item = case Search.channelDetailsFromId channel of Just channelDetails -> a - [ href <| githubUrlPrefix channelDetails.branch ++ (value |> String.replace ":" "#L") ] + [ href <| githubUrlPrefix channelDetails.branch ++ (value |> String.replace ":" "#L") + , target "_blank" + ] [ text <| value ] Nothing -> diff --git a/src/Page/Packages.elm b/src/Page/Packages.elm index 99ea000..db6f3fc 100644 --- a/src/Page/Packages.elm +++ b/src/Page/Packages.elm @@ -34,6 +34,7 @@ import Html.Attributes ( class , colspan , href + , target ) import Html.Events exposing @@ -248,18 +249,18 @@ viewResultItemDetails channel item = githubUrlPrefix branch = "https://github.com/NixOS/nixpkgs/blob/" ++ branch ++ "/" - cleanPosition value = - if String.startsWith "source/" value then - String.dropLeft 7 value - - else - value + cleanPosition = + Regex.fromString "^[0-9a-f]+\\.tar\\.gz\\/" + |> Maybe.withDefault Regex.never + >> (\reg -> Regex.replace reg (\_ -> "")) asGithubLink value = case Search.channelDetailsFromId channel of Just channelDetails -> a - [ href <| githubUrlPrefix channelDetails.branch ++ (value |> String.replace ":" "#L" |> cleanPosition) ] + [ href <| githubUrlPrefix channelDetails.branch ++ (value |> String.replace ":" "#L" |> cleanPosition) + , target "_blank" + ] [ text <| cleanPosition value ] Nothing -> diff --git a/src/Search.elm b/src/Search.elm index 03a4ea8..d1ef331 100644 --- a/src/Search.elm +++ b/src/Search.elm @@ -264,6 +264,9 @@ type Channel | 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 = { id : String , title : String