本文整理汇总了TypeScript中@trailimage/models.blog类的典型用法代码示例。如果您正苦于以下问题:TypeScript blog类的具体用法?TypeScript blog怎么用?TypeScript blog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了blog类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: withTag
/**
* Photos with tag rendered in response to click on label in photo tags page.
*/
function withTag(req: Request, res: Response) {
const slug = tagParam(req);
blog
.getPhotosWithTags(slug)
.then(photos => {
if (photos === null || photos.length == 0) {
view.notFound(req, res);
} else {
const tag = blog.tags.get(slug);
const title = `${sayNumber(
photos.length
)} “${tag}” Image${photos.length != 1 ? 's' : ''}`;
res.render(Page.PhotoSearch, {
photos,
config,
title,
layout: Layout.None
});
}
})
.catch(err => {
view.notFound(req, res);
log.error(err, { photoTag: slug });
});
}
示例2: withID
/**
* Render post with matching provider (e.g. Flickr) ID. Redirect to normal URL.
*/
function withID(req: Request, res: Response) {
const post = blog.postWithID(req.params[RouteParam.PostID]);
if (is.value(post)) {
res.redirect(HttpStatus.PermanentRedirect, '/' + post.key);
} else {
view.notFound(req, res);
}
}
示例3: trackJSON
/**
* Compressed GeoJSON of post photos and possible track.
*/
async function trackJSON(req: Request, res: Response) {
const slug = req.params[RouteParam.PostKey];
const post = blog.postWithKey(slug);
if (is.value(post)) {
view.sendJSON(res, `${slug}/${mapPath}`, post.geoJSON.bind(post));
} else {
view.notFound(req, res);
}
}
示例4: series
/**
* Render map for posts in a series.
*/
function series(req: Request, res: Response) {
render(
blog.postWithKey(
req.params[RouteParam.SeriesKey],
req.params[RouteParam.PartKey]
),
req,
res
);
}
示例5: siteMap
/**
* XML Sitemap.
*/
function siteMap(_req: Request, res: Response) {
view.send(
res,
Page.Sitemap,
{
posts: blog.posts,
layout: Layout.None,
categories: blog.categoryKeys(),
tags: blog.tags
},
MimeType.XML
);
}
示例6: loadMockData
export function loadMockData() {
postProvider.configure(config.providers.post);
mapProvider.configure(config.providers.map);
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;
return blog.load();
}
示例7: exif
/**
* Render HTML table of EXIF values for given photo.
*/
function exif(req: Request, res: Response) {
const photoID = req.params[RouteParam.PhotoID];
blog
.getEXIF(photoID)
.then(exif => {
res.render(Page.EXIF, {
EXIF: exif,
layout: Layout.None
});
})
.catch(err => {
log.error(err, { photoID });
view.notFound(req, res);
});
}
示例8: render
view.send(res, key, render => {
// use renderer to build view that wasn't cached
const category = blog.categoryWithKey(key);
if (!is.value(category)) {
return view.notFound(req, res);
}
render(
Page.CategoryList,
standardContext(category, category.subcategories.size, {
jsonLD: category.jsonLD(),
subtitle: 'Subcategories',
subcategories: Array.from(category.subcategories)
})
);
});
示例9: render
view.send(res, key, render => {
const p = blog.postWithKey(key);
if (!is.value(p)) {
view.notFound(req, res);
return;
}
p.ensureLoaded()
.then(() => {
render(viewName, {
post: p,
title: p.title,
jsonLD: p.jsonLD(),
layout: Layout.None,
description: p.longDescription,
slug: key
});
})
.catch(err => view.internalError(res, err));
});
示例10: withPhoto
/**
* Render post that contains photo with given ID.
*/
function withPhoto(req: Request, res: Response) {
const photoID = req.params[RouteParam.PhotoID];
blog
.postWithPhoto(photoID)
.then(post => {
if (is.value(post)) {
res.redirect(
HttpStatus.PermanentRedirect,
`/${post.key}#${photoID}`
);
} else {
view.notFound(req, res);
}
})
.catch(err => {
log.error(err, { photoID });
view.notFound(req, res);
});
}