Skip to content

Commit

Permalink
Merge pull request #110 from oSoc18/develop
Browse files Browse the repository at this point in the history
Merge develop into master
  • Loading branch information
ThibaultLesuisse authored Jul 16, 2018
2 parents 38277fc + 4856a04 commit f899bb3
Show file tree
Hide file tree
Showing 28 changed files with 4,614 additions and 2,024 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
machine:
enabled: true
steps:
- run: ssh -o "StrictHostKeyChecking no" $SSH_USER@$SSH_HOST "cd ~/build/SmartFlanders; git reset --hard; rm package-lock.json; git pull; git checkout master; npm install; forever stopall; forever start index.js"
- run: ssh -o "StrictHostKeyChecking no" $SSH_USER@$SSH_HOST "~/deploy.sh"

workflows:
version: 2
Expand Down
19 changes: 19 additions & 0 deletions .circleci/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash

# Go to master branch version
cd ~/build/SmartFlanders
git reset --hard
rm package-lock.json
git pull
git checkout master

# Install back end
npm install
forever stopall
forever start index.js

# Install front end
cd /var/www/smartflanders.ilabt.imec.be
rm *.html *.css *.js *.scss
cp ~/build/SmartFlanders/frontend /var/www/smartflanders.ilabt.imec.be

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ typings/

# next.js build output
.next

# SASS compile file
frontend/styles.css.map
28 changes: 28 additions & 0 deletions controllers/openingHoursController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const validator = require('validator')
const transformer = require('../helpers/transformer')

let json = []

exports.getOpeningHours = (params) => {

Object.keys(params.openinghours).forEach((element, index) => {
json.push({
"@type": "OpeningHoursSpecification",
"closes": Object.values(params.openinghours)[index][1],
"dayOfWeek": "http://schema.org/" + capitalizeFirstLetter(element),
"opens": Object.values(params.openinghours)[index][0]
}, {
"@type": "OpeningHoursSpecification",
"closes": Object.values(params.openinghours)[index][3],
"dayOfWeek": "http://schema.org/" + capitalizeFirstLetter(element),
"opens": Object.values(params.openinghours)[index][2]
})
});
return `
"openingHoursSpecification": ${JSON.stringify(json)}
`
}

