Skip to content

Commit

Permalink
Workaround for lack of root operator.
Browse files Browse the repository at this point in the history
  • Loading branch information
MattConrad committed May 3, 2016
1 parent 9425ca2 commit e56d02d
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
8 changes: 7 additions & 1 deletion Controllers/HomeController.cs
Expand Up @@ -3,6 +3,7 @@
using Microsoft.AspNet.Mvc;
using System.Diagnostics;
using Quill.Models;
using Microsoft.Extensions.Configuration;

namespace Quill.Controllers
{
Expand All @@ -12,16 +13,21 @@ public class HomeController : Controller
public static readonly string _rawInksDirectory = "/AppData/RawInks/";
private static readonly string _gameStatesDirectory = "/AppData/GameStates/";

//_rootPath is a filesystem path, for writing .ink/.jsons. _webAppPath is a URL modifier that is used instead of ~ (tilde, ofc, doesn't work with nginx)
private string _rootPath;
private string _webAppPath;

public HomeController(Microsoft.Extensions.PlatformAbstractions.IApplicationEnvironment appEnv)
public HomeController(Microsoft.Extensions.PlatformAbstractions.IApplicationEnvironment appEnv, IConfiguration config)
{
_rootPath = appEnv.ApplicationBasePath;
_webAppPath = config["WebAppPath"];

}

public IActionResult Index()
{
ViewBag.SessionGuid = Guid.NewGuid();
ViewBag.WebAppPath = _webAppPath;
return View();
}

Expand Down
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -16,4 +16,6 @@ The .dll and .exe in /lib are compiled against .NET Core (not Mono and not "regu

(Building the Ink runtime and Inklecate against .NET Core are a little tricky. This is a good RC1 resource for setting up a project.json and working through the issues, but be prepared to apply some workaround hacks as well. http://blog.marcgravell.com/2015/11/the-road-to-dnx-part-1.html. Again, when RC2 arrives, at least some things here will change.)

You'll need to revise the WebAppRoot setting in appsettings.json. "/" is a plausible value. This is a substitute for the '~' root operator that you get in ASP.NET on IIS, but don't get with nginx/Kestrel. There's probably a better way to handle this, drop me a note if you know what it is.

You will need to fix the path in /wrap/ink-engine-runtime/project.json to a local path. At least according to Stack Overflow, the wrap feature only works with an absolute path. Hey, we're on the edge here.
7 changes: 3 additions & 4 deletions Startup.cs
@@ -1,7 +1,3 @@
// using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Threading.Tasks;
using Microsoft.AspNet.Builder;
using Microsoft.AspNet.Hosting;
using Microsoft.Extensions.Configuration;
Expand All @@ -28,6 +24,8 @@ public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
//MWCTODO: would be nice if we could split between dev/prod for the WebAppRoot setting, look into this a little.
services.AddSingleton<IConfiguration>(sp => { return Configuration; } );
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand All @@ -42,6 +40,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
}
else
{
//MWCTODO: guess I'd better restore that view that I deleted earlier...
app.UseExceptionHandler("/Home/Error");
}

Expand Down
8 changes: 5 additions & 3 deletions Views/Home/Index.cshtml
@@ -1,4 +1,6 @@
<h2>@ViewBag.Title</h2>
@{
string webAppPath = (string)ViewBag.WebAppPath;
}

<form>
<div class="row">
Expand Down Expand Up @@ -55,8 +57,8 @@

<script type="text/javascript">
var customStorageKey = 'customink';
var playInkUrl = '@Url.Content("~/Home/PlayInk")';
var continueStoryUrl = '@Url.Content("~/Home/ContinueStory")';
var playInkUrl = '@webAppPath' + 'Home/PlayInk';
var continueStoryUrl = '@webAppPath' + 'Home/ContinueStory';
var sessionGuid = '@(((Guid)ViewBag.SessionGuid).ToString())';
var replayChoices = [];
Expand Down
3 changes: 2 additions & 1 deletion appsettings.json
Expand Up @@ -6,5 +6,6 @@
"System": "Information",
"Microsoft": "Information"
}
}
},
"WebAppPath" : "/quill/"
}

0 comments on commit e56d02d

Please sign in to comment.