add framework

This commit is contained in:
Neucrack
2019-05-25 19:01:45 +08:00
commit 617071829d
49 changed files with 1573 additions and 0 deletions

17
.bookignore Normal file
View File

@@ -0,0 +1,17 @@
/config/
gulpfile.js
.markdownlint.json
package.json
.gitignore
.bookignore
/README.md
/zh/CONTRIBUTING.md
*.xlsx
*.orig
*.less
*.ai
.travis.yml
deploy.sh
serve.sh
serve_daemon.sh

10
.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
npm-debug.log
.DS_Store
node_modules/
output/
.vscode/
_book/
*.epub
*.mobi
serve.tmp
*-lock.json

5
.markdownlint.json Normal file
View File

@@ -0,0 +1,5 @@
{
"fenced-code-language": false,
"ol-prefix": false,
"line-length": false
}

48
.travis.yml Normal file
View File

@@ -0,0 +1,48 @@
language: node_js
node_js:
- "8"
# 缓存依赖
cache:
directories:
- $HOME/.npm
before_install:
- export TZ='Asia/Shanghai' # 更改时区
# 依赖安装
install:
- npm install gitbook-cli -g
# 安装 gitbook 插件
- gitbook install
# 构建脚本
script:
# 自定义输出目录 gitbook build src dest
- gitbook build . ./build
# 分支白名单
branches:
only:
- master # 只对 master 分支进行构建
- dev
- /v*.*/
# # GitHub Pages 部署
# deploy:
# provider: pages
# skip_cleanup: true
# # 在项目仪表盘的 Settings -> Environment Variables 中配置
# github_token: $GITHUB_TOKEN
# # 将 build 目录下的内容推送到默认的 gh-pages 分支上,并不会连带 build/zh 目录一起
# local_dir: build/zh
# #fqdn: $CUSTOM_DOMAIN
# name: $GIT_NAME
# email: $GIT_EMAIL
# on:
# branch: master
# 不使用travis的github pages构建功能自定义脚本
after_success:
- bash ./deploy.sh

1
CNAME Normal file
View File

@@ -0,0 +1 @@
wiki.sipeed.com

2
LANGS.md Normal file
View File

@@ -0,0 +1,2 @@
- [English](/en)
- [中文](/zh)

48
README.md Normal file
View File

