Last active
March 7, 2017 22:18
-
-
Save JJediny/06bb13a93b7f3f7bff420864a0f0b739 to your computer and use it in GitHub Desktop.
Changes needed to produce valid "Federal" data.json. publisher.name == JKAN organization (or Department in San Diego JKAN implementation), but bureauCode and programCode should be attributes pulled from where organization == publisher.name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
--- | |
{ | |
"conformsTo": "https://project-open-data.cio.gov/v1.1/schema", | |
"@context": "https://project-open-data.cio.gov/v1.1/schema/catalog.jsonld", | |
"@id": "{{ site.baseurl }}/data.json", | |
"@type": "dcat:Catalog", | |
"describedBy": "https://project-open-data.cio.gov/v1.1/schema/catalog.json", | |
"dataset": [{% for dataset in site.datasets %}{% capture temp %} | |
{% assign schema = dataset.schema | default: site.schema %} | |
{% assign dataset_fields = site.data.schemas[schema].dataset_fields %} | |
{% assign resource_fields = site.data.schemas[schema].resource_fields %} | |
{% assign organization_fields = site.data.schemas[schema].organization_fields %} | |
{% assign organizations = site.organizations[organization].organization_fields %} | |
{% if dataset.publisher_name == site.organizations.organization.title %} | |
{% assign f_organization = organization_fields | where: "datajson", "title" | first %} | |
{% assign organization = [f_organization[field_name]] %} | |
{% assign f_bureauCode = organization_fields | where: "datajson", "bureauCode" | first %} | |
{% assign bureauCode = [f_bureauCode[field_name]] %} | |
{% assign f_programCode = organization_fields | where: "datajson", "programCode" | first %} | |
{% assign programCode = [f_programCode[field_name]] %} | |
{% endif %} | |
{% assign f_title = dataset_fields | where: "datajson", "title" | first %} | |
{% assign title = dataset[f_title[field_name]] %} | |
{% assign f_publisher_name = dataset_fields | where: "datajson", "publisher.name" | first %} | |
{% assign publisher_name = dataset[f_publisher_name[field_name]] %} | |
{% assign f_date_issued = dataset_fields | where: "datajson", "issued" | first %} | |
{% assign date_issued = dataset[f_date_issued[field_name]] %} | |
{% assign f_date_modified = dataset_fields | where: "datajson", "modified" | first %} | |
{% assign date_modified = dataset[f_date_modified[field_name]] %} | |
{% assign f_license = dataset_fields | where: "datajson", "license" | first %} | |
{% assign license = dataset[f_license[field_name]] %} | |
{% assign f_description = dataset_fields | where: "datajson", "description" | first %} | |
{% assign description = dataset[f_description[field_name]] %} | |
{% assign f_category = dataset_fields | where: "datajson", "category" | first %} | |
{% assign category = dataset[f_category[field_name]] %} | |
{% assign f_contact_point_fn = dataset_fields | where: "datajson", "contactPoint.fn" | first %} | |
{% assign contact_point_fn = dataset[f_contact_point_fn[field_name]] %} | |
{% assign f_contact_point_has_email = dataset_fields | where: "datajson", "contactPoint.hasEmail" | first %} | |
{% assign contact_point_has_email = dataset[f_contact_point_has_email[field_name]] %} | |
{% assign f_dist_title = resource_fields | where: "datajson", "distribution.title" | first %} | |
{% assign f_dist_download_url = resource_fields | where: "datajson", "distribution.downloadURL" | first %} | |
{% assign f_dist_format = resource_fields | where: "datajson", "distribution.format" | first %} | |
{% endcapture %}{% if title %} | |
{ | |
"title": "{{ title }}", | |
"identifier": "{{ title | downcase | replace:' ','_'}}_datasd", | |
"@type": "dcat:Dataset", | |
"issued": "{{ date_issued }}", | |
"modified": "{{ date_modified }}", | |
"accessLevel": "public"{% if publisher_name %}, | |
"publisher": { | |
"@type": "org:Organization", | |
"name": {{ publisher_name | jsonify }} | |
},{% endif %}{% if bureauCode %} | |
"bureauCode": [ | |
{{ bureauCode | jsonify }} | |
],{% endif %}{% if programCode %} | |
"programCode": [ | |
{{ programCode | jsonify}} | |
],{% endif %}{% if dataset.keywords %} | |
"keyword": [ | |
{% for keyword in dataset.keywords %}"{{ keyword }}"{% unless forloop.last %},{% endunless %}{% endfor %} | |
]{% endif %}{% if description %} | |
"description": {{ description | jsonify }}{% endif %}{% if category %}, | |
"category": {{ category | jsonify }}{% endif %}{% if contact_point_fn or contact_point_has_email %}, | |
"contactPoint": { | |
"fn": {{ contact_point_fn | jsonify }}{% if contact_point_has_email %}, | |
"hasEmail": "mailto:{{ contact_point_has_email }}"{% endif %} | |
}{% endif %}{% if license != '' %}, | |
"license": "{{ license }}" | |
{% endif %}{% if dataset.resources %}, | |
"distribution": [{% for distribution in dataset.resources %}{% capture temp %} | |
{% assign dist_title = distribution[f_dist_title[field_name]] %} | |
{% assign dist_download_url = distribution[f_dist_download_url[field_name]] %} | |
{% assign dist_format = distribution[f_dist_format[field_name]] %}{% endcapture %} | |
{% if dist_format == 'csv' %} | |
{% assign media_type = 'text/csv' %} | |
{% elsif dist_format == 'json' or dist_format == 'geojson' %} | |
{% assign media_type = 'application/json' %} | |
{% elsif dist_format == 'xml' or dist_format == 'kml' %} | |
{% assign media_type = 'application/xml' %} | |
{% elsif dist_format == 'html'%} | |
{% assign media_type = 'text/html' %} | |
{% else %} | |
{% assign media_type = 'application/octet-stream' %} | |
{% endif %} | |
{ | |
"title": {{ dist_title | jsonify }}, | |
"@type": "dcat:Distribution", | |
"downloadURL": {{ dist_download_url | jsonify }}{% if dist_format %}, | |
"mediaType": {{ media_type | jsonify }}, | |
"format": {{ dist_format | jsonify }}{% endif %} | |
}{% unless forloop.last %},{% endunless %}{% endfor %} | |
]{% endif %} | |
}{% unless forloop.last %},{% endunless %}{% endif %}{% endfor %} | |
] | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To add fields, make a new schema file in this directory | |
# and change the schema setting in _config.yml to its name | |
dataset_fields: | |
- field_name: title | |
label: Title | |
datajson: title | |
- field_name: organization | |
label: Organization | |
form_template: form/organization.html | |
datajson: publisher.name | |
- field_name: notes | |
label: Description | |
form_template: form/textarea.html | |
datajson: description | |
- field_name: license | |
label: License | |
form_template: form/license.html | |
datajson: license | |
- field_name: category | |
label: Category | |
form_template: form/category.html | |
display_template: display/category.html | |
datajson: category | |
- field_name: maintainer | |
label: Maintainer | |
datajson: contactPoint.fn | |
- field_name: maintainer_email | |
label: Maintainer Email | |
datajson: contactPoint.hasEmail | |
- field_name: date_issued | |
label: Date Issued (YYYY-MM-DD) | |
datajson: issued | |
- field_name: date_modified | |
label: Date Modified (YYYY-MM-DD) | |
datajson: modified | |
resource_fields: | |
- field_name: name | |
label: Resource Name | |
datajson: distribution.title | |
- field_name: url | |
label: URL | |
datajson: distribution.downloadURL | |
- field_name: format | |
label: Format | |
datajson: distribution.format | |
form_template: form/dropdown.html | |
values: | |
- api | |
- csv | |
- json | |
- geojson | |
- html | |
- kml | |
- kmz | |
- shp | |
- xml | |
organization_fields: | |
- field_name: title | |
label: Title | |
- field_name: description | |
label: Description | |
- field_name: logo | |
label: Logo | |
- field_name: bureauCode | |
label: bureauCode | |
datajson: bureauCode | |
- field_name: programCode | |
label: programCode | |
datajson: programCode | |
category_fields: | |
- field_name: name | |
label: Name | |
- field_name: logo | |
label: Logo | |
- field_name: logo_credit | |
label: Logo Credit | |
- field_name: featured | |
label: Featured on Homepage | |
form_template: form/checkbox.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment