Changes to default template to support index page [submitted by reklis (Steven Fusco)].

This commit is contained in:
Michael Mathews 2012-05-14 17:18:48 +01:00
parent 7d97a17421
commit 2cdb27fd6d
3 changed files with 22 additions and 3 deletions

View File

@ -12,8 +12,10 @@
@param {Tutorial} tutorials
*/
publish = function(data, opts, tutorials) {
var defaultTemplatePath = 'templates/default';
var templatePath = (opts.template) ? opts.template : defaultTemplate;
var out = '',
view = new template.Template(__dirname + '/templates/default/tmpl');
view = new template.Template(__dirname + '/' + templatePath + '/tmpl');
// set up templating
view.layout = 'layout.tmpl';
@ -174,7 +176,7 @@
fs.mkPath(outdir);
// copy static files to outdir
var fromDir = __dirname + '/templates/default/static',
var fromDir = __dirname + '/' + templatePath + '/static',
staticFiles = fs.ls(fromDir, 3);
staticFiles.forEach(function(fileName) {
@ -358,7 +360,10 @@
}
if (globals.length) generate('Global', [{kind: 'globalobj'}], 'global.html');
generate('Index', [], 'index.html');
generate('Index',
[{kind: 'mainpage', longname: (opts.mainpagetitle) ? opts.mainpagetitle : "Main Page"}]
, 'index.html');
function generate(title, docs, filename) {

View File

@ -3,6 +3,12 @@
docs.forEach(function(doc, i) {
?>
<?js if (doc.kind === 'mainpage') { ?>
<?js= self.partial('mainpage.tmpl', doc) ?>
<?js } else { ?>
<section>
<header>
@ -134,4 +140,6 @@
</article>
</section>
<?js } ?>
<?js }); ?>

View File

@ -0,0 +1,6 @@
<?js
var self = this;
?>
<div class="mainpage">
<h1>Welcome page</h1>
</div>