# HG changeset patch # User Goffi # Date 1547894557 -3600 # Node ID 7bd47d32da8756ca6035119039f93e5b02cc3ab8 # Parent 003597f895a0519ded2c30fe24f6fd7716d7f056 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. diff -r 003597f895a0 -r 7bd47d32da87 libervia/pages/merge-requests/edit/page_meta.py --- 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'
{body}
'.format(ns=C.NS_XHTML, + body=body)] + yield self.host.bridgeCall( "mergeRequestSet", service.full(), diff -r 003597f895a0 -r 7bd47d32da87 libervia/pages/tickets/edit/page_meta.py --- 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'
{body}
'.format(ns=C.NS_XHTML, + body=body)] + yield self.host.bridgeCall( "ticketSet", service.full(), node, posted_data, u"", ticket_id, {}, profile ) diff -r 003597f895a0 -r 7bd47d32da87 libervia/pages/tickets/new/page_meta.py --- 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'
{body}
'.format(ns=C.NS_XHTML, + body=body)] + + yield self.host.bridgeCall( "ticketSet", service.full(), node, posted_data, u"", u"", {}, profile )