@@ -0,0 +1,48 @@
Sipeed Wiki pages
===========
|[Read me online](https://wiki.sipeed.com/en/) | [在线阅读](https://wiki.sipeed.com/zh/) |
| ------------------------ | ----------- |
[![Build Status](https://travis-ci.org/sipeed/sipeed_wiki.svg?branch=master)](https://travis-ci.org/sipeed/sipeed_wiki)
-----------------------------------------------------------------------
## Build Doc
This documentation site is powered by GitBook. You can check out the online version here.
You need Node.js and npm to be able to build the site.
To install gitbook:
```
npm install gitbook-cli -g
```
Get Doc source code:
```
sudo apt install git
git clone https://github.com/sipeed/sipeed_wiki.git
```
Install gitbook plugins:
```
cd sipeed_wiki
gitbook install
```
Serve as a website:
```
chmod +x serve.sh
./serve.sh
```
Then visit http://localhost:4000

BIN
assets/BiT.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 510 KiB

BIN
assets/Dan_Dock.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 KiB

BIN
assets/Go.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 142 KiB

BIN
assets/binocular.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

BIN
assets/canaan-banner.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

View File

@@ -0,0 +1,9 @@
.languages{
margin-top: 50px;
}
.languages a{
color: green;
font-size: 18px;
}

BIN
assets/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

BIN
assets/icon_sipeed.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
assets/icon_sipeed2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

BIN
assets/m1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 KiB

BIN
assets/m1_pin.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 887 KiB

BIN
assets/mic_array.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

BIN
assets/micropython.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

90
book.json Normal file
View File

@@ -0,0 +1,90 @@
{
"title": "Sipeed Wiki",
"description": "Sipeed Wiki pages",
"author":"sipeed",
"plugins": [
"my-toolbar",
"-lunr",
"-search",
"search-title",
"anchor-navigation-ex",
"anchorjs",
"sharing",
"splitter",
"edit-link",
"ga",
"expandable-chapters-small@git+https://github.com/sipeed/gitbook-plugin-expandable-chapters-small.git"
],
"styles": {
"website": "./styles/website.css"
},
"pluginsConfig": {
"github": {
"url": "https://github.com/sipeed/sipeed_wiki"
},
"my-toolbar": {
"buttons": [
{
"label": "Github",
"text":" ",
"icon": "fa fa-github",
"position": "left",
"target": "_blank",
"url": "https://github.com/sipeed/sipeed_wiki"
}
]
},
"search": {
"maxIndexSize": 1000000000
},
"lunr": {
"maxIndexSize": 1000000000
},
"edit-link": {
"base": "https://github.com/sipeed/sipeed_wiki/blob/master",
"label": ""
},
"sharing": {
"douban": false,
"facebook": true,
"google": true,
"hatenaBookmark": false,
"instapaper": false,
"line": false,
"linkedin": false,
"messenger": false,
"pocket": false,
"qq": false,
"qzone": false,
"stumbleupon": false,
"twitter": true,
"viber": false,
"vk": false,
"weibo": true,
"whatsapp": false,
"all": [
"weibo",
"facebook",
"google",
"twitter",
"vk"
]
},
"anchor-navigation-ex": {
"associatedWithSummary": false,
"showLevel": true,
"multipleH1": false,
"mode": "float",
"pageTop": {
"showLevelIcon": true,
"level1Icon": "fa fa-angle-double-right",
"level2Icon": "fa fa-angle-double-right",
"level3Icon": "fa fa-angle-double-right"
}
},
"ga": {
"token": "UA-119047820-2"
}
}
}

69
deploy.sh Normal file
View File

@@ -0,0 +1,69 @@
#!/bin/bash
set -o errexit -o nounset
rev=$(git rev-parse --short HEAD)
BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, BRANCH=$BRANCH"
curr_branch=$TRAVIS_BRANCH
cp -f index.html build/index.html
cp -f assets/favicon.ico build/gitbook/images/favicon.ico
cp -f assets/icon_sipeed.png build/gitbook/images/apple-touch-icon-precomposed-152.png
git clone -b gh-pages https://github.com/sipeed/sipeed_wiki.git ./old
rm -rf ./old/.git/
echo "current build branch: --$curr_branch--"
if [[ "$curr_branch" == "master" ]]; then
echo "master"
if [[ -d './old/dev' ]]; then
echo "copy dev"
cp -r ./old/dev ./build/
fi
cd ./old
v_folder=`find ./ -maxdepth 1 -name 'v*.*'`
echo "version folder:$v_folder"
if [[ "x$v_folder" != "x" ]]; then
echo "copy version folder"
cp -r $v_folder ../build/
fi
cd ..
elif [[ "$curr_branch" == "dev" ]]; then
echo "dev"
rm -rf ./old/dev
mkdir ./old/dev
cp -r ./build/* ./old/dev
rm -rf ./build
mv ./old ./build
else
echo "not master or dev"
rm -rf ./old/$curr_branch
mkdir ./old/$curr_branch
cp -r ./build/* ./old/$curr_branch
rm -rf ./build
mv ./old ./build
fi
cd build
git init
git config user.name $GIT_NAME
git config user.email $GIT_EMAIL
git remote add upstream "https://$GITHUB_TOKEN@github.com/sipeed/sipeed_wiki.git"
# comment below because we don't need history of gh-pages, and use git push --force to cover history
# git fetch upstream
# git reset upstream/gh-pages
# echo "gprs.ai-thinker.com" > CNAME
git add -A
git commit -m "rebuild pages at ${rev}"
git push upstream HEAD:gh-pages --force

6
en/README.md Normal file
View File

@@ -0,0 +1,6 @@
Sipeed Wiki
==========

30
en/SUMMARY.md Normal file
View File

@@ -0,0 +1,30 @@
Summary
=====
- [Wiki](README.md)
## K210
- [About K210](k210/README.md)
- [Modules](k210/module/README.md)
- [Maix M1](k210/module/m1.md)
- [Development Boards](k210/board/README.md)
- [Maix Bit](k210/board/bit.md)
- [Maix Dock](k210/board/dock.md)
- [Maix Go](k210/board/go.md)
- [Maixduino](k210/board/maixduino.md)
- [SDK](k210/sdk/README.md)
- [MaixPy](https://maixpy.sipeed.com)
- [Maixduino](https://maixduino.sipeed.com)
- [Kendryte SDK](k210/sdk/kendryte_sdk.md)
- [RT-Thread](k210/sdk/rtt.md)
## Lichee Pi

View File

@@ -0,0 +1,47 @@
{% extends template.self %}
{% block book_header %}
<div class="sipeed-navbar navbar-collapse" id="navbar" role="navigation">
<ul class="nav navbar-nav">
<li><a href="https://www.sipeed.com" class="btn" target="_blank"><img src="/assets/icon_sipeed2.png" height="30" /></a></li>
<li><a href="#" class="btn autohide" onclick="toggleLanguage()">中文</a></li>
{% for item in book.items %}
{% if item.links %}
<li>
<a href="#" class="btn autohide"><i ></i>{{item.name}}</a>
<ul class="hovershow">
{% for entry in item.links %}
<li><a href="{{entry.link}}" class="btn" target="_blank">{{entry.name}}</a></li>
{% endfor %}
</ul>
</li>
{% else %}
<li><a href="{{item.link}}" class="btn autohide" target="_blank"><i ></i>{{item.name}}</a></li>
{% endif %}
{% endfor %}
{% for item in book.version %}
{% if item.links %}
<li class="version-link">
<a class="btn">Version <span style="font-weight:bold">{{item.name}}</span></a>
<ul class="hovershow">
{% for entry in item.links %}
<li><a href="{{entry.link}}" class="btn">Version: <span style="font-weight:bold">{{entry.name}}</span></a></li>
{% endfor %}
</ul>
</li>
{% else %}
<li><a href="{{item.link}}" class="btn">{{item.name}}</a></li>
{% endif %}
{% endfor %}
</ul>
</div>
<div class="book-header" role="navigation">
{% if glossary.path %}
<a href="{{ ('/' + glossary.path)|resolveFile }}" class="btn pull-left" aria-label="{{ "GLOSSARY_OPEN"|t }}"><i class="fa fa-sort-alpha-asc"></i></a>
{% endif %}
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="{{ "/"|resolveFile }}" >{{ page.title }}</a>
</h1>
</div>
{% endblock %}

View File

@@ -0,0 +1,54 @@
{% extends template.self %}
{% block book_sidebar %}
<nav role="navigation" class="autoshow">
<ul class="summary">
<li><a href="https://www.sipeed.com" class="btn" target="_blank"><img src="/assets/icon_sipeed2.png" height="30" /></a></li>
<li><a href="#" class="btn" onclick="toggleLanguage()">中文</a></li>
{% for item in book.version %}
{% if item.links %}
<li class="version-link">
<a href="#" class="btn" style="color:#444"></i>Version: <span style="font-weight: bold; display: inline">{{item.name}}</span></a>
<ul class="hovershow">
{% for entry in item.links %}
<li><a href="{{entry.link}}" class="btn">Version: <span style="font-weight:bold; display: inline">{{entry.name}}</span></a></li>
{% endfor %}
</ul>
</li>
{% else %}
<li><a href="{{item.link}}" class="btn"></i>{{item.name}}</a></li>
{% endif %}
{% endfor %}
{% for item in book.items %}
{% if item.links %}
<li>
<a href="#" class="btn"><i ></i>{{item.name}}</a>
<ul>
{% for entry in item.links %}
<li><a href="{{entry.link}}" class="btn" target="_blank">{{entry.name}}</a></li>
{% endfor %}
</ul>
</li>
{% else %}
<li><a href="{{item.link}}" class="btn" target="_blank"><i></i>{{item.name}}</a></li>
{% endif %}
{% endfor %}
</ul>
</nav>
{{ super() }}
{% endblock %}
{% block javascript %}
{{ super() }}
<script type="text/javascript">
function toggleLanguage () {
var path = location.href;
// console.log(path);
if (path.indexOf('/zh') !== -1) {
path = path.replace(/\/zh[\/$\s]/i, '/en/');
} else if (path.indexOf('/en') !== -1) {
path = path.replace(/\/en[\/$\s]/i, '/zh/');
}
// console.log('after: ' + path);
location.assign(path);
}
</script>
{% endblock %}

32
en/book.json Normal file
View File

@@ -0,0 +1,32 @@
{
"title": "Sipeed Wiki",
"description": "Sipeed Wiki pages",
"structure": {
"summary": "SUMMARY.md",
"readme": "README.md"
},
"variables": {
"items": [
{
"name": "Sipeed",
"link": "https://www.sipeed.com"
},
{
"name": "Blog",
"link": "http://blog.sipeed.com"
},
{
"name": "BBS",
"link": "https://bbs.sipeed.com/"
},
{
"name": "MaixPy",
"link": "https://maixpy.sipeed.com/"
},
{
"name": "Maixduino",
"link": "https://maixduino.sipeed.com/"
}
]
}
}

183
en/styles/website.css Normal file
View File

@@ -0,0 +1,183 @@
.navigation {
top: 90px;
}
.book-summary nav.autoshow a,
.book-summary nav.autoshow a:hover {
color: inherit;
text-decoration: none;
}
@media (min-width: 800px) {
.book-summary nav.autoshow {
display: none;
}
}
.sipeed-navbar {
overflow: visible;
width: 100%;
min-width: 600px;
z-index: 2;
font-size: 0.85em;
color: #7e888b;
background: #f5f5f5;
display: flex;
position: absolute;
top: 0;
}
.sipeed-navbar::after {
clear: both;
content: '.';
display: block;
visibility: hidden;
height: 0;
}
.sipeed-navbar a,
.sipeed-navbar a:hover {
color: inherit;
text-decoration: none;
}
.sipeed-navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 100%;
}
.sipeed-navbar ul li {
margin-right: 1px;
position: relative;
float: left;
}
.sipeed-navbar ul li a:hover + .hovershow,
.sipeed-navbar ul li .hovershow:hover,
.sipeed-navbar ul li .hovershow li:hover {
display: block;
}
.sipeed-navbar ul li img {
margin-top: 3px;
}
.sipeed-navbar ul li ul {
margin: -3px 0 0 0;
background: #f5f5f5;
display: none;
width: 100%;
z-index: 999;
position: absolute;
}
.sipeed-navbar ul li ul li {
display: block;
float: none;
}
.sipeed-navbar ul li ul li a {
width: auto;
min-width: 100px;
padding: 0 20px;
}
@media screen and (max-width: 800px) {
.sipeed-navbar ul li {
/*Make dropdown links appear inline*/
/*Create vertical spacing*/
/*Make all menu links full width*/
}
.sipeed-navbar ul li ul {
position: static;
display: none;
}
.sipeed-navbar ul li li {
margin-bottom: 1px;
}
.sipeed-navbar ul li ul li,
.sipeed-navbar ul li li a {
width: 100%;
}
}
.sipeed-navbar .btn {
display: inline-block;
height: 40px;
padding: 0px 15px;
border-bottom: none;
color: #aaa;
text-transform: none;
line-height: 40px;
position: relative;
font-size: 14px;
}
.sipeed-navbar .btn:hover {
position: relative;
text-decoration: none;
color: #444;
background: none;
}
.sipeed-navbar .btn:focus {
outline: none;
}
.sipeed-navbar:hover h1 {
opacity: 1;
}
@media (max-width: 800px) {
.sipeed-navbar {
display: none;
}
}
@media (min-width: 800px) {
.page-wrapper {
padding-top: 40px;
}
}
@media (max-width: 800px) {
.page-wrapper {
/* min-width: 800px; */
padding-top: 0;
}
}
@media (min-width: 800px) and (max-width: 1000px) {
.sipeed-navbar ul .version-link ul {
margin-left: 20px;
}
.sipeed-navbar .nav {
list-style-type: none;
margin: 0;
padding: 0;
width: 100%;
}
}
@media (max-width: 1240px) {
.book-body .body-inner {
overflow: visible;
}
}
.sipeed-navbar ul .version-link {
float: left;
z-index: 10;
padding-right: 15px;
/* text-align: right; */
min-width: 180px;
}
.version-link ul li .btn {
padding-right: 35px;
padding-left: 0;
}
.version-link a span {
padding: 0;
}
.book-header {
margin-top: 40px;
}
.title_pic {
padding-top: 30px;
padding-bottom: 30px;
}
.markdown-section li code{
color: #ec5d11;
}
#anchor-navigation-ex-navbar {
top:100px;
}
.gitbook-link {
display: none !important;
}

