Moya's Blog

BlogDev

Development information about blogging on the Moya's Blog

TWiki Blog 系統改版升級

3 months, 2 weeks ago in , by MoyaTseng
之前的 Blog 是採用 TWiki-4.1.2 合併 BlogPlugin 所建構的,版本已經有點老舊了,所以想要換成新版本的系統。

在 4.2.0 釋出的時候,曾經嘗試升級過一次,但是當時的 Plugins 都沒有跟上新的 TWiki API 標準,所以失敗。這次捲土重來,總算有點成果。

其實新的 4.2.2 版本和一些老舊的 Plugins 還是不太合,所以,我勢必要考慮修改支援的功能才行。之前在 4.1.2 當中已經做過的 Patch 還是得全部再做過一次,因為之前沒有把這些 Patch 送回 TWiki 總站,納入新的程式管理的關係,所以現在只好重作。

以後再另外找時間來包裝這些我已經 Patch 過的檔案,然後再送回去 TWiki 總站吧。

另外,本來想嘗試把留言功能打開來,不過,試過幾次,都需要先申請帳號之後才能夠留言,相當的不方便。特別是我其實都還沒有想要開啟公開註冊的功能,所以當然就不可能留言。這個之後再另外找時間測試看看吧!應該是有方法吧,只不過我也不是那麼確定,畢竟目前知道的都已經測試過了。

然後,我把 TWiki 和 Blog 的部分頁面設計都重新最佳化過了一次。因為對 NatSkin 的瞭解更深入了一些,所以有些設定我已經比較懂得該怎麼調整了。其實調的地方不多,就是把最上方的底圖先換掉,然後取消 TWiki 的 Border,再把 Blog 的 Boder 由 thin 改到一般的 Border 模式。

最後,雖然 4.2.2 有支援 admin only 模式,但是我都不太會想要用 admin 發表文章,所以還是繼續沿用一般模式,但是把註冊功能給完全 disable 掉了。省得偶爾會有人來註冊不過,然後發信過來問我,看到信的時候會有點不好意思,所以還是完全取消算了。

… reply

BlogPlugin 增加推推王的支援

6 months, 4 weeks ago in , by MoyaTseng
研究了一陣子,再加上之前已經小規模測試的結果,覺得似乎還滿有意思的,所以決定全面支援推推王的功能支援。未來應該也會考慮增加其他的流通管道的,只不過這個網站的 performance 不太好,有很大的改善空間。 @_@、、
稍微嘗試了一下,有上推推王的文章的閱覽率還真的滿不錯的。

個人覺得對於「靜思晨語」以及「人間菩提」這兩個部分的文章,既然是有讓大家來閱覽的推廣需要,所以決定在網站上增加推推王的支援。這樣我也可以比較方便的推文上去,多一個管道,讓上人開示的內容,有多一點讓人接觸到的管道。

也歡迎大家在閱讀之後,一起來推文。讓好的觀念、思想、正念、正思維都可以普及出去。牽引更多的人來加入新道德重整時代。

以下是相關的 BlogPlugin patch:

*** RenderFullTeaser.txt-orig   2008-06-11 16:54:42.000000000 +0800
--- RenderFullTeaser.txt        2008-06-11 16:46:14.000000000 +0800
***************
*** 64,69 ****
--- 64,74 ----
  ~~~      by [[Blog.$formfield(BlogAuthor)][$formfield(BlogAuthor)]] 
  ~~~    </span>
  ~~~  </div>

+ ~~~   <div class=\"funp\">
+ ~~~    <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td>
+ ~~~    <script language=\"JavaScript\" src=\"http://funp.com/tools/button.php?url=http%3A%2F%2Fmoya.iyard.org%2Fbin%2Fview%2FBlog%2FBlogEntry318&s=12\" type=\"text/javascript\"></script>
+ ~~~    </td></tr></table>
+ ~~~   </div>
  ~~~  <noautolink>

  ~~~  %STARTALIASAREA%
  ~~~  <div class=\"blogText\">

