Skip to content

Commit

Permalink
Merge pull request #38 from hang-up/v4.1.2
Browse files Browse the repository at this point in the history
v4.1.2
  • Loading branch information
Rob authored May 31, 2018
2 parents 35b16f1 + c522bbc commit e38fb23
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 98 deletions.
77 changes: 31 additions & 46 deletions cli/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,15 @@ module.exports = {
shell.mkdir('-p', 'docs');
shell.cd('..');

/*
3 files to create:
- manifest.json
- buuk-config.js
- .buukrc.json
*/
/**
* 3 files to create:
* - manifest.json
* - buuk-config.js
* - .buukrc.json
*
*/

/*
Manifest.json
*/
// Manifest.json
const manifest = {
articles: {}
};
Expand All @@ -47,47 +46,39 @@ module.exports = {
});
cp(`${__dirname}/manifest.json`, `${shell.pwd().stdout}/${folder}/manifest.json`);

/*
buuk-config.js
*/
//buuk-config.js
const config = {
/*
name and sub are displayed on the default homepage.
short_name is displayed at app startup and on top of the navbar.
description should provide additional details about what the Bük is.
*/
/**
* name and sub are displayed on the default homepage.
* short_name is displayed at app startup and on top of the navbar.
* description should provide additional details about what the Bük is.
*
*/
name: answers.name,
short_name: answers.short_name,
description: answers.description,

/*
Custom homepage. References a markdown file under /docs by its slug.
*/
// Custom homepage. References a markdown file under /docs by its slug.
homepage: null,

/*
TODO: support multilang for hardcoded string AND language switch
*/
// TODO: support multilang for hardcoded string AND language switch
language: null,

/*
Toolbar / sidebar active color.
*/
// Toolbar / sidebar active color.
theme_color: '#1f77b4',

/*
Logo. Must be under /static/img
*/
// Logo. Must be under /static/img
logo: null,

/*
Renderer Options.
- breaks { boolean | true }: Enable GFM line breaks.
- strict { boolean | false }: Conforms to markdown.pl as much as possible. Setting this to true might resolve obscure scenarios.
- ignore_html { boolean | false }: Sanitizes the output, ignores any html inputted.
- smart_typo { boolean | false }: Subtle changes to typographic punctuation (quotes, dashes, ...)
- template { string | 'wiki' }: Defines the output layout.
*/
/**
* Renderer Options.
* - breaks { boolean | true }: Enable GFM line breaks.
* - strict { boolean | false }: Conforms to markdown.pl as much as possible. Setting this to true might resolve obscure scenarios.
* - ignore_html { boolean | false }: Sanitizes the output, ignores any html inputted.
* - smart_typo { boolean | false }: Subtle changes to typographic punctuation (quotes, dashes, ...)
* - template { string | 'wiki' }: Defines the output layout.
*
*/
renderer: {
breaks: true,
strict: false,
Expand All @@ -96,14 +87,10 @@ module.exports = {
template: 'wiki'
},

/*
TODO: Summary of articles
*/
// TODO: Summary of articles
summarize_api_key: null,

/*
Toggles a table of contents for each article page. Automatically generates it from markdown headers.
*/
// Toggles a table of contents for each article page. Automatically generates it from markdown headers.
toc: true
};
fs.writeFileSync(
Expand All @@ -117,9 +104,7 @@ module.exports = {
);
cp(`${__dirname}/buuk-config.js`, `${shell.pwd().stdout}/${folder}/buuk-config.js`);

/*
.buukrc.json
*/
// .buukrc.json
const path = {
base_path: `${shell.pwd().stdout}/${folder}`
};
Expand Down
8 changes: 4 additions & 4 deletions src/core/loaders/article-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ function articleLoader(articleParam) {
// Dynamically load content of .md associated to the slug.
asyncImportArticleContent(res, resolve);
} else {
/*
Called with a slug: the only case this is used is to load a custom homepage,
so we assume the primitive will have "Homepage" as title.
*/
/**
* Called with a slug: the only case this is used is to load a custom homepage,
* so we assume the primitive will have "Homepage" as title.
*/
res.primitive = new ArticlePrimitive('Homepage', articleParam, '').value;

// Dynamically load content of .md associated to the slug.
Expand Down
47 changes: 23 additions & 24 deletions src/core/loaders/manifest-loader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { articles } from 'BASE_PATH/manifest.json';
import { store } from '../store/index';
import ArticlePrimitive from './article-primitive';
import articleLoader from './article-loader';

/**
* Loader to bridge the manifest and the articles.
Expand All @@ -9,33 +9,35 @@ import ArticlePrimitive from './article-primitive';
* @param rootArticles
*/
function manifestLoader(rootArticles = articles) {
let tree = rootArticles;

return new Promise(resolve => {
Object.values(rootArticles).forEach(topLevel => {
/*
If we have objects (aka sub categories within this level) we recursively load them until
we end up with an array. An array is the sign that we have POTENTIALLY reached the deepest
level of sub categories.
*/
Object.values(tree).forEach(topLevel => {
/**
* If we have objects (aka sub categories within this level) we recursively load them until
* we end up with an array. An array is the sign that we have POTENTIALLY reached the deepest
* level of sub categories.
*
*/
if (!Array.isArray(topLevel)) {
manifestLoader(topLevel);
} else {
/*
If we get an array, we MIGHT be at the deepest level of sub categories. This is not a certainty
since we can have an infinite number of sub categories.
*/
/**
* If we get an array, we MIGHT be at the deepest level of sub categories. This is not a certainty
* since we can have an infinite number of sub categories.
*
*/
Object.values(topLevel).forEach(article => {
/*
IMPORTANT:
"title" is a reserved keyword. It is how we know if we have further nested categories.
*/
/**
* IMPORTANT:
* "title" is a reserved keyword. It is how we know if we have further nested categories.
*
*/
if (!article.title) {
manifestLoader(article);
} else {
// TODO: USE articleLoader
article.primitive = new ArticlePrimitive(article.title, article.slug, article.tags).value;

import(`BASE_PATH/docs/${article.primitive.slug}.md`).then(content => {
article.primitive.content = content;
articleLoader(article).then(fullArticle => {
article = Object.assign(article, fullArticle);

// Dispatch an event of type 'manifest:primitive:content:${slug}' after loading the content of our md.
window.EventBus.$emit(`manifest:primitive:content:${article.slug}`);
Expand All @@ -44,13 +46,10 @@ function manifestLoader(rootArticles = articles) {
});
}
});

store.commit({
type: 'core/setArticles',
articles: articles
articles: tree
});

// Resolve the loader.
resolve();
});
}
Expand Down
29 changes: 16 additions & 13 deletions src/core/loaders/search-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,26 @@ import { store } from '../store/index';
function searchLoader(rootArticles = store.state.core.articles) {
return new Promise(resolve => {
Object.values(rootArticles).forEach(topLevel => {
/*
If we have objects (aka sub categories within this level) we recursively load them until
we end up with an array. An array is the sign that we have POTENTIALLY reached the deepest
level of sub categories.
*/
/**
* If we have objects (aka sub categories within this level) we recursively load them until
* we end up with an array. An array is the sign that we have POTENTIALLY reached the deepest
* level of sub categories.
*
*/
if (!Array.isArray(topLevel)) {
searchLoader(topLevel);
} else {
/*
If we get an array, we MIGHT be at the deepest level of sub categories. This is not a certainty
since we can have an infinite number of sub categories.
*/
/**
* If we get an array, we MIGHT be at the deepest level of sub categories. This is not a certainty
* since we can have an infinite number of sub categories.
*
*/
Object.values(topLevel).forEach(article => {
/*
IMPORTANT:
"title" is a reserved keyword. It is how we know if we have further nested categories.
*/
/**
* IMPORTANT:
* "title" is a reserved keyword. It is how we know if we have further nested categories.
*
*/
if (!article.title) {
searchLoader(article);
} else {
Expand Down
11 changes: 6 additions & 5 deletions src/core/router/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,12 @@ const router = new Router({
});

router.afterEach((to, from) => {
/*
We need to delay emitting events since we want components to actually render and be able
to listen to those events. FYI, this guard triggers before the components mount.
100ms is arbitrary.
*/
/**
* We need to delay emitting events since we want components to actually render and be able
* to listen to those events. FYI, this guard triggers before the components mount.
* 100ms is arbitrary.
*
*/
if (to.name === 'article' && from.name === 'home') {
window.setTimeout(() => {
window.EventBus.$emit('router:after:from:home:to:article');
Expand Down
2 changes: 1 addition & 1 deletion src/core/store/modules/core/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Vue from 'vue';

const state = {
articles: null,
articles: {},
homepage: null,
config: {}
};
Expand Down
5 changes: 3 additions & 2 deletions src/core/store/modules/search/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import Fuse from 'fuse.js';

/*
Options to calibrate fuse.
/**
* Options to calibrate fuse.
*
*/
const fuseOptions = {
keys: [
Expand Down
7 changes: 4 additions & 3 deletions src/core/utils/event-bus.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import Vue from 'vue';

/*
This Event bus will be used for pub/sub events that fall out of the scope of our vuex store,
aka simple communication within two components, notify of configuration loading, ...
/**
* This Event bus will be used for pub/sub events that fall out of the scope of our vuex store,
* aka simple communication within two components, notify of configuration loading, ...
*
*/
window.EventBus = new Vue();
export const EventBus = window.EventBus;

0 comments on commit e38fb23

Please sign in to comment.