wire up docs pages and 404 handlers
This commit is contained in:
Родитель
2d2bda4694
Коммит
e12b8e3b39
|
@ -1646,12 +1646,12 @@
|
|||
}
|
||||
},
|
||||
"electron-i18n": {
|
||||
"version": "github:electron/electron-i18n#cf1dd152fa3eff29df4018dd231f8a07f70f89c1",
|
||||
"version": "0.0.7",
|
||||
"resolved": "https://registry.npmjs.org/electron-i18n/-/electron-i18n-0.0.7.tgz",
|
||||
"integrity": "sha512-oDJj37yc8yW37lz7Wo987gC8QVG03Tvb/Cou3/vSgvMpss37GCgtnvT02E9Pkn9eIB9ojXdYsTPJqKrSUXIEtg==",
|
||||
"requires": {
|
||||
"flat": "2.0.1",
|
||||
"lodash": "4.17.4",
|
||||
"objectify-array": "1.0.1",
|
||||
"require-yml": "1.3.1"
|
||||
"objectify-array": "1.0.1"
|
||||
}
|
||||
},
|
||||
"electron-userland-reports": {
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
"dotenv": "^4.0.0",
|
||||
"electron-apps": "^1.762.0",
|
||||
"electron-docs": "^3.0.0",
|
||||
"electron-i18n": "github:electron/electron-i18n",
|
||||
"electron-i18n": "*",
|
||||
"electron-userland-reports": "1.6.0",
|
||||
"express": "^4.15.3",
|
||||
"express-hbs": "^1.0.4",
|
||||
|
@ -52,6 +52,7 @@
|
|||
"markdown-it": "^6.0.1",
|
||||
"marky-markdown-lite": "^1.2.0",
|
||||
"minimist": "^1.2.0",
|
||||
"mkdirp": "^0.5.1",
|
||||
"node-sass-middleware": "^0.11.0",
|
||||
"primer-breadcrumb": "1.0.2",
|
||||
"require-dir": "^0.3.1",
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
---
|
||||
title: Page Not Found
|
||||
permalink: /404.html
|
||||
excerpt: ""
|
||||
---
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
{% include head.html %}
|
||||
<style>
|
||||
h1 {
|
||||
font-size: 12em;
|
||||
font-weight: 100;
|
||||
margin: 0;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
{% include header.html %}
|
||||
<section class='page-section error-page'>
|
||||
<div class='container-narrow text-center py-md-8'>
|
||||
<h1>404</h1>
|
||||
<p class="lead">This page could not be found</p>
|
||||
</div>
|
||||
</section>
|
||||
</body>
|
||||
</html>
|
121
pages/docs.html
121
pages/docs.html
|
@ -1,121 +0,0 @@
|
|||
---
|
||||
title: Documentation
|
||||
permalink: /docs/
|
||||
excerpt: Guides and API reference documentation for the latest Electron release.
|
||||
redirect_from:
|
||||
- /docs/v0.24.0/
|
||||
- /docs/v0.25.0/
|
||||
- /docs/v0.26.0/
|
||||
- /docs/v0.27.0/
|
||||
- /docs/v0.28.0/
|
||||
- /docs/v0.29.0/
|
||||
- /docs/v0.30.0/
|
||||
- /docs/v0.31.0/
|
||||
- /docs/v0.32.0/
|
||||
- /docs/v0.33.0/
|
||||
- /docs/v0.34.0/
|
||||
- /docs/v0.35.0/
|
||||
- /docs/v0.36.0/
|
||||
- /docs/v0.36.3/
|
||||
- /docs/v0.36.4/
|
||||
- /docs/v0.36.5/
|
||||
- /docs/v0.36.6/
|
||||
- /docs/v0.36.7/
|
||||
- /docs/v0.36.8/
|
||||
- /docs/v0.36.9/
|
||||
- /docs/v0.36.10/
|
||||
- /docs/v0.36.11/
|
||||
- /docs/v0.37.0/
|
||||
- /docs/v0.37.1/
|
||||
- /docs/v0.37.2/
|
||||
- /docs/v0.37.3/
|
||||
- /docs/v0.37.4/
|
||||
- /docs/v0.37.5/
|
||||
- /docs/v0.37.7/
|
||||
- /docs/latest/
|
||||
layout: default
|
||||
---
|
||||
|
||||
{% assign docs = site.docs | sort: 'sort_title' %}
|
||||
|
||||
<div class='subtron'>
|
||||
<div class='container-narrow'>
|
||||
<h1><span class="mr-3 mr-lg-4">Electron Documentation</span><span class="docs-version">{{ site.data.releases[0].version }}</span></h1>
|
||||
<p class="lead mb-3">
|
||||
See all of the <a href="{{ site.baseurl }}/docs/all/">docs on one page</a> or check out the <a href="{{ site.baseurl }}/docs/faq/">FAQ</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class='page-section'>
|
||||
<div class='container'>
|
||||
<div class="grid">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-ms-12 col-lg-4">
|
||||
<h2 class="docs-heading pb-3 mb-3"><a class="docs-title" href="{{ site.baseurl }}/docs/guides/"><span class="mega-octicon octicon-book pr-3"></span>Guides</a></h2>
|
||||
<ul class="docs-list">
|
||||
{% for doc in docs %}
|
||||
{% if doc.category == 'Tutorial' %}
|
||||
<li>
|
||||
<a href="{{ site.baseurl }}{{ doc.url }}">{{ doc.title }}</a>
|
||||
<!-- <span class="excerpt">{{ doc.content | strip_html | truncatewords: 50 }}</span> -->
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="col-ms-12 col-lg-4">
|
||||
<h2 class="docs-heading pb-3 mb-3"><a class="docs-title" href="{{ site.baseurl }}/docs/api/"><span class="mega-octicon octicon-gear pr-3"></span>API Reference</a></h2>
|
||||
<h3>Main Process</h3>
|
||||
<ul class="docs-list">
|
||||
{% for doc in docs %}
|
||||
{% if doc.category == 'API' and site.data.processes[doc.title] == 'Main Process' %}
|
||||
<li>
|
||||
<a href="{{ site.baseurl }}{{ doc.url }}">{{ doc.title }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<h3>Renderer Process</h3>
|
||||
<ul class="docs-list">
|
||||
{% for doc in docs %}
|
||||
{% if doc.category == 'API' and site.data.processes[doc.title] == 'Renderer Process' %}
|
||||
<li>
|
||||
<a href="{{ site.baseurl }}{{ doc.url }}">{{ doc.title }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
<h3>Both Processes</h3>
|
||||
{% for doc in docs %}
|
||||
<ul class="docs-list">
|
||||
{% if doc.category == 'API' and site.data.processes[doc.title] == 'Main and Renderer Process' %}
|
||||
<li>
|
||||
<a href="{{ site.baseurl }}{{ doc.url }}">{{ doc.title }}</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="col-ms-12 col-lg-4">
|
||||
<h2 class="docs-heading pb-3 mb-3"><a class="docs-title" href="{{ site.baseurl }}/docs/development/"><span class="mega-octicon octicon-tools pr-3"></span>Advanced</a></h2>
|
||||
<ul class="docs-list">
|
||||
{% for doc in docs %}
|
||||
{% if doc.category == 'Development' %}
|
||||
<li>
|
||||
<a href="{{ site.baseurl }}{{ doc.url }}">{{ doc.title }}</a>
|
||||
<!-- <span class="excerpt">{{ doc.content | strip_html | truncatewords: 50 }}</span> -->
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
55
server.js
55
server.js
|
@ -37,16 +37,6 @@ app.use(jexodus.middleware)
|
|||
app.use(express.static(__dirname))
|
||||
app.use(browsersync)
|
||||
|
||||
app.get('/docs/api/:slug', (req, res) => {
|
||||
const locale = 'fr-FR'
|
||||
const api = i18n.api.get(req.params.slug, locale)
|
||||
const context = {
|
||||
api: api,
|
||||
layout: 'docs'
|
||||
}
|
||||
res.render('api', context)
|
||||
})
|
||||
|
||||
app.get('/apps', (req, res) => {
|
||||
let appList = electronApps
|
||||
if (req.query.category) {
|
||||
|
@ -105,6 +95,51 @@ app.get('/contact', (req, res) => {
|
|||
res.render('contact', context)
|
||||
})
|
||||
|
||||
app.get('/docs', (req, res) => {
|
||||
const locale = 'en'
|
||||
|
||||
if (!i18n[locale]) {
|
||||
return res.status(404).render('404', {message: `Invalid locale: ${locale}`})
|
||||
}
|
||||
|
||||
const docs = Object.keys(i18n[locale])
|
||||
.map(href => i18n[locale][href])
|
||||
.sort((a, b) => (a.slug).localeCompare((b.slug)))
|
||||
|
||||
const context = {
|
||||
pageDetails: Object.assign({}, localized.pages[req.path]),
|
||||
docs: docs
|
||||
}
|
||||
res.render('docs/index', context)
|
||||
})
|
||||
|
||||
app.get('/docs/*', (req, res) => {
|
||||
const locale = 'en'
|
||||
const href = req.path
|
||||
|
||||
if (!i18n[locale]) {
|
||||
return res.status(404).render('404', {message: `Invalid locale: ${locale}`})
|
||||
}
|
||||
|
||||
const doc = i18n[locale][href]
|
||||
|
||||
if (!doc) {
|
||||
return res.status(404).render('404', {message: `Document not found`})
|
||||
}
|
||||
|
||||
const context = {
|
||||
pageDetails: Object.assign({}, localized.pages[req.path]),
|
||||
doc: doc,
|
||||
title: doc.title,
|
||||
layout: 'docs'
|
||||
}
|
||||
res.render('docs/show', context)
|
||||
})
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
res.status(404).render('404')
|
||||
})
|
||||
|
||||
function startServer () {
|
||||
app.bootstrapped = true
|
||||
if (module.parent) return
|
||||
|
|
|
@ -61,16 +61,19 @@ describe('electron.atom.io', () => {
|
|||
})
|
||||
})
|
||||
|
||||
test('/docs/api/app', (done) => {
|
||||
get('/docs/api/app').then($ => {
|
||||
// layout is working
|
||||
test('/docs', (done) => {
|
||||
get('/docs').then($ => {
|
||||
$('header').should.have.class('site-header')
|
||||
$('a[href="/docs/tutorial/about"]').should.have.text('About Electron')
|
||||
$('a[href="/docs/api/auto-updater"]').should.have.text('autoUpdater')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
// localized content
|
||||
// TODO
|
||||
|
||||
// page title
|
||||
// TODO
|
||||
test('Docs Pages', (done) => {
|
||||
get('/docs/api/browser-window').then($ => {
|
||||
$('.docs-breadcrumbs a').should.have.length(2)
|
||||
$('.docs-breadcrumbs a[href="/docs/api"]').should.have.text('API')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
<section class='page-section error-page'>
|
||||
<div class='container-narrow text-center py-md-8'>
|
||||
<h1>404</h1>
|
||||
<p class="lead">
|
||||
This page could not be found.
|
||||
|
||||
{{message}}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
|
@ -0,0 +1,57 @@
|
|||
<div class='subtron'>
|
||||
<div class='container-narrow'>
|
||||
<h1><span class="mr-3 mr-lg-4">Electron Documentation</span><span class="docs-version">PUT STABLE VERSION HERE</span></h1>
|
||||
<p class="lead mb-3">
|
||||
See all of the <a href="/docs/all/">docs on one page</a> or check out the <a href="/docs/faq/">FAQ</a>.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class='page-section'>
|
||||
<div class='container'>
|
||||
<div class="grid">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-ms-12 col-lg-4">
|
||||
<h2 class="docs-heading pb-3 mb-3"><a class="docs-title" href="/docs/docs/"><span class="mega-octicon octicon-book pr-3"></span>Guides</a></h2>
|
||||
<ul class="docs-list">
|
||||
{{#each docs}}
|
||||
{{#if this.isTutorial}}
|
||||
<li>
|
||||
<a href="{{this.href}}">{{this.title}}</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="col-ms-12 col-lg-4">
|
||||
<h2 class="docs-heading pb-3 mb-3"><a class="docs-title" href="/docs/api/"><span class="mega-octicon octicon-gear pr-3"></span>API Reference</a></h2>
|
||||
<ul class="docs-list">
|
||||
{{#each docs}}
|
||||
{{#if this.isApiDoc}}
|
||||
<li>
|
||||
<a href="{{this.href}}">{{this.title}}</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="col-ms-12 col-lg-4">
|
||||
<h2 class="docs-heading pb-3 mb-3"><a class="docs-title" href="/docs/development/"><span class="mega-octicon octicon-tools pr-3"></span>Advanced</a></h2>
|
||||
<ul class="docs-list">
|
||||
{{#each docs}}
|
||||
{{#if this.isDevTutorial}}
|
||||
<li>
|
||||
<a href="{{this.href}}">{{this.title}}</a>
|
||||
</li>
|
||||
{{/if}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
|
@ -0,0 +1 @@
|
|||
{{{doc.html}}}
|
|
@ -4,7 +4,8 @@
|
|||
<div class='container-narrow'>
|
||||
|
||||
<h4 class="docs-breadcrumbs">
|
||||
<a href='/docs/'>Docs</a>
|
||||
<a href='/docs/'>Docs</a> /
|
||||
<a href="/docs/{{doc.category}}">{{doc.categoryFancy}}</a> / {{doc.title}}
|
||||
</h4>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -14,7 +15,6 @@
|
|||
|
||||
{{{body}}}
|
||||
|
||||
{% if page.category != 'ignore' %}
|
||||
<hr>
|
||||
<div class='text-center'>
|
||||
<span class="d-inline-block text-left">
|
||||
|
@ -28,7 +28,6 @@
|
|||
Want to search all the documentation at once? See all of the <a href='/docs/all'>docs on one page</a>.
|
||||
</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</section>
|
||||
|
|
Загрузка…
Ссылка в новой задаче