some icons

This commit is contained in:
Dmitry Zuikov 2024-04-21 06:18:47 +03:00
parent d738cbb9e4
commit 9fdab9aaeb
15 changed files with 159 additions and 26 deletions

View File

@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-file-filled"
width="20" height="20"
viewBox="0 0 24 24" stroke-width="1.5" stroke="#000000" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M12 2l.117 .007a1 1 0 0 1 .876 .876l.007 .117v4l.005 .15a2 2 0 0 0 1.838 1.844l.157 .006h4l.117 .007a1 1 0 0 1 .876 .876l.007 .117v9a3 3 0 0 1 -2.824 2.995l-.176 .005h-10a3 3 0 0 1 -2.995 -2.824l-.005 -.176v-14a3 3 0 0 1 2.824 -2.995l.176 -.005h5z" stroke-width="0" fill="currentColor" />
<path d="M19 7h-4l-.001 -4.001z" stroke-width="0" fill="currentColor" />
</svg>

After

Width:  |  Height:  |  Size: 679 B

View File

@ -0,0 +1,8 @@
<svg xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-settings-filled"
width="20" height="20"
viewBox="0 0 24 24" stroke-width="1.5" stroke="#000000" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M14.647 4.081a.724 .724 0 0 0 1.08 .448c2.439 -1.485 5.23 1.305 3.745 3.744a.724 .724 0 0 0 .447 1.08c2.775 .673 2.775 4.62 0 5.294a.724 .724 0 0 0 -.448 1.08c1.485 2.439 -1.305 5.23 -3.744 3.745a.724 .724 0 0 0 -1.08 .447c-.673 2.775 -4.62 2.775 -5.294 0a.724 .724 0 0 0 -1.08 -.448c-2.439 1.485 -5.23 -1.305 -3.745 -3.744a.724 .724 0 0 0 -.447 -1.08c-2.775 -.673 -2.775 -4.62 0 -5.294a.724 .724 0 0 0 .448 -1.08c-1.485 -2.439 1.305 -5.23 3.744 -3.745a.722 .722 0 0 0 1.08 -.447c.673 -2.775 4.62 -2.775 5.294 0zm-2.647 4.919a3 3 0 1 0 0 6a3 3 0 0 0 0 -6z" stroke-width="0" fill="currentColor" />
</svg>

After

Width:  |  Height:  |  Size: 908 B

View File

@ -0,0 +1,3 @@
<svg role="img" withd="20" height="20" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<title>Haskell</title>
<path d="M0 3.535L5.647 12 0 20.465h4.235L9.883 12 4.235 3.535zm5.647 0L11.294 12l-5.647 8.465h4.235l3.53-5.29 3.53 5.29h4.234L9.883 3.535zm8.941 4.938l1.883 2.822H24V8.473zm2.824 4.232l1.882 2.822H24v-2.822z"/></svg>

After

Width:  |  Height:  |  Size: 336 B

View File

@ -0,0 +1,8 @@
<svg role="img"
viewBox="0 0 24 24"
width="20"
height="20"
xmlns="http://www.w3.org/2000/svg">
<title>JavaScript</title>
<path d="M0 0h24v24H0V0zm22.034 18.276c-.175-1.095-.888-2.015-3.003-2.873-.736-.345-1.554-.585-1.797-1.14-.091-.33-.105-.51-.046-.705.15-.646.915-.84 1.515-.66.39.12.75.42.976.9 1.034-.676 1.034-.676 1.755-1.125-.27-.42-.404-.601-.586-.78-.63-.705-1.469-1.065-2.834-1.034l-.705.089c-.676.165-1.32.525-1.71 1.005-1.14 1.291-.811 3.541.569 4.471 1.365 1.02 3.361 1.244 3.616 2.205.24 1.17-.87 1.545-1.966 1.41-.811-.18-1.26-.586-1.755-1.336l-1.83 1.051c.21.48.45.689.81 1.109 1.74 1.756 6.09 1.666 6.871-1.004.029-.09.24-.705.074-1.65l.046.067zm-8.983-7.245h-2.248c0 1.938-.009 3.864-.009 5.805 0 1.232.063 2.363-.138 2.711-.33.689-1.18.601-1.566.48-.396-.196-.597-.466-.83-.855-.063-.105-.11-.196-.127-.196l-1.825 1.125c.305.63.75 1.172 1.324 1.517.855.51 2.004.675 3.207.405.783-.226 1.458-.691 1.811-1.411.51-.93.402-2.07.397-3.346.012-2.054 0-4.109 0-6.179l.004-.056z"/>
</svg>

After

Width:  |  Height:  |  Size: 1021 B

View File

@ -0,0 +1,7 @@
<svg role="img"
viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"
height="20"
withd="20"
>
<title>Markdown</title>
<path d="M22.27 19.385H1.73A1.73 1.73 0 010 17.655V6.345a1.73 1.73 0 011.73-1.73h20.54A1.73 1.73 0 0124 6.345v11.308a1.73 1.73 0 01-1.73 1.731zM5.769 15.923v-4.5l2.308 2.885 2.307-2.885v4.5h2.308V8.078h-2.308l-2.307 2.885-2.308-2.885H3.46v7.847zM21.232 12h-2.309V8.077h-2.307V12h-2.308l3.461 4.039z"/></svg>

After

Width:  |  Height:  |  Size: 448 B

View File

@ -0,0 +1,8 @@
<svg
role="img"
viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"
height="20"
width="20"
>
<title>NixOS</title>
<path d="M7.352 1.592l-1.364.002L5.32 2.75l1.557 2.713-3.137-.008-1.32 2.34H14.11l-1.353-2.332-3.192-.006-2.214-3.865zm6.175 0l-2.687.025 5.846 10.127 1.341-2.34-1.59-2.765 2.24-3.85-.683-1.182h-1.336l-1.57 2.705-1.56-2.72zm6.887 4.195l-5.846 10.125 2.696-.008 1.601-2.76 4.453.016.682-1.183-.666-1.157-3.13-.008L21.778 8.1l-1.365-2.313zM9.432 8.086l-2.696.008-1.601 2.76-4.453-.016L0 12.02l.666 1.157 3.13.008-1.575 2.71 1.365 2.315L9.432 8.086zM7.33 12.25l-.006.01-.002-.004-1.342 2.34 1.59 2.765-2.24 3.85.684 1.182H7.35l.004-.006h.001l1.567-2.698 1.558 2.72 2.688-.026-.004-.006h.01L7.33 12.25zm2.55 3.93l1.354 2.332 3.192.006 2.215 3.865 1.363-.002.668-1.156-1.557-2.713 3.137.008 1.32-2.34H9.881Z"/></svg>

After

Width:  |  Height:  |  Size: 843 B

View File

@ -0,0 +1,4 @@
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"
width="20" height="20">
<title>Python</title>
<path d="M14.25.18l.9.2.73.26.59.3.45.32.34.34.25.34.16.33.1.3.04.26.02.2-.01.13V8.5l-.05.63-.13.55-.21.46-.26.38-.3.31-.33.25-.35.19-.35.14-.33.1-.3.07-.26.04-.21.02H8.77l-.69.05-.59.14-.5.22-.41.27-.33.32-.27.35-.2.36-.15.37-.1.35-.07.32-.04.27-.02.21v3.06H3.17l-.21-.03-.28-.07-.32-.12-.35-.18-.36-.26-.36-.36-.35-.46-.32-.59-.28-.73-.21-.88-.14-1.05-.05-1.23.06-1.22.16-1.04.24-.87.32-.71.36-.57.4-.44.42-.33.42-.24.4-.16.36-.1.32-.05.24-.01h.16l.06.01h8.16v-.83H6.18l-.01-2.75-.02-.37.05-.34.11-.31.17-.28.25-.26.31-.23.38-.2.44-.18.51-.15.58-.12.64-.1.71-.06.77-.04.84-.02 1.27.05zm-6.3 1.98l-.23.33-.08.41.08.41.23.34.33.22.41.09.41-.09.33-.22.23-.34.08-.41-.08-.41-.23-.33-.33-.22-.41-.09-.41.09zm13.09 3.95l.28.06.32.12.35.18.36.27.36.35.35.47.32.59.28.73.21.88.14 1.04.05 1.23-.06 1.23-.16 1.04-.24.86-.32.71-.36.57-.4.45-.42.33-.42.24-.4.16-.36.09-.32.05-.24.02-.16-.01h-8.22v.82h5.84l.01 2.76.02.36-.05.34-.11.31-.17.29-.25.25-.31.24-.38.2-.44.17-.51.15-.58.13-.64.09-.71.07-.77.04-.84.01-1.27-.04-1.07-.14-.9-.2-.73-.25-.59-.3-.45-.33-.34-.34-.25-.34-.16-.33-.1-.3-.04-.25-.02-.2.01-.13v-5.34l.05-.64.13-.54.21-.46.26-.38.3-.32.33-.24.35-.2.35-.14.33-.1.3-.06.26-.04.21-.02.13-.01h5.84l.69-.05.59-.14.5-.21.41-.28.33-.32.27-.35.2-.36.15-.36.1-.35.07-.32.04-.28.02-.21V6.07h2.09l.14.01zm-6.47 14.25l-.23.33-.08.41.08.41.23.33.33.23.41.08.41-.08.33-.23.23-.33.08-.41-.08-.41-.23-.33-.33-.23-.41-.08-.41.08z"/></svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-file-type-sql" width="20" height="20" viewBox="0 0 24 24" stroke-width="1.5" stroke="#000000" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
<path d="M14 3v4a1 1 0 0 0 1 1h4" />
<path d="M5 20.25c0 .414 .336 .75 .75 .75h1.25a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1a1 1 0 0 1 -1 -1v-1a1 1 0 0 1 1 -1h1.25a.75 .75 0 0 1 .75 .75" />
<path d="M5 12v-7a2 2 0 0 1 2 -2h7l5 5v4" />
<path d="M18 15v6h2" />
<path d="M13 15a2 2 0 0 1 2 2v2a2 2 0 1 1 -4 0v-2a2 2 0 0 1 2 -2z" />
<path d="M14 20l1.5 1.5" />
</svg>

After

Width:  |  Height:  |  Size: 695 B

View File

@ -0,0 +1,9 @@
<svg xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-terminal-2"
width="20" height="20" viewBox="0 0 24 24"
stroke-width="1.5" stroke="#000000" fill="none" stroke-linecap="round" stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M8 9l3 3l-3 3" />
<path d="M13 15l3 0" />
<path d="M3 4m0 2a2 2 0 0 1 2 -2h14a2 2 0 0 1 2 2v12a2 2 0 0 1 -2 2h-14a2 2 0 0 1 -2 -2z" />
</svg>

After

Width:  |  Height:  |  Size: 444 B

View File

@ -1,4 +1,15 @@
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-arrow-big-up" width="24" height="24" viewBox="0 0 24 24" stroke-width="1" stroke="#2c3e50" fill="none" stroke-linecap="round" stroke-linejoin="round"> <svg xmlns="http://www.w3.org/2000/svg"
class="icon icon-tabler icon-tabler-arrow-back-up"
width="20"
height="20"
viewBox="0 0 24 24"
stroke-width="2"
stroke="#000000"
fill="none"
stroke-linecap="round"
stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/> <path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M9 20v-8h-3.586a1 1 0 0 1 -.707 -1.707l6.586 -6.586a1 1 0 0 1 1.414 0l6.586 6.586a1 1 0 0 1 -.707 1.707h-3.586v8a1 1 0 0 1 -1 1h-4a1 1 0 0 1 -1 -1z" /> <path d="M9 14l-4 -4l4 -4" />
<path d="M5 10h11a4 4 0 1 1 0 8h-1" />
</svg> </svg>

Before

Width:  |  Height:  |  Size: 451 B

After

Width:  |  Height:  |  Size: 399 B

View File

@ -0,0 +1,7 @@
<svg role="img"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
height="20"
withd="20" >
<title>YAML</title>
<path d="m0 .97 4.111 6.453v4.09h2.638v-4.09L11.053.969H8.214L5.58 5.125 2.965.969Zm12.093.024-4.47 10.544h2.114l.97-2.345h4.775l.804 2.345h2.26L14.255.994Zm1.133 2.225 1.463 3.87h-3.096zm3.06 9.475v10.29H24v-2.199h-5.454v-8.091zm-12.175.002v10.335h2.217v-7.129l2.32 4.792h1.746l2.4-4.96v7.295h2.127V12.696h-2.904L9.44 17.37l-2.455-4.674Z"/></svg>

After

Width:  |  Height:  |  Size: 484 B

View File

@ -232,10 +232,9 @@ runDashboardWeb wo = do
hash <- hash' & orFall (status status404) hash <- hash' & orFall (status status404)
co <- co' & orFall (status status404) co <- co' & orFall (status status404)
tree <- lift $ gitShowTree lww hash tree <- lift $ gitShowTree lww hash
back <- lift $ selectParentTree co hash back <- lift $ selectParentTree (TreeCommit co) (TreeTree hash)
debug $ "selectParentTree" <+> pretty co <+> pretty hash <+> pretty back debug $ "selectParentTree" <+> pretty co <+> pretty hash <+> pretty back
lift $ html =<< renderTextT (repoTree lww co hash tree back) lift $ html =<< renderTextT (repoTree lww co hash tree (coerce <$> back))
repoDataPath :: (DashBoardPerks m, MonadReader DashBoardEnv m) => LWWRefKey 'HBS2Basic -> m FilePath repoDataPath :: (DashBoardPerks m, MonadReader DashBoardEnv m) => LWWRefKey 'HBS2Basic -> m FilePath
repoDataPath lw = asks _dataDir <&> (</> (show $ pretty lw)) >>= canonicalizePath repoDataPath lw = asks _dataDir <&> (</> (show $ pretty lw)) >>= canonicalizePath

View File

@ -443,9 +443,11 @@ createRepoTreeIndexTable = do
ddl [qc| ddl [qc|
create table if not exists tree create table if not exists tree
( parent text not null ( parent text not null
, child text not null , tree text not null
, kommit text not null , kommit text not null
, primary key (parent,child,kommit) , level int not null
, path text not null
, primary key (parent,tree,kommit)
) )
|] |]
@ -463,23 +465,42 @@ insertProcessed href = do
on conflict(hash) do nothing on conflict(hash) do nothing
|] (Only href) |] (Only href)
insertTree :: (DashBoardPerks m) => GitHash -> GitHash -> GitHash -> DBPipeM m ()
insertTree commit parent child = do newtype TreeCommit = TreeCommit GitHash
deriving newtype (FromField,ToField,Pretty)
newtype TreeParent = TreeParent GitHash
deriving newtype (FromField,ToField,Pretty)
newtype TreeTree = TreeTree GitHash
deriving newtype (FromField,ToField,Pretty)
newtype TreeLevel = TreeLevel Int
deriving newtype (FromField,ToField,Pretty,Num,Enum)
newtype TreePath = TreePath FilePath
deriving newtype (FromField,ToField,Pretty)
insertTree :: (DashBoardPerks m)
=> (TreeCommit,TreeParent,TreeTree,TreeLevel,TreePath)
-> DBPipeM m ()
insertTree (commit,parent,tree,level,path) = do
S.insert [qc| S.insert [qc|
insert into tree (parent,child,kommit) insert into tree (parent,tree,kommit,level,path)
values (?,?,?) values (?,?,?,?,?)
on conflict (parent,child,kommit) do nothing on conflict (parent,tree,kommit)
|] (parent,child,commit) do update set level = excluded.level
, path = excluded.path
|] (parent,tree,commit,level,path)
selectParentTree :: (DashBoardPerks m, MonadReader DashBoardEnv m) => GitHash -> GitHash -> m (Maybe GitHash) selectParentTree :: (DashBoardPerks m, MonadReader DashBoardEnv m)
=> TreeCommit
-> TreeTree
-> m (Maybe TreeParent)
selectParentTree co me = withState do selectParentTree co me = withState do
w <- select [qc|select coalesce(parent,kommit) from tree where child = ? and kommit = ?|] (me,co) select [qc|select parent from tree where tree = ? and kommit = ?|] (me,co)
<&> listToMaybe . fmap fromOnly <&> listToMaybe . fmap fromOnly
if co == me then
pure Nothing
else do
pure $ w <|> Just co
{- HLINT ignore "Functor law" -} {- HLINT ignore "Functor law" -}
@ -530,7 +551,7 @@ buildCommitTreeIndex dir = do
for_ (Map.toList trees) $ \(t,h0) -> do for_ (Map.toList trees) $ \(t,h0) -> do
case t of case t of
[_] -> insertTree co root h0 [x] -> insertTree (TreeCommit co,TreeParent root,TreeTree h0,1,TreePath x)
_ -> pure () _ -> pure ()
let child = tailSafe t let child = tailSafe t
@ -539,7 +560,13 @@ buildCommitTreeIndex dir = do
for_ parent $ \p -> do for_ parent $ \p -> do
debug $ red "FOUND SHIT:" <+> pretty (h0,p) debug $ red "FOUND SHIT:" <+> pretty (h0,p)
insertTree co p h0 insertTree ( TreeCommit co
, TreeParent p
, TreeTree h0
, TreeLevel (length t)
, TreePath (headDef "" t)
)
-- insertTree co p h0
insertProcessed hkey insertProcessed hkey

