Typography

活版印字


  • Home
  • Archive
  • Categories
  • Tags
  •  

© 2020 alincode

Theme Typography by Makito

Proudly published with Hexo

建構一個漂亮的文件 with gitbook

Posted at 2016-04-19 gitbook 

我想大家都很可以認同文件很重要,而且一定要有歷史記錄,但如果沒有一個很容易開啓並美觀的界面與環境,大家都會懶得看文件跟編寫文件,文件寫得再好都沒用,因為我們每天要開這麼多資料夾,這麼多視窗,如果不方便,哪輪到打開你,那最方便的方式是什麼?文字檔 + 網頁是我認為最方便的方式。

現在 Mac 的使用者漸多,並不是每個人都有 Microsoft Office(小的我買不起,所以我最討厭人家給我doc檔),有些人說,那用 google drive,但其實對於一般的使用者友善度,還是有一段差距,而且我總覺得我的游標會一直亂跑。

gitbook 有提供一個圖形化工具,可以很容易的編輯 markdown 格式的文字檔,再結合一些 git commit 的概念,就可以更新。但這對於一般使用者還是太困難,這時放在 github 的好處就顯現了,他有網站編輯 markdown 檔的界面,弄得像留言板一樣,如果你說連留言板都不知道怎麼用,恩…那…你不要用好了。

整合方案

  • github
  • gitbook for
  • nginx for 靜態檔案伺服器
  • cron for 自動排成更新

範例使用 nginx 與 gitbook 整合,實際情況會寫成 bash script 加 cron 每日自動執行與部署。

與 Gitbook 相關

安裝 Gitbook

npm install gitbook -g

編譯 gitbook html 檔

gitbook build your-document-folder

與 Nginx 相關

安裝 Nginx

brew install nginx
or
yum install nginx
or
請依照你的作業系統調整

複製到指定的資料夾

cp -R your-document-folder/_book /srv/docs

更改資料夾權限

1
2
sudo chmod -R 755 /srv/docs/
sudo chown -R www-data:www-data /srv/docs/

產生加密密碼

openssl passwd

請一定要在 nginx 處在 server 機執行此指令,否則產出的密碼是無法正常解碼的。

建立密碼檔

1
vi /etc/nginx/conf.d/your-passwd

your-passwd

1
your-login-account:your-encode-password

編輯 nginx 設定檔

vi /etc/nginx/sites-available/default

default

1
2
3
4
5
6
7
8
9
10
server {
listen 80;
server_name your.domain.name.com;
auth_basic "docs website";
auth_basic_user_file /etc/nginx/conf.d/your-passwd;

location / {
root /srv/docs;
}
}

重啟 nginx

nginx -s reload

Share 

 Previous post: Selenium with Nodejs Next post: 好書推薦 - 如何閱讀一本書 

© 2020 alincode

Theme Typography by Makito

Proudly published with Hexo