搜索
Table_bottom

标签云
Table_bottom

分类
Table_bottom

声明
文章若未特別註明,皆採用 知识共享许可协议 請自覺遵守
Table_bottom

鏈。。。
Table_bottom

存档
Table_bottom

匆匆过客
83610
Table_bottom

功能
Table_bottom

在GitLab Pages部署TiddlyWiki5

人云E云 posted @ 2018年6月05日 22:22 in Linux with tags GitLab TiddlyWiki static website , 1469 阅读

想將TiddlyWiki搭建在GitLab Pages已經很久。今日終於用半個小時時間完成此事,完成後覺得竟然如此簡單。然而之前始終找不到合適的教程,實在讓人糾結,故而記錄要點(並簡單介紹TiddlyWiki在該模式下的使用),以便有需要者。

簡介

TiddlyWiki是一個工作在瀏覽器中的wiki系統,其對我來說最有用的特性是:1) 支持插件(通過JS);2) 支持自定義宏 (macro)。

由於TiddlyWiki設計爲在瀏覽器中工作,所以理所當然地可以託管在GitHub Pages或GitLab Pages這類靜態網站上。雖然使用TiddlyWiki本身的單一HTML版即可,但我總覺得這樣比較臃腫,而且不好追蹤版本變更,所以更傾向於這種使用server版功能的方式(即每個tiddler是單一文件,之後轉換爲網站)。

雖然已有前人給出的搭建模板,只用fork過來即可使用,但我個人略有強迫症,想要一個“清淨”的版本。所以簡單翻閱了GitLab的相關說明頁面後,仿照其例子自己從頭構建了一個倉庫(及對應Pages)。

本文假設讀者有基本的git知識,並且已安裝tiddlywiki服務端軟件(tiddlywiki)。下面的描述均假設當前在一個空目錄/空的git倉庫中。

初始化TiddlyWiki

TiddlyWiki支持兩種模式:單一HTML頁面模式本地服務器模式。既然要使用版本控制,本地服務器模式更加適合:該模式下,每個頁面(即Tiddler)均分別以文件形式存放,更適宜版本控制。

首先,使用下面命令創建服務器模式的TiddlyWiki:

tiddlywiki wiki --init server

該命令將會創建一個名叫wiki的目錄,其中存放TiddlyWiki服務器模式配置。要在本地瀏覽或更改該wiki的內容,執行下面命令,並且打開瀏覽器訪問localhost:8080:

tiddlywiki wiki --server

對該wiki的編輯均會存放在wiki目錄下(的tiddlers目錄中)。而且配置、插件等也是以文件形式存在,可以說是無縫接合。

在該模式下,對tiddler的修改會自動保存(可能有較小延遲),而不需要(也不應該)使用“保存”按鈕——除非你的確想將你的wiki保存爲單一HTML。類似地,在GitLab Pages的頁面上的修改不會被持久化,因爲沒有後端服務程序在執行——但你可以將其當成一個安全的沙箱隨便修改。

GitLab Pages

GitLab Pages是使用GitLab的流水線機制而構建起來的特殊功能。其理念源於GitHub Pages,但實現方式有所區別,且GitLab Pages更爲靈活(至於github pages如要達到該靈活度,則必須依賴外部CI)。

在倉庫根目錄中,.gitlab-ci.yml控制GitLab流水線如何執行——當push發生時,GitLab會自動根據該文件執行CI。GitLab Pages在.gitlab-ci.yml中使用專門的pages節。在該CI執行結束後,倉庫(生成文件中)的public目錄中的文件會被發佈到GitLab Pages上(網址構成同GitHub Pages類似)。GitLab Pages完全依賴該配置文件中的描述,不需要像GitHub那樣手動打開Pages。

對於部署TiddlyWiki來說,所用的.gitlab-ci.yml內容其實很短:

image: node:latest

pages:
  stage: deploy
  script:
    - npm install -g tiddlywiki
    - tiddlywiki wiki --build
    - mv wiki/output public
  artifacts:
    paths:
      - public
  only:
    - master

