当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript models.blog类代码示例

本文整理汇总了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 });
      });
}
开发者ID:Trail-Image,项目名称:blog,代码行数:30,代码来源:photo.ts

示例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);
   }
}
开发者ID:Trail-Image,项目名称:blog,代码行数:12,代码来源:post.ts

示例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);
   }
}
开发者ID:Trail-Image,项目名称:blog,代码行数:13,代码来源:map.ts

示例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
   );
}
开发者ID:Trail-Image,项目名称:blog,代码行数:13,代码来源:map.ts

示例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
   );
}
开发者ID:Trail-Image,项目名称:blog,代码行数:16,代码来源:static.ts

示例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();
}
开发者ID:Trail-Image,项目名称:blog,代码行数:13,代码来源:.test-data.ts

示例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);
      });
}
开发者ID:Trail-Image,项目名称:blog,代码行数:18,代码来源:photo.ts

示例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)
         })
      );
   });
开发者ID:Trail-Image,项目名称:blog,代码行数:17,代码来源:category.ts

示例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));
 });
开发者ID:Trail-Image,项目名称:blog,代码行数:19,代码来源:post.ts

示例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);
      });
}
开发者ID:Trail-Image,项目名称:blog,代码行数:23,代码来源:post.ts


注:本文中的@trailimage/models.blog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。