亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

搭建個人wiki站點

系統 1922 0

原文請猛戳: http://galoisplusplus.gitcafe.com/blog/2013/09/19/have-fun-with-vim-wiki/

寫blog確實是一種消化和深入理解知識的方式,但往往要整理一個完整的主題相當的耗時間。 平時我也想記一記一些有用然而散亂的tips,慢慢積累起來。 作為一位Vim忠實粉,我理所當然找到了大名鼎鼎的Vim插件 Vimwiki , 并開始借此搭建我的個人wiki。

pathogen 這個管理Vim插件的插件把Vimwiki安裝上后,需要在.vimrc中加入一些設置,其中最重要的是指定你所寫的wiki源文件的路徑和要發布的html文件的路徑:

                  
                    1
                  
                
                  
                    
                      let g:vimwiki_list = [{'path': '~/my_site/', 'path_html': '~/public_html/'}]
                    
                  
                

接下來就可以在你所指定的’path’下創建.wiki文件,編輯完后是用以下Vim命令

                  
                    1
                  
                
                  
                    
                      :Vimwiki2HTML
                    
                  
                

Vimwiki插件就會自動將該.wiki文件轉化為同名的html頁面(例如topic.wiki生成的是topic.html)并把html放到你所指定的’path_html’下。 如果要轉化所有條目可以用以下的Vim命令:

                  
                    1
                  
                
                  
                    
                      :VimwikiAll2HTML
                    
                  
                

