1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-04 00:20:07 +00:00

[wiki] redirect dir page (#2352)

This commit is contained in:
C_Q
2018-09-07 22:25:13 +08:00
committed by Daniel Pan
parent 75932af704
commit 6e873ef029
2 changed files with 26 additions and 2 deletions

View File

@@ -96,7 +96,7 @@ class EditorUtilities {
url = serviceUrl + "/lib/" + repoID + "/file" + encodeURIComponent(fileNode.path()); url = serviceUrl + "/lib/" + repoID + "/file" + encodeURIComponent(fileNode.path());
} }
} else { } else {
url = serviceUrl + "/#common/lib/" + repoID + "/" + encodeURIComponent(fileNode.path()); url = serviceUrl + "/#common/lib/" + repoID + encodeURIComponent(fileNode.path());
} }
return url; return url;
} }
@@ -108,7 +108,7 @@ class EditorUtilities {
isInternalDirLink(url) { isInternalDirLink(url) {
var re = new RegExp(serviceUrl + "/#[a-z\-]*?/lib/" + "[0-9a-f\-]{36}/.*"); var re = new RegExp(serviceUrl + "/#[a-z\-]*?/lib/" + "[0-9a-f\-]{36}.*");
return re.test(url); return re.test(url);
} }

View File

@@ -98,6 +98,9 @@ class Wiki extends Component {
if (this.isInternalMarkdownLink(url)) { if (this.isInternalMarkdownLink(url)) {
let path = this.getPathFromInternalMarkdownLink(url); let path = this.getPathFromInternalMarkdownLink(url);
this.initMainPanelData(path); this.initMainPanelData(path);
} else if (this.isInternalDirLink(url)) {
let path = this.getPathFromInternalDirLink(url);
this.initWikiData(path);
} else { } else {
window.location.href = url; window.location.href = url;
} }
@@ -424,6 +427,11 @@ class Wiki extends Component {
return re.test(url); return re.test(url);
} }
isInternalDirLink(url) {
var re = new RegExp(serviceUrl + '/#[a-z\-]*?/lib/' + repoID + '/.*');
return re.test(url);
}
getPathFromInternalMarkdownLink(url) { getPathFromInternalMarkdownLink(url) {
var re = new RegExp(serviceUrl + '/lib/' + repoID + '/file' + "(.*\.md)"); var re = new RegExp(serviceUrl + '/lib/' + repoID + '/file' + "(.*\.md)");
var array = re.exec(url); var array = re.exec(url);
@@ -431,6 +439,22 @@ class Wiki extends Component {
return path; return path;
} }
getPathFromInternalDirLink(url) {
var re = new RegExp(serviceUrl + '/#[a-z\-]*?/lib/' + repoID + "(/.*)");
var array = re.exec(url);
var path = decodeURIComponent(array[1]);
var dirPath = path.substring(1);
var re = new RegExp("(^/.*)");
if (re.test(dirPath)) {
path = dirPath;
} else {
path = '/' + dirPath
}
return path;
}
render() { render() {
return ( return (
<div id="main" className="wiki-main"> <div id="main" className="wiki-main">