Skip to content

Commit 4975169

Browse files
committed
resolve #5, 使用 hexo 编译网站
1 parent 0247488 commit 4975169

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+16839
-3
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
1. [GitHub 在线](./book/zh-cn/toc.md)
3434
2. [PDF 文档](./pdf/zh-cn/modern-cpp-tutorial.pdf)
35-
3. [网站]
35+
3. [网站](https://changkun.de/modern-cpp/)
3636

3737
## 相关代码
3838

book/zh-cn/00-preface.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: 序言
3+
type: book-zh-cn
4+
order: 0
5+
---
6+
17
# 序言
28

39
## 引言

book/zh-cn/01-intro.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: 第 1 章 迈向 C++11/14/17
3+
type: book-zh-cn
4+
order: 1
5+
---
6+
17
# 第 1 章 迈向 C++11/14/17
28

39
[TOC]

book/zh-cn/02-usability.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: 第 2 章 语言可用性的强化
3+
type: book-zh-cn
4+
order: 2
5+
---
6+
17
# 第 2 章 语言可用性的强化
28

39
[TOC]

book/zh-cn/03-runtime.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: 第 3 章 语言运行期的强化
3+
type: book-zh-cn
4+
order: 3
5+
---
6+
17
# 第 3 章 语言运行期的强化
28

39
> 内容修订中

book/zh-cn/04-containers.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: 第 4 章 标准库:容器
3+
type: book-zh-cn
4+
order: 4
5+
---
6+
17
# 第 4 章 标准库:容器
28

39
> 内容修订中

book/zh-cn/05-pointers.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: 第 5 章 标准库:容器
3+
type: book-zh-cn
4+
order: 5
5+
---
6+
17
# 第 5 章 标准库:指针
28

39
> 内容修订中

book/zh-cn/06-regex.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: 第 6 章 标准库:正则表达式
3+
type: book-zh-cn
4+
order: 6
5+
---
6+
17
# 第 6 章 标准库:正则表达式
28

39
> 内容修订中

book/zh-cn/07-thread.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: 第 7 章 标准库:线程与并发
3+
type: book-zh-cn
4+
order: 7
5+
---
6+
17
# 第 7 章 标准库:线程与并发
28

39
> 内容修订中

book/zh-cn/08-filesystem.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# 第 8 章 标准库: 文件系统
1+
---
2+
title: 第 8 章 标准库:文件系统
3+
type: book-zh-cn
4+
order: 8
5+
---
6+
7+
# 第 8 章 标准库:文件系统
28

39
> TODO: 这部分内容为 C++17 新增
410

book/zh-cn/09-others.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: 第 9 章 其他杂项
3+
type: book-zh-cn
4+
order: 9
5+
---
6+
17
# 第 9 章 其他杂项
28

39
> 内容修订中

book/zh-cn/10-cpp20.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# 第 10 章 展望: C++20 简介
1+
---
2+
title: 第 10 章 展望:C++20 简介
3+
type: book-zh-cn
4+
order: 10
5+
---
6+
7+
# 第 10 章 展望:C++20 简介
28

39
> 内容修订中, 目前内容为第一版中对 C++17 的展望
410

book/zh-cn/appendix.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
title: 附录:进一步阅读的学习材料
3+
type: book-zh-cn
4+
order: 11
5+
---
6+
17
# 附录:进一步阅读的学习材料
28

39
首先,恭喜你阅读完本书 🎉 !笔者希望本书有提起你对现代 C++ 的兴趣。

website/Makefile

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
all:
2+
rm -rf public db.json
3+
node install.js
4+
rm -rf src/modern-cpp/book
5+
python3 filter.py
6+
rm -rf ./src/modern-cpp/images/cover-2nd.png
7+
cp ../assets/cover-2nd.png ./src/modern-cpp/images/cover-2nd.png
8+
hexo generate
9+
mv public/index.html public/modern-cpp/index.html
10+
s:
11+
node_modules/serve/bin/serve.js ./public
12+
clean:
13+
rm ./src/modern-cpp/images/cover-2nd.png
14+
rm -rf src/modern-cpp/book
15+
rm -rf public db.json

website/README.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# changkun.de/modern-cpp
2+
3+
Welcome to Modern C++ Tutorial! This site is built with [hexo](http://hexo.io/). Site content is written in Markdown format located in `../book`. And all static files will be built into `./public`, which is served by a nginx server at [changkun.de](https://changkun.de).
4+
5+
## Requirements
6+
7+
- node.js
8+
- npm
9+
10+
## Developing
11+
12+
Start from the terminal:
13+
14+
```
15+
$ make # build
16+
$ make s # start serve
17+
```
18+
19+
Note that:
20+
21+
1. `make` command will check and install all dependencies for you, then build the website into `/public`;
22+
2. `make s` command will serve the static files inside `/public` folder.
23+
3. when you changed the website content, you will need re-compile the website, which means you need use `make` again.
24+
25+
## On Translations
26+
27+
The website is originally in German, but we are currently working on support more languages, such as English and Mandarin Chinese.
28+
29+
### Mandarin Chinese
30+
31+
* Translation directory - [/v2/modern-cpp/](./src/modern-cpp/cn/)
32+
33+
## English
34+
35+
- Translation directory - [/v2/en/](./src/v2/en/)
36+
37+
## Contributors
38+
39+
- [Ou Changkun](https://changkun.de)

website/_config.yml

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Site Configuration
2+
title: 高速上手 C++ 11/14/17
3+
subtitle:
4+
description: "欧长坤"
5+
author: 欧长坤
6+
email:
7+
language:
8+
9+
# URL
10+
## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
11+
url: https://changkun.de/modern-cpp/
12+
root: /
13+
permalink: :year/:month/:day/:title/
14+
tag_dir: tags
15+
archive_dir: archives
16+
category_dir: categories
17+
code_dir: downloads/code
18+
19+
# Directory
20+
source_dir: src
21+
public_dir: public
22+
23+
# Writing
24+
new_post_name: :title.md # File name of new posts
25+
default_layout: post
26+
auto_spacing: false # Add spaces between asian characters and western characters
27+
titlecase: false # Transform title into titlecase
28+
external_link: true # Open external links in new tab
29+
max_open_file: 100
30+
multi_thread: true
31+
filename_case: 0
32+
render_drafts: false
33+
post_asset_folder: false
34+
highlight:
35+
enable: true
36+
line_number: false
37+
tab_replace:
38+
toc:
39+
maxdepth: 3
40+
class: toc
41+
slugify: transliteration
42+
decodeEntities: false
43+
anchor:
44+
position: after
45+
symbol: '#'
46+
style: header-anchor
47+
48+
# Category & Tag
49+
default_category: uncategorized
50+
category_map:
51+
tag_map:
52+
53+
# Archives
54+
## 2: Enable pagination
55+
## 1: Disable pagination
56+
## 0: Fully Disable
57+
archive: 0
58+
category: 0
59+
tag: 0
60+
61+
# Server
62+
## Hexo uses Connect as a server
63+
## You can customize the logger format as defined in
64+
## http://www.senchalabs.org/connect/logger.html
65+
port: 4000
66+
logger: false
67+
logger_format:
68+
69+
# Date / Time format
70+
## Hexo uses Moment.js to parse and display date
71+
## You can customize the date format as defined in
72+
## http://momentjs.com/docs/#/displaying/format/
73+
date_format: MMM D YYYY
74+
time_format: H:mm:ss
75+
76+
# Pagination
77+
## Set per_page to 0 to disable pagination
78+
per_page: 10
79+
pagination_dir: page
80+
81+
# Extensions
82+
theme: moderncpp
83+
exclude_generator:
84+
85+
# Markdown
86+
## https://github.com/chjj/marked
87+
markdown:
88+
gfm: true
89+
pedantic: false
90+
sanitize: false
91+
tables: true
92+
breaks: true
93+
smartLists: true
94+
smartypants: true
95+
96+
# Deployment
97+
## Docs: http://zespia.tw/hexo/docs/deployment.html
98+
deploy:
99+
type: git
100+
repository:
101+
102+
feed:
103+
type: atom
104+
path: atom.xml
105+
limit: 20
106+
107+
alias:
108+
modern-cpp/l/index.html: l/index.html

website/filter.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# !/usr/bin/env python3
2+
# author: changkun<[email protected]>
3+
import os
4+
5+
source_dir = [
6+
'../book/zh-cn/'
7+
]
8+
9+
destination_dir = [
10+
'./src/modern-cpp/book/'
11+
]
12+
13+
chapters = ['00-preface.md', '01-intro.md', '02-usability.md', '03-runtime.md', '04-containers.md', '05-pointers.md', '06-regex.md', '07-thread.md', '08-filesystem.md', '09-others.md', '10-cpp20.md', 'appendix.md']
14+
15+
ignores = ['TOC', '返回目录', '许可', 'license']
16+
17+
for index, source in enumerate(source_dir):
18+
for chapter in chapters:
19+
dst_filepath = destination_dir[index] + chapter[:-3]
20+
os.makedirs(dst_filepath)
21+
print(dst_filepath)
22+
print(dst_filepath + '/index.md')
23+
with open(source+chapter, 'r') as source_file:
24+
with open(dst_filepath + '/index.md', 'w') as output_file:
25+
for line in source_file:
26+
if any(keyword in line for keyword in ignores):
27+
continue
28+
else:
29+
output_file.write(line)

website/install.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var fs = require('fs')
2+
var execSync = require('child_process').execSync
3+
var deps = require('./package.json').dependencies
4+
var depFolders = Object.keys(deps)
5+
6+
for (var depFolder in deps) {
7+
if (!fs.existsSync('./node_modules/' + depFolder)) {
8+
console.log('Dependency "' + depFolder + '" is NOT installed - installing now...')
9+
execSync('npm install')
10+
process.exit(0)
11+
}
12+
}
13+
14+
console.log('All dependencies are already installed.')

0 commit comments

Comments
 (0)