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 %} + +
+
+ +
+
+
+
+
+
+
+ +
+
+
+ {% include "./partials/data-search-form.njk" %} + {% include "./partials/data-search-results.njk" %} +
+ {% include "./partials/data-search-pagination.njk" %} +
+
+
+
+
+{% endblock %} diff --git a/themes/eds/views/collections-home.html b/themes/eds/views/collections-home.html new file mode 100644 index 00000000..f71ca676 --- /dev/null +++ b/themes/eds/views/collections-home.html @@ -0,0 +1,84 @@ +{% extends "base.html" %} + +{% block title%}{{title}}{% endblock %} + +{% block bodyclass %}awesome{% endblock %} + +{% block content %} + + +
+
+
+ +
+
+
+
+
+
+
+
+ +
+
+
+

{{ title }}

+
+
+
+
    +
  • +
  • + +
  • +
+
+
+
+
+

{{ collections|length }} {{ "organization" if slug=="organization" else "collection" }}{{ "s" if collections|length != 1 else ""}} found

+
+
+
+
    + {% for collection in collections %} +
  • + {{ collection.name }} +

    {{ collection.title }}

    + {% if slug=="organization" %} + {{ collection.count }} Dataset{{ 's' if collection.count != 1 else '' }} + {% endif %} + + View {{ collection.title }} + +
  • + {% endfor %} +
  • +
+
+
+
+
+
+
+ +{% endblock %} diff --git a/themes/eds/views/home.html b/themes/eds/views/home.html index 7f348964..124f2d21 100644 --- a/themes/eds/views/home.html +++ b/themes/eds/views/home.html @@ -254,25 +254,37 @@

{{__('News')}}

-
-

April 10, 2019

-
- Opdatering til ny version d. 10. april 2019/update to new version the 10th of April 2019 - - > - -
-
- -
-

February 5, 2019

-
- Der kan nu downloades igen / You can now download again - - > - -
-
+ {% for post in posts %} +
+

{{ post.published }}

+
+ {{ post.title }} + + > + +
+
+ {% endfor %} + + + + + + + + + + + + + + + + + + + + {{__('See all news')}} diff --git a/themes/eds/views/owner.html b/themes/eds/views/owner.html new file mode 100644 index 00000000..04c8d992 --- /dev/null +++ b/themes/eds/views/owner.html @@ -0,0 +1,69 @@ +{% extends "base.html" %} +{% import '_snippets.html' as snippets %} + +{% block title %} +{{ item.title }} +{% endblock %} + +{% block bodyclass %}search{% endblock %} + +{% block content %} + +
+
+ +
+
+
+
+
+
+
+ +
+
+
+ {% include "./partials/data-search-form.njk" %} + {% include "./partials/data-search-results.njk" %} +
+ {% include "./partials/data-search-pagination.njk" %} +
+
+
+
+
+{% endblock %} diff --git a/themes/eds/views/partials/data-search-form.njk b/themes/eds/views/partials/data-search-form.njk new file mode 100644 index 00000000..ecc69620 --- /dev/null +++ b/themes/eds/views/partials/data-search-form.njk @@ -0,0 +1,23 @@ +
+ +
+
+
    +
  • +
  • + +
  • +
+
+
+
+
+

{{ result.count }} dataset{{ "s" if result.count != 1 else ""}} found

+
+
+
diff --git a/themes/eds/views/partials/data-search-pagination.njk b/themes/eds/views/partials/data-search-pagination.njk new file mode 100644 index 00000000..6fa1d1c8 --- /dev/null +++ b/themes/eds/views/partials/data-search-pagination.njk @@ -0,0 +1,18 @@ +{% if totalPages > 1 %} +
+ +
+{% endif %} diff --git a/themes/eds/views/partials/data-search-results.njk b/themes/eds/views/partials/data-search-results.njk new file mode 100644 index 00000000..905d73d6 --- /dev/null +++ b/themes/eds/views/partials/data-search-results.njk @@ -0,0 +1,43 @@ + diff --git a/themes/eds/views/partials/search-filter.njk b/themes/eds/views/partials/search-filter.njk new file mode 100644 index 00000000..b835dce7 --- /dev/null +++ b/themes/eds/views/partials/search-filter.njk @@ -0,0 +1,104 @@ +
+
+

+ + {{__('Organizations')}} +

+ + +
+
+ +

+ + {{__('Groups')}} +

+ + +
+
+ +

+ + {{__('Tags')}} +

+ + + +
+
+ +

+ + {{__('Formats')}} +

+ + + +
+
+ +

+ + {{__('Licenses')}} +

+ + +
+
diff --git a/themes/eds/views/search.html b/themes/eds/views/search.html new file mode 100644 index 00000000..26473ee3 --- /dev/null +++ b/themes/eds/views/search.html @@ -0,0 +1,48 @@ +{% extends "base.html" %} +{% import '_snippets.html' as snippets %} + +{% block title %} +{{ title }} +{% endblock %} + +{% block bodyclass %}search{% endblock %} + +{% block content %} +
+
+
+ +
+
+
+
+
+
+
+ +
+
+
+ {% include "./partials/data-search-form.njk" %} + {% include "./partials/data-search-results.njk" %} +
+ {% include "./partials/data-search-pagination.njk" %} +
+
+
+
+
+ +
+{% endblock %} diff --git a/themes/eds/views/showcase.html b/themes/eds/views/showcase.html new file mode 100644 index 00000000..4cbe5205 --- /dev/null +++ b/themes/eds/views/showcase.html @@ -0,0 +1,244 @@ +{% extends "base.html" %} + +{% block title %} +{{dataset.title or dataset.name}} - Dataset +{% endblock %} + +{% block content %} + + + +
+
+ + + +
+
+
+
+
+ +
    +
  • + +
  • +
  • +
    + + +
    +
  • +
  • + + Metadata + +
  • +
  • + +
  • +
+
+

{{ dataset.title }}

+
+

+ Total number of rows: {{ dataset.resources[0].rows }} +

+
+ + {% for view in dataset.views %} + +
+ + {% endfor %} +
+ + + + +
+
+
+
+ + + +
+
+
+ +
+ {% for field in dataset.resources[0].schema.fields %} +
+
+
+

{{ field.title or field.name }}

+ + + {% for key, value in field %} + + + + + {% endfor %} + +
{{key}}{{value}}
+
+
+
+ {% endfor %} +
+
+
+
+ +
+
+ +
+{% endblock %} + +{% block scripts %} + + + +{% endblock %} diff --git a/views/static.html b/views/static.html index 19f2dc48..d433e3c1 100644 --- a/views/static.html +++ b/views/static.html @@ -1,13 +1,26 @@ {% extends "base.html" %} -{% block title %} -Welcome - About -{% endblock %} +{% block title%}{{title}}{% endblock %} -{% block bodyclass %}static{% endblock %} +{% block bodyclass %}blog static{% endblock %} {% block content %} -
- {{ title }} + +
+
+
+ +
+
+ {{content | safe}} +
+
+
+
+ {% endblock %}