mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-02 07:27:04 +00:00
fix index.md bug && update url wikis-->published
This commit is contained in:
@@ -230,7 +230,7 @@ class App extends Component {
|
||||
onTabNavClick={this.tabItemClick}
|
||||
onGroupChanged={this.onGroupChanged}
|
||||
/>
|
||||
<Wikis path={siteRoot + 'wikis'} onShowSidePanel={this.onShowSidePanel} onSearchedClick={this.onSearchedClick}/>
|
||||
<Wikis path={siteRoot + 'published'} onShowSidePanel={this.onShowSidePanel} onSearchedClick={this.onSearchedClick}/>
|
||||
<PublicSharedView path={siteRoot + 'org/'} onShowSidePanel={this.onShowSidePanel} onSearchedClick={this.onSearchedClick} onTabNavClick={this.tabItemClick}/>
|
||||
</Router>
|
||||
</MainPanel>
|
||||
|
@@ -9,7 +9,7 @@ const viewerPropTypes = {
|
||||
onLinkClick: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
const contentClass = 'wiki-page-content';
|
||||
const contentClass = 'wiki-nav-content';
|
||||
|
||||
class IndexContentViewer extends React.Component {
|
||||
|
||||
@@ -58,6 +58,7 @@ class IndexContentViewer extends React.Component {
|
||||
target = target.parentNode;
|
||||
}
|
||||
link = target.href;
|
||||
|
||||
} else {
|
||||
link = event.target.href;
|
||||
}
|
||||
@@ -86,18 +87,27 @@ class IndexContentViewer extends React.Component {
|
||||
|
||||
else if (item.type == 'link') {
|
||||
url = item.data.href;
|
||||
|
||||
let expression = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[\-;:&=\+\$,\w]+@)?[A-Za-z0-9\.\-]+|(?:www\.|[\-;:&=\+\$,\w]+@)[A-Za-z0-9\.\-]+)((?:\/[\+~%\/\.\w\-_]*)?\??(?:[\-\+=&;%@\.\w_]*)#?(?:[\.\!\/\\\w]*))?)/
|
||||
let re = new RegExp(expression);
|
||||
|
||||
// Solving relative paths
|
||||
if (!re.test(url)) {
|
||||
item.data.href = serviceURL + "/published/" + slug + '/' + url;
|
||||
}
|
||||
// change file url
|
||||
if (Utils.isInternalMarkdownLink(url, repoID)) {
|
||||
else if (Utils.isInternalMarkdownLink(url, repoID)) {
|
||||
let path = Utils.getPathFromInternalMarkdownLink(url, repoID);
|
||||
console.log(path);
|
||||
// replace url
|
||||
item.data.href = serviceURL + '/wikis/' + slug + path;
|
||||
item.data.href = serviceURL + '/published/' + slug + path;
|
||||
}
|
||||
// change dir url
|
||||
else if (Utils.isInternalDirLink(url, repoID)) {
|
||||
let path = Utils.getPathFromInternalDirLink(url, repoID);
|
||||
// replace url
|
||||
item.data.href = serviceURL + '/wikis/' + slug + path;
|
||||
}
|
||||
item.data.href = serviceURL + '/published/' + slug + path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +136,6 @@ class IndexContentViewer extends React.Component {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
IndexContentViewer.propTypes = viewerPropTypes;
|
||||
|
@@ -200,7 +200,7 @@ class MainSideNav extends React.Component {
|
||||
}
|
||||
{enableWiki &&
|
||||
<li className="nav-item">
|
||||
<Link className={`nav-link ellipsis ${this.getActiveClass('wikis')}`} to={siteRoot + 'wikis/'} title={gettext('Wikis')} onClick={() => this.tabItemClick('wikis')}>
|
||||
<Link className={`nav-link ellipsis ${this.getActiveClass('published')}`} to={siteRoot + 'published/'} title={gettext('Published Libraries')} onClick={() => this.tabItemClick('published')}>
|
||||
<span className="sf2-icon-wiki-view" aria-hidden="true"></span>
|
||||
<span className="nav-text">{gettext('Published Libraries')}</span>
|
||||
</Link>
|
||||
|
@@ -38,7 +38,7 @@ class WikiDirListItem extends React.Component {
|
||||
|
||||
render() {
|
||||
let { path, dirent } = this.props;
|
||||
let href = siteRoot + 'wikis' + Utils.joinPath(path, dirent.name);
|
||||
let href = siteRoot + 'published' + Utils.joinPath(path, dirent.name);
|
||||
let iconUrl = Utils.getDirentIcon(dirent);
|
||||
|
||||
return (
|
||||
|
@@ -151,13 +151,13 @@ class WikiMarkdownViewer extends React.Component {
|
||||
if (Utils.isInternalMarkdownLink(url, repoID)) {
|
||||
let path = Utils.getPathFromInternalMarkdownLink(url, repoID);
|
||||
// replace url
|
||||
item.data.href = serviceURL + '/wikis/' + slug + path;
|
||||
item.data.href = serviceURL + '/published/' + slug + path;
|
||||
}
|
||||
// change dir url
|
||||
else if (Utils.isInternalDirLink(url, repoID)) {
|
||||
let path = Utils.getPathFromInternalDirLink(url, repoID);
|
||||
// replace url
|
||||
item.data.href = serviceURL + '/wikis/' + slug + path;
|
||||
item.data.href = serviceURL + '/published/' + slug + path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -93,7 +93,7 @@ class MainPanel extends Component {
|
||||
<div className="main-panel-center">
|
||||
<div className="cur-view-path">
|
||||
<div className="path-containter">
|
||||
<a href={siteRoot + 'wikis/' + slug} className="normal">{slug}</a>
|
||||
<a href={siteRoot + 'published/' + slug} className="normal">{slug}</a>
|
||||
{this.renderNavPath()}
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -473,19 +473,19 @@ export const Utils = {
|
||||
|
||||
isWikiInternalMarkdownLink: function(url, slug) {
|
||||
slug = encodeURIComponent(slug);
|
||||
var re = new RegExp(serviceURL + '/wikis/' + slug + '.*\.md$');
|
||||
var re = new RegExp(serviceURL + '/published/' + slug + '.*\.md$');
|
||||
return re.test(url);
|
||||
},
|
||||
|
||||
isWikiInternalDirLink: function(url, slug) {
|
||||
slug = encodeURIComponent(slug);
|
||||
var re = new RegExp(serviceURL + '/wikis/' + slug + '.*');
|
||||
var re = new RegExp(serviceURL + '/published/' + slug + '.*');
|
||||
return re.test(url);
|
||||
},
|
||||
|
||||
getPathFromWikiInternalMarkdownLink: function(url, slug) {
|
||||
slug = encodeURIComponent(slug);
|
||||
var re = new RegExp(serviceURL + '/wikis/' + slug + '(.*\.md)');
|
||||
var re = new RegExp(serviceURL + '/published/' + slug + '(.*\.md)');
|
||||
var array = re.exec(url);
|
||||
var path = array[1];
|
||||
try {
|
||||
@@ -499,7 +499,7 @@ export const Utils = {
|
||||
|
||||
getPathFromWikiInternalDirLink: function(url, slug) {
|
||||
slug = encodeURIComponent(slug);
|
||||
var re = new RegExp(serviceURL + '/wikis/' + slug + '(/.*)');
|
||||
var re = new RegExp(serviceURL + '/published/' + slug + '(/.*)');
|
||||
var array = re.exec(url);
|
||||
var path = array[1];
|
||||
try {
|
||||
|
@@ -58,7 +58,7 @@ class Wiki extends Component {
|
||||
this.showDir('/');
|
||||
} else {
|
||||
this.setState({pathExist: false});
|
||||
let fileUrl = siteRoot + 'wikis/' + slug + Utils.encodePath(initialPath);
|
||||
let fileUrl = siteRoot + 'published/' + slug + Utils.encodePath(initialPath);
|
||||
window.history.pushState({url: fileUrl, path: initialPath}, initialPath, fileUrl);
|
||||
}
|
||||
} else if (isDir === 'True') {
|
||||
@@ -102,7 +102,7 @@ class Wiki extends Component {
|
||||
this.loadDirentList(dirPath);
|
||||
|
||||
// update location url
|
||||
let fileUrl = siteRoot + 'wikis/' + slug + Utils.encodePath(dirPath);
|
||||
let fileUrl = siteRoot + 'published/' + slug + Utils.encodePath(dirPath);
|
||||
window.history.pushState({url: fileUrl, path: dirPath}, dirPath, fileUrl);
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ class Wiki extends Component {
|
||||
});
|
||||
|
||||
const hash = window.location.hash;
|
||||
let fileUrl = siteRoot + 'wikis/' + slug + Utils.encodePath(filePath) + hash;
|
||||
let fileUrl = siteRoot + 'published/' + slug + Utils.encodePath(filePath) + hash;
|
||||
if (filePath === '/home.md') {
|
||||
window.history.replaceState({url: fileUrl, path: filePath}, filePath, fileUrl);
|
||||
} else {
|
||||
|
@@ -497,6 +497,7 @@ urlpatterns = [
|
||||
url(r'^inst/', include('seahub.institutions.urls', app_name='institutions', namespace='institutions')),
|
||||
url(r'^invite/', include('seahub.invitations.urls', app_name='invitations', namespace='invitations')),
|
||||
url(r'^terms/', include('termsandconditions.urls')),
|
||||
url(r'^published/', include('seahub.wiki.urls', app_name='wiki', namespace='wiki')),
|
||||
url(r'^wikis/', include('seahub.wiki.urls', app_name='wiki', namespace='wiki')),
|
||||
url(r'^drafts/', include('seahub.drafts.urls', app_name='drafts', namespace='drafts')),
|
||||
|
||||
|
@@ -29,7 +29,7 @@ class WikisViewTest(BaseTestCase):
|
||||
json_resp = json.loads(resp.content)
|
||||
assert len(json_resp['data']) == 1
|
||||
assert json_resp['data'][0]['name'] == wiki.name
|
||||
assert 'wikis/test-wiki' in json_resp['data'][0]['link']
|
||||
assert 'published/test-wiki' in json_resp['data'][0]['link']
|
||||
assert json_resp['data'][0]['owner'] == self.user.username
|
||||
print json_resp['data'][0]['created_at']
|
||||
assert json_resp['data'][0]['created_at'] is not None
|
||||
@@ -53,7 +53,7 @@ class WikisViewTest(BaseTestCase):
|
||||
json_resp = json.loads(resp.content)
|
||||
assert len(json_resp['data']) == 1
|
||||
assert json_resp['data'][0]['name'] == wiki.name
|
||||
assert 'wikis/test-wiki' in json_resp['data'][0]['link']
|
||||
assert 'published/test-wiki' in json_resp['data'][0]['link']
|
||||
assert json_resp['data'][0]['owner'] == self.user.username
|
||||
|
||||
def test_can_add(self):
|
||||
|
@@ -10,7 +10,7 @@ class WikiTest(BaseTestCase):
|
||||
wiki = Wiki.objects.add('new wiki', self.user.username)
|
||||
|
||||
d = wiki.to_dict()
|
||||
assert 'wikis/new-wiki/' in d['link']
|
||||
assert 'published/new-wiki/' in d['link']
|
||||
assert 'new-wiki' == d['slug']
|
||||
assert 'T' in d['created_at']
|
||||
assert 'T' in d['updated_at']
|
||||
|
@@ -17,4 +17,4 @@ class SlugTest(BaseTestCase):
|
||||
def test_old_home_page(self, ):
|
||||
resp = self.client.get(reverse('wiki:slug', args=['new-wiki', 'home']))
|
||||
self.assertEqual(302, resp.status_code)
|
||||
self.assertRegexpMatches(resp['Location'], '/wikis/new-wiki/home.md')
|
||||
self.assertRegexpMatches(resp['Location'], '/published/new-wiki/home.md')
|
||||
|
Reference in New Issue
Block a user