diff --git a/Makefile b/Makefile index b723b7c..3a8a9c4 100644 --- a/Makefile +++ b/Makefile @@ -24,8 +24,8 @@ CXXFLAGS=-Wall -Wextra -g -O0 -std=c++17 .PHONY: clean -$(PROGRAM_NAME): build/ build/obj/ build/obj/main.o build/obj/ConfigUtils.o build/obj/WebsiteBuilder.o build/obj/SwgRuntime.o build/obj/MarkdownParser.o - $(CXXC) -o $(PROGRAM_NAME) build/obj/main.o build/obj/ConfigUtils.o build/obj/WebsiteBuilder.o build/obj/SwgRuntime.o build/obj/MarkdownParser.o +$(PROGRAM_NAME): build/ build/obj/ build/obj/main.o build/obj/ConfigUtils.o build/obj/WebsiteBuilder.o build/obj/SwgRuntime.o build/obj/MarkdownParser.o build/obj/Article.o + $(CXXC) -o $(PROGRAM_NAME) build/obj/main.o build/obj/ConfigUtils.o build/obj/WebsiteBuilder.o build/obj/SwgRuntime.o build/obj/MarkdownParser.o build/obj/Article.o build/obj/main.o: src/main.cxx src/ConfigUtils.hxx src/SwgContext.hxx src/WebsiteBuilder.hxx src/Common.hxx $(CXXC) $(CXXFLAGS) -o build/obj/main.o -c src/main.cxx @@ -33,7 +33,7 @@ build/obj/main.o: src/main.cxx src/ConfigUtils.hxx src/SwgContext.hxx src/Websit build/obj/ConfigUtils.o: src/ConfigUtils.cxx src/SwgContext.hxx src/Common.hxx $(CXXC) $(CXXFLAGS) -o build/obj/ConfigUtils.o -c src/ConfigUtils.cxx -build/obj/WebsiteBuilder.o: src/WebsiteBuilder.hxx src/WebsiteBuilder.cxx src/SwgRuntime.hxx src/Common.hxx src/MarkdownParser.hxx +build/obj/WebsiteBuilder.o: src/WebsiteBuilder.hxx src/WebsiteBuilder.cxx src/SwgRuntime.hxx src/Common.hxx src/MarkdownParser.hxx src/Article.hxx $(CXXC) $(CXXFLAGS) -o build/obj/WebsiteBuilder.o -c src/WebsiteBuilder.cxx build/obj/SwgRuntime.o: src/SwgRuntime.hxx src/SwgRuntime.cxx @@ -42,6 +42,9 @@ build/obj/SwgRuntime.o: src/SwgRuntime.hxx src/SwgRuntime.cxx build/obj/MarkdownParser.o: src/MarkdownParser.hxx src/MarkdownParser.cxx $(CXXC) $(CXXFLAGS) -o build/obj/MarkdownParser.o -c src/MarkdownParser.cxx +build/obj/Article.o: src/Article.hxx src/Article.cxx + $(CXXC) $(CXXFLAGS) -o build/obj/Article.o -c src/Article.cxx + build/: mkdir -p build/ diff --git a/src/Article.cxx b/src/Article.cxx new file mode 100644 index 0000000..12fea4c --- /dev/null +++ b/src/Article.cxx @@ -0,0 +1,135 @@ +/* + * Copyright (C) 2022 luca0N! + * + * This file is part of Static Website Generator (swg). + * + * Static Website Generator (swg) is free software: you can redistribute it + * and/or modify it under the terms of the version 3 of the GNU Lesser General + * Public License as published by the Free Software Foundation. + * + * Static Website Generator (swg) is distributed in the hope that it will be + * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser + * General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with Static Website Generator (swg). If not, see + * . + * + * Contact luca0N! by e-mail: . + */ + +#include "Article.hxx" + +#include +#include +#include + +#include "Common.hxx" + +enum IterationStage { + CHECKING_TITLE, + READING_TITLE, + CHECKING +}; + +namespace Article { + /* + * FIXME: The article metadata declaration uses the same INI format as + * swg.cfg. Since they use the exact same format, we could unify the .cfg + * parsing into one function. + */ + void get_metadata(std::string const &path, Metadata *m) { + memset(m, 0, sizeof(Metadata)); + FILE *a = fopen(path.c_str(), "r"); + + int buflen = 16; + char buf[buflen]; + + const char *det_article = "