parent
19a89c9a9e
commit
f49084a6a9
2 changed files with 25 additions and 20 deletions
|
|
@ -57,7 +57,7 @@ class RedmineBackend(BaseBackend, ICapContent, ICapBugTracker, ICapCollection):
|
||||||
def id2path(self, id):
|
def id2path(self, id):
|
||||||
return id.split('/', 2)
|
return id.split('/', 2)
|
||||||
|
|
||||||
def get_content(self, id):
|
def get_content(self, id, revision=None):
|
||||||
if isinstance(id, basestring):
|
if isinstance(id, basestring):
|
||||||
content = Content(id)
|
content = Content(id)
|
||||||
else:
|
else:
|
||||||
|
|
@ -69,8 +69,9 @@ class RedmineBackend(BaseBackend, ICapContent, ICapBugTracker, ICapCollection):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
version = revision.id if revision else None
|
||||||
with self.browser:
|
with self.browser:
|
||||||
data = self.browser.get_wiki_source(project, page)
|
data = self.browser.get_wiki_source(project, page, version)
|
||||||
|
|
||||||
content.content = data
|
content.content = data
|
||||||
return content
|
return content
|
||||||
|
|
|
||||||
|
|
@ -36,21 +36,22 @@ __all__ = ['RedmineBrowser']
|
||||||
# Browser
|
# Browser
|
||||||
class RedmineBrowser(BaseBrowser):
|
class RedmineBrowser(BaseBrowser):
|
||||||
ENCODING = 'utf-8'
|
ENCODING = 'utf-8'
|
||||||
PAGES = {'https?://[^/]+/': IndexPage,
|
PAGES = {
|
||||||
'https?://[^/]+/login': LoginPage,
|
'https?://[^/]+/': IndexPage,
|
||||||
# compatibility with redmine 0.9
|
'https?://[^/]+/login': LoginPage,
|
||||||
'https?://[^/]+/login\?back_url.*': MyPage,
|
# compatibility with redmine 0.9
|
||||||
'https?://[^/]+/my/page': MyPage,
|
'https?://[^/]+/login\?back_url.*': MyPage,
|
||||||
'https?://[^/]+/projects': ProjectsPage,
|
'https?://[^/]+/my/page': MyPage,
|
||||||
'https?://[^/]+/projects/([\w-]+)/wiki/([^\/]+)/edit': WikiEditPage,
|
'https?://[^/]+/projects': ProjectsPage,
|
||||||
'https?://[^/]+/projects/[\w-]+/wiki/[^\/]*': WikiPage,
|
'https?://[^/]+/projects/([\w-]+)/wiki/([^\/]+)/edit(?:\?version=\d+)?': WikiEditPage,
|
||||||
'https?://[^/]+/projects/[\w-]+/issues/new': NewIssuePage,
|
'https?://[^/]+/projects/[\w-]+/wiki/[^\/]*': WikiPage,
|
||||||
'https?://[^/]+/projects/[\w-]+/issues': IssuesPage,
|
'https?://[^/]+/projects/[\w-]+/issues/new': NewIssuePage,
|
||||||
'https?://[^/]+/issues(|/?\?.*)': IssuesPage,
|
'https?://[^/]+/projects/[\w-]+/issues': IssuesPage,
|
||||||
'https?://[^/]+/issues/(\d+)': IssuePage,
|
'https?://[^/]+/issues(|/?\?.*)': IssuesPage,
|
||||||
'https?://[^/]+/issues/(\d+)/time_entries/new': IssueLogTimePage,
|
'https?://[^/]+/issues/(\d+)': IssuePage,
|
||||||
'https?://[^/]+/projects/[\w-]+/time_entries': IssueTimeEntriesPage,
|
'https?://[^/]+/issues/(\d+)/time_entries/new': IssueLogTimePage,
|
||||||
}
|
'https?://[^/]+/projects/[\w-]+/time_entries': IssueTimeEntriesPage,
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, url, *args, **kwargs):
|
def __init__(self, url, *args, **kwargs):
|
||||||
self._userid = 0
|
self._userid = 0
|
||||||
|
|
@ -86,8 +87,11 @@ class RedmineBrowser(BaseBrowser):
|
||||||
def get_userid(self):
|
def get_userid(self):
|
||||||
return self._userid
|
return self._userid
|
||||||
|
|
||||||
def get_wiki_source(self, project, page):
|
def get_wiki_source(self, project, page, version=None):
|
||||||
self.location('%s/projects/%s/wiki/%s/edit' % (self.BASEPATH, project, urllib.quote(page.encode('utf-8'))))
|
url = '%s/projects/%s/wiki/%s/edit' % (self.BASEPATH, project, urllib.quote(page.encode('utf-8')))
|
||||||
|
if version:
|
||||||
|
url += '?version=%s' % version
|
||||||
|
self.location(url)
|
||||||
return self.page.get_source()
|
return self.page.get_source()
|
||||||
|
|
||||||
def set_wiki_source(self, project, page, data, message):
|
def set_wiki_source(self, project, page, data, message):
|
||||||
|
|
@ -96,7 +100,7 @@ class RedmineBrowser(BaseBrowser):
|
||||||
|
|
||||||
def get_wiki_preview(self, project, page, data):
|
def get_wiki_preview(self, project, page, data):
|
||||||
if (not self.is_on_page(WikiEditPage) or self.page.groups[0] != project
|
if (not self.is_on_page(WikiEditPage) or self.page.groups[0] != project
|
||||||
or self.page.groups[1] != page):
|
or self.page.groups[1] != page):
|
||||||
self.location('%s/projects/%s/wiki/%s/edit' % (self.BASEPATH,
|
self.location('%s/projects/%s/wiki/%s/edit' % (self.BASEPATH,
|
||||||
project, urllib.quote(page.encode('utf-8'))))
|
project, urllib.quote(page.encode('utf-8'))))
|
||||||
url = '%s/projects/%s/wiki/%s/preview' % (self.BASEPATH, project, urllib.quote(page.encode('utf-8')))
|
url = '%s/projects/%s/wiki/%s/preview' % (self.BASEPATH, project, urllib.quote(page.encode('utf-8')))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue