mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-08-14 16:00:25 +02:00
fix: handle navigation inside the app
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"core.min.js": "core.6332b3c288.min.js",
|
||||
"vendor.min.js": "vendor.2c4b28d9af.min.js",
|
||||
"vendor.min.js": "vendor.c40cb91530.min.js",
|
||||
"mermaid.min.js": "mermaid.f848a72d16.min.js",
|
||||
"all.min.css": "all.b704319d9c.min.css"
|
||||
}
|
||||
@@ -118,7 +118,7 @@
|
||||
<a
|
||||
ng-show="content != null"
|
||||
ng-href="{{url}}"
|
||||
target="__self"
|
||||
target="_self"
|
||||
class="btn btn-sm"
|
||||
aria-label="View raw current file"
|
||||
title="View the raw content of the current file"
|
||||
@@ -127,7 +127,7 @@
|
||||
<a
|
||||
ng-show="content != null"
|
||||
ng-href="{{url}}&download=true"
|
||||
target="__self"
|
||||
target="_self"
|
||||
class="btn btn-sm"
|
||||
aria-label="Download current file"
|
||||
title="Download the current file"
|
||||
@@ -136,7 +136,7 @@
|
||||
<a
|
||||
ng-if="options.download"
|
||||
ng-href="/api/repo/{{repoId}}/zip"
|
||||
target="__self"
|
||||
target="_self"
|
||||
class="btn btn-sm"
|
||||
aria-label="Download full repository as ZIP"
|
||||
title="Download the full repository as a ZIP archive"
|
||||
@@ -145,7 +145,7 @@
|
||||
<a
|
||||
ng-if="options.hasWebsite"
|
||||
ng-href="/w/{{repoId}}/"
|
||||
target="__self"
|
||||
target="_self"
|
||||
class="btn btn-sm"
|
||||
aria-label="Website"
|
||||
><i class="fas fa-globe"></i><span class="d-none d-md-inline"> Website</span></a
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
|
||||
<a class="dropdown-item" href="/profile">Default settings</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="/api/user/logout" target="__self"
|
||||
<a class="dropdown-item" href="/api/user/logout" target="_self"
|
||||
>Logout</a
|
||||
>
|
||||
</div>
|
||||
|
||||
@@ -64,19 +64,19 @@
|
||||
<div class="paper-detail-grid">
|
||||
<div class="detail-label">Repository</div>
|
||||
<div class="detail-value">
|
||||
<a href="/r/{{repoId}}/" target="__self">/r/{{repoId}}/</a>
|
||||
<a href="/r/{{repoId}}/" target="_self">/r/{{repoId}}/</a>
|
||||
</div>
|
||||
<div class="detail-label" ng-if="repo.options.page">GitHub Page</div>
|
||||
<div class="detail-value" ng-if="repo.options.page">
|
||||
<a href="/w/{{repoId}}/" target="__self">/w/{{repoId}}/</a>
|
||||
<a href="/w/{{repoId}}/" target="_self">/w/{{repoId}}/</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="anonymize-submit-bar" ng-if="repo.status == 'ready'">
|
||||
<a class="btn btn-ink" href="/r/{{repoId}}/" target="__self">
|
||||
<a class="btn btn-ink" href="/r/{{repoId}}/" target="_self">
|
||||
<i class="far fa-eye mr-1"></i> Go to anonymized repository
|
||||
</a>
|
||||
<a class="btn" href="/w/{{repoId}}/" target="__self" ng-if="repo.options.page">
|
||||
<a class="btn" href="/w/{{repoId}}/" target="_self" ng-if="repo.options.page">
|
||||
<i class="fas fa-globe mr-1"></i> Go to anonymized GitHub page
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -159,6 +159,34 @@ angular
|
||||
$locationProvider.html5Mode(true);
|
||||
},
|
||||
])
|
||||
// Paths served by express, not by the Angular router. html5Mode makes
|
||||
// Angular swallow every same-origin anchor click and resolve it against the
|
||||
// route table, so a link to /w/<repoId>/ — the one an anonymized README
|
||||
// points at for the repository's GitHub Page — fell through to .otherwise()
|
||||
// and rendered the 404 partial. Reloading worked because that bypassed
|
||||
// Angular and reached the server. Give these URLs back to the browser as a
|
||||
// real navigation.
|
||||
.run([
|
||||
"$rootScope",
|
||||
"$window",
|
||||
function ($rootScope, $window) {
|
||||
const serverPaths = /^\/(w|api|github)(\/|$)/;
|
||||
$rootScope.$on("$locationChangeStart", function (event, next) {
|
||||
let url;
|
||||
try {
|
||||
url = new URL(next, $window.location.href);
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
if (url.origin !== $window.location.origin) return;
|
||||
if (!serverPaths.test(url.pathname)) return;
|
||||
// Reverts $location to the previous URL so the address bar stays
|
||||
// consistent until the browser leaves the page.
|
||||
event.preventDefault();
|
||||
$window.location.assign(url.href);
|
||||
});
|
||||
},
|
||||
])
|
||||
.filter("humanFileSize", function () {
|
||||
return humanFileSize;
|
||||
})
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user