Habari - RN Monthly Archives Plugin

General

This plugin show the monthly archives in an unordered list.

Installation

  1. Unzip the file
  2. Put the folder 'archives' to /user/plugins and activate it
Configuration Option

After activated it, click button to setup the plugin.

  • Number of most recent months to be shown - Leave it blank to show all months.
  • Month displayed as - You can either choose 'Full name', 'Abbreviation' or 'Number' as the display format of the month.
  • Show Monthly Entries Count? - You can choose to show or hide entries count
  • Detail View? - 'Yes' for showing day with post title with link, 'No' for showing summary only.
  • Delimiter to separate day and post title in detail view - Character(s) as the separator between day and post title in detail view.    will be used if leave it blank.
Usage
$theme->monthly_archives();
For detail view, a nested unordered list will be shown with the following similar structure.
<ul class="archive-month">
<li>April 2008 (2)
<ul class="archive-entry">
<li>3 Hello World</li>
<li>1 April Fool</li>
</ul>
</li>
<li>March 2008 (2)
<ul class="archive-entry">
<li>3 End Of World</li>
<li>1 Play Hard</li>
</ul>
</li>
</ul>
For summary view, a unordered list will be shown with the following similar structure.
<ul class="archive-month">
<li>April 2008 (2)</li>
<li>March 2008 (2)</li>
</ul>

You can use CSS to style the output.

Note
  • Version 0.9 is the first version to support caching. There is a new button added to the plugin page of dashboard to let you to clear the cache. Normally, you don't need to click it since the cache will be expired and regenerated automatically when new post published or some other post status changed affect the output of monthly archives. However, if you found something wrong with your archives output or it doesn't appear, you can click this button to clear the cache and let the new cache generated automatically.
  • Version 1.0 modified to use new FormUI and comply to the new standard of configuration name, please make sure you are using Habari SVN r1948 or later and configure the plugin again.
  • Version 1.1 changed to use theme function instead of theme variable, please note the change of usage.
Changelog
  • Version 0.5 - Initial release
  • Version 0.6 - Added SQLite support (please use SVN r1350 or later version) and configuration option to display month as 'Full name', 'Abbreviation' or 'Number'
  • Version 0.7 - Support i18n, support detail view (with day and post title),allow show or hide monthly entries count, and allow to display the specific number of most recent months only.
  • Version 0.8 - Added PostgreSQL support
  • Version 0.9 - Added cache support
  • Version 0.9a - Added the clear cache action for the missing scenarios
  • Version 1.0 - Modified to support new FormUI and setup default configuration option during activation
  • Version 1.1 - Changed from using theme variable to theme function for better memory utilization
Download here (Downloaded 905 times)

======

簡介

這個 plugin 是用作以一個 unordered list 來顯示 monthly archives。

安裝
  1. 將下載了的 zip file 解壓
  2. 把 'archives' folder 放在 /user/plugins 中,然後啟動 plugin

設定選項

啟動 plugin 後,click 按鈕來設定。

  • Number of most recent months to be shown - 設定顯示最近某個數量的月份,留空顯示所有月份
  • Month displayed as - 可以選擇 'Full name'、'Abbreviation' 或 'Number' 為月份的顯示方式
  • Show Monthly Entries Count? - 設定顯示或隱藏每月文章總數
  • Detail View? - 如希望顯示詳細日期及文章連結,請選擇 'Yes',否則選擇 'No' 來顯示月份摘要
  • Delimiter to separate day and post title in detail view - 適用於 detail view,設定字符來分隔日子和文章連結,如留空的話,   會用作分隔字符
使用方法
$theme->monthly_archives();
選用 detail view 的話,類似以下結構的 nested unordered list 會顯示出來。
<ul class="archive-month">
<li>April 2008 (2)
<ul class="archive-entry">
<li>3 Hello World</li>
<li>1 April Fool</li>
</ul>
</li>
<li>March 2008 (2)
<ul class="archive-entry">
<li>3 End Of World</li>
<li>1 Play Hard</li>
</ul>
</li>
</ul>
顯示摘要時,類似以下結構的 unordered list 會顯示出來。
<ul class="archive-month">
<li>April 2008 (2)</li>
<li>March 2008 (2)</li>
</ul>

大家可以使用 CSS 來修飾顯示效果。

注意事項
  • 由 Version 0.9 版本開始支援 caching,在 dashboard 的 plugin 頁面中加入了一個新按鈕 。正常來說是不用按這按鈕的,因為當有新文章發表或其他會影響 monthly archives 輸出的 post status 改變,cache 都會自動更新,但如果發現 monthly archives 的輸出有問題,或甚至沒有任何東西顯示出來的話,大家可以按這按鈕來清除 cache。
  • Version 1.0 轉用了新的 FormUI 加上跟隨了新的 configuration name 命名,請使用 Habari SVN r1948 或以後的版本,及重新設定 plugin
  • Version 1.1 由 theme variable 轉用 theme function,請留意使用方法的改變
