diff --git a/client/header_bottom.html b/client/header_bottom.html
index ef8b183..aac7894 100644
--- a/client/header_bottom.html
+++ b/client/header_bottom.html
@@ -34,6 +34,3 @@
-
diff --git a/client/style.css b/client/style.css
index ed5e7b7..135658a 100644
--- a/client/style.css
+++ b/client/style.css
@@ -61,6 +61,11 @@ img {
display: flex;
gap: 5px;
}
+
+a {
+ color: lime;
+ text-decoration: underline;
+}
nav {
background: rgb(25, 25, 25);
diff --git a/server/src/main.cpp b/server/src/main.cpp
index 1110223..df73de3 100644
--- a/server/src/main.cpp
+++ b/server/src/main.cpp
@@ -169,6 +169,7 @@ int main() {
std::stringstream ss;
ss << headerTop << "
" << headerBottom;
+ ss << "";
std::lock_guard
lock(data_mutex);
@@ -214,6 +215,36 @@ int main() {
}
});
+ svr.Get("/profile/:username", [&headerTop, &headerBottom, &footer, &e404, &database, &data_mutex](const httplib::Request& request, httplib::Response& response){
+ std::string username = request.path_params.at("username");
+ std::lock_guard lock(data_mutex);
+ try {
+ std::optional user = database.getUserByName(username);
+ if (!user.has_value()) {
+ response.status = 404;
+ response.set_content(e404, "text/html");
+ }
+ std::vector posts = database.getUserPosts(user->id);
+
+ std::stringstream ss;
+ ss << headerTop << "" << headerBottom;
+ ss << "";
+ for (const auto& post : posts) {
+ ss << post.genHtml();
+ }
+ ss << footer;
+
+ response.set_content(ss.str(), "text/html");
+ } catch (const std::runtime_error& e) {
+ response.status = 500;
+ response.set_content("there was an error :( it is: " + std::string(e.what()) + "
", "text/html");
+ } catch (const std::exception& e) {
+ response.status = 500;
+ response.set_content("there was an error :( it is: " + std::string(e.what()) + "
", "text/html");
+ }
+
+ });
+
// endpoint to be used by HTML forms
svr.Post("/make_post", [&database, &data_mutex](const httplib::Request& request, httplib::Response& response) {
diff --git a/server/src/post.cpp b/server/src/post.cpp
index 2e92eaa..bc679f0 100644
--- a/server/src/post.cpp
+++ b/server/src/post.cpp
@@ -47,7 +47,7 @@ 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 << "" << user << " posted this at " << buf << "
\n";
ss << content;