|
|
|
@ -37,7 +37,9 @@ const std::string DEFAULT_SOURCE_DIR = ".";
@@ -37,7 +37,9 @@ const std::string DEFAULT_SOURCE_DIR = ".";
|
|
|
|
|
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"; |
|
|
|
|
const std::string TEST_URL = "http://localhost:"; |
|
|
|
|
const std::string TEST_PORT = "8000"; |
|
|
|
|
|
|
|
|
|
static volatile bool continue_running = true; |
|
|
|
|
|
|
|
|
|
const std::string short_info("stgen3 prerelease from git.topsot.net (c) 2020-2021 Alistair Michael."); |
|
|
|
@ -50,6 +52,7 @@ struct runtime_config {
@@ -50,6 +52,7 @@ struct runtime_config {
|
|
|
|
|
bool save_config = false; |
|
|
|
|
bool test = false; |
|
|
|
|
std::set<std::string> readonly_properties {}; |
|
|
|
|
std::string port = TEST_PORT; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
runtime_config settings; |
|
|
|
@ -706,6 +709,7 @@ std::map<std::string, std::string> parse_options (int argc, char **argv) {
@@ -706,6 +709,7 @@ std::map<std::string, std::string> parse_options (int argc, char **argv) {
|
|
|
|
|
("s,save-config", "Save the configuration used to build the site to src/stgen.json") |
|
|
|
|
("y,noninteractive", "Non-interactive mode (confirm everything)") |
|
|
|
|
("t,test", "Start internal server and build in test mode") |
|
|
|
|
("p,port", "Port to use for the internal server", cxxopts::value<std::string>()) |
|
|
|
|
("n,name", "Site name, defaults to $source", cxxopts::value<std::string>())
|
|
|
|
|
("u,url", "Site url, defaults to file://$destination", cxxopts::value<std::string>()) |
|
|
|
|
("a,author", "Site author", cxxopts::value<std::string>()) |
|
|
|
@ -734,6 +738,11 @@ std::map<std::string, std::string> parse_options (int argc, char **argv) {
@@ -734,6 +738,11 @@ std::map<std::string, std::string> parse_options (int argc, char **argv) {
|
|
|
|
|
if (result.count("test")) { |
|
|
|
|
settings.readonly_properties.insert("url"); |
|
|
|
|
settings.test = true; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (result.count("port")) { |
|
|
|
|
settings.port = result["port"].as<std::string>(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (result.count("help")) |
|
|
|
@ -784,7 +793,7 @@ std::map<std::string, std::string> parse_options (int argc, char **argv) {
@@ -784,7 +793,7 @@ std::map<std::string, std::string> parse_options (int argc, char **argv) {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (settings.test) { |
|
|
|
|
parsed_opts["url"] = TEST_URL; |
|
|
|
|
parsed_opts["url"] = TEST_URL + settings.port; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -842,6 +851,7 @@ int main(int argc, char **argv) {
@@ -842,6 +851,7 @@ int main(int argc, char **argv) {
|
|
|
|
|
// TODO: filesystem watch mode using libevent
|
|
|
|
|
// TODO: folder listing semantics: need to look at the index.html for the
|
|
|
|
|
// folder.
|
|
|
|
|
// TODO: using -s should only set the things specified on the command line
|
|
|
|
|
|
|
|
|
|
auto cmd_options = parse_options(argc, argv); |
|
|
|
|
|
|
|
|
@ -853,7 +863,7 @@ int main(int argc, char **argv) {
@@ -853,7 +863,7 @@ int main(int argc, char **argv) {
|
|
|
|
|
signal(SIGINT, kill_childs); |
|
|
|
|
|
|
|
|
|
server s {}; |
|
|
|
|
s.serve_now(cmd_options.at("publish_root"), "8000", "127.0.0.1"); |
|
|
|
|
s.serve_now(cmd_options.at("publish_root"), settings.port, "127.0.0.1"); |
|
|
|
|
/* darkhttpd registers a signal handler so this just uses that as it is
|
|
|
|
|
* compiled in rather than fork and exec'd |
|
|
|
|
*/ |
|
|
|
|