Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Basic listing of files in UI #391

Merged
merged 11 commits into from
Feb 24, 2020
4 changes: 4 additions & 0 deletions .bettercodehub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
exclude:
- /ui/*.*
- /api/server/plugins/editAlbum/public/lib/json_to_xml.js
- /api/server/plugins/album/public/lib/color-thief.js
2,781 changes: 1,772 additions & 1,009 deletions api/package-lock.json

Large diffs are not rendered by default.

60 changes: 29 additions & 31 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,69 +20,67 @@
"main": "server/index.js",
"dependencies": {
"@hapi/hapi": "^18.4.1",
"@hapi/joi": "^15.0.3",
"@hapi/joi": "^15.1.1",
"app-root-path": "^2.2.1",
"async": "^2.1.2",
"async": "^2.6.3",
"babel-loader": "^7.0.0",
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.16.0",
"boom": "^7.0.0",
"camelcase": "^5.3.1",
"clone": "^2.1.1",
"dot-prop": "^5.1.1",
"dotenv": "^8.0.0",
"dropbox": "^4.0.17",
"dot-prop": "^5.2.0",
"dotenv": "^8.2.0",
"dropbox": "^4.0.30",
"extend": "^3.0.0",
"geojson": "^0.5.0",
"glob": "^7.1.4",
"glob": "^7.1.6",
"gm": "^1.23.0",
"hapi-react-views": "^10.0.1",
"hapi-swagger": "^10.0.2",
"hapi-react-views": "^10.1.1",
"hapi-swagger": "^10.3.0",
"inert": "^5.1.3",
"isomorphic-fetch": "^2.2.1",
"jquery-colorbox": "^1.6.4",
"lout": "^11.2.3",
"mime-types": "^2.1.24",
"moment": "^2.20.1",
"node-notifier": "^5.0.1",
"react": "^16.8.6",
"react-dates": "^20.2.1",
"react-dom": "^16.8.6",
"styled-components": "^4.2.1",
"mime-types": "^2.1.26",
"node-notifier": "^5.4.3",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"styled-components": "^4.4.1",
"tap-webpack-plugin": "^2.0.0",
"tuxharness": "^2.0.4",
"vision": "^5.3.1",
"webpack": "^4.32.2",
"xml2js": "^0.4.17"
"webpack": "^4.41.6",
"xml2js": "^0.4.23"
},
"devDependencies": {
"@hapi/wreck": "^15.1.0",
"@mapbox/geojsonhint": "^3.0.0",
"@hapi/wreck": "^15.0.1",
"calipers": "^2.0.0",
"calipers-jpeg": "^2.0.0",
"codeclimate-test-reporter": "^0.5.0",
"coveralls": "^3.0.3",
"coveralls": "^3.0.9",
"css-loader": "^2.1.0",
"enzyme": "^3.9.0",
"enzyme-adapter-react-16": "^1.13.2",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"eslint": "5.13.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-markdown": "^1.0.0-beta.6",
"eslint-plugin-react": "^7.13.0",
"eslint-config-airbnb": "^17.1.1",
"eslint-plugin-import": "^2.20.1",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-markdown": "^1.0.1",
"eslint-plugin-react": "^7.18.3",
"file-loader": "^3.0.1",
"jest": "^23.6.0",
"jsdom": "^15.1.1",
"lodash": "^4.17.11",
"jsdom": "^15.2.1",
"lodash": "^4.17.15",
"nyc": "^14.1.1",
"standard-version": "^6.0.1",
"style-loader": "^0.23.0",
"tape": "^4.10.2",
"tape": "^4.13.0",
"tape-catch": "^1.0.6",
"typy": "^3.1.0",
"typy": "^3.3.0",
"url-loader": "^1.0.1",
"webpack-cli": "^3.3.2"
"webpack-cli": "^3.3.11"
},
"description": "Your personal history storyboarded with photo and video albums. Associate photos with their meta data including geocode, caption, friends (characters)... in XML albums.",
"repository": {
Expand Down
5 changes: 5 additions & 0 deletions api/server/lib/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,14 @@ const createErrorReply = reply => (error) => {
reply(boomError);
};

function wrapError(error) {
return (error.isBoom) ? error : boom.boomify(error);
}

module.exports = {
createErrorReply,
staticRoute,
staticRouteJquery,
staticRouteUtils,
wrapError,
};
26 changes: 0 additions & 26 deletions api/server/plugins/walk/components/page.jsx

This file was deleted.

37 changes: 0 additions & 37 deletions api/server/plugins/walk/lib/browser.js

This file was deleted.

6 changes: 0 additions & 6 deletions api/server/plugins/walk/lib/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ const globCallback = require('glob');
const path = require('path');
const { promisify } = require('util');

const config = require('../../../../../config.json');
const utils = require('../../utils');

const glob = promisify(globCallback);
Expand Down Expand Up @@ -37,11 +36,6 @@ async function listFiles(destPath = '') {
}
}

function areImages(file) {
return (file.mediumType === 'image' && config.supportedFileTypes.photo.includes(file.ext.toLowerCase()));
}

module.exports = {
areImages,
listFiles,
};
41 changes: 11 additions & 30 deletions api/server/plugins/walk/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,31 @@ const routes = require('../../../lib/routes');
const files = require('./files');
const validation = require('../../../lib/validation');

const handler = ({ query: { path, raw: isRaw } }, reply) => new Promise((resolve) => {
const viewPath = 'plugins/walk/components/page.jsx';
const handleResponse = json => ((isRaw) ? resolve(json) : resolve(reply.view(viewPath, json)));
const handleError = routes.createErrorReply(resolve);

files.listFiles(path)
.then(handleResponse)
.catch(handleError);
});

const routeWalkPath = {
method: 'GET',
path: '/admin/walk-path',
options: {
handler,
tags: ['api', 'react'],
handler: async function handler({ query: { path } }) {
try {
return files.listFiles(path);
} catch (e) {
return routes.wrapError(e);
}
},
cors: {
origin: ['http://localhost:3000'],
},
tags: ['api'],
validate: {
query: {
path: validation.sourceFolder,
raw: validation.raw,
},
},
},
};

const routeBundle = {
method: 'GET',
path: '/walk/static/bundle.js',
options: {
tags: ['static'],
handler: {
file: 'plugins/walk/public/assets/bundle.js',
},
},
};

const register = (server) => {
server.route(routeWalkPath);

server.route(routes.staticRoute({ pluginName: 'walk', urlSegment: 'walk' }));

server.route(routes.staticRouteUtils({ urlSegment: 'walk' }));

server.route(routeBundle);
};

const plugin = {
Expand Down
34 changes: 0 additions & 34 deletions api/server/plugins/walk/test/controls.jest.jsx

This file was deleted.

41 changes: 0 additions & 41 deletions api/server/plugins/walk/test/files.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,45 +17,4 @@ tape('Files', { skip: false }, (describe) => {
.catch(error => testCase.error(assert, error));
});
});

describe.test('* Can this file be displayed as a supported image?', (assert) => {
const unit = lib.areImages;
let actual;
let expected;


actual = unit({
ext: 'jpg',
mediumType: 'video',
});
expected = false;
assert.equal(actual, expected, 'jpg video');


actual = unit({
ext: 'jpg',
mediumType: 'image',
});
expected = true;
assert.equal(actual, expected, 'jpg image');


actual = unit({
ext: 'JPG',
mediumType: 'image',
});
expected = true;
assert.equal(actual, expected, 'JPG image');


actual = unit({
ext: 'JPg',
mediumType: 'image',
});
expected = true;
assert.equal(actual, expected, 'JPg image');


assert.end();
});
});
Loading