From e542115cb827293fc8f8e897d2c7195b440f157a Mon Sep 17 00:00:00 2001 From: Szymon P Date: Mon, 12 Jan 2026 22:24:50 +0100 Subject: [PATCH] created builder files --- src/builder/builder.cpp | 32 ++++++++++++++++++++++++++++++++ src/builder/builder.hpp | 7 +++++++ src/makefile | 7 +++++-- 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/builder/builder.cpp create mode 100644 src/builder/builder.hpp diff --git a/src/builder/builder.cpp b/src/builder/builder.cpp new file mode 100644 index 0000000..b089c72 --- /dev/null +++ b/src/builder/builder.cpp @@ -0,0 +1,32 @@ +#include "builder/builder.hpp" +#include "config/config.hpp" +#include "format/format.hpp" + +std::string build_header(const std::string &TEMPLATE, + const Information &INFORMATION) { + std::string result = + format_file(TEMPLATE, "{{title}}", INFORMATION.metadata.title); + ; + + return result; +} + +std::string build_head(const std::string &TEMPLATE, + const Information &INFORMATION) { + std::string result = + format_file(TEMPLATE, "{{title}}", INFORMATION.metadata.title); + return result; +} + +std::string build_footer(const std::string &TEMPLATE, + const Information &INFORMATION) { + std::string result = TEMPLATE; + result = + format_file_conditionally(TEMPLATE, "{{if email}}", "{{endif}}", + "{{email}}", INFORMATION.config.contact.email); + + result = format_file_conditionally(TEMPLATE, "{{if signal}}", "{{endif}}", + "{{signal}}", + INFORMATION.config.contact.signal); + return result; +} diff --git a/src/builder/builder.hpp b/src/builder/builder.hpp new file mode 100644 index 0000000..6cf27f6 --- /dev/null +++ b/src/builder/builder.hpp @@ -0,0 +1,7 @@ +#include "config/config.hpp" +#include "markdown/markdown.hpp" + +struct Information { + Config config; + Metadata metadata; +}; diff --git a/src/makefile b/src/makefile index 0d73592..5d76770 100644 --- a/src/makefile +++ b/src/makefile @@ -9,7 +9,8 @@ SOURCES = main.cpp \ config/config.cpp \ format/format.cpp \ markdown/markdown.cpp \ - io/io.cpp + io/io.cpp \ + builder/builder.cpp OBJECTS = $(SOURCES:%.cpp=$(BUILD_DIR)/%.o) @@ -17,7 +18,8 @@ TEST_SOURCES = tests.cpp \ config/config.cpp \ format/format.cpp \ markdown/markdown.cpp \ - io/io.cpp + io/io.cpp \ + builder/builder.cpp TEST_OBJECTS = $(TEST_SOURCES:%.cpp=$(BUILD_DIR)/%.o) @@ -33,6 +35,7 @@ directories: @mkdir -p $(BUILD_DIR)/format @mkdir -p $(BUILD_DIR)/io @mkdir -p $(BUILD_DIR)/markdown + @mkdir -p $(BUILD_DIR)/builder $(TARGET): $(OBJECTS) $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)