Small fixes and changes in qwebcontentedit and ICapContent.
- content preview's html code is now cleaner - ICapContent.preview_content() renamed to ICapContent.get_content_preview() - tab "preview" was shown first when starting qwebcontentedit. Fixed.
This commit is contained in:
parent
0c5a449e5f
commit
3cbb5671d3
5 changed files with 27 additions and 20 deletions
|
|
@ -73,13 +73,11 @@ class RedmineBackend(BaseBackend, ICapContent):
|
|||
with self.browser:
|
||||
return self.browser.set_wiki_source(project, page, content.content, message)
|
||||
|
||||
def preview_content(self, content):
|
||||
def get_content_preview(self, content):
|
||||
try:
|
||||
_type, project, page = self.id2path(content.id)
|
||||
except ValueError:
|
||||
return
|
||||
|
||||
with self.browser:
|
||||
return self.browser.get_wiki_preview(project, page, content.content)
|
||||
|
||||
|
||||
return self.browser.get_wiki_preview(project, page, content.content)
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
from urlparse import urlsplit
|
||||
import urllib
|
||||
import lxml.html
|
||||
|
||||
from weboob.tools.browser import BaseBrowser, BrowserIncorrectPassword
|
||||
|
||||
|
|
@ -77,12 +78,18 @@ class RedmineBrowser(BaseBrowser):
|
|||
self.page.set_source(data, message)
|
||||
|
||||
def get_wiki_preview(self, project, page, data):
|
||||
if not self.is_on_page(WikiEditPage) or self.page.groups[0] != project \
|
||||
or self.page.groups[1] != page:
|
||||
if (not self.is_on_page(WikiEditPage) or self.page.groups[0] != project
|
||||
or self.page.groups[1] != page):
|
||||
self.location('%s/projects/%s/wiki/%s/edit' % (self.BASEPATH,
|
||||
project, page))
|
||||
url = '%s/projects/%s/wiki/%s/preview' % (self.BASEPATH, project, page)
|
||||
params = {}
|
||||
params['content[text]'] = data.encode('utf-8')
|
||||
params['authenticity_token'] = "%s" % self.page.get_authenticity_token()
|
||||
return self.readurl(url, urllib.urlencode(params))
|
||||
preview_html = lxml.html.fragment_fromstring(self.readurl(url,
|
||||
urllib.urlencode(params)),
|
||||
create_parent='div')
|
||||
preview_html.find("fieldset").drop_tag()
|
||||
preview_html.find("legend").drop_tree()
|
||||
return lxml.html.tostring(preview_html)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue