ScrewTurn Wiki 3.0.2

ScrewTurn Wiki 在農曆年前的幾天,發佈了 3.0.2 版本

這版本對於台灣用戶來說,是一個很重要的版本,因為已經內建的正體中文翻譯

另外原本要外掛的 Sitemap ,也改為內建功能,不需要再外掛了

詳細更新與下載,請見官方網站: http://www.screwturn.eu/Changelog.ashx

Posted 作者 dmwc with 1 comment(s)

Color ListBox for .Net 2.0

因為工作關係,常需要寫測試軟體,偶爾會看到訪間的 Log 畫面是彩色的,也想動手將測試結果輸出彩色的

一般我都會用 ListBox 作為顯示畫面,因為 ListBox 以行為單位,很適合我的使用,但也很不幸的 .Net 並沒有辦法將 ListBox 每行用不同的顏色,不過其實還是可以讓他用 "畫" 的完成這項作業

首先先把 DrawMode 設定為 OwnerDrawVariable ,再加入 listBox1.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.listBox1_DrawItem) ,這時您就可以自己創作 ListBox 的顯示方式了

此時便可以用 e.Graphics.DrawString 畫出所要的有顏色字串

e.Graphics.DrawString((sender as ListBox).Items[e.Index].ToString(), e.Font, myBrush, e.Bounds.X, e.Bounds.Y);

Item 內有 pass fail 時要改變不同顏色,判斷後修改 myBrush 的顏色即可

if (e.Index >= 0 && (sender as ListBox).Items[e.Index].ToString().IndexOf("fail", StringComparison.CurrentCultureIgnoreCase) >= 0)
					myBrush = Brushes.Red;
				else if (e.Index >= 0 && (sender as ListBox).Items[e.Index].ToString().IndexOf("pass", StringComparison.CurrentCultureIgnoreCase) >= 0)
					myBrush = Brushes.DarkGreen;
				else
					myBrush = Brushes.Black;

選取時反白當然也要考慮進去,改用 SolidBrush

myBrush = new SolidBrush(e.ForeColor);

完整的程式碼如下

public Form1()
		{
			InitializeComponent();
			this.listBox1.DrawMode = System.Windows.Forms.DrawMode.OwnerDrawVariable;
			this.listBox1.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.listBox1_DrawItem);
		}

		private void button1_Click(object sender, EventArgs e)
		{
			listBox1.Items.Clear();
			listBox1.Items.Add("This is test!!");
			listBox1.Items.Add("Test pass!!");
			listBox1.Items.Add("Test fail!!");
		}

		private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
		{
			e.DrawBackground();

			System.Drawing.Brush myBrush;
			if ((e.State & DrawItemState.Selected) != DrawItemState.Selected )
			{
				// unselected
				if (e.Index >= 0 && (sender as ListBox).Items[e.Index].ToString().IndexOf("fail", StringComparison.CurrentCultureIgnoreCase) >= 0)
					myBrush = Brushes.Red;
				else if (e.Index >= 0 && (sender as ListBox).Items[e.Index].ToString().IndexOf("pass", StringComparison.CurrentCultureIgnoreCase) >= 0)
					myBrush = Brushes.DarkGreen;
				else
					myBrush = Brushes.Black; 
			}
			else
			{
				myBrush = new SolidBrush(e.ForeColor);
			}

			if (e.Index >= 0)
				e.Graphics.DrawString((sender as ListBox).Items[e.Index].ToString(), e.Font, myBrush, e.Bounds.X, e.Bounds.Y);

			e.DrawFocusRectangle();
		}

成果:

後註:缺點是改用繪圖後,顯示的效能會下降很多,建議如需快速大量顯示資料,可以考慮完成後再切回繪圖模式,或是僅顯示少量

Posted 作者 dmwc with 1 comment(s)

Subkismet captcha for CommunityServer or ASP.Net

現在一位網站管理員,除了要管理真人的內容外,對付廣告機器人也是一件頭痛的問題,各大網站相繼淪陷於廣告機器人之後,就有網站陸續加入認證圖案,這時就造就了 CAPTCHA ( 詳細解釋請見 Wiki )

