Skip to content

Commit

Permalink
Merge pull request #17 from usegalaxy-au/dev
Browse files Browse the repository at this point in the history
Labs engine fixes
  • Loading branch information
neoformit authored Dec 11, 2024
2 parents 734faf0 + 11c3828 commit 3dc638c
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 32 deletions.
14 changes: 7 additions & 7 deletions ansible/roles/galaxy_labs_engine/tasks/certbot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@

- name: Request SSL certificate with certbot
shell: >
docker compose --profile certbot run --rm certbot certonly \
--webroot \
--webroot-path /var/www/certbot/ \
--agree-tos \
--non-interactive \
-d "{{ certbot_domain }}" \
docker compose --profile certbot run --rm certbot-init certonly \
--webroot \
--webroot-path /var/www/certbot/ \
--agree-tos \
--non-interactive \
-d "{{ certbot_domain }}" \
-m "{{ certbot_renew_email }}"
args:
chdir: "{{ config_root }}"
Expand All @@ -53,7 +53,7 @@
name: "certbot-renew"
minute: "0"
hour: "0"
job: "docker compose --profile certbot run --rm certbot renew"
job: "cd {{ config_root }} && docker compose --profile certbot run --rm certbot renew"
tags: certbot

always:
Expand Down
17 changes: 13 additions & 4 deletions app/labs/lab_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from bs4 import BeautifulSoup, MarkupResemblesLocatorWarning
from django.conf import settings
from markdown2 import Markdown
from pydantic import ValidationError
from pydantic import BaseModel, ValidationError

from types import SimpleNamespace
from utils.exceptions import LabBuildError
Expand Down Expand Up @@ -75,15 +75,19 @@ def validate(self):

def _validate_sections(self):
"""Validate sections against Pydantic schema."""
validated_sections = []
for section in self['sections']:
try:
LabSectionSchema(**section)
validated_sections.append(
LabSectionSchema(**section).model_dump()
)
except ValidationError as e:
raise LabBuildError(
e,
section_id=section["id"],
source='YAML',
)
self['sections'] = validated_sections

def _get(
self,
Expand Down Expand Up @@ -167,7 +171,7 @@ def _fetch_yaml_context(self):
context = self._fetch_yaml_content(self.content_root, extend=False)

if not self.content_root.endswith('base.yml'):
# Attempt to extend base.yml with self.content_root
# Attempt to extend base.yml with the given content_root
base_content_url = (self.parent_url + 'base.yml')
base_context = self._fetch_yaml_content(
base_content_url, ignore_404=True, extend=False)
Expand All @@ -176,7 +180,7 @@ def _fetch_yaml_context(self):
context = base_context

try:
LabSchema(**context)
context = LabSchema(**context).model_dump()
except ValidationError as exc:
raise LabBuildError(exc, url=self.content_root, source='YAML')

Expand Down Expand Up @@ -216,6 +220,11 @@ def is_excluded_item(item):
for item in data
if not is_excluded_item(item)
]
elif isinstance(data, BaseModel):
data = {
k: filter_excluded_items(v)
for k, v in data.model_dump().items()
}
return data

if self.get('root_domain'):
Expand Down
3 changes: 2 additions & 1 deletion app/labs/lab_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,11 @@ def validate_md(cls, value):
class LabSectionSchema(BaseModel):
"""Validate Galaxy Lab section."""
id: str
title: str
tabs: list[SectionTab]


class LabSchema(BaseModel):
class LabSchema(BaseModel, extra='allow'):
"""Validate Galaxy Lab content."""
site_name: str
lab_name: str
Expand Down
20 changes: 19 additions & 1 deletion app/labs/static/labs/css/labs.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,22 @@ ul.nav-pills li.nav-item {
color: white;
background-color: #25537B;
padding: 0.25rem 0.5rem;
}
}

@media screen and (max-width: 850px) {
.lab-header {
font-size: 3.5rem;
}
}

@media screen and (max-width: 768px) {
.lab-header {
font-size: 3rem;
}
}

