Skip to content

Commit

Permalink
Data Package inline format
Browse files Browse the repository at this point in the history
  • Loading branch information
loleg committed Nov 13, 2022
1 parent b66171d commit bd376b7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion dribdat/apipackage.py
Expand Up @@ -37,7 +37,7 @@ def PackageEvent(event, author=None, host_url='', full_contents=False):
package = Package(
name='event-%d' % event.id,
title=event.name,
description="Event and project details collected with dribdat",
description=event.summary or event.description,
keywords=["dribdat", "hackathon", "co-creation"],
sources=[{"title": "dribdat", "path": "https://dribdat.cc"}],
licenses=[{
Expand Down
49 changes: 29 additions & 20 deletions dribdat/boxout/datapackage.py
Expand Up @@ -3,40 +3,47 @@
import re
import logging
import pystache
from datetime import datetime
from frictionless import Package

TEMPLATE_PACKAGE = r"""
<div class="boxout datapackage card mb-4" style="max-width:23em">
<div class="card-body">
<a href="{{homepage}}">
<h5 class="card-title font-weight-bold">{{title}}</h5>
</a>
<a href="{{url}}" download>
<h6 class="card-subtitle mb-2 text-muted">Data Package</h6>
</a>
<div class="card-text description">{{description}}</div>
<h5 class="card-title font-weight-bold">
{{dp.title}}
</h5>
<h6 class="card-subtitle mb-2 text-muted">
Data Package
<a href="{{dp.homepage}}" title="Home page">
&#127760;&nbsp;www
</a>
<a href="{{url}}" download title="Get Data Package">
&#127760;&nbsp;json
</a>
</h6>
<div class="card-text description">{{dp.description}}</div>
<ul class="resources list-unstyled">
{{#resources}}
{{#dp.resources}}
<li><a href="{{path}}" download class="card-link">{{name}}</a>
<span class="schema-fields">{{#schema.fields}}
<b title="{{type}}">&#9632;</b>
{{/schema.fields}}</span></li>
{{/resources}}
{{/dp.resources}}
</ul>
<div class="details font-size-small">
<div class="sources float-left">&#128230;
{{#sources}}
<a href="{{path}}">{{name}}</a>
{{/sources}}
<div class="sources float-left">
{{#dp.sources}}
<a href="{{path}}">&#128230; {{title}}</a>
{{/dp.sources}}
</div>
{{#licenses}}
<i class="created">{{created}}</i>
<small title="Date" class="created">{{date}}</small>
&nbsp;
<i class="version">{{version}}</i>
<i title="Version" class="version">{{dp.version}}</i>
&nbsp;
<a class="license" target="_top"
href="{{path}}" title="{{title}}">License</a>
{{/licenses}}
{{#dp.licenses}}
<a class="license" target="_top"
href="{{path}}" title="{{title}}">License</a>
{{/dp.licenses}}
</div>
</div>
</div>
Expand Down Expand Up @@ -66,7 +73,9 @@ def box_datapackage(line, cache=None):
except Exception: # noqa: B902
logging.warn("Data Package not parsed: <%s>" % url)
return None
box = pystache.render(TEMPLATE_PACKAGE, package)
dt = datetime.fromisoformat(package.created).strftime("%d.%m.%Y")
box = pystache.render(
TEMPLATE_PACKAGE, {'url': url, 'dp': package, 'date': dt})
if cache:
cache.set(url, box)
if cache and cache.has(url):
Expand Down
3 changes: 3 additions & 0 deletions dribdat/static/css/style.css
Expand Up @@ -865,6 +865,9 @@ nav .nav-login {
border-radius: 0px;
clear: both;
}
.project-page .project-longtext .card {
background: none;
}
.project-page .project-star i {
padding-right: 5px;
}
Expand Down

0 comments on commit bd376b7

Please sign in to comment.