PloneArticleの利用 [Plone3.3]

インストール

$PLONE_INSTANCE : /usr/local/Plone/zinstance (Plone のインスタンス)

サーバへのインストール

インストールは解凍後、開発用ソースディレクトリに Products.PloneArticle という名前で格納する。ダウンロードは http://pypi.python.org/pypi/Products.PloneArticle より行える。

# tar zxvf Products.PloneArticle-4.1.7.tar.gz
# mv Products.PloneArticle-4.1.7 $PLONE_INSTANCE/src/Products.PloneArticle

次にインスタンス内の buildout.cfg を設定する。

  eggs =
      Plone
       :
+     Products.PloneArticle

  develop =
       :
+     src/Products.PloneArticle

  [versions]
       :
+ Products.PloneArticle = 4.1.7

最後に設定を反映する。

# bin/buildout
# bin/plonectl stop; bin/plonectl start

Ploneへのインストール

次に Plone に管理者でログインし、「サイト設定→プロダクトを追加・削除」より PloneArticle をインストールする。

日本語化

日本語化はされていないため下記のファイルを Products.PloneArticle/Products/PloneArticle/i18n フォルダに追加する。Zope を再起動すると反映される。
plonearticle-ja.po 

バグフィックス

日本語名のファイルをIEでダウンロードすると文字化けする点を修正する。Products.PloneArticle/Products/PloneArticle/proxy/fileinnercontent.py を編集する。

+ from urllib import quote
+ useragent =  REQUEST['HTTP_USER_AGENT']
+ MSIE = useragent.find('MSIE')
+ filename = data.filename or self.getId()
+ if MSIE >= 0:
+     filename=quote(filename)

  RESPONSE.setHeader(
      'Content-Disposition',
-     '%s; filename="%s"' % (content_dispo, data.filename or self.getId()))
+     '%s; filename="%s"' % (content_dispo, filename))

Articleの表示ページから編集リンクを削除する

IEで機能しないため削除しておく。Products.PloneArticle/Products/PloneArticle/skins/plonearticle_models/pa_model_macros.pt を編集する。

- <metal:block use-macro="here/pa_model_macros/macros/kss-menu" />

ファイルアップロード時にタイトル未入力であれば元のファイル名をタイトルとする

Products.PloneArticle/Products/PloneArticle/skins/plonearticle/pa_innerfile_upload.py を編集する。

+ new_file_title = test(new_file_title, new_file_title, new_file.filename.split('\\')[-1])

  return context.pa_innercontent_upload(

画像アップロード時にタイトル未入力であれば元のファイル名をタイトルとする

Products.PloneArticle/Products/PloneArticle/skins/plonearticle/pa_innerimage_upload.py を編集する。

+ new_file_title = test(new_file_title, new_file_title, new_file.filename.split('\\')[-1])

  return context.pa_innercontent_upload(

 

設定

デフォルトモデル、利用可能なモデルの変更

Ploneに管理者でログインし、サイト設定の PloneArticle preferences → Models より行える。工学ではDocumentation modelのみ利用する。

デフォルトのモデル : Documentation model
利用可能なモデル : Documentation model

Articleの表示ページにカテゴリと期限と作成者を表示する

portal_skins/plonearticle_models/pa_model_macros をスキンフォルダにコピーして編集する。

+ <div align="right">
+ [<span tal:define="keywords context/Subject;
+                    keywords python:test(len(keywords), '/'.join(keywords) ,u'\u672a\u5206\u985e');"
+        tal:content="keywords" />], 
+ <span tal:content="python:u'\u63b2\u8f09\u671f\u9650 ' + test(here.expires() < DateTime('2499/12/31'),
+                   here.expires().strftime('%Y/%m/%d %H:%M'), u'\u306a\u3057')" />,  
+ <span tal:define="creator here/Creator;
+                   author python:mtool.getMemberInfo(creator);"
+       i18n:translate="label_by_author"
+       i18n:domain="plone">
+     <span tal:content="python:author and author['fullname'] or 'Unknown'"
+           i18n:name="author" />
+ </span>
+ </div>

  <div tal:replace="structure provider:plone.belowcontentbody" />

テンプレートタブを表示しない

portal_types/PloneArticle の Actions タブで Templates で設定する。

Visible? : OFF

Articleのタイトル直下に掲載日欄を設ける

portal_skins/top_skins/pa_model_macros をスキンフォルダにコピーして編集する。

  <div tal:replace="structure provider:plone.belowcontenttitle" />

+ <div class="posted_date">
+     <div tal:replace="python:test(language=='ja', u'\u63b2\u8f09\u65e5 : ', 'Posted : ')">
+         Posted : 
+     </div>
+     <div tal:replace="python:here.toLocalizedTime(here.Date())">
+         2008/02/13
+     </div>
+ </div>