@media screen and (max-width: 650px) {
.lab-header {
font-size: 2.5rem;
}
}
20 changes: 20 additions & 0 deletions app/labs/static/labs/js/load-fonts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Load material icons and display when page has loaded
if ('fonts' in document) {
document.fonts.ready.then(() => {
$('.material-icons').css({
'opacity': 1,
'max-width': 'unset',
'overflow': 'visible'
});
}).catch((error) => {
console.error('Font loading failed:', error);
});
} else {
// Fallback for browsers that don't support document.fonts
console.warn('Font API not supported in this browser.');
$('.material-icons').css({
'opacity': 1,
'max-width': 'unset',
'overflow': 'visible'
});
}
2 changes: 1 addition & 1 deletion app/labs/templates/labs/components/accordion.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h2 class="accordion-header" id="{{ section.id }}-{{ tab_id }}-{{ forloop.counte
<div class="col">
{{ item.description_md|markdown }}
{% if item.inputs %}
{% include 'labs//components/inputs.html' with inputs=item.inputs %}
{% include 'labs/components/inputs.html' with inputs=item.inputs %}
{% endif %}
</div>

Expand Down
4 changes: 2 additions & 2 deletions app/labs/templates/labs/components/section.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ <h4 class="mb-3">{{ section.title }}</h4>
{% if tab.content.subsections %}
{% for subsection in tab.content.subsections %}
<p class="fw-bold my-3 mt-4 mx-3">{{ subsection.title }}</p>
{% include 'labs//components/accordion.html' with content=subsection.content tab_id=tab.id accordion_id=subsection.id %}
{% include 'labs/components/accordion.html' with content=subsection.content tab_id=tab.id accordion_id=subsection.id %}
{% endfor %}
{% else %}
{% include 'labs//components/accordion.html' with content=tab.content tab_id=tab.id %}
{% include 'labs/components/accordion.html' with content=tab.content tab_id=tab.id %}
{% endif %}
</div>
</div>
Expand Down
8 changes: 4 additions & 4 deletions app/labs/templates/labs/exported.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<main>

{% include 'labs//components/gtn-modal.html' %}
{% include 'labs/components/gtn-modal.html' %}

<section id="headerSection" class="lab-header d-flex align-items-center h-100">
{% if snippets.header_logo %}
Expand All @@ -41,22 +41,22 @@
{% endif %}

{% for section in sections %}
{% include 'labs//components/section.html' with section=section %}
{% include 'labs/components/section.html' with section=section %}
{% endfor %}

{% if snippets.conclusion_md %}
{{ snippets.conclusion_md|markdown }}
{% endif %}

{% if contributors %}
{% include 'labs//components/contributors.html' %}
{% include 'labs/components/contributors.html' %}
{% endif %}

</main>


{% if feedback_email %}
{% include 'labs//components/feedback-modal.html' %}
{% include 'labs/components/feedback-modal.html' %}
{% endif %}


Expand Down
12 changes: 1 addition & 11 deletions app/labs/templates/labs/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
{% include 'labs/snippets/head.html' %}
<title> {% if title %}{{ title }}{% else %}Galaxy - data analysis for everyone{% endif %} </title>
{% include 'labs/snippets/imports.html' %}
{% include 'labs/snippets/posthog.html' %}

{% block head %}
{% endblock %}
Expand All @@ -30,17 +29,8 @@
{% block script %}
{% endblock %}

<script src="{% static 'labs/js/load-fonts.js' %}"></script>
<script type="text/javascript">

// Load material icons and display when page has loaded
document.fonts.onloadingdone = () => {
$('.material-icons').css({
'opacity': 1,
'max-width': 'unset',
'overflow': 'visible'
});
}

$(document).ready( () => {
// Enable bootstrap tooltips
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'))
Expand Down
13 changes: 12 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ services:
- /etc/letsencrypt:/etc/letsencrypt:ro
restart: always

certbot:
certbot-init:
profiles:
- certbot
depends_on:
Expand All @@ -103,6 +103,17 @@ services:
- /var/www/certbot:/var/www/certbot:rw
- /etc/letsencrypt:/etc/letsencrypt:rw

certbot:
profiles:
- certbot
# depends_on: # N.B. certbot depends on nginx but it's usually running and
# - nginx # causes a container name collision
image: certbot/certbot:latest
container_name: certbot
volumes:
- /var/www/certbot:/var/www/certbot:rw
- /etc/letsencrypt:/etc/letsencrypt:rw

networks:
labs-engine-network:
driver: bridge

0 comments on commit 3dc638c

Please sign in to comment.