有了html頁面,自然想發布到某網站上。我選擇了提供pages服務的業界良心Github,創建一個名為wiki的新repo( https://github.com/yszheda/wiki ),把’path_html’上的html文件托管到上面,并通過gh-pages分支發布我的Project pages( http://yszheda.github.io/wiki/ )。 頁面的樣式我偷懶直接使用了Github官方提供的Architect主題,為了讓該主題應用到所有Vimwiki生成的html頁面上,需要修改Vimwiki插件目錄下的 autoload/vimwiki/default.tpl 模板文件:

(default.tpl) download
                  
                    1
                  
                  
                    2
                  
                  
                    3
                  
                  
                    4
                  
                  
                    5
                  
                  
                    6
                  
                  
                    7
                  
                  
                    8
                  
                  
                    9
                  
                  
                    10
                  
                  
                    11
                  
                  
                    12
                  
                  
                    13
                  
                  
                    14
                  
                  
                    15
                  
                  
                    16
                  
                  
                    17
                  
                  
                    18
                  
                  
                    19
                  
                  
                    20
                  
                  
                    21
                  
                  
                    22
                  
                  
                    23
                  
                  
                    24
                  
                  
                    25
                  
                  
                    26
                  
                  
                    27
                  
                  
                    28
                  
                  
                    29
                  
                  
                    30
                  
                  
                    31
                  
                  
                    32
                  
                  
                    33
                  
                  
                    34
                  
                  
                    35
                  
                  
                    36
                  
                  
                    37
                  
                  
                    38
                  
                  
                    39
                  
                  
                    40
                  
                  
                    41
                  
                  
                    42
                  
                
                  
                    
                      
                        <!DOCTYPE html>
                      
                    
                    
                      
                        <html>
                      
                    
                    
                      
                        <head>
                      
                    
                    
                      
                        <meta
                      
                      
                        charset=
                      
                      
                        'utf-8'
                      
                      
                        >
                      
                    
                    
                      
                        <!--
                      
                    
                    
                      
                        <link rel="Stylesheet" type="text/css" href="%root_path%%css%">
                      
                    
                    
                      
                        -->
                      
                    
                    
                      
                        <link
                      
                      
                        href=
                      
                      
                        'https://fonts.googleapis.com/css?family=Architects+Daughter'
                      
                      
                        rel=
                      
                      
                        'stylesheet'
                      
                      
                        type=
                      
                      
                        'text/css'
                      
                      
                        >
                      
                    
                    
                      
                        <link
                      
                      
                        rel=
                      
                      
                        "stylesheet"
                      
                      
                        type=
                      
                      
                        "text/css"
                      
                      
                        href=
                      
                      
                        "stylesheets/stylesheet.css"
                      
                      
                        media=
                      
                      
                        "screen"
                      
                      
                        />
                      
                    
                    
                      
                        <link
                      
                      
                        rel=
                      
                      
                        "stylesheet"
                      
                      
                        type=
                      
                      
                        "text/css"
                      
                      
                        href=
                      
                      
                        "stylesheets/pygment_trac.css"
                      
                      
                        media=
                      
                      
                        "screen"
                      
                      
                        />
                      
                    
                    
                      
                        <link
                      
                      
                        rel=
                      
                      
                        "stylesheet"
                      
                      
                        type=
                      
                      
                        "text/css"
                      
                      
                        href=
                      
                      
                        "stylesheets/print.css"
                      
                      
                        media=
                      
                      
                        "print"
                      
                      
                        />
                      
                    
                    
                      
                        <!--[if lt IE 9]>
                      
                    
                    
                      
                        <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
                      
                    
                    
                      
                        <![endif]-->
                      
                    
                    
                      
                        <title>
                      
                      %title%
                      
                        </title>
                      
                    
                    
                      
                        <meta
                      
                      
                        http-equiv=
                      
                      
                        "Content-Type"
                      
                      
                        content=
                      
                      
                        "text/html; charset=%encoding%"
                      
                      
                        >
                      
                    
                    
                      
                        </head>
                      
                    
                    
                      
                        <body>
                      
                    
                    
                      
                        <header>
                      
                    
                    
                      
                        <div
                      
                      
                        class=
                      
                      
                        "inner"
                      
                      
                        >
                      
                    
                    
                      
                        <h1>
                      
                      Wiki
                      
                        </h1>
                      
                    
                    
                      
                        <h2>
                      
                      by yszheda
                      
                        </h2>
                      
                    
                    
                      
                        <a
                      
                      
                        href=
                      
                      
                        "https://github.com/yszheda/wiki"
                      
                      
                        class=
                      
                      
                        "button"
                      
                      
                        ><small>
                      
                      View project on
                      
                        </small>
                      
                      GitHub
                      
                        </a>
                      
                    
                    
                      
                        </div>
                      
                    
                    
                      
                        </header>
                      
                    
                    
                      
                        <div
                      
                      
                        id=
                      
                      
                        "content-wrapper"
                      
                      
                        >
                      
                    
                    
                      
                        <div
                      
                      
                        class=
                      
                      
                        "inner clearfix"
                      
                      
                        >
                      
                    
                    
                      
                        <section
                      
                      
                        id=
                      
                      
                        "main-content"
                      
                      
                        >
                      
                    
                    
                      %content% 
                    
                    
                      
                        </section>
                      
                    
                    
                      
                        <aside
                      
                      
                        id=
                      
                      
                        "sidebar"
                      
                      
                        >
                      
                    
                    
                      
                        <p>
                      
                      Wiki maintained by 
                      
                        <a
                      
                      
                        href=
                      
                      
                        "https://github.com/yszheda"
                      
                      
                        >
                      
                      yszheda
                      
                        </a></p>
                      
                    
                    
                      
                        <p>
                      
                      This page was generated by 
                      
                        <a
                      
                      
                        href=
                      
                      
                        "pages.github.com"
                      
                      
                        >
                      
                      GitHub Pages
                      
                        </a>
                      
                       using the Architect theme by 
                      
                        <a
                      
                      
                        href=
                      
                      
                        "https://twitter.com/jasonlong"
                      
                      
                        >
                      
                      Jason Long
                      
                        </a>
                      
                      .
                      
                        </p>
                      
                    
                    
                      
                        </aside>
                      
                    
                    
                      
                        </div>
                      
                    
                    
                      
                        </div>
                      
                    
                    
                      
                        </body>
                      
                    
                    
                      
                        </html>
                      
                    
                  
                

接下來要折騰的就是自動發布Vimwiki生成的html頁面了。 我寫了一個簡單的auto-deploy.sh腳本:

(auto-deploy.sh) download
                  
                    1
                  
                  
                    2
                  
                  
                    3
                  
                  
                    4
                  
                  
                    5
                  
                  
                    6
                  
                  
                    7
                  
                
                  
                    
                      
                        #!/bin/bash
                      
                    
                    
                      
                        path_html
                      
                      
                        =
                      
                      
                        # set your vimwiki html path
                      
                    
                    
                      
                        cd
                      
                      
                        $path_html
                      
                    
                    
                      git checkout gh-pages 
                    
                    
                      git add *.html 
                    
                    
                      git commit -m
                      
                        "syn at `date`"
                      
                    
                    
                      git push origin gh-pages 
                    
                  
                

再把它設置為定時作業,可以用經典的 crontab ,例如 crontab -e 后加入:

                  
                    1
                  
                
                  
                    
                      * 20 * * * /<path>/auto-deploy.sh
                    
                  
                

設置每日晚上八點自動發布。

不過作為一名Arch user,很早之間就 當小白鼠 從sysvinit遷移到了systemd,自然要試試這個高大上的 systemd 。 systemd也支持定時作業,以我的例子來講,我希望每日定時發布,可以從創建一般的daily event開始。

編輯 /etc/systemd/system/timer-daily.timer 文件:

                  
                    1
                  
                  
                    2
                  
                  
                    3
                  
                  
                    4
                  
                  
                    5
                  
                  
                    6
                  
                  
                    7
                  
                  
                    8
                  
                  
                    9
                  
                  
                    10
                  
                
                  
                    
                      [Unit] 
                    
                    
                      Description=Daily Timer 
                    
                    
                      [Timer] 
                    
                    
                      OnBootSec=10min 
                    
                    
                      OnUnitActiveSec=1d 
                    
                    
                      Unit=timer-daily.target 
                    
                    
                      [Install] 
                    
                    
                      WantedBy=basic.target
                    
                  
                

編輯 /etc/systemd/system/timer-daily.target 文件:

                  
                    1
                  
                  
                    2
                  
                  
                    3
                  
                
                  
                    
                      [Unit] 
                    
                    
                      Description=Daily Timer Target 
                    
                    
                      StopWhenUnneeded=yes
                    
                  
                

創建以下目錄,作為接下來要被執行的具體的定時作業的服務設置文件的路徑:

                  
                    1
                  
                
                  
                    
                      mkdir /etc/systemd/system/timer-daily.target.wants
                    
                  
                

在該目錄下添加具體要被執行的定時作業的服務設置文件 /etc/systemd/system/timer-daily.target.wants/syn-vimwiki.service

                  
                    1
                  
                  
                    2
                  
                  
                    3
                  
                  
                    4
                  
                  
                    5
                  
                  
                    6
                  
                  
                    7
                  
                  
                    8
                  
                
                  
                    
                      [Unit] 
                    
                    
                      Description=syn vimwiki 
                    
                    
                      [Service] 
                    
                    
                      Nice=19 
                    
                    
                      IOSchedulingClass=2 
                    
                    
                      IOSchedulingPriority=7 
                    
                    
                      ExecStart= /<path>/auto-deploy.sh
                    
                  
                

最后執行

                  
                    1
                  
                
                  
                    
                      systemctl enable timer-daily.timer && systemctl start timer-daily.timer
                    
                  
                

即可。

設置按小時或按星期定時發布也是可以的, 萬能的 Arch wiki 上都有詳細的說明。

關于systemd再多啰嗦幾句,遷移到systemd后自然還是可以用原來的 cron 服務的,如果某一天你打了雞血,突然變激進了,想把cron撤掉換成純systemd(Arch發行版就經常干這種事XD),在執行

                  
                    1
                  
                
                  
                    
                      systemctl stop cronie && systemctl disable cronie
                    
                  
                

之前,別忘了加入 logrotate 、 man-db-update 、 mlocate-update verify-shadow 這些服務的配置文件。 至于具體的內容,萬能的 Arch wiki 也早為不折騰不死的你準備好了XD

搭建個人wiki站點


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦?。?!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 在线观看人成午夜影片 | 色偷偷综合 | 国产伦精品一区二区三区女 | 中文字幕精品久久 | 亚洲精品成人一区二区www | 日本亚洲精品成人 | 91伦理视频| 久久国产精品免费网站 | 欧美综合国产 | 波多野结衣一区二区三区 | 欧美日韩国产另类一区二区三区 | 国产一级毛片视频在线! | 亚洲精品国产成人7777 | 美女在线看永久免费网址 | 一区二区三区高清在线 | 国产一区二区免费播放 | 欧美第一视频 | 一级特黄特交牲大片 | 久久综合中文字幕一区二区三区 | 丁香狠狠色婷婷久久综合 | 亚洲精品中文字幕不卡在线 | 久久中文视频 | 国产97公开成人免费视频 | 国内精品伊人久久久久妇 | 久久r8这里只精品99re66 | 牛牛影视午夜免费福利 | 国产免费资源 | h片在线播放 | 91长腿女神清纯大又嫩在线 | 久久久久九九 | 欧美日韩亚洲综合在线一区二区 | 毛片电| 亚州视频一区 | 欧美激情一区二区 | 久久天天躁夜夜躁狠狠躁2020 | 青青影院一区二区免费视频 | 日本精品久久久一区二区三区 | 日韩免费毛片视频 | 可以免费观看的一级毛片 | 4虎在线观看 | 99成人在线视频 |