Mercurial > libervia-backend
comparison sat/plugins/plugin_misc_merge_requests.py @ 2785:f18d8315929e
merge_requests: use XHTML for body
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 19 Jan 2019 11:39:02 +0100 |
parents | 003b8b4b56a7 |
children | 0b7ce5daee9b |
comparison
equal
deleted
inserted
replaced
2784:76ebecdb9b1e | 2785:f18d8315929e |
---|---|
32 PLUGIN_INFO = { | 32 PLUGIN_INFO = { |
33 C.PI_NAME: _("Merge requests management"), | 33 C.PI_NAME: _("Merge requests management"), |
34 C.PI_IMPORT_NAME: "MERGE_REQUESTS", | 34 C.PI_IMPORT_NAME: "MERGE_REQUESTS", |
35 C.PI_TYPE: "EXP", | 35 C.PI_TYPE: "EXP", |
36 C.PI_PROTOCOLS: [], | 36 C.PI_PROTOCOLS: [], |
37 C.PI_DEPENDENCIES: ["XEP-0060", "PUBSUB_SCHEMA", "TICKETS"], | 37 C.PI_DEPENDENCIES: ["XEP-0060", "PUBSUB_SCHEMA", "TICKETS", "TEXT_SYNTAXES"], |
38 C.PI_MAIN: "MergeRequests", | 38 C.PI_MAIN: "MergeRequests", |
39 C.PI_HANDLER: "no", | 39 C.PI_HANDLER: "no", |
40 C.PI_DESCRIPTION: _("""Merge requests management plugin""") | 40 C.PI_DESCRIPTION: _("""Merge requests management plugin""") |
41 } | 41 } |
42 | 42 |
65 | 65 |
66 def __init__(self, host): | 66 def __init__(self, host): |
67 log.info(_(u"Merge requests plugin initialization")) | 67 log.info(_(u"Merge requests plugin initialization")) |
68 self.host = host | 68 self.host = host |
69 host.registerNamespace('merge_requests', NS_MERGE_REQUESTS) | 69 host.registerNamespace('merge_requests', NS_MERGE_REQUESTS) |
70 self._p = self.host.plugins["XEP-0060"] | 70 self._p = self.host.plugins[u"XEP-0060"] |
71 self._s = self.host.plugins["PUBSUB_SCHEMA"] | 71 self._s = self.host.plugins[u"PUBSUB_SCHEMA"] |
72 self._t = self.host.plugins["TICKETS"] | 72 self._t = self.host.plugins[u"TICKETS"] |
73 self._handlers = {} | 73 self._handlers = {} |
74 self._handlers_list = [] # handlers sorted by priority | 74 self._handlers_list = [] # handlers sorted by priority |
75 self._type_handlers = {} # data type => handler map | 75 self._type_handlers = {} # data type => handler map |
76 host.bridge.addMethod("mergeRequestsGet", ".plugin", | 76 host.bridge.addMethod("mergeRequestsGet", ".plugin", |
77 in_sign='ssiassa{ss}s', out_sign='(asa{ss}aaa{ss})', | 77 in_sign='ssiassa{ss}s', out_sign='(asa{ss}aaa{ss})', |
257 commits_msg = patches[-1][self.META_COMMIT_MSG] | 257 commits_msg = patches[-1][self.META_COMMIT_MSG] |
258 msg_lines = commits_msg.splitlines() | 258 msg_lines = commits_msg.splitlines() |
259 if not values.get(u'title'): | 259 if not values.get(u'title'): |
260 values[u'title'] = msg_lines[0] | 260 values[u'title'] = msg_lines[0] |
261 if not values.get(u'body'): | 261 if not values.get(u'body'): |
262 values[u'body'] = u'\n'.join(msg_lines[1:]) | 262 ts = self.host.plugins['TEXT_SYNTAXES'] |
263 xhtml = yield ts.convert( | |
264 u'\n'.join(msg_lines[1:]), | |
265 syntax_from = ts.SYNTAX_TEXT, | |
266 syntax_to = ts.SYNTAX_XHTML, | |
267 profile = client.profile) | |
268 values[u'body'] = '<div xmlns="{ns}">{xhtml}</div>'.format( | |
269 ns=C.NS_XHTML, xhtml=xhtml) | |
263 | 270 |
264 values[FIELD_DATA] = data | 271 values[FIELD_DATA] = data |
265 | 272 |
266 item_id = yield self._t.set(client, service, node, values, schema, item_id, extra, | 273 item_id = yield self._t.set(client, service, node, values, schema, item_id, extra, |
267 deserialise, form_ns=NS_MERGE_REQUESTS) | 274 deserialise, form_ns=NS_MERGE_REQUESTS) |