From 8dbd1438572b8b3682e879900fd0a9c44ac94227 Mon Sep 17 00:00:00 2001 From: SteveSandersonMS Date: Tue, 7 Jun 2016 14:31:23 +0100 Subject: [PATCH] Move ES2015 example into a subpage of the NodeServicesExamples sample --- .../Controllers/HomeController.cs | 5 +++++ .../{ => Node}/transpilation.js | 0 samples/misc/NodeServicesExamples/Startup.cs | 2 +- .../Views/Home/ES2015Transpilation.cshtml | 16 ++++++++++++++++ .../NodeServicesExamples/Views/Home/Index.cshtml | 15 +++++++++++---- 5 files changed, 33 insertions(+), 5 deletions(-) rename samples/misc/NodeServicesExamples/{ => Node}/transpilation.js (100%) create mode 100755 samples/misc/NodeServicesExamples/Views/Home/ES2015Transpilation.cshtml mode change 100755 => 100644 samples/misc/NodeServicesExamples/Views/Home/Index.cshtml diff --git a/samples/misc/NodeServicesExamples/Controllers/HomeController.cs b/samples/misc/NodeServicesExamples/Controllers/HomeController.cs index 8a52e7d..be21da6 100755 --- a/samples/misc/NodeServicesExamples/Controllers/HomeController.cs +++ b/samples/misc/NodeServicesExamples/Controllers/HomeController.cs @@ -10,6 +10,11 @@ namespace NodeServicesExamples.Controllers return View(); } + public IActionResult ES2015Transpilation() + { + return View(); + } + public IActionResult Error() { return View("~/Views/Shared/Error.cshtml"); diff --git a/samples/misc/NodeServicesExamples/transpilation.js b/samples/misc/NodeServicesExamples/Node/transpilation.js similarity index 100% rename from samples/misc/NodeServicesExamples/transpilation.js rename to samples/misc/NodeServicesExamples/Node/transpilation.js diff --git a/samples/misc/NodeServicesExamples/Startup.cs b/samples/misc/NodeServicesExamples/Startup.cs index 2f157a6..cec3093 100755 --- a/samples/misc/NodeServicesExamples/Startup.cs +++ b/samples/misc/NodeServicesExamples/Startup.cs @@ -30,7 +30,7 @@ namespace NodeServicesExamples if (requestPath.StartsWith("/js/") && requestPath.EndsWith(".js")) { var fileInfo = env.WebRootFileProvider.GetFileInfo(requestPath); if (fileInfo.Exists) { - var transpiled = await nodeServices.Invoke("transpilation.js", fileInfo.PhysicalPath, requestPath); + var transpiled = await nodeServices.Invoke("./Node/transpilation.js", fileInfo.PhysicalPath, requestPath); await context.Response.WriteAsync(transpiled); return; } diff --git a/samples/misc/NodeServicesExamples/Views/Home/ES2015Transpilation.cshtml b/samples/misc/NodeServicesExamples/Views/Home/ES2015Transpilation.cshtml new file mode 100755 index 0000000..bfb35ec --- /dev/null +++ b/samples/misc/NodeServicesExamples/Views/Home/ES2015Transpilation.cshtml @@ -0,0 +1,16 @@ +

ES2015 Transpilation

+ +

+ This sample demonstrates a way of intercepting requests for .js files and dynamically transpiling them + from ES2015 code to browser-compatible ES5 code using the Babel library. +

+ +

+ To see that it's working, open your browser's 'Debug' console and look for the log message. This is + produced by the file /js/main.js, which is transpiled from ES2015 dynamically + when requested. +

+ +@section scripts { + +} diff --git a/samples/misc/NodeServicesExamples/Views/Home/Index.cshtml b/samples/misc/NodeServicesExamples/Views/Home/Index.cshtml old mode 100755 new mode 100644 index 0df9cfe..21dcd3b --- a/samples/misc/NodeServicesExamples/Views/Home/Index.cshtml +++ b/samples/misc/NodeServicesExamples/Views/Home/Index.cshtml @@ -1,5 +1,12 @@ -Hello +

NodeServices examples

+ +

+ These examples demonstrate the direct use of the NodeServices package, independently of the usual SPA scenarios. + In general, NodeServices offers an efficient way to use Node-provided functionality (e.g., NPM modules) from inside + a .NET application. +

+ +