forked from AOEpeople/aoe_technology_radar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5c5f90d
commit 0252c9e
Showing
10 changed files
with
144 additions
and
104 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { | ||
createRadar, | ||
outputRadar, | ||
} from './radar'; | ||
import { | ||
createStatic, | ||
} from './static'; | ||
|
||
|
||
(async () => { | ||
try { | ||
const radar = await createRadar(); | ||
outputRadar(radar); | ||
createStatic(radar); | ||
|
||
console.log('Radar build!'); | ||
console.log(JSON.stringify(radar, null, 2)); | ||
} catch(e) { | ||
console.error('error:', e); | ||
} | ||
})() |
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,56 @@ | ||
import path from 'path'; | ||
import { walk } from 'walk'; | ||
|
||
export const relativePath = (...relativePath) => ( | ||
path.resolve(__dirname, '..', ...relativePath) | ||
); | ||
|
||
export const srcPath = (...pathInSrc) => ( | ||
export const radarPath = (...pathInSrc) => ( | ||
relativePath('radar', ...pathInSrc) | ||
); | ||
|
||
export const staticPath = (...pathInSrc) => ( | ||
relativePath('static-pages', ...pathInSrc) | ||
); | ||
|
||
export const distPath = (...pathInDist) => ( | ||
relativePath('dist', ...pathInDist) | ||
); | ||
|
||
export const getAllMarkdownFiles = (folder) => ( | ||
getAllFiles(folder, isMarkdownFile) | ||
); | ||
|
||
export const getAllPugFiles = (folder) => ( | ||
getAllFiles(folder, isPugFile) | ||
); | ||
|
||
const getAllFiles = (folder, predicate) => ( | ||
new Promise((resolve, reject) => { | ||
const walker = walk(folder, { followLinks: false }); | ||
const files = []; | ||
|
||
walker.on("file", (root, fileStat, next) => { | ||
if (predicate(fileStat.name)) { | ||
files.push(path.resolve(root, fileStat.name)); | ||
} | ||
next(); | ||
}); | ||
|
||
walker.on("errors", (root, nodeStatsArray, next) => { | ||
nodeStatsArray.forEach(function (n) { | ||
console.error("[ERROR] " + n.name) | ||
console.error(n.error.message || (n.error.code + ": " + n.error.path)); | ||
}); | ||
next(); | ||
}); | ||
|
||
walker.on("end", () => { | ||
resolve(files.sort()); | ||
}); | ||
}) | ||
); | ||
|
||
const isMarkdownFile = (name) => name.match(/\.md$/); | ||
|
||
const isPugFile = (name) => name.match(/\.pug$/); |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { outputFile } from 'fs-extra'; | ||
import pug from 'pug'; | ||
import frontmatter from 'front-matter'; | ||
import marked from 'marked'; | ||
import { | ||
staticPath, | ||
distPath, | ||
getAllPugFiles, | ||
} from './file'; | ||
|
||
export const createStatic = async (radar) => { | ||
const paths = await getAllPugFiles(staticPath()); | ||
const fileNames = getPlainFileNames(paths); | ||
return renderStaticPages(radar, fileNames); | ||
return fileNames; | ||
}; | ||
|
||
const getPlainFileNames = (paths) => ( | ||
paths.map((fileName) => { | ||
const [ nameWithSuffix ] = fileName.split('/').slice(-1); | ||
return nameWithSuffix.substr(0, nameWithSuffix.length - 4); | ||
}) | ||
) | ||
|
||
const renderStaticPages = (radar, fileNames) => ( | ||
Promise.all(fileNames.map((name) => ( | ||
new Promise((resolve, reject) => ( | ||
outputFile(distPath(`${name}.html`), pug.renderFile(staticPath(`${name}.pug`), { | ||
radar, | ||
}), (err, data) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(data); | ||
} | ||
}) | ||
)) | ||
))) | ||
); |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
extends ../templates/layout.pug | ||
|
||
block vars | ||
- var title='Overview' | ||
|
||
block content | ||
ul | ||
each quadrant, quadrantName in radar | ||
li | ||
h4= quadrantName | ||
ul | ||
each radarItem, itemName in quadrant | ||
li | ||
a(href='/' + quadrantName + '/' + itemName + '.html')= radarItem.attributes.title |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,13 @@ | ||
block vars | ||
html | ||
head | ||
title #{attributes.title} - AOE Tech Radar | ||
title #{title} - AOE Tech Radar | ||
block scripts | ||
script(src='/jquery.js') | ||
|
||
h3 AOE Tech Radar | ||
|
||
hr | ||
|
||
body | ||
block content |