2012/12/28

Add Author Name to Collection Portlet

By default the Plone collection portlet will display item's title only. We might want add other info for the item listing. Here is an example to add Author Name in plone.portlet.collection/collection.pt:

     itemUrl    python:useView and obj.getURL() + '/view' or obj.getURL();
-    item_icon python:getIcon(obj);"
+    item_icon python:getIcon(obj);
+    itemCreator python:obj.getObject().Creator();
+    author python:context.portal_membership.getMemberInfo(itemCreator);
+    authorName python: author and author['fullname'] or itemCreator"

Note that using Creator() instead of Creator, or you will fail when passing itemCreator to portal_membership.getMemberInfo(). This is adapted from codes in plone.app.layout/viewlets/content.py

Prof. Chen Interview by PanSci

Quotes from the interview by PanSci

如果學術界不被論文發表綁架,培養出的優秀學生可以在社會各角落,像是檢驗公司,成為專業又公正的檢驗員,未必要留在學校作學術研究;只要不背離知識的核心價值,就能成為校正社會的力量。

就像我年輕的時候讀過的《天地一沙鷗》,族群裡總有幾隻個體認為自己的翅膀是為了某些更偉大的事而存在的,不該留自己在地上;人類社會也是如此,我認為大學裡頭這樣的個體應該比例上要多一點。

如果全台灣的大學-包括台大的研究背後真正的目的都是為了教學,而不是學術發表,那我們的視野會變得很不一樣。

2012/12/18

Plone Template Global Variables

It is a common task to get information about the state of your site and other global variables. For Plone 4+, the recommended approach is to use one of the following browser views:

  • @@plone_portal_state
  • @@plone_context_state
  • @@plone_tools

You can find how they are defined in plone.app.layout/globals/configure.zcml:

<browser:page
   name="plone_tools"
   for="*"
   permission="zope.Public"
   class=".tools.Tools"
   allowed_interface=".interfaces.ITools"
   />

<browser:page
   name="plone_context_state"
   for="*"
   permission="zope.Public"
   class=".context.ContextState"
   allowed_interface=".interfaces.IContextState"
   />

<browser:page
   name="plone_portal_state"
   for="*"
   permission="zope.Public"
   class=".portal.PortalState"
   allowed_interface=".interfaces.IPortalState"
   />

For example, a straight way to add the homepage link:

<a href="http://www.yoursite.com/">home</a>

This works only for the site running on the specific domain name. When testing, you are likely to run on localhost or IP address, that the homepage URL needs updated accordingly. The recommended style looks like this:

<a href="#"
   tal:define="home_url context/@@plone_portal_state/portal_url"
   tal:attributes="href home_url">home</a>

2012/12/04

Ushahidi on Ubuntu

這次裝的是 Ushahidi 2.6.1 版本,想從 git 下載安裝的話,可以試試其他文件說明

在 Ubuntu 12.04 大致裝了這些:

$ apt-get install mysql-server
$ apt-get install php5-mysql php5-curl php5-gd php5-mcrypt php5-imap

搭配 Apache 的話,可以設定 sites-available/default 的內容:

<Directory “/var/www/ushahidi”>
    AllowOverride All
</Directory>

還要啟用 mod_rewrite 模組才能使用 Clean URLs 功能。

設定好 MySQL 帳號權限後,差不多就可以透過瀏覽器執行安裝步驟。

Error!
This deployment spans within one country only.
Please make sure the report location is within the country Kenya.

太急著要新增表單的話,可能會遇到上述訊息,到 http://your.site.org/ushahidi/admin 進入管理介面,設定地圖等參數值,想新增自己的圖層,可以編輯 application/helpers/map.php 找 Generate the Map Base layer Object 內容,依樣畫葫蘆。首頁的內容可以先查看 themes/default/views/main/layout.php 檔案。

訊息翻譯檔案位於 application/i18n 目錄裡,用不到的語系檔案可以直接刪掉,語系選單可以到 application/helpers/ush_locale.php 找,操作介面的翻譯內容可以到 application/i18n/zh_TW/ui_main.php 找。