mirror of
https://github.com/zulip/zulip.git
synced 2026-07-12 21:04:41 +08:00
views/integrations: Change non-generic HelpView to MarkdownDirectoryView.
The HelpView class will render a directory as markdown with an index HTML page. This however can also be used for other generics and applied to the API pages as well, so change the class to a generic class and specify the path templates and names. Tweaked by tabbott and Eeshan Garg.
This commit is contained in:
parent
4cb3cdb5b0
commit
6933d51c0f
@ -50,9 +50,8 @@ class APIView(ApiURLView):
|
||||
template_name = 'zerver/api.html'
|
||||
|
||||
|
||||
class HelpView(ApiURLView):
|
||||
template_name = 'zerver/help/main.html'
|
||||
path_template = 'zerver/help/%s.md'
|
||||
class MarkdownDirectoryView(ApiURLView):
|
||||
path_template = ""
|
||||
|
||||
def get_path(self, article):
|
||||
# type: (str) -> str
|
||||
@ -65,7 +64,7 @@ class HelpView(ApiURLView):
|
||||
def get_context_data(self, **kwargs):
|
||||
# type: (**Any) -> Dict[str, Any]
|
||||
article = kwargs["article"]
|
||||
context = super(HelpView, self).get_context_data() # type: Dict[str, Any]
|
||||
context = super().get_context_data() # type: Dict[str, Any]
|
||||
path = self.get_path(article)
|
||||
try:
|
||||
loader.get_template(path)
|
||||
@ -81,7 +80,7 @@ class HelpView(ApiURLView):
|
||||
def get(self, request, article=""):
|
||||
# type: (HttpRequest, str) -> HttpResponse
|
||||
path = self.get_path(article)
|
||||
result = super(HelpView, self).get(self, article=article)
|
||||
result = super().get(self, article=article)
|
||||
try:
|
||||
loader.get_template(path)
|
||||
except loader.TemplateDoesNotExist:
|
||||
|
||||
@ -8,7 +8,7 @@ import os
|
||||
import zerver.forms
|
||||
from zproject import dev_urls
|
||||
from zproject.legacy_urls import legacy_urls
|
||||
from zerver.views.integrations import IntegrationView, APIView, HelpView
|
||||
from zerver.views.integrations import IntegrationView, APIView, MarkdownDirectoryView
|
||||
from zerver.lib.integrations import WEBHOOK_INTEGRATIONS
|
||||
from zerver.webhooks import github_dispatcher
|
||||
|
||||
@ -543,7 +543,9 @@ urls += [
|
||||
urls += [url(r'^', include('social_django.urls', namespace='social'))]
|
||||
|
||||
# User documentation site
|
||||
urls += [url(r'^help/(?P<article>.*)$', HelpView.as_view(template_name='zerver/help/main.html'))]
|
||||
urls += [url(r'^help/(?P<article>.*)$',
|
||||
MarkdownDirectoryView.as_view(template_name='zerver/help/main.html',
|
||||
path_template='/zerver/help/%s.md'))]
|
||||
|
||||
if settings.DEVELOPMENT:
|
||||
urls += dev_urls.urls
|
||||
|
||||
Loading…
Reference in New Issue
Block a user