不論你網站規模大小,有沒有流量等等,總是會有一些廣告機器人滲透,CommunityServer 只要開了匿名留言,自然也會成為攻擊對象,於 .Net 2.0 中,要寫一個 CAPTCHA 並不困難,相對的網路上的免費資源也不少,這次就介紹 Subkismet ,Captcha 只是 Subkismet 專案的一部分,做出來的 Captcha 會是由點狀顯示文字 (如下圖),對於一般(亞洲)人辨識並不至於太困難,例如 reCaptcha 這個對於亞洲人來說就太過困難

 

Subkismet 主要分為兩部分,HttpHandler 與 CaptchaControl , HttpHandler 是負責產生圖形, CaptchaControl 負責編碼與驗證,在使用前請先完成設定作業

1. Web.config 加入 <add verb="*" path="*CaptchaImage.ashx" type="Subkismet.Captcha.CaptchaImageHandler, Subkismet"/>

2. 在使用的頁面開頭註冊元件 <%@ Register Assembly="Subkismet" Namespace="Subkismet.Captcha" TagPrefix="sbk" %>

完成要使用 CaptchaControl 其實很簡單,因為他是繼承 System.Web.UI.WebControls.BaseValidator ,設定好後直接放入以下程式碼到輸出表單中

<sbk:CaptchaControl id="captcha" runat="server" ErrorMessage="Oops! You must be bad at reading." Display="dynamic" CaptchaLength="4" ValidationGroup="Visible" />

 

CommunityServer Blog 使用方法範例 ( 以 default2 為例 ):

1. 開啟 \Themes\Blogs\default2\post.aspx

2. 於頁面最上方註冊 Subkismet.Captcha 元件 <%@ Register Assembly="Subkismet" Namespace="Subkismet.Captcha" TagPrefix="sbk" %>

3. 在留言的下方加入 Subkimet Captcha

<dt><CSControl:FormLabel LabelForId="tbComment" runat="server" ResourceName="Weblog_CommentForm_Comments" /> <em>(<CSControl:ResourceControl runat="server" ResourceName="Required" />)</em><asp:RequiredFieldValidator runat="server" ErrorMessage="*" ControlToValidate="tbComment" ValidationGroup="CreateCommentForm" /></dt>
                        <dd><asp:TextBox id="tbComment" runat="server" Rows="5" Columns="25" TextMode="MultiLine" ValidationGroup="CreateCommentForm" /></dd>
                        
                        <dt>Captcha</dt>
                        <dd><sbk:CaptchaControl id="captcha" runat="server" ErrorMessage="輸入錯誤."  LayoutStyle="CssBased" Display="dynamic" CaptchaLength="4" ValidationGroup="CreateCommentForm" /></dd>

                        <dt id="RememberWrapper" runat="server"><asp:CheckBox id="chkRemember" runat="server" Text="Remember Me?" ValidationGroup="CreateCommentForm" /></dt>

成果:

 

後註:

1. ASP.Net 皆可適用此元件,和 CMS 是不是 CommunityServer 並沒有關聯

2. 這種點文字 Captcha 已經有國外 de-Captcha 100% 讀取破解,可能還是會有機器人可以順利解讀,如果覺得功能不夠強大可以自行修改原始碼改善

3. 原本的 Subkismet 顯示後只會有一個文字方框讓使用者輸入訊息,一般訪客可能很難理解那方框用途,我加了 HelpInputMessage 版本供大家使用,需要者可下載

4. Hawaii blog Theme 修改範例,下載此範例

當 CommunityServer 遇上 LightBox (下)

在上一篇,講解了如何在 tinymce 上使用 lightbox ,但只有 blog 才能使用 tinymce 顯示 lightbox ,在多媒體 ( media ) 便派不上用場

如果要在多媒體使用 lightbox ,只有從 Theme ( aspx 檔案 ) 下手,CommunityServer 上,主要是靠 CSMedia:MediaGalleryPostData 物件顯示與建立聯結,但很不幸的,建立聯結這個屬性 LinkTo="View" 此類,並無法擴充讓他支援 lightbox ,如果要支援,唯有修改 SDK 或是自己建立一個新的 Control ,這裡便從講解 SDK 開始

當有 SDK 環境後,開啟CS2008.5_SP2_4.1.40407.4157.sdk\Source\CommunityServer.MediaGalleries\Controls\MediaGalleryPost\MediaGalleryPostData.cs 檔案,在 104 行左右便可見到此程式碼

case MediaGalleryPostLinkTo.View:
                            link = new HyperLink();

                            if (mediaGallery.Hub == null)
                                link.NavigateUrl = MediaGalleryUrls.Instance().ViewMediaGalleryPost(mediaGallery.ApplicationKey, post.PostID);
                            else
                                link.NavigateUrl = MediaGalleryUrls.Instance().HubMediaGalleryPost(mediaGallery.Hub.ApplicationKey, post.PostID);

                            break;

我並不建議直接修改原本的 LinkTo ,建議加一個 lightbox ,在 HyperLink 要加入 Rel 與 Title 屬性很簡單

link.Attributes.Add("rel", "lightbox");

再加入考慮是否為圖片再使用 lightbox ,整個 LinkTo 程式就如下列

case MediaGalleryPostLinkTo.LightBox:
							link = new HyperLink();

							if (post.Attachment.IsImage)
							{
								link.Attributes.Add("rel", "lightbox");
								link.Attributes.Add("title", post.Subject);
								link.NavigateUrl = post.Attachment.Url;
							}
							else
							{
								if (mediaGallery.Hub == null)
									link.NavigateUrl = MediaGalleryUrls.Instance().ViewMediaGalleryPost(mediaGallery.ApplicationKey, post.PostID);
								else
									link.NavigateUrl = MediaGalleryUrls.Instance().HubMediaGalleryPost(mediaGallery.Hub.ApplicationKey, post.PostID);
							}

							break;

當完成後,重新編譯即可使用 LinkTo="lightbox" 來顯示多媒體 lightbox ,以下就是顯示的範例

<CSMedia:MediaGalleryPostList runat="server" ID="MediaInformation" ShowHeaderFooterOnNone="true">
                                        <QueryOverrides PageSize="5" SortBy="PostDate" SortOrder="Descending" IncludeCategories="false"
                                            PageIndex="0" IsAggregate="false" IsCommunityAggregatedOnly="false" />
                                        <HeaderTemplate>
                                            <ul class="CommonContentBoxList">
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <CSMedia:MediaGalleryPostData ID="MediaGalleryPostData1" runat="server" Property="Subject"
                                                TruncateAt="50" LinkTo="LightBox" Tag="LI">
												<contenttemplate>
													<CSMedia:MediaGalleryPostViewer ID="MediaGalleryPostViewer1" runat="server" Width="1" Height="1" ViewType="Preview" />
												</contenttemplate>
                                            </CSMedia:MediaGalleryPostData>
                                        </ItemTemplate>
                                        <NoneTemplate>
                                            <li>
                                                <CSControl:ResourceControl runat="server" ResourceName="Home_NoFilesUploaded" />
                                            </li>
                                        </NoneTemplate>
                                        <FooterTemplate>
                                            </ul></FooterTemplate>
                                    </CSMedia:MediaGalleryPostList>

效果就會如本站首頁的顯示方式,按下圖片後啟用 lightbox 顯示圖片

當 CommunityServer 遇上 LightBox (中)

在一般 Tinymce 上,預設並不允許使用 rel 屬性,使用前請先在 extended_valid_elements 加入 a[name|href|target|title|onclick|rel] ,在 CommunityServer 環境下,上面步驟不需要,Telligent 已經將預設值寫好了

但在一般環境下,您插入聯結後就會發現 tinymce 並沒有地方讓您輸入 rel="lightbox" ,這時候有兩種解決方法

 

方法1: 直接編輯 HTML

按下 tinymce 的 HTML 按鈕,自己 DIY 加進去,這方法如果文章很長,就會很辛苦去找那些圖片連結跑哪去了

方法2: 安裝 advlink plugins

advlink plugins 預設並沒有安裝在 CommunityServer 上,首先先到 TinyMCE 官網下載最新版,解開後到 plugins 目錄即可取得 advlink

再來就是把 plugins 啟動,在 CommunityServer 上即用 notepad 開啟 CommunityServer.config ,在 editorOption name="plugins" 加入 advlink ,其他環境下可以看官網的安裝步驟

完成後插入或編輯聯結,就會變成 advlink ,這時就有 rel = lightbox 可以選擇,經常使用 lightbox 用戶建議安裝此 plugins

BlogEngine.NET 1.6 釋出

今天 BlogEngine.NET 1.6 已經正式推出了,在這版,主要是針對 SPAM 回應做出一些改進,並且可以使用多重 Widget zone,Page Slug 也可以存在資料庫中

詳細的更新,請見官方網站 http://dotnetblogengine.net/page/BlogEngineNET-16-Release-Notes.aspx

 

※更新時,請務必參照更新步驟砍掉 ExtensionManager 目錄並修改 CSS

Posted 作者 dmwc with 1 comment(s)

當 CommunityServer 遇上 LightBox (上)

LightBox 已經在許多官方網站採用,或許大家對他並不陌生,這是一套 JavaScript 的程式,也就是他可以套用在各作業平台上

要取得這套,先到 Lightbox 官方網站下載取得

安裝步驟很簡單

1. 上傳檔案

2. 在網頁上加入 Javascript

<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>

3. 同網頁加入 CSS link

<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />

4. 建議修改 lightbox.js 裡面的圖片連結,以免因為路徑的關係無法出來

fileLoadingImage:        '/lightbox/images/loading.gif',
    fileBottomNavCloseImage: '/lightbox/images/closelabel.gif',

以上完成後就可以開始使用 Lightbox 了,要在圖片上啟動,只要在 a 裡面加入 rel="lightbox" 就會有此效果,如

<a href="大圖片網址" rel="lightbox" title="圖片標題"><img src="小圖片網址" /></a>

 

使用 LightBox 最大的好處於,不論 LightBox Javascript 是否有正確運作(如轉載到其他網站或 RSS ),都不會因此而造成圖片無法顯示

下一集在介紹如何整合到 CommunityServer 上

更新為 CommunityServer 2008.5 SP3 (Build: 36.8414)

自從 TelligentCommunity 推出後,不僅我就沒在關心 CommunityServer ,連官方更新都是靜悄悄,但事實上 CommunityServer 2008.5 SP3 已經悄悄的推出了

本次更新,主要是修正 Wiki 功能外,修正 Flash 上傳問題,和修正一些小 Bug ,並沒有增加任何功能

更新資料庫時,僅會發現有些分頁功能修正 與 Wiki 修正,還有修正月曆顯示外,並無資料格式變動 ( PS. 更新後即無法使用在 SQL2000 Server 上 )

詳細更新列表請見官方網站:http://telligent.com/support/communityserver/community_server_2008/w/cs20085docs/full-list-of-bug-fixes-in-cs2008-5-sp3.aspx

另外此次更新,並沒有公開下載,須提供序號與相關資料給 Telligent Support 後,他們才會寄檔案給您,並此 SP3 也沒有 SDK 版本可以下載

CommunityServer 2007 Unicode Search CSModule

Because some user request , release this CSModule.

Change source code release to CSModule , and Change to always using like search.

Using this CSModule , you can run search unicode without SearchBarrel or EnterpriseSearch

Download ( for CS2007 ) : http://www.ruri.com.tw/media/p/3909.aspx

Download ( for CS2008 ) : http://www.ruri.com.tw/media/p/2642.aspx

Download ( for CS2008.5 sp2 ) : http://www.ruri.com.tw/media/p/3910.aspx

Posted 作者 dmwc with 2 comment(s)

活動行事曆啟用

在 ASP.Net 2.0 中,提供的月曆控制項可以輕易的改造成行事曆,也因為如此,在 Codeplex 也找不到這類的行事曆

但偏偏在 CommunityServer 上 ( 包含 Telligent Community 5.0 ) ,就是沒有行事曆功能,最近網站剛好有此需求,就順手 DIY 了一個

Popup 部分,原本都是用 OverLib ,但不知為何套到 CommunityServer Themes 後,顯示視窗位置會有很大的偏差,還好有找到另外一套極度相似 wz_tooltip ,這兩套極度相似到大部份指令還可以相容,有 tooltip popup 需求的人,可以參考看看

SyntaxHighlighter Wrapper CSModule 2.0 in CommunityServer 2008.5

At several ago , Serge B. send a mail want release SyntaxHighlighter Wrapper CSModule source code and will help update to dp.SyntaxHighlighter 2.0 .

But many many day ago , I already wrote a CSModule for dp.SyntaxHighlighter 2.0 of this time they a not freeware.But they are freeware now.

I recheck the CSModule and fix backward compatibility , upgrade tiny_mce plugins. Now it release!!

You can use SyntaxHighlighter Wrapper CSModule 2.0 with dp.SyntaxHighlighter 2.x . This CSModule will automatic load CSS and needs Javascipt to do SyntaxHighlighter.

 

The zip file include :
1. SyntaxHighlighter Wrapper CSModule 2.0
2. SyntaxHighlighter 2.1.364 (October 15 2009)
3. SyntaxHighlighter, TinyMCE et YML ( Modify for CommunityServer )
4. Source Code

Download it : http://update.to/cs/SyntaxHighlighter/CommunityServer.SyntaxHighlighterWrapper20.zip

SyntaxHighlighter Wrapper CSModule 2.0 in CommunityServer 2008.5

在很久很久以前,有釋出 SyntaxHighlighter Wrapper CSModule ,在當時已經有 dp.SyntaxHighlighter 2.0 了,只是那時這並不是免費軟體,開發好對應的 CSModule 後,便發現此困境,便就沒有發表出來,也沒繼續追蹤下去

直到最近,有網友 Serge B.  發信來,希望我提供 1.1 版原始碼讓他更新,這時才驚覺 dp.SyntaxHighlighter已經轉為 Freeware 了,其實我早有 2.0 對應的 CSModule ,不過對方是 Microsoft MVP ,怎麼可以丟出去是讓人丟臉,便先行驗證了一下,並將 1.1 版的相容性同時做了點修正與調整,同時更新 Tiny_mce plugins for 2.0

 

下載網址: http://update.to/cs/SyntaxHighlighter/CommunityServer.SyntaxHighlighterWrapper20.zip

フィーナ 逆変身

一直請白河さやか當 model ,這次換請月公主 フィーナ (Feena) 來當個 model

其實 フィーナ 的照片一直有陸續照,但一直照不出拿的出來見人的照片,照出來的感覺總是和實際上的不太一樣,首先是我對那個大臉頗有意見,另外琉璃色的頭髮是一個很難呈現的顏色,因為很容易因為太淡,被背景蓋掉,所以特地挑了一個黑色背景,不過在 E20 下,拍出來不夠艷麗,還好朋友借來的 40D 拍出來還不錯

不過拍好後發覺眼睫毛沒有貼的很好,下次要拍再改進一下

Posted 作者 dmwc with 1 comment(s)
分類:

英語發音教學

台灣人英語程度和年齡相反,小學生程度>國中生>高中生>大學生>已畢業,英文不好除了單字不夠多外,另一點就是不會念

一般上班族,大都會用眼睛博士 ( Dr.eye ),這套有個缺點,當字庫裡面沒有的單字 (有時並不算單字),查不到時您也沒辦法知道讀音,還好國外有網站可以告訴你讀音

Acapela Text to Speech Demo

您只要在裡面輸入文字,他就會念給你聽,例如一些比較難發音的網站 ( Plurk , youtube ) 或平台 Android , ubuntu 或根本不是單字 SPMT

至少先會念,這樣要背下來就會快很多

Posted 作者 dmwc with 1 comment(s)
分類:

每日匯率 RSS 正式播送

因為我個人常常需要繳外幣給主機商、網域名稱和國際購物,匯率多少常常需要關心一下,可以從帳戶調度和預知帳單金額以免吐血

在首頁的右方下面一點點,有我從土銀偷出來的資料,每天會自動更新,但有時候也稍稍的懶惰,想說用 RSS 跑更方便

要產生 RSS ,在 CommunityServer 裡面就有提供 RSS.Net 的元件,說個歷史, RSS.Net 其實古早古早以前就有了,可以到此下載 http://www.rssdotnet.com/ ,但不曉得是不是作者不見了還是商業化,原本原始碼已經失聯了,雖然商業化後的個人版只要 9 美金,但免錢的不是更好

在 CommuntiyServer 2008 時,Telligent 有被網友提出來,2008 裡面包含的 RSS.Net 並不是上面提到的那個古早版本,有修正了一些 Bug ,但原始碼就沒有公布,當時 Telligent 也就只好把 Source Code 放了出來 (不過放哪裡我也忘了,好像也失聯了) ,這套 Telligent 改過的 RSS.Net 含原始碼(也含範例)就一直躺在我電腦裡,如果也有網友有需要,可以連絡我,不需要原始碼的可以直接下 CommunityServer 2008.5 去挖出來用

因為有範例和原始碼,外加其實用土法煉鋼吐 RSS 也不會太難,沒兩三下就搞定了

如果您也要看 每日匯率RSS ,請把這連結加到您的 RSS 瀏覽器即可 http://www.ruri.com.tw/Currency/CurrencyRSS.aspx

Posted 作者 dmwc with 1 comment(s)
分類:
更多內容 下一頁 »