Skip to content

Commit

Permalink
Merge pull request #143 from usegalaxy-au/dev
Browse files Browse the repository at this point in the history
Export embedded snippets
  • Loading branch information
neoformit authored Aug 13, 2024
2 parents a3f6113 + d4bf7ce commit 7357adb
Show file tree
Hide file tree
Showing 23 changed files with 114 additions and 46 deletions.
4 changes: 2 additions & 2 deletions webapp/home/lab_export.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Exported landing pages to be requested by external Galaxy servers.
Example with local YAML:
http://127.0.0.1:8000/landing/export?content_root=http://127.0.0.1:8000/static/home/labs/genome/main.yml
http://127.0.0.1:8000/landing/export?content_root=http://127.0.0.1:8000/static/home/labs/genome/base.yml
Example URL with remote YAML:
http://127.0.0.1:8000/landing/export?content_root=https://raw.githubusercontent.com/usegalaxy-au/galaxy-media-site/dev/webapp/home/static/home/labs/genome/main.yml
http://127.0.0.1:8000/landing/export?content_root=https://raw.githubusercontent.com/usegalaxy-au/galaxy-media-site/dev/webapp/home/static/home/labs/genome/base.yml
"""

Expand Down
2 changes: 1 addition & 1 deletion webapp/home/labs/docs/base.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Default spec for an exported subsite landing page

# You can test with: /lab/export?content_root=https://raw.githubusercontent.com/usegalaxy-au/galaxy-media-site/dev/webapp/home/labs/docs/main.yml
# You can test with: /lab/export?content_root=https://raw.githubusercontent.com/usegalaxy-au/galaxy-media-site/dev/webapp/home/labs/docs/base.yml

site_name: Antarctica
lab_name: Galaxy Lab Pages
Expand Down
1 change: 0 additions & 1 deletion webapp/home/labs/docs/main.yml

This file was deleted.

18 changes: 9 additions & 9 deletions webapp/home/labs/docs/templates/intro.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
</li>
<li>
See a full working example of an exported Galaxy Lab page
<a href="/lab/export?content_root=http://{{ HOSTNAME }}/static/home/labs/genome/main.yml">here</a>.
<a href="/lab/export?content_root=http://{{ HOSTNAME }}/static/home/labs/genome/base.yml">here</a>.
</li>
<li>
See a minimal working example of a lab page
<a href="/lab/export?content_root=http://{{ HOSTNAME }}/static/home/labs/simple/main.yml">here</a>.
<a href="/lab/export?content_root=http://{{ HOSTNAME }}/static/home/labs/simple/base.yml">here</a>.
</li>
</ul>

Expand Down Expand Up @@ -48,8 +48,8 @@ <h2 class="accordion-header" id="headingOne">
<ul>
<li>
The root of your site's content should be a YAML file - see
<a href="https://github.com/usegalaxy-au/galaxy-media-site/tree/dev/webapp/home/labs/docs/main.yml" target="_blank">
main.yml
<a href="https://github.com/usegalaxy-au/galaxy-media-site/tree/dev/webapp/home/labs/docs/base.yml" target="_blank">
base.yml
</a>
for the content root of this page.
</li>
Expand All @@ -59,16 +59,16 @@ <h2 class="accordion-header" id="headingOne">
For example, we can explicitly request this page with:
<br>
<small>
<a href="/lab/export?content_root=https://raw.githubusercontent.com/usegalaxy-au/galaxy-media-site/dev/webapp/home/labs/docs/main.yml" target="_blank">
http://{{ HOSTNAME }}/lab/export?content_root=https://raw.githubusercontent.com/usegalaxy-au/galaxy-media-site/dev/webapp/home/labs/docs/main.yml
<a href="/lab/export?content_root=https://raw.githubusercontent.com/usegalaxy-au/galaxy-media-site/dev/webapp/home/labs/docs/base.yml" target="_blank">
http://{{ HOSTNAME }}/lab/export?content_root=https://raw.githubusercontent.com/usegalaxy-au/galaxy-media-site/dev/webapp/home/labs/docs/base.yml
</a>
</small>
</li>
<li>
The web server will fetch your content from GitHub (or anywhere on the internet) and render it into this page.
</li>
<li>
Note that <code>main.yml</code> points to other files (YAML, HTML, CSS and images), which are located in the same remote directory (e.g. on GitHub). You can template the entire page with these files!
Note that <code>base.yml</code> points to other files (YAML, HTML, CSS and images), which are located in the same remote directory (e.g. on GitHub). You can template the entire page with these files!
</li>
<li>
The most useful part of this machinery is the <code>sections</code> content, which populates the tool/workflow sections below.
Expand Down Expand Up @@ -110,7 +110,7 @@ <h2 class="accordion-header" id="headingTwo">
<br>
<small>
<code>
http://{{ HOSTNAME }}/lab/export?content_root=https://raw.githubusercontent.com/myusername/myrepo/path/to/content/main.yml
http://{{ HOSTNAME }}/lab/export?content_root=https://raw.githubusercontent.com/myusername/myrepo/path/to/content/base.yml
</code>
</small>
</li>
Expand Down Expand Up @@ -204,7 +204,7 @@ <h5 class="modal-title">Galaxy {{ site_name }}</h5>
$(`#${id}`).append(exportInfoButton);
}
$(document).ready(function() {
addHoverInfo('headerSection', 'main.yml');
addHoverInfo('headerSection', 'base.yml');
addHoverInfo('introSection', 'templates/intro.html');
addHoverInfo('section_1Section', 'section_1.yml');
addHoverInfo('section_2Section', 'section_2.yml');
Expand Down
4 changes: 2 additions & 2 deletions webapp/home/labs/genome/base.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Test this locally with:
# http://127.0.0.1:8000/lab/export?content_root=http://localhost:8000/static/home/labs/genome/main.yml
# http://127.0.0.1:8000/lab/export?content_root=http://localhost:8000/static/home/labs/genome/base.yml

# Request this on site.usegalaxy.org.au with:
# https://site.usegalaxy.org.au/lab/export?content_root=https://site.usegalaxy.org.au/static/home/labs/genome/main.yml
# https://site.usegalaxy.org.au/lab/export?content_root=https://site.usegalaxy.org.au/static/home/labs/genome/base.yml

# Check out the documentation for building exported labs:
# https://site.usegalaxy.org.au/lab/export
Expand Down
1 change: 0 additions & 1 deletion webapp/home/labs/genome/main.yml

This file was deleted.

16 changes: 8 additions & 8 deletions webapp/home/labs/proteomics/base.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Test this locally with:
# http://127.0.0.1:8000/lab/export?content_root=http://localhost:8000/static/home/labs/proteomics/main.yml
# http://127.0.0.1:8000/lab/export?content_root=http://localhost:8000/static/home/labs/proteomics/base.yml

# Request this on site.usegalaxy.org.au with:
# https://site.usegalaxy.org.au/lab/export?content_root=https://site.usegalaxy.org.au/static/home/labs/proteomics/main.yml
# https://site.usegalaxy.org.au/lab/export?content_root=https://site.usegalaxy.org.au/static/home/labs/proteomics/base.yml

# Check out the documentation for building exported labs:
# https://site.usegalaxy.org.au/lab/export
Expand Down Expand Up @@ -30,9 +30,9 @@ footer_md: templates/footer.html
# 1. Relative to this file URL
# 2. Full URL to fetch globally centralized content
sections:
- data.yml
- conversion_modification.yml
- database_searching.yml
- dda_standardised_tools.yml
- dia_standardised_tools.yml
- dda_tmt.yml
- sections/data.yml
- sections/conversion_modification.yml
- sections/database_searching.yml
- sections/dda_standardised_tools.yml
- sections/dia_standardised_tools.yml
- sections/dda_tmt.yml
1 change: 0 additions & 1 deletion webapp/home/labs/proteomics/main.yml

This file was deleted.

File renamed without changes.
File renamed without changes.
70 changes: 53 additions & 17 deletions webapp/home/labs/proteomics/templates/intro.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,18 @@
</div>

<div class="col">
<a class="text-danger" href="">
<table>
<tr>
<td>
<span class="material-icons px-3" style="font-size: 3rem;">change_circle</span>
</td>
<td>
MS data file format converters
</td>
</tr>
</table>
</a>
</div>

<div class="col">
<a class="text-danger" href="">
<a
href="#"
data-bs-toggle="modal"
data-bs-target="#sharedHistoryModal"
>
<table>
<tr>
<td>
<span class="material-icons px-3" style="font-size: 3rem;">account_tree</span>
</td>
<td>
MS reference data on Galaxy
Shared proteomics histories
</td>
</tr>
</table>
Expand Down Expand Up @@ -100,3 +89,50 @@ <h5 class="modal-title">Galaxy {{ site_name }}</h5>
</div>
</div>
</div>


<div class="modal fade" id="sharedHistoryModal" tabindex="-1">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Galaxy {{ site_name }} Shared Histories</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>
This set of proteomics-specific shared histories contain test or demo data for software available on Proteomics Lab. You can copy these histories directly to your account on Galaxy, making it faster to get started!
</p>

<table class="table table-striped">
<tr>
<td>
Demo data for LFQanalyst and TMTanalyst.
</td>
<td>
<a class="btn btn-primary text-nowrap" href="https://usegalaxy.org.au/u/mike/h/lfq-and-tmt">
View history
</a>
</td>
</tr>
<tr>
<td>
Example data provided for the "MaxQuant and MSstats for the analysis of label-free data" Galaxy Training Network (GTN) tutorial, which is available
<a href="https://gxy.io/GTN:T00219">here</a>.
</td>
<td>
<a
class="btn btn-primary text-nowrap"
href="https://usegalaxy.org.au/u/johan/h/maxquant-and-msstats-for-the-analysis-of-label-free-data-1"
>
View history
</a>
</td>
</tr>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Default spec for an exported subsite landing page

# You can test with: /lab/export?content_root=https://raw.githubusercontent.com/usegalaxy-au/galaxy-media-site/dev/webapp/home/labs/docs/main.yml
# You can test with: /lab/export?content_root=https://raw.githubusercontent.com/usegalaxy-au/galaxy-media-site/dev/webapp/home/labs/docs/base.yml

site_name: Archaeology
lab_name: Archaeology Lab
Expand Down
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 %}
2 changes: 1 addition & 1 deletion webapp/home/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
'Report statistics from sequencing reads',
'Assemble Nanopore long reads.',
)
TEST_LAB_CONTENT_URL = f'{MOCK_LAB_BASE_URL}/static/home/labs/docs/main.yml'
TEST_LAB_CONTENT_URL = f'{MOCK_LAB_BASE_URL}/static/home/labs/docs/base.yml'
TEST_LAB_URL = f'/lab/export?content_root={TEST_LAB_CONTENT_URL}'


Expand Down
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 webapp/webapp/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
LOG_ROOT = ensure_dir(BASE_DIR / 'webapp/logs')
RECIPIENT_MASTER_CSV = BASE_DIR / '../scripts/mail/recipient_records.csv'
DEFAULT_EXPORTED_LAB_CONTENT_ROOT = (
f'http://{HOSTNAME}/static/home/labs/docs/main.yml'
f'http://{HOSTNAME}/static/home/labs/docs/base.yml'
)

# Hostnames
Expand Down
2 changes: 1 addition & 1 deletion wiki
Submodule wiki updated from 1e0e78 to 4e6de0

0 comments on commit 7357adb

Please sign in to comment.