1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 15:09:14 +00:00

Update public wiki (#2868)

This commit is contained in:
C_Q
2019-01-24 15:41:01 +08:00
committed by Daniel Pan
parent 711855f8ae
commit 41b3d2c5df
13 changed files with 245 additions and 50 deletions

View File

@@ -1,4 +1,4 @@
import { mediaUrl, gettext, siteRoot } from './constants';
import { mediaUrl, gettext, serviceURL } from './constants';
import { strChineseFirstPY } from './pinyin-by-unicode';
export const Utils = {
@@ -404,30 +404,59 @@ export const Utils = {
},
isInternalMarkdownLink: function(url, repoID) {
var re = new RegExp(siteRoot + 'lib/' + repoID + '.*\.md$');
var re = new RegExp(serviceURL + '/lib/' + repoID + '.*\.md$');
return re.test(url);
},
isInternalDirLink: function(url, repoID) {
var re = new RegExp(siteRoot + 'library/' + repoID + '.*');
var re = new RegExp(serviceURL + '/library/' + repoID + '.*');
return re.test(url);
},
getPathFromInternalMarkdownLink: function(url, repoID) {
var re = new RegExp(siteRoot + 'lib/' + repoID + '/file' + '(.*\.md)');
var re = new RegExp(serviceURL + '/lib/' + repoID + '/file' + '(.*\.md)');
var array = re.exec(url);
var path = decodeURIComponent(array[1]);
return path;
},
getPathFromInternalDirLink: function(url, repoID, repoName) {
var re = new RegExp(siteRoot + 'library/' + repoID + '/' + repoName + '(/.*)');
var repoName = encodeURIComponent(repoName);
var re = new RegExp(serviceURL + '/library/' + repoID + '/' + repoName + '(/.*)');
var array = re.exec(url);
var path = decodeURIComponent(array[1]);
return path;
},
isWikiInternalMarkdownLink: function(url, slug) {
var slug = encodeURIComponent(slug);
var re = new RegExp(serviceURL + '/wikis/' + slug + '.*\.md$');
return re.test(url);
},
isWikiInternalDirLink: function(url, slug) {
var slug = encodeURIComponent(slug);
var re = new RegExp(serviceURL + '/wikis/' + slug + '.*');
return re.test(url);
},
getPathFromWikiInternalMarkdownLink: function(url, slug) {
var slug = encodeURIComponent(slug);
var re = new RegExp(serviceURL + '/wikis/' + slug + '(.*\.md)');
var array = re.exec(url);
var path = decodeURIComponent(array[1]);
return path;
},
getPathFromWikiInternalDirLink: function(url, slug) {
var slug = encodeURIComponent(slug);
var re = new RegExp(serviceURL + '/wikis/' + slug+ '(/.*)');
var array = re.exec(url);
var path = decodeURIComponent(array[1]);
return path;
},
compareTwoWord: function(wordA, wordB) {
// compare wordA and wordB at lower case
// if wordA >= wordB, return 1
@@ -577,6 +606,17 @@ export const Utils = {
}
});
return items;
}
},
changeMarkdownNodes: function(nodes, fn) {
nodes.map((item) => {
fn(item);
if (item.nodes && item.nodes.length > 0){
Utils.changeMarkdownNodes(item.nodes, fn);
}
});
return nodes;
},
};