*** RenderBlogEntry.txt-orig    2008-06-11 16:56:09.000000000 +0800
--- RenderBlogEntry.txt 2008-06-11 16:57:44.000000000 +0800
***************
*** 87,92 ****
--- 87,97 ----
  ~~~     <span class=\"blogAuthor\">by [[Blog.$formfield(BlogAuthor)][$formfield(BlogAuthor)]] </span> 
  ~~~     

  ~~~   </div>
+ ~~~   <div class=\"funp\">
+ ~~~    <table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td>
+ ~~~    <script language=\"JavaScript\" src=\"http://funp.com/tools/button.php?&s=12\" type=\"text/javascript\"></script>
+ ~~~    </td></tr></table>
+ ~~~   </div>
  ~~~   %STARTALIASAREA%
  ~~~   <div class=\"blogText\">
  ~~~      
<noautolink>

… reply

限制發佈時間為過去時間

8 months, 4 days ago in , by MoyaTseng
因為有時後會想要先把文章寫好,但是又想要讓他可以在時間到了之後才發佈出去,但是目前的 TWiki BlogPlugin 沒有支援這個功能,所以需要作點修改。
這一次的修改只做到列表的時候不會出現,但是針對的是全部的人,當然包括我自己在內。這樣的修改還有改善的空間,至少還需要做到讓管理員可以看到才對。如果連管理員都看不到,要作修改等等的就沒辦法了。

這次的修改,是修改位在 ~twiki/data/Blog/RenderFrontPage.txt 這個檔案的內容。在採用 DBQUERY 的時候,增加判斷「發佈時間」是否是在「系統時間」之前,如果是在系統時間之前的話,才會把他顯示出來,不然就先隱藏起來。

參考的文件:

  1. TWiki:Plugins/DBCachePlugin
  2. TWiki:Plugins/DBCacheContrib
  3. TWiki:TWiki/TWikiVariables

Perl Modules 的 Patch 內容

  • perl Time::Parse 預設不認得 dd mmm yyyy – HH:MM 的格式,最多也只認識 dd mmm yyyy HH:MM 而已,所以我們需要讓他有能力多認識一下 BlogPlugin 的時間格式。

