From c3e39d571474ed9613d6b0b645394ea09a8c74b0 Mon Sep 17 00:00:00 2001 From: Maxwell Jeffress Date: Mon, 20 Jul 2026 11:48:27 +1000 Subject: [PATCH] Style things a little --- build.sh | 1 + client/footer.html | 1 + client/header.html | 47 +++++++++++++++++++++---------------- client/style.css | 56 +++++++++++++++++++++++++++++++++++++++++++++ server/meson.build | 1 + server/src/main.cpp | 12 ++++++---- server/src/post.cpp | 4 ++-- 7 files changed, 95 insertions(+), 27 deletions(-) create mode 100644 client/style.css diff --git a/build.sh b/build.sh index ac5039c..df3636f 100644 --- a/build.sh +++ b/build.sh @@ -2,3 +2,4 @@ bin2cpp --file=client/footer.html --output=server/src/generated bin2cpp --file=client/header.html --output=server/src/generated +bin2cpp --file=client/style.css --output=server/src/generated diff --git a/client/footer.html b/client/footer.html index 2ab5c0d..64584ee 100644 --- a/client/footer.html +++ b/client/footer.html @@ -1,2 +1,3 @@ + diff --git a/client/header.html b/client/header.html index d2393f9..e444d8a 100644 --- a/client/header.html +++ b/client/header.html @@ -2,27 +2,34 @@ posts + + -
-
- - -
-
-
- - -
-
-
- +
+ +
+ + +

- +
+ + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+

posts

-
-
- -
- -

posts

diff --git a/client/style.css b/client/style.css new file mode 100644 index 0000000..1458d17 --- /dev/null +++ b/client/style.css @@ -0,0 +1,56 @@ +@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital@0;1&display=swap'); + +body { + font-family: "JetBrains Mono", monospace; + font-size: 12pt; + color: lime; + background-color: black; + line-height: 1.1; +} + +hr { + border: none; + height: 2px; + background-color: lime; +} + +button, input, textarea { + appearance: none; + font-family: "JetBrains Mono", monospace; + font-size: 12pt; + color: lime; + background-color: black; + border: 1px solid lime; +} + +textarea { + width: 100%; + box-sizing: border-box; +} + +.postbox, #posts { + max-width: 700px; + margin: 0 auto; +} + +img { + max-height: 200px; + max-width: 100%; + height: auto; + width: auto; +} + +.postinfo { + background-color: #313131; +} + +.postbox, #posts { + padding: 0 16px; + box-sizing: border-box; +} + +@media (max-width: 600px) { + input, textarea, button { + font-size: 16px; + } +} diff --git a/server/meson.build b/server/meson.build index a50cf8d..681b576 100644 --- a/server/meson.build +++ b/server/meson.build @@ -6,6 +6,7 @@ sources = [ 'src/db.cpp', 'src/generated/header.cpp', 'src/generated/footer.cpp', + 'src/generated/style.cpp', # bcrypt 'src/bcrypt/bcrypt.cpp', diff --git a/server/src/main.cpp b/server/src/main.cpp index 621cf22..220a8c6 100644 --- a/server/src/main.cpp +++ b/server/src/main.cpp @@ -1,10 +1,8 @@ -#include #include #include #include #include #include -#include #include #include "httplib/httplib.h" @@ -15,16 +13,16 @@ #include "generated/header.h" #include "generated/footer.h" +#include "generated/style.h" int main() { const bin2cpp::File& headerfile = bin2cpp::getHeaderHtmlFile(); const bin2cpp::File& footerfile = bin2cpp::getFooterHtmlFile(); + const bin2cpp::File& stylefile = bin2cpp::getStyleCssFile(); std::string header{headerfile.getBuffer(), headerfile.getSize()}; std::string footer{footerfile.getBuffer(), footerfile.getSize()}; - - //std::vector posts = {}; - //std::unordered_map users = {}; + std::string style{stylefile.getBuffer(), stylefile.getSize()}; Database database{"chookchat.db"}; @@ -32,6 +30,10 @@ int main() { httplib::Server svr; + svr.Get("/style.css", [&style](const httplib::Request& request, httplib::Response& response) { + response.set_content(style, "text/css"); + }); + svr.Get("/", [&header, &footer, &database, &data_mutex](const httplib::Request& request, httplib::Response& response) { std::cout << "requested /" << std::endl; diff --git a/server/src/post.cpp b/server/src/post.cpp index a9865d9..4061e73 100644 --- a/server/src/post.cpp +++ b/server/src/post.cpp @@ -29,11 +29,11 @@ std::string Post::genHtml() const { ts = *localtime(&time); strftime(buf, sizeof(buf), "%a %Y-%m-%d %H:%M:%S %Z", &ts); - ss << "

" << user << " posted this at " << buf << "

\n"; + ss << "\n"; ss << content; - ss << "

" << likes << " likes

"; + ss << ""; return ss.str();