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