MoinMoinの運用と管理

MoinMoin を運用するうえで知っておきたいシステム管理のことや、あまり使用しない action やページの説明です。

ページ管理

ページの一覧を取得したい

クエリに ?action=titleindex と指定してアクセスする。titleindexアクションはページ名の一覧を作成する。mimetype をサポートしており text/plain または text/xml を指定できる。デフォルトは text/plain だ。

テキストの例

http://www.codereading.com/notebook/moin.cgi/TitleIndex?action=titleindex

XML 文書の例

http://www.codereading.com/notebook/moin.cgi/TitleIndex?action=titleindex&mimetype=text/xml

編集されていないページを探す

AbandonedPages にアクセスします。

存在しないページを発見する

WantedPages にアクセスします。文中に WikiName があれば自動的にリンクされるのですが、システムはリンク先となるページが存在しない WikiName の一覧を返してきます。

ページタイトルをカスタマイズ

下記のような記述で自由にページタイトルを付けるには MoinMoin/Page.py にパッチをあてます。

#title 自由なページタイトル

MoinMoin バージョン 1.8 用のパッチ。

--- MoinMoin/Page.py    2008-08-31 22:00:00.000000000 +0200
+++ MoinMoin/Page.py
@@ -715,6 +715,10 @@
         @return: pagename of this page, splitted into space separated words
         """
         request = self.request
+
+        if self.pi.get("title"):
+            return self.pi["title"]
+
         if not force and not request.user.wikiname_add_spaces:
             return self.page_name

@@ -953,6 +957,9 @@
                 else:
                     request.setPragma(key, val)

+            elif verb == "title":
+                pi["title"] = args
+
         pi['acl'] = security.AccessControlList(request.cfg, acl)
         return pi

情報源は FeatureRequests/CustomPageTitle です。

RSS にカスタム ページタイトルを出力する

上記の「ページタイトルをカスタマイズ」を行ったうえで、RSS に出力するパッチ。

--- action/rss_rc.py.orig       2010-05-15 00:26:16.000000000 +0900
+++ action/rss_rc.py    2010-05-15 00:34:47.000000000 +0900
@@ -181,7 +181,7 @@
             handler.startNode('item', attr={(handler.xmlns['rdf'], 'about'): rdflink, })

             # general attributes
-            handler.simpleNode('title', item.pagename)
+            handler.simpleNode('title', page.split_title())
             if ddiffs:
                 handler.simpleNode('link', full_url(request, page, querystr={'action': 'diff'}))
             else:

検索結果にカスタム ページタイトルを出力する

FullSearch, FullSearchCached の検索結果にカスタム ページタイトルを出力するパッチ。

--- search/results.py.orig      2010-06-22 00:48:48.000000000 +0900
+++ search/results.py   2010-06-22 00:53:22.000000000 +0900
@@ -611,7 +611,7 @@
         matches = page.get_matches(unique=1, sort='start', type=TitleMatch)

         # Format
-        pagename = page.page_name
+        pagename = page.page.split_title()
         f = self.formatter
         output = []
         start = 0

ユーザ管理

see: HelpOnUserHandling

スーパーユーザを設定する

スーパーユーザ(super user)とはUnix系OSのユーザーで言うrootにあたります。スーパーユーザはフルバックアップの作成やソフトウェア、言語パッケージのインストール、ユーザー管理などが行なえます。

スーパーユーザはwikiconfig.pysuperuserオプションとして設定できます。

superuser = [u"User1", u"User2", ...]

ユーザアカウントを無効にする

superuserでログインしてUserPreferencesから他のユーザーとしてログインして "Disable this account forever" にチェックを付けて保存する。logoutを忘れずに行なう。

ユーザアカウントを削除する

LATER!

新規ユーザの作成を禁止する

wikiconfig.py に以下の一行を追加する。バージョン1.7と1.8で使える。

actions_excluded = DefaultConfig.actions_excluded + ['newaccount']

システムのアップグレード

1.5.9 to 1.8.3 にアップグレードした時のメモ。

データの移行

MoinMoin/script/moin.py --config-dir=/path/to/config_dir migration data

上記コマンドの出力メッセージに従い rename1.txt を編集して rename2.txt にリネームした後、再び上記のコマンドを実行する。

MoinMoin/script/moin.py --config-dir=/path/to/config_dir maint cleancache

自作テーマのアップデート

そのまま使えた。

mod_rewrite を用いたSEO

url_prefix_static を /moin183/ に設定したので以下の設定を行なった。

moin.cgi の properties に script_name を 設定。

properties = {'script_name': '/notebook/moin.cgi'}

htaccess に以下の記述を追加

RewriteRule ^notebook/moin.cgi(.*)$ /moin183/moin.cgi$1 [QSA,L]

robots.txt で /moin183/ を Disallow 。

バージョン 1.8 の仕様変更メモ

ページキャッシュの削除

data/ を別のマシンにコピーした時、次のようなエラーが出てページが表示されなかった。

moinmoin 'dict' object is not callable

apache のエラーログ。

TypeError: 'dict' object is not callable

ページのキャッシュを削除すると直る。

 python site-packages/MoinMoin/script/moin.py --config-dir=$HOME/public_html/moin --wiki-url=http://www.codereading.com/notebook/ maint cleancache