Skip to content

Instantly share code, notes, and snippets.

@reklis
Created May 11, 2012 20:40
Show Gist options
  • Select an option

  • Save reklis/2662280 to your computer and use it in GitHub Desktop.

Select an option

Save reklis/2662280 to your computer and use it in GitHub Desktop.
mainpage support
diff --git a/templates/default/publish.js b/templates/default/publish.js
index 2adf9e2..6b3e2f4 100644
--- a/templates/default/publish.js
+++ b/templates/default/publish.js
@@ -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) {
diff --git a/templates/default/tmpl/container.tmpl b/templates/default/tmpl/container.tmpl
index 9ff6cf3..1ce4185 100644
--- a/templates/default/tmpl/container.tmpl
+++ b/templates/default/tmpl/container.tmpl
@@ -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 }); ?>
<?js
var self = this;
?>
<div class="mainpage">
<h1>Welcome page</h1>
</div>
@micmath
Copy link
Copy Markdown

micmath commented May 12, 2012

The design goal was that each template would have its own "publish.js" so, if that is so, then I don't see the benefit of modifying the default publish.js to refer to files in other templates. Can give a compelling use-case for that feature?

@reklis
Copy link
Copy Markdown
Author

reklis commented May 13, 2012 via email

@micmath
Copy link
Copy Markdown

micmath commented May 13, 2012

Sorry, I don't think you addressed why it's necessary to refer to files in other templates in order to have a main page by default. (did you read my comment above?)

@reklis
Copy link
Copy Markdown
Author

reklis commented May 14, 2012 via email

@micmath
Copy link
Copy Markdown

micmath commented May 14, 2012

That's been committed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment