From 04b81a278d05839a0779bba2a372c3d9744a3fd3 Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Wed, 24 Apr 2024 09:44:13 +0300 Subject: [PATCH] wip --- .../src/HBS2/Git/Web/Html/Root.hs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hbs2-git/hbs2-git-dashboard/src/HBS2/Git/Web/Html/Root.hs b/hbs2-git/hbs2-git-dashboard/src/HBS2/Git/Web/Html/Root.hs index 119df945..26768d45 100644 --- a/hbs2-git/hbs2-git-dashboard/src/HBS2/Git/Web/Html/Root.hs +++ b/hbs2-git/hbs2-git-dashboard/src/HBS2/Git/Web/Html/Root.hs @@ -746,7 +746,7 @@ repoCommits lww predicate' = do , hxGet_ (toURL (RepoCommitDefault lww hash)) , hxTarget_ "#repo-tab-data" , hxPushUrl_ (toURL query) - ] (toHtml $ take 10 (show $ pretty hash) <> "..") + ] $ toHtml (ShortRef hash) td_ [class_ "commit-brief-title"] do toHtml $ normalizeText $ coerce @_ @Text commitListTitle @@ -859,15 +859,20 @@ itemNotFound s = StatusError status404 (Text.pack $ show $ pretty s) newtype ShortRef a = ShortRef a -shortRef :: String -> String -shortRef a = [qc|{b}..{r}|] +shortRef :: Int -> Int -> String -> String +shortRef n k a = if k > 0 then [qc|{b}..{r}|] else [qc|{b}|] where - b = take 18 a - r = reverse $ take 2 (reverse a) + b = take n a + r = reverse $ take k (reverse a) + +instance ToHtml (ShortRef GitHash) where + toHtml (ShortRef a) = toHtml (shortRef 10 0 (show $ pretty a)) + toHtmlRaw (ShortRef a) = toHtml (shortRef 10 0 (show $ pretty a)) + +instance ToHtml (ShortRef (LWWRefKey 'HBS2Basic)) where + toHtml (ShortRef a) = toHtml (shortRef 14 3 (show $ pretty a)) + toHtmlRaw (ShortRef a) = toHtml (shortRef 14 3 (show $ pretty a)) -instance Pretty a => ToHtml (ShortRef a) where - toHtml (ShortRef a) = toHtml (shortRef (show $ pretty a)) - toHtmlRaw (ShortRef a) = toHtml (shortRef (show $ pretty a)) repoPage :: (MonadIO m, DashBoardPerks m, MonadReader DashBoardEnv m) => RepoPageTabs