-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement build of showcase page custom node
- Loading branch information
Showing
4 changed files
with
86 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
var util = require('util'), | ||
utility = require('../../util'), | ||
nodes = require('./index'), | ||
|
||
/** | ||
* Subclass of dynamic nodes which describe showcase pagr | ||
* @param {VersionNode} parent node object | ||
* @param {Object} version - library version object | ||
* @param {Object} showcase object | ||
* @constructor | ||
*/ | ||
ShowcaseNode = function (parent, version, showcase) { | ||
this.setTitle(showcase) | ||
.setSource(showcase) | ||
.processRoute(parent, { | ||
conditions: { | ||
lib: version.repo, | ||
version: version.ref, | ||
id: showcase.title | ||
} | ||
}) | ||
.init(parent) | ||
.setView() | ||
.createBreadcrumbs(); | ||
}; | ||
|
||
ShowcaseNode.prototype = Object.create(nodes.dynamic.DynamicNode.prototype); | ||
|
||
/** | ||
* Sets title for node | ||
* @param {Object} showcase object | ||
* @returns {ShowcaseNode} | ||
*/ | ||
ShowcaseNode.prototype.setTitle = function (showcase) { | ||
this.title = utility.getLanguages().reduce(function (prev, lang) { | ||
prev[lang] = showcase.title; | ||
return prev; | ||
}, {}); | ||
return this; | ||
}; | ||
|
||
/** | ||
* Sets source for node | ||
* @param {Object} showcase object | ||
* @returns {ShowcaseNode} | ||
*/ | ||
ShowcaseNode.prototype.setSource = function (showcase) { | ||
this.content = showcase.content; | ||
return this; | ||
}; | ||
|
||
/** | ||
* Sets class for node | ||
* @returns {ShowcaseNode} | ||
*/ | ||
ShowcaseNode.prototype.setClass = function () { | ||
this.class = 'showcase'; | ||
return this; | ||
}; | ||
|
||
/** | ||
* Sets view for node | ||
* @returns {ShowcaseNode} | ||
*/ | ||
ShowcaseNode.prototype.setView = function () { | ||
this.view = this.VIEW.SHOWCASE; | ||
return this; | ||
}; | ||
|
||
ShowcaseNode.prototype.saveToDb = function () { | ||
this.parent = this.parent.id; | ||
return { type: 'put', key: this.generateKey(), value: this }; | ||
}; | ||
|
||
exports.ShowcaseNode = ShowcaseNode; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters