當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。