Browse Source

Gitbook Auto Published

willin 6 years ago
parent
commit
8c96dfda8e
6 changed files with 303 additions and 23 deletions
  1. 4 0
      COPYRIGHT.md
  2. 32 20
      README.md
  3. 1 1
      _sidebar.md
  4. 2 0
      basic/node/babel.md
  5. 261 0
      basic/node/docsify.md
  6. 3 2
      index.html

+ 4 - 0
COPYRIGHT.md

@@ -5,3 +5,7 @@
 《不可替代的团队领袖培养计划》由 [Willin Wang](http://willin.wang/) 创作,采用 [知识共享 署名-非商业性使用-相同方式共享 4.0 国际 许可协议](http://creativecommons.org/licenses/by-nc-sa/4.0/)进行许可。
 
 本人保留所有权限,保留出版权限,未经本人书面许可任何人不得用于商业出版。
+
+![支付宝捐赠](https://cloud.githubusercontent.com/assets/1890238/15489630/fccbb9cc-2193-11e6-9fed-b93c59d6ef37.png) 
+
+支付宝捐赠请扫码.

+ 32 - 20
README.md

@@ -1,34 +1,46 @@
 # 《不可替代的团队领袖培养计划》
 
-你离技术经理,只差这本书: <http://leader.js.cool>
+# 前言
 
-如果还想看视频类的,可以到我的斗鱼直播间来一波正义的订阅: <https://www.douyu.com/200058>
+> 对于工作上应该做什么事,如果你没有自己的想法,而是完全听主管的,很危险。多数的主管不会在乎你的成长,也不会把公司的利益摆第一位,他们最在乎的是自己的工作绩效,而他们的工作绩效是要靠你们去达成的。完全听他们的任务布置去做,没有自己的主张,东一榔头,西一棒槌,几年下来就变打杂的了。
+> ——蔡学镛
+
+本书由浅及深主要包括如下几个方面:
+
+## 知识
+
+介绍OS X上个人常用的效率、开发、设计工具及使用技巧。从基础常识讲起,推荐一些工具、资源,以及自动化测试、持续集成的一些概念入门。
+
+## 经验
 
-### 安装
+从产品架构设计到项目实践,再到部署运维的各方面的技术、管理、流程小细节。
 
-```bash
-npm i -g gitbook-cli
-gitbook install
-```
+## 思想
 
-### 本地运行
+未来的世界不属于富人,更不属于穷人,只会属于有思想的人。
 
-```bash
-gitbook serve
-```
+总结个人在工作中积累的思想原则,和看重的一些能力及培养方法。
 
-### 打包生成
+---
 
-```bash
-gitbook build
-```
+2016.8.3晚写下了本书的第一行话,当时想的名字为《可替代的团队领袖培养计划》,其寓意是希望这些知识经验在团队内部分享,能够培养出更优秀的人才,每个人都能够替代我做得更好。如果能够因此有所建树,则将会成为不可替代的团队领袖。
 
-## License
+源码:
 
-<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="知识共享许可协议" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><br />本作品采用<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议</a>进行许可。
+* Github: <https://github.com/js-cool/leader.js.cool>
+* Coding: <https://coding.net/u/willin/p/leader.js.cool/git>
 
-通过支付宝捐赠:
+欢迎进行反馈交流。
 
-![qr](https://cloud.githubusercontent.com/assets/1890238/15489630/fccbb9cc-2193-11e6-9fed-b93c59d6ef37.png)
+&copy; Willin Wang
 
-该项目始建于2016.8.3。
+## CHANGELOG
+
+- 2017.06.20: 将本书的网站从`GitBook`转移到了`Docsify`
+- 2016.08.03: 该项目创建
+
+---
+
+你离技术经理,只差这本书: <http://leader.js.cool>
+
+如果还想看视频类的,可以到我的斗鱼直播间来一波正义的订阅: <https://www.douyu.com/200058>

+ 1 - 1
_sidebar.md

@@ -1,4 +1,3 @@
-- [前言](INTRO.md)
 - [版权](COPYRIGHT.md)
 - 知识篇
   - [操作系统(OS X)](basic/osx.md)
@@ -28,6 +27,7 @@
     - [包管理](basic/node/pkg.md)
     - [Hexo静态博客搭建](basic/node/hexo.md)
     - [GitBook静态文档生成](basic/node/gitbook.md)
+    - [Docsify流程图序列图](basic/node/docsify.md)
     - [Babel](basic/node/babel.md)
     - [Test](basic/node/test.md)
     - [Benchmark](basic/node/benchmark.md)

+ 2 - 0
basic/node/babel.md

@@ -50,3 +50,5 @@ babel src --out-dir dist
 ```
 
 源目录`src`,目标目录`dist`。
+
+p.s. 从 Node.js `7.6.0` 版本开始,再也没用过 `Babel` 执行后端代码.

+ 261 - 0
basic/node/docsify.md

@@ -0,0 +1,261 @@
+# Docsify画图建模Mermaid插件支持
+
+先上图
+
+![mermaid1](https://user-images.githubusercontent.com/1890238/27322559-3217d3b8-5564-11e7-8d27-2d6de348aa5f.png)
+
+## 引入Mermaid
+
+在 `head` 中加入css:
+
+```html
+<link rel="stylesheet" href="//unpkg.com/mermaid/dist/mermaid.min.css">
+```
+
+在 底部 引用js:
+
+```html
+<script type="text/javascript" src="//unpkg.com/mermaid/dist/mermaid.min.js"></script>
+```
+
+## 配置文件修改
+
+```js
+window.$docsify = {
+  // ...
+  plugins: [
+    function(hook, vm) {
+      hook.ready(function () {
+        mermaid.initialize({startOnLoad: false});
+      });
+      hook.doneEach(function () {
+        mermaid.init(undefined,'.mermaid');
+      });
+    }
+  ],
+  markdown: {
+    renderer: {
+      code: function(code, lang) {
+        var html = '';
+        if(code.match(/^sequenceDiagram/) || code.match(/^graph/) || code.match(/^gantt/)){
+          html = '<div class="mermaid">' + code + '</div>';
+        }
+        var hl = Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup)
+        return html + '<pre v-pre data-lang="' + lang + '"><code class="lang-' + lang + '">' + hl + '</code></pre>'
+      }
+    }
+  }
+}
+```
+
+解释一下,两个关键步骤:
+
+### markdown代码解析器
+
+```js
+markdown: {
+  renderer: {
+    code: function(code, lang) {
+    var html = '';
+    // 搜索 mermaid 代码
+    if(code.match(/^sequenceDiagram/) || code.match(/^graph/) || code.match(/^gantt/)){
+      // 生成一个 mermaid 图表的容器
+      html = '<div class="mermaid">' + code + '</div>';
+    }
+    // 源码自带的 Prism 高亮插件
+    var hl = Prism.highlight(code, Prism.languages[lang] || Prism.languages.markup)
+    // 将图表的容器添加到代码之前
+    return html + '<pre v-pre data-lang="' + lang + '"><code class="lang-' + lang + '">' + hl + '</code></pre>'
+    }
+  }
+}
+```
+
+### 自定义插件
+
+```js
+plugins: [
+  function(hook, vm) {
+    hook.ready(function () {
+      // 类似 jQuery.ready 初始化 mermaid, 禁用自动渲染
+      mermaid.initialize({startOnLoad: false});
+    });
+    hook.doneEach(function () {
+      // 每个页面渲染完成后手动渲染 mermaid 图表
+      mermaid.init(undefined,'.mermaid');
+    });
+  }
+]
+```
+
+
+最后再补一张甘特图:
+
+
+![mermaid2](https://user-images.githubusercontent.com/1890238/27322558-31c84fbe-5564-11e7-9949-851fddbafa33.png)
+
+
+Mermaid支持:
+
+- 流程图
+- 序列图
+- 甘特图
+
+而且语法结构非常简单,值得推荐. 
+
+## 其实,正文才刚刚开始.
+
+### 流程图
+
+#### 开始/结束
+
+```mermaid
+graph TB
+  s(开始/结束)
+  style s rx: 10, ry: 10
+```
+
+#### 过程
+
+```mermaid
+graph TB
+  step1[过程]
+```
+
+#### 输入/输出
+
+```mermaid
+graph TB
+  step2>输入/输出]
+```
+
+#### 判断
+
+```mermaid
+graph TB
+  step3{判断}
+```
+
+#### 连接线
+
+```mermaid
+graph LR
+  A --> B
+```
+
+#### 自定义样式
+
+```mermaid
+graph LR
+  id1(Start)-->id2(Stop)
+  style id1 fill:#f9f,stroke:#333,stroke-width:4px
+  style id2 fill:#ccf,stroke:#f66,stroke-width:2px,stroke-dasharray: 5, 5
+```
+
+#### 示例
+
+```mermaid
+graph TB
+  s(开始) --> step1>输入参数]
+  step1 --> step2{判断参数合法性}
+  step2 ==> |校验失败|e
+  step2--> |校验成功|step3[处理业务]
+  step3 --> e(结束)
+  style s rx: 10, ry: 10
+  style e rx: 10, ry: 10
+```
+
+#### 子图
+
+```mermaid
+graph TB
+  s(开始) --> step1>输入参数]
+  subgraph 强调
+    step1 --> step2{判断参数合法性}
+  end
+  step2 ==> |校验失败|e
+  step2--> |校验成功|step3[处理业务]
+  step3 --> e(结束)
+  style s rx: 10, ry: 10
+  style e rx: 10, ry: 10
+```
+
+### 时序图
+
+#### 参与者
+
+```mermaid
+sequenceDiagram
+  participant 客户端
+  participant 接口服务器
+  participant 数据库
+```
+
+#### 消息
+
+##### 消息格式
+
+```
+[参与者][箭头][参与者]:消息内容
+```
+
+支持的箭头有:
+
+| 类型 | 说明     |
+|:---:|----------|
+| ->  | 无箭头实线 |
+| --> | 无箭头虚线 |
+| ->> | 箭头实线  |
+| -->>| 箭头虚线  |
+| -x  | 箭头实线带x(异步) |
+| --x | 箭头虚线带x(异步) |
+
+```mermaid
+sequenceDiagram
+  Alice->>John: Hello John, how are you?
+  John-->>Alice: Great!
+```
+
+#### 激活
+
+用 `+/-` 符号
+
+```mermaid
+sequenceDiagram
+  Alice->>+John: Hello John, how are you?
+  Alice->>+John: John, can yoy hear me?
+  John-->>-Alice: Hi Alice, I can hear you!
+  John-->>-Alice: I feel great!
+```
+
+### 甘特图
+
+```mermaid
+gantt
+dateFormat  YYYY-MM-DD
+title Adding GANTT diagram functionality to mermaid
+
+section A section
+Completed task            :done,    des1, 2014-01-06,2014-01-08
+Active task               :active,  des2, 2014-01-09, 3d
+Future task               :         des3, after des2, 5d
+Future task2              :         des4, after des3, 5d
+
+section Critical tasks
+Completed task in the critical line :crit, done, 2014-01-06,24h
+Implement parser and jison          :crit, done, after des1, 2d
+Create tests for parser             :crit, active, 3d
+Future task in critical line        :crit, 5d
+Create tests for renderer           :2d
+Add to mermaid                      :1d
+
+section Documentation
+Describe gantt syntax               :active, a1, after des1, 3d
+Add gantt diagram to demo page      :after a1  , 20h
+Add another diagram to demo page    :doc1, after a1  , 48h
+
+section Last section
+Describe gantt syntax               :after doc1, 3d
+Add gantt diagram to demo page      :20h
+Add another diagram to demo page    :48h
+```

+ 3 - 2
index.html

@@ -14,7 +14,7 @@
 </body>
 <script type="text/javascript">
 window.$docsify = {
-  name: 'leader.js.cool',
+  name: '《团队领袖培养计划》',
   repo: 'https://github.com/js-cool/leader.js.cool.git',
   loadSidebar: true,
   subMaxLevel: 2,
@@ -67,10 +67,11 @@ window.$docsify = {
         var paragraphs = main.getElementsByTagName('p');
         var ads = [];
         if(paragraphs.length > 15) {
-          ads.push(Math.ceil(Math.random()*paragraphs.length));
+          ads.push(paragraphs[Math.ceil(Math.random() * 15)]);
         }
         ads.push(paragraphs[paragraphs.length-1]);
         for(var i = 0; i < ads.length; i += 1) {
+          console.log(ads[i]);
           ads[i].insertAdjacentHTML('afterend', '<ins class="adsbygoogle" style="display:block;margin: 1.5em auto;" data-ad-client="ca-pub-5059418763237956" data-ad-slot="9518721243" data-ad-format="auto"></ins>');
           (adsbygoogle = window.adsbygoogle || []).push({});   
         }