131
en/styles/website.less Normal file
View File

@@ -0,0 +1,131 @@
// Header
@header-height: 40px;
@header-color: hsl(194, 5%, 52%);
@header-background: #f5f5f5;
@header-border: rgba(0, 0, 0, 0.07);
@header-button-color: #aaa;
@header-button-hover-color: #444;
@header-button-hover-background: none;
// Font sizes
@font-size-base: 14px;
@font-size-large: ceil(@font-size-base * 1.25); // ~18px
@font-size-small: ceil(@font-size-base * 0.85); // ~12px
@line-height-base: 1.428571429; // 20/14
@line-height-computed: floor(@font-size-base * @line-height-base);
.navigation {
top: 90px;
}
.book-summary nav.autoshow {
a, a:hover {
color: inherit;
text-decoration: none;
}
@media (min-width: 800px) {
display: none;
}
}
.sipeed-navbar {
overflow: visible;
height: @header-height;
padding: 0px 8px;
z-index: 2;
font-size: 0.85em;
color: @header-color;
background: @header-background;
display: flex;
a, a:hover {
color: inherit;
text-decoration: none;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
position: absolute;
li {
margin-right: 1px;
position: relative;
float: left;
a:hover + .hovershow, .hovershow:hover, .hovershow li:hover {
display:block;
}
img {
margin-top: 3px;
}
ul {
margin: -3px 0 0 0;
background: #f5f5f5;
display:none;
width: 100%;
z-index:999;
li {
display: block;
float: none;
a {
width: auto;
min-width: 100px;
padding: 0 20px;
}
}
}
@media screen and (max-width : 800px){
/*Make dropdown links appear inline*/
ul {
position: static;
display: none;
}
/*Create vertical spacing*/
li {
margin-bottom: 1px;
}
/*Make all menu links full width*/
ul li, li a {
width: 100%;
}
}
}
}
.btn {
display: inline-block;
height: @header-height;
padding: 0px 15px;
border-bottom: none;
color: @header-button-color;
text-transform: none;
line-height: @header-height;
position:relative;
font-size: @font-size-base;
&:hover {
position: relative;
text-decoration: none;
color: @header-button-hover-color;
background: @header-button-hover-background;
}
&:focus {
outline: none;
}
}
.autohide{
@media (max-width: 800px) {
display: none;
}
}
&:hover {
h1 {
opacity: 1;
}
}
}

