mirror of https://github.com/voidlizard/hbs2
wip
This commit is contained in:
parent
90c3ea2bf0
commit
89f81f6c0e
|
@ -0,0 +1,89 @@
|
||||||
|
header {
|
||||||
|
background-color: #f8f9fa;
|
||||||
|
padding: 10px 0;
|
||||||
|
text-align: left;
|
||||||
|
border-bottom: 1px solid #eaeaea;
|
||||||
|
margin-bottom: 30px;
|
||||||
|
}
|
||||||
|
|
||||||
|
header h1 {
|
||||||
|
color: #333;
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: 400;
|
||||||
|
padding: 10px 20px;
|
||||||
|
/* font-weight: 300; */
|
||||||
|
margin: 0;
|
||||||
|
text-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-size: 0.725rem; /* Уменьшаем размер шрифта, если он кажется слишком большим */
|
||||||
|
}
|
||||||
|
|
||||||
|
button.primary, button.secondary, button.success {
|
||||||
|
padding: 0.5rem 1rem; /* Уменьшаем отступы */
|
||||||
|
font-size: 0.75rem; /* Уменьшаем размер шрифта в кнопке */
|
||||||
|
line-height: 1.2; /* Опционально можно установить высоту строки */
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-container {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap; /* Элементы будут переноситься на следующую строку при нехватке места */
|
||||||
|
gap: 1rem; /* Отступ между элементами */
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-item {
|
||||||
|
padding: 1rem; /* добавляем отступ внутри боксов */
|
||||||
|
border: 1px solid #cccccc; /* добавляем тонкую серую границу */
|
||||||
|
margin: 10px; /* добавляем внешний отступ вокруг боксов */
|
||||||
|
border-radius: 8px; /* если хотите скругленные углы */
|
||||||
|
background: #ffffff; /* установка белого фона для боксов, если нужно */
|
||||||
|
|
||||||
|
flex: 1; /* Каждый элемент будет занимать равное пространство, но не меньше минимальной ширины */
|
||||||
|
min-width: 12em; /* Минимальная ширина для каждого бокса */
|
||||||
|
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); /* Добавляем немного тени для лучшей визуализации */
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1024px) {
|
||||||
|
.flex-container {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
.flex-item {
|
||||||
|
/* Блоки будут занимать всю ширину контейнера на меньших экранах */
|
||||||
|
min-width: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-item:nth-child(1) {
|
||||||
|
flex: 1.5; /* Третий элемент будет расти вдвое быстрее остальных */
|
||||||
|
}
|
||||||
|
|
||||||
|
th {
|
||||||
|
font-weight: bolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.colr {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ref {
|
||||||
|
font-family: 'Courier New', Courier, monospace;
|
||||||
|
font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.lab {
|
||||||
|
padding-left: 0.8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.ref {
|
||||||
|
width: 35em;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.reftype {
|
||||||
|
width: 10em;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.reftime {
|
||||||
|
width: 4em;
|
||||||
|
}
|
||||||
|
|
|
@ -8,4 +8,6 @@ import Data.ByteString
|
||||||
cssDir :: [(FilePath, ByteString)]
|
cssDir :: [(FilePath, ByteString)]
|
||||||
cssDir = $(embedDir "assets")
|
cssDir = $(embedDir "assets")
|
||||||
|
|
||||||
|
templates :: [(FilePath, ByteString)]
|
||||||
|
templates = $(embedDir "templates")
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="ru">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>hbs2-peer browser</title>
|
||||||
|
<link rel="stylesheet" href="/css/pico.min.css">
|
||||||
|
<link rel="stylesheet" href="/css/fontawesomeall.css">
|
||||||
|
<link rel="stylesheet" href="/css/custom.css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<header class="container">
|
||||||
|
<h1>hbs2-peer 0.24.1.0</h1>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<nav class="tabs" role="navigation">
|
||||||
|
<ul>
|
||||||
|
<li><a href="/dashboard">Dashboard</a></li>
|
||||||
|
<!-- <li><a href="#details">Детали</a></li> -->
|
||||||
|
<!-- <li><a href="#stats">Статистика</a></li> -->
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2"><i class="fas fa-key"></i><span
|
||||||
|
class="ref lab">5GnroAC8FXNRL8rcgJj6RTu9mt1AbuNd5MZVnDBcCKzb</span></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<footer class="container text-center">
|
||||||
|
<p>© 2024 hbs2-peer. Все права защищены.</p>
|
||||||
|
</footer>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -1,7 +1,8 @@
|
||||||
{-# Language TypeOperators #-}
|
{-# Language TypeOperators #-}
|
||||||
module HttpWorker where
|
module HttpWorker where
|
||||||
|
|
||||||
import HBS2.Prelude
|
import HBS2.Prelude.Plated
|
||||||
|
import HBS2.OrDie
|
||||||
import HBS2.Hash
|
import HBS2.Hash
|
||||||
import HBS2.Actors.Peer
|
import HBS2.Actors.Peer
|
||||||
import HBS2.Storage
|
import HBS2.Storage
|
||||||
|
@ -15,7 +16,7 @@ import HBS2.Net.Auth.Schema
|
||||||
import HBS2.Data.Types.SignedBox
|
import HBS2.Data.Types.SignedBox
|
||||||
import HBS2.Events
|
import HBS2.Events
|
||||||
import HBS2.Storage.Operations.ByteString
|
import HBS2.Storage.Operations.ByteString
|
||||||
|
import HBS2.Misc.PrettyStuff
|
||||||
|
|
||||||
|
|
||||||
import PeerTypes
|
import PeerTypes
|
||||||
|
@ -31,10 +32,16 @@ import Network.Wai.Middleware.StaticEmbedded
|
||||||
import Text.InterpolatedString.Perl6 (qc)
|
import Text.InterpolatedString.Perl6 (qc)
|
||||||
import Web.Scotty
|
import Web.Scotty
|
||||||
|
|
||||||
|
import Data.Text.Lazy.IO qualified as TIO
|
||||||
|
import Data.Text.Lazy.Encoding qualified as Enc
|
||||||
|
import Text.Microstache.Compile
|
||||||
|
import Text.Microstache.Render
|
||||||
|
|
||||||
import Data.ByteString.Builder (byteString, Builder)
|
import Data.ByteString.Builder (byteString, Builder)
|
||||||
|
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
import Data.Either
|
import Data.Either
|
||||||
|
import Data.HashMap.Strict qualified as HM
|
||||||
import Codec.Serialise (deserialiseOrFail)
|
import Codec.Serialise (deserialiseOrFail)
|
||||||
import Data.Aeson (object, (.=))
|
import Data.Aeson (object, (.=))
|
||||||
import Data.ByteString.Lazy.Char8 qualified as LBS8
|
import Data.ByteString.Lazy.Char8 qualified as LBS8
|
||||||
|
@ -76,6 +83,18 @@ httpWorker (PeerConfig syn) pmeta e = do
|
||||||
let bro = runReader (cfgValue @PeerBrowser) syn == FeatureOn
|
let bro = runReader (cfgValue @PeerBrowser) syn == FeatureOn
|
||||||
penv <- ask
|
penv <- ask
|
||||||
|
|
||||||
|
let tpl = templates
|
||||||
|
|
||||||
|
|
||||||
|
tpls <- for tpl $ \(n,bs) -> do
|
||||||
|
let txt = Enc.decodeUtf8 (LBS.fromStrict bs)
|
||||||
|
tpl <- compileMustacheText (fromString n) txt
|
||||||
|
& orThrowUser [qc|Can't compile template {n}|]
|
||||||
|
debug $ green "TEMPLATE" <+> pretty n
|
||||||
|
pure (n, tpl)
|
||||||
|
|
||||||
|
let templates = HM.fromList tpls
|
||||||
|
|
||||||
maybe1 port' none $ \port -> liftIO do
|
maybe1 port' none $ \port -> liftIO do
|
||||||
|
|
||||||
scotty port $ do
|
scotty port $ do
|
||||||
|
@ -199,12 +218,15 @@ httpWorker (PeerConfig syn) pmeta e = do
|
||||||
get "/metadata" do
|
get "/metadata" do
|
||||||
raw $ serialise $ pmeta
|
raw $ serialise $ pmeta
|
||||||
|
|
||||||
when bro do
|
middleware (static cssDir)
|
||||||
middleware (static cssDir)
|
|
||||||
|
|
||||||
get "/browser" do
|
when bro do
|
||||||
text "BRO"
|
|
||||||
status status200
|
get "/browser" $ flip runContT pure do
|
||||||
|
template <- orElse (status status500) (HM.lookup "browser.html" templates)
|
||||||
|
lift do
|
||||||
|
html $ renderMustache template "JOPAKITA"
|
||||||
|
status status200
|
||||||
|
|
||||||
put "/" do
|
put "/" do
|
||||||
-- FIXME: optional-header-based-authorization
|
-- FIXME: optional-header-based-authorization
|
||||||
|
|
|
@ -279,7 +279,13 @@ executable hbs2-peer
|
||||||
, Paths_hbs2_peer
|
, Paths_hbs2_peer
|
||||||
|
|
||||||
-- other-extensions:
|
-- other-extensions:
|
||||||
build-depends: base, hbs2-peer, hbs2-keyman, hbs2-browser, vty
|
build-depends:
|
||||||
|
base
|
||||||
|
, hbs2-peer
|
||||||
|
, hbs2-keyman
|
||||||
|
, hbs2-browser
|
||||||
|
, microstache
|
||||||
|
, vty
|
||||||
|
|
||||||
hs-source-dirs: app
|
hs-source-dirs: app
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue