Skip to content

Commit

Permalink
resource gallery works
Browse files Browse the repository at this point in the history
  • Loading branch information
jmunroe committed Jun 13, 2024
1 parent ac7ac63 commit 19e5b93
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions pythia-gallery.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,45 @@ def fetch_yaml(url: str):


def render_resource(resource: dict):
return {}

def new_render_resource(resource: dict):

title = resource["title"]
resource_url = resource["url"]
description = resource["description"]


#if "thumbnail" in resource:
#else:
try:
thumbnail = "https://projectpythia.org/" + resource['thumbnail']
except:
thumbnail = "https://projectpythia.org/_static/thumbnails/ProjectPythia_Blue.png"

# Build tags
tags = resource["tags"]

return {
"type": "card",
"url": resource_url,
"children": [
{"type": "cardTitle", "children": [text(title)]},
div([
image(thumbnail),
text(description),
div(
[
span(
[text(item)],
style=styles.get(name, DEFAULT_STYLE),
)
for name, items in tags.items()
if items is not None
for item in items
]
)
])
]
}

return {
"type": "card",
"url": resource_url,
Expand Down

0 comments on commit 19e5b93

Please sign in to comment.