LinuxServer

# なぜ pukiwiki から wiki.js へ移行しようと思ったか 1 1. コメントの受け付けしたい 1. スパムがやだ 1. 過去にストーカー被害にあったこともあり、特定のユーザーを拒否できる仕組みを実装したい 1. ユーザーが、ユーザー自身を登録できる wiki が良いなぁ。。。 -> wiki.js となりました。

## なぜ pukiwiki から wiki.js へ移行しようと思ったか 2

# 目次

<!-- toc -->

# 公式リンク(top)

## Editor - Markdown

## Editor - MarkDown(日本語)

# 前提

## 環境

## 他に検討したもの

# 構築

## 構築コマンド

## MariaDBへ切り替え

### なぜ?

### 参考サイト

### MariaDB のインストールと自動起動設定,起動 ``` sudo apt install mariadb-server sudo apt start mariadb sudo apt enable mariadb ```

### 初期設定 ``` sudo mysql_secure_installation ```

### (MariaDB) wiki.js用ユーザーの作成とデータベースの作成 1. root ユーザーでログイン

	```
	mysql
	```

1. データベースの作成

	```
	create database wikijs;
	```

1. 権限の設定とパスワードの設定

	```
	grant all privileges on wikijs.* to wikijs@'localhost' identified by 'password'; 
	```

1.権限の更新

	```
	flush privileges; 
	```

1. MariaDBから出る。

	```
	exit
	```

### wiki.js の変更

	# PostgreSQL / MySQL / MariaDB / MS SQL Server only:
	host: localhost
	port: 3306
	user: wikijs
	pass: password
	db: wikijs
	ssl: false
	```

### backup [こちらを参照(mysql)](/310-Linux/313-LinuxServer/mysql#mysql-server-backup)

# 設定変更

## config.yml の場所,Path

## SSL(TLS)化 1. key と crt は適当なディレクトリへ保存

	(自分はLet's Encryptは使ってません。有償の証明書を持ってるため)
	ssl:
	#enabled: false
	enabled: true
	port: 3443
	# Provider to use, possible values: custom, letsencrypt
	provider: custom
	#provider: letsencrypt
	# ++++++ For custom only ++++++
	# Certificate format, either 'pem' or 'pfx':
	format: pem
	# Using PEM format:
	# key
	key: /etc/pki/tls/certs/server.key
	# 証明書
	cert: /etc/pki/tls/certs/server.crt
	# Using PFX format:
	#pfx: path/to/cert.pfx
	# Passphrase when using encrypted PEM / PFX keys (default: null):
	passphrase: null
	# Diffie Hellman parameters, with key length being greater or equal
	# to 1024 bits (default: null):
	dhparam: null
	# ++++++ For letsencrypt only ++++++
	domain: wikijp.tar3.net
	subscriberEmail: hogehoge@unyaunya.net
	```

## dataPAth: の変更

## faviconの変更 1. favicon.ico

	- path
		- /opt/wikijs/assets/favicon.ico
	- 画像解像度
		- 48 x 48

1. favicons ディレクトリ

	- path
		- /opt/wikijs/assets/favicons/
		|ファイル名|解像度|
		|-|-|
		|android-chrome-192x192.png|192 x 192|
		|android-chrome-256x256.png|256 x 256|
		|apple-touch-icon.png|180 x 180|
		|favicon-16x16.png|16 x 16|
		|favicon-32x32.png|32 x 32|
		|mstile-150x150.png|150 x 150|
		{.dense}

## Web画面からの設定変更

### 全般設定

### 言語

### ナビゲーション

### グループ

### アナリティクス

### セキュリティ

# 記事の作成関連

## markdown

### User's manual(公式)

### 書式の設定方法(参考サイト)

### designet(参考サイト)

#### ブロッククォート(箇条書きと組み合わせない場合、使用可能です) ```

スタイルなし eee

.is-info aaa {.is-info}

.is-succsess bbb {.is-success}

.is-warning ccc {.is-warning}

.is-danger ddd {.is-danger} ```

スタイルなし eee

.is-info aaa {.is-info}

.is-succsess bbb {.is-success}

.is-warning ccc {.is-warning}

.is-danger ddd {.is-danger}

#### 脚注 ``` This sentence[^1] needs a few footnotes.[^2]

[^1]: A string of syntactic words. [^2]: A useful example sentence. ``` This sentence[^1] needs a few footnotes.[^2]

[^1]: A string of syntactic words. [^2]: A useful example sentence.

#### キーボード,<kbd></kbd> ```

kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>o</kbd> ```

kbd>Ctrl</kbd> + <kbd>Shift</kbd> + <kbd>o</kbd>

#### tabset ```

### タブ {.tabset}

#### タブ aaa タブの記事

#### タブ bbb タブの記事2 ```

### タブ {.tabset}

#### タブ aaa タブの記事

#### タブ bbb タブの記事2

# メディア資産(画像など)の管理

## 前提条件

## 関連情報は3つ 1. データベース(MariaDB)

	1. assets
	1. assetFolders

1. dataPath

	1. /mnt/hoge/munya/wikijs/imagedirectorya/imagedirectoryb/testimage.png

## table の desc 情報 1. assets

	| Field     | Type                   | Null | Key | Default                  | Extra          |
	|-----------|------------------------|------|-----|--------------------------|----------------|
	| id        | int(10) unsigned       | NO   | PRI | NULL                     | auto_increment |
	| filename  | varchar(255)           | NO   |     | NULL                     |                |
	| hash      | varchar(255)           | NO   |     | NULL                     |                |
	| ext       | varchar(255)           | NO   |     | NULL                     |                |
	| kind      | enum('binary','image') | NO   |     | binary                   |                |
	| mime      | varchar(255)           | NO   |     | application/octet-stream |                |
	| fileSize  | int(10) unsigned       | YES  |     | NULL                     |                |
	| metadata  | longtext               | YES  |     | NULL                     |                |
	| createdAt | varchar(255)           | NO   |     | NULL                     |                |
	| updatedAt | varchar(255)           | NO   |     | NULL                     |                |
	| folderId  | int(10) unsigned       | YES  | MUL | NULL                     |                |
	| authorId  | int(10) unsigned       | YES  | MUL | NULL                     |                |
	{.dense}

1. assetFolders

	| Field    | Type             | Null | Key | Default | Extra          |
	|----------|------------------|------|-----|---------|----------------|
	| id       | int(10) unsigned | NO   | PRI | NULL    | auto_increment |
	| name     | varchar(255)     | NO   |     | NULL    |                |
	| slug     | varchar(255)     | NO   |     | NULL    |                |
	| parentId | int(10) unsigned | YES  | MUL | NULL    |                |
	{.dense}

## 概要 1. assets が画像情報の格納先です。

	- folderID で assetFolders へ正規化されています。
	ここで紐づけられたフォルダに画像が入っている必要があります。

1. assetFolders は、親フォルダ名を持ってるだけで一般的な基準情報ですね。

	- フォルダ名はここで決まります。

## 場面ごとの変更方法(MariaDBでの変更方法)

### 共通

### メディア資産で表示されるフォルダ名の変更

### メディア資産で表示されるフォルダ名の削除

### メディア資産で表示される画像ファイルのフォルダ移動 1. 正直、これは画像を再アップロードした方が早いかもしんないw 1. WHERE の後ろのIDは、対象の画像ファイルのid

	folderIdは上記「SELECT * FROM assetFolders;」の結果から変更したい(ターゲット)フォルダーIDを入力
	```
	update assets SET folderId=35 WHERE id>=24 and id<=36;
	```

1. Linuxサーバ上のファイルを移動

	- 例) imagedirectory<span style='color:red;'>**b**</span> -> imagedirectory<span style='color:red;'>**c**</span>
		```
		mv /mnt/hoge/munya/wikijs/imagedirectorya/imagedirectoryb/testimage.png /mnt/hoge/munya/wikijs/imagedirectorya/imagedirectoryc/testimage.png
		```

1. イメージリンクを変更

	- 前(例) imagedirectory<span style='color:red;'>**b**</span> -> imagedirectory<span style='color:red;'>**c**</span>
		```
		![testimage.png](/imagedirectorya/imagedirectoryb/testimage.png)
		```
	- 後(例)
		```
		![testimage.png](/imagedirectorya/imagedirectoryc/testimage.png)
		```

