-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
212 additions
and
20 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ plugins/album/public/assets | |
plugins/editAlbum/public/assets | ||
coverage.lcov | ||
.nyc_output | ||
yarn-error.log |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
File renamed without changes.
This file contains 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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
plugins/gallery/test/index.spec.js → plugins/gallery/test/gallery.spec.js
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* global __dirname, require */ | ||
const json = require('./json'); | ||
const validation = require('../../../lib/validation'); | ||
|
||
const handler = (request, reply) => { | ||
const albumStem = request.query.album_stem; | ||
const gallery = request.query.gallery; | ||
|
||
json.dataToGeojson(gallery, albumStem) | ||
.then(geojsonData => reply(geojsonData)) | ||
.catch(error => reply(error)); | ||
}; | ||
|
||
exports.register = (server, options, next) => { | ||
server.route({ | ||
method: 'GET', | ||
path: '/', | ||
config: { | ||
description: 'GeoJSON for any album in any gallery', | ||
handler, | ||
tags: ['api', 'plugin'], | ||
validate: { | ||
query: { | ||
album_stem: validation.albumStem, | ||
gallery: validation.gallery, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
next(); | ||
}; | ||
|
||
exports.register.attributes = { | ||
name: 'history-geojson', | ||
version: '0.1.0', | ||
}; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
const convertor = require('geojson'); | ||
|
||
const viewAlbum = require('../../album/lib/json'); | ||
|
||
module.exports.dataToGeojson = (gallery, albumStem) => new Promise((resolve, reject) => { | ||
viewAlbum.getAlbum(gallery, albumStem) | ||
.then((albumData) => { | ||
const jsonData = convertor.parse(albumData.album.items, { Point: ['geo_lat', 'geo_lon'] }); | ||
resolve(jsonData); | ||
}) | ||
.catch(error => reject(error)); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"extends": "airbnb", | ||
"rules": { | ||
"max-len": [2, 150, 4], | ||
"import/no-extraneous-dependencies": ["error", { "devDependencies": true }], | ||
"global-require": 0 | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const tape = require('tape-catch'); | ||
|
||
tape('GeoJSON Index', { skip: false }, (describe) => { | ||
const geojsonhint = require('@mapbox/geojsonhint'); | ||
const hapi = require('hapi'); | ||
|
||
const lib = require('../lib'); | ||
const utils = require('../../utils/lib'); | ||
|
||
const plugins = [lib]; | ||
const port = utils.config.get('port'); | ||
|
||
describe.test('* Validate GeoJSON', (assert) => { | ||
const server = new hapi.Server(); | ||
server.connection({ port }); | ||
server.register(plugins, (pluginError) => { | ||
if (pluginError) { | ||
assert.fail(pluginError); | ||
return; | ||
} | ||
|
||
const request = { | ||
method: 'GET', | ||
url: '/?gallery=demo&album_stem=sample', | ||
}; | ||
|
||
server.inject(request, (result) => { | ||
assert.ok(geojsonhint.hint({}).length > 0, 'Error expected'); | ||
|
||
assert.equal(result.statusCode, 200); | ||
const response = result.result; | ||
const error = geojsonhint.hint(response); | ||
|
||
assert.equal(error.length, 0, 'Validation passes'); | ||
assert.end(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
const tape = require('tape-catch'); | ||
|
||
tape('GeoJSON JSON', { skip: false }, (describe) => { | ||
const geojsonhint = require('@mapbox/geojsonhint'); | ||
const lib = require('../lib/json'); | ||
|
||
describe.test('* Validate GeoJSON', (assert) => { | ||
const expectedError = geojsonhint.hint({}); | ||
|
||
assert.ok(expectedError.length > 0, 'Error expected'); | ||
|
||
lib.dataToGeojson('demo', 'sample') | ||
.then((json) => { | ||
const error = geojsonhint.hint(json); | ||
|
||
assert.equal(error.length, 0, 'Validation passes'); | ||
assert.end(); | ||
}); | ||
}); | ||
}); |
This file contains 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
File renamed without changes.
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.