Add {{presence_events}} template.

pull/977/head
Kegan Dougal 9 years ago
parent e046402a4a
commit 9abadaf7af

@ -1,6 +1,8 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"title": "Presence Event",
"description": "Informs the client of a user's presence state change.",
"properties": {
"content": {
"type": "object",

@ -14,6 +14,20 @@ class MatrixSections(Sections):
def render_spec_version(self):
return "0.1.0"
def _render_events(self, filterFn, sortFn):
template = self.env.get_template("events.tmpl")
examples = self.units.get("event_examples")
schemas = self.units.get("event_schemas")
sections = []
for event_name in sortFn(schemas):
if not filterFn(event_name):
continue
sections.append(template.render(
example=examples[event_name],
event=schemas[event_name]
))
return "\n\n".join(sections)
def render_room_events(self):
template = self.env.get_template("events.tmpl")
examples = self.units.get("event_examples")
@ -66,6 +80,11 @@ class MatrixSections(Sections):
))
return "\n\n".join(sections)
def render_presence_events(self):
def filterFn(eventType):
return eventType.startswith("m.presence")
return self._render_events(filterFn, sorted)
def _render_ce_type(self, type):
template = self.env.get_template("common-event-fields.tmpl")
ce_types = self.units.get("common_event_fields")

@ -170,6 +170,8 @@ class MatrixUnits(Units):
schema["typeof"] = base_defs.get(
json_schema["allOf"][0].get("$ref")
)
elif json_schema.get("title"):
schema["typeof"] = json_schema["title"]
# add type
schema["type"] = Units.prop(

Loading…
Cancel
Save