# Microsoft Visual Studio Code(vscode)を使用

## おすすめ拡張機能 1. Markdown Preview Enhanced 1. Markdown All in One

### 使い方(Markdown Preview Enhanced)

### 使い方(Markdown All in One)

## vscode 共通機能の設定についてはこちら

## (vscode) 目次の作成方法

# Log (ログ) の出力,確認

## rsyslog のインストール ``` sudo apt install rsyslog ```

## daemonの実行と再起動時の自動実行設定 ``` sudo systemctl start rsyslog sudo systemctl enable rsyslog ```

## log の確認 ``` cat /var/log/syslog ```

## 新規ユーザーや新規コメントの確認

# elasticsearchの導入

## install 1. レポジトリの追加

	```
	sudo wget https://artifacts.elastic.co/GPG-KEY-elasticsearch -O /etc/apt/keyrings/GPG-KEY-elasticsearch.key
	sudo su -
	echo "deb [signed-by=/etc/apt/keyrings/GPG-KEY-elasticsearch.key] https://artifacts.elastic.co/packages/8.x/apt stable main" | tee /etc/apt/sources.list.d/elastic-8.x.list 
	```

1. install

	```
	sudo apt update
	sudo apt install apt-transport-https
	sudo apt -y install elasticsearch
	```
	- 以下に表示されているパスワードをメモする
		```
		The generated password for the elastic built-in superuser is :
		```
	- アナライザ トークナイザ、「analysis-kuromoji」のインストール
		```
		sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install analysis-kuromoji
		```

## 設定

