├── .gitignore ├── layout ├── src │ ├── img │ │ └── logo.png │ ├── index.html │ └── css │ │ ├── tags.css │ │ ├── mainstyle.css │ │ ├── artical.css │ │ ├── works.css │ │ └── csshake.css └── ejs │ ├── common │ ├── head.ejs │ ├── footer.ejs │ └── nav.ejs │ ├── index │ └── index.ejs │ ├── page │ └── page.ejs │ ├── tags │ ├── tagGuiding.ejs │ └── tags.ejs │ └── categories │ └── categories.ejs ├── bin └── float-site-manager.js ├── source ├── aSiteExample │ ├── src │ │ └── untitled.png │ ├── infos.json │ └── index.html └── aPageExample │ ├── index.html │ └── infos.json ├── lib ├── config.js ├── server.js ├── index.js ├── deploygit.js ├── sourceManager.js ├── extras.js └── generator.js ├── package.json ├── config.json ├── doc ├── README.md └── USAGE.md ├── README.md └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | public/ 3 | __deploy/ 4 | source/fileRecord.json 5 | package-lock.json -------------------------------------------------------------------------------- /layout/src/img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fltb/float-site-manager-npm/HEAD/layout/src/img/logo.png -------------------------------------------------------------------------------- /bin/float-site-manager.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | "use strict"; 4 | 5 | const main = require("../lib/index"); 6 | 7 | main(); 8 | -------------------------------------------------------------------------------- /source/aSiteExample/src/untitled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fltb/float-site-manager-npm/HEAD/source/aSiteExample/src/untitled.png -------------------------------------------------------------------------------- /layout/src/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

Welcome!

4 |

This is Float's site.

5 |
6 | -------------------------------------------------------------------------------- /layout/ejs/common/head.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /source/aPageExample/index.html: -------------------------------------------------------------------------------- 1 |

Float's Example

2 | 3 |

First Paragraph.

4 | 5 |

Second Paragraph.

6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /source/aPageExample/infos.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "page", 3 | "title": "Float's Example Page", 4 | "auther": "Float", 5 | "category": "Test", 6 | "tags": [ 7 | "Test", 8 | "Float" 9 | ], 10 | "description": "An Example Page for test", 11 | "date": "2077-07-07" 12 | } -------------------------------------------------------------------------------- /source/aSiteExample/infos.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "site", 3 | "title": "Float's Example Site", 4 | "auther": "Float", 5 | "category": "Test", 6 | "tags": [ 7 | "Test", 8 | "Float" 9 | ], 10 | "description": "An Example Site for test", 11 | "date": "2077-07-07" 12 | } -------------------------------------------------------------------------------- /lib/config.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const fs = require("fs"); 4 | 5 | const config = { 6 | getConfig: function() { 7 | if (!this.inited) { 8 | this.inited = true; 9 | this.conf = JSON.parse(fs.readFileSync("config.json")); 10 | } 11 | return this.conf; 12 | } 13 | } 14 | 15 | module.exports = config; -------------------------------------------------------------------------------- /layout/ejs/common/footer.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /source/aSiteExample/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | Float's Test 8 | 9 | 10 |

Testing page LOL

11 |

Welcome to the Child site

