Skip to content

Instantly share code, notes, and snippets.

@timwis
Created August 10, 2016 12:22
Show Gist options
  • Save timwis/d0cf9d015d9cb73ef7df5f43c22257ec to your computer and use it in GitHub Desktop.
Save timwis/d0cf9d015d9cb73ef7df5f43c22257ec to your computer and use it in GitHub Desktop.
jkan dataset page with disqus
---
layout: default
---
{% include breadcrumbs.html parent="Datasets" %}
{% assign schema = page.schema | default: site.schema %}
{% assign dataset_fields = site.data.schemas[schema].dataset_fields %}
{% assign dataset_system_fields = "title|organization|notes|license" | split: "|" %}
{% assign resource_fields = site.data.schemas[schema].resource_fields %}
{% assign resource_system_fields = "name|url|format|description" | split: "|" %}
{% assign organization = site.organizations | where:"title",page.organization | first %}
{% capture organization_url %}{{ site.baseurl }}/datasets/?organization={{ organization.title | slugify }}{% endcapture %}
<div data-component="view-switcher">
<div class="row" data-component="dataset-display" data-hook="view" data-view="display" typeof="dcat:Dataset" resource="{{ page.url }}">
{% if organization %}
<div class="col-sm-3" property="dct:publisher" resource="{{ organization_url }}">
<div class="panel panel-default">
<div class="panel-heading">
{% if organization.logo and organization.logo != empty %}
<a href="{{ site.baseurl }}/datasets/?organization={{ organization.title | slugify }}" class="thumbnail"><img src="{{ organization.logo }}" alt="{{ organization.title }} logo"></a>
{% endif %}
</div>
<div class="panel-body">
<h3>
<a href="{{ organization_url }}" about="{{ organization_url }}" property="foaf:homepage">
<span property="foaf:name">{{ organization.title }}</span>
</a>
</h3>
{{ organization.description }}
</div>
</div>
</div>
<div class="col-sm-9">
{% else %}
<div class="col-sm-12">
{% endif %}
<h1>
<span property="dct:title">{{ page.title }}</span>
<a href="?view=edit" class="pull-right btn btn-default admin-only" data-hook="edit-dataset-btn">Edit</a>
</h1>
<p property="dct:description">{{ page.notes }}</p>
<h2>Resources</h2>
<ul>
{% for resource in page.resources %}
<li data-hook="resource-item" property='dcat:distribution' typeof='dcat:Distribution'>
<a href="{{ resource.url }}" property='dcat:accessURL'><span property="dct:title">{{ resource.name }}</span></a>
{% if resource.format %}<span class="label label-default" property='dcat:mediaType'>{{ resource.format}}</span>{% endif %}
<a href="#" class="show-resource-details" data-hook="show-resource-details">(Details)</a>
{% if resource.description %}<div class="resource-description">{{ resource.description }}</div>{% endif %}
<table class="table table-striped table-condensed resource-details" data-hook="resource-details">
{% for field in resource_fields %}
{% unless resource_system_fields contains field.field_name %}
{% assign value = resource[field[field_name]] %}
{% if value %}
{% if field.display_template %}
{% include {{ field.display_template }} field=field value=value %}
{% else %}
<tr>
<th>{{ field.label }}</th>
<td>{{ value }}</td>
</tr>
{% endif %}
{% endif %}
{% endunless %}
{% endfor %}
</table>
</li>
{% endfor %}
</ul>
<h2>Additional Info</h2>
<table class="table table-striped dataset-details">
{% if page.license and page.license != empty %}
<tr>
<th>License</th>
<td>
<a property="dct:license" resource="{{ page.license }}" href="{{ page.license }}">
{{ site.data.licenses[page.license] }}
</a>
</td>
</tr>
{% endif %}
{% for field in dataset_fields %}
{% unless dataset_system_fields contains field.field_name %}
{% assign value = page[field[field_name]] %}
{% if value %}
{% if field.display_template %}
{% include {{ field.display_template }} field=field value=value %}
{% else %}
<tr>
<th>{{ field.label }}</th>
<td>{{ value }}</td>
</tr>
{% endif %}
{% endif %}
{% endunless %}
{% endfor %}
</table>
<div class = "disqus">
<div id="disqus_thread"></div>
<script>
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables
*/
var disqus_config = function () {
var disqus_shortname = "{{ site.disqus_shortname }}"; // required: replace example with your forum shortname
// var disqus_developer = 1; // Comment out when the site is live
var disqus_identifier = "{{ page.url }}";
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = '//pandaatx.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
</div>
</div>
</div>
<div class="row" data-hook="view" data-view="edit">
<div class="col-sm-8 col-sm-offset-2">
{% include dataset-form.html dataset=page %}
</div>
<div class="col-sm-2">
<a href="{{ site.baseurl }}{{ page.url }}" class="btn btn-default pull-right">Cancel</a>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment