Skip to content
This repository was archived by the owner on Nov 6, 2022. It is now read-only.

Commit d3c16ff

Browse files
authored
Merge pull request #176 from trailimage/develop
Develop
2 parents 1f9ba29 + e575b4c commit d3c16ff

40 files changed

+6351
-2884
lines changed

.vscode/extensions.json

-16
This file was deleted.

LICENSE.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2019 Jason Abbott
1+
Copyright (c) 2020 Jason Abbott
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44

package-lock.json

+5,230-1,721
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,32 @@
1919
},
2020
"dependencies": {
2121
"@toba/block-spam-referer": "^2.1.0",
22-
"@toba/develop": "^6.7.5",
22+
"@toba/develop": "^6.8.0",
2323
"@toba/feed": "^3.1.1",
2424
"@toba/handlebars": "^2.1.0",
25-
"@toba/node-tools": "^1.4.13",
26-
"@trailimage/flickr-provider": "^3.2.0",
27-
"@trailimage/google-provider": "^2.5.0",
28-
"@trailimage/models": "^3.2.1",
25+
"@toba/node-tools": "^1.5.3",
26+
"@trailimage/flickr-provider": "^3.2.2",
27+
"@trailimage/google-provider": "^2.5.1",
28+
"@trailimage/models": "^3.2.2",
2929
"compression": "^1.7.0",
3030
"express": "^4.16.0",
3131
"node-fetch": "^2.2.0",
32-
"uglify-js": "^3.7.2"
32+
"uglify-js": "^3.7.6"
3333
},
3434
"devDependencies": {
35-
"@toba/test": "^4.1.17",
35+
"@toba/test": "^4.2.0",
3636
"@types/compression": "1.0.0",
3737
"@types/core-js": "^2.5.0",
3838
"@types/express": "^4.17.2",
3939
"@types/facebook-js-sdk": "^3.3.0",
4040
"@types/gapi": "0.0.35",
4141
"@types/geojson": "^7946.0.0",
4242
"@types/google.analytics": "^0.0.37",
43-
"@types/googlemaps": "^3.38.1",
43+
"@types/googlemaps": "^3.39.2",
4444
"@types/jquery": "^3.3.0",
4545
"@types/mapbox-gl": "^0.45.0",
4646
"@types/node-fetch": "^2.5.4",
47-
"@types/request": "^2.48.3",
47+
"@types/request": "^2.48.4",
4848
"@types/twitter": "1.7.0",
4949
"@types/uglify-js": "^3.0.0",
5050
"cssnano": "^4.1.10",
@@ -58,7 +58,7 @@
5858
"merge2": "^1.3.0",
5959
"through2": "^3.0.0",
6060
"ts-node-dev": "^1.0.0-pre.44",
61-
"typescript": "^3.7.3"
61+
"typescript": "^3.7.5"
6262
},
6363
"repository": {
6464
"type": "git",

src/app.ts

+52-51
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,82 @@
1-
import { blockSpamReferers } from '@toba/block-spam-referer';
2-
import compress from 'compression';
3-
import Express from 'express';
4-
import { ExpressHandlebars } from '@toba/handlebars';
5-
import * as path from 'path';
6-
import { postProvider } from '@trailimage/flickr-provider';
7-
import { mapProvider } from '@trailimage/google-provider';
8-
import { config as modelConfig, blog } from '@trailimage/models';
9-
import { config } from './config';
1+
import { blockSpamReferers } from '@toba/block-spam-referer'
2+
import compress from 'compression'
3+
import Express from 'express'
4+
import { ExpressHandlebars } from '@toba/handlebars'
5+
import * as path from 'path'
6+
import { postProvider } from '@trailimage/flickr-provider'
7+
import { mapProvider } from '@trailimage/google-provider'
8+
import { config as modelConfig, blog } from '@trailimage/models'
9+
import { config } from './config'
1010
import {
1111
Layout,
1212
addTemplateMethods,
1313
requireSSL,
1414
checkCacheReset,
1515
sortCategories
16-
} from './views/';
17-
import { route } from './routes';
16+
} from './views/'
17+
import { route } from './routes'
1818

19-
const root = path.join(__dirname, '..');
19+
const root = path.join(__dirname, '..')
2020

2121
if (process.argv.includes('--serve')) {
22-
configureModels();
23-
createWebService();
22+
configureModels()
23+
createWebService()
2424
}
2525

2626
export function configureModels() {
27-
postProvider.configure(config.providers.post);
28-
mapProvider.configure(config.providers.map);
27+
postProvider.configure(config.providers.post)
28+
mapProvider.configure(config.providers.map)
2929

30-
modelConfig.site = config.site;
31-
modelConfig.owner = config.owner;
32-
modelConfig.subtitleSeparator = config.posts.subtitleSeparator;
33-
modelConfig.maxPhotoMarkersOnMap = config.providers.map.maxMarkers;
34-
modelConfig.providers.post = postProvider;
35-
modelConfig.providers.map = mapProvider;
30+
modelConfig.site = config.site
31+
modelConfig.owner = config.owner
32+
modelConfig.subtitleSeparator = config.posts.subtitleSeparator
33+
modelConfig.maxPhotoMarkersOnMap = config.providers.map.maxMarkers
34+
modelConfig.providers.post = postProvider
35+
modelConfig.providers.map = mapProvider
3636
modelConfig.artistsToNormalize = new RegExp(
3737
config.posts.artistNames.join('|')
38-
);
38+
)
3939
}
4040

4141
async function createWebService() {
42-
const app = Express();
43-
const port = process.env['PORT'] || 3000;
42+
const app = Express()
43+
const port = process.env['PORT'] || 3000
4444

4545
console.info(
4646
`Starting ${
4747
config.isProduction ? 'production' : 'development'
4848
} application`
49-
);
49+
)
5050

51-
defineViews(app);
51+
defineViews(app)
5252

53-
if (false) {
54-
//config.needsAuth) {
53+
if (
54+
false &&
55+
!(postProvider.isAuthenticated && mapProvider.isAuthenticated)
56+
) {
5557
// must authenticate before normal routes are available
56-
route.authentication(app);
57-
app.listen(port);
58-
console.info(`Listening for authentication on port ${port}`);
58+
route.authentication(app)
59+
app.listen(port)
60+
console.info(`Listening for authentication on port ${port}`)
5961
} else {
60-
if (config.requireSSL) {
61-
app.use(requireSSL);
62-
}
63-
app.use(blockSpamReferers);
64-
app.use(checkCacheReset);
62+
if (config.requireSSL) app.use(requireSSL)
63+
64+
app.use(blockSpamReferers)
65+
app.use(checkCacheReset)
6566
// https://github.com/expressjs/compression/blob/master/README.md
66-
app.use(compress());
67-
app.use(Express.static(path.join(root, 'public')));
67+
app.use(compress())
68+
app.use(Express.static(path.join(root, 'public')))
6869

69-
await blog.load();
70+
await blog.load()
7071

7172
if (blog.loaded) {
7273
// blog must be loaded before routes are defined
73-
sortCategories(blog);
74-
route.standard(app);
75-
app.listen(port);
76-
console.info(`Listening on port ${port}`);
74+
sortCategories(blog)
75+
route.standard(app)
76+
app.listen(port)
77+
console.info(`Listening on port ${port}`)
7778
} else {
78-
console.error('Blog data failed to load. Stopping application.');
79+
console.error('Blog data failed to load. Stopping application.')
7980
}
8081
}
8182
}
@@ -85,15 +86,15 @@ async function createWebService() {
8586
* @see http://mustache.github.com/mustache.5.html
8687
*/
8788
function defineViews(app: Express.Application) {
88-
const viewPath = path.join(root, 'views');
89+
const viewPath = path.join(root, 'views')
8990
const ehb = new ExpressHandlebars({
9091
defaultLayout: Layout.Main!
91-
});
92+
})
9293

9394
// http://expressjs.com/4x/api.html#app-settings
94-
app.set('views', viewPath);
95-
app.set('view engine', ehb.fileExtension);
96-
app.engine(ehb.fileExtension, ehb.renderer);
95+
app.set('views', viewPath)
96+
app.set('view engine', ehb.fileExtension)
97+
app.engine(ehb.fileExtension, ehb.renderer)
9798

98-
addTemplateMethods(ehb);
99+
addTemplateMethods(ehb)
99100
}

src/client/browser.d.ts

+33-33
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,34 @@
77
* @see http://www.trailimage.com/js/post-menu-data.js
88
*/
99
interface PostMenu {
10-
category: { [key: string]: MenuCategory[] };
11-
post: { [key: string]: MenuPost };
10+
category: { [key: string]: MenuCategory[] }
11+
post: { [key: string]: MenuPost }
1212
}
1313

1414
interface MenuCategory {
15-
title: string;
16-
posts: string[];
15+
title: string
16+
posts: string[]
1717
}
1818

1919
/**
2020
* Post data within menu.
2121
*/
2222
interface MenuPost {
23-
slug: string;
24-
title: string;
25-
icon: string;
26-
description: string;
27-
subTitle?: string;
23+
slug: string
24+
title: string
25+
icon: string
26+
description: string
27+
subTitle?: string
2828
/** Post position if part of a series */
29-
part?: number;
29+
part?: number
3030
}
3131

3232
/**
3333
* Which features to enable on a page — determines which libraries to lazy-load
3434
*/
3535
interface PageFeature {
36-
facebook: boolean;
37-
timestamp: number;
36+
facebook: boolean
37+
timestamp: number
3838
}
3939

4040
/**
@@ -49,54 +49,54 @@ interface PageFeature {
4949
* GeoJSON properties for post photos.
5050
*/
5151
interface MapPhoto {
52-
url?: string;
53-
title?: string;
54-
partKey?: string;
52+
url?: string
53+
title?: string
54+
partKey?: string
5555
/** Distance from clicked cluster */
56-
distance?: number;
56+
distance?: number
5757
}
5858

5959
/**
6060
* Object generated in `mapbox.hbs` to display post details on the map.
6161
*/
6262
interface MapPost {
63-
key: string;
64-
photoID: number;
63+
key: string
64+
photoID: number
6565
bounds: {
6666
/**
6767
* Southwest corner as lon, lat. For the U.S. this is the smallest
6868
* longitude and latitude values.
6969
*/
70-
sw: number[];
70+
sw: number[]
7171
/**
7272
* Northeast corner as lon, lat. For the U.S. this is the largest
7373
* longitude and latitude values.
7474
*/
75-
ne: number[];
76-
};
75+
ne: number[]
76+
}
7777
}
7878

7979
interface PointCluster {
80-
point_count?: number;
80+
point_count?: number
8181
}
8282

8383
interface UrlPosition {
84-
[key: string]: number | number[];
84+
[key: string]: number | number[]
8585
/** longitude, latitude */
86-
center?: number[];
87-
lon?: number;
88-
lat?: number;
89-
zoom?: number;
86+
center?: number[]
87+
lon?: number
88+
lat?: number
89+
zoom?: number
9090
}
9191
interface FakeEvent {
92-
reason: string;
92+
reason: string
9393
}
9494

9595
interface CssPosition extends JQuery.PlainObject {
96-
top?: number;
97-
left?: number;
98-
right?: number;
99-
bottom?: number;
96+
top?: number
97+
left?: number
98+
right?: number
99+
bottom?: number
100100
}
101101

102102
/**
@@ -106,4 +106,4 @@ type JQueryResponse = (
106106
responseText: string,
107107
textStatus: string,
108108
XMLHttpRequest: XMLHttpRequest
109-
) => any;
109+
) => any

0 commit comments

Comments
 (0)