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

Commit

Permalink
Merge pull request #176 from trailimage/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Jason-Abbott authored Jan 25, 2020
2 parents 1f9ba29 + e575b4c commit d3c16ff
Show file tree
Hide file tree
Showing 40 changed files with 6,351 additions and 2,884 deletions.
16 changes: 0 additions & 16 deletions .vscode/extensions.json

This file was deleted.

2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2019 Jason Abbott
Copyright (c) 2020 Jason Abbott

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:

Expand Down
6,951 changes: 5,230 additions & 1,721 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,32 @@
},
"dependencies": {
"@toba/block-spam-referer": "^2.1.0",
"@toba/develop": "^6.7.5",
"@toba/develop": "^6.8.0",
"@toba/feed": "^3.1.1",
"@toba/handlebars": "^2.1.0",
"@toba/node-tools": "^1.4.13",
"@trailimage/flickr-provider": "^3.2.0",
"@trailimage/google-provider": "^2.5.0",
"@trailimage/models": "^3.2.1",
"@toba/node-tools": "^1.5.3",
"@trailimage/flickr-provider": "^3.2.2",
"@trailimage/google-provider": "^2.5.1",
"@trailimage/models": "^3.2.2",
"compression": "^1.7.0",
"express": "^4.16.0",
"node-fetch": "^2.2.0",
"uglify-js": "^3.7.2"
"uglify-js": "^3.7.6"
},
"devDependencies": {
"@toba/test": "^4.1.17",
"@toba/test": "^4.2.0",
"@types/compression": "1.0.0",
"@types/core-js": "^2.5.0",
"@types/express": "^4.17.2",
"@types/facebook-js-sdk": "^3.3.0",
"@types/gapi": "0.0.35",
"@types/geojson": "^7946.0.0",
"@types/google.analytics": "^0.0.37",
"@types/googlemaps": "^3.38.1",
"@types/googlemaps": "^3.39.2",
"@types/jquery": "^3.3.0",
"@types/mapbox-gl": "^0.45.0",
"@types/node-fetch": "^2.5.4",
"@types/request": "^2.48.3",
"@types/request": "^2.48.4",
"@types/twitter": "1.7.0",
"@types/uglify-js": "^3.0.0",
"cssnano": "^4.1.10",
Expand All @@ -58,7 +58,7 @@
"merge2": "^1.3.0",
"through2": "^3.0.0",
"ts-node-dev": "^1.0.0-pre.44",
"typescript": "^3.7.3"
"typescript": "^3.7.5"
},
"repository": {
"type": "git",
Expand Down
103 changes: 52 additions & 51 deletions src/app.ts
Original file line number Diff line number Diff line change
@@ -1,81 +1,82 @@
import { blockSpamReferers } from '@toba/block-spam-referer';
import compress from 'compression';
import Express from 'express';
import { ExpressHandlebars } from '@toba/handlebars';
import * as path from 'path';
import { postProvider } from '@trailimage/flickr-provider';
import { mapProvider } from '@trailimage/google-provider';
import { config as modelConfig, blog } from '@trailimage/models';
import { config } from './config';
import { blockSpamReferers } from '@toba/block-spam-referer'
import compress from 'compression'
import Express from 'express'
import { ExpressHandlebars } from '@toba/handlebars'
import * as path from 'path'
import { postProvider } from '@trailimage/flickr-provider'
import { mapProvider } from '@trailimage/google-provider'
import { config as modelConfig, blog } from '@trailimage/models'
import { config } from './config'
import {
Layout,
addTemplateMethods,
requireSSL,
checkCacheReset,
sortCategories
} from './views/';
import { route } from './routes';
} from './views/'
import { route } from './routes'

const root = path.join(__dirname, '..');
const root = path.join(__dirname, '..')

if (process.argv.includes('--serve')) {
configureModels();
createWebService();
configureModels()
createWebService()
}

export function configureModels() {
postProvider.configure(config.providers.post);
mapProvider.configure(config.providers.map);
postProvider.configure(config.providers.post)
mapProvider.configure(config.providers.map)

modelConfig.site = config.site;
modelConfig.owner = config.owner;
modelConfig.subtitleSeparator = config.posts.subtitleSeparator;
modelConfig.maxPhotoMarkersOnMap = config.providers.map.maxMarkers;
modelConfig.providers.post = postProvider;
modelConfig.providers.map = mapProvider;
modelConfig.site = config.site
modelConfig.owner = config.owner
modelConfig.subtitleSeparator = config.posts.subtitleSeparator
modelConfig.maxPhotoMarkersOnMap = config.providers.map.maxMarkers
modelConfig.providers.post = postProvider
modelConfig.providers.map = mapProvider
modelConfig.artistsToNormalize = new RegExp(
config.posts.artistNames.join('|')
);
)
}

