diff --git a/themes/eds/i18n/da.json b/themes/eds/i18n/da.json index bea8f5b0..a2a708ec 100644 --- a/themes/eds/i18n/da.json +++ b/themes/eds/i18n/da.json @@ -77,7 +77,7 @@ "E.g. environment": "F.eks. environment", "Search through the Energinet DataStore datasets": "Søg i Energinet Data Service datasæt", "Search": "Søg", - "What are Organizations?": "Hvad er en organisation", + "What are Organizations?": "Hvad er en organisation?", "All datasets are attached to an organization/company. The organization is responsible for publishing and maintaining data and for data quality in general. The organization is also responsible for providing data support and to support data usage.": "Alle datasæt er tilknyttet én organisation/selskab. Organisationen er ansvarlig for at udgive og vedligeholde data og for datakvaliteten generelt. Organisationen er også ansvarlig for at yde support på datasættet og understøtte, at data bringes i anvendelse.", "View {organization_name}": "Se {organization_name}", "Unsubscribe": "Følg ikke", @@ -160,5 +160,14 @@ "Transmission Lines": "Transmission", "CO2 Emissions": "CO2 Emissioner", "Gas": "Gas", - "Highlighted data": "Highlighted data" -} + "Highlighted data": "Highlighted data", + "Tags": "Tags", + "Formats": "Formater", + "Licenses": "Licenser", + "Organization": "Organisationer", + "Relevance": "Relevans", + "Last Modified": "Sidst modificeret", + "What are Dataset Collections?": "Hvad er grupper?", + "Dataset Collections": "Grupper", + "Show More Groups": "Show More Groups" +} \ No newline at end of file diff --git a/themes/eds/i18n/en.json b/themes/eds/i18n/en.json index 772667f2..d37b8240 100644 --- a/themes/eds/i18n/en.json +++ b/themes/eds/i18n/en.json @@ -28,5 +28,18 @@ "Subscribe to news and get notified when new data are released": "Subscribe to news and get notified when new data are released", "Help Energinet to provide better service and support": "Help Energinet to provide better service and support", "Register": "Register", - "Energinet has a lot of energy data and through Energi Data Service, we want to make these data available. The portal will be expanded regularly. We hope you will join us on the journey, and will contribute with advice and feedback.": "Energinet has a lot of energy data and through Energi Data Service, we want to make these data available. The portal will be expanded regularly. We hope you will join us on the journey, and will contribute with advice and feedback." -} + "Energinet has a lot of energy data and through Energi Data Service, we want to make these data available. The portal will be expanded regularly. We hope you will join us on the journey, and will contribute with advice and feedback.": "Energinet has a lot of energy data and through Energi Data Service, we want to make these data available. The portal will be expanded regularly. We hope you will join us on the journey, and will contribute with advice and feedback.", + "Tags": "Tags", + "Formats": "Formats", + "Licenses": "Licenses", + "Organization": "Organization", + "Name Ascending": "Name Ascending", + "Name Descending": "Name Descending", + "What are Organizations?": "What are Organizations?", + "Order by": "Order by", + "Dataset Collections": "Dataset Collections", + "What are Dataset Collections?": "What are Dataset Collections?", + "Show More Groups": "Show More Groups", + "Relevance": "Relevance", + "Last Modified": "Last Modified" +} \ No newline at end of file diff --git a/themes/eds/public/stylesheets/app.css b/themes/eds/public/stylesheets/app.css index be32c0aa..fc0d0180 100644 --- a/themes/eds/public/stylesheets/app.css +++ b/themes/eds/public/stylesheets/app.css @@ -6651,7 +6651,6 @@ body.search { padding-right: 0px !important; } body.search .search-page { background-color: white; - padding-top: 35px; padding-bottom: 35px; /* Certified Adjustments */ } body.search .search-page .section-logo { diff --git a/themes/eds/routes.js b/themes/eds/routes.js new file mode 100644 index 00000000..40a60a18 --- /dev/null +++ b/themes/eds/routes.js @@ -0,0 +1,150 @@ +const fetch = require('node-fetch') +const moment = require('moment') +const config = require('../../config') +const dms = require('../../lib/dms') +const utils = require('../../utils') + + +module.exports = function (app) { + app.get('/:owner/:name', async (req, res, next) => { + const Model = new dms.DmsModel(config) + let datapackage = null + + try { + datapackage = await Model.getPackage(req.params.name) + } catch (err) { + next(err) + return + } + + // Convert timestamps into human readable format: + datapackage.resources[0].created = moment(datapackage.resources[0].created).format('MMMM Do, YYYY') + datapackage.resources[0].last_modified = moment(datapackage.resources[0].last_modified).format('MMMM Do, YYYY') + + // Prep downloads property with various formats + datapackage.downloads = [ + { + format: 'CSV', + path: datapackage.resources[0].path + }, + { + format: 'TSV', + path: datapackage.resources[0].path + '?format=tsv' + }, + { + format: 'XLSX - Excel', + path: datapackage.resources[0].path + '?bom=true' + }, + { + format: 'JSON', + path: datapackage.resources[0].path + '?format=json' + }, + { + format: 'XML', + path: datapackage.resources[0].path + '?format=xml' + } + ] + + // Prep resource e.g., make an inline datapackage and pass to renderer lib + datapackage.resources[0].path = config.get('API_URL') + `datastore_search?resource_id=${datapackage.resources[0].id}` + const response = await fetch(datapackage.resources[0].path) + if (response.ok) { + const result = await response.json() + datapackage.resources[0].rows = result.result.total + datapackage.resources[0].data = result.result.records.map(record => { + delete record._id + delete record._full_text + return record + }) + } else { + // Data is unavailable + datapackage.resources[0].unavailable = true + } + delete datapackage.resources[0].path + // Resource format should be known tabular format for data previews to work + // in EDS, all resources are in 'data' format which isn't valid for previewing + datapackage.resources[0].format = 'csv' + + const schema = { + fields: [ + { + name: 'GasDay', + title: 'Gas Day', + type: 'date', + description: 'Gas Day is a period commencing at 06:00 CET on any day and ending at 06:00 CET on the following day. The Gas Day is reduced to 23 Hours at the transition to summer time and is increased to 25 Hours at the transition to winter time.', + example: '2017-12-24', + unit: 'Days' + }, + { + name: 'KWhFromBiogas', + type: 'number' + }, + { + name: 'KWhToDenmark', + type: 'number' + }, + { + name: 'KWhFromNorthSea', + type: 'number' + }, + { + name: 'KWhToOrFromStorage', + type: 'number' + }, + { + name: 'KWhToOrFromGermany', + type: 'number' + }, + { + name: 'KWhToSweden', + type: 'number' + } + ] + } + datapackage.resources[0].schema = schema + + // Since "datapackage-views-js" library renders views according to + // descriptor's "views" property, we need to generate view objects: + datapackage.views = datapackage.views || [] + datapackage.resources.forEach((resource, index) => { + // Convert bytes into human-readable format: + resource.size = resource.size ? bytes(resource.size, {decimalPlaces: 0}) : resource.size + const view = { + id: index, + title: resource.title || resource.name, + resources: [ + resource.name + ], + specType: null + } + resource.format = resource.format.toLowerCase() + // Add 'table' views for each tabular resource: + const tabularFormats = ['csv', 'tsv', 'dsv', 'xls', 'xlsx'] + if (tabularFormats.includes(resource.format)) { + view.specType = 'table' + } else if (resource.format.includes('json')) { + // Add 'map' views for each geo resource: + view.specType = 'map' + } else if (resource.format === 'pdf') { + view.specType = 'document' + } + + datapackage.views.push(view) + }) + + const profile = await Model.getProfile(req.params.owner) + + res.render('showcase.html', { + title: req.params.owner + ' | ' + req.params.name, + dataset: datapackage, + owner: { + name: profile.name, + title: profile.title, + description: utils.processMarkdown.render(profile.description), + avatar: profile.image_display_url || profile.image_url + }, + thisPageFullUrl: req.protocol + '://' + req.get('host') + req.originalUrl, + dpId: JSON.stringify(datapackage).replace(/'/g, "'") + }) + }) +} diff --git a/themes/eds/views/base.html b/themes/eds/views/base.html index d99f9334..3b3ad2cf 100644 --- a/themes/eds/views/base.html +++ b/themes/eds/views/base.html @@ -40,11 +40,12 @@ - - {% if dataset %} + {% endif %} + + diff --git a/themes/eds/views/collection.html b/themes/eds/views/collection.html new file mode 100644 index 00000000..ab212a0e --- /dev/null +++ b/themes/eds/views/collection.html @@ -0,0 +1,69 @@ +{% extends "base.html" %} +{% import '_snippets.html' as snippets %} + +{% block title %} +{{ item.title }} +{% endblock %} + +{% block bodyclass %}search{% endblock %} + +{% block content %} + +
+ April 10, 2019
-February 5, 2019
-{{ post.published }}
++ {{ dataset.readmeSnippet }} +
+ {% elif dataset.readmeHtml %} ++ {{ dataset.readmeHtml|safe }} +
+ {% elif dataset.description %} ++ {% if dataset.description|length > 200 %} + {{ dataset.description|truncate(200) }} + {% else %} + {{ dataset.description }} + {% endif %} +
+ {% endif %} ++ Total number of rows: {{ dataset.resources[0].rows }} +
+| {{key}} | +{{value}} | +
|---|