Add CSS
This commit is contained in:
parent
6ceea16739
commit
7f1cde5579
|
@ -24,7 +24,7 @@ add_link_options(${FLAGS})
|
|||
|
||||
|
||||
add_executable(${PROJECT_NAME} main.cpp misc.cpp config.cpp servehelper.cpp blankie/serializer.cpp blankie/escape.cpp
|
||||
routes/home.cpp)
|
||||
routes/home.cpp routes/css.cpp)
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
CXX_STANDARD 20
|
||||
|
|
3
main.cpp
3
main.cpp
|
@ -3,7 +3,7 @@
|
|||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "config.h"
|
||||
#include "routes/home.h"
|
||||
#include "routes/routes.h"
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
if (argc != 2) {
|
||||
|
@ -23,6 +23,7 @@ int main(int argc, char** argv) {
|
|||
server.Get("/", [&](const httplib::Request& req, httplib::Response& res) {
|
||||
home_route(req, res, config);
|
||||
});
|
||||
server.Get("/style.css", css_route);
|
||||
|
||||
if (config.bind_port != 0) {
|
||||
if (!server.bind_to_port(config.bind_host, config.bind_port)) {
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#include "routes.h"
|
||||
|
||||
void css_route(const httplib::Request& req, httplib::Response& res) {
|
||||
res.set_content(R"EOF(
|
||||
|
||||
:root {
|
||||
--background-color: black;
|
||||
--text-color: white;
|
||||
--accent-color: #962AC3;
|
||||
--dark-accent-color: #7D3F7D;
|
||||
--bright-accent-color: #DE6DE6;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: var(--background-color);
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--accent-color);
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
color: var(--bright-accent-color);
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
)EOF", "text/css");
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
#include "home.h"
|
||||
#include "routes.h"
|
||||
#include "../servehelper.h"
|
||||
|
||||
void home_route(const httplib::Request& req, httplib::Response& res, const Config& config) {
|
||||
|
|
|
@ -5,3 +5,4 @@
|
|||
struct Config; // forward declaration from config.h
|
||||
|
||||
void home_route(const httplib::Request& req, httplib::Response& res, const Config& config);
|
||||
void css_route(const httplib::Request& req, httplib::Response& res);
|
Loading…
Reference in New Issue