From c7d9cf85678e69f41d2c177850f2454bd27655a6 Mon Sep 17 00:00:00 2001 From: Szymon P Date: Wed, 31 Dec 2025 14:01:18 +0100 Subject: [PATCH] Added general config --- config/config_example.toml | 4 ++++ src/config.cpp | 7 ++++++- src/config.hpp | 6 ++++++ src/tests.cpp | 3 +++ templates/index.html | 24 ++++++++++++++++++++++++ 5 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 templates/index.html diff --git a/config/config_example.toml b/config/config_example.toml index 8ba3b37..6cf6a90 100644 --- a/config/config_example.toml +++ b/config/config_example.toml @@ -1,3 +1,7 @@ +[general] +lang = "en" +title = "Blog" + [contact] author = "author" email = "email@example.com" diff --git a/src/config.cpp b/src/config.cpp index a3d98fd..4deede6 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -19,7 +19,12 @@ Config get_config(const std::string &CONFIG_FILE) { toml_table["contact"]["signal"].value_or(""), }; - Config config = {contact}; + General general = { + toml_table["general"]["lang"].value_or(""), + toml_table["general"]["title"].value_or(""), + }; + + Config config = {contact, general}; return config; } diff --git a/src/config.hpp b/src/config.hpp index 019ce6f..30e25ee 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -7,8 +7,14 @@ struct Contact { std::string signal; }; +struct General { + std::string lang; + std::string title; +}; + struct Config { Contact contact; + General general; }; Config get_config(const std::string &CONFIG_FILE); diff --git a/src/tests.cpp b/src/tests.cpp index 5a6f567..bf7e992 100644 --- a/src/tests.cpp +++ b/src/tests.cpp @@ -1,5 +1,6 @@ #include "config.hpp" #include +#include #include TEST_CASE("Checking config file read", "[config]") { @@ -10,4 +11,6 @@ TEST_CASE("Checking config file read", "[config]") { REQUIRE(config.contact.author == "author"); REQUIRE(config.contact.email == "email@example.com"); REQUIRE(config.contact.signal == "signal url"); + REQUIRE(config.general.lang == "en"); + REQUIRE(config.general.title == "Blog"); } diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..5d21e41 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,24 @@ + + + + + + {{title}} + + + +
+

{{title}}

+
+ + + +
+
    + +
+
+ +