1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-26 15:26:19 +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

@@ -13,6 +13,7 @@ export const isPro = window.app.config.isPro === 'True';
export const lang = window.app.config.lang;
export const fileServerRoot = window.app.config.fileServerRoot;
export const seafileVersion = window.app.config.seafileVersion;
export const serviceURL = window.app.config.serviceURL;
//pageOptions
export const seafileCollabServer = window.app.pageOptions.seafileCollabServer;
@@ -46,6 +47,7 @@ export const initialPath = window.wiki ? window.wiki.config.initial_path : '';
export const permission = window.wiki ? window.wiki.config.permission === 'True' : '';
export const isDir = window.wiki ? window.wiki.config.isDir : '';
export const serviceUrl = window.wiki ? window.wiki.config.serviceUrl : '';
export const isPublicWiki = window.wiki ? window.wiki.config.isPublicWiki === 'True': '';
// file history
export const PER_PAGE = 25;

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;
},
};