forked from chookspace/chookchat
Style things a little
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
#include <exception>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#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<Post> posts = {};
|
||||
//std::unordered_map<std::string, std::string> 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;
|
||||
|
||||
@@ -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 << "<p><i>" << user << "</i> posted this at " << buf << "</p>\n";
|
||||
ss << "<p class='postinfo'><i>" << user << "</i> posted this at " << buf << "</p>\n";
|
||||
|
||||
ss << content;
|
||||
|
||||
ss << "<p>" << likes << " likes</p>";
|
||||
ss << "<p class='postinfo'>" << likes << " likes</p>";
|
||||
|
||||
return ss.str();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user