mirror of
https://github.com/zulip/zulip.git
synced 2025-11-04 14:03:30 +00: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:
committed by
Tim Abbott
parent
4cb3cdb5b0
commit
6933d51c0f
@@ -50,9 +50,8 @@ class APIView(ApiURLView):
|
|||||||
template_name = 'zerver/api.html'
|
template_name = 'zerver/api.html'
|
||||||
|
|
||||||
|
|
||||||
class HelpView(ApiURLView):
|
class MarkdownDirectoryView(ApiURLView):
|
||||||
template_name = 'zerver/help/main.html'
|
path_template = ""
|
||||||
path_template = 'zerver/help/%s.md'
|
|
||||||
|
|
||||||
def get_path(self, article):
|
def get_path(self, article):
|
||||||
# type: (str) -> str
|
# type: (str) -> str
|
||||||
@@ -65,7 +64,7 @@ class HelpView(ApiURLView):
|
|||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
# type: (**Any) -> Dict[str, Any]
|
# type: (**Any) -> Dict[str, Any]
|
||||||
article = kwargs["article"]
|
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)
|
path = self.get_path(article)
|
||||||
try:
|
try:
|
||||||
loader.get_template(path)
|
loader.get_template(path)
|
||||||
@@ -81,7 +80,7 @@ class HelpView(ApiURLView):
|
|||||||
def get(self, request, article=""):
|
def get(self, request, article=""):
|
||||||
# type: (HttpRequest, str) -> HttpResponse
|
# type: (HttpRequest, str) -> HttpResponse
|
||||||
path = self.get_path(article)
|
path = self.get_path(article)
|
||||||
result = super(HelpView, self).get(self, article=article)
|
result = super().get(self, article=article)
|
||||||
try:
|
try:
|
||||||
loader.get_template(path)
|
loader.get_template(path)
|
||||||
except loader.TemplateDoesNotExist:
|
except loader.TemplateDoesNotExist:
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import os
|
|||||||
import zerver.forms
|
import zerver.forms
|
||||||
from zproject import dev_urls
|
from zproject import dev_urls
|
||||||
from zproject.legacy_urls import legacy_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.lib.integrations import WEBHOOK_INTEGRATIONS
|
||||||
from zerver.webhooks import github_dispatcher
|
from zerver.webhooks import github_dispatcher
|
||||||
|
|
||||||
@@ -543,7 +543,9 @@ urls += [
|
|||||||
urls += [url(r'^', include('social_django.urls', namespace='social'))]
|
urls += [url(r'^', include('social_django.urls', namespace='social'))]
|
||||||
|
|
||||||
# User documentation site
|
# 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:
|
if settings.DEVELOPMENT:
|
||||||
urls += dev_urls.urls
|
urls += dev_urls.urls
|
||||||
|
|||||||
Reference in New Issue
Block a user