created builder files

This commit is contained in:
2026-01-12 22:24:50 +01:00
parent 3b676a8c49
commit e542115cb8
3 changed files with 44 additions and 2 deletions

32
src/builder/builder.cpp Normal file
View File

@@ -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;
}

7
src/builder/builder.hpp Normal file
View File

@@ -0,0 +1,7 @@
#include "config/config.hpp"
#include "markdown/markdown.hpp"
struct Information {
Config config;
Metadata metadata;
};

View File

@@ -9,7 +9,8 @@ SOURCES = main.cpp \
config/config.cpp \ config/config.cpp \
format/format.cpp \ format/format.cpp \
markdown/markdown.cpp \ markdown/markdown.cpp \
io/io.cpp io/io.cpp \
builder/builder.cpp
OBJECTS = $(SOURCES:%.cpp=$(BUILD_DIR)/%.o) OBJECTS = $(SOURCES:%.cpp=$(BUILD_DIR)/%.o)
@@ -17,7 +18,8 @@ TEST_SOURCES = tests.cpp \
config/config.cpp \ config/config.cpp \
format/format.cpp \ format/format.cpp \
markdown/markdown.cpp \ markdown/markdown.cpp \
io/io.cpp io/io.cpp \
builder/builder.cpp
TEST_OBJECTS = $(TEST_SOURCES:%.cpp=$(BUILD_DIR)/%.o) TEST_OBJECTS = $(TEST_SOURCES:%.cpp=$(BUILD_DIR)/%.o)
@@ -33,6 +35,7 @@ directories:
@mkdir -p $(BUILD_DIR)/format @mkdir -p $(BUILD_DIR)/format
@mkdir -p $(BUILD_DIR)/io @mkdir -p $(BUILD_DIR)/io
@mkdir -p $(BUILD_DIR)/markdown @mkdir -p $(BUILD_DIR)/markdown
@mkdir -p $(BUILD_DIR)/builder
$(TARGET): $(OBJECTS) $(TARGET): $(OBJECTS)
$(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS) $(CXX) $(CXXFLAGS) -o $@ $^ $(LIBS)