12 | a photograph 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/server.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const express = require("express"); 4 | 5 | const app = express(); 6 | 7 | app.use(express.static("public")); 8 | 9 | const server = { 10 | start: function(port) { 11 | if (port === undefined || !Number.isInteger(port)) { 12 | port = 4000; 13 | } 14 | console.log("Server started at http://localhost:" + port); 15 | console.log("Use Ctrl+C to stop"); 16 | app.listen(port); 17 | } 18 | } 19 | 20 | module.exports = server; -------------------------------------------------------------------------------- /layout/ejs/common/nav.ejs: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /layout/ejs/index/index.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%- include('../common/head.ejs', {page: page}); %> 6 | 7 | <%= page.title %> 8 | 9 | 10 | 11 |
12 | 13 | <%- include('../common/nav.ejs', {config: config}); %> 14 | 15 |
16 | <%- index.content %> 17 |
18 | 19 | <%- include('../common/footer.ejs', {config: config}); %> 20 | 21 |
22 | 23 | 24 | -------------------------------------------------------------------------------- /layout/ejs/page/page.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%- include('../common/head.ejs', {page: page}); %> 6 | 7 | <%= page.title + " - " + config.siteName %> 8 | 9 | 10 | 11 |
12 | 13 | <%- include('../common/nav.ejs', {config: config}); %> 14 | 15 |
16 | <%- page.content %> 17 |
18 | 19 | <%- include('../common/footer.ejs', {config: config}); %> 20 | 21 |
22 | 23 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "float-site-manager", 3 | "version": "1.0.7", 4 | "description": "To manage static sites", 5 | "main": "bin/float-site-manager.js", 6 | "files": [ 7 | "bin", 8 | "lib" 9 | ], 10 | "bin": { 11 | "float-site-manager": "bin/float-site-manager.js" 12 | }, 13 | "dependencies": { 14 | "ejs": "^3.1.6", 15 | "express": "^4.17.1" 16 | }, 17 | "homepage": "https://github.com/floatingblocks/float-site-manager-npm", 18 | "bugs": { 19 | "url": "https://github.com/floatingblocks/float-site-manager-npm/issues" 20 | }, 21 | "author": { 22 | "name": "FloatingBlocks" 23 | }, 24 | "license": "GPL-3.0" 25 | } 26 | -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "siteName": "Float's Site", 3 | "siteURL": "https://example.com", 4 | "year": 2021, 5 | "owner": "Float", 6 | "licenseLink": "https://creativecommons.org/licenses/by-sa/4.0/", 7 | "licenseName": "CC-BY-SA 4.0", 8 | "navs": [ { 9 | "name": "Home", 10 | "link": "/" 11 | }, { 12 | "name": "Categories", 13 | "link": "/categories" 14 | }, { 15 | "name": "Tags", 16 | "link": "/tags" 17 | }, { 18 | "name": "About", 19 | "link": "/about" 20 | } 21 | ], 22 | "deploygit": { 23 | "repo": "https://example.com.git", 24 | "branch": "master" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const generator = require("./generator"); 4 | const sourseManager = require("./sourceManager"); 5 | const server = require("./server"); 6 | const deploygit = require("./deploygit"); 7 | 8 | function main() { 9 | const args = process.argv.slice(2); 10 | switch (args[0]) { 11 | case "generate": 12 | case "g": 13 | generator.renderAll(); 14 | break; 15 | case "server": 16 | case "s": 17 | server.start(args[1]); 18 | break; 19 | case "deploy": 20 | case "d": 21 | deploygit.deploy(); 22 | break; 23 | case "clean": 24 | sourseManager.clean(); 25 | break; 26 | case "new": 27 | sourseManager.newer(args[1], args[2]); 28 | break; 29 | 30 | default: 31 | console.log("Unknown arguments.\nUsage: [generate] [server] [clean] [new ]\nSee ./doc to get more infomations."); 32 | } 33 | } 34 | 35 | module.exports = main; 36 | -------------------------------------------------------------------------------- /layout/src/css/tags.css: -------------------------------------------------------------------------------- 1 | .main-container { 2 | display:flex; 3 | flex-direction: column; 4 | align-items: center; 5 | padding: 1.6em; 6 | } 7 | .tags-tab-links { 8 | margin: 1em; 9 | padding: 1em; 10 | list-style-type: none; 11 | display: flex; 12 | flex-wrap: wrap; 13 | align-items: center; 14 | justify-content: space-around; 15 | } 16 | 17 | .tags-tab-links > li { 18 | display: block; 19 | margin: 1em; 20 | text-align: center; 21 | } 22 | 23 | .tags-tab-link { 24 | padding: 0.5em; 25 | text-decoration: none; 26 | } 27 | 28 | .tags-tab-links { 29 | background-color: #00000000; 30 | border-style: solid; 31 | border-width: 0.2em; 32 | border-color: #0288d1; 33 | border-radius: 0.2em; 34 | } 35 | 36 | 37 | .tags-tab-link { 38 | color: #0288d1; 39 | background-color: #00000000; 40 | border: #0288d1; 41 | border-radius: 0.2em; 42 | transition: background-color 0.8s; 43 | font-size: 1.5em; 44 | } 45 | 46 | .tags-tab-link:hover { 47 | background-color: rgb(179, 229, 252); 48 | } -------------------------------------------------------------------------------- /layout/ejs/tags/tagGuiding.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%- include('../common/head.ejs', {page: page}); %> 6 | 7 | 8 | 9 | <%= page.title + " - " + config.siteName %> 10 | 11 | 12 | 13 |
14 | 15 | <%- include('../common/nav.ejs', {config: config}); %> 16 | 17 |
18 |

标签

19 | 20 |
21 | 29 |
30 |
31 | 32 | <%- include('../common/footer.ejs', {config: config}); %> 33 | 34 |
35 | 36 | -------------------------------------------------------------------------------- /doc/README.md: -------------------------------------------------------------------------------- 1 | # 说明 2 | 3 | 这是我给文档的说明,这个网站的项目就按照这个做了 4 | 5 | ## 组成 6 | 7 | 主要分成主页,索引页和内容页 8 | 9 | 主页展示一些最基础的导航,要试着加上一些看起来比较 geek 的元素,用来炫技 10 | 11 | 索引页有两种:分类页和标签页。这两种都使用卡片的方式展示子连接。 12 | 13 | 其中,分类页是用一个 JS 在同一页面进行不同分类的切换,标签页通过一个标签索引页来导航到不同的标签。 14 | 15 | 内容页也有两种:子页面和子网站。 16 | 17 | 子页面是一个单个 HTML,只有一部分内容,会被放在内容模板的 content 里面。也可以有一些资源文件。 18 | 19 | 子网站就相当于一个独立网站,具有完全的功能 20 | 21 | ## 使用的技术 22 | 23 | 前端是原生的 HTML CSS JS 技术,后端使用 NodeJS 程序加上 ejs 模板进行部署。 24 | 25 | ## 文件结构 26 | 27 | ### infos.json 28 | 29 | 包含很多关于当前页面信息的 json,包括了: 30 | 31 | - type 32 | - name 33 | - auther 34 | - categorie 35 | - tags 36 | - description 37 | - date 38 | 39 | 以后也会可能加上一些新的东西。 40 | 41 | ## 部署流程 42 | 43 | 遍历 source 文件夹的所有文件,对于每个 page 生成对应子目录下的 HTML。 44 | 45 | 按照每个 page 或者 site 的 infos.json 对它属于的归档页面和标签页面进行生成。 46 | 47 | 之后把生成的文件写到 public 文件夹当中,再复制拿些不用生成的文件(page 中除了 HTML 的资源,site 的全部)。 48 | 49 | 把这些文件 hash 都记录到 fileRecord.json 当中。 50 | 51 | 最后,使用 git 对 public 文件夹中的东西进行 push 到对应的 pages 上面。 52 | 53 | ### 更新 54 | 55 | 首先读取所有的文件,判断文件的变更情况(使用一个 fileRecord.json 来记录 src 文件夹中每个文件名和对应的 Hash 值),对于变更或者新增的文件对应的 HTML 和索引都进行更新。具体变化有: 56 | 57 | - public 文件夹下对应 HTML(page.html) 58 | - 对应的标签或者模板(infos.json) 59 | - 或者直接对应的文件(不是前面提到的) 60 | 61 | 接着把新生成的文件覆盖掉 public 文件夹中的对应文件,并且修改 fileRecord.json。 62 | 63 | ## 使用 64 | 65 | 暂且命名为 float-site-manager 。主要命令目前就只有这么几个 66 | 67 | ``` text 68 | float-site-manager new page [name] 69 | float-site-manager new site [name] 70 | float-site-manager generate 71 | float-site-manager clean 72 | float-site-manager deploy 73 | ``` 74 | 75 | generate 就是生成对应的。然后 clean 直接删掉 public 和 fileRecord.json。deploy 是上传到 github。 76 | -------------------------------------------------------------------------------- /layout/ejs/tags/tags.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%- include('../common/head.ejs', {page: page}); %> 6 | 7 | 8 | 9 | <%= page.title + " - " + config.siteName %> 10 | 11 | 12 | 13 |
14 | 15 | <%- include('../common/nav.ejs', {config: config}); %> 16 | 17 |
18 |

<%= tag.name %>

19 |
20 | 37 |
38 | 39 |
40 | 41 | <%- include('../common/footer.ejs', {config: config}); %> 42 | 43 |
44 | 45 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 说明 2 | 3 | 这个项目是在 Github 上面的。见 。 4 | 5 | ## 组成 6 | 7 | 主要分成主页,索引页和内容页 8 | 9 | 主页展示一些最基础的导航,要试着加上一些看起来比较 geek 的元素,用来炫技 10 | 11 | 索引页有两种:分类页和标签页。这两种都使用卡片的方式展示子连接。 12 | 13 | 其中,分类页是用一个 JS 在同一页面进行不同分类的切换,标签页通过一个标签索引页来导航到不同的标签。 14 | 15 | 内容页也有两种:子页面和子网站。 16 | 17 | 子页面是一个单个 HTML,只有一部分内容,会被放在内容模板的 content 里面。也可以有一些资源文件。 18 | 19 | 子网站就相当于一个独立网站,具有完全的功能 20 | 21 | ## 使用的技术 22 | 23 | 前端是原生的 HTML CSS JS 技术,后端使用 NodeJS 程序加上 ejs 模板进行部署。 24 | 25 | ## 文件结构 26 | 27 | ### infos.json 28 | 29 | 包含很多关于当前页面信息的 json,包括了: 30 | 31 | - type 32 | - name 33 | - auther 34 | - categorie 35 | - tags 36 | - description 37 | - date 38 | 39 | 以后也会可能加上一些新的东西。 40 | 41 | ## 部署流程 42 | 43 | 遍历 source 文件夹的所有文件,对于每个 page 生成对应子目录下的 HTML。 44 | 45 | 按照每个 page 或者 site 的 infos.json 对它属于的归档页面和标签页面进行生成。 46 | 47 | 之后把生成的文件写到 public 文件夹当中,再复制拿些不用生成的文件(page 中除了 HTML 的资源,site 的全部)。 48 | 49 | 把这些文件 hash 都记录到 fileRecord.json 当中。 50 | 51 | 最后,使用 git 对 public 文件夹中的东西进行 push 到对应的 pages 上面。 52 | 53 | ### 更新 54 | 55 | 首先读取所有的文件,判断文件的变更情况(使用一个 fileRecord.json 来记录 src 文件夹中每个文件名和对应的 Hash 值),对于变更或者新增的文件对应的 HTML 和索引都进行更新。具体变化有: 56 | 57 | - public 文件夹下对应 HTML(page.html) 58 | - 对应的标签或者模板(infos.json) 59 | - 或者直接对应的文件(不是前面提到的) 60 | 61 | 接着把新生成的文件覆盖掉 public 文件夹中的对应文件,并且修改 fileRecord.json。 62 | 63 | ## 使用 64 | 65 | 暂且命名为 float-site-manager 。主要命令目前就只有这么几个 66 | 67 | ``` text 68 | float-site-manager new page [name] 69 | float-site-manager new site [name] 70 | float-site-manager generate 71 | float-site-manager clean 72 | float-site-manager deploy 73 | ``` 74 | 75 | generate 就是生成对应的。然后 clean 直接删掉 public 和 fileRecord.json。deploy 是上传到 github。 76 | -------------------------------------------------------------------------------- /lib/deploygit.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const child_process = require("child_process"); 4 | const fs = require("fs"); 5 | const extras = require("./extras"); 6 | const configGet = require("./config") 7 | 8 | 9 | const deploygit = { 10 | deploy: function() { 11 | /* 12 | copy public/ to the __deploy/ 13 | cd __deploy 14 | git add . 15 | git commit -m "Update" 16 | git push config.deploygit.repo congig.deploygit.branch -f 17 | */ 18 | const deployDir = "__deploy"; 19 | const config = configGet.getConfig(); 20 | // get an empty dir __deploy/ 21 | if (fs.existsSync(deployDir)) { 22 | extras.rmQuiet(deployDir); 23 | } 24 | fs.mkdirSync(deployDir); 25 | 26 | // copy 27 | if (fs.existsSync("public")) { 28 | extras.copyQuiet("public", deployDir); 29 | } else { 30 | throw new Error("public/ not exsist. Haven't generated?") 31 | } 32 | 33 | child_process.execSync("echo $PWD", { 34 | cwd: deployDir, 35 | stdio:[0, 1, 2] 36 | }) 37 | 38 | // git's action 39 | child_process.execSync("git init", { 40 | cwd: deployDir, 41 | stdio:[0, 1, 2] 42 | }); 43 | 44 | child_process.execSync("git add .", { 45 | cwd: deployDir, 46 | stdio:[0, 1, 2] 47 | }); 48 | 49 | child_process.execSync("git commit -m Update", { 50 | cwd: deployDir, 51 | stdio:[0, 1, 2] 52 | }); 53 | 54 | child_process.execSync(`git push ${config.deploygit.repo} ${config.deploygit.branch} -f`, { 55 | cwd: deployDir, 56 | stdio:[0, 1, 2] 57 | }); 58 | } 59 | }; 60 | 61 | module.exports = deploygit; 62 | -------------------------------------------------------------------------------- /layout/ejs/categories/categories.ejs: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <%- include('../common/head.ejs', {page: page}); %> 6 | 7 | <%= page.title + " - " + config.siteName %> 8 | 9 | 10 | 11 |
12 | 13 | <%- include('../common/nav.ejs', {config: config}); %> 14 | 15 |
16 |
17 | 29 |
30 |
31 | 48 |
49 |
50 | 51 | <%- include('../common/footer.ejs', {config: config}); %> 52 | 53 |
54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /lib/sourceManager.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const fs = require("fs"); 4 | const path = require("path"); 5 | const ejs = require("ejs"); 6 | const config = require("./config"); 7 | const extras = require("./extras"); 8 | 9 | const sourceManager = { 10 | 11 | getInfosTemplete: function(type, name) { 12 | // Waiting 13 | return `{ 14 | "type": "${type}", 15 | "title": "${name}", 16 | "auther": "", 17 | "category": "", 18 | "tags": [""], 19 | "description": "", 20 | "date": "${new Date().toISOString().split("T")[0]}" 21 | }`; 22 | }, 23 | 24 | clean: function() { 25 | // just delete rendered files 26 | extras.rm("public"); 27 | extras.rm("source/fileRecord.json"); 28 | }, 29 | 30 | newer: function(type, name) { 31 | /* 32 | type: "page" || "site", name: "" 33 | */ 34 | if (type === undefined) { 35 | throw new Error("Type not given."); 36 | } 37 | if (name === undefined) { 38 | throw new Error("Name not given"); 39 | } 40 | const infos = this.getInfosTemplete(type, name); 41 | let index = ""; 42 | if (type === "site") { 43 | const ejsTemptele = fs.readFileSync("layout/ejs/page/page.ejs", "utf-8"); 44 | index = ejs.render(ejsTemptele, { 45 | page: { 46 | title: name, 47 | content: ` 48 | 49 |

${name}

50 | ` 51 | }, 52 | config: config.getConfig(), 53 | }, { 54 | filename: "layout/ejs/page/page.ejs" 55 | }); 56 | } else if (type === "page") { 57 | index = "\n

" + name + "

\n"; 58 | } else { 59 | throw new Error("Unknown type: " + type); 60 | } 61 | 62 | if (!fs.existsSync(path.join("source", name))) { 63 | fs.mkdirSync(path.join("source", name), { recursive: true }); 64 | fs.writeFileSync(path.join("source", name, "index.html"), index); 65 | fs.writeFileSync(path.join("source", name, "infos.json"), infos); 66 | } else { 67 | throw new Error("Failed: " + path.join("source", name) + " Already exsist"); 68 | } 69 | } 70 | }; 71 | 72 | module.exports = sourceManager; 73 | -------------------------------------------------------------------------------- /layout/src/css/mainstyle.css: -------------------------------------------------------------------------------- 1 | /* Layout begin::*/ 2 | .site-nav { 3 | /*flex-grow: 1;*/ 4 | display: flex; 5 | margin-left: auto; 6 | margin-right: auto; 7 | width: 60em; 8 | padding: 0.5em 2em 0.5em 2em; 9 | border-radius: 0.8em; 10 | 11 | top: 0; 12 | position: fixed; 13 | } 14 | 15 | .main { 16 | margin: 0 auto; 17 | display: flex; 18 | flex-direction: column; 19 | width: 64em; 20 | } 21 | 22 | .main-menu { 23 | padding: 0; 24 | display: flex; 25 | list-style-type: none; 26 | margin: 0; 27 | margin-left: auto; 28 | } 29 | 30 | .site-meta a { 31 | font-size: 1.5em; 32 | font-weight: bold; 33 | } 34 | 35 | .main-menu li { 36 | /*margin: 0em 0em 1em 1em;*/ 37 | border-radius: 10px; 38 | padding: 1px 4px; 39 | } 40 | 41 | .main-menu a { 42 | border-radius: 2px; 43 | padding: 0.6rem; 44 | text-decoration:none; 45 | } 46 | 47 | .main-container { 48 | margin-top: 4.5em; 49 | min-height: 48em; 50 | min-height: calc(100vh - 10.5em); 51 | overflow: auto; 52 | border-radius: 0.8em; 53 | padding: 1em; 54 | padding-left: 2.3em; 55 | padding-right: 2.3em; 56 | } 57 | 58 | .footer { 59 | margin-top: 2em; 60 | text-align: center; 61 | flex: 1; 62 | } 63 | 64 | @media (max-width: 64em) { 65 | .site-nav { 66 | margin: 0; 67 | width: 90%; 68 | width: calc(100% - 5em); 69 | } 70 | .main { 71 | width: 100%; 72 | } 73 | } 74 | @media (max-width: 500px) { 75 | .site-title { 76 | display: none; 77 | } 78 | .main-menu { 79 | margin-left: 0; 80 | } 81 | .site-nav { 82 | padding: 0.5em 0 0.5em 0; 83 | margin: 0; 84 | border-radius: 0.8em; 85 | position: static; 86 | width: 100%; 87 | } 88 | .main-container { 89 | margin-top: 0.5em; 90 | } 91 | } 92 | /* Layout end::*/ 93 | 94 | /* colors begin::*/ 95 | body { 96 | background-color: #48e4ef; 97 | background: linear-gradient(to top, #48e4ef 0%, rgb(119, 182, 218) 100%); 98 | } 99 | 100 | .site-nav { 101 | background-color: rgba(245, 245, 245, 0.8); 102 | box-shadow: 0 0px 0.6px rgba(0, 0, 0, 0.028), 0 0px 1.3px rgba(0, 0, 0, 0.04), 0 0px 2.5px rgba(0, 0, 0, 0.05), 0 0px 4.5px rgba(0, 0, 0, 0.06), 0 0px 8.4px rgba(0, 0, 0, 0.072), 0 0px 20px rgba(0, 0, 0, 0.1); 103 | } 104 | .site-meta a { 105 | color: rgb(0, 0, 0); 106 | text-shadow: 1px 1px 0 rgba(0, 0, 0, .1); 107 | } 108 | 109 | .main-menu li { 110 | text-shadow: 1px 1px 0 rgba(0, 0, 0, .1); 111 | } 112 | 113 | .main-menu a { 114 | color: #0288d1; 115 | transition: background-color 0.8s; 116 | } 117 | 118 | .main-menu a:hover { 119 | background-color: #b3e5fc; 120 | } 121 | 122 | .main-container { 123 | background-color: rgba(245, 245, 245, 0.900); 124 | box-shadow: 0 0px 0.6px rgba(0, 0, 0, 0.028), 0 0px 1.3px rgba(0, 0, 0, 0.04), 0 0px 2.5px rgba(0, 0, 0, 0.05), 0 0px 4.5px rgba(0, 0, 0, 0.06), 0 0px 8.4px rgba(0, 0, 0, 0.072), 0 0px 20px rgba(0, 0, 0, 0.1); 125 | } 126 | 127 | .footer { 128 | text-shadow: 1px 1px 0 rgba(0, 0, 0, .1); 129 | } 130 | /* colors end::*/ -------------------------------------------------------------------------------- /layout/src/css/artical.css: -------------------------------------------------------------------------------- 1 | /* from https://github.com/markdowncss/modest*/ 2 | /* markdown css begin::*/ 3 | @media print { 4 | *, 5 | *:before, 6 | *:after { 7 | background: transparent !important; 8 | color: #000 !important; 9 | box-shadow: none !important; 10 | text-shadow: none !important; 11 | } 12 | 13 | a, 14 | a:visited { 15 | text-decoration: underline; 16 | } 17 | 18 | a[href]:after { 19 | content: " (" attr(href) ")"; 20 | } 21 | 22 | abbr[title]:after { 23 | content: " (" attr(title) ")"; 24 | } 25 | 26 | a[href^="#"]:after, 27 | a[href^="javascript:"]:after { 28 | content: ""; 29 | } 30 | 31 | pre, 32 | blockquote { 33 | border: 1px solid #999; 34 | page-break-inside: avoid; 35 | } 36 | 37 | thead { 38 | display: table-header-group; 39 | } 40 | 41 | tr, 42 | img { 43 | page-break-inside: avoid; 44 | } 45 | 46 | img { 47 | max-width: 100% !important; 48 | } 49 | 50 | p, 51 | h2, 52 | h3 { 53 | orphans: 3; 54 | widows: 3; 55 | } 56 | 57 | h2, 58 | h3 { 59 | page-break-after: avoid; 60 | } 61 | } 62 | 63 | pre, 64 | code { 65 | font-family: Menlo, Monaco, "Courier New", monospace; 66 | } 67 | 68 | pre { 69 | padding: .5rem; 70 | line-height: 1.25; 71 | overflow-x: scroll; 72 | } 73 | 74 | a, 75 | a:visited { 76 | color: #3498db; 77 | } 78 | 79 | a:hover, 80 | a:focus, 81 | a:active { 82 | color: #2980b9; 83 | } 84 | 85 | .modest-no-decoration { 86 | text-decoration: none; 87 | } 88 | 89 | html { 90 | font-size: 12px; 91 | } 92 | 93 | @media screen and (min-width: 32rem) and (max-width: 48rem) { 94 | html { 95 | font-size: 15px; 96 | } 97 | } 98 | 99 | @media screen and (min-width: 48rem) { 100 | html { 101 | font-size: 16px; 102 | } 103 | } 104 | 105 | body { 106 | line-height: 1.85; 107 | } 108 | 109 | p, 110 | .modest-p { 111 | font-size: 1rem; 112 | margin-bottom: 1.3rem; 113 | } 114 | 115 | h1, 116 | .modest-h1, 117 | h2, 118 | .modest-h2, 119 | h3, 120 | .modest-h3, 121 | h4, 122 | .modest-h4 { 123 | margin: 1.414rem 0 .5rem; 124 | font-weight: inherit; 125 | line-height: 1.42; 126 | } 127 | 128 | h1, 129 | .modest-h1 { 130 | margin-top: 0; 131 | font-size: 2.827rem; 132 | } 133 | 134 | h2, 135 | .modest-h2 { 136 | font-size: 1.999rem; 137 | } 138 | 139 | h3, 140 | .modest-h3 { 141 | font-size: 1.414rem; 142 | } 143 | 144 | h4, 145 | .modest-h4 { 146 | font-size: 1.121rem; 147 | } 148 | 149 | h5, 150 | .modest-h5 { 151 | font-size: .88rem; 152 | } 153 | 154 | h6, 155 | .modest-h6 { 156 | font-size: .80rem; 157 | } 158 | 159 | small, 160 | .modest-small { 161 | font-size: .707em; 162 | } 163 | 164 | /* https://github.com/mrmrs/fluidity */ 165 | 166 | img, 167 | canvas, 168 | iframe, 169 | video, 170 | svg, 171 | select, 172 | textarea { 173 | max-width: 100%; 174 | } 175 | 176 | html { 177 | font-size: 18px; 178 | max-width: 100%; 179 | } 180 | 181 | body { 182 | color: #3f3f3f; 183 | font-family: sans-serif; 184 | font-weight: 300; 185 | margin: 0 auto; 186 | line-height: 1.45; 187 | } 188 | 189 | h1, 190 | h2, 191 | h3, 192 | h4, 193 | h5, 194 | h6 { 195 | font-family: Arimo, Helvetica, sans-serif; 196 | } 197 | 198 | h1, 199 | h2, 200 | h3 { 201 | border-bottom: 2px solid #fafafa; 202 | margin-bottom: 1.15rem; 203 | padding-bottom: .5rem; 204 | text-align: center; 205 | } 206 | 207 | blockquote { 208 | border-left: 8px solid #fafafa; 209 | padding: 1rem; 210 | } 211 | 212 | pre, 213 | code { 214 | background-color: #fafafa; 215 | } 216 | /* markdown css end::*/ -------------------------------------------------------------------------------- /layout/src/css/works.css: -------------------------------------------------------------------------------- 1 | /*layout begin::*/ 2 | 3 | .main-container { 4 | display:flex; 5 | flex-direction: column; 6 | align-items: center; 7 | padding: 1.6em; 8 | } 9 | 10 | .paging-area { 11 | margin-top: auto; 12 | } 13 | 14 | .categories-tab-links { 15 | list-style: none; 16 | margin: 0; 17 | margin-top: 1em; 18 | padding: 0.1em; 19 | border-radius: 0.5em; 20 | display: flex; 21 | } 22 | 23 | .categories-tab-link { 24 | margin: 0.1em; 25 | width: 4em; 26 | padding-top: 0.2em; 27 | padding-bottom: 0.2em; 28 | display: block; 29 | text-align: center; 30 | } 31 | 32 | .categories-tab-link{ 33 | text-decoration:none; 34 | } 35 | 36 | .categories-tab-contents { 37 | list-style: none; 38 | padding: 2em; 39 | } 40 | 41 | .displayed-contents { 42 | margin:0; 43 | margin-top: 2em; 44 | padding:0; 45 | list-style-type: none; 46 | display: grid; 47 | grid-template-columns: 1fr 1fr 1fr; 48 | grid-gap: 1.5em; 49 | flex-wrap: wrap; 50 | width: 100%; 51 | } 52 | 53 | .displayed-content { 54 | padding: 0.5em; 55 | display: flex; 56 | width: 16em; 57 | height: 10em; 58 | border-radius: 0.8em; 59 | } 60 | 61 | .content-title { 62 | margin: 0; 63 | margin-left: 0.2em; 64 | } 65 | 66 | .content-description, 67 | .content-infos { 68 | margin: 0; 69 | margin-left: 0.6em; 70 | } 71 | 72 | .displayed-content > a{ 73 | display:flex; 74 | flex-direction:column; 75 | } 76 | 77 | .content-infos { 78 | margin-top:auto; 79 | margin-bottom: 0.2em; 80 | display: flex; 81 | } 82 | 83 | .content-infos > span { 84 | margin-right: 0.5em; 85 | } 86 | 87 | .content-infos > .push { 88 | margin-right: 0em; 89 | margin-left: auto; 90 | } 91 | 92 | @media (max-width: 60em) { 93 | .displayed-contents { 94 | grid-template-columns: 1fr 1fr; 95 | } 96 | } 97 | 98 | @media (max-width: 40em) { 99 | .displayed-contents { 100 | grid-template-columns: 1fr; 101 | } 102 | } 103 | 104 | /*layout end:: */ 105 | 106 | /*style begin::*/ 107 | .categories-tab-links { 108 | background-color: rgba(166, 208, 228, 0.8); 109 | } 110 | 111 | .categories-tab-link { 112 | color: #0288d1; 113 | background-color: #00000000; 114 | border: #0288d1; 115 | border-radius: 0.2em; 116 | transition: background-color 0.8s; 117 | font-size: 1.5em; 118 | } 119 | 120 | .categories-tab-link.active, .categories-tab-link:hover { 121 | background-color: rgb(179, 229, 252); 122 | } 123 | 124 | @keyframes content-show { 125 | from {opacity: 0;} 126 | to {opacity: 1;;} 127 | } 128 | 129 | .categories-tab-content.active { 130 | animation-name: content-show; 131 | animation-duration: 0.8s; 132 | } 133 | 134 | .displayed-content { 135 | background-color: rgba(245, 245, 245, 0); 136 | box-shadow: 0px 0px 0.1em 0.1em rgba(179, 229, 252, 0.8); 137 | transition: background-color 0.5s; 138 | } 139 | 140 | .displayed-content:hover { 141 | background-color: rgba(179, 229, 252, 0.8); 142 | } 143 | 144 | .displayed-content > a { 145 | color: #222; 146 | text-decoration: none; 147 | } 148 | 149 | .displayed-content > a:hover { 150 | color: #000; 151 | } 152 | 153 | .content-infos { 154 | font-size: smaller; 155 | } 156 | /*style end::*/ 157 | 158 | /*Mobile begin::*/ 159 | @media (max-width: 28em) { 160 | .main-container { 161 | display:block; 162 | align-items: center; 163 | } 164 | .displayed-content { 165 | height: 7em; 166 | width: 90%; 167 | padding: 0; 168 | margin: auto; 169 | } 170 | .categories-tab-links { 171 | margin: 0; 172 | margin-top: 1em; 173 | padding: auto; 174 | display: flex; 175 | } 176 | .categories-tab-link { 177 | font-size: 1.2em; 178 | width: auto; 179 | padding: 0.2em; 180 | } 181 | .displayed-contents { 182 | display: flex; 183 | flex-direction: column; 184 | justify-items: center; 185 | width: 100%; 186 | } 187 | } 188 | /*Mobile end::*/ 189 | -------------------------------------------------------------------------------- /lib/extras.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const fs = require("fs"); 4 | const path = require("path"); 5 | 6 | const extras = { 7 | 8 | rm: function (Path) { 9 | function deleteFolderOrFileRecursive(directoryPath) { 10 | if (fs.existsSync(directoryPath)) { 11 | try { 12 | const stat = fs.statSync(directoryPath); 13 | if (stat.isFile()) { 14 | fs.unlinkSync(directoryPath); 15 | } else { 16 | fs.readdirSync(directoryPath).forEach((file, index) => { 17 | const curPath = path.join(directoryPath, file); 18 | if (fs.lstatSync(curPath).isDirectory()) { 19 | // recurse 20 | deleteFolderOrFileRecursive(curPath); 21 | } else { 22 | // delete file 23 | console.log("Deleted " + curPath); 24 | fs.unlinkSync(curPath); 25 | } 26 | }); 27 | console.log("Deleted " + directoryPath); 28 | fs.rmdirSync(directoryPath); 29 | } 30 | } catch (err) { 31 | throw err; 32 | } 33 | } 34 | } 35 | function deleteEmpty(dirPath) { 36 | try { 37 | fs.rmdirSync(dirPath); 38 | } catch (err) { 39 | return; 40 | } 41 | // delete success, dir is empty 42 | deleteEmpty(path.dirname(dirPath)); 43 | } 44 | deleteFolderOrFileRecursive(Path); 45 | deleteEmpty(path.dirname(Path)); 46 | }, 47 | 48 | rmQuiet: function (Path) { 49 | function deleteFolderOrFileRecursive(directoryPath) { 50 | if (fs.existsSync(directoryPath)) { 51 | try { 52 | const stat = fs.statSync(directoryPath); 53 | if (stat.isFile()) { 54 | fs.unlinkSync(directoryPath); 55 | } else { 56 | fs.readdirSync(directoryPath).forEach((file, index) => { 57 | const curPath = path.join(directoryPath, file); 58 | if (fs.lstatSync(curPath).isDirectory()) { 59 | // recurse 60 | deleteFolderOrFileRecursive(curPath); 61 | } else { 62 | // delete file 63 | fs.unlinkSync(curPath); 64 | } 65 | }); 66 | fs.rmdirSync(directoryPath); 67 | } 68 | } catch (err) { 69 | throw err; 70 | } 71 | } 72 | } 73 | function deleteEmpty(dirPath) { 74 | try { 75 | fs.rmdirSync(dirPath); 76 | } catch (err) { 77 | return; 78 | } 79 | // delete success, dir is empty 80 | deleteEmpty(path.dirname(dirPath)); 81 | } 82 | deleteFolderOrFileRecursive(Path); 83 | deleteEmpty(path.dirname(Path)); 84 | }, 85 | 86 | 87 | copy: function(source_, target_) { 88 | function copyFolderRecursiveSync(source, target) { 89 | 90 | if (!fs.existsSync(target)) { 91 | fs.mkdirSync(target); 92 | } 93 | if (fs.lstatSync(source).isDirectory()) { 94 | const files = fs.readdirSync(source); 95 | files.forEach(function (file) { 96 | const curSource = path.join(source, file); 97 | const targetNext = path.join(target, file); 98 | if (fs.lstatSync(curSource).isDirectory()) { 99 | copyFolderRecursiveSync(curSource, targetNext); 100 | } else { 101 | fs.copyFileSync(curSource, targetNext); 102 | } 103 | }); 104 | } 105 | } 106 | if (fs.lstatSync(source_).isFile()) { 107 | fs.copyFileSync(source_, target_); 108 | } else { 109 | copyFolderRecursiveSync(source_, target_); 110 | } 111 | console.log("Copyed " + source_ + " to " + target_ ); 112 | }, 113 | 114 | copyQuiet: function(source_, target_) { 115 | function copyFolderRecursiveSync(source, target) { 116 | 117 | if (!fs.existsSync(target)) { 118 | fs.mkdirSync(target); 119 | } 120 | if (fs.lstatSync(source).isDirectory()) { 121 | const files = fs.readdirSync(source); 122 | files.forEach(function (file) { 123 | const curSource = path.join(source, file); 124 | const targetNext = path.join(target, file); 125 | if (fs.lstatSync(curSource).isDirectory()) { 126 | copyFolderRecursiveSync(curSource, targetNext); 127 | } else { 128 | fs.copyFileSync(curSource, targetNext); 129 | } 130 | }); 131 | } 132 | } 133 | if (fs.lstatSync(source_).isFile()) { 134 | fs.copyFileSync(source_, target_); 135 | } else { 136 | copyFolderRecursiveSync(source_, target_); 137 | } 138 | } 139 | 140 | }; 141 | 142 | module.exports = extras; -------------------------------------------------------------------------------- /doc/USAGE.md: -------------------------------------------------------------------------------- 1 | # 使用方式 2 | 3 | ## 前言 4 | 5 | 反正又不是啥正经项目,文档写的规规整整也没啥意思,搞得大家看到烦。不如整点烂活,写成古里古怪的样子,争取让大家笑一下。 6 | 7 | 本文中的人物并没有现实中的对应,当然你硬要无端联想我只能说个人自由。 8 | 9 | 教程是这个项目自己的,如果需要给 yjzx-site 发文章要看那边的教程有关的特殊说明。 10 | 11 | 写文章好累,难怪大多项目文档都这么烂。 12 | 13 | 情节其实已经完了,但是我要把情节改到逻辑自洽了再放上来。 14 | 15 | ## 正文 16 | 17 | ### 引子 18 | 19 | 一日, {{ajun}} …… 20 | 21 | {此处应该有情节。} 22 | 23 | 过去了两个星期,{{ajun}}快要忘记这茬了,没想到某企鹅上面亮了个红点,是那人发的: 24 | 25 | “你说的那个项目,我已经写好了,要不你试试看?” 26 | 27 | “打开 就可以看到我那个网站的成品了。是相应式布局的,你的手机应该也能正常显示” 28 | 29 | “我本来想着能一个星期写完的,结果还是高估自己了,不过好在也没拖太久” 30 | 31 | “后端是拿 NodeJS 搞的一个简易的部署工具。没时间写文档了,待会你在线了我再告诉你怎么用” 32 | 33 | 怀揣着惊讶,{{ajun}}打开了这个网站,发现果然是一个完整的网站,首先是主页。他点开了上面导航栏里面的 “分类” ,看见里面陈列着几篇测试页面的导航,按照各自的归档分着类。每个页面按照卡片形式展示,有一些基础的信息。点开来是各个页面。“标签”也是一样。虽然很简单,但是也能足够让他震惊到了。 34 | 35 | {这里似乎需要一点感谢的话,可惜我一时想不出。两者风格应该不一样,不然明显双簧戏。,大括号包裹的是 {{ajun}} 的回话,我决定找另一个人表述。} 36 | 37 | “只是举手之劳而已,毕竟我也好久没写什么正经程序了,你这也算是给我创造一个展现的机会嘛” 38 | 39 | “好了,废话不多说,我现在要告诉你这个怎么用了,{{ajun}}” 40 | 41 | ### 安装篇 42 | 43 | “你的系统应该是 Windows 吧。” 44 | 45 | {是的} 46 | 47 | “那好,你先搭一个运行环境吧。就装个 Git 和 NodeJS 就行了。” 48 | 49 | “因为东方的神秘法术,现在访问 Github 和 Npm 有点困难,所以你可能需要施法对抗。下个 [dev-sidecar](https://gitee.com/docmirror/dev-sidecar/releases) ,然后安装上。” 50 | 51 | {打开了} 52 | 53 | “安装好了之后,打开,点那个安装证书,应该就可以用上了吧。有啥问题看下那边的文档。” 54 | 55 | {好了} 56 | 57 | “那么接下来你就可以装 [Git](https://git-scm.com/) 和 [NodeJS](https://nodejs.org/zh-cn/) 了。” 58 | 59 | “Git 直接点这个下载就能用了 。” 60 | 61 | “NodeJS 的话,Windows 8 以上是可以直接用官网上面最新版的。Windows 7 我找到了 13.14 版本的,是可以正常使用的最后一个版本了 。” 62 | 63 | {版本号好奇怪(此处表情,作者注)} 64 | 65 | “应该是缘分吧(此处表情,作者注)” 66 | 67 | “好了,不浪费你时间。安装什么就的无脑下一步吧,看不懂的不要乱改,安装路径啥最好也别动。免得出什么问题。” 68 | 69 | {OK,装好了。} 70 | 71 | “好啦,现在你已经有了完整的运行环境了。” 72 | 73 | “随便打开一个文件夹,右键,打开 git bash,然后按顺序输入下面的几条命令:” 74 | 75 | ``` sh 76 | # 因为先前使用了 dev sidecar,这里需要暂时关掉证书认证 77 | git config --global http.sslverify false 78 | 79 | # 下载一些资源文件 80 | git clone https://github.com/floatingblocks/float-site-manager.git 81 | ``` 82 | 83 | {运行了,下好了} 84 | 85 | “现在你应该可以再这个目录下面看到一个叫做 float-site-manager 的文件夹了吧。使用 VSCode 打开那个文件夹,然后再在 VSCode 里面按下 Ctrl+Shift+\` 打开命令行,输入下面的内容,安装我的网站管理程序:” 86 | 87 | ``` sh 88 | # npm 会自动安装好需要的程序 89 | npm install 90 | ``` 91 | 92 | ### 使用篇 93 | 94 | “安装好了之后应该就可以使用了。” 95 | 96 | {那我要怎么用它} 97 | 98 | “里面有一些测试页面,你可以先试着本地跑下服务看看是不是正常的。” 99 | 100 | ``` sh 101 | # 命令格式 npx float-site-manager [参数] 102 | 103 | # 从源文件渲染好整个网站 104 | npx float-site-manager g 105 | 106 | # 打开测试服务器,然后就可以在浏览器打开 http://localhost:4000 预览 107 | npx float-site-manager s 108 | ``` 109 | 110 | “如果一切正常的话,打开 就能看到预览网页了。” 111 | 112 | {预览网页是开起来了,一切正常。具体操作又是如何呢?比如说怎么添加页面?} 113 | 114 | “你可以用 new 命令生成对应的文件嘛,生成一个页面对应的文件。命令的格式是这样:” 115 | 116 | ``` sh 117 | npx float-site-manager [页面类型] [页面名称] 118 | ``` 119 | 120 | “页面类型目前是两个选项,一个是 page,它的 index.html 是只有正文内容的,渲染的时候就会把其中的内容复制到中间那一块正文区域里面去。这个是最常用的。” 121 | 122 | “另一个选项是 site,它的 index.html 是个完整的 HTML,相当于一个子网站,如果需要高自由度自定义的话可以用上。” 123 | 124 | “比如我们要生成一个 page,名字叫做 PageA,或者生成一个 site 叫做 site1:” 125 | 126 | ``` sh 127 | npx float-site-manager new page PageA 128 | npx float-site-manager new site site1 129 | ``` 130 | 131 | “之后你应该就可以看到 source 文件夹下面多出来一些文件夹,目录结构大概是这样:” 132 | 133 | ``` text 134 | - source/ 135 | - PageA/ 136 | - index.html 137 | - infos.json 138 | - site1/ 139 | - index.html 140 | - infos.json 141 | ``` 142 | 143 | {是的,但是接下来要怎么做?} 144 | 145 | “这样的话,每个文件夹都是一个对应的页面了。其中 index.html 是页面的主页,infos.json 则包含了页面的一些信息,是管理这个网站的重要部分。infos.json 里面的信息是不会显示在页面中的,但是它会显示在“归档”,“标签”之类的导航页里面,所以非常非常重要。” 146 | 147 | “我们先看看 infos.json 吧,打开来应该能看到这个东西:” 148 | 149 | ``` json 150 | { 151 | "type": "page", 152 | "title": "PageA", 153 | "auther": "", 154 | "category": "", 155 | "tags": [""], 156 | "description": "", 157 | "date": "2021-12-05" 158 | } 159 | ``` 160 | 161 | {看到了,要怎么用?} 162 | 163 | “这里面的 type title 和 date 都已经自动填充好了,一般不用改。” 164 | 165 | “auther 是作者,显示在信息里面,比如你的名字是{{ajun}}, 那么就可以写成 "auther": "{{ajun}}"。” 166 | 167 | “ category 的意思是分类,页面属于什么分类,主要用作分类页面的导航。” 168 | 169 | “当然分类的粒度比较大,最好还是加上一些 tags,比如要加上 tag A 和 B,就可以这么写: "tags": ["A", "B"]。这里可以使用 tag 进行导航。” 170 | 171 | “最好加上一点点对于这个页面写了什么的简易介绍,就是 description,讲下这个页面是什么。下面就是一个例子:” 172 | 173 | ``` json 174 | { 175 | "type": "page", 176 | "title": "我是标题", 177 | "auther": "王大锤", 178 | "category": "测试", 179 | "tags": [ 180 | "测试", 181 | "真的只是测试" 182 | ], 183 | "description": "一个非常简单的测试页面", 184 | "date": "2077-07-07" 185 | } 186 | ``` 187 | 188 | {现在 infos.json 我算是知道了,不过页面怎么做。} 189 | 190 | “接下来自然是 index.html 了。对于 page 类型,这里面是只有正文的内容,比如这样:” 191 | 192 | ``` html 193 |

标题

194 |

第一段内容.

195 |

第二段内容.

196 | ``` 197 | 198 | “而不是这样:” 199 | 200 | ``` html 201 | 202 | 203 | 204 | Document 205 | 206 | 207 |

标题

208 |

第一段内容.

209 |

第二段内容.

210 | 211 | 212 | ``` 213 | 214 | {为什么要这样子呢?} 215 | 216 | “因为这样子,渲染的时候就会自动填充进页面里面去。如果要对页面的模板进行改动,就不需要一个一个页面改过来了。” 217 | 218 | {如果我想要加入一些资源,比如图片,要怎么办?} 219 | 220 | “直接往里面加就好了嘛,一个文件夹就相当于一个子网站,里面的所有其他文件都会被直接复制到渲染好的网站的对应目录下面,所以你要给 PageA 加上图片的话,直接用 img 标签就行了。” 221 | 222 | “假设目录结构如下:” 223 | 224 | ``` text 225 | - source/ 226 | - PageA/ 227 | - img.png 228 | - index.html 229 | - infos.json 230 | ``` 231 | 232 | “ HTML 就可以写成这样” 233 | 234 | ``` html 235 | a photograph 236 | ``` 237 | 238 | {如果我的页面不使用网站的默认模板,是不是最好要选择 site 类型?} 239 | 240 | “对了,不然我写这东西干嘛。自定义程度很高的需求就需要这样了。site 类型下面,除了 infos.json,其他的都可以当成是一个完整的网站来看待。” 241 | 242 | {假如我已经搞好了页面,下一步怎么做?} 243 | 244 | “肯定是生成+测试啊。最后再部署上去。” 245 | 246 | “因为现在整个网站还是源码阶段,就是都在 source 文件夹里面,所以需要渲染成一个完整可用的网站。这个过程是自动化的,你只要一条命令就可以了。完成之后你可以看到一个 public 文件夹,里面就是渲染好了的文件。source 目录下面也会多出来一个 fileRecord.json。生成出来的文件最好别动。” 247 | 248 | ``` sh 249 | npx float-site-manager g 250 | ``` 251 | 252 | {输出了一大堆东西,不过文件夹倒是有了。} 253 | 254 | “输出啥的不用管他,只是为了说明它在正常运行。” 255 | 256 | “现在运行一下网站测试它吧。跑一跑下面的命令。然后打开 ,应该就能看到页面跑起来了。” 257 | 258 | {对,成了。} 259 | 260 | ### 配置篇 261 | 262 | “不过,现在网站的基本信息还是默认的。你可能要自己去改 config.json。打开来,你看到下面的内容” 263 | 264 | ``` json 265 | { 266 | "siteName": "Float's Site", 267 | "siteURL": "https://example.com", 268 | "year": 2021, 269 | "owner": "Float", 270 | "licenseLink": "https://creativecommons.org/licenses/by-sa/4.0/", 271 | "licenseName": "CC-BY-SA 4.0", 272 | "navs": [ { 273 | "name": "主页", 274 | "link": "/" 275 | }, { 276 | "name": "分类看到了out" 277 | } 278 | ], 279 | "deploygit": { 280 | "repo": "https://github.com/yjzx-site/yjzx-site.github.io.git", 281 | "branch": "master" 282 | } 283 | } 284 | ``` 285 | 286 | “siteName 是网站的标题,显示在左上角和页面标题中的那个。” 287 | 288 | “siteURL 目前没用,一般放上网站的主页连接。” 289 | 290 | “year 显示在网站的最下方。licenseLink 和 licenseName 说明当前网站用的是什么协议。我默认是直接 CC-BY-SA 了,也可以换成别的。” 291 | 292 | “navs 是导航栏里面的项目连接和名称。” 293 | 294 | “deploygit 是部署到 Github Pages 上面的时候用的,等会再提。” 295 | 296 | “现在你按照自己的信息改下里面的内容” 297 | 298 | {我改好了。} 299 | 300 | “现在网站需要重新生成一下了。因为改了总配置,所以需要先清空之前生成过的文件。当然在 source 文件夹下面改文件是不需要这么做的。” 301 | 302 | ``` sh 303 | # 清空生成过的文件 304 | npx float-site-manager clean 305 | 306 | # 生成文件 307 | npx float-site-manager g 308 | 309 | # 运行测试服务器 310 | npx float-site-manager s 311 | ``` 312 | 313 | “打开 ,现在你的信息是不是改过来了?” 314 | 315 | {是的,我看到了。看起来还挺容易的。} 316 | 317 | ### 部署篇 318 | 319 | “OK,到最后一步了。我们的网站需要部署起来。” 320 | 321 | “因为没钱买服务器,加上这个网站也是简单的静态网站,我就推荐你用 Github Pages 好了。” 322 | 323 | “你之前应该没用过 Github Pages 吧。” 324 | 325 | {我怎么会用过呢?} 326 | 327 | “好吧,不过 Github 帐号总是有的吧。” 328 | 329 | {那肯定,毕竟还是写过那么一点点程序的。} 330 | 331 | “OK,你新建一个仓库,名字 `[你的用户名].github.io` , 比如用户名 user123,就是 user123.github.io。” 332 | 333 | {新建完成了。} 334 | 335 | “接下来好办,打开 config.json,把 deploygit 选项的 url 换成你的仓库的地址。branch 就先不要动好了。” 336 | 337 | “如果你没有初始化 git 的话,你就可能需要加入一个用户:” 338 | 339 | ``` sh 340 | git config --global user.name "一个名字" 341 | git config --global user.email "自己的邮箱@邮箱.com" 342 | ``` 343 | 344 | “接着运行这个命令,按照提示操作,就可以部署上了” 345 | 346 | ``` sh 347 | npx float-site-manager d 348 | ``` 349 | 350 | “当然现在 Github 不允许你使用密码登录 git,你可能需要自己创建一个 Personal Acess Token。具体百度吧,我有点累了。” 351 | 352 | {行得行得,我慢慢研究。} 353 | 354 | ### 尾声 355 | 356 | {没想到我这个东西你还能帮忙做出来。} 357 | 358 | “小事小事,帮你忙了,我也高兴。” 359 | 360 | {好了,现在时间也不早了,下次再聊。} 361 | 362 | “嗯嗯” 363 | 364 | {此处还有一点小小的情节,呼应开头,回头润色一下} 365 | -------------------------------------------------------------------------------- /layout/src/css/csshake.css: -------------------------------------------------------------------------------- 1 | /*! * * * * * * * * * * * * * * * * * * * *\ 2 | CSShake :: Package 3 | v1.5.0 4 | CSS classes to move your DOM 5 | (c) 2015 @elrumordelaluz 6 | http://elrumordelaluz.github.io/csshake/ 7 | Licensed under MIT 8 | \* * * * * * * * * * * * * * * * * * * * */.shake,.shake-little,.shake-slow,.shake-hard,.shake-horizontal,.shake-vertical,.shake-rotate,.shake-opacity,.shake-crazy,.shake-chunk{display:inherit;transform-origin:center center}.shake-freeze,.shake-constant.shake-constant--hover:hover,.shake-trigger:hover .shake-constant.shake-constant--hover{animation-play-state:paused}.shake-freeze:hover,.shake-trigger:hover .shake-freeze,.shake:hover,.shake-trigger:hover .shake,.shake-little:hover,.shake-trigger:hover .shake-little,.shake-slow:hover,.shake-trigger:hover .shake-slow,.shake-hard:hover,.shake-trigger:hover .shake-hard,.shake-horizontal:hover,.shake-trigger:hover .shake-horizontal,.shake-vertical:hover,.shake-trigger:hover .shake-vertical,.shake-rotate:hover,.shake-trigger:hover .shake-rotate,.shake-opacity:hover,.shake-trigger:hover .shake-opacity,.shake-crazy:hover,.shake-trigger:hover .shake-crazy,.shake-chunk:hover,.shake-trigger:hover .shake-chunk{animation-play-state:running}@keyframes shake{2%{transform:translate(1.5px, -1.5px) rotate(-.5deg)}4%{transform:translate(-1.5px, -.5px) rotate(1.5deg)}6%{transform:translate(1.5px, 2.5px) rotate(-.5deg)}8%{transform:translate(2.5px, .5px) rotate(-.5deg)}10%{transform:translate(2.5px, -.5px) rotate(-.5deg)}12%{transform:translate(-.5px, 1.5px) rotate(1.5deg)}14%{transform:translate(2.5px, -.5px) rotate(1.5deg)}16%{transform:translate(.5px, -1.5px) rotate(.5deg)}18%{transform:translate(2.5px, 2.5px) rotate(-.5deg)}20%{transform:translate(1.5px, -.5px) rotate(1.5deg)}22%{transform:translate(-.5px, 1.5px) rotate(.5deg)}24%{transform:translate(-1.5px, 1.5px) rotate(.5deg)}26%{transform:translate(2.5px, .5px) rotate(1.5deg)}28%{transform:translate(-.5px, -.5px) rotate(.5deg)}30%{transform:translate(.5px, -.5px) rotate(.5deg)}32%{transform:translate(1.5px, -.5px) rotate(1.5deg)}34%{transform:translate(1.5px, .5px) rotate(-.5deg)}36%{transform:translate(.5px, 2.5px) rotate(.5deg)}38%{transform:translate(-1.5px, -.5px) rotate(.5deg)}40%{transform:translate(.5px, -.5px) rotate(.5deg)}42%{transform:translate(.5px, -.5px) rotate(1.5deg)}44%{transform:translate(-1.5px, .5px) rotate(1.5deg)}46%{transform:translate(-1.5px, -.5px) rotate(-.5deg)}48%{transform:translate(-1.5px, -.5px) rotate(-.5deg)}50%{transform:translate(-.5px, -.5px) rotate(.5deg)}52%{transform:translate(-1.5px, .5px) rotate(1.5deg)}54%{transform:translate(2.5px, .5px) rotate(-.5deg)}56%{transform:translate(1.5px, 2.5px) rotate(1.5deg)}58%{transform:translate(.5px, 1.5px) rotate(1.5deg)}60%{transform:translate(-1.5px, -1.5px) rotate(1.5deg)}62%{transform:translate(.5px, 1.5px) rotate(-.5deg)}64%{transform:translate(1.5px, 2.5px) rotate(1.5deg)}66%{transform:translate(1.5px, -.5px) rotate(1.5deg)}68%{transform:translate(-1.5px, 1.5px) rotate(.5deg)}70%{transform:translate(.5px, .5px) rotate(-.5deg)}72%{transform:translate(-.5px, -.5px) rotate(.5deg)}74%{transform:translate(.5px, -1.5px) rotate(.5deg)}76%{transform:translate(-.5px, 1.5px) rotate(.5deg)}78%{transform:translate(1.5px, -1.5px) rotate(-.5deg)}80%{transform:translate(-1.5px, -.5px) rotate(.5deg)}82%{transform:translate(.5px, -.5px) rotate(.5deg)}84%{transform:translate(2.5px, 2.5px) rotate(1.5deg)}86%{transform:translate(2.5px, -.5px) rotate(1.5deg)}88%{transform:translate(.5px, .5px) rotate(-.5deg)}90%{transform:translate(-.5px, -1.5px) rotate(-.5deg)}92%{transform:translate(2.5px, 1.5px) rotate(-.5deg)}94%{transform:translate(2.5px, -1.5px) rotate(-.5deg)}96%{transform:translate(2.5px, 2.5px) rotate(.5deg)}98%{transform:translate(2.5px, -.5px) rotate(.5deg)}0%,100%{transform:translate(0, 0) rotate(0)}}.shake:hover,.shake-trigger:hover .shake,.shake.shake-freeze,.shake.shake-constant{animation-name:shake;animation-duration:100ms;animation-timing-function:ease-in-out;animation-iteration-count:infinite}@keyframes shake-little{2%{transform:translate(1px, 1px) rotate(.5deg)}4%{transform:translate(0px, 1px) rotate(.5deg)}6%{transform:translate(0px, 1px) rotate(.5deg)}8%{transform:translate(1px, 0px) rotate(.5deg)}10%{transform:translate(0px, 0px) rotate(.5deg)}12%{transform:translate(1px, 0px) rotate(.5deg)}14%{transform:translate(1px, 0px) rotate(.5deg)}16%{transform:translate(0px, 1px) rotate(.5deg)}18%{transform:translate(0px, 1px) rotate(.5deg)}20%{transform:translate(0px, 1px) rotate(.5deg)}22%{transform:translate(0px, 1px) rotate(.5deg)}24%{transform:translate(0px, 0px) rotate(.5deg)}26%{transform:translate(1px, 1px) rotate(.5deg)}28%{transform:translate(1px, 1px) rotate(.5deg)}30%{transform:translate(1px, 1px) rotate(.5deg)}32%{transform:translate(1px, 0px) rotate(.5deg)}34%{transform:translate(0px, 1px) rotate(.5deg)}36%{transform:translate(0px, 1px) rotate(.5deg)}38%{transform:translate(1px, 1px) rotate(.5deg)}40%{transform:translate(1px, 1px) rotate(.5deg)}42%{transform:translate(1px, 1px) rotate(.5deg)}44%{transform:translate(1px, 1px) rotate(.5deg)}46%{transform:translate(1px, 0px) rotate(.5deg)}48%{transform:translate(1px, 1px) rotate(.5deg)}50%{transform:translate(1px, 1px) rotate(.5deg)}52%{transform:translate(1px, 0px) rotate(.5deg)}54%{transform:translate(0px, 1px) rotate(.5deg)}56%{transform:translate(0px, 0px) rotate(.5deg)}58%{transform:translate(0px, 0px) rotate(.5deg)}60%{transform:translate(1px, 1px) rotate(.5deg)}62%{transform:translate(0px, 0px) rotate(.5deg)}64%{transform:translate(1px, 0px) rotate(.5deg)}66%{transform:translate(1px, 1px) rotate(.5deg)}68%{transform:translate(1px, 0px) rotate(.5deg)}70%{transform:translate(1px, 1px) rotate(.5deg)}72%{transform:translate(0px, 0px) rotate(.5deg)}74%{transform:translate(1px, 0px) rotate(.5deg)}76%{transform:translate(0px, 1px) rotate(.5deg)}78%{transform:translate(1px, 1px) rotate(.5deg)}80%{transform:translate(0px, 0px) rotate(.5deg)}82%{transform:translate(1px, 0px) rotate(.5deg)}84%{transform:translate(0px, 0px) rotate(.5deg)}86%{transform:translate(1px, 1px) rotate(.5deg)}88%{transform:translate(1px, 1px) rotate(.5deg)}90%{transform:translate(1px, 1px) rotate(.5deg)}92%{transform:translate(0px, 0px) rotate(.5deg)}94%{transform:translate(1px, 1px) rotate(.5deg)}96%{transform:translate(0px, 1px) rotate(.5deg)}98%{transform:translate(0px, 0px) rotate(.5deg)}0%,100%{transform:translate(0, 0) rotate(0)}}.shake-little:hover,.shake-trigger:hover .shake-little,.shake-little.shake-freeze,.shake-little.shake-constant{animation-name:shake-little;animation-duration:100ms;animation-timing-function:ease-in-out;animation-iteration-count:infinite}@keyframes shake-slow{2%{transform:translate(0px, -7px) rotate(2.5deg)}4%{transform:translate(6px, 3px) rotate(-.5deg)}6%{transform:translate(6px, -5px) rotate(.5deg)}8%{transform:translate(3px, 3px) rotate(-1.5deg)}10%{transform:translate(-4px, 5px) rotate(1.5deg)}12%{transform:translate(2px, 7px) rotate(2.5deg)}14%{transform:translate(0px, 6px) rotate(-1.5deg)}16%{transform:translate(-9px, 5px) rotate(-2.5deg)}18%{transform:translate(4px, -8px) rotate(-.5deg)}20%{transform:translate(2px, 9px) rotate(3.5deg)}22%{transform:translate(-5px, 1px) rotate(-2.5deg)}24%{transform:translate(-2px, -8px) rotate(.5deg)}26%{transform:translate(4px, -2px) rotate(-.5deg)}28%{transform:translate(-4px, 9px) rotate(1.5deg)}30%{transform:translate(-4px, -3px) rotate(3.5deg)}32%{transform:translate(-2px, 6px) rotate(-2.5deg)}34%{transform:translate(4px, -4px) rotate(-.5deg)}36%{transform:translate(-1px, 6px) rotate(.5deg)}38%{transform:translate(8px, 8px) rotate(1.5deg)}40%{transform:translate(9px, -2px) rotate(3.5deg)}42%{transform:translate(-2px, -9px) rotate(.5deg)}44%{transform:translate(-1px, 10px) rotate(-1.5deg)}46%{transform:translate(-1px, 1px) rotate(-.5deg)}48%{transform:translate(6px, -8px) rotate(2.5deg)}50%{transform:translate(-1px, -7px) rotate(-1.5deg)}52%{transform:translate(0px, 1px) rotate(-1.5deg)}54%{transform:translate(1px, -8px) rotate(-2.5deg)}56%{transform:translate(-4px, 2px) rotate(1.5deg)}58%{transform:translate(10px, -7px) rotate(-2.5deg)}60%{transform:translate(-2px, -4px) rotate(-1.5deg)}62%{transform:translate(-3px, 3px) rotate(1.5deg)}64%{transform:translate(8px, 2px) rotate(-1.5deg)}66%{transform:translate(-4px, -1px) rotate(1.5deg)}68%{transform:translate(-1px, -2px) rotate(-1.5deg)}70%{transform:translate(8px, 8px) rotate(.5deg)}72%{transform:translate(-8px, -3px) rotate(-2.5deg)}74%{transform:translate(6px, 5px) rotate(.5deg)}76%{transform:translate(4px, -9px) rotate(1.5deg)}78%{transform:translate(-2px, -6px) rotate(3.5deg)}80%{transform:translate(1px, 0px) rotate(1.5deg)}82%{transform:translate(-4px, 6px) rotate(-2.5deg)}84%{transform:translate(-4px, -3px) rotate(1.5deg)}86%{transform:translate(7px, 10px) rotate(2.5deg)}88%{transform:translate(-3px, -2px) rotate(1.5deg)}90%{transform:translate(8px, -3px) rotate(3.5deg)}92%{transform:translate(0px, 3px) rotate(1.5deg)}94%{transform:translate(5px, -5px) rotate(-2.5deg)}96%{transform:translate(7px, -2px) rotate(-.5deg)}98%{transform:translate(-6px, 0px) rotate(3.5deg)}0%,100%{transform:translate(0, 0) rotate(0)}}.shake-slow:hover,.shake-trigger:hover .shake-slow,.shake-slow.shake-freeze,.shake-slow.shake-constant{animation-name:shake-slow;animation-duration:5s;animation-timing-function:ease-in-out;animation-iteration-count:infinite}@keyframes shake-hard{2%{transform:translate(7px, -4px) rotate(-.5deg)}4%{transform:translate(3px, 7px) rotate(2.5deg)}6%{transform:translate(3px, 8px) rotate(.5deg)}8%{transform:translate(-7px, 4px) rotate(1.5deg)}10%{transform:translate(6px, 10px) rotate(-.5deg)}12%{transform:translate(4px, 2px) rotate(-.5deg)}14%{transform:translate(-4px, 6px) rotate(3.5deg)}16%{transform:translate(1px, 5px) rotate(-1.5deg)}18%{transform:translate(3px, -7px) rotate(-2.5deg)}20%{transform:translate(-8px, -7px) rotate(.5deg)}22%{transform:translate(3px, -2px) rotate(-2.5deg)}24%{transform:translate(5px, -4px) rotate(1.5deg)}26%{transform:translate(-6px, -4px) rotate(-.5deg)}28%{transform:translate(1px, 0px) rotate(.5deg)}30%{transform:translate(-9px, -3px) rotate(3.5deg)}32%{transform:translate(3px, 6px) rotate(-1.5deg)}34%{transform:translate(-2px, -3px) rotate(-1.5deg)}36%{transform:translate(9px, -3px) rotate(-.5deg)}38%{transform:translate(9px, -9px) rotate(-1.5deg)}40%{transform:translate(8px, -7px) rotate(-2.5deg)}42%{transform:translate(-8px, -2px) rotate(2.5deg)}44%{transform:translate(-7px, 2px) rotate(-.5deg)}46%{transform:translate(-1px, 4px) rotate(3.5deg)}48%{transform:translate(3px, 1px) rotate(1.5deg)}50%{transform:translate(9px, -1px) rotate(2.5deg)}52%{transform:translate(-1px, 5px) rotate(-2.5deg)}54%{transform:translate(9px, -2px) rotate(.5deg)}56%{transform:translate(5px, -4px) rotate(-2.5deg)}58%{transform:translate(5px, -8px) rotate(-1.5deg)}60%{transform:translate(10px, 4px) rotate(1.5deg)}62%{transform:translate(-8px, 1px) rotate(-2.5deg)}64%{transform:translate(-9px, 6px) rotate(-1.5deg)}66%{transform:translate(-3px, 2px) rotate(.5deg)}68%{transform:translate(10px, 4px) rotate(.5deg)}70%{transform:translate(3px, -4px) rotate(-2.5deg)}72%{transform:translate(-5px, 10px) rotate(.5deg)}74%{transform:translate(1px, -7px) rotate(3.5deg)}76%{transform:translate(8px, -3px) rotate(-2.5deg)}78%{transform:translate(-8px, 2px) rotate(-.5deg)}80%{transform:translate(2px, 7px) rotate(-2.5deg)}82%{transform:translate(6px, -4px) rotate(1.5deg)}84%{transform:translate(3px, 2px) rotate(3.5deg)}86%{transform:translate(0px, -5px) rotate(-2.5deg)}88%{transform:translate(1px, -3px) rotate(2.5deg)}90%{transform:translate(-8px, -9px) rotate(2.5deg)}92%{transform:translate(-2px, 3px) rotate(2.5deg)}94%{transform:translate(-6px, 0px) rotate(-.5deg)}96%{transform:translate(-9px, 8px) rotate(1.5deg)}98%{transform:translate(9px, 4px) rotate(-1.5deg)}0%,100%{transform:translate(0, 0) rotate(0)}}.shake-hard:hover,.shake-trigger:hover .shake-hard,.shake-hard.shake-freeze,.shake-hard.shake-constant{animation-name:shake-hard;animation-duration:100ms;animation-timing-function:ease-in-out;animation-iteration-count:infinite}@keyframes shake-horizontal{2%{transform:translate(-5px, 0) rotate(0)}4%{transform:translate(8px, 0) rotate(0)}6%{transform:translate(8px, 0) rotate(0)}8%{transform:translate(9px, 0) rotate(0)}10%{transform:translate(-7px, 0) rotate(0)}12%{transform:translate(1px, 0) rotate(0)}14%{transform:translate(-4px, 0) rotate(0)}16%{transform:translate(7px, 0) rotate(0)}18%{transform:translate(8px, 0) rotate(0)}20%{transform:translate(-7px, 0) rotate(0)}22%{transform:translate(9px, 0) rotate(0)}24%{transform:translate(8px, 0) rotate(0)}26%{transform:translate(-2px, 0) rotate(0)}28%{transform:translate(5px, 0) rotate(0)}30%{transform:translate(6px, 0) rotate(0)}32%{transform:translate(4px, 0) rotate(0)}34%{transform:translate(3px, 0) rotate(0)}36%{transform:translate(7px, 0) rotate(0)}38%{transform:translate(-1px, 0) rotate(0)}40%{transform:translate(3px, 0) rotate(0)}42%{transform:translate(10px, 0) rotate(0)}44%{transform:translate(3px, 0) rotate(0)}46%{transform:translate(-9px, 0) rotate(0)}48%{transform:translate(6px, 0) rotate(0)}50%{transform:translate(-8px, 0) rotate(0)}52%{transform:translate(6px, 0) rotate(0)}54%{transform:translate(1px, 0) rotate(0)}56%{transform:translate(5px, 0) rotate(0)}58%{transform:translate(-4px, 0) rotate(0)}60%{transform:translate(3px, 0) rotate(0)}62%{transform:translate(-5px, 0) rotate(0)}64%{transform:translate(7px, 0) rotate(0)}66%{transform:translate(-8px, 0) rotate(0)}68%{transform:translate(-2px, 0) rotate(0)}70%{transform:translate(-5px, 0) rotate(0)}72%{transform:translate(1px, 0) rotate(0)}74%{transform:translate(1px, 0) rotate(0)}76%{transform:translate(-9px, 0) rotate(0)}78%{transform:translate(6px, 0) rotate(0)}80%{transform:translate(8px, 0) rotate(0)}82%{transform:translate(10px, 0) rotate(0)}84%{transform:translate(-6px, 0) rotate(0)}86%{transform:translate(-1px, 0) rotate(0)}88%{transform:translate(5px, 0) rotate(0)}90%{transform:translate(-1px, 0) rotate(0)}92%{transform:translate(7px, 0) rotate(0)}94%{transform:translate(-3px, 0) rotate(0)}96%{transform:translate(-7px, 0) rotate(0)}98%{transform:translate(-4px, 0) rotate(0)}0%,100%{transform:translate(0, 0) rotate(0)}}.shake-horizontal:hover,.shake-trigger:hover .shake-horizontal,.shake-horizontal.shake-freeze,.shake-horizontal.shake-constant{animation-name:shake-horizontal;animation-duration:100ms;animation-timing-function:ease-in-out;animation-iteration-count:infinite}@keyframes shake-vertical{2%{transform:translate(0, -9px) rotate(0)}4%{transform:translate(0, 0px) rotate(0)}6%{transform:translate(0, 4px) rotate(0)}8%{transform:translate(0, 4px) rotate(0)}10%{transform:translate(0, 0px) rotate(0)}12%{transform:translate(0, -4px) rotate(0)}14%{transform:translate(0, 8px) rotate(0)}16%{transform:translate(0, 8px) rotate(0)}18%{transform:translate(0, 4px) rotate(0)}20%{transform:translate(0, -5px) rotate(0)}22%{transform:translate(0, -8px) rotate(0)}24%{transform:translate(0, -4px) rotate(0)}26%{transform:translate(0, -9px) rotate(0)}28%{transform:translate(0, -3px) rotate(0)}30%{transform:translate(0, -9px) rotate(0)}32%{transform:translate(0, 8px) rotate(0)}34%{transform:translate(0, -6px) rotate(0)}36%{transform:translate(0, -7px) rotate(0)}38%{transform:translate(0, -7px) rotate(0)}40%{transform:translate(0, 1px) rotate(0)}42%{transform:translate(0, -7px) rotate(0)}44%{transform:translate(0, 0px) rotate(0)}46%{transform:translate(0, 10px) rotate(0)}48%{transform:translate(0, 1px) rotate(0)}50%{transform:translate(0, 7px) rotate(0)}52%{transform:translate(0, -6px) rotate(0)}54%{transform:translate(0, 9px) rotate(0)}56%{transform:translate(0, 8px) rotate(0)}58%{transform:translate(0, 10px) rotate(0)}60%{transform:translate(0, 8px) rotate(0)}62%{transform:translate(0, -3px) rotate(0)}64%{transform:translate(0, 4px) rotate(0)}66%{transform:translate(0, -8px) rotate(0)}68%{transform:translate(0, -6px) rotate(0)}70%{transform:translate(0, -8px) rotate(0)}72%{transform:translate(0, 7px) rotate(0)}74%{transform:translate(0, 7px) rotate(0)}76%{transform:translate(0, -6px) rotate(0)}78%{transform:translate(0, -8px) rotate(0)}80%{transform:translate(0, -6px) rotate(0)}82%{transform:translate(0, -1px) rotate(0)}84%{transform:translate(0, 10px) rotate(0)}86%{transform:translate(0, 10px) rotate(0)}88%{transform:translate(0, -8px) rotate(0)}90%{transform:translate(0, 1px) rotate(0)}92%{transform:translate(0, 9px) rotate(0)}94%{transform:translate(0, 4px) rotate(0)}96%{transform:translate(0, 1px) rotate(0)}98%{transform:translate(0, 7px) rotate(0)}0%,100%{transform:translate(0, 0) rotate(0)}}.shake-vertical:hover,.shake-trigger:hover .shake-vertical,.shake-vertical.shake-freeze,.shake-vertical.shake-constant{animation-name:shake-vertical;animation-duration:100ms;animation-timing-function:ease-in-out;animation-iteration-count:infinite}@keyframes shake-rotate{2%{transform:translate(0, 0) rotate(.5deg)}4%{transform:translate(0, 0) rotate(5.5deg)}6%{transform:translate(0, 0) rotate(.5deg)}8%{transform:translate(0, 0) rotate(-5.5deg)}10%{transform:translate(0, 0) rotate(.5deg)}12%{transform:translate(0, 0) rotate(2.5deg)}14%{transform:translate(0, 0) rotate(5.5deg)}16%{transform:translate(0, 0) rotate(-5.5deg)}18%{transform:translate(0, 0) rotate(-1.5deg)}20%{transform:translate(0, 0) rotate(4.5deg)}22%{transform:translate(0, 0) rotate(-6.5deg)}24%{transform:translate(0, 0) rotate(1.5deg)}26%{transform:translate(0, 0) rotate(1.5deg)}28%{transform:translate(0, 0) rotate(-4.5deg)}30%{transform:translate(0, 0) rotate(5.5deg)}32%{transform:translate(0, 0) rotate(2.5deg)}34%{transform:translate(0, 0) rotate(3.5deg)}36%{transform:translate(0, 0) rotate(-3.5deg)}38%{transform:translate(0, 0) rotate(-4.5deg)}40%{transform:translate(0, 0) rotate(2.5deg)}42%{transform:translate(0, 0) rotate(.5deg)}44%{transform:translate(0, 0) rotate(-3.5deg)}46%{transform:translate(0, 0) rotate(-4.5deg)}48%{transform:translate(0, 0) rotate(-1.5deg)}50%{transform:translate(0, 0) rotate(-3.5deg)}52%{transform:translate(0, 0) rotate(-2.5deg)}54%{transform:translate(0, 0) rotate(3.5deg)}56%{transform:translate(0, 0) rotate(.5deg)}58%{transform:translate(0, 0) rotate(-6.5deg)}60%{transform:translate(0, 0) rotate(-3.5deg)}62%{transform:translate(0, 0) rotate(-1.5deg)}64%{transform:translate(0, 0) rotate(3.5deg)}66%{transform:translate(0, 0) rotate(.5deg)}68%{transform:translate(0, 0) rotate(4.5deg)}70%{transform:translate(0, 0) rotate(1.5deg)}72%{transform:translate(0, 0) rotate(-3.5deg)}74%{transform:translate(0, 0) rotate(-3.5deg)}76%{transform:translate(0, 0) rotate(2.5deg)}78%{transform:translate(0, 0) rotate(-1.5deg)}80%{transform:translate(0, 0) rotate(-5.5deg)}82%{transform:translate(0, 0) rotate(7.5deg)}84%{transform:translate(0, 0) rotate(.5deg)}86%{transform:translate(0, 0) rotate(5.5deg)}88%{transform:translate(0, 0) rotate(4.5deg)}90%{transform:translate(0, 0) rotate(-2.5deg)}92%{transform:translate(0, 0) rotate(1.5deg)}94%{transform:translate(0, 0) rotate(-5.5deg)}96%{transform:translate(0, 0) rotate(7.5deg)}98%{transform:translate(0, 0) rotate(-3.5deg)}0%,100%{transform:translate(0, 0) rotate(0)}}.shake-rotate:hover,.shake-trigger:hover .shake-rotate,.shake-rotate.shake-freeze,.shake-rotate.shake-constant{animation-name:shake-rotate;animation-duration:100ms;animation-timing-function:ease-in-out;animation-iteration-count:infinite}@keyframes shake-opacity{10%{transform:translate(1px, -2px) rotate(1.5deg);opacity:.95}20%{transform:translate(-4px, 5px) rotate(-.5deg);opacity:.8}30%{transform:translate(4px, -2px) rotate(-1.5deg);opacity:.62}40%{transform:translate(-1px, 2px) rotate(-1.5deg);opacity:.97}50%{transform:translate(5px, 0px) rotate(1.5deg);opacity:.97}60%{transform:translate(2px, -4px) rotate(1.5deg);opacity:.24}70%{transform:translate(-3px, 3px) rotate(1.5deg);opacity:.59}80%{transform:translate(2px, -2px) rotate(-.5deg);opacity:.03}90%{transform:translate(2px, -4px) rotate(-.5deg);opacity:.05}0%,100%{transform:translate(0, 0) rotate(0)}}.shake-opacity:hover,.shake-trigger:hover .shake-opacity,.shake-opacity.shake-freeze,.shake-opacity.shake-constant{animation-name:shake-opacity;animation-duration:.5s;animation-timing-function:ease-in-out;animation-iteration-count:infinite}@keyframes shake-crazy{10%{transform:translate(15px, 4px) rotate(2deg);opacity:.3}20%{transform:translate(-18px, -15px) rotate(9deg);opacity:.94}30%{transform:translate(0px, -1px) rotate(5deg);opacity:.68}40%{transform:translate(-8px, 11px) rotate(-2deg);opacity:.68}50%{transform:translate(1px, 5px) rotate(-3deg);opacity:.3}60%{transform:translate(-7px, -9px) rotate(3deg);opacity:.8}70%{transform:translate(-2px, 1px) rotate(5deg);opacity:.66}80%{transform:translate(13px, -13px) rotate(-5deg);opacity:.38}90%{transform:translate(-2px, -10px) rotate(9deg);opacity:.64}0%,100%{transform:translate(0, 0) rotate(0)}}.shake-crazy:hover,.shake-trigger:hover .shake-crazy,.shake-crazy.shake-freeze,.shake-crazy.shake-constant{animation-name:shake-crazy;animation-duration:100ms;animation-timing-function:ease-in-out;animation-iteration-count:infinite}@keyframes shake-chunk{2%{transform:translate(-9px, 15px) rotate(5deg)}4%{transform:translate(5px, 15px) rotate(7deg)}6%{transform:translate(4px, 12px) rotate(3deg)}8%{transform:translate(-11px, 3px) rotate(5deg)}10%{transform:translate(-5px, -11px) rotate(-1deg)}12%{transform:translate(12px, 14px) rotate(1deg)}14%{transform:translate(12px, 8px) rotate(-11deg)}16%{transform:translate(9px, 14px) rotate(-1deg)}18%{transform:translate(-14px, 5px) rotate(-14deg)}20%{transform:translate(-3px, 9px) rotate(-14deg)}22%{transform:translate(-4px, 11px) rotate(-14deg)}24%{transform:translate(13px, -7px) rotate(-13deg)}26%{transform:translate(8px, 13px) rotate(-3deg)}28%{transform:translate(6px, 0px) rotate(9deg)}30%{transform:translate(0px, 5px) rotate(14deg)}32%{transform:translate(12px, 4px) rotate(-12deg)}34%{transform:translate(6px, -6px) rotate(4deg)}36%{transform:translate(6px, 7px) rotate(-3deg)}38%{transform:translate(9px, 0px) rotate(-1deg)}0%,40%,100%{transform:translate(0, 0) rotate(0)}}.shake-chunk:hover,.shake-trigger:hover .shake-chunk,.shake-chunk.shake-freeze,.shake-chunk.shake-constant{animation-name:shake-chunk;animation-duration:4s;animation-timing-function:ease-in-out;animation-iteration-count:infinite} 9 | -------------------------------------------------------------------------------- /lib/generator.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const fs = require("fs"); 4 | const ejs = require("ejs"); 5 | const path = require("path"); 6 | const crypto = require("crypto"); 7 | const config = require("./config"); 8 | const extras = require("./extras"); 9 | const { info } = require("console"); 10 | 11 | const getConfig = function () { 12 | return config.getConfig(); 13 | } 14 | 15 | const generator = { 16 | 17 | getHash: function (filePath) { 18 | return new Promise(function (resolve, reject) { 19 | try { 20 | const stream = fs.createReadStream(filePath); 21 | const sha256sum = crypto.createHash('sha256'); 22 | stream.on('data', function (data) { 23 | sha256sum.update(data); 24 | }); 25 | stream.on('end', function () { 26 | resolve(sha256sum.digest('hex')); 27 | }); 28 | } catch (err) { 29 | reject(err); 30 | } 31 | }); 32 | }, 33 | 34 | getSingleDirectoty: function (fileRootPath) { 35 | let allFile = []; 36 | function readDirSync(filePath) { 37 | try { 38 | const dirs = fs.readdirSync(filePath); 39 | for (let i = 0; i < dirs.length; i++) { 40 | const fileName = dirs[i]; 41 | const filePathChild = path.join(filePath, fileName); 42 | try { 43 | const stat = fs.statSync(filePathChild); 44 | if (stat.isDirectory()) { 45 | readDirSync(filePathChild); 46 | } else if (stat.isFile()) { 47 | allFile.push(filePathChild); 48 | } 49 | } catch (err) { 50 | throw err; 51 | } 52 | } 53 | } catch (err) { 54 | if (err.code === 'ENOENT' || err.code === "ENOTDIR") { 55 | return; 56 | } else { 57 | throw err; 58 | } 59 | } 60 | } 61 | readDirSync(fileRootPath); 62 | return allFile; 63 | }, 64 | 65 | getAllFile: function () { 66 | /* 67 | sync, returns an object included all file's name 68 | return object: [ 69 | { 70 | name: '', 71 | files[ 72 | '', 73 | ... 74 | ] 75 | }, 76 | ... 77 | ] 78 | */ 79 | 80 | let allFile = []; 81 | try { 82 | const rootDirs = fs.readdirSync("source"); 83 | for (let i = 0; i < rootDirs.length; i++) { 84 | const dirName = rootDirs[i]; 85 | const dirPath = path.join("source", dirName); 86 | try { 87 | fs.accessSync(path.join(dirPath, "infos.json")); 88 | const stat = fs.statSync(dirPath); 89 | if (stat.isDirectory()) { 90 | const tmp = this.getSingleDirectoty(dirPath); 91 | allFile.push({ 92 | name: dirName, 93 | files: tmp 94 | }); 95 | } 96 | } catch (err) { 97 | if (err.code === "ENOENT" || err.code == "ENOTDIR") { 98 | ; 99 | } else { 100 | throw err; 101 | } 102 | } 103 | } 104 | } catch (err) { 105 | if (err.code === 'ENOENT' || err.code === "ENOTDIR") { 106 | ; 107 | } else { 108 | throw err; 109 | } 110 | } 111 | return allFile; 112 | }, 113 | 114 | getChanged: function () { 115 | /* 116 | promise (async), resolve an object that included all changed or newly build page and site's object. 117 | resolve (return): object: [ 118 | { 119 | name: '', // directory's name 120 | files[ 121 | '', // path relative to porject root directory 122 | ... 123 | ] 124 | }, 125 | ... 126 | ] 127 | */ 128 | const that = this; 129 | return new Promise(async function (resolve, reject) { 130 | const allFile = that.getAllFile(); 131 | try { 132 | const fileRec = JSON.parse(fs.readFileSync('source/fileRecord.json', "utf-8")); 133 | let rts = []; // returns, words faild to me QwQ 134 | // pardon my for loop, I thought they are more understandable to me than callbacks 135 | for (let i = 0; i < allFile.length; i++) { 136 | const dir = allFile[i]; 137 | let chandedFile = { 138 | name: dir.name, 139 | files: [] 140 | }; 141 | for (let j = 0; j < dir.files.length; j++) { 142 | const file = dir.files[j]; 143 | if (fileRec[file]) { 144 | const checksum = await that.getHash(file); 145 | if (checksum != fileRec[file]) { 146 | chandedFile.files.push(file); 147 | } 148 | } else { 149 | // newly build 150 | chandedFile.files.push(file); 151 | } 152 | } 153 | if (chandedFile.files.length > 0) { // not empty 154 | rts.push(chandedFile); 155 | } 156 | } 157 | resolve(rts); 158 | } catch (err) { 159 | if (err.code === 'ENOENT' || err.code === "ENOTDIR") { 160 | // fileRecord,json not exsists, should return all page or site 161 | resolve(allFile); 162 | } else { 163 | reject(err); 164 | } 165 | } 166 | }); 167 | }, 168 | 169 | getAllInfos: function () { 170 | let allInfos = []; 171 | try { 172 | const rootDirs = fs.readdirSync("source"); 173 | for (let i = 0; i < rootDirs.length; i++) { 174 | const dirName = rootDirs[i]; 175 | const dirPath = path.join("source", dirName); 176 | try { 177 | let data = JSON.parse(fs.readFileSync(path.join(dirPath, "infos.json"), "utf-8")); 178 | data.link = "/" + dirName; 179 | allInfos.push(data); 180 | } catch (err) { 181 | if (err.code === 'ENOENT' || err.code === "ENOTDIR") { 182 | // fileRecord,json not exsists 183 | ; 184 | } else { 185 | throw err; 186 | } 187 | } 188 | } 189 | return allInfos; 190 | } catch (err) { 191 | if (err.code === 'ENOENT' || err.code === "ENOTDIR") { 192 | // fileRecord,json not exsists 193 | return allInfos; 194 | } else { 195 | throw err; 196 | } 197 | } 198 | }, 199 | 200 | recordFileandClean: function (changedFilePaths) { 201 | /* 202 | arg: filePaths: [string] 203 | 204 | get file's hash then write into fileRecord.json 205 | */ 206 | const that = this; 207 | return new Promise(async function (resolve, reject) { 208 | let fileRec; 209 | try { 210 | fileRec = JSON.parse(fs.readFileSync('source/fileRecord.json', "utf-8")); 211 | } catch (err) { 212 | if (err.code === 'ENOENT' || err.code === "ENOTDIR") { 213 | fileRec = {}; 214 | } else { 215 | reject(err); 216 | } 217 | } 218 | 219 | // find all deleted file then clean them 220 | let infoChanged = false; 221 | const keys = Object.getOwnPropertyNames(fileRec); 222 | for (let i = 0; i < keys.length; i++) { 223 | const key = keys[i]; 224 | if (!fs.existsSync(key)) { 225 | delete fileRec[key]; 226 | if (path.parse(key).base === "infos.json") { 227 | infoChanged = true; 228 | } 229 | extras.rm(path.join("public", path.relative("source", key))); 230 | } 231 | } 232 | 233 | for (let i = 0; i < changedFilePaths.length; i++) { 234 | const filePath = changedFilePaths[i]; 235 | const checksum = await that.getHash(filePath); 236 | fileRec[filePath] = checksum; 237 | } 238 | 239 | fs.writeFile("source/fileRecord.json", JSON.stringify(fileRec, null, "\t"), err => { 240 | if (err) { 241 | reject(err); 242 | } else { 243 | if (infoChanged) { 244 | resolve("changed"); 245 | } else { 246 | resolve(); 247 | } 248 | } 249 | }); 250 | }); 251 | }, 252 | 253 | renderPage: function (pagePath, pageTitle) { 254 | /* 255 | use ejs to summon file, then copy 256 | */ 257 | const data = fs.readFileSync(pagePath, "utf-8"); 258 | const ejsTemptele = fs.readFileSync("layout/ejs/page/page.ejs", "utf-8"); 259 | 260 | const config = getConfig(); 261 | const html = ejs.render(ejsTemptele, { 262 | page: { 263 | content: data, 264 | title: pageTitle 265 | }, 266 | config: config 267 | }, { 268 | filename: "layout/ejs/page/page.ejs" 269 | }); 270 | 271 | const pathPublic = path.join('public', path.relative('source', pagePath)); 272 | if (!fs.existsSync(path.dirname(pathPublic))) { 273 | fs.mkdirSync(path.dirname(pathPublic), { recursive: true }); 274 | } 275 | fs.writeFileSync(pathPublic, html); 276 | console.log("Writen " + pathPublic); 277 | }, 278 | 279 | renderCommonFile: function (filePath) { 280 | /* 281 | Just copy them into ./public 282 | */ 283 | 284 | const pathPublic = path.join('public', path.relative('source', filePath)); 285 | if (!fs.existsSync(path.dirname(pathPublic))) { 286 | fs.mkdirSync(path.dirname(pathPublic), { recursive: true }); 287 | } 288 | console.log("Writen " + pathPublic); 289 | fs.copyFileSync(filePath, pathPublic); 290 | }, 291 | 292 | renderCategories: function (allItems) { 293 | /* 294 | arg: [{ 295 | link: '/', 296 | title: '', 297 | description: '', 298 | category: '', 299 | auther: '', 300 | date: '' 301 | }, 302 | ... 303 | ], 304 | */ 305 | function compare(Item1, Item2) { 306 | // reverse 307 | const date1 = new Date(Item1.date); 308 | const date2 = new Date(Item2.date); 309 | if (date1 < date2) { 310 | return 1; 311 | } else if (date1 > date2) { 312 | return -1; 313 | } else { 314 | return 0; 315 | } 316 | } 317 | 318 | let categories = { 319 | All: [] 320 | }; 321 | 322 | extras.rm("public/categories"); 323 | 324 | for (let i = 0; i < allItems.length; i++) { 325 | const item = allItems[i]; 326 | if (item.category) { 327 | if (categories[item.category] === undefined) { 328 | categories[item.category] = []; 329 | } 330 | categories[item.category].push(item); 331 | categories.All.push(item); 332 | 333 | } 334 | } 335 | 336 | const categoriesKeys = Object.getOwnPropertyNames(categories); 337 | const ejsTemptele = fs.readFileSync("layout/ejs/categories/categories.ejs", "utf-8"); 338 | // render every single category, including all 339 | for (let i = 0; i < categoriesKeys.length; i++) { 340 | const key = categoriesKeys[i]; 341 | let items = categories[key]; 342 | items.sort(compare); 343 | const html = ejs.render(ejsTemptele, { 344 | config: getConfig(), 345 | page: { 346 | title: "Categories " + key 347 | }, 348 | category: { 349 | categories: categoriesKeys, 350 | active: key, 351 | items: items 352 | } 353 | }, { 354 | filename: "layout/ejs/categories/categories.ejs" 355 | }); 356 | if (!fs.existsSync(path.join("public/categories", key))) { 357 | fs.mkdirSync(path.join("public/categories", key), { recursive: true }); 358 | } 359 | console.log("Writen " + path.join("public/categories", key, "index.html")); 360 | fs.writeFileSync(path.join("public/categories", key, "index.html"), html); 361 | } 362 | console.log("Writen public/categories/index.html"); 363 | fs.copyFileSync("public/categories/All/index.html", "public/categories/index.html") 364 | }, 365 | 366 | renderTagPage: function (tagName, items) { 367 | /* 368 | arg: tagname: 369 | items: 370 | */ 371 | function compare(Item1, Item2) { 372 | // reverse 373 | const date1 = new Date(Item1.date); 374 | const date2 = new Date(Item2.date); 375 | if (date1 < date2) { 376 | return 1; 377 | } else if (date1 > date2) { 378 | return -1; 379 | } else { 380 | return 0; 381 | } 382 | } 383 | items.sort(compare); 384 | const ejsTemptele = fs.readFileSync("layout/ejs/tags/tags.ejs", "utf-8"); 385 | const html = ejs.render(ejsTemptele, { 386 | config: getConfig(), 387 | page: { 388 | title: 'Tag' + tagName 389 | }, 390 | tag: { 391 | name: tagName, 392 | items: items 393 | } 394 | }, { 395 | filename: "layout/ejs/tags/tags.ejs" 396 | }); 397 | if (!fs.existsSync(path.join("public/tags", tagName))) { 398 | fs.mkdirSync(path.join("public/tags", tagName), { recursive: true }); 399 | } 400 | console.log("Writen " + path.join("public/tags", tagName, "index.html")); 401 | fs.writeFileSync(path.join("public/tags", tagName, "index.html"), html); 402 | }, 403 | 404 | renderTagGuiding: function (allInfos) { 405 | /* 406 | arg: 407 | */ 408 | let allTags = []; 409 | let recTags = {}; 410 | for (let i = 0; i < allInfos.length; i++) { 411 | const info = allInfos[i]; 412 | for (let j = 0; j < info.tags.length; j++) { 413 | const tag = info.tags[j]; 414 | if (tag && recTags[tag] === undefined) { 415 | allTags.push(tag); 416 | recTags[tag] = 1; 417 | } 418 | } 419 | } 420 | const ejsTemptele = fs.readFileSync("layout/ejs/tags/tagGuiding.ejs", "utf-8"); 421 | const html = ejs.render(ejsTemptele, { 422 | config: getConfig(), 423 | page: { 424 | title: "Tags" 425 | }, 426 | tagGuiding: { 427 | items: allTags 428 | } 429 | }, { 430 | filename: "layout/ejs/tags/tagGuiding.ejs" 431 | }); 432 | if (!fs.existsSync("public/tags")) { 433 | fs.mkdirSync("public/tags", { recursive: true }); 434 | } 435 | console.log("Writen " +"public/tags/index.html"); 436 | fs.writeFileSync("public/tags/index.html", html); 437 | }, 438 | 439 | renderAllTagPage: function (allInfos) { 440 | let infosGuideByTag = {}; 441 | for (let i = 0; i < allInfos.length; i++) { 442 | const info = allInfos[i]; 443 | for (let j = 0; j < info.tags.length; j++) { 444 | const tag = info.tags[j]; 445 | if (tag) { 446 | if (infosGuideByTag[tag] === undefined) { 447 | infosGuideByTag[tag] = []; 448 | } 449 | infosGuideByTag[tag].push(info); 450 | } 451 | } 452 | } 453 | extras.rm("public/tags"); 454 | const keys = Object.getOwnPropertyNames(infosGuideByTag); 455 | for (let i = 0; i < keys.length; i++) { 456 | const key = keys[i]; 457 | this.renderTagPage(key, infosGuideByTag[key]); 458 | } 459 | this.renderTagGuiding(allInfos); 460 | }, 461 | 462 | renderIndex: function() { 463 | const ejsTemptele = fs.readFileSync("layout/ejs/index/index.ejs", "utf-8"); 464 | const content = fs.readFileSync("layout/src/index.html", "utf-8"); 465 | const html = ejs.render(ejsTemptele, { 466 | config: getConfig(), 467 | page: { 468 | title: config.getConfig()["siteName"] 469 | }, 470 | index: { 471 | content: content 472 | } 473 | }, { 474 | filename: "layout/ejs/index/index.ejs" 475 | }); 476 | 477 | const pathPublic = "public/index.html"; 478 | if (!fs.existsSync("public")) { 479 | fs.mkdirSync("public", {recursive: true}); 480 | } 481 | console.log("Writen " + pathPublic); 482 | fs.writeFileSync(pathPublic, html); 483 | }, 484 | 485 | renderSrc: function() { 486 | let allFile = this.getSingleDirectoty("layout/src"); 487 | 488 | for (let i = 0; i < allFile.length; i++) { 489 | const file = allFile[i]; 490 | if (file !== "layout/src/index.html") { 491 | fs.mkdirSync(path.join("public", path.relative("layout", path.dirname(file))), { recursive: true }); 492 | console.log("Writen " + path.join("public", path.relative("layout", file))); 493 | fs.copyFileSync(file, path.join("public", path.relative("layout", file))); 494 | } 495 | } 496 | }, 497 | 498 | renderAll: function () { 499 | /* 500 | Read all changed directory in ../source, 501 | then render them according to their infos.json, 502 | finally put them in ../public directory, 503 | */ 504 | 505 | // read all file 506 | const that = this; 507 | return new Promise(async function (resolve) { 508 | const allChangedFileList = await that.getChanged(); 509 | 510 | // copy static files if not exsist 511 | if (!fs.existsSync("public/src")) { 512 | that.renderSrc(); 513 | } 514 | 515 | if (!fs.existsSync("public/index.html")) { 516 | that.renderIndex(); 517 | } 518 | 519 | let infoChanged = false; 520 | 521 | // record all files 522 | let allChangedList = []; 523 | for (let i = 0; i < allChangedFileList.length; i++) { 524 | const changed = allChangedFileList[i]; 525 | for (let j = 0; j < changed.files.length; j++) { 526 | const filePath = changed.files[j]; 527 | allChangedList.push(filePath); 528 | } 529 | } 530 | if("changed" === await that.recordFileandClean(allChangedList)) { 531 | infoChanged = true; 532 | } 533 | 534 | // if a page or site's info have been changed, we need to update categroies and tags 535 | for (let i = 0; i < allChangedFileList.length; i++) { 536 | const changed = allChangedFileList[i]; 537 | const infosjson = path.join("source", changed.name, "infos.json"); 538 | const infos = JSON.parse(fs.readFileSync(infosjson, "utf-8")); 539 | if (infos.type !== "page" && infos.type !== "site") { 540 | throw new Error("Unknown type at " + infosjson); 541 | } 542 | for (let j = 0; j < changed.files.length; j++) { 543 | const filePath = changed.files[j]; 544 | if ("infos.json" === path.relative(path.join("source", changed.name), filePath)) { 545 | // is infos 546 | infoChanged = true; 547 | const indexPath = path.join(path.dirname(filePath), "index.html"); 548 | if (infos.type === "page") { 549 | that.renderPage(indexPath, infos.title); 550 | } else { 551 | that.renderCommonFile(indexPath); 552 | } 553 | } else if (infos.type === "page" && 554 | "index.html" === path.relative(path.join("source", changed.name), filePath)) { 555 | // is page's index.html 556 | that.renderPage(filePath, infos.title); 557 | } else { 558 | that.renderCommonFile(filePath); 559 | } 560 | } 561 | } 562 | 563 | // if infos have been changed, all categroies and tags should be updated 564 | if (infoChanged) { 565 | const allInfos = that.getAllInfos(); 566 | that.renderCategories(allInfos); 567 | that.renderAllTagPage(allInfos); 568 | } 569 | 570 | resolve(); 571 | }); 572 | } 573 | } 574 | 575 | module.exports = generator; -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------