我的博客搬家工具开发
從四月一號開始就著手開發(fā)一個從“陽光博客”搬家到“Blogger”的工具,歷經(jīng)一個月,宣告失敗!
下面是開發(fā)的過程:
一、項目背景
從07年四月開始,我就在陽光博客上開始寫博客,整整兩年。在寫博客過程中覺得陽光博客提供的博客功能有如下地方不友好:
1、無法添加mita數(shù)據(jù)到博客
2、文章編輯器太簡單,對程序代碼沒有良好的支持
3、站點老是被檢測出有病毒,Google搜索無法進入,Firefox也是警告,不過這個好像最近解決了。
4、看過陽光博客站點的首頁覺得很多推薦的博客之類的都是90后。。。
5、整個站點是用ASP搭建的,注意是ASP不是ASP.NET,落伍的技術,每次看見后綴名是.asp 覺得就不爽,心里作用。
使用Google提供的服務已經(jīng)好多年了,差不多完全接受或者說是依賴Google已經(jīng)兩年多了,覺得它提供的服務還是比較穩(wěn)定,而且能滿足我很多的需求,
比如:Gmail,Bookmarks,Doc,Code等等,Blogger是被Google收購的一家博客站點,覺得應該不錯,就想把博客遷入Blogger,再個發(fā)現(xiàn)它是全球博客服比較好的博客,還有另個是Wordspress,我也在用,不過只寫英文的,鍛煉英文,呵呵!
?
二、項目需求
把陽光博客中所有的帖子全部移入Blogger,范圍只是博客,不包括回復和留言。由于Blogger不支持自己生成創(chuàng)建時間,所以對于時間也不導入。
?
三、項目設計:
1、接口
Blooger API:http://code.google.com/apis/blogger/docs/2.0/developers_guide_protocol.html
YgBlog使用從博客管理中導出的日志Rss文件
2、程序架構設計
IBlog是接口類,定義一個博客要實現(xiàn)的所有方法以及需要的屬性
BlogspotEntity是Blogger的實現(xiàn),核心是做登錄驗證和接受博客數(shù)據(jù)
YgBlogEntity是陽光博客的實現(xiàn),核心職責是從Rss文件中讀入博客實體
Utility是公用的一些方法的集合,現(xiàn)在加入的核心功能是數(shù)據(jù)請求一個URL,并返回URL的Response結果
BlogEntityCollection是方便把BlogspotEntity和YgBlogEntity輸出到BlogTools項目中
BlogTools是UI層,提供的功能有博客移動和發(fā)布博客以及查看配置
UI 層使用WPF開發(fā)。
整個架構設計的核心思想是:
可擴展的博客管理,配置文件如下:
?
BlogList.xaml?1<ResourceDictionary?xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
?2????xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
?3????xmlns:list="clr-namespace:Disappearwind.BlogSolution.BlogTools;assembly=Disappearwind.BlogSolution.BlogTools">
?4????<list:BlogInfo?
?5????????x:Key="ygBlog"
?6????????BlogName="YgBlog"
?7????????AssemblyName="Disappearwind.BlogSolution.YgBlogEntity"
?8????????TypeName="Disappearwind.BlogSolution.YgBlogEntity.YgBlog"
?9????????IsReadOnly="True">
10????</list:BlogInfo>
11????<list:BlogInfo
12????????x:Key="blogspot"
13????????BlogName="Blogspot"
14????????AssemblyName="Disappearwind.BlogSolution.BlogspotEntity"
15????????TypeName="Disappearwind.BlogSolution.BlogspotEntity.BlogspotBlog"
16????????IsReadOnly="False"
17????????UserName="disappearwind@gmail.com"
18????????Password="mypassword"
19????????PostURL="http://www.blogger.com/feeds/4113265077745692418/posts/default">
20????</list:BlogInfo>
21</ResourceDictionary>
?
每個BlogInfo配置的是實現(xiàn)了IBlog的BlogEntity,配置的時候需要指定程序集和類,如果是可以導入的博客則要提供用戶名密碼,以及導入請求的URL。
?
四、開發(fā)實現(xiàn)
接口定義:
?
IBaseBlog?1/**//****************************************************************************
?2?*?Copyright?(C)?Disappearwind.?All?rights?reserved.????????????????????????*
?3?*??????????????????????????????????????????????????????????????????????????*
?4?*?Author:?disapearwind,?disappearwind@gmail.com????????????????????????????*
?5?*?Created:?2009-4-1????????????????????????????????????????????????????????*
?6?*??????????????????????????????????????????????????????????????????????????*
?7?*?Description:?????????????????????????????????????????????????????????????*
?8?*???Definition?interface?for?base?blog.????????????????????????????????????*
?9?*??????????????????????????????????????????????????????????????????????????*
10*****************************************************************************/
11using?System;
12using?System.Collections.Generic;
13using?System.Linq;
14using?System.Text;
15
16namespace?Disappearwind.BlogSolution.IBlog
17{
18????/**////?<summary>
19????///?Base?blog?interface
20????///?</summary>
21????public?interface?IBaseBlog
22????{
23????????/**////?<summary>
24????????///?Blog?name,the?type?is?string?and?it's?readonly
25????????///?</summary>
26????????string?BlogName?{?get;}
27????????/**////?<summary>
28????????///?Blog?url,the?url?which?the?blog?can?access?and?it's?readonly
29????????///?</summary>
30????????string?URL?{?get;?}
31????????/**////?<summary>
32????????///?Keyword?assign?to?the?blog
33????????///?</summary>
34????????string?KeyWord?{?get;?}
35????????/**////?<summary>
36????????///?The?url?or?address?of?blog?posts
37????????///?when?it?used?in?get?posts?from?blog,it?is?a?rss?url?or?xml?file?of?post
38????????///?and?when?it?used?in?add?post?to?blog?it?is?the?api?of?the?blog?support?to?manage?blog
39????????///?</summary>
40????????string?PostURL?{?get;?set;?}
41????????/**////?<summary>
42????????///?The?url?for?authenticate?user
43????????///?</summary>
44????????string?AuthURL?{?get;?}
45????????/**////?<summary>
46????????///?Login?blog?to?operate?blog
47????????///?</summary>
48????????///?<param?name="userName">user?name</param>
49????????///?<param?name="password">password</param>
50????????///?<returns></returns>
51????????bool?Login(string?userName,?string?password);
52????????/**////?<summary>
53????????///?Get?all?posts
54????????///?</summary>
55????????///?<returns>posts?list</returns>
56????????List<IPost>?GetPosts();
57????????/**////?<summary>
58????????///?Add?a?post?to?the?blog
59????????///?</summary>
60????????///?<param?name="post">the?post?to?be?added,it?must?implement?IPost</param>
61????????///?<returns>result</returns>
62????????bool?AddPost(IPost?post);
63????????/**////?<summary>
64????????///?Delete?post
65????????///?</summary>
66????????///?<param?name="post">the?post?to?be?deleted</param>
67????????///?<returns></returns>
68????????bool?DetetePost(IPost?post);
69????}
70}
71
?
?
IPost?1/**//****************************************************************************
?2?*?Copyright?(C)?Disappearwind.?All?rights?reserved.????????????????????????*
?3?*??????????????????????????????????????????????????????????????????????????*
?4?*?Author:?disapearwind,?disappearwind@gmail.com????????????????????????????*
?5?*?Created:?2009-4-1????????????????????????????????????????????????????????*
?6?*??????????????????????????????????????????????????????????????????????????*
?7?*?Description:?????????????????????????????????????????????????????????????*
?8?*???Definition?interface?for?base?post.????????????????????????????????????*
?9?*??????????????????????????????????????????????????????????????????????????*
10*****************************************************************************/
11using?System;
12using?System.Collections.Generic;
13using?System.Linq;
14using?System.Text;
15
16namespace?Disappearwind.BlogSolution.IBlog
17{
18????/**////?<summary>
19????///?post?interface
20????///?</summary>
21????public?interface?IPost
22????{
23????????/**////?<summary>
24????????///?Post?title
25????????///?</summary>
26????????string?Title?{?get;?set;?}
27????????/**////?<summary>
28????????///?Post?content
29????????///?</summary>
30????????string?Content?{?get;?set;?}
31????????/**////?<summary>
32????????///?Post?createdate,maybe?didn't?today,it?was?the?actual?created?day.
33????????///?</summary>
34????????DateTime?CreateDate?{?get;?set;?}
35????}
36}
37
?
YbBlogEntity和BlogspotEntity負責實現(xiàn)這兩個接口。當然也可以再添加其它的博客,只要實現(xiàn)了這兩個接口就可以無縫的插入到BlogTools中
?
五、測試
工具開發(fā)完以后做了一些導入測試,可以導入大部分的博客,但是還是存在一些問題:
1、Blogger每天提供的訪問URL的次數(shù)有限制,不能一直調(diào)試測試,好像大概每天只能有三次(做三次導入,每次我一般有50多條數(shù)據(jù))
2、對于特殊標簽Blogger不允許導入,比如YgBlog自定義的<o:p>
3、Html標簽必須成對,如果有單個的則不能導入
4、Html中不能帶屬性,包括樣式。
?
六、總結
整個項目對我來說是一個失敗的項目:整個項目實現(xiàn)了基本數(shù)據(jù)從陽光博客到Blogger的導入,但是Html標簽的處理比較失敗。
代碼完成的時間是4月17號,但是卻話了近半個月的時間做調(diào)試測試。當然也有Blogger的限時訪問的原因。
還有一個很重要的外界因素:Blogger在中國訪問有問題,老是會掛掉。估計GFW屏蔽的吧。我在公司使用的是直連到日本的網(wǎng)絡,不會有這個問題。
所以,這個工具只能自己娛樂了,不能作為實用工具了,真可惜。
?
后記:
我寫這個博客的主要目的是和大家分享一下。我們每天用技術為公司創(chuàng)造價值,其實我們也可以用我們掌握的技術去為自己開發(fā)一些工具服務,順便可以學學東西,包括程序設計的架構(比如BlogSolution中對接口的定義,以及實現(xiàn)的方案,無縫的插入擴展)和新的技術(Blogsolution中的BlogTools是用WPF開發(fā)的),以及使用一些別家公司提供的API(比如Google的Blogger API),這樣對自己以后的項目也有很大的幫助。
附:Blogsolution Release?
轉(zhuǎn)載于:https://www.cnblogs.com/disappearwind/archive/2009/05/04/1448589.html
總結
以上是生活随笔為你收集整理的我的博客搬家工具开发的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: plsql轻量版记录类型2
- 下一篇: 前端学习(1901)vue之电商管理系统