From 3cb758d3392b8ae08342be732a09778447c0def2 Mon Sep 17 00:00:00 2001 From: Eeshan Garg Date: Wed, 24 May 2017 19:43:50 -0230 Subject: [PATCH] templates: Support parametric Markdown macros for webhooks docs. --- templates/zerver/help/include/create-bot-construct-url.md | 8 ++++---- templates/zerver/help/include/create-stream.md | 7 ++++--- templates/zerver/help/include/webhook-url.md | 1 + zerver/templatetags/app_filters.py | 7 +++++++ 4 files changed, 16 insertions(+), 7 deletions(-) create mode 100644 templates/zerver/help/include/webhook-url.md diff --git a/templates/zerver/help/include/create-bot-construct-url.md b/templates/zerver/help/include/create-bot-construct-url.md index 3b805fb1e6..c4dfa97084 100644 --- a/templates/zerver/help/include/create-bot-construct-url.md +++ b/templates/zerver/help/include/create-bot-construct-url.md @@ -1,5 +1,5 @@ -Next, on your {{ settings_html|safe }}, create a bot for this -integration. Construct the URL for this bot using the bot API key -and stream name: +Next, on your {{ settings_html|safe }}, create a bot for +{{ integration_display_name }}. Construct the URL for the +{{ integration_display_name }} bot using the bot API key and stream name: -`{{ external_api_uri_subdomain }}/v1/external/ +{!webhook-url.md!} diff --git a/templates/zerver/help/include/create-stream.md b/templates/zerver/help/include/create-stream.md index d65cbe2db2..3f269363a7 100644 --- a/templates/zerver/help/include/create-stream.md +++ b/templates/zerver/help/include/create-stream.md @@ -1,3 +1,4 @@ -First, create the stream you'd like to use for notifications from -this integration, and subscribe all interested parties to this stream. -We recommend the name +First, create the stream you'd like to use for +{{ integration_display_name }} notifications, and subscribe all +interested parties to this stream. We recommend the +name `{{ integration_name }}`. diff --git a/templates/zerver/help/include/webhook-url.md b/templates/zerver/help/include/webhook-url.md new file mode 100644 index 0000000000..cc742e114f --- /dev/null +++ b/templates/zerver/help/include/webhook-url.md @@ -0,0 +1 @@ +`{{ external_api_uri_subdomain }}{{ integration_url }}?api_key=abcdefgh&stream={{ integration_name }}` diff --git a/zerver/templatetags/app_filters.py b/zerver/templatetags/app_filters.py index 35f17d8493..b89f21fd3f 100644 --- a/zerver/templatetags/app_filters.py +++ b/zerver/templatetags/app_filters.py @@ -82,6 +82,13 @@ def render_markdown_path(markdown_file_path, context=None): if context is None: context = {} + if markdown_file_path.endswith('doc.md'): + integration_dir = markdown_file_path.split('/')[0] + integration = context['integrations_dict'][integration_dir] + context['integration_name'] = integration.name + context['integration_display_name'] = integration.display_name + context['integration_url'] = integration.url[3:] + jinja = engines['Jinja2'] markdown_string = jinja.env.loader.get_source(jinja.env, markdown_file_path)[0] html = md_engine.convert(markdown_string)