menu

SiteGenesis / Server-side JS / Source: app_storefront_controllers/cartridge/controllers/SiteMap.js

'use strict';

/**
 * Controller that handles site map requests.
 *
 * @module controllers/SiteMap
 */

/* Script Modules */
var app = require('~/cartridge/scripts/app');
var guard = require('~/cartridge/scripts/guard');

/**
 * Serves requests for search provider (Google, Yahoo) XML site maps. Reads a
 * given site map and copies it into the request output stream. If this is successful,
 * renders an http_200 template. If it fails, renders the http_404 template.
 * SiteMap Rule:
 * # process sitemaps
 * RewriteRule ^/(sitemap([^/]*))$ /on/demandware.store/%{HTTP_HOST}/-/SiteMap-Google?name=$1 [PT,L]
 */
function google() {
    // TODO - rework
    var SendGoogleSiteMapResult = new dw.system.Pipelet('SendGoogleSiteMap').execute({
        FileName: request.httpParameterMap.name.stringValue
    });
    if (SendGoogleSiteMapResult.result === PIPELET_ERROR) {
        app.getView().render('sitemap/http_404');
    } else {
        app.getView().render('sitemap/http_200');
    }
}

/**
 * Renders the sitemap template (sitemap/sitemap template).
 */
function start() {

    app.getView().render('sitemap/sitemap');

}


/*
 * Module exports
 */

/*
 * Web exposed methods
 */
/** @see module:controllers/SiteMap~google */
exports.Google = guard.ensure(['get'], google);
/** Renders the sitemap template
 *  Serves requests for search provider (Google, Yahoo) XML site maps.
 *  @see module:controllers/SiteMap~start */
exports.Start = guard.ensure(['get'], start);

X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used. By continuing to use this site you are giving us your consent to do this. Privacy Policy.