Posts tagged with @言語

“Ochlophobia”

距離上次改版將近一年,沒想到 De Morgan 可以用這麼久 :p 這次改版有幾個原因:

  1. 我在某次更新時忘了備份標題圖片,而標題圖片對 De Morgan 來說是不可或缺的,所以在正式改版前,我還用了一段時間的 Binadamu ,用了之後才發現不使用 Grid 概念的話,看起來真的會很亂。
  2. 其實我大概半年前就開始想要改版了,只是一直作不出滿意的 Mockup。
  3. 最近 Proposal 剛結束,很閒 XD
Read More

TweetSuite Plugin for Habari (pre-alpha)

前幾天看到了 TweetBacks 這個新 idea ,實用性可能很低,但相當有趣,因此今天趁著有空寫了給 Habari 用的版本。目前完成度還不高,不過 TweetBacks 的功能都有了。

為了讓此 Plugin 得以運作,我修改了 Habari Core ,請參閱安裝前須知。目前 Habari 暫時還沒有自訂 Comment 內容型態的功能, Post 則有,這個功能未來計畫會加入,因此現在只能用這種克難作法。

Things to Do Before Installation

請先修改 comment.php, comments.php 兩個檔案,方能使用此 Plugin 。

To use this plugin, please modify your comment.php and comments.php as below.

  1. comment.php

    const COMMENT = 0;
    const PINGBACK = 1;
    const TRACKBACK = 2;
    const TWEETBACK = 3; // Add this line
    
    public static function list_comment_types( $refresh = false )
    {
        if ( ( ! $refresh ) && ( ! empty( self::$comment_type_list ) ) ) {
            return self::$comment_type_list;
        }
        self::$comment_type_list = array(
            self::COMMENT => 'comment',
            self::PINGBACK => 'pingback',
            self::TRACKBACK => 'trackback',
            self::TWEETBACK => 'tweetback', // Add this line
        );
        return self::$comment_type_list;
    }
    
  2. comments.php

    private function sort_comments()
    {
        $type_sort = array(
            Comment::COMMENT => 'comments',
            Comment::PINGBACK => 'pingbacks',
            Comment::TRACKBACK => 'trackbacks',
            Comment::TWEETBACK => 'tweetbacks',  // Add this line
        );
    ...
    
    public function __get( $name )
    {
        switch ( $name ) {
            case 'count':
                return count( $this );
            case 'approved':
            case 'unapproved':
            case 'moderated':
            case 'comments':
            case 'pingbacks':
            case 'trackbacks':
            case 'tweetbacks':  // Add this line
                return new Comments( $this->only( $name ) );
        }
    }
    

Get it!

目前只能透過 SVN 取得。

You can get TweetSuite via SVN.

Known Issues

  1. 有時(或者該說是經常?)資料庫會儲存到重複的 Tweetbacks ,但這種情況是一次就出現很多重複的 Tweetbacks。
  2. 有些短網址是大小寫有別的,而 Twitter Search 不區分大小寫,於是可能會抓到一些無關的 Tweetbacks 。(尤其是 bit.ly 的短網址超容易發生這種事)

Notes

此 Plugin 的運作流程依序為:

  1. 使用者讀取單篇文章(Post)
  2. 讀取完畢時, TweetSuite 才開始執行,這有兩層考量:在讀取文章前執行可能導致讀取變得非常慢、讀取文章前還沒有 Post 物件能用 XD 但這種作法的缺點就是最新的 TweetBacks 會在第二次載入時才出現。
  3. TweetSuite 首先會讀取這篇文章的短網址資訊,如果資訊不存在,便會到各個短網址服務產生這篇文章的短網址,然後儲存到資料庫。如果是有缺漏,便只會重新嘗試產生遺漏的短網址。(寫這個的時候我發現 tr.im 這個服務,程式寫得不太好…… 因為它不會檢查資料庫中是否已經存在重複的網址,每次都將給你一個新產生的網址)
  4. 得到這些短網址後, TweetSuite 會將它們串接起來丟到 Twitter Search 作聯集搜尋,最後將得到的搜尋結果存入 comments 資料表。其實在執行 Twitter Search 之前, TweetSuite 會先取得這篇文章最近一次的 TweetBacks 的 ID ,然後就能加入 Twitter Search 的參數中,讓 Twitter Search 只回傳較新的 Tweets ,因此資料庫中的 TweetBacks 不會重複。
  5. TweetSuite 會紀錄這一次執行的時間,接下來一個小時內同樣的文章將不會重複執行。

No more backward compatibility

我最近突然覺得向下相容是一件錯誤的事。就因為網頁設計師總是向下相容到 IE 6 ,使用者才不願升級為 IE 7 ——— 反正都可以用,當然選擇已經用得順手的舊版瀏覽器。所以本站下次的改版將無視 IE 6 使用者,版面爛掉就爛掉,我不要為 IE 6 作任何 Fix! XD (但 IE 7 使用者我還是會照顧一下)

Lvx ex Cælis 近半年訪客使用瀏覽器統計 (by BCSEEATI)

為了心安,我還是參考了一下本站的流量統計,結果令我相當驚喜———本站近一個月來的 IE 使用者只佔了 51% ,其中大約只有一半為 IE 6 ,而 Firefox 使用者竟然高達 40% 。不過近一個月可能太近,我又看了近半年的資料,其實沒差多少, IE 使用者只佔了 58% ,其中同樣大約一半為 IE 6 ,計算得精確一點的話,本站近半年來只有 32.35% 的訪客使用 IE 6 。雖然 IE 的數字仍然過半,但這比例與一般網站相較,差異已經相當懸殊。綜合以上資料,我認為本站主要客群並不是使用 IE 6 ,我可以安心地寫新時代的網頁 >ω<

Do As Infinity 復出!

DoAs (by BCSEEATI)

剛開始的消息是說伴和亮要出席 a-nation ,當時還不敢太期待 XD 現在則是確定於 9/29 復出,間隔剛好三年。不過… 新的成員中看來沒有大…… orz

Breezy Archives Plugin for Habari

簡介

Breezy Archives 是一個模仿 Live Archives 的彙整 Plugin 。當瀏覽器關閉 JavaScript 功能時,它會變成 Clean Archives ,而不會留下一個空白的頁面。

安裝

  1. 解壓縮檔案。
  2. 將 breezyarchives 資料夾放到 /user/plugins 資料夾中,然後到 Habari 管理介面中啟用它。
  3. 將下面這行貼到你的 Theme 中。

    <?php if ( Plugins::is_loaded('BreezyArchives') ) $theme->breezyarchives(); ?>
    

設定 / 自訂

啟用後,請按下 Configure 來設定此 Plugin ,有這些項目可以設定:

  • Chronology — 依月份彙整的設定
    • Title for Chronology Archives — 月份彙整的標題。
    • Month Format — 設定月份的格式,共有四個選項可選擇。
      • Full name — 全稱 (January – December)
      • Abbreviation — 縮寫 (Jan – Dec)
      • Number with leading zero — 前方補零的數字 (01 – 12)
      • Number without leading zero — 前方不補零的數字 (1 – 12)
    • Show Monthly Posts Count — 顯示每個月份的文章數量。
  • Taxonomy — 依標籤彙整的設定
    • Title for Taxonomy Archives — 標籤彙整的標題。
    • Show Tagged Posts Count — 顯示每個標籤的文章數量。
    • Excluded Tags — 此為選填欄位。在此輸入你不要顯示於標籤彙整的 tag slugs
  • Pagination — 分頁設定
    • № of Posts per Page — 每頁顯示幾篇文章。
    • Next Page Link Text — 下一頁的連結文字。
    • Previous Page Link Text — 上一頁的連結文字。
  • General — 一般設定
    • Show Newest First — 將新的文章放在前面。
    • Show № of Comments — 顯示每篇文章的迴響數量。

如果你要修改 CSS 呈現的結果,可以將 breezyarchives.css 複製到你的 Theme 資料夾中並修改這個檔案。

下載

更新紀錄

  • 0.1 (2008-08-27) — 初次釋出。

Introduction

Breezy Archives is an archives plugin which mimics ‘Live Archives’ on WordPress. When JavaScript is not available, it will graceful degrade to a ‘Clean Archives’.

Installation

  1. Extract the file.
  2. Put the folder ‘breezyarchives’ to /user/plugins and activate it.
  3. Copy and paste the following line to your theme.

    <?php if ( Plugins::is_loaded('BreezyArchives') ) $theme->breezyarchives(); ?>
    

Configuration & Customization

After activated it, click Configure button to setup the plugin. Most of following options are required and have to be set properly.

  • Chronology — Configurations about Monthly Archives
    • Title for Chronology Archives
    • Month Format — There are 4 options: ‘Full name’, ‘Abbreviation’, ‘Number with leading zero’, ‘Number without leading zero’
    • Show Monthly Posts Count — Check this to show the number of posts of each month.
  • Taxonomy — Configurations about Tag Archives
    • Title for Taxonomy Archives
    • Show Tagged Posts Count — Check this to show the number of posts of each tag.
    • Excluded Tags — This field is optional. Put tag slugs here which you want it to be excluded from tag archives.
  • Pagination — Configurations about Pagination
    • № of Posts per Page
    • Next Page Link Text
    • Previous Page Link Text
  • General — General Configurations
    • Show Newest First — Check this to show latest posts first.
    • Show № of Comments — Check this to show the number of comments of each post.

You can copy ‘breezyarchives.css’ to your theme directory and modify the CSS style.

Download

Changelog

  • 0.1 (2008-08-27) — Initial release.

YUI 3 SlickSpeed Selector Test

YUI 3.0 Preview Release 1 推出了,並且是砍掉重練式的大更新,所以我當然要來測一下它的 Selector 速度囉!由於取用方式與其他 Library 有很大的不同,我花了一點時間才成功將它放進 SlickSpeed

目前 YUI 官方給的範例、文件中都是採用這樣的方式

YUI().use('node', function(Y) {
    Y.get('#demo').addClass('enabled');
});

yui-min.js 是一個 Loader ,使用時必須先用 YUI.use() 來建立 instance 並載入所需功能,然後才能使用 Y.get() 這種寫法。經過我研究原始碼後發現,如果只要用 Selector 的部份,則僅需載入 yui-base-min.js, dom-base-min.jsselector-min.js 三個檔案,然後使用 YUI().use("selector").Selector.query() ,就能選擇 HTML 物件。不過如果是載入 yui-min.js ,就不能用這種方法了。

測試結果:YUI 2 終於不再是最慢的 Selector ,因為現在多了 YUI 3 來當它的墊背… 囧rz

UAODecode

完全是無聊而寫了這個,我自己也用不到 XD

這個 PHP Class 的功能是將 Big5 中文及 Unicode-At-On 新增字轉換為 UTF-8 或 NCR。本程式移植自 PCMan 2007 ,所以採用 GNU GPL 授權。

下載

使用方法

<?php
    // 輸出 UTF-8
    echo UAODecode::big5_to_utf8('Unicode-At-On 文字');

    // 輸出 NCR
    echo UAODecode::big5_to_ncr('Unicode-At-On 文字');
?>