From aeb69dfd61594e18a447b21cdfd4a5f574779d46 Mon Sep 17 00:00:00 2001 From: Greg Price Date: Fri, 27 Oct 2017 18:58:15 -0700 Subject: [PATCH] template context: Eliminate now-constant variable `api_site_required`. --- docs/integration-docs-guide.md | 3 +-- templates/zerver/api.html | 18 +++++++++--------- templates/zerver/help/include/zulip-config.md | 2 +- templates/zerver/integrations/mercurial.md | 4 ++-- templates/zerver/integrations/nagios.md | 2 +- zerver/context_processors.py | 1 - 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/docs/integration-docs-guide.md b/docs/integration-docs-guide.md index 67ba27ca53..66862e0af1 100644 --- a/docs/integration-docs-guide.md +++ b/docs/integration-docs-guide.md @@ -102,8 +102,7 @@ Here are a few common macros used to document Zulip's integrations: `{{ external_api_uri }}` template variable, so that your integration documentation will provide the correct URL for whatever server it is deployed on. If special configuration is required to set the SITE - variable, you should document that too, inside an `{% if - api_site_required %}` check. + variable, you should document that too. * **Example usage:** ``` diff --git a/templates/zerver/api.html b/templates/zerver/api.html index d2abb5a5ec..5c3963648b 100644 --- a/templates/zerver/api.html +++ b/templates/zerver/api.html @@ -106,24 +106,24 @@ Sample steps to do:

Stream message

zulip-send --stream Denmark --subject Castle \
---user othello-bot@example.com --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5{% if api_site_required %} \
---site={{ external_api_uri_subdomain }}{% endif %}
+--user othello-bot@example.com --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 \ +--site={{ external_api_uri_subdomain }}

Private message

zulip-send hamlet@example.com \
---user othello-bot@example.com --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5{% if api_site_required %} \
---site={{ external_api_uri_subdomain }}{% endif %}
+--user othello-bot@example.com --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 \ +--site={{ external_api_uri_subdomain }}

Passing in the message on the command-line

If you'd like, you can also provide the message on the command-line with the -m flag, as follows:

zulip-send --stream Denmark --subject Castle \
 -m "Something is rotten in the state of Denmark." \
---user othello-bot@example.com --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5{% if api_site_required %} \
---site={{ external_api_uri_subdomain }}{% endif %}
+--user othello-bot@example.com --api-key a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5 \
+--site={{ external_api_uri_subdomain }}
 
-

You can omit the user{% if api_site_required %}, api-key, and - site{% else %} and api-key{% endif %} arguments if you have a +

You can omit the user, api-key, and + site arguments if you have a ~/.zuliprc file.

See also the full API endpoint documentation.

@@ -192,7 +192,7 @@ Sample steps to do:
[api]
 key=BOT_API_KEY
 email=BOT_EMAIL_ADDRESS
-{% if api_site_required %}site={{ external_api_uri_subdomain }}{% endif %}
+site={{ external_api_uri_subdomain }}

Additionally, you can also specify the parameters as environment variables as follows:

export ZULIP_CONFIG=/path/to/zulipconfig
diff --git a/templates/zerver/help/include/zulip-config.md b/templates/zerver/help/include/zulip-config.md
index 792d8bc89e..3a7d62b7ac 100644
--- a/templates/zerver/help/include/zulip-config.md
+++ b/templates/zerver/help/include/zulip-config.md
@@ -1,5 +1,5 @@
 ```
 ZULIP_USER = "{{ integration_name }}-bot@example.com"
 ZULIP_API_KEY = "0123456789abcdef0123456789abcdef"
-{% if api_site_required %}ZULIP_SITE = "{{ external_api_uri_subdomain }}"{% endif %}
+ZULIP_SITE = "{{ external_api_uri_subdomain }}"
 ```
diff --git a/templates/zerver/integrations/mercurial.md b/templates/zerver/integrations/mercurial.md
index 9425764ff7..78dcb4b6ac 100644
--- a/templates/zerver/integrations/mercurial.md
+++ b/templates/zerver/integrations/mercurial.md
@@ -20,7 +20,7 @@ hook if it installs in a different location on this system:
         email = "hg-bot@example.com"
         api_key = "0123456789abcdefg"
         stream = "commits"
-        {% if api_site_required %}site = {{ external_api_uri_subdomain }}{% endif %}
+        site = {{ external_api_uri_subdomain }}
 
 That’s all it takes for the basic setup! On the next `hg push`, you’ll
 get a Zulip update for the changeset.
@@ -44,7 +44,7 @@ notifications:
     api_key = "0123456789abcdefg"
     stream = "commits"
     web_url = "http://hg.example.com:8000/"
-    {% if api_site_required %}site = {{ external_api_uri_subdomain }}{% endif %}
+    site = {{ external_api_uri_subdomain }}
 
 [1]: http://mercurial.selenic.com/wiki/QuickStart#Network_support
 
diff --git a/templates/zerver/integrations/nagios.md b/templates/zerver/integrations/nagios.md
index 6825b6088d..30b874db77 100644
--- a/templates/zerver/integrations/nagios.md
+++ b/templates/zerver/integrations/nagios.md
@@ -14,7 +14,7 @@ on your Nagios server:
 [api]
 email = NAGIOS_BOT_EMAIL_ADDRESS
 key = NAGIOS_BOT_API_KEY
-{% if api_site_required %}site = {{ external_api_uri_subdomain }}{% endif %}
+site = {{ external_api_uri_subdomain }}
 ```
 
 Copy `integrations/nagios/zulip_nagios.cfg` to `/etc/nagios3/conf.d`
diff --git a/zerver/context_processors.py b/zerver/context_processors.py
index e895be4cf9..881bff539f 100644
--- a/zerver/context_processors.py
+++ b/zerver/context_processors.py
@@ -120,7 +120,6 @@ def zulip_default_context(request):
         'realm_icon': realm_icon,
         'realm_description': realm_description,
         'root_domain_uri': settings.ROOT_DOMAIN_URI,
-        'api_site_required': True,
         'email_gateway_example': settings.EMAIL_GATEWAY_EXAMPLE,
         'apps_page_url': apps_page_url,
         'open_realm_creation': settings.OPEN_REALM_CREATION,