Skip to content

Commit

Permalink
Run tour offline - fixes dlang-tour#443
Browse files Browse the repository at this point in the history
  • Loading branch information
wilzbach committed Aug 25, 2016
1 parent ba15b8c commit cea2948
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,21 @@ private void doSanityCheck(ContentProvider contentProvider, IExecProvider execPr

shared static this()
{
string configFile = "config.yml";
import std.file : thisExePath;
import std.path : buildPath, dirName, isAbsolute;

string rootDir = thisExePath.dirName;

string configFile = buildPath(rootDir, "config.yml");
readOption("c|config", &configFile, "Configuration file");
bool sanityCheck = false;
readOption("sanitycheck", &sanityCheck,
"Runs sanity check before starting that checks whether all source code examples actually compile; doesn't start the service");
auto config = new Config(configFile);

auto contentProvider = new ContentProvider(config.publicDir ~ "/content");
string publicDir = config.publicDir.isAbsolute ? config.publicDir : rootDir.buildPath(config.publicDir);

auto contentProvider = new ContentProvider(publicDir.buildPath("content"));
auto execProvider = createExecProvider(config, contentProvider);

if (sanityCheck) {
Expand Down Expand Up @@ -144,7 +151,7 @@ shared static this()
urlRouter
.registerWebInterface(new WebInterface(contentProvider, config.googleAnalyticsId))
.registerRestInterface(new ApiV1(execProvider, contentProvider))
.get("/static/*", serveStaticFiles(config.publicDir ~ "/static/", fsettings));
.get("/static/*", serveStaticFiles(publicDir.buildPath("static"), fsettings));

listenHTTP(settings, urlRouter);
listenHTTP(httpsSettings, urlRouter);
Expand Down

0 comments on commit cea2948

Please sign in to comment.