Skip to content

Commit 9361da5

Browse files
authored
Merge branch 'master' into master
2 parents c3eff35 + 8cd7b79 commit 9361da5

File tree

309 files changed

+7448
-1090
lines changed

Some content is hidden

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

309 files changed

+7448
-1090
lines changed

.github/manual_lint.js

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
const util = require("util");
2+
const glob = util.promisify(require('glob'));
3+
const fs = require("fs").promises;
4+
const path = require('path');
5+
6+
7+
async function main() {
8+
var errors = [];
9+
var directories = await glob(__dirname + '../../dishes/**/*.md');
10+
11+
for (var filePath of directories) {
12+
var data = await fs.readFile(filePath, 'utf8');
13+
var filename = path.parse(filePath).base.replace(".md","");
14+
15+
dataLines = data.split('\n').map(t => t.trim());
16+
titles = dataLines.filter(t => t.startsWith('#'));
17+
secondTitles = titles.filter(t => t.startsWith('## '));
18+
19+
if (dataLines.filter(line => line.includes('勺')).length >
20+
dataLines.filter(line => line.includes('勺子')).length +
21+
dataLines.filter(line => line.includes('炒勺')).length +
22+
dataLines.filter(line => line.includes('漏勺')).length +
23+
dataLines.filter(line => line.includes('吧勺')).length) {
24+
errors.push(`文件 ${filePath} 不符合仓库的规范!勺 不是一个精准的单位!`);
25+
}
26+
if (dataLines.filter(line => line.includes('适量')).length > 0) {
27+
errors.push(`文件 ${filePath} 不符合仓库的规范!适量 不是一个精准的描述!请给出克 g 或毫升 ml。`);
28+
}
29+
if (dataLines.filter(line => line.includes('左右')).length > 0) {
30+
errors.push(`文件 ${filePath} 不符合仓库的规范!左右 不是一个能够明确定量的标准! 如果是在描述一个模糊物体的特征,请使用 '大约'。例如:鸡(大约1kg)`);
31+
}
32+
if (dataLines.filter(line => line.includes('你')).length > 0) {
33+
errors.push(`文件 ${filePath} 不符合仓库的规范!请不要出现人称代词。`);
34+
}
35+
if (titles[0].trim() != "# " + filename + "的做法") {
36+
errors.push(`文件 ${filePath} 不符合仓库的规范! 它的大标题应该是: ${"# " + filename + "的做法"}! 而它现在是 ${titles[0].trim()}!`);
37+
continue;
38+
}
39+
if (secondTitles.length != 4) {
40+
errors.push(`文件 ${filePath} 不符合仓库的规范! 它并不是四个标题的格式。请参考示例菜模板!`);
41+
continue;
42+
}
43+
if (secondTitles[0].trim() != "## 必备原料和工具") {
44+
errors.push(`文件 ${filePath} 不符合仓库的规范! 第一个标题不是 必备原料和工具!`);
45+
}
46+
if (secondTitles[1].trim() != "## 计算") {
47+
errors.push(`文件 ${filePath} 不符合仓库的规范! 第二个标题不是 计算!`);
48+
}
49+
if (secondTitles[2].trim() != "## 操作") {
50+
errors.push(`文件 ${filePath} 不符合仓库的规范! 第三个标题不是 操作`);
51+
}
52+
if (secondTitles[3].trim() != "## 附加内容") {
53+
errors.push(`文件 ${filePath} 不符合仓库的规范! 第四个标题不是 附加内容`);
54+
}
55+
56+
var mustHave = '如果您遵循本指南的制作流程而发现有问题或可以改进的流程,请提出 Issue 或 Pull request 。';
57+
var mustHaveIndex = dataLines.indexOf(mustHave);
58+
if (mustHaveIndex < 0) {
59+
errors.push(`文件 ${filePath} 不符合仓库的规范! 它没有包含必需的附加内容!`);
60+
}
61+
}
62+
63+
if (errors.length > 0) {
64+
for (var error of errors) {
65+
console.error(error + "\n");
66+
}
67+
68+
var message = `Found ${errors.length} errors! Please fix!`;
69+
throw new Error(message);
70+
}
71+
}
72+
73+
main();