182
gulpfile.js Normal file
View File

@@ -0,0 +1,182 @@
'use strict';
const Fs = require('fs');
const Path = require('path');
const Del = require('del');
const Globby = require('globby');
// const spawn = require('child_process').spawn;
// const gulpSequence = require('gulp-sequence');
const Difference = require('lodash/difference');
const { exec } = require('child_process');
const gulp = require('gulp');
const program = require('commander');
program
.option('-o, --only <items>', 'Only build these files, specrated by ","', x => x.split(','))
.option('--dest <path>', 'Copy generated document to specified path.')
.parse(process.argv);
gulp.task('publish', function (done) {
var dest = program.dest;
if (!dest) {
return done('dest not supplied');
}
var del = Path.join(dest, '*');
console.log('deleting ' + del);
Del.sync(del, { force: true });
console.log('copying _book/**/* to ' + dest);
gulp.src('_book/**/*', {
base: '_book'
})
.pipe(gulp.dest(dest))
.on('end', done);
});
const FORBID_IGNORE_ARRAY = ['README.md', 'SUMMARY.md'];
const allPagesPattern = ['zh/**/*.md', 'en/**/*.md', '!zh/*.md', '!en/*.md'];
const START_TAG = '\n\n## CC_HIDE_IN_SUMMARY_START';
const END_TAG = '## CC_HIDE_IN_SUMMARY_END\n';
const START_TAG_IGNORE = '\n\nCC_IGNORE_START';
const END_TAG_IGNORE = '\nCC_IGNORE_END';
const PRUNE_LEFT_BAR_RE = /<[^<>]*>\s*CC_HIDE_IN_SUMMARY_START\s*<\/[^<>]*>(?:\n|\r|.)*<[^<>]*>\s*CC_HIDE_IN_SUMMARY_END\s*<\/[^<>]*>/g;
const PAGE_TITLE_RE = /^\s*(?:<!--(?:\n|.)*?-->\s*)*#*\s*(.*?)\s*\n/;
function parseListedPages (summaryPath) {
var content = Fs.readFileSync(summaryPath, 'utf8');
var re = /\[[^\]]*\]\(([^\)]+)\)/g; // should recreate a new RegExp every time this function called
var res = [];
var exec = null;
while ((exec = re.exec(content)) !== null) {
res.push(Path.resolve(Path.dirname(summaryPath), exec[1]));
}
return res;
}
function getPageTitle (path) {
var content = Fs.readFileSync(path, 'utf8');
var match = PAGE_TITLE_RE.exec(content);
if (match) {
return match[1];
}
else {
return Path.parse(path).name;
}
}
function fillSummary (path) {
var cwd = Path.dirname(path);
// get missing pages
var listedPages = parseListedPages(path);
var allPagesPattern = Path.join(cwd, '*/**/*.md');
var allPages = Globby.sync(allPagesPattern, { absolute: true });
var missingPages = Difference(allPages, listedPages);
// fill summary
var content = Fs.readFileSync(path, 'utf8');
var append = missingPages.map(x => `- [${getPageTitle(x)}](${Path.relative(cwd, x)})`).join('\n');
content = `${content}${START_TAG}\n\n${append}\n\n${END_TAG}`;
Fs.writeFileSync(path, content, 'utf8');
}
// add unlisted pages into SUMMARY.md to allow gitbook to build them
gulp.task('prebuild', ['restore-summary'], function () {
fillSummary('zh/SUMMARY.md');
fillSummary('en/SUMMARY.md');
});
gulp.task('preview', ['restore-summary', 'restore-ignore'], function (done) {
var includeFiles = program.only;
if (includeFiles) {
quickPreview(includeFiles, (error) => {
if (error) {
return done(error);
}
else {
openServer(done);
}
});
}
else {
fillSummary('zh/SUMMARY.md');
fillSummary('en/SUMMARY.md');
openServer(done);
}
});
function restoreSummary (path) {
var re = new RegExp(START_TAG + '(?:\\n|.)*' + END_TAG);
var content = Fs.readFileSync(path, 'utf8');
content = content.replace(re, '');
Fs.writeFileSync(path, content, 'utf8');
}
function restoreIgnore (path) {
var re = new RegExp(START_TAG_IGNORE + '(?:\\n|.)*' + END_TAG_IGNORE);
var content = Fs.readFileSync(path, 'utf8');
content = content.replace(re, '');
Fs.writeFileSync(path, content, 'utf8');
}
function openServer (done) {
var server = exec('gitbook serve --no-watch --open');
server.stderr.on('error', error => {
if(error) {
return done(error);
process.exit(1);
}
});
server.stdout.on('data', data => {
console.log(data.toString());
});
}
//only build the target file
function quickPreview (includeFiles, done) {
includeFiles = includeFiles.concat(FORBID_IGNORE_ARRAY);
var excludePattern = includeFiles.map(x => '!**/' + Path.basename(x, '.md') + '.md');
var allIgnorePages = Globby.sync(allPagesPattern.concat(excludePattern), { absolute: true });
allIgnorePages = allIgnorePages.map(x => '/' + Path.relative(__dirname,x).replace(/\\/g, '/'));
Fs.readFile('.bookignore', 'utf8', function (error, content) {
if (error) {
return done(error);
}
const fileContent = `${content}\n${START_TAG_IGNORE}\n${allIgnorePages.join('\n')}${END_TAG_IGNORE}`;
Fs.writeFile('.bookignore', fileContent, 'utf8', done);
});
}
// restore SUMMARY.md to keep repo clean
gulp.task('restore-summary', function () {
restoreSummary('zh/SUMMARY.md');
restoreSummary('en/SUMMARY.md');
});
gulp.task('restore-ignore', function () {
restoreIgnore('.bookignore');
});
function pruneLeftBar (dir) {
var allPagesPattern = Path.join(dir, '**/*.html');
var allPages = Globby.sync(allPagesPattern);
for (var i = 0; i < allPages.length; ++i) {
var path = allPages[i];
var content = Fs.readFileSync(path, 'utf8');
var result = content.replace(PRUNE_LEFT_BAR_RE, '');
if (content !== result) {
Fs.writeFileSync(path, result, 'utf8');
}
else {
throw 'Prune Summary Failed!';
}
}
}
// remove added pages from generated index.html
gulp.task('prune-left-bar', function () {
pruneLeftBar('_book/zh');
pruneLeftBar('_book/en');
});
gulp.task('postbuild', ['restore-summary', 'prune-left-bar']);