### メモリ関連の設定 ``` sudo vim /etc/elasticsearch/jvm.options ```

	-Xms512m
	-Xmx512m
	```
	```
	# ======================== Elasticsearch Configuration =========================
	#
	# NOTE: Elasticsearch comes with reasonable defaults for most settings.
	#       Before you set out to tweak and tune the configuration, make sure you
	#       understand what are you trying to accomplish and the consequences.
	#
	# The primary way of configuring a node is via this file. This template lists
	# the most important settings you may want to configure for a production cluster.
	#
	# Please consult the documentation for further information on configuration options:
	# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
	#
	# ---------------------------------- Cluster -----------------------------------
	#
	# Use a descriptive name for your cluster:
	#
	#cluster.name: my-application
	 cluster.name: wikijs
	#
	# ------------------------------------ Node ------------------------------------
	#
	# Use a descriptive name for the node:
	#
	#node.name: node-1
	#
	# Add custom attributes to the node:
	#
	#node.attr.rack: r1
	#
	# ----------------------------------- Paths ------------------------------------
	#
	# Path to directory where to store the data (separate multiple locations by comma):
	#
	path.data: /var/lib/elasticsearch
	#
	# Path to log files:
	#
	path.logs: /var/log/elasticsearch
	#
	# ----------------------------------- Memory -----------------------------------
	#
	# Lock the memory on startup:
	#
	#bootstrap.memory_lock: true
	#
	# Make sure that the heap size is set to about half the memory available
	# on the system and that the owner of the process is allowed to use this
	# limit.
	#
	# Elasticsearch performs poorly when the system is swapping the memory.
	#
	# ---------------------------------- Network -----------------------------------
	#
	# By default Elasticsearch is only accessible on localhost. Set a different
	# address here to expose this node on the network:
	#
	#network.host: 192.168.0.1
	#
	# By default Elasticsearch listens for HTTP traffic on the first free port it
	# finds starting at 9200. Set a specific HTTP port here:
	#
	#http.port: 9200
	#
	# For more information, consult the network module documentation.
	#
	# --------------------------------- Discovery ----------------------------------
	#
	# Pass an initial list of hosts to perform discovery when this node is started:
	# The default list of hosts is ["127.0.0.1", "[::1]"]
	#
	#discovery.seed_hosts: ["host1", "host2"]
	#
	# Bootstrap the cluster using an initial set of master-eligible nodes:
	#
	#cluster.initial_master_nodes: ["node-1", "node-2"]
	#
	# For more information, consult the discovery and cluster formation module documentation.
	#
	# ---------------------------------- Various -----------------------------------
	#
	# Allow wildcard deletion of indices:
	#
	#action.destructive_requires_name: false
	#----------------------- BEGIN SECURITY AUTO CONFIGURATION -----------------------
	#
	# The following settings, TLS certificates, and keys have been automatically
	# generated to configure Elasticsearch security features on 07-06-2025 05:58:45
	#
	# --------------------------------------------------------------------------------
	# Enable security features
	xpack.security.enabled: false
	xpack.security.enrollment.enabled: false
	# Enable encryption for HTTP API client connections, such as Kibana, Logstash, and Agents
	xpack.security.http.ssl:
	enabled: false
	keystore.path: certs/http.p12
	# Enable encryption and mutual authentication between cluster nodes
	xpack.security.transport.ssl:
	enabled: false
	verification_mode: certificate
	keystore.path: certs/transport.p12
	truststore.path: certs/transport.p12
	# Create a new cluster with the current node only
	# Additional nodes can still join the cluster later
	cluster.initial_master_nodes: ["serverName"]
	# Allow HTTP API connections from anywhere
	# Connections are encrypted and require user authentication
	http.host: 0.0.0.0
	# Allow other nodes to join the cluster from anywhere
	# Connections are encrypted and mutually authenticated
	#transport.host: 0.0.0.0
	#----------------------- END SECURITY AUTO CONFIGURATION -------------------------
	```

### elasticsearchデーモンの起動と自動起動設定 ``` sudo systemctl restart elasticsearch sudo systemctl enable elasticsearch ```

## 動作確認

## wiki.js側の設定

## 動作確認して完了です。

## refresh_interval の時間を変更する。 1. 1秒から20秒へ 1. index名の確認

	```bash
	curl --noproxy '*' http://localhost:9200/_cat/indices?v
	```
	- 結果例(index の下にあるのがindex名です)(例では wikijs)
		```
		health status index  uuid                   pri rep docs.count docs.deleted store.size pri.store.size dataset.size
		yellow open   wikijs abcdefgabcdefg2JgCrqg   1   1         69            3      2.8mb          2.8mb        2.8mb
		```

1. 1秒から20秒へ

	```bash
	curl --noproxy '*' -X PUT "http://localhost:9200/wikijs/_settings" \
	  -H "Content-Type: application/json" \
	  -d '{ "index": { "refresh_interval": "20s" } }'
	```
	- 変更確認
		```bash
		curl --noproxy '*' -X GET "http://localhost:9200/wikijs/_settings?pretty"
		```

# pukiwikiからの移行(置換概要)

## 最初に

## * -> #(数の多い方からやっていきます) 1. 回目

	- 正規表現(<kbd>Alt</kbd> + <kbd>r</kbd>) : オフ
	- 置換元(スペースを入れないとurlも変わってしまうかも。。。)
		```
		***** 
		```
	- 置換先(スペースを入れないとurlも変わってしまうかも。。。)
		```
		##### 
		```
	- 全部まとめて変換(<kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Enter</kbd>)

1. 回目

	- 正規表現(<kbd>Alt</kbd> + <kbd>r</kbd>) : オフ
	- 置換元(スペースを入れないとurlも変わってしまうかも。。。)
		```
		**** 
		```
	- 置換先(スペースを入れないとurlも変わってしまうかも。。。)
		```
		#### 
		```
	- 全部まとめて変換(<kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Enter</kbd>)

1. 回目

	- 正規表現(<kbd>Alt</kbd> + <kbd>r</kbd>) : オフ
	- 置換元(スペースを入れないとurlも変わってしまうかも。。。)
		```
		*** 
		```
	- 置換先(スペースを入れないとurlも変わってしまうかも。。。)
		```
		### 
		```
	- 全部まとめて変換(<kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Enter</kbd>)

1. 回目

	- 正規表現(<kbd>Alt</kbd> + <kbd>r</kbd>) : オフ
	- 置換元(スペースを入れないとurlも変わってしまうかも。。。)
		```
		** 
		```
	- 置換先(スペースを入れないとurlも変わってしまうかも。。。)
		```
		## 
		```
	- 全部まとめて変換(<kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Enter</kbd>)

1. 回目

	- 正規表現(<kbd>Alt</kbd> + <kbd>r</kbd>) : オフ
	- 置換元(スペースを入れないとurlも変わってしまうかも。。。)
		```
		* 
		```
	- 置換先(スペースを入れないとurlも変わってしまうかも。。。)
		```
		# 
		```
	- 全部まとめて変換(<kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Enter</kbd>)

## + -> 1.

## 「----」 -> Tab へ

## ハッシュタグの消去

## リンクの変更

## 改行 1. チルダ

	- 正規表現(<kbd>Alt</kbd> + <kbd>r</kbd>) : オン
	- 置換元
		```
		~\n
		```
	- 置換先
		```
		\n\t
		```
	- 全部まとめて変換(<kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Enter</kbd>)

1.

	- 正規表現(<kbd>Alt</kbd> + <kbd>r</kbd>) : オフ
	- 置換元
		```
		&br;
		```
	- 置換先
		```
		<br>
		```
	- 全部まとめて変換(<kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>Enter</kbd>)

## -- -> tabへ

## template

	```
	```

## あまりにも面倒なので python でプログラムを組みましたw 1. 最初に

	1. 実行は自己責任でお願いします。
	1. とりあえず動けば良いや、的なやっつけプログラムです。
	1. python、始めて組んだんですが、まぁ他の言語と大差ないかなぁ。。。
		なんでこんなに世間で話題になってるのか、いまいちわからなかったです。。。
	1. 4時間位で作ったので、まだバグはありそうw
	1. python の基本的な使い方は[こちら](/510-program/python/python)から

1. 機能

	1. Listの後ろに半角スペースが無ければ追加
	1. Tabの処理
	1. \+ を 1. へ
	1. \* を # へ
	1. リンクを変更
		- 例
			- 変更前
				```
				[[Link:https://dummy.hoge.net]]
				```
			- 変更後
				```
				[Link](https://dummy.hoge.net)
				```
	1. 表を変換
	1. #の下はタブ無しへ

1. 更新履歴

	|日時|更新内容|
	|-|-|
	|2025/6/15 13:23|# or * 後のTab処理が反映されなかったのを修正|
	|2025/6/15 8:32|``&imgr(./image/keyboard/Mechanical-Jiku-12_2.JPG,50%);``の形式からwiki.jsの画像リンクへ変更<br> -> ``![keyboardHHKJPLite2Black.jpg](%ImgFilePath%/keyboardhhkjplite2black.jpg)``|
	|2025/6/14 10:20 |# と表組みに対応|
	|2025/6/9 10:20 |間違えて ' と指定した個所を ` へ修正|
	{.dense}

1. その他

	1. 以下2点が同時に発生する時、行頭のタブが一つ足りなくなる不具合があります。
		ただ、自分にはちょっと無理かもしれない。。。
		1. リストのインデントが増えたり減ったりする時(例) 「\t\t1.」 -> 「\t1.」)
		1. `` ``` ``を閉じる際

``` import re import os

class CheckTabSharpClass:

   def __init__(self) -> None:
       self.tabCharacter = ""
       self.sharpAsteriskFlag = False
       self.tableFlag = False
   def check( \
                      self \
                     ,line\
                       ):
       afterReplaceCharacter=""
       beforeReplaceCharacter=""
       if line and line[0] in {"+", "-"}:
           beforeReplaceCharacter = line[0]
           if line and line[0] == "+":
               afterReplaceCharacter = "1."
           else:
               afterReplaceCharacter = line[0]
           beforeReplaceOrderList = ""
           orderCount=0
           newListLine=""
           self.tabCharacter = ""
           for characterOrder in line:
               if characterOrder==" ":
                   break
               else:
                   if orderCount==0:
                       beforeReplaceOrderList = characterOrder
                       newListLine = characterOrder.replace(beforeReplaceCharacter,afterReplaceCharacter)
                   else:
                       beforeReplaceOrderList += characterOrder
                       newListLine = "\t" + newListLine
                       self.tabCharacter += "\t"
               orderCount += 1
           line = line.replace(beforeReplaceOrderList,newListLine)
       if line and line[0]=="|":
           self.tableFlag=True
       else:
           self.tableFlag=False
       if line and line[0]=="*":
           line = line.replace("*","#")
           self.tabCharacter=""
           self.sharpAsteriskFlag=True
       elif self.tableFlag==False:
           self.sharpAsteriskFlag=False
       return line

def checkAddSpace(line):

   headerSpace=""
   spaceFlag= False
   beforeReplace=""
   for character in line:
       if character==" ":
           spaceFlag = True
           headerSpace += character
           break
       elif character.startswith('*') \
               or character.startswith('+') \
               or character.startswith('-') \
                   :
           pass
       else:
           beforeReplace = headerSpace
           headerSpace = headerSpace + " "
           break
       headerSpace += character
   if spaceFlag == False:
       line= line.replace(beforeReplace,headerSpace)
   return line

class CreateTabTextClass:

   def __init__(self) -> None:
       self.codeFlag=False
       self.codeHeadTab=""
       self.tableFlag=False
   def CreateTabText( \
                      self \
                     ,eachLine \
                     ,checkTabSharpClass \
                       ):
       tabCharacter=""
       returnEachLine=""
       returnEachLine=eachLine
       if checkTabSharpClass.sharpAsteriskFlag==False \
               and checkTabSharpClass.tableFlag==False:
           tabCharacter="\t"
       self.codeHeadTab=""
       if eachLine.startswith(" "):
           if self.codeFlag == False:
               self.codeHeadTab = tabCharacter + checkTabSharpClass.tabCharacter + "```\n"
           
           returnEachLine = self.codeHeadTab + tabCharacter + checkTabSharpClass.tabCharacter + eachLine[1:]
           self.codeFlag=True
       elif eachLine.startswith(' ')==False \
               and self.codeFlag==True :
           returnEachLine = self.codeHeadTab + tabCharacter + checkTabSharpClass.tabCharacter + "```\n" + eachLine
           self.codeFlag=False
       
       if eachLine.replace("\t","").startswith("|"):
           tableSeparate="|"
           
           if self.tableFlag==False:
               for pipeCount in range(1, eachLine.count("|")):
                   tableSeparate+="-|"
               returnEachLine= tabCharacter + checkTabSharpClass.tabCharacter + eachLine \
                                    + tabCharacter + checkTabSharpClass.tabCharacter + tableSeparate + "\n"
               self.tableFlag=True
           else:
               returnEachLine= tabCharacter + checkTabSharpClass.tabCharacter + eachLine
       elif self.tableFlag==True \
               and eachLine.replace("\t","").startswith("|")==False \
                   :
           self.tableFlag=False
       return returnEachLine

class ConvertImgrClass:

   def convert(self, argEachLine):
       eachLine=argEachLine
       afterSplitComma=[]
       afterSplitSlash=[]
       imgFileName=""
       afterSplitComma=eachLine.split(",")
       afterSplitSlash=afterSplitComma[0].split("/")
       imgFileName=afterSplitSlash[-1].lower()
       eachLine="!["+imgFileName+"](%ImgFilePath%/"+imgFileName+")\n"
       return eachLine

class TransFormLineClass:

   def transform_line( \
                        self \
                      , inputLines \
                       ):
       
       try:
           checkTabSharpClass = CheckTabSharpClass()
           createTabTextClass = CreateTabTextClass()
           convertImgrClass = ConvertImgrClass()
           eachLine=""
           outputText=""
           for line in inputLines:
               eachLine=line
               if \
                   eachLine.startswith('*') \
                       or eachLine.startswith('+') \
                       or eachLine.startswith('-') \
                       or eachLine.startswith('|') \
                           :
                   #Spaceが無い場合に追加
                   if eachLine.startswith('|')==False:
                       eachLine = checkAddSpace(eachLine)
                   #Tabと * の処理
                   eachLine = checkTabSharpClass.check(eachLine)
                   eachLine=re.sub(r" \[.........\]", "", eachLine)
                   eachLine=re.sub(r"\[.........\]", "", eachLine)
               eachLine=createTabTextClass.CreateTabText( \
                                                       eachLine \
                                                       , checkTabSharpClass \
                                                           )
               if "&imgr" in eachLine:
                   eachLine=convertImgrClass.convert(eachLine)
               eachLine=eachLine.replace("~","")
               eachLine=eachLine.replace("[[","[")
               eachLine=eachLine.replace(":http","](http")
               eachLine=eachLine.replace("]]",")")
               eachLine=eachLine.replace("''","**")
               eachLine=eachLine.replace("&br;","<br>")
               eachLine=eachLine.replace("|h","|")
               outputText+=eachLine
           
           del createTabTextClass
           del checkTabSharpClass
           del convertImgrClass
           return outputText
       
       except:
           import traceback
           traceback.print_exc()

# ファイル単位で処理する場合 inputFileName="input.pukiwiki" outputFileName="output.wikijs" with open('pukiwikiWikijsSource\\'+inputFileName, 'r', encoding='utf-8') as infile, \

    open('pukiwikiWikijsSource\\'+outputFileName, 'w', encoding='utf-8') as outfile:
   transFormLineClass = TransFormLineClass()
   inputLines=[]
   for line in infile:
       inputLines.append(line)
   outputText=""
   outputText=transFormLineClass.transform_line(inputLines)
   if outputText is not None and isinstance(outputText, str):
       outfile.write(outputText)
   del transFormLineClass

``` 1. PlantUML,シーケンス図

	1. 
		```
		@startuml sequence
		title pukiwiki -> wiki.js 変換プログラム
		participant main
		participant TransFormLineClass
		participant CheckTabSharpClass
		participant CreateTabTextClass
		Activate main
		note right main
			inputFileName="input.pukiwiki"
			outputFileName="output.wikijs"
			open input.pukiwiki
			open output.wikijs
		end note
		loop foreach line in input file
			note right main
				inputLines.append(line)
			end note
		end
		note right main
			outputText=transFormLineClass.transform_line(inputLines)
		end note
		main -> TransFormLineClass:  transform_line(self, inputLines)
		Activate TransFormLineClass
			note right TransFormLineClass
				checkTabSharpClass = CheckTabSharpClass()
				createTabTextClass = CreateTabTextClass()
				eachLine=""
				outputText=""
			end note
			TransFormLineClass -> CheckTabSharpClass
			activate CheckTabSharpClass
			TransFormLineClass -> CreateTabTextClass
			activate CreateTabTextClass
			loop foreach line in inputLines
				note right TransFormLineClass
					eachLine = line
				end note
				
				alt eachLine.startswith('*') or eachLine.startswith('+') or eachLine.startswith('-') or eachLine.startswith('|') 
					alt eachLine.startswith('|')==False
						TransFormLineClass -> main: checkAddSpace
						note right TransFormLineClass
							1. # - のあとに半角スペースが無ければ挿入
						end note
						activate main
						main --> TransFormLineClass: eachLine
						deactivate main
					end
					TransFormLineClass -> CheckTabSharpClass: check(eachLine)
					note right  CheckTabSharpClass
						afterReplaceCharacter=""
						beforeReplaceCharacter=""
					end note
					alt line and line[0] in {"+", "-"}
						note right CheckTabSharpClass 
							+ を 1. へ変更
							beforeReplaceOrderList = ""
							orderCount=0
							newListLine=""
						end note
						loop characterOrder in line
							alt characterOrder==" "
								note right CheckTabSharpClass 
									何文字目かの文字(foreach)が、半角スペース(もう終わりなら)
									break
								end note
							else
								alt orderCount==0
									note right CheckTabSharpClass 
										文字が - か + で、かつ最初の文字の時
										beforeReplaceOrderList = characterOrder
										newListLine = characterOrder.replace(beforeReplaceCharacter,afterReplaceCharacter)
									end note
								else
									note right CheckTabSharpClass 
										文字が - か + で、かつ2文字目以降(タブの追加)
										beforeReplaceOrderList += characterOrder
										newListLine = "\ t" + newListLine
										self.tabCharacter += "\ t"
									end note
								end
							end
							note right CheckTabSharpClass 
								orderCount += 1
							end note
						end
						note right CheckTabSharpClass 
							line = line.replace(beforeReplaceOrderList,newListLine)
						end note
					end
					alt line and line[0]=="|" 
						note right CheckTabSharpClass 
							self.tableFlag=True
						end note
					else
						note right CheckTabSharpClass 
							self.tableFlag=False
						end note
					end
					alt line and line[0]=="*"
						note right CheckTabSharpClass 
								line = line.replace("*","#")
								self.tabCharacter=""
								self.sharpAsteriskFlag=True
						end note
					else self.tableFlag==False
						note right CheckTabSharpClass 
							self.sharpAsteriskFlag=False
						end note
					end
					CheckTabSharpClass --> TransFormLineClass: eachLine=line
					note right TransFormLineClass
						ハッシュタグの消去
					end note
				end
				TransFormLineClass -> CreateTabTextClass:createTabText(eachLine, checkTabSharpClass)
				note right CreateTabTextClass
					tabCharacter=""
					returnEachLine=""
					returnEachLine=eachLine
				end note
				alt checkTabSharpClass.sharpAsteriskFlag==False
					note right CreateTabTextClass
						tabCharacter="\ t"
					end note
				end
				alt checkTabSharpClass.tableFlag==False
					note right CreateTabTextClass
						tabCharacter="\ t"
					end note
				end
				alt self.eachLine.startswith(" "):
					alt self.codeFlag == False
						note right CreateTabTextClass
							self.codeHeadTab = tabCharacter + "```\n"
						end note
					end
					note right CreateTabTextClass
						returnEachLine = self.codeHeadTab + tabCharacter + "" + eachLine[1:]
						self.codeFlag=True
					end note
				else self.eachLine.startswith(' ')==False and self.codeFlag==True
					note right CreateTabTextClass
						returnEachLine = tabCharacter + "```\n" + eachLine
						self.codeFlag=False
					end note
				end
				alt eachLine.replace("\ t","").startswith("|")
					note right CreateTabTextClass
						tableSeparate="|"
					end note
					alt eachLine.replace("\t","").startswith("|")
						note right CreateTabTextClass
							tableSeparate="|"
						end note
						loop pipeCount in range(1, eachLine.count("|"))
							note right CreateTabTextClass
								tableSeparate+="-|"
							end note
						end
						note right CreateTabTextClass
							returnEachLine= tabCharacter + checkTabSharpClass.tabCharacter + eachLine \ 
												+ tabCharacter + checkTabSharpClass.tabCharacter + tableSeparate + "\n"
							self.tableFlag=True
						end note
					else
						note right CreateTabTextClass
							returnEachLine= tabCharacter + checkTabSharpClass.tabCharacter + eachLine
						end note
					end
				else self.tableFlag==True and eachLine.replace("\t","").startswith("|")==False 
					note right CreateTabTextClass
						self.tableFlag=False
					end note
				end
				CreateTabTextClass --> TransFormLineClass:returnEachLine
				note right TransFormLineClass
					eachLine=eachLine.replace("~","")
					eachLine=eachLine.replace("[[","[")
					eachLine=eachLine.replace(":http","](http")
					eachLine=eachLine.replace("]]",")")
					eachLine=eachLine.replace("''","**")
					outputText+=eachLine
				end note
			end
			TransFormLineClass --> main: outputText                        
			deActivate CreateTabTextClass
			deActivate CheckTabSharpClass
		deActivate TransFormLineClass
		note right main
			outfile.write(outputText)
		end note
		@enduml
		```
	1. ![plantuml-01.png](/310-linux/313-linuxserver/wikijs/plantuml-01.png)

# その他

## Visual Editor と Markdown 比較と感想

### Visual Editorの長所

### Markdownの長所 vs codeでの編集が可能。

# (おまけ) なぜか vim をインストール後、かつsshの状態で、マウス右クリックしても貼り付けできない

# コメントをフルオープンにした場合、どれくらいスパムが来るのか検証


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS