mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 06:53:25 +00:00
docs: Automate creation of Hubot documentation lozenges.
This removes a bunch of semi-duplicated code.
This commit is contained in:
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
@@ -68,60 +68,14 @@
|
||||
<a class="integration-link integration-hubot" href="#hubot"><span class="integration-label">Hubot</span></a> follows below:</p>
|
||||
|
||||
<div class="integration-lozenges">
|
||||
<div class="integration-lozenge integration-assembla">
|
||||
<a class="integration-link integration-assembla" href="https://github.com/hubot-scripts/hubot-assembla" target="_blank">
|
||||
<img class="integration-logo" src="/static/images/integrations/logos/assembla.png" alt="Assembla logo" />
|
||||
<span class="integration-label">Assembla</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="integration-lozenge integration-bonusly">
|
||||
<a class="integration-link integration-bonusly" href="https://github.com/hubot-scripts/hubot-bonusly" target="_blank">
|
||||
<img class="integration-logo" src="/static/images/integrations/logos/bonusly.png" alt="Bonusly logo" />
|
||||
<span class="integration-label">Bonusly</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="integration-lozenge integration-chartbeat">
|
||||
<a class="integration-link integration-chartbeat" href="https://github.com/hubot-scripts/hubot-chartbeat" target="_blank">
|
||||
<img class="integration-logo" src="/static/images/integrations/logos/chartbeat.png" alt="Chartbeat logo" />
|
||||
<span class="integration-label">Chartbeat</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="integration-lozenge integration-darksky">
|
||||
<a class="integration-link integration-darksky" href="https://github.com/hubot-scripts/hubot-darksky" target="_blank">
|
||||
<img class="integration-logo" src="/static/images/integrations/logos/darksky.png" alt="Dark Sky logo" />
|
||||
<span class="integration-label">Dark Sky</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="integration-lozenge integration-hangouts">
|
||||
<a class="integration-link integration-hangouts" href="https://github.com/hubot-scripts/hubot-google-hangouts" target="_blank">
|
||||
<img class="integration-logo" src="/static/images/integrations/logos/hangouts.png" alt="Hangouts logo" />
|
||||
<span class="integration-label">Hangouts</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="integration-lozenge integration-instagram">
|
||||
<a class="integration-link integration-instagram" href="https://github.com/hubot-scripts/hubot-instagram" target="_blank">
|
||||
<img class="integration-logo" src="/static/images/integrations/logos/instagram.png" alt="Instagram logo" />
|
||||
<span class="integration-label">Instagram</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="integration-lozenge integration-mailchimp">
|
||||
<a class="integration-link integration-mailchimp" href="https://github.com/hubot-scripts/hubot-mailchimp" target="_blank">
|
||||
<img class="integration-logo" src="/static/images/integrations/logos/mailchimp.png" alt="MailChimp logo" />
|
||||
<span class="integration-label">MailChimp</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="integration-lozenge integration-translate">
|
||||
<a class="integration-link integration-translate" href="https://github.com/hubot-scripts/hubot-google-translate" target="_blank">
|
||||
<img class="integration-logo" src="/static/images/integrations/logos/translate.png" alt="Google Translate logo" />
|
||||
<span class="integration-label">Translate</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="integration-lozenge integration-youtube">
|
||||
<a class="integration-link integration-youtube" href="https://github.com/hubot-scripts/hubot-youtube" target="_blank">
|
||||
<img class="integration-logo" src="/static/images/integrations/logos/youtube.png" alt="YouTube logo" />
|
||||
<span class="integration-label">YouTube</span>
|
||||
{% for integration in hubot_lozenges_dict.values() %}
|
||||
<div class="integration-lozenge integration-{{ integration.name }}">
|
||||
<a class="integration-link integration-{{ integration.name }}" href="{{ integration.git_url }}">
|
||||
<img class="integration-logo" src="/{{ integration.logo }}" alt="{{ integration.logo_alt }} logo" />
|
||||
<span class="integration-label">{{ integration.display_name}}</span>
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<div id="integration-instructions-group">
|
||||
|
||||
@@ -76,6 +76,20 @@ class WebhookIntegration(Integration):
|
||||
# type: () -> LocaleRegexProvider
|
||||
return url(self.url, self.function)
|
||||
|
||||
class HubotLozenge(Integration):
|
||||
GIT_URL_TEMPLATE = "https://github.com/hubot-scripts/hubot-{}"
|
||||
|
||||
def __init__(self, name, display_name=None, logo=None, logo_alt=None, git_url=None):
|
||||
# type: (str, Optional[str], Optional[str], Optional[str], Optional[str]) -> None
|
||||
if logo_alt is None:
|
||||
logo_alt = "{} logo".format(name.title())
|
||||
self.logo_alt = logo_alt
|
||||
|
||||
if git_url is None:
|
||||
git_url = self.GIT_URL_TEMPLATE.format(name)
|
||||
self.git_url = git_url
|
||||
super(HubotLozenge, self).__init__(name, name, logo, display_name=display_name)
|
||||
|
||||
|
||||
WEBHOOK_INTEGRATIONS = [
|
||||
WebhookIntegration('airbrake'),
|
||||
@@ -164,5 +178,17 @@ INTEGRATIONS = {
|
||||
|
||||
} # type: Dict[str, Integration]
|
||||
|
||||
HUBOT_LOZENGES = {
|
||||
'assembla': HubotLozenge('assembla'),
|
||||
'bonusly': HubotLozenge('bonusly'),
|
||||
'chartbeat': HubotLozenge('chartbeat'),
|
||||
'darksky': HubotLozenge('darksky', display_name='Dark Sky', logo_alt='Dark Sky logo'),
|
||||
'hangouts': HubotLozenge('google-hangouts', display_name="Hangouts"),
|
||||
'instagram': HubotLozenge('instagram'),
|
||||
'mailchump': HubotLozenge('mailchimp', display_name='MailChimp', logo_alt='MailChimp logo'),
|
||||
'translate': HubotLozenge('google-translate', display_name="Translate", logo_alt='Google Translate logo'),
|
||||
'youtube': HubotLozenge('youtube', display_name='YouTube', logo_alt='YouTube logo')
|
||||
}
|
||||
|
||||
for integration in WEBHOOK_INTEGRATIONS:
|
||||
INTEGRATIONS[integration.name] = integration
|
||||
|
||||
@@ -8,7 +8,7 @@ from django.test import TestCase, override_settings
|
||||
from typing import Any
|
||||
|
||||
from zproject.settings import DEPLOY_ROOT
|
||||
from zerver.lib.integrations import INTEGRATIONS
|
||||
from zerver.lib.integrations import INTEGRATIONS, HUBOT_LOZENGES
|
||||
from zerver.lib.test_helpers import HostRequestMock
|
||||
from zerver.views.integrations import add_api_uri_context
|
||||
|
||||
@@ -18,6 +18,11 @@ class IntegrationTest(TestCase):
|
||||
for integration in INTEGRATIONS.values():
|
||||
self.assertTrue(os.path.isfile(os.path.join(DEPLOY_ROOT, integration.logo)))
|
||||
|
||||
def test_check_if_every_hubot_lozenges_has_logo_that_exists(self):
|
||||
# type: () -> None
|
||||
for integration in HUBOT_LOZENGES.values():
|
||||
self.assertTrue(os.path.isfile(os.path.join(DEPLOY_ROOT, integration.logo)))
|
||||
|
||||
@override_settings(REALMS_HAVE_SUBDOMAINS=False)
|
||||
def test_api_url_view_base(self):
|
||||
# type: () -> None
|
||||
|
||||
@@ -9,7 +9,7 @@ import os
|
||||
import ujson
|
||||
|
||||
from zerver.lib import bugdown
|
||||
from zerver.lib.integrations import INTEGRATIONS
|
||||
from zerver.lib.integrations import INTEGRATIONS, HUBOT_LOZENGES
|
||||
from zerver.lib.utils import get_subdomain
|
||||
from zproject.jinja2 import render_to_response
|
||||
|
||||
@@ -85,7 +85,9 @@ class IntegrationView(ApiURLView):
|
||||
# type: (Optional[Dict[str, Any]]) -> Dict[str, Any]
|
||||
context = super(IntegrationView, self).get_context_data(**kwargs) # type: Dict[str, Any]
|
||||
alphabetical_sorted_integration = OrderedDict(sorted(INTEGRATIONS.items()))
|
||||
alphabetical_sorted_hubot_lozenges = OrderedDict(sorted(HUBOT_LOZENGES.items()))
|
||||
context['integrations_dict'] = alphabetical_sorted_integration
|
||||
context['hubot_lozenges_dict'] = alphabetical_sorted_hubot_lozenges
|
||||
|
||||
if context["html_settings_links"]:
|
||||
settings_html = '<a href="../#settings">Zulip settings page</a>'
|
||||
|
||||
Reference in New Issue
Block a user