Permalink
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
1 parent 83b7f9e commit dd376e1e0b070071700e007467b18468b0fbbbd9 @jonschlinkert jonschlinkert committed May 5, 2016
Showing with 3,421 additions and 912 deletions.
  1. +1 −1 LICENSE
  2. +2 −2 bin/cli.js
  3. +128 −78 docs/assemblefile.js
  4. +21 −1 docs/assets/css/assemble.css
  5. +95 −4 docs/assets/js/docs.js
  6. +2,054 −0 docs/assets/js/lunr.js
  7. +7 −0 docs/assets/js/lunr.min.js
  8. +1 −0 docs/content/api.md
  9. +1 −0 docs/content/api/app.md
  10. +3 −1 docs/content/api/app.use.md
  11. +8 −7 docs/content/api/app.view.md
  12. +1 −3 docs/content/api/assemblefile.md
  13. +2 −8 docs/content/api/class.View.md
  14. +8 −8 docs/content/api/collection.view.md
  15. +8 −10 docs/content/api/events.md
  16. +6 −6 docs/content/api/file-system.md
  17. +8 −0 docs/content/api/index.md
  18. +4 −6 docs/content/api/layouts.md
  19. +10 −9 docs/content/api/middleware.md
  20. +1 −2 docs/content/api/options/mergeTypes.md
  21. +1 −1 docs/content/api/options/renameKey.md
  22. +2 −2 docs/content/api/pagination.md
  23. +6 −0 docs/content/api/readme.md
  24. +5 −5 docs/content/api/tasks.md
  25. +4 −6 docs/content/api/view-collections.md
  26. +9 −11 docs/content/api/view-types.md
  27. +2 −2 docs/content/build-cycle.md
  28. +2 −0 docs/content/docs.md
  29. +9 −0 docs/content/getting-started.md
  30. +10 −0 docs/content/index.md
  31. +6 −0 docs/content/readme.md
  32. +1 −1 docs/content/recipes/assemble-instance.md
  33. +1 −1 docs/content/recipes/assemblefile.md
  34. +3 −3 docs/content/recipes/browser-sync.md
  35. +3 −3 docs/content/recipes/copy-files.md
  36. +3 −5 docs/content/recipes/create-a-collection.md
  37. +5 −8 docs/content/recipes/custom-async-helpers.md
  38. +5 −9 docs/content/recipes/custom-helpers.md
  39. +4 −2 docs/content/recipes/declarative-config.md
  40. +3 −3 docs/content/recipes/default-layout.md
  41. +1 −2 docs/content/recipes/delete-files.md
  42. +2 −1 docs/content/recipes/{javascript-generators.md → es2015-generators.md}
  43. +1 −2 docs/content/recipes/generate-html-and-precompile-less.md
  44. +1 −2 docs/content/recipes/generate-html-and-precompile-sass.md
  45. +17 −0 docs/content/recipes/index.md
  46. +1 −2 docs/content/recipes/inspecting-the-context.md
  47. +1 −2 docs/content/recipes/install-assemble.md
  48. +5 −19 docs/content/recipes/listening-for-errors.md
  49. +19 −5 docs/content/recipes/listening-for-views.md
  50. +4 −7 docs/content/recipes/load-templates-from-the-file-system.md
  51. +0 −1 docs/content/recipes/markdown-to-html.md
  52. +3 −4 docs/content/recipes/merging-context.md
  53. +2 −3 docs/content/recipes/readme.md
  54. +1 −2 docs/content/recipes/register-helpers.md
  55. +3 −3 docs/content/recipes/rename-keys.md
  56. +3 −4 docs/content/recipes/render-markdown-in-layouts.md
  57. +1 −3 docs/content/recipes/rendering-templates.md
  58. +1 −2 docs/content/recipes/to-stream.md
  59. +1 −8 docs/content/subjects/assemble.md
  60. +1 −2 docs/content/subjects/assemblefile.md
  61. +1 −2 docs/content/subjects/building-blocks.md
  62. +2 −3 docs/content/subjects/context.md
  63. +1 −2 docs/content/subjects/gulp-faq.md
  64. +1 −1 docs/content/subjects/helper-context.md
  65. +10 −0 docs/content/subjects/index.md
  66. +1 −0 docs/content/subjects/overview.md
  67. +2 −7 docs/content/subjects/plugins.md
  68. +2 −2 docs/content/subjects/readme.md
  69. +91 −147 docs/data/redirects.json
  70. +92 −235 docs/data/versions.json
  71. +15 −6 docs/package.json
  72. +1 −0 docs/static/CNAME
  73. +22 −0 docs/static/LICENSE-MIT
  74. +7 −0 docs/static/README.md
  75. BIN docs/static/favicon.ico
  76. +1 −0 docs/support/async-helpers/index.js
  77. +25 −0 docs/support/async-helpers/markdown.js
  78. +96 −0 docs/support/async-helpers/related.js
  79. +1 −1 docs/support/helpers/current.js
  80. +1 −1 docs/support/helpers/default.js
  81. +16 −0 docs/support/helpers/ends-with.js
  82. +5 −0 docs/support/helpers/isnt.js
  83. +19 −0 docs/support/helpers/issue-link.js
  84. +0 −31 docs/support/helpers/list.js
  85. +0 −6 docs/support/helpers/log.js
  86. +0 −3 docs/support/helpers/markdown.js
  87. +6 −0 docs/support/helpers/pascal.js
  88. +1 −1 docs/support/helpers/uppercase.js
  89. +20 −0 docs/support/helpers/url.js
  90. +0 −104 docs/support/plugins/assemble-collections.js
  91. +0 −25 docs/support/plugins/get-dest.js
  92. +64 −0 docs/support/plugins/search.js
  93. +2 −2 docs/support/plugins/versions.js
  94. +1 −1 docs/templates/layouts/base.hbs
  95. +1 −6 docs/templates/layouts/body.hbs
  96. +1 −1 docs/templates/layouts/default.hbs
  97. +11 −0 docs/templates/layouts/markdown-raw.hbs
  98. +8 −0 docs/templates/layouts/markdown.hbs
  99. +284 −2 docs/templates/pages/index.hbs
  100. +2 −2 docs/templates/partials/btn-tweet.hbs
  101. +5 −0 docs/templates/partials/category-list.hbs
  102. +1 −1 docs/templates/partials/edit-template-link.hbs
  103. +1 −0 docs/templates/partials/edit-template.hbs
  104. +2 −0 docs/templates/partials/javascripts.hbs
  105. +1 −0 docs/templates/partials/layout/category-dropdown-link.hbs
  106. +16 −0 docs/templates/partials/layout/category-dropdown.hbs
  107. +2 −1 docs/templates/partials/layout/footer.hbs
  108. +1 −0 docs/templates/partials/layout/head.hbs
  109. +10 −3 docs/templates/partials/layout/masthead.hbs
  110. +1 −0 docs/templates/partials/layout/sidenav-section-header-link.hbs
  111. +10 −9 docs/templates/partials/layout/sidenav-section.hbs
  112. +3 −15 docs/templates/partials/navbar.hbs
  113. +0 −4 docs/templates/partials/related.hbs
  114. +9 −1 docs/templates/partials/snippets/analytics.hbs
  115. +22 −0 docs/templates/partials/snippets/disqus.hbs
  116. +0 −2 index.js
  117. +3 −3 package.json
View
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2014-2016, Jon Schlinkert, Brian Woodard.
+Copyright (c) 2014-2016, Jon Schlinkert, Brian Woodward.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
View
@@ -74,7 +74,7 @@ function run(cb) {
* Listen for errors
*/
- app.on('error', console.error.bind(console));
+ app.on('error', handleError);
/**
* Support `--emit` for debugging
@@ -128,7 +128,7 @@ run(function(err, app) {
app.cli.process(app.get('cache.argv'), function(err) {
if (err) handleError(err);
- var tasks = app.option('tasks') || ['default'];
+ var tasks = app.option('tasks') || (argv._.length ? argv._ : ['default']);
/**
* Run tasks
View
@@ -4,22 +4,24 @@ var path = require('path');
var del = require('delete');
var Time = require('time-diff');
var watch = require('base-watch');
-var prettify = require('gulp-prettify');
var drafts = require('gulp-drafts');
var extname = require('gulp-extname');
var ignore = require('gulp-ignore');
var debug = require('debug')('assemble:docs');
var browserSync = require('browser-sync').create();
+var collections = require('assemble-collections');
var permalinks = require('assemble-permalinks');
+var getDest = require('view-get-dest');
var merge = require('mixin-deep');
var through = require('through2');
+var ghPages = require('gulp-gh-pages');
+var ghClone = require('gh-clone');
+var cmd = require('spawn-commands');
-var collections = require('./support/plugins/assemble-collections');
var viewEvents = require('./support/plugins/view-events');
var redirects = require('./support/plugins/redirects');
var manifest = require('./support/plugins/manifest');
var versions = require('./support/plugins/versions');
-var getDest = require('./support/plugins/get-dest');
var utils = require('./support/utils');
var pkg = require('../package');
var assemble = require('..');
@@ -29,17 +31,17 @@ var assemble = require('..');
*/
var app = assemble();
-
app.time = new Time();
-viewEvents('permalink')(app);
+app.use(viewEvents('permalink'));
app.use(collections());
-app.use(permalinks());
app.use(getDest());
app.use(watch());
-app.on('error', function(err) {
- console.log(err.stack);
-});
+/**
+ * Setup search plugin
+ */
+
+var search = require('./support/plugins/search')(app);
/**
* Common variables
@@ -53,19 +55,8 @@ var build = {
* Middleware
*/
-var permalinkCache = {};
-app.onLoad(/./, function(file, next) {
- debug('onLoad for %s', file.path);
- if (permalinkCache[file.path] === true) {
- debug('creating permalink context for %s', file.path);
- file.permalink(file.options.permalink);
- }
- next();
-});
-
app.onPermalink(/./, function(file, next) {
debug('onPermalink for %s', file.path);
- permalinkCache[file.path] = true;
file.data = merge({category: 'docs'}, app.cache.data, file.data);
next();
});
@@ -75,49 +66,46 @@ app.onPermalink(/./, function(file, next) {
* key of each template, so it's easier to lookup later
*/
-app.option('renameKey', function(fp) {
+app.option('renameKey', function(fp, view) {
+ // key has already been renamed, just strip extension
if (fp.indexOf(__dirname) === -1) {
+ if (/\.md$/.test(fp)) {
+ return fp.substr(0, fp.length - 3);
+ }
return fp;
}
- return path.basename(fp, path.extname(fp));
+
+ // remove __dirname/content
+ var base = fp.replace(__dirname, '');
+ fp = base.split(path.sep)
+ .filter(Boolean)
+ .slice(1)
+ .join(path.sep);
+
+ // drop extension
+ var ext = path.extname(fp);
+ return fp.substr(0, fp.length - ext.length);
});
/**
* Load some "global" data
*/
app.data({
+ docs: {
+ content: 'https://github.com/assemble/assemble/tree/master/docs/content'
+ },
+ pkg: pkg,
site: {
title: 'Assemble Docs',
+ description: 'The static site generator for Node.js, Grunt.js and Yeoman.',
+ lead: 'It has never been easier to leverage the full force of powerful frameworks like Bootstrap and Zurb Foundation. Nothing can stop you now.',
version: pkg.version,
base: ':destBase/en/v:site.version',
- categories: {
- docs: {
- title: 'Docs',
- description: 'Assemble documentation',
- category: 'docs',
- filter: navFilter('docs')
- },
- api: {
- title: 'API',
- description: 'Assemble API Documentation',
- category: 'api',
- filter: navFilter('api')
- },
- recipes: {
- title: 'Recipes',
- description: 'Assemble recipes',
- category: 'recipes',
- filter: navFilter('recipes')
- },
- subjects: {
- title: 'Subjects',
- description: 'Advanced subjects on using assemble',
- category: 'subjects',
- filter: navFilter('subjects')
- }
- }
+ baseUrl: 'http://assemble.io'
},
+ // slug is defined in the url helper. this should be refactored.
+ url: ':site.baseUrl/en/v:site.version/docs/:slug()',
destBase: '_gh_pages',
assets: ':site.base/assets',
links: [{
@@ -128,7 +116,7 @@ app.data({
});
/**
- * Create a custom view collection
+ * Permalink options to use in the permalinks plugin below
*/
var permalinkOpts = {
@@ -138,30 +126,40 @@ var permalinkOpts = {
}
var rel = this.relative;
var ext = path.extname(rel);
- return path.join(rel.substr(0, rel.length - ext.length), 'index.html');
+ return path.join(rel.substr(0, rel.length - ext.length) + '.html');
}
};
-function navFilter(category) {
- return function(item) {
- if (item.data.category !== category) {
- return false;
- }
- return (typeof item.data.draft === 'undefined' || item.data.draft === false);
- };
+/**
+ * Custom preRender middleware to use on the `docs` collection below.
+ */
+
+function preRender(file, next) {
+ var category = file.data.category;
+ if (!category) return next();
+ file.data = merge({
+ layout: category === 'recipes' ? 'recipe' : file.data.layout
+ }, file.data);
+ next();
}
+/**
+ * Create a custom view collection for `docs`
+ */
+
app.create('docs', {layout: 'body'})
- .preRender(/\.md/, function(file, next) {
- var category = file.data.category;
- if (!category) return next();
- file.data = merge({
- section: app.data('site.categories.' + category),
- layout: category === 'recipes' ? 'recipe' : file.data.layout
- }, file.data);
- next();
- })
- .use(permalinks(':site.base/:slug()', permalinkOpts));
+ .preRender(/\.md/, preRender)
+ .use(permalinks(':site.base/docs/:slug()', permalinkOpts));
+
+/**
+ * Configure permalinks for main site pages.
+ */
+
+app.pages.use(permalinks(':site.base/:name.html'));
+
+/**
+ * Create a custom view collection for html files that do redirects.
+ */
app.create('redirects', {
renameKey: function(key, view) {
@@ -170,12 +168,24 @@ app.create('redirects', {
});
/**
+ * Load default handlebars helpers
+ */
+
+app.helpers(require('assemble-handlebars-helpers'));
+
+/**
* Load helpers
*/
app.helpers('support/helpers/*.js');
/**
+ * Load async-helpers
+ */
+
+app.asyncHelpers('support/async-helpers/*.js');
+
+/**
* Clean out the current version's built files
*/
@@ -184,14 +194,42 @@ app.task('clean', function(cb) {
});
/**
+ * Clone current assemble/assemble.io#gh-pages ensure getting previous versions.
+ */
+
+app.task('clone', function(cb) {
+ var options = {
+ repo: 'assemble/assemble.io',
+ branch: 'gh-pages',
+ dest: build.dest()
+ };
+
+ ghClone(options, function(err, config) {
+ if (err) return cb(err);
+ cmd(config, cb);
+ });
+});
+
+/**
+ * Deploy built docs to a branch for the current version.
+ */
+
+app.task('deploy', function() {
+ return app.src(build.dest('**/*'))
+ .pipe(ghPages({
+ remoteUrl: 'https://github.com/assemble/assemble.io.git',
+ branch: 'v' + pkg.version
+ }));
+});
+
+/**
* Build manifest for a specific version.
* This is in case an old version didn't have a manifest.
* Run with `assemble manifest --version 0.6.0`
*/
app.task('manifest', function(cb) {
- // get the version from argv.orig (because of the dots in versions)
- var version = app.argv.orig.version;
+ var version = app.option('version');
if (typeof version === 'undefined' || typeof version === 'boolean') {
cb(new Error('--version needs to be specified when running `assemble manifest`'));
return;
@@ -238,8 +276,9 @@ app.task('redirects', function() {
*/
app.task('load', function* () {
- app.partials('templates/partials/**/*.hbs', {cwd: __dirname});
- app.layouts('templates/layouts/**/*.hbs', {cwd: __dirname});
+ app.partials(['templates/partials/**/*.hbs'], {cwd: __dirname});
+ app.layouts(['templates/layouts/**/*.hbs'], {cwd: __dirname});
+ app.pages(['templates/pages/**/*.hbs'], {cwd: __dirname});
app.docs(['content/**/*.md'], {cwd: __dirname});
});
@@ -250,7 +289,7 @@ app.task('load', function* () {
app.task('serve', function() {
browserSync.init({
port: 8080,
- startPath: 'docs.html',
+ startPath: 'index.html',
server: {
baseDir: build.dest()
}
@@ -282,7 +321,6 @@ app.task('generate-redirects', function() {
.on('error', console.error)
.pipe(app.renderFile('hbs'))
.on('error', console.error)
- // .pipe(prettify())
.pipe(extname())
.pipe(app.dest(build.dest()));
});
@@ -306,13 +344,14 @@ function changedFilter(key, view) {
app.task('build', ['load'], function() {
return app.toStream('docs', changedFilter).on('error', console.log)
+ .pipe(app.toStream('pages', changedFilter)).on('error', console.log)
.pipe(drafts())
+ .pipe(search.collect())
.pipe(app.renderFile()).on('error', console.log)
- // .pipe(prettify())
.pipe(extname())
.pipe(through.obj(function(file, enc, next) {
- file.path = file.data.permalink || file.path;
- file.base = '_gh_pages';
+ file.path = file.dest;
+ file.base = app.data('destBase');
next(null, file);
}))
.pipe(manifest(app, {
@@ -323,9 +362,10 @@ app.task('build', ['load'], function() {
return fp.substr(idx);
}
}))
- .pipe(app.dest(function(file) {
- return build.dest();
+ .pipe(search.generate({
+ base: 'en/v' + pkg.version
}))
+ .pipe(app.dest(build.dest()))
.pipe(browserSync.stream());
});
@@ -339,6 +379,15 @@ app.task('assets', function() {
});
/**
+ * Copy static "root" files
+ */
+
+app.task('static', function(cb) {
+ return app.copy(['static/**/*'], build.dest())
+ .pipe(browserSync.stream());
+});
+
+/**
* Watch files for changes
*/
@@ -374,6 +423,7 @@ app.task('default', [
'clean',
'build',
'assets',
+ 'static',
'redirects',
'generate-redirects'
]);
Oops, something went wrong.

0 comments on commit dd376e1

Please sign in to comment.