Skip to content

Commit

Permalink
styla modifications for validations
Browse files Browse the repository at this point in the history
  • Loading branch information
amoisescu committed Jan 22, 2020
1 parent cfcb440 commit 4a83ffa
Show file tree
Hide file tree
Showing 43 changed files with 1,367 additions and 689 deletions.
36 changes: 18 additions & 18 deletions cartridges/int_styla/cartridge/controllers/StylaMagazine.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
* Controller exposes methods for injecting Styla JavaScript and SEO content.
*
* @module controllers/StylaMagazine
*
*
*
*
* Do not reference the storefront controller cartridge here (e.g to re-use 'app' or 'guard'):
* This montroller module is also called via remote include even when the storefront uses pipelines.
* IOW: the storefront controller cartridge may or may not exist when this controller executes.
*
*
*/

var Logger = require('dw/system/Logger').getLogger('styla', 'StylaMagazine');
var ISML = require('dw/template/ISML');

var StylaMain = require('/int_styla/cartridge/scripts/StylaMain');
var StylaMain = require('/int_styla/cartridge/scripts/stylaMain');


const CONFIG_CO_TYPE = 'StylaMagazineConfiguration'; // custom object type for storing magazine configurations
Expand All @@ -31,7 +31,7 @@ function renderContent(template) {
}
else {
ISML.renderTemplate('styla/empty');
}
}
}


Expand All @@ -55,41 +55,41 @@ function bodyContent() {
* Render the Styla cartridge version.
*/
function cartridgeVersion() {

var versionInfo = {
version: require('~/package.json').cartridgeVersion
},
str;

str = JSON.stringify(versionInfo, null, '\t');

response.setContentType('application/json');
response.setExpires(5 * 60 * 1000); // 5 minutes
response.writer.print(str);
response.writer.print(str);
}


/**
* If the current URL is part of a magazine, then jump to the corresponding
* If the current URL is part of a magazine, then jump to the corresponding
* controller method so that the original URL is preserved in the browser.
*
*
* This is called from RedirectURL.start() if no matching redirect rule was found.
*
*
* E.g. assume we have an alias 'magazine' assigned to a pipeline which renders a Styla magazine.
* When interacting with the magazine the Styla JavaScript will modify the URL in the
* When interacting with the magazine the Styla JavaScript will modify the URL in the
* customer's browser to e.g. 'magazine/stories/5'.
* Because RedirectUrl.start() doesn't find a matching rule for 'magazine/stories/5'
* it calls this function.
*
* Because RedirectUrl.start() doesn't find a matching rule for 'magazine/stories/5'
* it calls this function.
*
* @param path Original URL before redirect.
* @returns True, if a matching magazine configuration was found and the configured
* @returns True, if a matching magazine configuration was found and the configured
* controller method was called successfully.
*/
function alias(path) {
var result = false,
magazineConfig = StylaMain.GetConfigForAlias(path),
parts;

if (magazineConfig) {
// read controller method method from configuration
parts = magazineConfig.pipeline.split('-');
Expand Down Expand Up @@ -127,7 +127,7 @@ function alias(path) {
Logger.debug('no matching config found for path: ' + path);
}


return result;
}

Expand Down
73 changes: 0 additions & 73 deletions cartridges/int_styla/cartridge/pipelines/StylaMagazine.xml

This file was deleted.

4 changes: 2 additions & 2 deletions cartridges/int_styla/cartridge/scripts/StylaMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*/

var CustomObjectMgr = require('dw/object/CustomObjectMgr');
var Logger = require('dw/system/Logger').getLogger('styla', 'StylaMain');
var StylaServiceInit = require('./init/StylaServiceInit');
var Logger = require('dw/system/Logger').getLogger('styla', 'stylaMain');
var StylaServiceInit = require('./init/stylaServiceInit');
var Site = require('dw/system/Site');

var CONFIG_CO_TYPE = 'StylaMagazineConfiguration'; // custom object type for storing magazine configurations
Expand Down

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@
Example of a category rendering template which can be used to render a Styla magazine.
</iscomment>

<isset name="SkipPageTitleAndMeta" value="${true}" scope="page"/>
<isset name="SkipPageTitleAndMeta" value="${true}" scope="page"/>

<iscontent type="text/html" charset="UTF-8" compact="true"/>
<isdecorate template="rendering/pt_catlanding">

<iscache type="relative" minute="30" varyby="price_promotion"/>

<isinclude template="util/modules"/>

<iscomment>
Configured as rendering template for the general category landing page.
Displays two category specific slots containing static html with promotional
banner in the first slot and either up to four featured products or promotional
content in the second slot.
</iscomment>
<div id="primary" class="primary-content">
<isslot id="cat-landing-slotbanner" context="category" description="Banner at the top of Category Landing Pages" context-object="${pdict.ProductSearchResult.category}"/>

<div id="primary" class="primary-content">
<isslot id="cat-landing-slotbanner" context="category" description="Banner at the top of Category Landing Pages" context-object="${pdict.ProductSearchResult.category}"/>
</div>

<!-- include Styla body content -->
<!-- include Styla body content -->
<isinclude template="styla/bodyinclude"/>

<div class="secondary-content">
<isslot id="cat-landing-slotbottom" context="category" description="First slot below the Category Banner" context-object="${pdict.ProductSearchResult.category}"/>

<isslot id="cat-landing-slotbottom2" context="category" description="Second slot below the Category Banner" context-object="${pdict.ProductSearchResult.category}"/>
</div>

</isdecorate>

Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
<isif condition="${dw.system.Site.current.getCustomPreferenceValue('stylaEnabled') == true}">

<isscript>
var StylaMain = require('/int_styla/cartridge/scripts/StylaMain');
var StylaMain = require('/int_styla/cartridge/scripts/stylaMain');
StylaMain.SetHttpStatus();
</isscript>

<isinclude url="${URLUtils.url('StylaMagazine-BodyContent', 'magazinepath', request.httpHeaders['x-is-path_info'], 'querystring', request.httpQueryString)}"/>

</isif>
2 changes: 1 addition & 1 deletion cartridges/int_styla/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"init": [
"./cartridge/scripts/init/StylaServiceInit.js"
"./cartridge/scripts/init/stylaServiceInit.js"
],

"cartridgeVersion": "19.0.1"
Expand Down
30 changes: 30 additions & 0 deletions cartridges/int_styla_refArch/cartridge/controllers/RedirectURL.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use strict';

var server = require('server');

server.extend(module.superModule);

server.append('Start', function (req, res, next) {
var URLRedirectMgr = require('dw/web/URLRedirectMgr');

var redirect = URLRedirectMgr.redirect;
var location = redirect ? redirect.location : null;

if (!location) {
var StylaMain,
path = URLRedirectMgr.redirectOrigin,
handledByStyla = false;
if (dw.system.Site.current.getCustomPreferenceValue('stylaEnabled') == true) {
StylaMain = require('/int_styla_refArch/cartridge/scripts/stylaMain');
handledByStyla = StylaMain.Alias(path);
}

if (handledByStyla) {
return handledByStyla;
}
}

next();
});

module.exports = server.exports();
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ var server = require('server');
*
*/

var StylaMain = require('/int_styla_refArch/cartridge/scripts/StylaMain');
var StylaMain = require('/int_styla_refArch/cartridge/scripts/stylaMain');
var cache = require('*/cartridge/scripts/middleware/cache');

function renderContent(template, res) {
var pdict = StylaMain.GetRenderContent();
Expand All @@ -24,12 +25,12 @@ function renderContent(template, res) {
}
}

server.get('HeaderContent', function (req, res, next) {
server.get('HeaderContent', cache.applyStylaCustomCache, function (req, res, next) {
renderContent('styla/headercontent', res);
return next();
});

server.get('BodyContent', function (req, res, next) {
server.get('BodyContent', cache.applyStylaCustomCache, function (req, res, next) {
renderContent('styla/bodycontent', res);
return next();
});
Expand Down
Loading

0 comments on commit 4a83ffa

Please sign in to comment.