編集メニュー > 新規作成 編集 コピー 名前の変更 アップロード 添付ファイル一覧 バックアップ

* MoinMoin [#k7f7d4c0]

** install [#f4936535]

1.8.xはpython2.5,2.4用。1.9.xは2.7-2.4用だが、古い2.4についてはあまりチェックされてないよ的なことが書かれているので1.8.9をダウンロード。展開した後、
 python setup.py install --prefix='/home/xxx/moin'
でインストール。これで

- moin/bin
- moin/lib
- moin/share

というところにインストールされる。
***instance [#v079d3ab]
次にデータ(instanceと呼ばれる)用のディレクトリをsetup。以下のスクリプトを実行

 #!/bin/bash
 
 INSTANCE=/home/smdayone/moin/
 SHARE=/home/smdayone/moin/share
 USER=smdayone
 GROUP=smdayone
 
 mkdir -p $INSTANCE
 cp -R $SHARE/moin/data $INSTANCE
 cp -R $SHARE/moin/underlay $INSTANCE
 cp -R $SHARE/moin/config/wikiconfig.py $INSTANCE
 cp -R $SHARE/moin/server/moin.wsgi $INSTANCE
 
 chown -R $USER.$GROUP $INSTANCE
 chmod -R ug+rwX $INSTANCE
 chmod -R o-rwx $INSTANCE

上のディレクトリに全部放り込んでしまう。
*** moin.cgi [#w19c1967]
moin-1.8.9/wiki/server/moin.cgiを編集してpublic_htmlに置く。
 sys.path.insert(0, '/home/smdayone/moin/lin/python2.4/site-packages')
 sys.path.insert(0, '/home/smdayone/moin/lib/python2.6/site-packages')
 sys.path.insert(0, '/home/smdayone/moin')

.htaccessの設定も忘れずに。

*** wikiconfig.py [#y4a4ed3d]
moin/wikiconfig.pyを編集。以下を設定
-data_dir = '/home/smdayone/moin/data/'
-data_underlay_dir = '/home/smdayone/moin/underlay/'
-sitename = u'SAMURAI Dayone Wiki'
-page_front_page = u"FrontPage"
-superuser = [u"superuser", ]
-acl_rights_before =

***できた? [#m1db1e7e]
これでURLをたたいてみると。FrontPageが表示されたが、テキスト表示でテーマが反映されていない感じ。うーむ。
***moin_static189 [#j8b04e55]
moin/share/moin/htdocsを丸ごとpublic_html/moin_static189にコピー。このディレクトリの中にcss等が詰まっている。
さらにwikiconfiig.pyの以下を変更。
 url_prefix_static = '/~xxx/moin_static189'
ただしこれだけではだめで、moin_satic189のpermissionを変更してあげる必要がある。ディレクトリには実効権限を与えないとだめです。(ハマった。。。)

***uploadのファイルサイズ制限 [#r739256e]
30MBのファイルは難なくuploadできてしまった。バカでかいファイルもuploadできてしまうんではないのかい?

ググってもファイルのuploadのサイズの制限については出てこない。MoinMoinではできないの?多数の人が編集できるようになっているのだからそファイルサイズの制限くらい設定できるようになっているべきなのだけれど...

結局moin/lib/python2.4/site-packages/MoinMoin/actions/AttachFile.pyを改造。
以下の行を追加。

- add_attachemntの中

         filesize = os.path.getsize(fpath)
 # kondo -->
         if filesize/1000 > 50000:     #Exceeds Max file size (50MB)
             os.unlink(fpath)
             return target, -1
 #<--
 
         _addLogEntry(request, 'ATTNEW', pagename, target)
         event = FileAttachedEvent(request, pagename, target, filesize)
         send_event(event)


- _do_uploadの中

     # add the attachment
     try:
         target, bytes = add_attachment(request, pagename, target, filecontent, overwrite=overwrite)
 # kondo
         if bytes < 0:      # file size exceeded the limit (50MB)
            return _("File size is too large, should be less than 50MB")
 #<--
         msg = _("Attachment '%(target)s' (remote name '%(filename)s')"
                 " with %(bytes)d bytes saved.") % {
                 'target': target, 'filename': filename, 'bytes': bytes}


とりあえずこれでできたっぽい。一旦サーバーにファイルが置かれてしまうが、まあよしとする。add_attachmentはzipファイルのところでも使用されているが、とりあえず無視で。