Mercurial > libervia-web
changeset 1143:7bd47d32da87
pages (tickets, merge-requests): convert body from/to markdown while editing/creating new ticket:
there is currently no way to edit XHTML directly inside the browser with Libervia pages, this patch works around this by doing a conversion to/from markdown.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 19 Jan 2019 11:42:37 +0100 |
parents | 003597f895a0 |
children | 2af117bfe6cc |
files | libervia/pages/merge-requests/edit/page_meta.py libervia/pages/tickets/edit/page_meta.py libervia/pages/tickets/new/page_meta.py |
diffstat | 3 files changed, 52 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libervia/pages/merge-requests/edit/page_meta.py Fri Jan 11 21:47:10 2019 +0100 +++ b/libervia/pages/merge-requests/edit/page_meta.py Sat Jan 19 11:42:37 2019 +0100 @@ -68,6 +68,15 @@ ) except KeyError: pass + + # same as tickets_edit + wid = ticket.widgets[u'body'] + if wid.type == u"xhtmlbox": + wid.type = u"textbox" + wid.value = yield self.host.bridgeCall( + u"syntaxConvert", wid.value, C.SYNTAX_XHTML, u"markdown", + False, profile) + template_data[u"new_ticket_xmlui"] = ticket @@ -85,6 +94,14 @@ except (KeyError, IndexError): pass profile = self.getProfile(request) + + # we convert back body to XHTML + body = yield self.host.bridgeCall( + u"syntaxConvert", posted_data[u'body'][0], u"markdown", C.SYNTAX_XHTML, + False, profile) + posted_data[u'body'] = [u'<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML, + body=body)] + yield self.host.bridgeCall( "mergeRequestSet", service.full(),
--- a/libervia/pages/tickets/edit/page_meta.py Fri Jan 11 21:47:10 2019 +0100 +++ b/libervia/pages/tickets/edit/page_meta.py Sat Jan 19 11:42:37 2019 +0100 @@ -66,6 +66,16 @@ ) except KeyError: pass + + # for now we don't have XHTML editor, so we'll go with a TextBox and a convertion + # to a text friendly syntax using markdown + wid = ticket.widgets[u'body'] + if wid.type == u"xhtmlbox": + wid.type = u"textbox" + wid.value = yield self.host.bridgeCall( + u"syntaxConvert", wid.value, C.SYNTAX_XHTML, u"markdown", + False, profile) + template_data[u"new_ticket_xmlui"] = ticket @@ -83,6 +93,14 @@ except (KeyError, IndexError): pass profile = self.getProfile(request) + + # we convert back body to XHTML + body = yield self.host.bridgeCall( + u"syntaxConvert", posted_data[u'body'][0], u"markdown", C.SYNTAX_XHTML, + False, profile) + posted_data[u'body'] = [u'<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML, + body=body)] + yield self.host.bridgeCall( "ticketSet", service.full(), node, posted_data, u"", ticket_id, {}, profile )
--- a/libervia/pages/tickets/new/page_meta.py Fri Jan 11 21:47:10 2019 +0100 +++ b/libervia/pages/tickets/new/page_meta.py Sat Jan 19 11:42:37 2019 +0100 @@ -40,6 +40,14 @@ xmlui_obj.widgets[u"labels"].type = u"string" except KeyError: pass + + # same as for tickets_edit, we have to convert for now + wid = xmlui_obj.widgets[u'body'] + if wid.type == u"xhtmlbox": + wid.type = u"textbox" + wid.value = yield self.host.bridgeCall( + u"syntaxConvert", wid.value, C.SYNTAX_XHTML, u"markdown", + False, profile) template_data[u"new_ticket_xmlui"] = xmlui_obj @@ -56,6 +64,15 @@ except (KeyError, IndexError): pass profile = self.getProfile(request) + + # we convert back body to XHTML + body = yield self.host.bridgeCall( + u"syntaxConvert", posted_data[u'body'][0], u"markdown", C.SYNTAX_XHTML, + False, profile) + posted_data[u'body'] = [u'<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML, + body=body)] + + yield self.host.bridgeCall( "ticketSet", service.full(), node, posted_data, u"", u"", {}, profile )