mirror of
https://github.com/twirl/The-API-Book.git
synced 2025-02-04 18:21:47 +02:00
minor changes & fresh builds
This commit is contained in:
parent
c8a36c8634
commit
943f929d4d
@ -1,27 +1,50 @@
|
||||
import { readFileSync, writeFileSync, readdirSync } from 'fs';
|
||||
import {
|
||||
readFileSync,
|
||||
writeFileSync,
|
||||
readdirSync,
|
||||
existsSync,
|
||||
mkdirSync
|
||||
} from 'fs';
|
||||
import { resolve } from 'path';
|
||||
import { pathToFileURL } from 'url';
|
||||
import puppeteer from 'puppeteer';
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const dir = process.cwd();
|
||||
const langs = (args[1] || 'en,ru').split(',');
|
||||
const graphDir = resolve(dir, 'src', 'graphs');
|
||||
const tmpDir = resolve(graphDir, 'tmp');
|
||||
const srcDir = resolve(dir, 'src');
|
||||
|
||||
if (args[0] == 'l10n') {
|
||||
buildL10N(dir, (args[1] || 'en,ru').split(','));
|
||||
} else {
|
||||
buildGraphs(dir, (args[0] || 'en,ru').split(','), args[1]);
|
||||
if (!existsSync(tmpDir)) {
|
||||
mkdirSync(tmpDir);
|
||||
}
|
||||
const targets = args[2]
|
||||
? [args[2] + '.yaml']
|
||||
: readdirSync(graphDir).filter((i) => i.endsWith('.yaml'));
|
||||
|
||||
build(langs, targets, srcDir, graphDir, tmpDir).then(
|
||||
() => process.exit(0),
|
||||
(e) => {
|
||||
throw e;
|
||||
}
|
||||
);
|
||||
|
||||
async function build(langs, targets, srcDir, graphDir, tmpDir) {
|
||||
await buildL10n(langs, srcDir, tmpDir);
|
||||
await buildGraphs(langs, targets, graphDir, tmpDir);
|
||||
}
|
||||
|
||||
async function buildL10N(dir, langs) {
|
||||
async function buildL10n(langs, srcDir, tmpDir) {
|
||||
const l10n = langs.reduce((l10n, lang) => {
|
||||
const l10nFile = resolve(dir, 'src', lang, 'l10n.json');
|
||||
const l10nFile = resolve(srcDir, lang, 'l10n.json');
|
||||
const contents = JSON.parse(readFileSync(l10nFile).toString('utf-8'));
|
||||
l10n[lang] = JSON.stringify(contents);
|
||||
return l10n;
|
||||
}, {});
|
||||
|
||||
writeFileSync(
|
||||
resolve(dir, 'src', 'graphs', 'l10n.js'),
|
||||
resolve(tmpDir, 'l10n.js'),
|
||||
`(function(global){global.l10n={${Object.entries(l10n)
|
||||
.map(
|
||||
([lang, content]) =>
|
||||
@ -31,17 +54,19 @@ async function buildL10N(dir, langs) {
|
||||
);
|
||||
}
|
||||
|
||||
async function buildGraphs(dir, langs, source) {
|
||||
const srcDir = resolve(dir, 'src', 'graphs');
|
||||
const sources = source
|
||||
? [source]
|
||||
: readdirSync(srcDir)
|
||||
.filter((file) => file.slice(-3) == '.js' && file != 'l10n.js')
|
||||
.map((file) => file.slice(0, file.length - 3))
|
||||
.sort();
|
||||
const indexFileUrl = pathToFileURL(
|
||||
resolve(dir, 'src', 'graphs', 'index.html')
|
||||
async function buildGraphs(langs, targets, graphDir, tmpDir) {
|
||||
const tasks = langs.reduce(
|
||||
(tasks, lang) =>
|
||||
tasks.concat(
|
||||
targets.map((target) => {
|
||||
lang, target;
|
||||
})
|
||||
),
|
||||
[]
|
||||
);
|
||||
return Promise.all(tasks.map(({lang, target}) => {
|
||||
const yaml = readFileSync(resolve(graphDir, target))
|
||||
});
|
||||
|
||||
for (const source of sources) {
|
||||
console.log(`Building ${source}…`);
|
||||
|
BIN
docs/API.en.epub
BIN
docs/API.en.epub
Binary file not shown.
BIN
docs/API.en.pdf
BIN
docs/API.en.pdf
Binary file not shown.
BIN
docs/API.ru.epub
BIN
docs/API.ru.epub
Binary file not shown.
BIN
docs/API.ru.pdf
BIN
docs/API.ru.pdf
Binary file not shown.
@ -119,8 +119,16 @@ img.header {
|
||||
min-width: 200px;
|
||||
max-width: 400px;
|
||||
padding-top: 0.4em;
|
||||
color: gray;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.about-me aside a, .about-me aside a:visited {
|
||||
color: inherit;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
||||
.about-me aside img {
|
||||
width: 100%;
|
||||
}
|
||||
|
@ -105,7 +105,7 @@
|
||||
<p>Source code available at <a href="https://github.com/twirl/The-API-Book">github.com/twirl/The-API-Book</a></p>
|
||||
<h3><a name="about-author">About the Author</a></h3>
|
||||
<section class="about-me">
|
||||
<aside><img src="https://konstantinov.cc/static/me.png"/></aside>
|
||||
<aside><img src="https://konstantinov.cc/static/me.png"/><br/>Photo by <a href="http://linkedin.com/in/zloylos/">Denis Hananein</a></aside>
|
||||
<div class="content">
|
||||
<p>Sergey Konstantinov has been working with APIs for more than a decade. He started his career as a software engineer in the Maps API division at Yandex and eventually became the head of the service, being responsible for both technical architecture and product management.</p>
|
||||
<p>During this tenure, Sergey got a unique experience in building world-class APIs with a daily audience of tens of millions, planning roadmaps for such a service, and giving numerous public speeches. He also worked for a year and a half as a member of the W3C Technical Architecture Group.</p>
|
||||
|
@ -105,7 +105,7 @@
|
||||
<p>Исходный код доступен на <a href="https://github.com/twirl/The-API-Book">github.com/twirl/The-API-Book</a></p>
|
||||
<h3><a name="about-author">Об авторе</a></h3>
|
||||
<section class="about-me">
|
||||
<aside><img src="https://konstantinov.cc/static/me.png"/></aside>
|
||||
<aside><img src="https://konstantinov.cc/static/me.png"/><br/>Фото: <a href="http://linkedin.com/in/zloylos/">Denis Hananein</a></aside>
|
||||
<div class="content">
|
||||
<p>Сергей Константинов работает с API уже больше десятилетия. Он начинал свою карьеру разработчиком в подразделении API Яндекс.Карт, и со временем стал руководителем всего сервиса, отвечая и за техническую, и за продуктовую составляющую.</p>
|
||||
<p>За это время Сергей получил уникальный опыт построения API мирового уровня с дневной аудторией в десятки миллионов человек, планирования роадмапов для такого продукта и многочисленных публичных выступлений. Он также проработал полтора года в составе Технической архитектурной группы W3C.</p>
|
||||
|
@ -12,7 +12,8 @@
|
||||
"<p>Sergey Konstantinov has been working with APIs for more than a decade. He started his career as a software engineer in the Maps API division at Yandex and eventually became the head of the service, being responsible for both technical architecture and product management.</p>",
|
||||
"<p>During this tenure, Sergey got a unique experience in building world-class APIs with a daily audience of tens of millions, planning roadmaps for such a service, and giving numerous public speeches. He also worked for a year and a half as a member of the W3C Technical Architecture Group.</p>",
|
||||
"<p>After nine years in Maps, Sergey switched to technical-lead roles in other departments and companies, leading integration efforts and being responsible for the technical architecture of entire business units. Today, Sergey lives in Tallinn, Estonia, and works as a staff software engineer at Bolt.</p>"
|
||||
]
|
||||
],
|
||||
"imageCredit": "Photo by <a href=\"http://linkedin.com/in/zloylos/\">Denis Hananein</a>"
|
||||
},
|
||||
"landingFile": "index.html",
|
||||
"url": "https://twirl.github.io/The-API-Book/",
|
||||
|
@ -13,7 +13,8 @@
|
||||
"<p>Сергей Константинов работает с API уже больше десятилетия. Он начинал свою карьеру разработчиком в подразделении API Яндекс.Карт, и со временем стал руководителем всего сервиса, отвечая и за техническую, и за продуктовую составляющую.</p>",
|
||||
"<p>За это время Сергей получил уникальный опыт построения API мирового уровня с дневной аудторией в десятки миллионов человек, планирования роадмапов для такого продукта и многочисленных публичных выступлений. Он также проработал полтора года в составе Технической архитектурной группы W3C.</p>",
|
||||
"<p>После девяти лет в Картах Сергей переключился на технические роли в других департаментах и компаниях, занимаясь интеграционными проектами и будучи ответственным за техническую архитектуру целых продуктов компании. Сегодня Сергей живёт в Таллинне, Эстония, и работает ведущим инженером в компании Bolt.</p>"
|
||||
]
|
||||
],
|
||||
"imageCredit": "Фото: <a href=\"http://linkedin.com/in/zloylos/\">Denis Hananein</a>"
|
||||
},
|
||||
"url": "https://twirl.github.io/The-API-Book/index.ru.html",
|
||||
"favicon": "/img/favicon.png",
|
||||
|
@ -146,7 +146,9 @@ const templates = (module.exports = {
|
||||
}</a></p>
|
||||
<h3><a name="about-author">${l10n.aboutMe.title}</a></h3>
|
||||
<section class="about-me">
|
||||
<aside><img src="https://konstantinov.cc/static/me.png"/></aside>
|
||||
<aside><img src="https://konstantinov.cc/static/me.png"/><br/>${
|
||||
l10n.aboutMe.imageCredit
|
||||
}</aside>
|
||||
<div class="content">
|
||||
${l10n.aboutMe.content.join('\n')}</div>
|
||||
</section>
|
||||
|
Loading…
x
Reference in New Issue
Block a user