templates: Merge Help and API doc main into documentation_main.

With minor fixes by eeshangarg.
This commit is contained in:
Lyla Fischer 2018-08-18 09:42:01 -04:00 committed by Eeshan Garg
parent 8b141e6dbc
commit 1efcdfdb5c
9 changed files with 23 additions and 45 deletions

View File

@ -1,35 +0,0 @@
{% extends "zerver/portico-help.html" %}
{# API information page #}
{% block portico_content %}
<div class="app help api-docs terms-page inline-block">
<div class="sidebar">
<div class="content">
<h1 class="no-arrow"><a href="/api/" class="no-underline">Home</a></h1>
{{ render_markdown_path("zerver/api/sidebar.md", api_uri_context) }}
<h1 class="home-link"><a href="/" class="no-underline">Back to Home</a></h1>
</div>
</div>
<svg height="32px" class="hamburger" style="enable-background:new 0 0 32 32;" version="1.1" viewBox="0 0 32 32" width="32px" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<path d="M4,10h24c1.104,0,2-0.896,2-2s-0.896-2-2-2H4C2.896,6,2,6.896,2,8S2.896,10,4,10z M28,14H4c-1.104,0-2,0.896-2,2 s0.896,2,2,2h24c1.104,0,2-0.896,2-2S29.104,14,28,14z M28,22H4c-1.104,0-2,0.896-2,2s0.896,2,2,2h24c1.104,0,2-0.896,2-2 S29.104,22,28,22z"></path>
</svg>
<div class="markdown">
<div class="content">
{{ render_markdown_path(article, api_uri_context) }}
<div id="footer" class="documentation-footer">
<hr />
<p>
We're here to help! Email us at
<a href="mailto:{{ support_email }}">{{ support_email }}</a>
with questions, feedback, or feature requests.
</p>
</div>
</div>
</div>
</div>
{{ render_bundle("help") }}
{% endblock %}

View File

@ -1,13 +1,13 @@
{% extends "zerver/portico-help.html" %}
{# Zulip User Documentation. #}
{# Zulip User and API Documentation. #}
{% block portico_content %}
<div class="app help terms-page inline-block">
<div class="sidebar slide">
<div class="{{ sidebar_class }}">
<div class="content">
<h1><a href="/help/" class="no-underline">Index</a></h1>
{{ render_markdown_path("zerver/help/include/sidebar.md", api_uri_context) }}
<h1><a href="{{ doc_root }}" class="no-underline">Index</a></h1>
{{ render_markdown_path(sidebar_index, api_uri_context) }}
<h1 class="home-link"><a href="/" class="no-underline">Back to Home</a></h1>
</div>
</div>

View File

@ -13,4 +13,4 @@ downloaded [here](https://zulipchat.com/apps/).
One Zulip account, associated with a particular company, project, or team,
is known as an **organization**.
{!sidebar.md!}
{!sidebar_index.md!}

View File

@ -711,8 +711,7 @@ def build_custom_checkers(by_lang):
'templates/zerver/register.html',
'templates/zerver/accounts_send_confirm.html',
'templates/zerver/integrations/index.html',
'templates/zerver/help/main.html',
'templates/zerver/api/main.html',
'templates/zerver/documentation_main.html',
'templates/analytics/realm_summary_table.html',
'templates/corporate/zephyr.html',
'templates/corporate/zephyr-mirror.html',

View File

@ -172,6 +172,8 @@ class TemplateTestCase(ZulipTestCase):
email = user_profile.email
context = dict(
sidebar_index="zerver/help/include/sidebar_index.md",
doc_root="/help/",
article="zerver/help/index.md",
shallow_tested=True,
user_profile=user_profile,

View File

@ -64,6 +64,8 @@ class MarkdownDirectoryView(ApiURLView):
def get_path(self, article: str) -> str:
if article == "":
article = "index"
elif article == "include/sidebar_index":
pass
elif "/" in article:
article = "missing"
return self.path_template % (article,)
@ -80,10 +82,20 @@ class MarkdownDirectoryView(ApiURLView):
# For disabling the "Back to home" on the homepage
context["not_index_page"] = not path.endswith("/index.md")
if self.template_name == "zerver/help/main.html":
if self.path_template == '/zerver/help/%s.md':
context["page_is_help_center"] = True
context["doc_root"] = "/help/"
sidebar_index = self.get_path("include/sidebar_index")
# We want the sliding/collapsing behavior for /help pages only
sidebar_class = "sidebar slide"
else:
context["page_is_api_center"] = True
context["doc_root"] = "/api/"
sidebar_index = self.get_path("sidebar_index")
sidebar_class = "sidebar"
context["sidebar_index"] = sidebar_index
context["sidebar_class"] = sidebar_class
# An "article" might require the api_uri_context to be rendered
api_uri_context = {} # type: Dict[str, Any]
add_api_uri_context(api_uri_context, self.request)

View File

@ -624,10 +624,10 @@ urls += [url(r'^', include('social_django.urls', namespace='social'))]
# User documentation site
urls += [url(r'^help/(?P<article>.*)$',
MarkdownDirectoryView.as_view(template_name='zerver/help/main.html',
MarkdownDirectoryView.as_view(template_name='zerver/documentation_main.html',
path_template='/zerver/help/%s.md'))]
urls += [url(r'^api/(?P<article>[-\w]*\/?)$',
MarkdownDirectoryView.as_view(template_name='zerver/api/main.html',
MarkdownDirectoryView.as_view(template_name='zerver/documentation_main.html',
path_template='/zerver/api/%s.md'))]
# Two Factor urls