Created
May 11, 2012 20:40
-
-
Save reklis/2662280 to your computer and use it in GitHub Desktop.
mainpage support
This file contains hidden or 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
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 }); ?> |
This file contains hidden or 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
<?js | |
var self = this; | |
?> | |
<div class="mainpage"> | |
<h1>Welcome page</h1> | |
</div> |
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?
It'd be nice to have a main page by default?
…-SLF
On May 12, 2012, at 2:49 PM, Michael ***@***.*** wrote:
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?
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/2662280
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?)
Oh, I think I see what you mean. This just makes it easier to fork the default publish and not change any logic, just the template files. That publish.js is scary looking the first time you get in there.
…-SLF
On May 13, 2012, at 5:43 PM, Michael ***@***.*** wrote:
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?)
---
Reply to this email directly or view it on GitHub:
https://gist.github.com/2662280
That's been committed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Changes to publish are also include support for other folders instead of being hard coded to default