mirror of https://github.com/zulip/zulip.git
docs: Add a simple markdown-based help center.
The plan is to use this for adding user documentation to Zulip.
This commit is contained in:
parent
a715f083bb
commit
cf2007d4e0
|
@ -0,0 +1,6 @@
|
|||
# This is a test article
|
||||
|
||||
* yes
|
||||
* no
|
||||
|
||||
<a href="zulip.org">Zulip</a> rules.
|
|
@ -0,0 +1,13 @@
|
|||
{% extends "zerver/portico.html" %}
|
||||
|
||||
{# Zulip User Documentation. #}
|
||||
|
||||
{% block portico_content %}
|
||||
|
||||
<div class="app terms-page">
|
||||
<div class="app-main terms-page-container">
|
||||
{{ article|render_markdown_path }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
|
@ -0,0 +1 @@
|
|||
No such article.
|
|
@ -63,7 +63,8 @@ class PublicURLTest(ZulipTestCase):
|
|||
# through Tornado.
|
||||
get_urls = {200: ["/accounts/home/", "/accounts/login/"
|
||||
"/en/accounts/home/", "/ru/accounts/home/",
|
||||
"/en/accounts/login/", "/ru/accounts/login/"],
|
||||
"/en/accounts/login/", "/ru/accounts/login/",
|
||||
"/help/"],
|
||||
302: ["/", "/en/", "/ru/"],
|
||||
401: ["/api/v1/streams/Denmark/members",
|
||||
"/api/v1/users/me/subscriptions",
|
||||
|
@ -71,6 +72,7 @@ class PublicURLTest(ZulipTestCase):
|
|||
"/json/messages",
|
||||
"/api/v1/streams",
|
||||
],
|
||||
404: ["/help/nonexistent",],
|
||||
}
|
||||
post_urls = {200: ["/accounts/login/"],
|
||||
302: ["/accounts/logout/"],
|
||||
|
|
|
@ -86,6 +86,7 @@ class TemplateTestCase(ZulipTestCase):
|
|||
user_profile = get_user_profile_by_email(email)
|
||||
|
||||
context = dict(
|
||||
article="templates/zerver/help/index.md",
|
||||
shallow_tested=True,
|
||||
user_profile=user_profile,
|
||||
user=user_profile,
|
||||
|
|
|
@ -3,8 +3,9 @@ from typing import Optional, Any, Dict
|
|||
from collections import OrderedDict
|
||||
from django.views.generic import TemplateView
|
||||
from django.conf import settings
|
||||
from django.http import HttpRequest, HttpResponse
|
||||
from django.http import HttpRequest, HttpResponse, HttpResponseNotFound
|
||||
|
||||
import os
|
||||
import ujson
|
||||
|
||||
from zerver.lib import bugdown
|
||||
|
@ -46,6 +47,37 @@ class APIView(ApiURLView):
|
|||
template_name = 'zerver/api.html'
|
||||
|
||||
|
||||
class HelpView(ApiURLView):
|
||||
template_name = 'zerver/help/main.html'
|
||||
path_template = os.path.join(settings.DEPLOY_ROOT, 'templates/zerver/help/%s.md')
|
||||
|
||||
def get_path(self, article):
|
||||
# type: (**Any) -> str
|
||||
if article == "":
|
||||
article = "index"
|
||||
return self.path_template % (article,)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
# type: (**Any) -> Dict[str, str]
|
||||
article = kwargs["article"]
|
||||
context = super(HelpView, self).get_context_data()
|
||||
path = self.get_path(article)
|
||||
if os.path.exists(path):
|
||||
context["article"] = path
|
||||
else:
|
||||
context["article"] = self.get_path("missing")
|
||||
return context
|
||||
|
||||
def get(self, request, article=""):
|
||||
# type: (HttpRequest, str) -> HttpResponse
|
||||
path = self.get_path(article)
|
||||
result = super(HelpView, self).get(self, article=article)
|
||||
if not os.path.exists(path):
|
||||
# Ensure a 404 response code if no such document
|
||||
result.status_code = 404
|
||||
return result
|
||||
|
||||
|
||||
class IntegrationView(ApiURLView):
|
||||
template_name = 'zerver/integrations.html'
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ import os.path
|
|||
import zerver.forms
|
||||
from zproject import dev_urls
|
||||
from zproject.legacy_urls import legacy_urls
|
||||
from zerver.views.integrations import IntegrationView, APIView
|
||||
from zerver.views.integrations import IntegrationView, APIView, HelpView
|
||||
from zerver.lib.integrations import WEBHOOK_INTEGRATIONS
|
||||
|
||||
# NB: There are several other pieces of code which route requests by URL:
|
||||
|
@ -306,6 +306,9 @@ urls += [
|
|||
# Python Social Auth
|
||||
urls += [url(r'^', include('social.apps.django_app.urls', namespace='social'))]
|
||||
|
||||
# User documentation site
|
||||
urls += [url(r'^help/(?P<article>.*)$', HelpView.as_view(template_name='zerver/help/main.html'))]
|
||||
|
||||
if settings.DEVELOPMENT:
|
||||
urls += dev_urls.urls
|
||||
i18n_urls += dev_urls.i18n_urls
|
||||
|
|
Loading…
Reference in New Issue