Mercurial > libervia-web
comparison libervia/pages/merge-requests/edit/page_meta.py @ 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 | 28e3eb3bb217 |
children | 29eb15062416 |
comparison
equal
deleted
inserted
replaced
1142:003597f895a0 | 1143:7bd47d32da87 |
---|---|
66 ticket.widgets[u"labels"].value = ticket.widgets[u"labels"].value.replace( | 66 ticket.widgets[u"labels"].value = ticket.widgets[u"labels"].value.replace( |
67 u"\n", ", " | 67 u"\n", ", " |
68 ) | 68 ) |
69 except KeyError: | 69 except KeyError: |
70 pass | 70 pass |
71 | |
72 # same as tickets_edit | |
73 wid = ticket.widgets[u'body'] | |
74 if wid.type == u"xhtmlbox": | |
75 wid.type = u"textbox" | |
76 wid.value = yield self.host.bridgeCall( | |
77 u"syntaxConvert", wid.value, C.SYNTAX_XHTML, u"markdown", | |
78 False, profile) | |
79 | |
71 template_data[u"new_ticket_xmlui"] = ticket | 80 template_data[u"new_ticket_xmlui"] = ticket |
72 | 81 |
73 | 82 |
74 @defer.inlineCallbacks | 83 @defer.inlineCallbacks |
75 def on_data_post(self, request): | 84 def on_data_post(self, request): |
83 try: | 92 try: |
84 posted_data["labels"] = [l.strip() for l in posted_data["labels"][0].split(",")] | 93 posted_data["labels"] = [l.strip() for l in posted_data["labels"][0].split(",")] |
85 except (KeyError, IndexError): | 94 except (KeyError, IndexError): |
86 pass | 95 pass |
87 profile = self.getProfile(request) | 96 profile = self.getProfile(request) |
97 | |
98 # we convert back body to XHTML | |
99 body = yield self.host.bridgeCall( | |
100 u"syntaxConvert", posted_data[u'body'][0], u"markdown", C.SYNTAX_XHTML, | |
101 False, profile) | |
102 posted_data[u'body'] = [u'<div xmlns="{ns}">{body}</div>'.format(ns=C.NS_XHTML, | |
103 body=body)] | |
104 | |
88 yield self.host.bridgeCall( | 105 yield self.host.bridgeCall( |
89 "mergeRequestSet", | 106 "mergeRequestSet", |
90 service.full(), | 107 service.full(), |
91 node, | 108 node, |
92 u"", | 109 u"", |