ArticleDirectory
Summary
This series of articles will teach you how to create your own blog or homepage on GitHub step by step. In fact, there are many related articles on the Internet. Here, I just share my experience with new users, so that they can start their GitHub journey. This article describes how to make GitHub blog compatible with Windows writer.
This article is first published on my GitHub homepage: Create a blog homepage step by step on GitHub (7)-service providers compatible with Windows writer.
Origin
What? Does the GitHub homepage support Windows writer? Joke! You will definitely ask me this question. Well, I am indeed the title party, but what I want to introduce in this article is not to make the GitHub homepage compatible with our windows writer, but to implement a service provider compatible with Windows writer. You can program this provider to support the functions you want, so that we can build the Jekyll template and blog structure on the local machine.
I like to use Windows writer to write articles, mainly because it is compatible with many blog systems. I can copy them in writer and useCodePlug-ins: When I publish a blog, all of this work order is very good. images will be uploaded to my blog hosting website, and an appropriate image link will be automatically created. This saves me a lot of time. However, I recently started to open my own blog on GitHub. Use git to manage static files. I have described this in detail in the articles earlier in this series. However, since GitHub only supports static html, I must use Windows writer to edit my article locally and then compile the HTML generated by writer.Source codePaste it to the file in the pre-prepared _ posts path. If there is no image in the article, it is relatively simple, but it is very troublesome to have images. Every image must be copied from the writer and manually created in the IMG folder, this is not the worst. I have to manually change the SRC of the IMG label in source to the desired link. Repeat the above steps makes me very uncomfortable. I previously thought about whether to make this process more convenient by creating a writer plug-in, but it was fruitless. Today, I happened to think that I could implement a writer provider locally as I did in the blog Park, so that writer would "Upload" Images and articles to my local web application.Program, I just need to automatically implement the tedious work above in the Web application.
XML-RPC and imetaweblog
Find related implementation methods on the Internet: add support for Windows Live writer to your blog Program
There are many interface methods between writer and the provider supporting writer, one of which is a simple implementation of XML-RPC and metaweblog.
What is XML-RPC: as the name suggests, is based on XML Remote Call, similar to soap. The only advantage of XML-RPC is "as simple as possible ".
What is metaweblog? It is an interface standard of the blog system and is easy to implement.
XML-RPC.NET
This is a class library implementing the XML-RPC, and in the source code combined with the implementation, with the imetaweblog interface definition. Download it here.
Start
After explaining the basic concepts, we started to work on it. First follow the link above to download the XML-RPC.NET. I like to use the source code to build an application, so after decompression, find the src directory in the source code, which is a. NET 2.0 project XMLRPC, contains the complete source code. Build a solution, add this project, create an ASP. NET web application, and reference XMLRPC in the project.
Not surprisingly, it can be compiled directly now. Find metaweblogapi. CS in the interfaces folder in the decompressed package. This file contains all interface definitions of imetaweblog and adds it to the Web application. To be compatible with writer, you need to add an interface and a structure:
Public Struct Userblog
{
Public String URL ;
Public String Blogid ;
Public String Blogname ;
} [Xmlrpcmethod ("blogger. getusersblogs")]
Userblog [] Getusersblogs ( String Appkey , String Username , String Password );
The xmlrpcservice class of XML-RPC.NET implements ihttphandler and provides implementation of all the underlying details of all XML-RPC. Therefore, you only need to use an ashx to implement imetaweblog:
Rpc. ashx
[Xmlrpcservice (description = "metaweblog XML-RPC service")]
Public Class RPC : Xmlrpcservice , Imetaweblog
{
}
After debugging, you can see a list of methods.
Let's take a look at the definition of each method in the interface:
- Getusersblogs: it is called when a blog is set in writer. It must be implemented and can be returned at will.
- Editpost: used for writer to edit articles already on the server. Optional.
- Getcategories: obtains all categories. It is called when the writer "set category" function is refreshed. It may also be called when initializing a blog configuration. Optional.
- Getpost: writer tries to synchronize remote articles for synchronization. Optional.
- Getrecentposts: obtain the latest article. Optional.
- Newpost: Create a new article, which must be implemented
- Newmediaobject: it is best to upload images using this method, otherwise it will not make sense.
Next, let me talk about my needs. When I click "publish" in writer, the image can be automatically saved to the path I specified, and the article can be automatically created in the path I specified. The image link in the article can be correctly pointed.
Configure writer
Select other services
Enter our ashx address. The username and password are free, because we do not care.Remember the password first
Writer cannot identify the API type. manually select and enter the address again.
In this way, you have configured a new blog provider. You can define a name by yourself. Restart writer and you will be able to see this provisioner in the list.
The following details are the implementation of these interfaces, which is not difficult. I will not detail it here. However, you must pay attention to the following picture:
When the writer processes images, one a and one IMG are generated by default. When the image is uploaded to the server, two images are uploaded simultaneously, one for the link of A and the other for the IMG, the two images have different sizes. Uploading all files is a waste of space. Therefore, when editing a document, you must remove the default link of the image, so that only one image uploaded to the server will be available:
Select the image and set it to "no connection".
If you need source code, contact me or leave a message.
Complete Series directory:
Step by step create a blog homepage on GitHub (6) This article describes how to add the blog function.
Step by step create a blog homepage on GitHub (5) This article describes how to use Jekyll to build a blog. Step by step create a blog homepage on GitHub (4) This article describes how to build a local GitHub server for pre-release testing. Step by step create a blog homepage on GitHub (3) This article describes how to bind a domain name. Create a blog homepage step by step on GitHub (2) This article will show you how to quickly build a GitHub project homepage. You 'd better have installed the GIT client before you start. Step by step create a blog homepage on GitHub (1) This article introduces the personal blog provided by GitHub and Its Key Technologies for readers to make decisions.