日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

我的博客搬家工具开发

發布時間:2023/12/10 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 我的博客搬家工具开发 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

從四月一號開始就著手開發一個從“陽光博客”搬家到“Blogger”的工具,歷經一個月,宣告失敗!

下面是開發的過程:

一、項目背景

從07年四月開始,我就在陽光博客上開始寫博客,整整兩年。在寫博客過程中覺得陽光博客提供的博客功能有如下地方不友好:

1、無法添加mita數據到博客

2、文章編輯器太簡單,對程序代碼沒有良好的支持

3、站點老是被檢測出有病毒,Google搜索無法進入,Firefox也是警告,不過這個好像最近解決了。

4、看過陽光博客站點的首頁覺得很多推薦的博客之類的都是90后。。。

5、整個站點是用ASP搭建的,注意是ASP不是ASP.NET,落伍的技術,每次看見后綴名是.asp 覺得就不爽,心里作用。

使用Google提供的服務已經好多年了,差不多完全接受或者說是依賴Google已經兩年多了,覺得它提供的服務還是比較穩定,而且能滿足我很多的需求,

比如:Gmail,Bookmarks,Doc,Code等等,Blogger是被Google收購的一家博客站點,覺得應該不錯,就想把博客遷入Blogger,再個發現它是全球博客服比較好的博客,還有另個是Wordspress,我也在用,不過只寫英文的,鍛煉英文,呵呵!

?

二、項目需求

把陽光博客中所有的帖子全部移入Blogger,范圍只是博客,不包括回復和留言。由于Blogger不支持自己生成創建時間,所以對于時間也不導入。

?

三、項目設計:

1、接口

Blooger API:http://code.google.com/apis/blogger/docs/2.0/developers_guide_protocol.html

YgBlog使用從博客管理中導出的日志Rss文件

2、程序架構設計

IBlog是接口類,定義一個博客要實現的所有方法以及需要的屬性

BlogspotEntity是Blogger的實現,核心是做登錄驗證和接受博客數據

YgBlogEntity是陽光博客的實現,核心職責是從Rss文件中讀入博客實體

Utility是公用的一些方法的集合,現在加入的核心功能是數據請求一個URL,并返回URL的Response結果

BlogEntityCollection是方便把BlogspotEntity和YgBlogEntity輸出到BlogTools項目中

BlogTools是UI層,提供的功能有博客移動和發布博客以及查看配置

UI 層使用WPF開發。

整個架構設計的核心思想是:

可擴展的博客管理,配置文件如下:

?

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配置的是實現了IBlog的BlogEntity,配置的時候需要指定程序集和類,如果是可以導入的博客則要提供用戶名密碼,以及導入請求的URL。

?

四、開發實現

接口定義:

?

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負責實現這兩個接口。當然也可以再添加其它的博客,只要實現了這兩個接口就可以無縫的插入到BlogTools中

?

五、測試

工具開發完以后做了一些導入測試,可以導入大部分的博客,但是還是存在一些問題:

1、Blogger每天提供的訪問URL的次數有限制,不能一直調試測試,好像大概每天只能有三次(做三次導入,每次我一般有50多條數據)

2、對于特殊標簽Blogger不允許導入,比如YgBlog自定義的<o:p>

3、Html標簽必須成對,如果有單個的則不能導入

4、Html中不能帶屬性,包括樣式。

?

六、總結

整個項目對我來說是一個失敗的項目:整個項目實現了基本數據從陽光博客到Blogger的導入,但是Html標簽的處理比較失敗。

代碼完成的時間是4月17號,但是卻話了近半個月的時間做調試測試。當然也有Blogger的限時訪問的原因。

還有一個很重要的外界因素:Blogger在中國訪問有問題,老是會掛掉。估計GFW屏蔽的吧。我在公司使用的是直連到日本的網絡,不會有這個問題。

所以,這個工具只能自己娛樂了,不能作為實用工具了,真可惜。

?

后記:

我寫這個博客的主要目的是和大家分享一下。我們每天用技術為公司創造價值,其實我們也可以用我們掌握的技術去為自己開發一些工具服務,順便可以學學東西,包括程序設計的架構(比如BlogSolution中對接口的定義,以及實現的方案,無縫的插入擴展)和新的技術(Blogsolution中的BlogTools是用WPF開發的),以及使用一些別家公司提供的API(比如Google的Blogger API),這樣對自己以后的項目也有很大的幫助。

附:Blogsolution Release?

轉載于:https://www.cnblogs.com/disappearwind/archive/2009/05/04/1448589.html

總結

以上是生活随笔為你收集整理的我的博客搬家工具开发的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。