--- ParseDate.pm-orig   Tue May 20 16:26:24 2008
+++ ParseDate.pm        Tue May 20 16:26:24 2008
@@ -665,7 +665,7 @@
 {
        my ($tr, $hr, $mr, $sr, $tzr, %options) = @_;
 
-       $$tr =~ s#^\s+##;
+       $$tr =~ s#^(-)\s+##;
 
        if ($$tr =~ s!^(?x)
                        (?:

TWiki 的 Contrib module 的 patch 內容:

  • DBCacheContrib 只提供小於、大於指定時間的功能,如果是等於的話就沒辦法判斷,所以增加了「小等及等於」和「大於及等於」指定時間這兩個新的判斷式。

  1. TWiki/Contrib/DBCacheContrib/Search.pm
    --- TWiki/Contrib/DBCacheContrib/Search.pm-orig Tue May 20 11:20:31 2008
    +++ TWiki/Contrib/DBCacheContrib/Search.pm      Tue May 20 11:19:26 2008
    @@ -72,7 +72,9 @@
         '>' => { exec => \&OP_greater, prec => 4},
         '<' => { exec => \&OP_smaller, prec => 4},
         'EARLIER_THAN' => { exec => \&OP_earlier_than, prec => 4},
    +    'EARLIER_EQUAL' => { exec => \&OP_earlier_equal, prec => 4},
         'LATER_THAN' => { exec => \&OP_later_than, prec => 4},
    +    'LATER_EQUAL' => { exec => \&OP_later_equal, prec => 4},
         'WITHIN_DAYS' => { exec => \&OP_within_days, prec => 4},
         'IS_DATE' => { exec => \&OP_is_date, prec => 4},
         '!' => { exec => \&OP_not, prec => 3},
    @@ -88,7 +90,7 @@
       );
     
     my $bopRE =
    -  "AND\\b|OR\\b|!=|=~?|<=?|>=?|LATER_THAN\\b|EARLIER_THAN\\b|WITHIN_DAYS\\b|IS_DATE\\b";
    +  "AND\\b|OR\\b|!=|=~?|<=?|>=?|LATER_THAN\\b|LATER_EQUAL\\b|EARLIER_THAN\\b|EARLIER_EQUAL\\b|WITHIN_DAYS\\b|IS_DATE\\b";
     my $uopRE = "!|[lu]c\\b";
     
     my 
    ow = time();
    @@ -397,6 +399,25 @@
       return ( $lval > $rval )?1:0;
     }
     
    +sub OP_later_equal {
    +  my ($r, $l, $map) = @_;
    +
    +  my $lval = $l->matches( $map );
    +  if ($lval !~ /^-?\d+$/) {
    +    require Time::ParseDate;
    +    $lval = Time::ParseDate::parsedate( $lval );
    +  }
    +  return 0 unless( defined( $lval ));
    +  
    +  my $rval = $r->matches( $map );
    +  if ($rval !~ /^-?\d+$/) {
    +    require Time::ParseDate;
    +    $rval = Time::ParseDate::parsedate( $rval );
    +  }
    +  return 0 unless( defined( $lval ));
    +  return ( $lval >= $rval )?1:0;
    +}
    +
     sub OP_earlier_than {
       my ($r, $l, $map) = @_;
     
    @@ -414,6 +435,25 @@
       }
       return 0 unless( defined( $lval ));
       return ( $lval < $rval )?1:0;
    +}
    +
    +sub OP_earlier_equal {
    +  my ($r, $l, $map) = @_;
    +
    +  my $lval = $l->matches( $map );
    +  if ($lval !~ /^-?\d+$/) {
    +    require Time::ParseDate;
    +    $lval = Time::ParseDate::parsedate( $lval );
    +  }
    +  return 0 unless( defined( $lval ));
    +  
    +  my $rval = $r->matches( $map );
    +  if ($rval !~ /^-?\d+$/) {
    +    require Time::ParseDate;
    +    $rval = Time::ParseDate::parsedate( $rval );
    +  }
    +  return 0 unless( defined( $lval ));
    +  return ( $lval <= $rval )?1:0;
     }
     
     sub OP_is_date {
    

TWiki 的 BlogPlugin Template 的 patch 內容:

  1. RenderFrontPage.txt
    --- RenderFrontPage.txt-orig    Wed May  7 23:37:26 2008
    +++ RenderFrontPage.txt Wed May  7 23:36:45 2008
    @@ -17,7 +17,7 @@
     %STARTINCLUDE%
     ~~~ %DBCALL{"RenderGoogleAdsense" TYPE="text_image"}%
     %~~ DBQUERY{
    -~~~   "TopicType=~'\bBlogEntry\b' AND State='published'
    +~~~   "TopicType=~'\bBlogEntry\b' AND State='published' AND Date EARLIER_EQUAL '%SERVERTIME%'
     ~~~    %IFDEFINED{"%CAT%" then="AND SubjectCategory=~'\b%CAT%\b'" glue="off"}%
     ~~~    %IFDEFINED{"%TAG%" then="AND BlogTag=~'\b%TAG%\b'" glue="off"}%
     ~~~    %IFDEFINED{"%AUTHOR%" then="AND BlogAuthor=~'\b%AUTHOR%\b'" glue="off"}%
    
  2. RenderRecentPostings.txt
    --- RenderRecentPostings.txt-orig       Mon May 12 18:46:44 2008
    +++ RenderRecentPostings.txt  Mon May 12 18:46:02 2008
    @@ -13,7 +13,7 @@
     %STARTINCLUDE%
     ~~~ %STOPALIASAREA%
     %~~ DBQUERY{"TopicType=~'\bBlogEntry\b' AND
    -~~~   State='published' 
    +~~~   State='published' AND Date EARLIER_EQUAL '%SERVERTIME%'
     ~~~   %IFDEFINED{"%CAT%" then="AND SubjectCategory=~'\b%CAT%\b'"}%
     ~~~   %IFDEFINED{"%AUTHOR%" then="AND BlogAuthor=~'\b%AUTHOR%\b'"}%"
     ~~~  order="createdate" reverse="on" limit="%LIMIT%" 
    
  3. RenderArchives.txt
    --- RenderArchives.txt-orig Mon May 12 18:56:48 2008
    +++ RenderArchives.txt  Mon May 12 18:58:39 2008
    @@ -11,7 +11,7 @@
     %STARTINCLUDE%
     *~~ 
    -%~~     DBSTATS{"TopicType=~'\bBlogEntry\b' AND State='published'
    +%~~     DBSTATS{"TopicType=~'\bBlogEntry\b' AND State='published' AND Date EARLIER_EQUAL '%SERVERTIME%'
     ~~~         %IFDEFINED{"%CAT%" then="AND SubjectCategory=~'\b%CAT%\b'" glue="off"}%
     ~~~         %IFDEFINED{"%AUTHOR%" then="AND BlogAuthor=~'\b%AUTHOR%\b'" glue="off"}%
     ~~~       "
    
  4. RenderBlogArchiveCat.txt
    --- RenderBlogArchiveCat.txt-orig       Mon May 12 18:57:24 2008
    +++ RenderBlogArchiveCat.txt  Mon May 12 18:58:39 2008
    @@ -14,7 +14,7 @@
     <noautolink>
     *~~
     %~~ TAGCLOUD{
    -~~~   "%DBQUERY{\"TopicType=~'\bBlogEntry\b' AND State='published'\"
    +~~~   "%DBQUERY{\"TopicType=~'\bBlogEntry\b' AND State='published' AND %Date EARLIER_EQUAL '%SERVERTIME%'\"
     ~~~     format=\"$formfield(SubjectCategory)\" separator=\", \"
     ~~~   }%"
     ~~~   buckets="30"
    
  5. RenderBlogArchiveChron.txt
    --- RenderBlogArchiveChron.txt-orig     Mon May 12 18:56:59 2008
    +++ RenderBlogArchiveChron.txt  Mon May 12 18:58:40 2008
    @@ -15,7 +15,7 @@
     *~~
     <div class="blogArchiveDateSelect">
     <div class="blogArchiveYears">
    -%~~ DBSTATS{"TopicType=~'\bBlogEntry\b' AND State='published'
    +%~~ DBSTATS{"TopicType=~'\bBlogEntry\b' AND State='published' AND Date EARLIER_EQUAL '%SERVERTIME%'
     ~~~   %IFDEFINED{"%URLPARAM{"year"}%" then="AND Date=~'$test'" glue="off"}%
     ~~~   "
     ~~~   field="Date" sort="created" 
    
  6. RenderBlogArchiveHitList.txt
    --- RenderBlogArchiveHitList.txt-orig   Mon May 12 18:57:35 2008
    +++ RenderBlogArchiveHitList.txt        Mon May 12 18:58:40 2008
    @@ -13,7 +13,7 @@
     *~~
     <div class="blogArchiveHitList">
     <a name="hits"></a>
    -%~~ DBQUERY{"TopicType=~'\bBlogEntry\b' AND State='published' %QUERY%"
    +%~~ DBQUERY{"TopicType=~'\bBlogEntry\b' AND State='published' AND Date EARLIER_EQUAL '%SERVERTIME%' %QUERY%"
     ~~~   %IFDEFINED{"%URLPARAM{"skip"}%" then="skip=\"$test\""}%
     ~~~   limit="15"
     ~~~   order="created" 
    
  7. RenderBlogArchiveLex.txt
    --- RenderBlogArchiveLex.txt-orig       Mon May 12 18:57:46 2008
    +++ RenderBlogArchiveLex.txt  Mon May 12 18:58:41 2008
    @@ -67,7 +67,7 @@
     </div>
     *~~
     %~~ TAGCLOUD{
    -~~~   "%DBQUERY{\"TopicType=~'\bBlogEntry\b' AND State='published'\"
    +~~~   "%DBQUERY{\"TopicType=~'\bBlogEntry\b' AND State='published' AND Date EARLIER_EQUAL '%SERVERTIME%'\"
     ~~~     format=\"$formfield(Headline) $formfield(Teaser) $formfield(Text)\" 
     ~~~     separator=\", \"
     ~~~   }%"
    
  8. RenderBlogArchiveTag.txt
    --- RenderBlogArchiveTag.txt-orig       Mon May 12 18:57:56 2008
    +++ RenderBlogArchiveTag.txt  Mon May 12 18:58:41 2008
    @@ -14,7 +14,7 @@
     <noautolink>
     *~~
     %~~ TAGCLOUD{
    -~~~   "%DBQUERY{\"TopicType=~'\bBlogEntry\b' AND State='published'\"
    +~~~   "%DBQUERY{\"TopicType=~'\bBlogEntry\b' AND State='published' AND Date EARLIER_EQUAL '%SERVERTIME%'\"
     ~~~     format=\"$formfield(BlogTag)\" separator=\", \"
     ~~~   }%"
     ~~~   buckets="40"
    
  9. RenderCategories.txt
    --- RenderCategories.txt-orig Mon May 12 18:58:07 2008
    +++ RenderCategories.txt    Mon May 12 18:58:42 2008
    @@ -9,7 +9,7 @@
     ---++ Implementation
     %STARTINCLUDE%
     *~~
    -%~~ DBSTATS{"TopicType=~'\bBlogEntry\b' AND State='published'"
    +%~~ DBSTATS{"TopicType=~'\bBlogEntry\b' AND State='published' AND Date EARLIER_EQUAL '%SERVERTIME%'"
     ~~~   field="SubjectCategory"
     ~~~   header="
     ~~~     <div class=\"blogSideBarSection blogSideBarCategories\">
    
  10. RenderDocNavigation.txt
    --- RenderDocNavigation.txt-orig        Mon May 12 18:58:18 2008
    +++ RenderDocNavigation.txt Mon May 12 18:58:42 2008
    @@ -84,7 +84,7 @@
     <div class="alt">
     %~~ DBCALL{"%TOPIC%" 
     ~~~   NAME="BlogEntry0" 
    -~~~   WHERE="TopicType=~'\bBlogEntry\b' AND State='published'"
    +~~~   WHERE="TopicType=~'\bBlogEntry\b' AND State='published' AND Date EARLIER_EQUAL '%SERVERTIME%'"
     ~~~ }%
     </div>
    
  11. RenderBlogEntry.txt
    --- RenderBlogEntry.txt-orig    2008-09-16 18:12:35.000000000 +0800
    +++ RenderBlogEntry.txt 2008-09-16 18:11:35.000000000 +0800
    @@ -19,7 +19,8 @@
     ~~~ 
     %~~ DBCALL{"RenderDocNavigation" 
     ~~~   NAME="%NAME%" 
    -~~~   WHERE="TopicType=~'\bBlogEntry\b' AND State='published'
    +~~~   WHERE="TopicType=~'\bBlogEntry\b' AND State='published' AND Date EARLIER_THAN '%SERVERTIME%'
     ~~~     AND SubjectCategory=~'\b%URLPARAM{"cat" default=".*"}%\b'"
     ~~~   REVERSE="on"
     ~~~   PARAMS="%IFDEFINED{"%URLPARAM{"cat"}%" then="cat=$test"}%"
    
  12. RenderBlogEntry.txt
    --- RenderBlogEntry.txt-orig  Mon May 12 18:58:26 2008
    +++ RenderBlogEntry.txt Mon May 12 18:58:38 2008
    @@ -33,7 +33,7 @@
     ~~~   }%"
     ~~~ }%
     ~~~
    -%~~ DBQUERY{"State='unpublished'" topic="%NAME%" 
    +%~~ DBQUERY{"State='unpublished' OR Date LATER_THAN '%SERVERTIME%'" topic="%NAME%" 
     ~~~   format="%DBCALL{\"BlogHelpText\" 
     ~~~     section=\"Unpublished\"
     ~~~     NAME=\"posting\"}%"
    
    … reply

另外一個 Blog 套件 BlogAddOn

1 year, 2 weeks ago in , by MoyaTseng
BlogPlugin 的作者對於這個分離出來的 BlogAddOn 套件有點不太滿意,在討論區看起來有點火力全開的感覺,另外一位作者似乎不太理他。不過,我個人是覺得,每個人需要的不一樣,如果別人不願意加入一起開發的話,也不能勉強別人。
另外一方面,我倒是在另外一個地方嘗試把 BlogAddOn 裝起來試看看,感覺一下差異。畢竟 BlogPlugin 也已經太久沒有更新了,而且還有一些已知的 bug 都沒有人關心,連作者都沒有花精神在目前版本上,只公開說今年要推出新版本,到現在還沒看到就是了。

其實 BlogAddOn 的安裝方式也相當簡單,只不過他需要安裝一個 TWiki:Plugins/CommentPlugin 才能用就是了。

話又說回來,經過測試的結果,BlogAddOn 還不及 CommentPlugin 成果的程度,所以不是那麼好用,說穿了,他其實也只有把 CommentPlugin 稍微包裝了一下而已。所以我這邊就沒有 duplicate 安裝一份的 BlogAddOn 程式,有興趣的人可以自己裝來玩玩看了。

BlogAddOn 的實作理念和 BlogPlugin 相當不同。BlogPlugin 是架構在一個完整個新的 Web 上,所以他是獨立出來的一個 TWiki Web。但是 BlogAddOn 則是融合進去既有的 TWiki Web 當中。看起來這兩位作者要能夠異中求同會是很難的事情吧!

安裝

  1. fetch http://twiki.org/p/pub/Plugins/BlogAddOn/BlogAddOn.zip
  2. unzip BlogAddOn.zip
  3. perl BlogAddOn_installer

參考文件

  1. TWiki:Plugins/BlogAddOn

使用方式

  1. 連到 ManagingWebs 建立一個新的 TWiki web,例如 Blog
  2. 到系統裡面,把 ~data/_BlogAddOn 目錄下的所有檔案複製到 ~data/Blog 的目錄下。
  3. 參考 Blog.BlogAddOnHome 的內容
  4. 先連結到 Blog.BlogCategory 建立新的 Category
  5. 然後到 Blog.BlogPostCreator 建立新的文章
  6. 最後,在 Blog.BlogPost 列表可以看到全部現有的文章內容

… reply

設定NatSkin屬性不能有空白

1 year, 2 weeks ago in , by MoyaTseng
研究了兩天的 BlogPlugin 的問題,研究不出什麼所以然來,乾脆另外建一個新的 Blog 來測看看,才發現這個問題,不能說是程式的 Bug,不過是不太友善就是了。但是話又說回來,容錯性太好也並不是什麼好事情就是了。
BlogPlugin 當中,可以使用 NatSkin 作為頁面呈現的方式,所以可以讓 BlogPlugin 看起來很像 MoveableType 或是 WordPress 的樣子。

設定方法也不難,只要在每一個 web 或是在 Main 的 WebPreferences 當中加上以下的設定就可以了。

NatSkin variables:

  • Set SKINSTYLE = PlainJane
  • Set STYLESIDEBAR = right
  • Set STYLEBORDER= thin
  • Set STYLEBUTTONS = on
  • Set STYLEVARIATION = Subway
  • Set STYLESEARCHBOX = top

不過,前兩天更改頁面的 Template 的時候,發現失敗。查了很久,才發現原來是這些參數的後面多了一堆空白,結果因為目前程式的容錯率太差,所以失效。把這些多出來的空白移除之後,頁面就恢復正常了。

不經一事不長一智,發現 TWiki 的 Set 會有這個問題也是好事情,下次遇到同樣的狀況就可以很快的解決,或者根本在設定的時候就可以完全避免出現這樣的問題。

凡是都要往好處想!

… reply

訪客統計: 3626 人次



請按此訂閱每日人間菩提。靜思晨語 External link mark
本站所有言論均不代表慈濟基金會 External link mark


我為你祝福
我也要許願

r1 - 07 Sep 2008 - 00:28:13 - TWikiGuest
Copyright © 1999-2009 by the contributing authors. All material on this collaboration platform is the property of the contributing authors. Ideas, requests, problems regarding Moya's Blog? Send feedback.