23
index.html Normal file
View File

@@ -0,0 +1,23 @@
<!DOCTYPE HTML>
<html lang="" >
<head>
<meta charset="UTF-8">
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Sipeed Wiki</title>
</head>
<body>
<script language="javascript" type="text/javascript">
var JsSrc =(navigator.language || navigator.browserLanguage).toLowerCase();
if(JsSrc.indexOf('zh')>=0){
window.location.href='zh/';
}else{
window.location.href='en/';
}
</script>
<br />
Loading . . .
<br />
</body>
</html>

31
package.json Normal file
View File

@@ -0,0 +1,31 @@
{
"name": "sipeed_wiki",
"version": "1.0.0",
"description": "This repo is for hosting Sipeed Wiki pages.",
"main": "index.js",
"dependencies": {
"commander": "^2.12.2",
"del": "^3.0.0",
"globby": "^7.1.1",
"gulp": "^3.9.1",
"gulp-sequence": "^0.4.6",
"lodash": "^4.17.4"
},
"devDependencies": {},
"scripts": {
"build": "gulp restore-ignore && gulp prebuild && gitbook build && gulp postbuild",
"preview": "gulp preview",
"upload": "gulp publish --dest /Volumes/MaixPy/manual",
"publish": "npm run build && npm run upload"
},
"repository": {
"type": "git",
"url": "git+https://github.com/sipeed/sipeed_wiki.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/sipeed/sipeed_wiki/issues"
},
"homepage": "https://github.com/sipeed/sipeed_wiki"
}

