|
|
|
@ -23,6 +23,7 @@
@@ -23,6 +23,7 @@
|
|
|
|
|
#include <tinyxml2.h> |
|
|
|
|
|
|
|
|
|
#include <unistd.h> |
|
|
|
|
#include <csignal> |
|
|
|
|
|
|
|
|
|
#include "default-templates.h" |
|
|
|
|
#include "templater.hpp" |
|
|
|
@ -36,6 +37,7 @@ const std::string TEMPLATE_FILEEXT = "template";
@@ -36,6 +37,7 @@ const std::string TEMPLATE_FILEEXT = "template";
|
|
|
|
|
const std::string DEFAULT_WATCH_FILETYPES[] = {"md", "markdown", TEMPLATE_FILEEXT}; |
|
|
|
|
const std::string DEFAULT_IGNORE_FILES[] = {SITE_CONFIG_FNAME}; |
|
|
|
|
const std::string TEST_URL = "http://localhost:8000"; |
|
|
|
|
static volatile bool continue_running = true; |
|
|
|
|
|
|
|
|
|
using json = nlohmann::json; |
|
|
|
|
namespace fs = std::filesystem; |
|
|
|
@ -708,6 +710,12 @@ std::map<std::string, std::string> parse_options (int argc, char **argv) {
@@ -708,6 +710,12 @@ std::map<std::string, std::string> parse_options (int argc, char **argv) {
|
|
|
|
|
return parsed_opts; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void kill_childs(int sig) |
|
|
|
|
{ |
|
|
|
|
continue_running = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **argv) { |
|
|
|
|
// TODO:
|
|
|
|
|
//
|
|
|
|
@ -749,22 +757,27 @@ int main(int argc, char **argv) {
@@ -749,22 +757,27 @@ int main(int argc, char **argv) {
|
|
|
|
|
|
|
|
|
|
auto cmd_options = parse_options(argc, argv); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stgen::builder b (cmd_options); |
|
|
|
|
b.build(); |
|
|
|
|
|
|
|
|
|
if (settings.test) { |
|
|
|
|
|
|
|
|
|
signal(SIGINT, kill_childs); |
|
|
|
|
|
|
|
|
|
server s {}; |
|
|
|
|
s.serve_now(cmd_options.at("publish_root"), "8000", "127.0.0.1"); |
|
|
|
|
spdlog::info("Rebuilding every 5 seconds."); |
|
|
|
|
while (true) { |
|
|
|
|
/* darkhttpd registers a signal handler so this just uses that as it is
|
|
|
|
|
* compiled in rather than fork and exec'd |
|
|
|
|
*/ |
|
|
|
|
while (continue_running) { |
|
|
|
|
b.build(); |
|
|
|
|
unsigned int microsecond = 1000000; |
|
|
|
|
usleep(5 * microsecond);//sleeps for 3 second
|
|
|
|
|
spdlog::info("Rebuilt."); |
|
|
|
|
spdlog::info("Built site."); |
|
|
|
|
sleep(5); |
|
|
|
|
} |
|
|
|
|
s.stop_serving(); |
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
putchar('\n'); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|