原理上看,搭建的方法就是通過tiddlywiki的工具,在CI時生成頁面,然後放到public目錄。由於tiddlywiki是nodejs程序,所以在.gitlab-ci.ymlimage部分聲明使用nodejs的docker鏡像。

注意,如前文所說,我這裏將tiddlywiki的文件結構(tiddlywiki.info所在地)放在之前所描述的wiki目錄中。該代碼片段中所有引用wiki目錄的地方均是出於此處。

至此,GitLab方面也已經設置完畢。之後只要正常將該倉庫提交,並push到GitLab上即可。

  • 无匹配
六翼 说:
2019年3月20日 08:09

剛剛好像沒有找到地方留言,再問一次好了:

並且已安裝tiddlywiki服務端軟件(tiddlywiki)

請問要如何安裝這個服務端軟件呢?

Avatar_small
人云E云 说:
2019年4月08日 22:12

就按照你所用系統/發行版上常規安裝方法即可,保證本機能運行(主要是爲了下一步的初始化,以及之後在本地修改/新建內容)。
比方說我用的是Arch Linux,在AUR上有,按照AUR的正常方法安裝就行;另外archlinuxcn源中有人打包好了,如果添加了archlinuxcn源的話直接pacman -S nodejs-tiddlywiki就行。
另外,官網說可以直接npm install -g tiddlywiki(我不熟悉,參見官網)。

Nicco Park Kolkata 说:
2022年11月11日 06:53

West Bengal State, India, is among the top-best states with beautiful scenarios, temples, parks, and more. The state contains the popular Nicco Park Amusement park located in Jiheel Meel sector 4 of Bidhannagar. Nicco Park Kolkata The park receives many visitors from inside and outside the WB state. Visitors can experience various enjoyment services at affordable prices. Nicco Park was established in 1991 under the name Disneyland of West Bengal.

192.168.l.l login pa 说:
2023年2月08日 07:45

Do you own a router or modem, then you might have heard about the term Internal configuration and router configuration which are very important to do when you first buy a new router or when you have just reset a router. 192.168.l.l login password wifi Frankly speaking, there are hundreds of router brands across the world and every one of them has high end router models that have a different configuration process.

tgpost.in 说:
2023年5月16日 19:16

Tgpost is a project of experienced writers who have banded together for specialised news coverage of recent events across the nation (India). Our team is made up of professional writers and citizen journalists with a wide range ofjournalism interests who are committed about delivering education updates in tgpost.in the public interest while maintaining transparency. Our reporting team plans to release the Education & Recruitment Update for all age groups and provide inside coverage to show the real picture of current occurrences. As we want to provide news divided into General, Political, Crime, Sports, Entertainment, Education, and World News, our goal is to meet the needs of people of all age groups.

hora militar y hora 说:
2023年7月27日 17:03

La hora militar, también conocida como hora de 24 horas, es una forma de decir la hora utilizada por las fuerzas armadas y otras organizaciones. Es diferente del reloj normal de 12 horas que usa la mayoría de la gente. hora militar y hora normal En horario militar, el día se divide en 24 horas, a partir de la medianoche (00:00) y hasta la medianoche siguiente. Cada hora está representada por un número de dos dígitos del 00 al 23.

UP Board 2nd Class 说:
2023年9月05日 08:26 Uttar Pradesh State Primary School Students who are Eagerly Searching for the UPMSP 2nd Revised Syllabus 2024 can Stay on this webpage.Complete Subject wise SCERT UP Syllabus 2024 Pdf Format are Attached in the Following Sections for Free of Cost, Therefore, All the Students who are Going to Appear for the Examination can make use of the Information Provided here and Accordingly practice UP Board 2nd Class Syllabus 2024 Complete Uttar Pradesh Syllabus 2024 given in order to give their best in the Examination.Uttar Pradesh Primary School Parents can use the Syllabus to Understand the Concepts and Prepare their Children for the Exam, Accordingly, The UP Board Syllabus 2024 All Subject Chapter Wise Students Prepare for the Upcoming Exam.

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter