Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request embedded snippets at /embed/snippet/path.html #142

Merged
merged 1 commit into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions webapp/home/static/home/css/embedded.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
body {
padding: 1rem;
}
footer {
margin-top: 100px;
}
12 changes: 12 additions & 0 deletions webapp/home/templates/embed-snippet.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% extends 'home/header-export.html' %}

{% load static %}

{% block head %}
<link rel="stylesheet" href="{% static 'home/css/embedded.css' %}">
{% endblock %}


{% block content %}
{% include snippet_path %}
{% endblock %}
4 changes: 4 additions & 0 deletions webapp/home/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
api.validate_institutional_email,
name="validate_institutional_email"),

# Arbitrary HTML snippets
re_path(r'^embed\/([\S\/]+\.html)', views.embed_snippet,
name='embed_snippet'),

# Arbitrary *.html / *.md pages
re_path(r'^[\w\d\_-]+\.(?:html|md)$', views.page, name='html_pages'),

Expand Down
13 changes: 13 additions & 0 deletions webapp/home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,16 @@ def custom_400(request, exception, template_name="400.html"):
return render(request, template_name, {
'exc': exception,
}, status=400)


def embed_snippet(request, snippet_path):
"""Serve an embeddable snippet."""
try:
if 'snippets' not in snippet_path:
raise Http404
return render(request, 'embed-snippet.html', {
'title': 'Galaxy Media - embedded snippet',
'snippet_path': snippet_path,
})
except TemplateDoesNotExist:
raise Http404
2 changes: 1 addition & 1 deletion wiki
Submodule wiki updated from 1e0e78 to 4e6de0
Loading