Skip to content

Commit

Permalink
Run black
Browse files Browse the repository at this point in the history
  • Loading branch information
jacklinke committed Oct 14, 2024
1 parent b611ea2 commit b62bb5e
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion example_project/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"django.contrib.staticfiles",
"crispy_forms",
"crispy_bootstrap5",
'markdownx',
"markdownx",
"example_project.example",
"django_help",
]
Expand Down
2 changes: 1 addition & 1 deletion example_project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
urlpatterns = [
path("admin/", admin.site.urls),
path("", include("django_help.urls")),
path('markdownx/', include('markdownx.urls')),
path("markdownx/", include("markdownx.urls")),
]
1 change: 1 addition & 0 deletions src/django_help/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class RelevantPathForm(forms.ModelForm):

class Meta:
"""Meta class for RelevantPathForm."""

model = RelevantPath
fields = ("path",)

Expand Down
4 changes: 2 additions & 2 deletions src/django_help/templatetags/django_help_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,14 @@ def markdown_format(text):
def replace_internal_links(match):
slug = match.group(1)
title = match.group(2) if match.group(2) else slug
url = reverse('django_help:view_article', kwargs={'article_slug': slug})
url = reverse("django_help:view_article", kwargs={"article_slug": slug})
return f'<a href="{url}" class="internal-link" data-slug="{slug}">{title}</a>'

# Convert markdown to HTML
html = md.markdown(text, extensions=["markdown.extensions.fenced_code"])

# Replace internal links with custom format
pattern = r'\[\[([^\]|]+)(?:\|([^\]]+))?\]\]'
pattern = r"\[\[([^\]|]+)(?:\|([^\]]+))?\]\]"
html = re.sub(pattern, replace_internal_links, html)

return mark_safe(html)
Expand Down
3 changes: 2 additions & 1 deletion src/django_help/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def category(request: HttpRequest, category_slug: str) -> TemplateResponse:
@login_required
def view_article(request: HttpRequest, article_slug: str) -> TemplateResponse:
"""Uses htmx to load a specific article instance based on the slug."""
if 'HTTP_HX_REQUEST' in request.META and request.META['HTTP_HX_REQUEST'] == 'true':
if "HTTP_HX_REQUEST" in request.META and request.META["HTTP_HX_REQUEST"] == "true":
context = {}
template = "django_help/fragments/modal_content.html"

Expand All @@ -133,6 +133,7 @@ def view_article(request: HttpRequest, article_slug: str) -> TemplateResponse:
logger.error("Request to view article %s was not an htmx request", article_slug)
raise Http404


@login_required
def get_articles(request: HttpRequest, *, category: str = None, slug: str = None, tag: str = None) -> TemplateResponse:
"""Fetches articles based on category, slug, or tag."""
Expand Down

0 comments on commit b62bb5e

Please sign in to comment.