-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Actually works!!
- Loading branch information
0 parents
commit 4032533
Showing
16 changed files
with
24,976 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
node_modules | ||
obj | ||
bin | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<template> | ||
<h2>Server Clock</h2> | ||
<div> | ||
<button click.trigger="fetchTime()">Fetch time</button> | ||
${time} | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export class AppViewModel { | ||
time = "n/a"; | ||
|
||
activate() { | ||
return this.fetchTime(); | ||
} | ||
|
||
fetchTime() { | ||
return fetch("/api/Time") | ||
.then<any>(response => response.json()) | ||
.then(obj => this.time = obj.time); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {Aurelia, PLATFORM} from "aurelia-framework"; | ||
|
||
export function configure(aurelia: Aurelia) { | ||
aurelia.use.standardConfiguration() | ||
.developmentLogging(); | ||
aurelia.start() | ||
.then(() => aurelia.setRoot(PLATFORM.moduleName("app"))); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp1.0</TargetFramework> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Folder Include="wwwroot\" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.1" /> | ||
<PackageReference Include="Microsoft.AspNetCore.SpaServices" Version="1.1.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.0.0-msbuild3-final" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace AureliaDemo.Controllers | ||
{ | ||
public class HomeController : Controller | ||
{ | ||
public IActionResult Index() => View(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
|
||
namespace AureliaDemo.Controllers { | ||
public class TimeController { | ||
public object Index() | ||
{ | ||
return new { | ||
Time = DateTime.Now.ToString("T") | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System.IO; | ||
using Microsoft.AspNetCore.Hosting; | ||
|
||
namespace AureliaDemo | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
var host = new WebHostBuilder() | ||
.UseKestrel() | ||
.UseContentRoot(Directory.GetCurrentDirectory()) | ||
.UseIISIntegration() | ||
.UseStartup<Startup>() | ||
.Build(); | ||
|
||
host.Run(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.AspNetCore.SpaServices.Webpack; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace AureliaDemo | ||
{ | ||
public class Startup | ||
{ | ||
public void ConfigureServices(IServiceCollection services) | ||
{ | ||
services.AddMvc(); | ||
} | ||
|
||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) | ||
{ | ||
loggerFactory.AddConsole(); | ||
|
||
if (env.IsDevelopment()) | ||
{ | ||
app.UseDeveloperExceptionPage(); | ||
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions | ||
{ | ||
HotModuleReplacement = true | ||
}); | ||
} | ||
|
||
app.UseStaticFiles(); | ||
|
||
app.UseMvc(routes => | ||
{ | ||
routes.MapRoute("api", "api/{controller}/{action=Index}"); | ||
routes.MapSpaFallbackRoute("spa-fallback", new { controller = "Home", action = "Index" }); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
@addTagHelper "*, Microsoft.AspNetCore.Mvc.TagHelpers" | ||
@addTagHelper "*, Microsoft.AspNetCore.SpaServices" | ||
|
||
<!doctype html> | ||
<html> | ||
<head> | ||
<script defer src="/dist/app.js" asp-append-version="true"></script> | ||
</head> | ||
<body aurelia-app="main" asp-prerender-module="render" asp-prerender-timeout=2000> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"license": "MIT", | ||
"devDependencies": { | ||
"aspnet-webpack": "^1.0.28", | ||
"aurelia-webpack-plugin": "^2.0.0-rc.1", | ||
"ts-loader": "^2.0.1", | ||
"typescript": "^2.2.1", | ||
"webpack": "^2.2.1", | ||
"webpack-hot-middleware": "^2.17.1" | ||
}, | ||
"dependencies": { | ||
"aspnet-prerendering": "^2.0.3", | ||
"aurelia-bootstrapper": "^2.1.1", | ||
"jsdom": "^9.11.0", | ||
"whatwg-fetch": "^2.0.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const prerendering = require("aspnet-prerendering"); | ||
const jsdom = require("jsdom"); | ||
|
||
module.exports = prerendering.createServerRenderer(params => | ||
new Promise((resolve, reject) => { | ||
jsdom.env({ | ||
html: "<html><body aurelia-app=main></body></html>", | ||
scripts: ["/dist/app.js"], | ||
url: "http://localhost:5000" + params.url, | ||
features: { | ||
FetchExternalResources: ["script"], | ||
ProcessExternalResources: ["script"] | ||
}, | ||
created: (err, window) => { | ||
// HACK: "polyfill" missing stuff in JSDOM... | ||
window.SVGElement = class SVGElement extends window.Element {}; | ||
window.requestAnimationFrame = f => window.setTimeout(f, 1000/60); | ||
|
||
window.addEventListener("aurelia-composed", () => { | ||
resolve({ | ||
html: window.document.body.innerHTML | ||
}); | ||
window.close(); | ||
}); | ||
}, | ||
done: (err, window) => { | ||
if (err) reject(err); | ||
} | ||
}); | ||
}) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es6", | ||
"module": "es6", | ||
"moduleResolution": "node", | ||
"lib": [ "es6", "dom" ], | ||
"importHelpers": true, | ||
|
||
"experimentalDecorators": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const path = require("path"); | ||
const { AureliaPlugin } = require("aurelia-webpack-plugin"); | ||
|
||
module.exports = { | ||
// The Fetch polyfill is required in JSDOM/NodeJS environment | ||
entry: { main: ["whatwg-fetch", "aurelia-bootstrapper"] }, | ||
|
||
output: { | ||
path: path.join(__dirname, "wwwroot", "dist"), | ||
filename: "app.js", | ||
publicPath: "/dist/", | ||
}, | ||
|
||
resolve: { | ||
extensions: [".ts", ".js"], | ||
modules: ["App", "node_modules"], | ||
}, | ||
|
||
module: { | ||
rules: [ | ||
{ test: /\.html$/i, loaders: "html-loader" }, | ||
{ test: /\.ts$/i, loaders: "ts-loader" }, | ||
] | ||
}, | ||
|
||
plugins: [ | ||
new AureliaPlugin(), | ||
] | ||
}; |
Oops, something went wrong.