mirror of https://github.com/voidlizard/hbs2
wip
This commit is contained in:
parent
86a42c4d93
commit
ff94ef96f2
|
@ -23,8 +23,7 @@ import Data.Word
|
||||||
import Data.List qualified as List
|
import Data.List qualified as List
|
||||||
import Data.HashMap.Strict qualified as HM
|
import Data.HashMap.Strict qualified as HM
|
||||||
import Data.ByteString.Lazy
|
import Data.ByteString.Lazy
|
||||||
import Text.Pandoc
|
import Text.Pandoc hiding (getPOSIXTime)
|
||||||
import Text.Pandoc.Error (handleError)
|
|
||||||
import Text.InterpolatedString.Perl6 (qc)
|
import Text.InterpolatedString.Perl6 (qc)
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,8 +60,12 @@ onClickCopy :: Text -> Attribute
|
||||||
onClickCopy s =
|
onClickCopy s =
|
||||||
hyper_ [qc|on click writeText('{s}') into the navigator's clipboard add .clicked to me wait 2s remove .clicked from me|]
|
hyper_ [qc|on click writeText('{s}') into the navigator's clipboard add .clicked to me wait 2s remove .clicked from me|]
|
||||||
|
|
||||||
renderEntries :: Monad m => PluginMethod -> [(HashVal, Text, Text, Word64)] -> m ByteString
|
renderEntries :: MonadIO m => PluginMethod -> [(HashVal, Text, Text, Word64)] -> m ByteString
|
||||||
renderEntries (Method _ kw) items = pure $ renderBS do
|
renderEntries (Method _ kw) items = do
|
||||||
|
|
||||||
|
now <- liftIO getPOSIXTime <&> fromIntegral . round
|
||||||
|
|
||||||
|
pure $ renderBS do
|
||||||
|
|
||||||
-- TODO: ugly
|
-- TODO: ugly
|
||||||
let hrefBase = HM.lookup "URL_PREFIX" kw & List.singleton . maybe "/" Text.unpack
|
let hrefBase = HM.lookup "URL_PREFIX" kw & List.singleton . maybe "/" Text.unpack
|
||||||
|
@ -81,6 +84,9 @@ renderEntries (Method _ kw) items = pure $ renderBS do
|
||||||
|
|
||||||
for_ items $ \(h,n,b,t) -> do
|
for_ items $ \(h,n,b,t) -> do
|
||||||
|
|
||||||
|
let days = "updated" <+> if d == 0 then "today" else viaShow d <+> "days ago"
|
||||||
|
where d = ( now - t ) `div` 86400
|
||||||
|
|
||||||
let s = if Text.length n > 2 then n else "unnamed"
|
let s = if Text.length n > 2 then n else "unnamed"
|
||||||
let refpart = Text.take 8 $ Text.pack $ show $ pretty h
|
let refpart = Text.take 8 $ Text.pack $ show $ pretty h
|
||||||
let sref = show $ pretty h
|
let sref = show $ pretty h
|
||||||
|
@ -91,13 +97,18 @@ renderEntries (Method _ kw) items = pure $ renderBS do
|
||||||
let url = path (hrefBase <> suff)
|
let url = path (hrefBase <> suff)
|
||||||
|
|
||||||
div_ [class_ "repo-list-item"] do
|
div_ [class_ "repo-list-item"] do
|
||||||
div_ [class_ "repo-info"] do
|
div_ [class_ "repo-info", style_ "flex: 1; flex-basis: 70%;"] do
|
||||||
|
|
||||||
h2_ [class_ "xclip", onClickCopy ref] $ toHtml (s <> "-" <> refpart)
|
h2_ [class_ "xclip", onClickCopy ref] $ toHtml (s <> "-" <> refpart)
|
||||||
|
|
||||||
p_ $ a_ [href_ url] (toHtml ref)
|
p_ $ a_ [href_ url] (toHtml ref)
|
||||||
|
|
||||||
renderMarkdown b
|
renderMarkdown b
|
||||||
|
|
||||||
|
div_ [ class_ "attr" ] do
|
||||||
|
div_ [ class_ "attrname"] (toHtml $ show days)
|
||||||
|
|
||||||
|
|
||||||
wrapped :: Monad m => HtmlT m a -> HtmlT m a
|
wrapped :: Monad m => HtmlT m a -> HtmlT m a
|
||||||
wrapped f = do
|
wrapped f = do
|
||||||
doctypehtml_ do
|
doctypehtml_ do
|
||||||
|
@ -142,6 +153,18 @@ renderRepoHtml (Method _ kw) page@(GitRepoPage{..}) = pure $ renderBS $ wrapped
|
||||||
repoMenuItem mempty $ a_ [href_ hrefBase] "root"
|
repoMenuItem mempty $ a_ [href_ hrefBase] "root"
|
||||||
repoMenuItem0 mempty "manifest"
|
repoMenuItem0 mempty "manifest"
|
||||||
|
|
||||||
|
section_ [] do
|
||||||
|
|
||||||
|
div_ [class_ "attr"] do
|
||||||
|
|
||||||
|
let ref = headDef "" [ r | GitLwwRef r <- universeBi page ]
|
||||||
|
& Text.pack . show . pretty
|
||||||
|
|
||||||
|
div_ [class_ "attrname"] "reference"
|
||||||
|
|
||||||
|
div_ [class_ "attrval", style_ "align: left; width: 20rem;"] do
|
||||||
|
span_ [class_ "xclip", onClickCopy ref] (toHtml ref)
|
||||||
|
|
||||||
section_ [id_ "repo-data"] do
|
section_ [id_ "repo-data"] do
|
||||||
for_ name' $ \name -> do
|
for_ name' $ \name -> do
|
||||||
h1_ (toHtml name)
|
h1_ (toHtml name)
|
||||||
|
|
|
@ -92,6 +92,7 @@ common shared-properties
|
||||||
, random
|
, random
|
||||||
, vector
|
, vector
|
||||||
, unix
|
, unix
|
||||||
|
, friendly-time
|
||||||
|
|
||||||
|
|
||||||
library
|
library
|
||||||
|
|
|
@ -229,18 +229,20 @@ div .repo-list-item {
|
||||||
|
|
||||||
.attr {
|
.attr {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
gap: 2rem;
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
|
padding-right: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.attrname, .attribute-value {
|
.attrname, {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
margin-right: 0.5em;
|
margin-right: 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.attrval {
|
.attrval {
|
||||||
text-align: right;
|
text-align: left;
|
||||||
font-weight: bold;
|
flex-basis: 70%;
|
||||||
flex-basis: 30%;
|
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,19 +265,30 @@ form.search button {
|
||||||
}
|
}
|
||||||
|
|
||||||
.xclip::after {
|
.xclip::after {
|
||||||
content: "";
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
height: 16px;
|
content: url('/icon/xclip.svg');
|
||||||
width: 16px;
|
vertical-align: middle;
|
||||||
vertical-align: top;
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
opacity: 0;
|
||||||
|
transition: opacity 0.2s;
|
||||||
|
left: 16px;
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.xclip:hover::after {
|
.xclip:hover::after {
|
||||||
|
left: 16px;
|
||||||
|
position: relative;
|
||||||
content: url('/icon/xclip.svg');
|
content: url('/icon/xclip.svg');
|
||||||
margin-left: 1rem;
|
vertical-align: middle;
|
||||||
height: 24x;
|
height: 24x;
|
||||||
width: 24x;
|
width: 24x;
|
||||||
vertical-align: top;
|
opacity: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.xclip {
|
||||||
|
/*position: relative;*/
|
||||||
|
text-decoration: underline dotted;
|
||||||
}
|
}
|
||||||
|
|
||||||
.xclip:hover {
|
.xclip:hover {
|
||||||
|
@ -284,10 +297,11 @@ form.search button {
|
||||||
|
|
||||||
.clicked:hover::after {
|
.clicked:hover::after {
|
||||||
content: url('/icon/xclipdone.svg');
|
content: url('/icon/xclipdone.svg');
|
||||||
margin-left: 1rem;
|
vertical-align: middle;
|
||||||
height: 24px;
|
right: 16px;
|
||||||
|
height: 24x;
|
||||||
width: 24x;
|
width: 24x;
|
||||||
vertical-align: top;
|
opacity: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
nav[role="tab-control"] {
|
nav[role="tab-control"] {
|
||||||
|
|
Loading…
Reference in New Issue