.github/pull_request_template.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<!-- 请在此填写该 pr 的内容,例如 增加 or 修改一道菜谱。 -->
2+
3+
## 修改类型
4+
5+
这个 Pull Request 是在:
6+
7+
- [ ] 增加菜谱
8+
- [ ] 修复错误
9+
- [ ] 其它
10+
11+
## 检查单
12+
13+
- [ ] 我已阅读贡献模板,并按照模板规范进行了内容创作。
14+
- [ ] 菜谱包含`必备原料和工具`, `计算`, `操作`三部分内容。
15+
- [ ] 菜品的`原材料用量`是无歧义且准确的。对于可以自行发挥的量给出了建议的范围。
16+
- [ ] 菜品的`制作步骤`是无歧义,准确且完整的。对于每一个步骤的开始和结束都有明确的标准。
17+
- [ ] 我没有破坏模板的一二级标题格式。
18+
- [ ] 我没有删除模板中必需的内容。
19+
- [ ] 我已删除干净所有的复制出来的模板的注释。
20+
- [ ] 我确保我没有签入任何和版权方相关的内容、图片。
21+
22+
请审核人员按照 [审核检查单](https://github.com/Anduin2017/HowToCook/blob/master/CONTRIBUTING.md#%E5%AE%A1%E6%A0%B8%E5%91%98%E9%A1%BB%E7%9F%A5) 对照审核检查。
23+
24+
## 警告
25+
26+
**HowToCook 仓库采用了 [The Unlicense](https://unlicense.org/) 协议!**
27+
28+
**菜谱在签入前,必须确保其可以直接声明进入 "公共领域"(public domain)。这意味着一旦合并后,任何人都可以自由复制,修改,发布,使用,编译,出售或以菜谱的形式或菜的形式分发,无论是出于商业目的还是非商目的,以及任何手段。**
29+
30+
<!-- 如果该 pr 有关联 issue 请在此填写 -->

.github/readme-generate.js

+163
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,163 @@
1+
const { readdir, writeFile, stat } = require('fs/promises');
2+
const fs = require('fs').promises;
3+
4+
const README_PATH = './README.md';
5+
6+
const MKDOCS_PATH = 'mkdocs.yml';
7+
8+
const ignorePaths = ['.git', 'README.md', 'node_modules', 'CONTRIBUTING.md', '.github'];
9+
10+
const categories = {
11+
vegetable_dish: {
12+
title: '素菜',
13+
readme: '',
14+
mkdocs: '',
15+
},
16+
meat_dish: {
17+
title: '荤菜',
18+
readme: '',
19+
mkdocs: '',
20+
},
21+
aquatic: {
22+
title: '水产',
23+
readme: '',
24+
mkdocs: '',
25+
},
26+
breakfast: {
27+
title: '早餐',
28+
readme: '',
29+
mkdocs: '',
30+
},
31+
staple: {
32+
title: '主食',
33+
readme: '',
34+
mkdocs: '',
35+
},
36+
'semi-finished': {
37+
title: '半成品加工',
38+
readme: '',
39+
mkdocs: '',
40+
},
41+
soup: {
42+
title: '汤与粥',
43+
readme: '',
44+
mkdocs: '',
45+
},
46+
drink: {
47+
title: '饮料',
48+
readme: '',
49+
mkdocs: '',
50+
},
51+
condiment: {
52+
title: '酱料和其它材料',
53+
readme: '',
54+
mkdocs: '',
55+
},
56+
dessert: {
57+
title: '甜品',
58+
readme: '',
59+
mkdocs: '',
60+
},
61+
};
62+
63+
async function main() {
64+
try {
65+
let README_BEFORE = (README_MAIN = README_AFTER = '');
66+
let MKDOCS_BEFORE = (MKDOCS_MAIN = MKDOCS_AFTER = '');
67+
const markdownObj = await getAllMarkdown('.');
68+
for (const markdown of markdownObj) {
69+
if (markdown.path.includes('tips/advanced')) {
70+
README_AFTER += inlineReadmeTemplate(markdown.file, markdown.path);
71+
MKDOCS_AFTER += inlineMkdocsTemplate(markdown.file, markdown.path);
72+
continue;
73+
}
74+
75+
if (markdown.path.includes('tips')) {
76+
README_BEFORE += inlineReadmeTemplate(markdown.file, markdown.path);
77+
MKDOCS_BEFORE += inlineMkdocsTemplate(markdown.file, markdown.path);
78+
continue;
79+
}
80+
81+
for (const category of Object.keys(categories)) {
82+
if (!markdown.path.includes(category)) continue;
83+
categories[category].readme += inlineReadmeTemplate(markdown.file, markdown.path);
84+
categories[category].mkdocs += inlineMkdocsTemplate(
85+
markdown.file,
86+
markdown.path,
87+
true,
88+
);
89+
}
90+
}
91+
92+
for (const category of Object.values(categories)) {
93+
README_MAIN += categoryReadmeTemplate(category.title, category.readme);
94+
MKDOCS_MAIN += categoryMkdocsTemplate(category.title, category.mkdocs);
95+
}
96+
97+
const MKDOCS_TEMPLATE = await fs.readFile("./.github/templates/mkdocs_template.yml", "utf-8");
98+
const README_TEMPLATE = await fs.readFile("./.github/templates/readme_template.md", "utf-8");
99+
100+
await writeFile(
101+
README_PATH,
102+
README_TEMPLATE
103+
.replace('{{before}}', README_BEFORE.trim())
104+
.replace('{{main}}', README_MAIN.trim())
105+
.replace('{{after}}', README_AFTER.trim()),
106+
);
107+
108+
109+
await writeFile(
110+
MKDOCS_PATH,
111+
MKDOCS_TEMPLATE
112+
.replace('{{before}}', MKDOCS_BEFORE)
113+
.replace('{{main}}', MKDOCS_MAIN)
114+
.replace('{{after}}', MKDOCS_AFTER),
115+
);
116+
} catch (error) {
117+
console.error(error);
118+
}
119+
}
120+
121+
async function getAllMarkdown(path) {
122+
const paths = [];
123+
const files = await readdir(path);
124+
// chinese alphabetic order
125+
files.sort((a, b) => a.localeCompare(b, 'zh-CN'));
126+
127+
// mtime order
128+
// files.sort(async (a, b) => {
129+
// const aStat = await stat(`${path}/${a}`);
130+
// const bStat = await stat(`${path}/${b}`);
131+
// return aStat.mtime - bStat.mtime;
132+
// });
133+
for (const file of files) {
134+
const filePath = `${path}/${file}`;
135+
if (ignorePaths.includes(file)) continue;
136+
const fileStat = await stat(filePath);
137+
if (fileStat.isFile() && file.endsWith('.md')) {
138+
paths.push({ path, file });
139+
} else if (fileStat.isDirectory()) {
140+
const subFiles = await getAllMarkdown(filePath);
141+
paths.push(...subFiles);
142+
}
143+
}
144+
return paths;
145+
}
146+
147+
function inlineReadmeTemplate(file, path) {
148+
return `- [${file.replace('.md', '')}](${path}/${file})\n`;
149+
}
150+
151+
function categoryReadmeTemplate(title, inlineStr) {
152+
return `\n### ${title}\n\n${inlineStr}`;
153+
}
154+
155+
function inlineMkdocsTemplate(file, path, isDish = false) {
156+
return `${' '.repeat(isDish ? 10 : 6)}- ${file.replace('.md', '')}: ${path}/${file}\n`;
157+
}
158+
159+
function categoryMkdocsTemplate(title, inlineStr) {
160+
return `\n${' '.repeat(6)}- ${title}:\n${inlineStr}`;
161+
}
162+
163+
main();

.github/stale.yml

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Configuration for probot-stale - https://github.com/probot/stale
2+
# Number of days of inactivity before an issue becomes stale
3+
daysUntilStale: 30
4+
# Number of days of inactivity before a stale issue is closed
5+
daysUntilClose: 7
6+
# Issues with these labels will never be considered stale
7+
exemptLabels:
8+
- "Type: Bug"
9+
# Label to use when marking an issue as stale
10+
staleLabel: "Resolution: Stale"
11+
issues:
12+
# Comment to post when marking an issue as stale.
13+
markComment: >
14+
This issue has been automatically marked as stale.
15+
**If this issue is still affecting you, please leave any comment** (for example, "bump"), and we'll keep it open.
16+
We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!
17+
# Comment to post when closing a stale issue.
18+
closeComment: >
19+
Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please create a new issue with up-to-date information. Thank you!
20+
pulls:
21+
# Comment to post when marking a pull request as stale.
22+
markComment: >
23+
This pull request has been automatically marked as stale.
24+
**If this pull request is still relevant, please leave any comment** (for example, "bump"), and we'll keep it open.
25+
We are sorry that we haven't been able to prioritize reviewing it yet. Your contribution is very much appreciated.
26+
# Comment to post when closing a stale pull request.
27+
closeComment: >
28+
Closing this pull request after a prolonged period of inactivity. If this issue is still present in the latest release, please ask for this pull request to be reopened. Thank you!

.github/templates/mkdocs_template.yml

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
site_name: How To Cook
2+
3+
# Repository
4+
repo_name: Anduin2017/HowToCook
5+
repo_url: https://github.com/Anduin2017/HowToCook
6+
edit_uri: ""
7+
8+
use_directory_urls: true
9+
docs_dir: .
10+
theme:
11+
name: material
12+
language: zh
13+
features:
14+
- content.code.annotate
15+
# - content.tabs.link
16+
# - header.autohide
17+
#- navigation.expand
18+
#- navigation.indexes
19+
- navigation.instant
20+
- navigation.sections
21+
- navigation.tabs
22+
- navigation.tabs.sticky
23+
- navigation.top
24+
- navigation.tracking
25+
- search.highlight
26+
- search.share
27+
- search.suggest
28+
- toc.follow
29+
# # - toc.integrate
30+
search_index_only: true
31+
palette:
32+
- media: "(prefers-color-scheme: light)"
33+
scheme: default
34+
toggle:
35+
icon: material//weather-sunny
36+
name: Switch to dark mode
37+
- media: "(prefers-color-scheme: dark)"
38+
scheme: slate
39+
toggle:
40+
icon: material/weather-night
41+
name: Switch to light mode
42+
43+
icon:
44+
admonition:
45+
note: octicons/tag-16
46+
abstract: octicons/checklist-16
47+
info: octicons/info-16
48+
tip: octicons/squirrel-16
49+
success: octicons/check-16
50+
question: octicons/question-16
51+
warning: octicons/alert-16
52+
failure: octicons/x-circle-16
53+
danger: octicons/zap-16
54+
bug: octicons/bug-16
55+
example: octicons/beaker-16
56+
quote: octicons/quote-16
57+
58+
markdown_extensions:
59+
- admonition
60+
- pymdownx.details
61+
- pymdownx.superfences
62+
- abbr
63+
- pymdownx.snippets
64+
- def_list
65+
- pymdownx.tasklist:
66+
custom_checkbox: true
67+
- attr_list
68+
69+
plugins:
70+
- same-dir
71+
- search
72+
- minify:
73+
minify_html: true
74+
75+
nav:
76+
- README.md
77+
- 做菜之前:
78+
{{before}}
79+
- 菜谱:
80+
- 按种类: # 只有两层section以上才能出现navigation expansion https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/#navigation-sections
81+
{{main}}
82+
- 进阶知识学习:
83+
{{after}}
84+
- CONTRIBUTING.md
85+
- CODE_OF_CONDUCT.md

0 commit comments

Comments
 (0)