View File

@ -23,6 +23,8 @@ import Safe
import Data.List (sortOn) import Data.List (sortOn)
import Data.Ord (comparing, Down(..)) import Data.Ord (comparing, Down(..))
import Skylighting.Core qualified as Sky
import Skylighting qualified as Sky
import Streaming.Prelude qualified as S import Streaming.Prelude qualified as S
@ -223,6 +225,8 @@ repoTree :: (DashBoardPerks m, MonadReader DashBoardEnv m)
repoTree lww co root tree back' = do repoTree lww co root tree back' = do
let syntaxMap = Sky.defaultSyntaxMap
let co_ = show $ pretty co let co_ = show $ pretty co
let sorted = sortOn (\(tp, _, name) -> (tpOrder tp, name)) tree let sorted = sortOn (\(tp, _, name) -> (tpOrder tp, name)) tree
@ -249,9 +253,26 @@ repoTree lww co root tree back' = do
let uri = path [ "repo", show $ pretty lww, "tree", co_, hash_ ] let uri = path [ "repo", show $ pretty lww, "tree", co_, hash_ ]
tr_ mempty do tr_ mempty do
td_ $ case tp of td_ $ case tp of
Blob -> img_ [src_ "/icon/blob.svg"] Commit -> mempty
Tree -> img_ [src_ "/icon/tree.svg"] Tree -> img_ [src_ "/icon/tree.svg"]
_ -> mempty Blob -> do
let syn = Sky.syntaxesByFilename syntaxMap (Text.unpack name)
& headMay
<&> Text.toLower . Sky.sName
let icon = case syn of
Just "haskell" -> [src_ "/icon/haskell.svg"]
Just "markdown" -> [src_ "/icon/markdown.svg"]
Just "nix" -> [src_ "/icon/nixos.svg"]
Just "bash" -> [src_ "/icon/terminal.svg"]
Just "python" -> [src_ "/icon/python.svg"]
Just "javascript" -> [src_ "/icon/javascript.svg"]
Just "sql" -> [src_ "/icon/sql.svg"]
Just s | s `elem` ["cabal","makefile","toml","ini","yaml"]
-> [src_ "/icon/gear.svg"]
_ -> [src_ "/icon/blob-filled.svg"]
img_ ([alt_ (fromMaybe "blob" syn)] <> icon)
td_ [class_ itemClass] (toHtml $ show $ pretty name) td_ [class_ itemClass] (toHtml $ show $ pretty name)
td_ [class_ "mono"] do td_ [class_ "mono"] do

View File

@ -171,6 +171,9 @@ executable hbs2-git-dashboard
, lucid , lucid
, lucid-htmx , lucid-htmx
, pandoc , pandoc
, skylighting
, skylighting-core
, skylighting-lucid
, scotty >= 0.22 , scotty >= 0.22
hs-source-dirs: hs-source-dirs: