-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SigSpec UI #35
Draft
TomSmith27
wants to merge
18
commits into
RicoSuter:master
Choose a base branch
from
TomSmith27:feature/sigspec-ui
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
SigSpec UI #35
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
76635c1
Merge branch 'master' into feature/sigspec-ui
e25f935
Add SigSpec.UI
a6cc839
Tidy up
e4b47f1
Add build steps and format Callbacks
b78d317
fix build yaml
74f0fb9
Update Yaml for Build again
8d70cf2
update working directory
384df4a
Add missing njsproj
ec5aaa5
Improve middleware and services registration (document) & prepare UI …
RicoSuter d75f656
add sigspec ui middleware
f5d0fed
Merge remote-tracking branch 'origin-real/features/improve-middleware…
5044c06
Merge branch 'master' into feature/sigspec-ui
cc88ba4
tidy up
7bc1c61
more tidy
34beb05
delete extra folder
73de9bf
minor tidy up
39ee1b6
Add ability to pass settings to UI, and adding loading indicator to o…
78db800
remove tests to make project simpler
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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
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 |
---|---|---|
|
@@ -37,7 +37,6 @@ public async Task Invoke(HttpContext httpContext) | |
else | ||
{ | ||
await _next(httpContext); | ||
return; | ||
} | ||
} | ||
|
||
|
42 changes: 42 additions & 0 deletions
42
src/SigSpec.AspNetCore/Middlewares/SigSpecUiIndexMiddleware.cs
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,42 @@ | ||
using System; | ||
using System.IO; | ||
using System.Reflection; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace SigSpec.AspNetCore.Middlewares | ||
{ | ||
internal class SigSpecUIIndexMiddleware | ||
{ | ||
private readonly RequestDelegate _nextDelegate; | ||
private readonly string _indexPath; | ||
private readonly SigSpecUiSettings _settings; | ||
private readonly string _resourcePath; | ||
|
||
public SigSpecUIIndexMiddleware(RequestDelegate nextDelegate, string indexPath, SigSpecUiSettings settings, string resourcePath) | ||
{ | ||
_nextDelegate = nextDelegate; | ||
_indexPath = indexPath; | ||
_settings = settings; | ||
_resourcePath = resourcePath; | ||
} | ||
|
||
public async Task Invoke(HttpContext context) | ||
{ | ||
if (context.Request.Path.HasValue && string.Equals(context.Request.Path.Value.Trim('/'), _indexPath.Trim('/'), StringComparison.OrdinalIgnoreCase)) | ||
{ | ||
var stream = typeof(SigSpecUIIndexMiddleware).GetTypeInfo().Assembly.GetManifestResourceStream(_resourcePath); | ||
using (var reader = new StreamReader(stream)) | ||
{ | ||
context.Response.Headers["Content-Type"] = "text/html; charset=utf-8"; | ||
context.Response.StatusCode = 200; | ||
await context.Response.WriteAsync(_settings.TransformHtml(await reader.ReadToEndAsync(), context.Request)); | ||
} | ||
} | ||
else | ||
{ | ||
await _nextDelegate(context); | ||
} | ||
} | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
namespace SigSpec.AspNetCore.Middlewares | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace SigSpec.AspNetCore.Middlewares | ||
{ | ||
public class SigSpecSettings | ||
{ | ||
/// <summary>Gets or sets the path to serve the SigSpec document (default: '/sigspec/{documentName}/sigspec.json').</summary> | ||
public string Path { get; set; } = "/sigspec/{documentName}/sigspec.json"; | ||
|
||
} | ||
} |
Binary file not shown.
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 |
---|---|---|
@@ -1,11 +1,28 @@ | ||
<!DOCTYPE html> | ||
|
||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<title>Hello World!</title> | ||
</head> | ||
<body> | ||
Hello World! | ||
</body> | ||
</html> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width,initial-scale=1.0" /> | ||
<link rel="icon" href="./favicon.ico" /> | ||
<title>SigSpecUI</title> | ||
</head> | ||
|
||
<body> | ||
<noscript> | ||
<strong>We're sorry but SigSpecUI doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> | ||
</noscript> | ||
<script> | ||
window.sigSpecUiSettings = { | ||
baseUrl: '{BaseUrl}', | ||
route : '{Route}' | ||
} | ||
</script> | ||
|
||
<div id="app"></div> | ||
<script src="./app.js"></script> | ||
<script src="./chunk-vendors.js"></script> | ||
<link href="./app.css" rel="stylesheet" /> | ||
<link href="./chunk-vendors.css" rel="stylesheet" /> | ||
</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 |
---|---|---|
@@ -1,7 +1,16 @@ | ||
namespace SigSpec.AspNetCore | ||
using Microsoft.AspNetCore.Http; | ||
|
||
namespace SigSpec.AspNetCore | ||
{ | ||
public class SigSpecUiSettings | ||
{ | ||
public string Route { get; set; } = "/sigspec"; | ||
|
||
public string TransformHtml(string html, HttpRequest request) | ||
{ | ||
html = html.Replace("{Route}", this.Route); | ||
html = html.Replace("{BaseUrl}", request.Scheme + "://" + request.Host); | ||
return 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,3 @@ | ||
> 1% | ||
last 2 versions | ||
not dead |
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,15 @@ | ||
module.exports = { | ||
root: true, | ||
env: { | ||
node: true | ||
}, | ||
extends: ['plugin:vue/essential', 'eslint:recommended', '@vue/typescript/recommended'], | ||
parserOptions: { | ||
ecmaVersion: 2020 | ||
}, | ||
rules: { | ||
'@typescript-eslint/no-explicit-any': 'off', | ||
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off', | ||
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off' | ||
} | ||
}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to Route? What is the default in asp?