版本資料
  • Version 0.5 - 最初公開版本
  • Version 0.6 - 支援 SQLite (請使用 SVN r1350 或以後版本),新增設定頁選擇月份的顯示方式 - 'Full name'、'Abbreviation' 或者 'Number'
  • Version 0.7 - 支援 i18n,新增 detail view(顯示日子及文章連結),新增選擇顯示月份文章總數及可設定顯示最近某個數量的月份資料
  • Version 0.8 - 支援 PostgreSQL
  • Version 0.9 - 支援 caching
  • Version 0.9a - 補足了一些應該 clear cache 而又遺漏的地方
  • Version 1.0 - 使用了新的 FormUI 和在啟動 plugin 時自動設定 plugin 的預設選項
  • Version 1.1 - 由 theme variable 轉用 theme function 來節省記憶體的使用

下載連結(已經下載了 905 次)

35 Responses to “Habari - RN Monthly Archives Plugin”

  1. 6268

    天佑的Archive页面就是通过这个插件来实现的吗?
    Habari里是不是对page的定制是用对指定页面的特定模板来实现的,不是像wordpress里通过后面选择。
    最近想将blog平台转到habari下的想法越来越强烈了。但是模板方面还是挺不适应,以后要多向天佑请教。

  2. 6277

    @iHao:我現在使用中的 archives 頁面就是使用這個 plugin 的,頗簡陋吧? :P

    Habari theme 的彈性我覺得比 WordPress 高,純粹用 file 來決定 template,例如以 Page 就例,正常情況會使用 page.single.php,亦可以用 page.<slug>.php 來把特定 slug 的 page 來另一 template 顯示。

    最近 svn 的更新更加上 <type>.tag.<posttype>.php 這款 template,可以處理某一 tag 的 post 或 page。

  3. 6742

    @天佑:其实我就是因为habari的简洁与高效才有将blog平台转过去的想法,目前我正在将自己wordpress下的一个模板转到habari里面,估计等修改完就转到habari下面吧,必竟我对blog的要求也不是很多,不需要往里面贴照片、视频、源代码什么的。
    但是转换过程中还是遇到些问题一下不知如何解决,比如我的sidebar中需要输出留言最多的用户、留言最多的post,但在现有的system classes里没有找到相应的方法可以调用。
    而像最新post,最新comments,随机post这些我都有找着。
    在sidebar中我还想放置热门tag列表和最近几个月的archive列表,这俩个我看了下你发布的插件,应该可以实现,但我在本地测试时habari时后台一直无法打开插件页面,不知道是不是使用wamp套件环境的原因,所以暂时放下。
    还有相当多的问题也不是太明白,像时区的设置,中文搜索失效,如何使用habari自身的读取rss的功能等问题。
    我对habari还是太不了解,希望天佑有空的话指点一下。

  4. 7108

    @iHao:現在是沒有 API 來輸出留言最多的用、留言最多的 post 的,要自行用 SQL 來做的。

    至於沒法打開 plugins page,有沒有什麼 error message?

    而現時是不支援時區設定的,所有時間皆跟隨 server 設定,這個亦是我同時轉用 VPS 其中一個原因,因為所有東西皆可由我控制。

    中文搜索方面,因未確定怎樣才算最正確的方法在 regular expression 搜尋 unicode 文字,暫時我是用一個 hack 來解決這個問題,複製 system/classes/posts.php 到 /user/classes(所有在 /user/classes 中的 file 會自動 override /system/classes 同名的 file,方便升級時不會 overwrite 自行修改的 file),修改 posts.php 的 144 行

    preg_match_all( '/(?<=")(\\w[^"]*)(?=")|(\\w+)/', $paramset['criteria'], $matches );

    修改為

    preg_match_all( '/(?<=")(\\w[^"]*)(?=")|(\\w+)|(\X+)/u', $paramset['criteria'], $matches );

    而 Habari 的 atom feed URL 是 /atom/1。

  5. 7767

    @天佑
    谢谢天佑的这个中文搜索HACK,现在中文搜索已经ok.
    输出留言最多的用户及留言最多的post我不太清楚该怎么写,对theme.php文件搞不太零清.
    最后有个请求不知道是否合适,想求一份天佑现在用的主题的theme.php文件,参考一下一些功能的实现方法.

  6. 8054

    @iHao:其實 theme.php 的作用和 WP 的 functions.php 差不多,都是放一些 theme 所需要的 functions,方便 theme 的運作和顯示,其中一個常用的做法就是將一些資料 assign 到一個 theme variable 內,在 theme 中只需 echo 出來便可。

    我以輸出留言最多的用戶作為一個例子講解,在 theme.php 中的 add_template_vars() 中,我將以下輸出十個最多留言用戶的 SQL statement 的 result assign 到 $commenters 這個 variable 內。

    SELECT name, email, url, count(*) AS cnt FROM ' . DB::table( 'comments' ) . ' WHERE status = ' . Comment::STATUS_APPROVED . ' AND type = ' . Comment::COMMENT . ' GROUP BY name, email, url ORDER BY cnt DESC LIMIT 10
    方法如下。
    $this->template_engine->commenters= DB::get_results( 'SELECT name, email, url, count(*) AS cnt FROM ' . DB::table( 'comments' ) . ' WHERE status = ' . Comment::STATUS_APPROVED . ' AND type = ' . Comment::COMMENT . ' GROUP BY name, email, url ORDER BY cnt DESC LIMIT 10' );
    DB::get_results() 會 return 一個 array,用以下的 statement 就可讀取 $commenters 內的內容。
    foreach ( $commenters as $commenter ) 
    {
    echo $commenter->name;
    echo $commenter->email;
    echo $commenter->url;
    }
  7. 18483

    Would it be possible for you to add a feature to only show a few months? Say, I want to show the 5 most recent months only and link to "More".

  8. 18545

    @Randy, add the features to show a few months is so simple. But for the link "More" to show the remaining months. I can't think of a way to implement it except using javascript but I'm a javascript idiot.

    Do you have any other alternative to implement "More" link or give me some information / tutorial web site about similar javascript implementation?

  9. 18553

    Haha, no, I'm not a coder. For the "More" link, I was just thinking of making it link to an Archives page.

  10. 18946

    When trying to save changes for the plugin, v.07, I get the following error:

    "Could not include class file 332w83sshopo4s.php"

    Using the latest svn version of habari. Any ideas?

    Just an idea about the "more" link randy requested. Place the "extra" month in an new container (new ul inside a li or something like that). Add "display:none;" to the stylesheat for the container and add this to the header:

    now a click on "" will slide out the extra month and a nother click will hide them.

    The code is taken from here: http://docs.jquery.com/Effects/slideToggle#speedcallback
    Since habari uses jquery as default it should work nicely. Will try it myself when I get back from home.

  11. 18949

    The same could be done with posts for every month, clicking a month could roll out the posts for that month.

  12. 18997

    is it possible to use the plugin in two ways on the same blog... once to create a recent list of months, the other to do a full archive page?

  13. 19435

    俺楼上的楼上的楼上也遇到了这个问题
    "Could not include class file 332w83sshopo4s.php"

  14. 19513

    @chori, the error of "Could not include class file 332w83sshopo4s.php" is very weird. I'm using FormUI class of Habari to construct the plugin configuration page. Don't know why this error is occurred.

    Have you tried other plugin required to save option? No problem or same error occur?

  15. 19514

    @Randy, I have to think about the best way to implement it. May be included jQuery stuff mentioned by chori.

  16. 19851

    I think I am being extremely dumb here, but I can't get anything to show. I've put on my page, and nothing happens.

    Am I using this wrong? Have I misunderstood where I should be putting the code?

  17. 19911

    @Adam, I've visited your blog and found the plugin working properly. I think you have solved your problem, right?

  18. 19925

    I also get the error: Could not include class file 332w83sshopo4s.php

    I'm using the 4/21 nightly with monthly_archives and flickrrss. The only other plugins I've used so far are the built in ones - flickr silo and the wordpress importer, and both seem to save their settings fine.

  19. 20198

    @chori & mikelietz, the problem is caused by core class file "formui.php", r1594 (http://trac.habariproject.org/habari/changeset/1594) has fixed this problem. Please upgrade to SVN r1594.

  20. 20337

    Great, thanks!

  21. 21429

    天佑你好,我使用這個 plugin ,在最新版本的 Habari ,遇到了 Undefined variable: monthly_archives 的問題(我用的是 SVN 上的 0.8.1 版,似乎比這頁提供的版本還新)。

    順便提醒一下,您的 page_selector 沒有更新為新的寫法喔! :p

  22. 21432

    不知道我上一篇留言有沒有成功,不過我知道解決方法了… 新版 Habari 的呼叫方法改為 $theme->monthly_archives();

  23. 21465

    @bcse:那個版本是 dmondark (Ali. B) 為了 Charcoal theme 而修改出來的版本。

  24. 21623

    你好,我對於您寫的 plugins 有個小建議,我發現 Blogroll 和 Twitter 這兩個 plugin 可以讓使用者在 theme 中修改 plugin 的呈現方式,如果您的 plugins 都改寫為如此方式,應該會更加有彈性!(而且這樣一來, Ali. B 就不需要另外維護他的 branch 了)

  25. 22000

    @bcse:我會參考一下,剛完成 Habari 的 PostgreSQL support,應該會有時間修改其他東西。 ;)

  1. 15575 Hack RN Monthly Archives Plugin - Give me an endless summer
  2. 18931 RN Monthly Archives Plugin 0.7 @ 天佑的自由天地
  3. 18982 links from dupola’s bookmarks.» Blog Archive » links for 2008-04-04
  4. 18983 links for 2008-04-04 | Links from dupola's bookmarks
  5. 18984 links for 2008-04-04 « dupola’s weblog(en)
  6. 22448 RN Monthly Archives Plugin 0.8 @ 天佑的自由天地
  7. 24544 RN Monthly Archives Plugin 0.9 @ 天佑的自由天地
  8. 24702 RN Monthly Archives Plugin 0.9a @ 天佑的自由天地
  9. 25212 RN Monthly Archives Plugin 1.0 @ 天佑的自由天地
  10. 27441 RN Monthly Archives Plugin 1.1 @ 天佑的自由天地

Leave a Reply