Skip to content

Commit

Permalink
Merge pull request #142 from usegalaxy-au/embed-snippets
Browse files Browse the repository at this point in the history
Request embedded snippets at /embed/snippet/path.html
  • Loading branch information
neoformit authored Aug 13, 2024
2 parents 2b8e3b2 + 57dc9d1 commit d4bf7ce
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 0 deletions.
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

0 comments on commit d4bf7ce

Please sign in to comment.