mirror of https://github.com/voidlizard/hbs2
hbs2-browser plugin basically works
This commit is contained in:
parent
073e8e4579
commit
ee0d25716f
|
@ -32,16 +32,8 @@ renderMarkdown markdown = case markdownToHtml markdown of
|
||||||
renderEntries :: Monad m => HashMap Text Text -> [(HashVal, Text, Text, Word64)] -> m ByteString
|
renderEntries :: Monad m => HashMap Text Text -> [(HashVal, Text, Text, Word64)] -> m ByteString
|
||||||
renderEntries args items = pure $ renderBS do
|
renderEntries args items = pure $ renderBS do
|
||||||
wrapped do
|
wrapped do
|
||||||
|
|
||||||
div_ [class_ "container main"] $ do
|
|
||||||
nav_ [class_ "left"] $ do
|
|
||||||
div_ [class_ "info-block"] "Всякая разная рандомная информация хрен знает, что тут пока выводить"
|
|
||||||
div_ [class_ "info-block"] "Всякая разная рандомная информация хрен знает, что тут пока выводить"
|
|
||||||
|
|
||||||
main_ do
|
main_ do
|
||||||
|
|
||||||
div_ [class_ "container"] do
|
|
||||||
|
|
||||||
section_ do
|
section_ do
|
||||||
h1_ "Git repositories"
|
h1_ "Git repositories"
|
||||||
form_ [class_ "search"] do
|
form_ [class_ "search"] do
|
||||||
|
@ -53,33 +45,25 @@ renderEntries args items = pure $ renderBS do
|
||||||
|
|
||||||
for_ items $ \(h,n,b,t) -> do
|
for_ items $ \(h,n,b,t) -> do
|
||||||
|
|
||||||
-- let name = if Text.length n > 2 then toHtml (n <> "-" <>) else toHtml (show $ pretty h)
|
let s = if Text.length n > 2 then n else "unnamed"
|
||||||
|
let refpart = Text.take 8 $ Text.pack $ show $ pretty h
|
||||||
let name = mempty
|
|
||||||
|
|
||||||
div_ [class_ "repo-list-item"] do
|
div_ [class_ "repo-list-item"] do
|
||||||
div_ [class_ "repo-info"] do
|
div_ [class_ "repo-info"] do
|
||||||
h2_ $ a_ [href_ ""] name
|
h2_ $ a_ [href_ ""] $ toHtml (s <> "-" <> refpart)
|
||||||
|
|
||||||
a_ [href_ ""] (toHtml (show $ pretty h))
|
a_ [href_ ""] (toHtml (show $ pretty h))
|
||||||
|
|
||||||
renderMarkdown b
|
renderMarkdown b
|
||||||
|
|
||||||
|
|
||||||
-- h3_ [class_ "repo-name"] name
|
|
||||||
|
|
||||||
-- div_ [class_ "repo-brief"] do
|
|
||||||
-- renderMarkdown b
|
|
||||||
|
|
||||||
-- div_ [class_ "repo-reference"] $ a_ [] (toHtml (show $ pretty h))
|
|
||||||
|
|
||||||
where
|
where
|
||||||
|
|
||||||
wrapped f | not (HM.member "HTML_WRAPPED" args) = div_ f
|
-- wrapped f | not (HM.member "HTML_WRAPPED" args) = div_ f
|
||||||
| otherwise = do
|
-- | otherwise = do
|
||||||
doctypehtml_ do
|
wrapped f = do
|
||||||
head_ mempty do
|
doctypehtml_ do
|
||||||
meta_ [charset_ "utf-8"]
|
head_ mempty do
|
||||||
|
meta_ [charset_ "utf-8"]
|
||||||
|
|
||||||
body_ mempty f
|
body_ mempty f
|
||||||
|
|
||||||
|
|
|
@ -240,7 +240,7 @@ instance (MonadUnliftIO m, HasOracleEnv m) => HandleMethod m RpcChannelQuery whe
|
||||||
|
|
||||||
formatJson items = do
|
formatJson items = do
|
||||||
let root = object [ "rows" .= items
|
let root = object [ "rows" .= items
|
||||||
, "desc" .= [ "entity", "name", "brief" ]
|
, "desc" .= [ "entity", "name", "brief", "timestamp" ]
|
||||||
]
|
]
|
||||||
|
|
||||||
pure $ Just $ A.encodePretty root
|
pure $ Just $ A.encodePretty root
|
||||||
|
|
|
@ -19,9 +19,12 @@ import Lucid (Html,HtmlT,toHtml,toHtmlRaw)
|
||||||
import Lucid.Html5 hiding (for_)
|
import Lucid.Html5 hiding (for_)
|
||||||
import Data.Text qualified as Text
|
import Data.Text qualified as Text
|
||||||
import Text.InterpolatedString.Perl6 (q)
|
import Text.InterpolatedString.Perl6 (q)
|
||||||
|
import Data.ByteString.Lazy.Char8 qualified as LBS
|
||||||
import System.FilePath
|
import System.FilePath
|
||||||
import Control.Monad
|
import Control.Monad
|
||||||
|
|
||||||
|
import Text.HTML.TagSoup
|
||||||
|
|
||||||
import UnliftIO
|
import UnliftIO
|
||||||
|
|
||||||
rootPath :: [String] -> [String]
|
rootPath :: [String] -> [String]
|
||||||
|
@ -35,7 +38,7 @@ myCss = style_ $ [q|
|
||||||
|
|
||||||
input, button {
|
input, button {
|
||||||
font-size: var(--form-element-font-size);
|
font-size: var(--form-element-font-size);
|
||||||
height: 2rem;
|
height: 2.5rem;
|
||||||
padding: 0.25rem 0.5rem;
|
padding: 0.25rem 0.5rem;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
|
@ -43,7 +46,7 @@ input, button {
|
||||||
|
|
||||||
input[type="search"] {
|
input[type="search"] {
|
||||||
font-size: var(--form-element-font-size);
|
font-size: var(--form-element-font-size);
|
||||||
height: 2rem;
|
height: 2.5rem;
|
||||||
padding: 0.25rem 0.5rem;
|
padding: 0.25rem 0.5rem;
|
||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
border: 1px solid #ccc;
|
border: 1px solid #ccc;
|
||||||
|
@ -53,6 +56,7 @@ input[type="search"] {
|
||||||
body, html {
|
body, html {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
header {
|
header {
|
||||||
|
@ -60,13 +64,21 @@ header {
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 1rem;
|
|
||||||
|
padding: 8px;
|
||||||
|
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
z-index: 100;
|
z-index: 100;
|
||||||
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
|
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
|
||||||
height: 64px;
|
}
|
||||||
|
|
||||||
|
/* height: 64px; */
|
||||||
|
|
||||||
|
header h1 {
|
||||||
|
font-size: 1.45rem;
|
||||||
|
margin: 0 0 0 2.21rem;
|
||||||
|
font-weight: 500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header-title {
|
.header-title {
|
||||||
|
@ -104,13 +116,10 @@ nav.left {
|
||||||
main {
|
main {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
padding: 2rem 0 0 4rem;
|
padding: 2rem 0 0 4rem;
|
||||||
height: calc(100vh - 64px);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
header h1 {
|
|
||||||
font-size: 16pt;
|
/* height: calc(100vh - 64px); */
|
||||||
margin-left: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
section {
|
section {
|
||||||
margin-top: 1rem;
|
margin-top: 1rem;
|
||||||
|
@ -124,11 +133,11 @@ section {
|
||||||
}
|
}
|
||||||
|
|
||||||
main h1 {
|
main h1 {
|
||||||
font-size: 24pt;
|
font-size: 1.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
main h2 {
|
main h2 {
|
||||||
font-size: 18pt;
|
font-size: 1.45rem;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,11 +169,17 @@ div .repo-list-item {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.repo-info h2 a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
.repo-info-misc {
|
.repo-info-misc {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
font-size: 0.85rem;
|
font-size: 0.85rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.attr {
|
.attr {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
|
@ -217,7 +232,7 @@ rootPage content = do
|
||||||
|
|
||||||
body_ do
|
body_ do
|
||||||
header_ do
|
header_ do
|
||||||
div_ [class_ "header-title"] $ strong_ "hbs2-peer dashboard"
|
div_ [class_ "header-title"] $ h1_ "hbs2-peer dashboard"
|
||||||
content
|
content
|
||||||
|
|
||||||
|
|
||||||
|
@ -275,6 +290,24 @@ channelPage api env' = do
|
||||||
<&> join
|
<&> join
|
||||||
<&> fromMaybe mempty
|
<&> fromMaybe mempty
|
||||||
|
|
||||||
rootPage $ toHtmlRaw r
|
let str = LBS.unpack r
|
||||||
|
|
||||||
|
rootPage $ do
|
||||||
|
|
||||||
|
div_ [class_ "container main"] $ do
|
||||||
|
nav_ [class_ "left"] $ do
|
||||||
|
div_ [class_ "info-block"] "Всякая разная рандомная информация хрен знает, что тут пока выводить"
|
||||||
|
div_ [class_ "info-block"] "Всякая разная рандомная информация хрен знает, что тут пока выводить"
|
||||||
|
|
||||||
|
main_ do
|
||||||
|
toHtmlRaw (extractBodyHtml str)
|
||||||
|
|
||||||
|
where
|
||||||
|
extractBodyHtml :: String -> String
|
||||||
|
extractBodyHtml html =
|
||||||
|
let tags = parseTags html
|
||||||
|
bodyTags = takeWhile (~/= "</main>") . dropWhile (~/= "<main>") $ tags
|
||||||
|
-- Убираем начальный и конечный тег <body>, если это необходимо
|
||||||
|
contentTags = drop 1 $ take (length bodyTags - 1) bodyTags
|
||||||
|
in renderTags contentTags
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ common common-deps
|
||||||
, stm
|
, stm
|
||||||
, streaming
|
, streaming
|
||||||
, sqlite-simple
|
, sqlite-simple
|
||||||
|
, tagsoup
|
||||||
, time
|
, time
|
||||||
, temporary
|
, temporary
|
||||||
, text
|
, text
|
||||||
|
@ -209,6 +210,7 @@ test-suite test
|
||||||
, serialise
|
, serialise
|
||||||
, stm
|
, stm
|
||||||
, streaming
|
, streaming
|
||||||
|
, tagsoup
|
||||||
, tasty
|
, tasty
|
||||||
, tasty-quickcheck
|
, tasty-quickcheck
|
||||||
, tasty-hunit
|
, tasty-hunit
|
||||||
|
|
Loading…
Reference in New Issue