20
serve.sh Normal file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
function cancel()
{
sub=`ps -ef|grep "serve_daemon.sh"|grep -v grep|awk '{print $2}'`
if [[ "x$sub" != "x" ]]; then
`ps -ef|grep "serve_daemon.sh"|grep -v grep|awk '{print $2}'|xargs kill -9`
fi
rm -rf serve.tmp
exit 0
}
trap cancel SIGINT SIGTERM SIGQUIT
echo "" > serve.tmp
./serve_daemon.sh &
gitbook serve | tee serve.tmp

22
serve_daemon.sh Normal file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
function cp_files(){
cp -f index.html _book/index.html
cp -f assets/favicon.ico _book/gitbook/images/favicon.ico
cp -f assets/icon_sipeed.png _book/gitbook/images/apple-touch-icon-precomposed-152.png
}
success_str='Serving book on'
while [ 0 ];
do
a=`cat serve.tmp |grep "$success_str"`
b=`cat serve.tmp|grep "Error"`
if [[ "x$a" != "x" ]]; then
cp_files
`echo "">serve.tmp`
elif [[ "x$b" != "x" ]]; then
exit 0
fi
sleep 1s
done

1
test Normal file
View File

@@ -0,0 +1 @@
aaaaaaaaaaa

7
zh/README.md Normal file
View File

@@ -0,0 +1,7 @@
Sipeed Wiki
======

36
zh/SUMMARY.md Normal file
View File

