merge_requests: use XHTML for body

This commit is contained in:
Goffi 2019-01-19 11:39:02 +01:00
commit 9cfbbce2d1
2 changed files with 19 additions and 30 deletions

View file

@ -34,7 +34,7 @@ PLUGIN_INFO = {
C.PI_IMPORT_NAME: "MERGE_REQUESTS", C.PI_IMPORT_NAME: "MERGE_REQUESTS",
C.PI_TYPE: "EXP", C.PI_TYPE: "EXP",
C.PI_PROTOCOLS: [], C.PI_PROTOCOLS: [],
C.PI_DEPENDENCIES: ["XEP-0060", "PUBSUB_SCHEMA", "TICKETS"], C.PI_DEPENDENCIES: ["XEP-0060", "PUBSUB_SCHEMA", "TICKETS", "TEXT_SYNTAXES"],
C.PI_MAIN: "MergeRequests", C.PI_MAIN: "MergeRequests",
C.PI_HANDLER: "no", C.PI_HANDLER: "no",
C.PI_DESCRIPTION: _("""Merge requests management plugin""") C.PI_DESCRIPTION: _("""Merge requests management plugin""")
@ -67,9 +67,9 @@ class MergeRequests(object):
log.info(_(u"Merge requests plugin initialization")) log.info(_(u"Merge requests plugin initialization"))
self.host = host self.host = host
host.registerNamespace('merge_requests', NS_MERGE_REQUESTS) host.registerNamespace('merge_requests', NS_MERGE_REQUESTS)
self._p = self.host.plugins["XEP-0060"] self._p = self.host.plugins[u"XEP-0060"]
self._s = self.host.plugins["PUBSUB_SCHEMA"] self._s = self.host.plugins[u"PUBSUB_SCHEMA"]
self._t = self.host.plugins["TICKETS"] self._t = self.host.plugins[u"TICKETS"]
self._handlers = {} self._handlers = {}
self._handlers_list = [] # handlers sorted by priority self._handlers_list = [] # handlers sorted by priority
self._type_handlers = {} # data type => handler map self._type_handlers = {} # data type => handler map
@ -259,7 +259,14 @@ class MergeRequests(object):
if not values.get(u'title'): if not values.get(u'title'):
values[u'title'] = msg_lines[0] values[u'title'] = msg_lines[0]
if not values.get(u'body'): if not values.get(u'body'):
values[u'body'] = u'\n'.join(msg_lines[1:]) ts = self.host.plugins['TEXT_SYNTAXES']
xhtml = yield ts.convert(
u'\n'.join(msg_lines[1:]),
syntax_from = ts.SYNTAX_TEXT,
syntax_to = ts.SYNTAX_XHTML,
profile = client.profile)
values[u'body'] = '<div xmlns="{ns}">{xhtml}</div>'.format(
ns=C.NS_XHTML, xhtml=xhtml)
values[FIELD_DATA] = data values[FIELD_DATA] = data

View file

@ -83,16 +83,8 @@ class Tickets(object):
async=True, async=True,
) )
def _set( def _set(self, service, node, values, schema=None, item_id=None, extra=None,
self, profile_key=C.PROF_KEY_NONE):
service,
node,
values,
schema=None,
item_id=None,
extra=None,
profile_key=C.PROF_KEY_NONE,
):
client, service, node, schema, item_id, extra = self._s.prepareBridgeSet( client, service, node, schema, item_id, extra = self._s.prepareBridgeSet(
service, node, schema, item_id, extra, profile_key service, node, schema, item_id, extra, profile_key
) )
@ -103,18 +95,8 @@ class Tickets(object):
return d return d
@defer.inlineCallbacks @defer.inlineCallbacks
def set( def set(self, client, service, node, values, schema=None, item_id=None, extra=None,
self, deserialise=False, form_ns=NS_TICKETS):
client,
service,
node,
values,
schema=None,
item_id=None,
extra=None,
deserialise=False,
form_ns=NS_TICKETS,
):
"""Publish a tickets """Publish a tickets
@param node(unicode, None): Pubsub node to use @param node(unicode, None): Pubsub node to use
@ -135,9 +117,9 @@ class Tickets(object):
if not item_id: if not item_id:
comments_service = yield self._m.getCommentsService(client, service) comments_service = yield self._m.getCommentsService(client, service)
# we need to use uuid for comments node, because we don't know item id in advance # we need to use uuid for comments node, because we don't know item id in
# (we don't want to set it ourselves to let the server choose, so we can have # advance (we don't want to set it ourselves to let the server choose, so we
# a nicer id if serial ids is activated) # can have a nicer id if serial ids is activated)
comments_node = self._m.getCommentsNode( comments_node = self._m.getCommentsNode(
node + u"_" + unicode(shortuuid.uuid()) node + u"_" + unicode(shortuuid.uuid())
) )