From 8b443062ebf8bcbce321c569157f7c4e651239f6 Mon Sep 17 00:00:00 2001 From: blankie Date: Fri, 24 Nov 2023 10:55:02 +1100 Subject: [PATCH] Add "View on original instance" link --- routes/css.cpp | 2 +- routes/user.cpp | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/routes/css.cpp b/routes/css.cpp index e9409e6..d061dc9 100644 --- a/routes/css.cpp +++ b/routes/css.cpp @@ -143,11 +143,11 @@ svg { .user_page-profile { width: 7.5em; height: 7.5em; + margin-right: 0.5em; } .user_page-main_header span { margin-top: auto; margin-bottom: auto; - margin-left: 0.5em; } /* https://stackoverflow.com/a/7354648 */ diff --git a/routes/user.cpp b/routes/user.cpp index 7dd8f7e..928f27b 100644 --- a/routes/user.cpp +++ b/routes/user.cpp @@ -93,6 +93,10 @@ static inline Element user_header(const httplib::Request& req, const std::string user_links.nodes.push_back(user_link_field(req, account, i)); } + Node view_on_original = !account.same_server + ? Element("span", {" (", Element("a", {{"href", get_origin(req) + '/' + account.server + "/@" + account.username}}, {"View on original instance"}), ")"}) + : Node(""); + Element header("header", { Element("a", {{"href", account.header}}, { Element("img", {{"class", "user_page-header"}, {"alt", "User header"}, {"src", account.header}}, {}), @@ -102,7 +106,7 @@ static inline Element user_header(const httplib::Request& req, const std::string Element("img", {{"class", "user_page-profile"}, {"alt", "User profile picture"}, {"src", account.avatar}}, {}), }), Element("span", { - Element("b", {preprocess_html(req, account.emojis, account.display_name)}), " (", account.acct(), ")", + Element("b", {preprocess_html(req, account.emojis, account.display_name)}), " (", account.acct(), ")", view_on_original, Element("br"), Element("br"), Element("b", {"Joined: "}), short_time(account.created_at), Element("br"),