@@ -0,0 +1,36 @@
Summary
=====
- [Wiki](README.md)
## K210 系列
- [关于 K210](k210/README.md)
- [模组](k210/module/README.md)
- [Maix M1](k210/module/m1.md)
- [开发板](k210/board/README.md)
- [Maix Bit](k210/board/bit.md)
- [Maix Dock](k210/board/dock.md)
- [Maix Go](k210/board/go.md)
- [Maixduino](k210/board/maixduino.md)
- [软件开发套件SDK](k210/sdk/README.md)
- [MaixPy](https://maixpy.sipeed.com)
- [Maixduino](https://maixduino.sipeed.com)
- [Kendryte SDK](k210/sdk/kendryte_sdk.md)
- [RT-Thread](k210/sdk/rtt.md)
## 荔枝派系列

View File

@@ -0,0 +1,47 @@
{% extends template.self %}
{% block book_header %}
<div class="sipeed-navbar navbar-collapse" id="navbar" role="navigation">
<ul class="nav navbar-nav">
<li><a href="https://www.sipeed.com" class="btn" target="_blank"><img src="/assets/icon_sipeed2.png" height="30" /></a></li>
<li><a href="#" class="btn autohide" onclick="toggleLanguage()">English</a></li>
{% for item in book.items %}
{% if item.links %}
<li>
<a href="#" class="btn autohide"><i ></i>{{item.name}}</a>
<ul class="hovershow">
{% for entry in item.links %}
<li><a href="{{entry.link}}" class="btn" target="_blank">{{entry.name}}</a></li>
{% endfor %}
</ul>
</li>
{% else %}
<li><a href="{{item.link}}" class="btn autohide" target="_blank"><i ></i>{{item.name}}</a></li>
{% endif %}
{% endfor %}
{% for item in book.version %}
{% if item.links %}
<li class="version-link">
<a class="btn" >版本 <span style="font-weight:bold">{{item.name}}</span></a>
<ul class="hovershow">
{% for entry in item.links %}
<li><a href="{{entry.link}}" class="btn">版本: <span style="font-weight:bold">{{entry.name}}</span></a></li>
{% endfor %}
</ul>
</li>
{% else %}
<li><a href="{{item.link}}" class="btn">{{item.name}}</a></li>
{% endif %}
{% endfor %}
</ul>
</div>
<div class="book-header" role="navigation">
{% if glossary.path %}
<a href="{{ ('/' + glossary.path)|resolveFile }}" class="btn pull-left" aria-label="{{ "GLOSSARY_OPEN"|t }}"><i class="fa fa-sort-alpha-asc"></i></a>
{% endif %}
<!-- Title -->
<h1>
<i class="fa fa-circle-o-notch fa-spin"></i>
<a href="{{ "/"|resolveFile }}" >{{ page.title }}</a>
</h1>
</div>
{% endblock %}

View File

@@ -0,0 +1,54 @@
{% extends template.self %}
{% block book_sidebar %}
<nav role="navigation" class="autoshow">
<ul class="summary">
<li><a href="https://www.sipeed.com" class="btn" target="_blank"><img src="/assets/icon_sipeed2.png" height="30" /></a></li>
<li><a href="#" class="btn" onclick="toggleLanguage()">English</a></li>
{% for item in book.version %}
{% if item.links %}
<li class="version-link">
<a href="#" class="btn" style="color:#444"></i>Version: <span style="font-weight: bold; display: inline">{{item.name}}</span></a>
<ul class="hovershow">
{% for entry in item.links %}
<li><a href="{{entry.link}}" class="btn">Version: <span style="font-weight:bold; display: inline">{{entry.name}}</span></a></li>
{% endfor %}
</ul>
</li>
{% else %}
<li><a href="{{item.link}}" class="btn"></i>{{item.name}}</a></li>
{% endif %}
{% endfor %}
{% for item in book.items %}
{% if item.links %}
<li>
<a href="#" class="btn"><i ></i>{{item.name}}</a>
<ul>
{% for entry in item.links %}
<li><a href="{{entry.link}}" class="btn">{{entry.name}}</a></li>
{% endfor %}
</ul>
</li>
{% else %}
<li><a href="{{item.link}}" class="btn"><i ></i>{{item.name}}</a></li>
{% endif %}
{% endfor %}
</ul>
</nav>
{{ super() }}
{% endblock %}
{% block javascript %}
{{ super() }}
<script type="text/javascript">
function toggleLanguage () {
var path = location.href;
// console.log(path);
if (path.indexOf('/zh') !== -1) {
path = path.replace(/\/zh[\/$\s]/i, '/en/');
} else if (path.indexOf('/en') !== -1) {
path = path.replace(/\/en[\/$\s]/i, '/zh/');
}
// console.log('after: ' + path);
location.assign(path);
}
</script>
{% endblock %}

33
zh/book.json Normal file
View File

@@ -0,0 +1,33 @@
{
"title": "Sipeed Wiki",
"description": "Sipeed Wiki",
"language" : "zh-hans",
"structure": {
"summary": "SUMMARY.md",
"readme": "README.md"
},
"variables": {
"items": [
{
"name": "官网",
"link": "https://www.sipeed.com"
},
{
"name": "博客",
"link": "http://blog.sipeed.com"
},
{
"name": "论坛",
"link": "https://bbs.sipeed.com/"
},
{
"name": "MaixPy",
"link": "https://maixpy.sipeed.com/"
},
{
"name": "Maixduino",
"link": "https://maixduino.sipeed.com/"
}
]
}
}

2
zh/k210/board/bit.md Normal file
View File

@@ -0,0 +1,2 @@
开发板 Maix Bit
===========

3
zh/k210/board/dock.md Normal file
View File

@@ -0,0 +1,3 @@
开发板 Maix Dan Dock
===========

2
zh/k210/board/go.md Normal file
View File

@@ -0,0 +1,2 @@
开发板 Maix Go
===========

View File

@@ -0,0 +1,2 @@
开发板 Maixduino
===========

4
zh/k210/module/m1.md Normal file
View File

@@ -0,0 +1,4 @@
Sipeed Maix M1
=============

View File

@@ -0,0 +1,5 @@
Kendryte SDK
======
[kendryte-standalone-sdk](https://github.com/kendryte/kendryte-standalone-sdk)

5
zh/k210/sdk/rtt.md Normal file
View File

@@ -0,0 +1,5 @@
RT-Thread
======
[rt-thread](https://github.com/RT-Thread/rt-thread)

181
zh/styles/website.css Normal file
View File

@@ -0,0 +1,181 @@
.navigation {
top: 90px;
}
.book-summary nav.autoshow a,
.book-summary nav.autoshow a:hover {
color: inherit;
text-decoration: none;
}
@media (min-width: 800px) {
.book-summary nav.autoshow {
display: none;
}
}
.sipeed-navbar {
overflow: visible;
width: 100%;
min-width: 600px;
z-index: 2;
font-size: 0.85em;
color: #7e888b;
background: #f5f5f5;
display: flex;
position: absolute;
top: 0;
}
.sipeed-navbar::after {
clear: both;
content: '.';
display: block;
visibility: hidden;
height: 0;
}
.sipeed-navbar a,
.sipeed-navbar a:hover {
color: inherit;
text-decoration: none;
}
.sipeed-navbar ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 100%;
}
.sipeed-navbar ul li {
margin-right: 1px;
position: relative;
float: left;
}
.sipeed-navbar ul li a:hover + .hovershow,
.sipeed-navbar ul li .hovershow:hover,
.sipeed-navbar ul li .hovershow li:hover {
display: block;
}
.sipeed-navbar ul li img {
margin-top: 3px;
}
.sipeed-navbar ul li ul {
margin: -3px 0 0 0;
background: #f5f5f5;
display: none;
width: 100%;
z-index: 999;
position: absolute;
}
.sipeed-navbar ul li ul li {
display: block;
float: none;
}
.sipeed-navbar ul li ul li a {
width: auto;
min-width: 100px;
padding: 0 20px;
}
@media screen and (max-width: 800px) {
.sipeed-navbar ul li {
/*Make dropdown links appear inline*/
/*Create vertical spacing*/
/*Make all menu links full width*/
}
.sipeed-navbar ul li ul {
position: static;
display: none;
}
.sipeed-navbar ul li li {
margin-bottom: 1px;
}
.sipeed-navbar ul li ul li,
.sipeed-navbar ul li li a {
width: 100%;
}
}
.sipeed-navbar .btn {
display: inline-block;
height: 40px;
padding: 0px 15px;
border-bottom: none;
color: #aaa;
text-transform: none;
line-height: 40px;
position: relative;
font-size: 14px;
}
.sipeed-navbar .btn:hover {
position: relative;
text-decoration: none;
color: #444;
background: none;
}
.sipeed-navbar .btn:focus {
outline: none;
}
.sipeed-navbar:hover h1 {
opacity: 1;
}
@media (max-width: 800px) {
.sipeed-navbar {
display: none;
}
}
@media (min-width: 800px) {
.page-wrapper {
padding-top: 40px;
}
}
@media (max-width: 800px) {
.page-wrapper {
/* min-width: 800px; */
padding-top: 0;
}
}
@media (min-width: 800px) and (max-width: 1000px) {
.sipeed-navbar ul .version-link ul {
margin-left: 20px;
}
.sipeed-navbar .nav {
list-style-type: none;
margin: 0;
padding: 0;
width: 100%;
}
}
@media (max-width: 1240px) {
.book-body .body-inner {
overflow: visible;
}
}
.sipeed-navbar ul .version-link {
float: left;
z-index: 10;
padding-right: 15px;
/* text-align: right; */
min-width: 180px;
}
.version-link ul li .btn {
padding-right: 35px;
padding-left: 0;
}
.version-link a span {
padding: 0;
}
.book-header {
margin-top: 40px;
}
.title_pic {
padding-top: 30px;
padding-bottom: 30px;
}
.markdown-section li code{
color: #ec5d11;
}
#anchor-navigation-ex-navbar {
top:100px;
}
.gitbook-link {
display: none !important;
}

131
zh/styles/website.less Normal file
View File

@@ -0,0 +1,131 @@
// Header
@header-height: 40px;
@header-color: hsl(194, 5%, 52%);
@header-background: #f5f5f5;
@header-border: rgba(0, 0, 0, 0.07);
@header-button-color: #aaa;
@header-button-hover-color: #444;
@header-button-hover-background: none;
// Font sizes
@font-size-base: 14px;
@font-size-large: ceil(@font-size-base * 1.25); // ~18px
@font-size-small: ceil(@font-size-base * 0.85); // ~12px
@line-height-base: 1.428571429; // 20/14
@line-height-computed: floor(@font-size-base * @line-height-base);
.navigation {
top: 90px;
}
.book-summary nav.autoshow {
a, a:hover {
color: inherit;
text-decoration: none;
}
@media (min-width: 800px) {
display: none;
}
}
.sipeed-navbar {
overflow: visible;
height: @header-height;
padding: 0px 8px;
z-index: 2;
font-size: 0.85em;
color: @header-color;
background: @header-background;
display: flex;
a, a:hover {
color: inherit;
text-decoration: none;
}
ul {
list-style-type: none;
margin: 0;
padding: 0;
position: absolute;
li {
margin-right: 1px;
position: relative;
float: left;
a:hover + .hovershow, .hovershow:hover, .hovershow li:hover {
display:block;
}
img {
margin-top: 3px;
}
ul {
margin: -3px 0 0 0;
background: #f5f5f5;
display:none;
width: 100%;
z-index:999;
li {
display: block;
float: none;
a {
width: auto;
min-width: 100px;
padding: 0 20px;
}
}
}
@media screen and (max-width : 800px){
/*Make dropdown links appear inline*/
ul {
position: static;
display: none;
}
/*Create vertical spacing*/
li {
margin-bottom: 1px;
}
/*Make all menu links full width*/
ul li, li a {
width: 100%;
}
}
}
}
.btn {
display: inline-block;
height: @header-height;
padding: 0px 15px;
border-bottom: none;
color: @header-button-color;
text-transform: none;
line-height: @header-height;
position:relative;
font-size: @font-size-base;
&:hover {
position: relative;
text-decoration: none;
color: @header-button-hover-color;
background: @header-button-hover-background;
}
&:focus {
outline: none;
}
}
.autohide{
@media (max-width: 800px) {
display: none;
}
}
&:hover {
h1 {
opacity: 1;
}
}
}