function capitalizeFirstLetter(chars) {
return chars[0].toUpperCase() + chars.slice(1);
}
25 changes: 22 additions & 3 deletions controllers/transformerController.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const transformer = require('../helpers/transformer')
* Validates user input
* @param {Object} params
*/
module.exports = async (params) => {
exports.getAdres = async (params) => {
try {
if (!validator.isPostalCode(params.postcode, 'BE')) throw new Error("Postcode is niet correct");
if (!validator.isLength(params.street, {
Expand All @@ -18,10 +18,29 @@ module.exports = async (params) => {
min: 1,
max: 10000
})) throw new Error("Huisnummer is niet correct");
let response = await transformer(params);
let response = await transformer.adresFetcher(params);
return response
} catch (error) {
console.log(error.name + ': ' + error.message);
throw new Error(error.message)
}
}
}

exports.getGebouwEenheden = async (params) => {
try {
if(!validator.isInt(params.adresObjectId)) throw new Error ("Adres is geen nummer");
return await transformer.gebouwEenheidFetcher(params)
} catch (error) {
console.log(error.name + ': ' + error.message);
throw new Error(error.message)
}
}

exports.getGebouwId = async (params) => {
try {
if(!validator.isDataURI(params.gebouwEenheidId)) throw new Error ("gebouwEenheidId is geen URI");
} catch (error) {
console.log(error.name + ': ' + error.message);
throw new Error(error.message)
}
}
39 changes: 39 additions & 0 deletions files/catalog-example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"@context": {
"dcat": "https://www.w3.org/ns/dcat#",
"dcterms": "http://purl.org/dc/terms/",
"foaf": "http://xmlns.com/foaf/0.1/"
},
"@type": "dcat:Catalog",
"dcterms:license": [{
"@id": "https://creativecommons.org/publicdomain/zero/1.0/"
}],
"dcat:dataset": [{
"@type": "dcat:Dataset",
"dcat:keyword": "http://schema.org/Service",
"dcat:distribution": [{
"@type": "dcat:Distribution",
"dcat:accessUrl": "https://www.mechelen.be/huis-van-de-mechelaar",
"dcat:mediaType": "text/html"
}]
},
{
"@type": "dcat:Dataset",
"dcat:keyword": "http://purl.org/vocab/cpsv#PublicService",
"dcat:distribution": [{
"@type": "dcat:Distribution",
"dcat:accessUrl": "http://www.academiemechelen.be/",
"dcat:mediaType": "text/html"
}]
},
{
"@type": "dcat:Dataset",
"dcat:keyword": "http://data.vlaanderen.be/ns/gebouw#Gebouw",
"dcat:distribution": [{
"@type": "dcat:Distribution",
"dcat:accessUrl": "http://smartflanders.ilabt.imec.be/graph/gebouw-example.json",
"dcat:mediaType": "text/html"
}]
}
]
}
26 changes: 26 additions & 0 deletions files/gebouw-example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"@context": {
"gebouwenRegister": "http://data.vlaanderen.be/id/gebouw/",
"adressenRegister": "https://data.vlaanderen.be/doc/adres",
"gebouw": "http://data.vlaanderen.be/ns/gebouw#",
"schema": "http://schema.org/",
"dcterms": "http://purl.org/dc/terms/",
"toevla": "http://semweb.mmlab.be/ns/wa#",
"locn": "http://www.w3.org/ns/locn#",
"geo": "http://www.opengis.net/ont/geosparql#",
"xsd": "http://www.w3.org/2001/XMLSchema#"
},
"@id": "http://data.vlaanderen.be/id/gebouw/123",
"@type": "gebouw:Gebouw",
"http://purl.org/dc/terms/description": "The entrance of the public library of Mechelen",
"toevla:accessibilityMeasurement": {
"toevla:accessibilityMeasurement_for": {
"dcterms:description": "The entrance",
"toevla:entranceDoorWidth": {
"@value": "70",
"@type": "xsd:Integer"
},
"toevla:entranceDoorWidthScore": "+"
}
}
}
17 changes: 17 additions & 0 deletions files/master-catalog.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"@context": {
"dcat": "https://www.w3.org/ns/dcat#",
"dcterms": "http://purl.org/dc/terms/",
"foaf": "http://xmlns.com/foaf/0.1/"
},
"@type": "dcterms:Collection",
"dcterms:hasPart": [{
"foaf:page": "http://smartflanders.ilabt.imec.be/catalog-example.json",
"@type": "dcat:Catalog"
},
{
"foaf:page": "http://www.oostende.be/",
"@type": "dcat:Catalog"
}
]
}
69 changes: 69 additions & 0 deletions files/service-example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[{
"@context": "http://schema.org/",
"@id": "https://stad.gent/id/products/123",
"@type": "Service",
"name": "Public toilet library",
"description": "The public toilet of the public library of Mechelen",
"http://purl.org/oslo/ns/localgov#productType": "http://productencatalogus.vlaanderen.be/fiche/158",
"telephone": "+32",
"email": "[email protected]",
"https://schema.org/hoursAvailable":
[
{
"@type": "OpeningHoursSpecification",
"dayOfWeek": "schema:Monday",
"opens": "09:00",
"closes": "11:00"
},
{
"@type": "OpeningHoursSpecification",
"dayOfWeek": "schema:Tuesday",
"opens": "09:00",
"closes": "16:00"
},
{
"@type": "OpeningHoursSpecification",
"validFrom": "2013-12-24",
"validThrough": "2014-01-02"
}
]
},{
"@id": "https://stad.gent/id/products/123",
"@type": "http://purl.org/vocab/cpsv#PublicService",
"http://data.europa.eu/m8g/hasChannel": {
"https://schema.org/hoursAvailable":
[
{
"@type": "OpeningHoursSpecification",
"validFrom": "2013-12-24",
"validThrough": "2013-12-25",
"opens": "09:00",
"closes": "11:00"
},
{
"@type": "OpeningHoursSpecification",
"validFrom": "2013-05-24",
"validThrough": "2013-10-25",
"opens": "09:00",
"closes": "16:00"
},
{
"@type": "OpeningHoursSpecification",
"validFrom": "2013-12-24",
"validThrough": "2014-01-02"
}
]
},
"http://purl.org/dc/terms/description": "The public toilet of the public library of Mechelen",
"http://www.w3.org/ns/locn#location": "http://data.vlaanderen.be/id/gebouw/123",
"toevla:accessibilityMeasurement": {
"toevla:accessibilityMeasurement_for": {
"dcterms:description": "The elevator",
"toevla:elevatorDoorWidth": {
"@value": "70",
"@type": "xsd:Integer"
},
"toevla:elevatorDoorScore": "+"
}
}
}]
Loading

0 comments on commit f899bb3

Please sign in to comment.