Skip to content

Commit

Permalink
fix up sample
Browse files Browse the repository at this point in the history
  • Loading branch information
pwelter34 committed Dec 4, 2023
1 parent 93f616d commit ddb0557
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 64 deletions.
2 changes: 1 addition & 1 deletion samples/Sample.ClientSide/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"commandName": "Project",
"launchBrowser": true,
"inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}",
"applicationUrl": "https://localhost:5001;http://localhost:5000",
"applicationUrl": "https://localhost:5001;http://localhost:5002",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
Expand Down
52 changes: 19 additions & 33 deletions samples/Sample.ClientSide/wwwroot/404.html
Original file line number Diff line number Diff line change
@@ -1,41 +1,27 @@
<!DOCTYPE html>
<html>
<head>
<head>
<meta charset="utf-8">
<title>Single Page Apps for GitHub Pages</title>
<title>LoreSoft Blazor Controls</title>
<!-- Start Single Page Apps for GitHub Pages -->
<script type="text/javascript">
// Single Page Apps for GitHub Pages
// https://github.com/rafrex/spa-github-pages
// Copyright (c) 2016 Rafael Pedicini, licensed under the MIT License
// ----------------------------------------------------------------------
// This script takes the current url and converts the path and query
// string into just a query string, and then redirects the browser
// to the new url with only a query string and hash fragment,
// e.g. http://www.foo.tld/one/two?a=b&c=d#qwe, becomes
// http://www.foo.tld/?p=/one/two&q=a=b~and~c=d#qwe
// Note: this 404.html file must be at least 512 bytes for it to work
// with Internet Explorer (it is currently > 512 bytes)
// Single Page Apps for GitHub Pages
var pathSegmentsToKeep = 0;

// If you're creating a Project Pages site and NOT using a custom domain,
// then set segmentCount to 1 (enterprise users may need to set it to > 1).
// This way the code will only replace the route part of the path, and not
// the real directory in which the app resides, for example:
// https://username.github.io/repo-name/one/two?a=b&c=d#qwe becomes
// https://username.github.io/repo-name/?p=/one/two&q=a=b~and~c=d#qwe
// Otherwise, leave segmentCount as 0.
var segmentCount = 0;

var l = window.location;
l.replace(
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
l.pathname.split('/').slice(0, 1 + segmentCount).join('/') + '/?p=/' +
l.pathname.slice(1).split('/').slice(segmentCount).join('/').replace(/&/g, '~and~') +
(l.search ? '&q=' + l.search.slice(1).replace(/&/g, '~and~') : '') +
l.hash
);
var l = window.location;
l.replace(
l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +
l.pathname.split('/').slice(0, 1 + pathSegmentsToKeep).join('/') + '/?/' +
l.pathname.slice(1).split('/').slice(pathSegmentsToKeep).join('/').replace(/&/g, '~and~') +
(l.search ? '&' + l.search.slice(1).replace(/&/g, '~and~') : '') +
l.hash
);

</script>
</head>
<body>
</body>
<!-- End Single Page Apps for GitHub Pages -->

</head>
<body>
Loading ...
</body>
</html>
27 changes: 0 additions & 27 deletions samples/Sample.ClientSide/wwwroot/GitHubPages.js

This file was deleted.

1 change: 1 addition & 0 deletions samples/Sample.ClientSide/wwwroot/decode.min.js

Large diffs are not rendered by default.

41 changes: 38 additions & 3 deletions samples/Sample.ClientSide/wwwroot/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@

<base href="/" />

<!-- Start Single Page Apps for GitHub Pages -->
<script type="text/javascript">
(function (l) {
if (l.search[1] === '/') {
var decoded = l.search.slice(1).split('&').map(function (s) {
return s.replace(/~and~/g, '&')
}).join('?');
window.history.replaceState(null, null,
l.pathname.slice(0, -1) + decoded + l.hash
);
}
}(window.location))
</script>
<!-- End Single Page Apps for GitHub Pages -->

<link rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"
integrity="sha256-MBffSnbbXwHCuZtgPYiwMQbfE7z+GOZ7fBPCNB06Z98="
Expand Down Expand Up @@ -40,8 +55,6 @@ <h3 class="d-flex justify-content-center">
<a class="dismiss">🗙</a>
</div>

<script src="GitHubPages.js" type="text/javascript"></script>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"
integrity="sha256-gvZPYrsDwbwYJLD5yeBfcNujPhRoGOY831wwbIzz3t0="
crossorigin="anonymous"></script>
Expand All @@ -53,7 +66,29 @@ <h3 class="d-flex justify-content-center">
integrity="sha256-ht8ay6ZTPZfuixYB99I5oRpCLsCq7Do2LjEYLwbe+X8="
crossorigin="anonymous"></script>

<script src="_framework/blazor.webassembly.js"></script>
<script src="_framework/blazor.webassembly.js" autostart="false"></script>

<script type="module">
import { BrotliDecode } from './decode.min.js';
Blazor.start({
loadBootResource: function (type, name, defaultUri, integrity) {
if (type !== 'dotnetjs' && location.hostname !== 'localhost' && type !== 'configuration') {
return (async function () {
const response = await fetch(defaultUri + '.br', { cache: 'no-cache' });
if (!response.ok) {
throw new Error(response.statusText);
}
const originalResponseBuffer = await response.arrayBuffer();
const originalResponseArray = new Int8Array(originalResponseBuffer);
const decompressedResponseArray = BrotliDecode(originalResponseArray);
const contentType = type ===
'dotnetwasm' ? 'application/wasm' : 'application/octet-stream';
return new Response(decompressedResponseArray,
{ headers: { 'content-type': contentType } });
})();
}
}
});
</script>
</body>
</html>

0 comments on commit ddb0557

Please sign in to comment.