mirror of
https://github.com/hoytech/strfry.git
synced 2025-06-19 01:34:57 +00:00
landing page
This commit is contained in:
@ -3,7 +3,7 @@ ENV TZ=Europe/London
|
|||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
RUN apt update && apt install -y --no-install-recommends \
|
RUN apt update && apt install -y --no-install-recommends \
|
||||||
git g++ make pkg-config libtool ca-certificates \
|
git g++ make pkg-config libtool ca-certificates \
|
||||||
libyaml-perl libtemplate-perl libssl-dev zlib1g-dev \
|
libyaml-perl libtemplate-perl libregexp-grammars-perl libssl-dev zlib1g-dev \
|
||||||
liblmdb-dev libflatbuffers-dev libsecp256k1-dev \
|
liblmdb-dev libflatbuffers-dev libsecp256k1-dev \
|
||||||
libzstd-dev
|
libzstd-dev
|
||||||
|
|
||||||
|
5
Makefile
5
Makefile
@ -6,3 +6,8 @@ include golpe/rules.mk
|
|||||||
|
|
||||||
LDLIBS += -lsecp256k1 -lzstd
|
LDLIBS += -lsecp256k1 -lzstd
|
||||||
INCS += -Iexternal/negentropy/cpp
|
INCS += -Iexternal/negentropy/cpp
|
||||||
|
|
||||||
|
build/StrfryTemplates.h: $(shell find src/tmpls/ -type f -name '*.tmpl')
|
||||||
|
perl golpe/external/templar/templar.pl src/tmpls/ strfrytmpl $@
|
||||||
|
|
||||||
|
src/apps/relay/RelayWebsocket.o: build/StrfryTemplates.h
|
||||||
|
@ -29,7 +29,7 @@ Either the full set of messages in the DB can be synced, or the results of one o
|
|||||||
|
|
||||||
A C++20 compiler is required, along with a few other common dependencies. On Debian/Ubuntu use these commands:
|
A C++20 compiler is required, along with a few other common dependencies. On Debian/Ubuntu use these commands:
|
||||||
|
|
||||||
sudo apt install -y git build-essential libyaml-perl libtemplate-perl libssl-dev zlib1g-dev liblmdb-dev libflatbuffers-dev libsecp256k1-dev libzstd-dev
|
sudo apt install -y git build-essential libyaml-perl libtemplate-perl libregexp-grammars-perl libssl-dev zlib1g-dev liblmdb-dev libflatbuffers-dev libsecp256k1-dev libzstd-dev
|
||||||
git submodule update --init
|
git submodule update --init
|
||||||
make setup-golpe
|
make setup-golpe
|
||||||
make -j4
|
make -j4
|
||||||
|
@ -42,7 +42,7 @@ While you wait for your server to provision, go to your DNS provider and point a
|
|||||||
cd strfry
|
cd strfry
|
||||||
|
|
||||||
# Install complication dependencies
|
# Install complication dependencies
|
||||||
sudo apt install -y git build-essential libyaml-perl libtemplate-perl libssl-dev zlib1g-dev liblmdb-dev libflatbuffers-dev libsecp256k1-dev libzstd-dev
|
sudo apt install -y git build-essential libyaml-perl libtemplate-perl libregexp-grammars-perl libssl-dev zlib1g-dev liblmdb-dev libflatbuffers-dev libsecp256k1-dev libzstd-dev
|
||||||
|
|
||||||
# Build it
|
# Build it
|
||||||
git submodule update --init
|
git submodule update --init
|
||||||
|
2
golpe
2
golpe
Submodule golpe updated: 2c40f2dc26...ef252ab997
@ -1,5 +1,6 @@
|
|||||||
#include "RelayServer.h"
|
#include "RelayServer.h"
|
||||||
|
|
||||||
|
#include "StrfryTemplates.h"
|
||||||
#include "app_git_version.h"
|
#include "app_git_version.h"
|
||||||
|
|
||||||
|
|
||||||
@ -47,15 +48,16 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
|
|||||||
tempBuf.reserve(cfg().events__maxEventSize + MAX_SUBID_SIZE + 100);
|
tempBuf.reserve(cfg().events__maxEventSize + MAX_SUBID_SIZE + 100);
|
||||||
|
|
||||||
|
|
||||||
|
tao::json::value supportedNips = tao::json::value::array({ 1, 2, 4, 9, 11, 12, 16, 20, 22, 28, 33, 40 });
|
||||||
|
|
||||||
auto getServerInfoHttpResponse = [ver = uint64_t(0), rendered = std::string("")]() mutable {
|
auto getServerInfoHttpResponse = [&supportedNips, ver = uint64_t(0), rendered = std::string("")]() mutable {
|
||||||
if (ver != cfg().version()) {
|
if (ver != cfg().version()) {
|
||||||
rendered = preGenerateHttpResponse("application/json", tao::json::to_string(tao::json::value({
|
rendered = preGenerateHttpResponse("application/json", tao::json::to_string(tao::json::value({
|
||||||
{ "name", cfg().relay__info__name },
|
{ "name", cfg().relay__info__name },
|
||||||
{ "description", cfg().relay__info__description },
|
{ "description", cfg().relay__info__description },
|
||||||
{ "pubkey", cfg().relay__info__pubkey },
|
{ "pubkey", cfg().relay__info__pubkey },
|
||||||
{ "contact", cfg().relay__info__contact },
|
{ "contact", cfg().relay__info__contact },
|
||||||
{ "supported_nips", tao::json::value::array({ 1, 2, 4, 9, 11, 12, 15, 16, 20, 22, 28, 33, 40 }) },
|
{ "supported_nips", supportedNips },
|
||||||
{ "software", "git+https://github.com/hoytech/strfry.git" },
|
{ "software", "git+https://github.com/hoytech/strfry.git" },
|
||||||
{ "version", APP_GIT_VERSION },
|
{ "version", APP_GIT_VERSION },
|
||||||
})));
|
})));
|
||||||
@ -65,7 +67,19 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
|
|||||||
return std::string_view(rendered); // memory only valid until next call
|
return std::string_view(rendered); // memory only valid until next call
|
||||||
};
|
};
|
||||||
|
|
||||||
const std::string defaultHttpResponse = preGenerateHttpResponse("text/plain", "Please use a Nostr client to connect.");
|
auto getLandingPageHttpResponse = [&supportedNips, ver = uint64_t(0), rendered = std::string("")]() mutable {
|
||||||
|
if (ver != cfg().version()) {
|
||||||
|
struct {
|
||||||
|
std::string supportedNips;
|
||||||
|
std::string version;
|
||||||
|
} ctx = { tao::json::to_string(supportedNips), APP_GIT_VERSION };
|
||||||
|
|
||||||
|
rendered = preGenerateHttpResponse("text/html", ::strfrytmpl::landing(ctx).str);
|
||||||
|
ver = cfg().version();
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::string_view(rendered); // memory only valid until next call
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -87,7 +101,8 @@ void RelayServer::runWebsocket(ThreadPool<MsgWebsocket>::Thread &thr) {
|
|||||||
auto info = getServerInfoHttpResponse();
|
auto info = getServerInfoHttpResponse();
|
||||||
res->write(info.data(), info.size());
|
res->write(info.data(), info.size());
|
||||||
} else {
|
} else {
|
||||||
res->write(defaultHttpResponse.data(), defaultHttpResponse.size());
|
auto landing = getLandingPageHttpResponse();
|
||||||
|
res->write(landing.data(), landing.size());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
160
src/tmpls/landing.tmpl
Normal file
160
src/tmpls/landing.tmpl
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<style>
|
||||||
|
/* CSS Reset */
|
||||||
|
|
||||||
|
html, body, div, span, applet, object, iframe,
|
||||||
|
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||||
|
a, abbr, acronym, address, big, cite, code,
|
||||||
|
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||||
|
small, strike, strong, sub, sup, tt, var,
|
||||||
|
b, u, i, center,
|
||||||
|
dl, dt, dd, ol, ul, li,
|
||||||
|
fieldset, form, label, legend,
|
||||||
|
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||||
|
article, aside, canvas, details, embed,
|
||||||
|
figure, figcaption, footer, header, hgroup,
|
||||||
|
menu, nav, output, ruby, section, summary,
|
||||||
|
time, mark, audio, video {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
border: 0;
|
||||||
|
font-size: 100%;
|
||||||
|
font: inherit;
|
||||||
|
vertical-align: baseline;
|
||||||
|
}
|
||||||
|
/* HTML5 display-role reset for older browsers */
|
||||||
|
article, aside, details, figcaption, figure,
|
||||||
|
footer, header, hgroup, menu, nav, section {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
line-height: 1;
|
||||||
|
}
|
||||||
|
ol, ul {
|
||||||
|
list-style: none;
|
||||||
|
}
|
||||||
|
blockquote, q {
|
||||||
|
quotes: none;
|
||||||
|
}
|
||||||
|
blockquote:before, blockquote:after,
|
||||||
|
q:before, q:after {
|
||||||
|
content: '';
|
||||||
|
content: none;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
border-spacing: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Our stylesheet */
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: sans-serif;
|
||||||
|
font-size: 135%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
font-size: 150%;
|
||||||
|
text-align: center;
|
||||||
|
margin-top: 20px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-around;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header img {
|
||||||
|
width: 200px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
width: 100%;
|
||||||
|
margin-bottom: 50px;
|
||||||
|
font-size: 125%
|
||||||
|
}
|
||||||
|
|
||||||
|
table th {
|
||||||
|
color: white;
|
||||||
|
background-color: black;
|
||||||
|
font-size: 110%;
|
||||||
|
}
|
||||||
|
|
||||||
|
table tr td:nth-child(1) {
|
||||||
|
width: 20%;
|
||||||
|
text-align: right;
|
||||||
|
padding-right: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table tr td:nth-child(2) {
|
||||||
|
font-weight: bold;
|
||||||
|
padding-left: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
table tr:nth-child(even) {
|
||||||
|
background-color: #f2f2f2;
|
||||||
|
}
|
||||||
|
|
||||||
|
table td,th {
|
||||||
|
padding: 8px 5px 8px 5px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div class="header">
|
||||||
|
<a href="https://github.com/hoytech/strfry"><img src="data:image/svg+xml;charset=utf-8;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxzdmcgaWQ9InN2ZzgiIHdpZHRoPSIyNzMuNDMiIGhlaWdodD0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dHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS13aWR0aD0iLjEzOTc2IiBzdHlsZT0icGFpbnQtb3JkZXI6bWFya2VycyBzdHJva2UgZmlsbCIvPg0KIDwvZz4NCjwvc3ZnPg=="></a>
|
||||||
|
<span>Please use a <a href="https://github.com/aljazceru/awesome-nostr#clients">Nostr client</a> to connect.</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th colspan="2">Relay</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Name</td>
|
||||||
|
<td>$(cfg().relay__info__name)</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Description</td>
|
||||||
|
<td>$(cfg().relay__info__description)</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Pubkey</td>
|
||||||
|
<td>$(cfg().relay__info__pubkey)</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Contact</td>
|
||||||
|
<td>$(cfg().relay__info__contact)</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th colspan="2">Server Software</th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Software</td>
|
||||||
|
<td><a href="https://github.com/hoytech/strfry">strfry</a></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Version</td>
|
||||||
|
<td>$(ctx.version)</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Supported NIPs</td>
|
||||||
|
<td>$(ctx.supportedNips)</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</html>
|
Reference in New Issue
Block a user