async function createWebService() {
const app = Express();
const port = process.env['PORT'] || 3000;
const app = Express()
const port = process.env['PORT'] || 3000

console.info(
`Starting ${
config.isProduction ? 'production' : 'development'
} application`
);
)

defineViews(app);
defineViews(app)

if (false) {
//config.needsAuth) {
if (
false &&
!(postProvider.isAuthenticated && mapProvider.isAuthenticated)
) {
// must authenticate before normal routes are available
route.authentication(app);
app.listen(port);
console.info(`Listening for authentication on port ${port}`);
route.authentication(app)
app.listen(port)
console.info(`Listening for authentication on port ${port}`)
} else {
if (config.requireSSL) {
app.use(requireSSL);
}
app.use(blockSpamReferers);
app.use(checkCacheReset);
if (config.requireSSL) app.use(requireSSL)

app.use(blockSpamReferers)
app.use(checkCacheReset)
// https://github.com/expressjs/compression/blob/master/README.md
app.use(compress());
app.use(Express.static(path.join(root, 'public')));
app.use(compress())
app.use(Express.static(path.join(root, 'public')))

await blog.load();
await blog.load()

if (blog.loaded) {
// blog must be loaded before routes are defined
sortCategories(blog);
route.standard(app);
app.listen(port);
console.info(`Listening on port ${port}`);
sortCategories(blog)
route.standard(app)
app.listen(port)
console.info(`Listening on port ${port}`)
} else {
console.error('Blog data failed to load. Stopping application.');
console.error('Blog data failed to load. Stopping application.')
}
}
}
Expand All @@ -85,15 +86,15 @@ async function createWebService() {
* @see http://mustache.github.com/mustache.5.html
*/
function defineViews(app: Express.Application) {
const viewPath = path.join(root, 'views');
const viewPath = path.join(root, 'views')
const ehb = new ExpressHandlebars({
defaultLayout: Layout.Main!
});
})

// http://expressjs.com/4x/api.html#app-settings
app.set('views', viewPath);
app.set('view engine', ehb.fileExtension);
app.engine(ehb.fileExtension, ehb.renderer);
app.set('views', viewPath)
app.set('view engine', ehb.fileExtension)
app.engine(ehb.fileExtension, ehb.renderer)

addTemplateMethods(ehb);
addTemplateMethods(ehb)
}
66 changes: 33 additions & 33 deletions src/client/browser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,34 @@
* @see http://www.trailimage.com/js/post-menu-data.js
*/
interface PostMenu {
category: { [key: string]: MenuCategory[] };
post: { [key: string]: MenuPost };
category: { [key: string]: MenuCategory[] }
post: { [key: string]: MenuPost }
}

interface MenuCategory {
title: string;
posts: string[];
title: string
posts: string[]
}

/**
* Post data within menu.
*/
interface MenuPost {
slug: string;
title: string;
icon: string;
description: string;
subTitle?: string;
slug: string
title: string
icon: string
description: string
subTitle?: string
/** Post position if part of a series */
part?: number;
part?: number
}

/**
* Which features to enable on a page — determines which libraries to lazy-load
*/
interface PageFeature {
facebook: boolean;
timestamp: number;
facebook: boolean
timestamp: number
}

/**
Expand All @@ -49,54 +49,54 @@ interface PageFeature {
* GeoJSON properties for post photos.
*/
interface MapPhoto {
url?: string;
title?: string;
partKey?: string;
url?: string
title?: string
partKey?: string
/** Distance from clicked cluster */
distance?: number;
distance?: number
}

/**
* Object generated in `mapbox.hbs` to display post details on the map.
*/
interface MapPost {
key: string;
photoID: number;
key: string
photoID: number
bounds: {
/**
* Southwest corner as lon, lat. For the U.S. this is the smallest
* longitude and latitude values.
*/
sw: number[];
sw: number[]
/**
* Northeast corner as lon, lat. For the U.S. this is the largest
* longitude and latitude values.
*/
ne: number[];
};
ne: number[]
}
}

interface PointCluster {
point_count?: number;
point_count?: number
}

interface UrlPosition {
[key: string]: number | number[];
[key: string]: number | number[]
/** longitude, latitude */
center?: number[];
lon?: number;
lat?: number;
zoom?: number;
center?: number[]
lon?: number
lat?: number
zoom?: number
}
interface FakeEvent {
reason: string;
reason: string
}

interface CssPosition extends JQuery.PlainObject {
top?: number;
left?: number;
right?: number;
bottom?: number;
top?: number
left?: number
right?: number
bottom?: number
}

/**
Expand All @@ -106,4 +106,4 @@ type JQueryResponse = (
responseText: string,
textStatus: string,
XMLHttpRequest: XMLHttpRequest
) => any;
) => any
Loading

0 comments on commit d3c16ff

Please sign in to comment.