forked from chookspace/chookchat
Support for <meta> attributes
This commit is contained in:
@@ -12,19 +12,22 @@
|
||||
#include "post.h"
|
||||
|
||||
#include "generated/e404.h"
|
||||
#include "generated/header.h"
|
||||
#include "generated/header_top.h"
|
||||
#include "generated/header_bottom.h"
|
||||
#include "generated/footer.h"
|
||||
#include "generated/style.h"
|
||||
#include "generated/script.h"
|
||||
|
||||
int main() {
|
||||
const bin2cpp::File& headerfile = bin2cpp::getHeaderHtmlFile();
|
||||
const bin2cpp::File& headerTopFile = bin2cpp::getHeader_topHtmlFile();
|
||||
const bin2cpp::File& headerBottomFile = bin2cpp::getHeader_bottomHtmlFile();
|
||||
const bin2cpp::File& footerfile = bin2cpp::getFooterHtmlFile();
|
||||
const bin2cpp::File& e404file = bin2cpp::getE404HtmlFile();
|
||||
const bin2cpp::File& stylefile = bin2cpp::getStyleCssFile();
|
||||
const bin2cpp::File& scriptfile = bin2cpp::getScriptJsFile();
|
||||
|
||||
std::string header{headerfile.getBuffer(), headerfile.getSize()};
|
||||
std::string headerTop{headerTopFile.getBuffer(), headerTopFile.getSize()};
|
||||
std::string headerBottom{headerBottomFile.getBuffer(), headerBottomFile.getSize()};
|
||||
std::string footer{footerfile.getBuffer(), footerfile.getSize()};
|
||||
std::string e404{e404file.getBuffer(), e404file.getSize()};
|
||||
std::string style{stylefile.getBuffer(), stylefile.getSize()};
|
||||
@@ -44,10 +47,10 @@ int main() {
|
||||
response.set_content(script, "text/css");
|
||||
});
|
||||
|
||||
svr.Get("/", [&header, &footer, &database, &data_mutex](const httplib::Request& request, httplib::Response& response) {
|
||||
svr.Get("/", [&headerTop, &headerBottom, &footer, &database, &data_mutex](const httplib::Request& request, httplib::Response& response) {
|
||||
|
||||
std::stringstream ss;
|
||||
ss << header;
|
||||
ss << headerTop << "<meta content='Chookchat' property='og:title' /><meta content='See posts from cool people' property='og:description' />" << headerBottom;
|
||||
|
||||
std::lock_guard<std::mutex> lock(data_mutex);
|
||||
|
||||
@@ -68,7 +71,7 @@ int main() {
|
||||
}
|
||||
});
|
||||
|
||||
svr.Get("/posts/:id", [&header, &footer, &e404, &database, &data_mutex](const httplib::Request& request, httplib::Response& response) {
|
||||
svr.Get("/posts/:id", [&headerTop, &headerBottom, &footer, &e404, &database, &data_mutex](const httplib::Request& request, httplib::Response& response) {
|
||||
std::string postId = request.path_params.at("id");
|
||||
try {
|
||||
uint64_t postIdNum = std::stoll(postId);
|
||||
@@ -81,7 +84,7 @@ int main() {
|
||||
}
|
||||
|
||||
std::stringstream ss;
|
||||
ss << header << post->genHtml() << footer;
|
||||
ss << headerTop << post->genHtmlMeta() << headerBottom << post->genHtml() << footer;
|
||||
response.set_content(ss.str(), "text/html");
|
||||
} catch (const std::runtime_error& e) {
|
||||
response.status = 500;
|
||||
|
||||
Reference in New Issue
Block a user