deepin right click to send blog

1 Overview

There is no decent note-taking software on the deepin system. It is a pity that I did not provide deb packaged software for the notes. The software provided by the store has stayed in the interface for the last century.
At this time, if you want to share to the blog through notes is a very difficult thing.
This blog is to directly use the Python environment of the deepin system, call the API of the blog garden, and then send the local article to the blog garden.
This operation is integrated into the right mouse button or setting shortcut keys, scripts, etc. are great experiences

2. Environmental preparation

2.1 Learning Blog Park API and creating scripts

I learned the blog garden API through this blog. I would like to thank the blogger for sharing.
The following is a Python script I created locally.
The first is to install xmlrpc, omitted here

#!/usr/bin/python3

import sys
import xmlrpc.client

if __name__ == "__main__":

    if len(sys.argv) != 2:
        sys.exit(0)

    #获取博客内容
    with open(sys.argv[1],'r') as blog:
        content = blog.read()

    #设置博客标题
    blog_title=sys.argv[1].split('/')[-1].split('.')[0]

    p = xmlrpc.client.ServerProxy("https://rpc.cnblogs.com/metaweblog/liwanliangblog")
    p.metaWeblog.newPost('',"liwanliang","我的博客密码",{
        'title':blog_title,
        'description':content,
        'categories':['[]','[Markdown]'],
        },True)

The above script chmod +x blog.pycan be executed by modifying the permissions.
The execution method is: ./blog.py 你的博客.md
so far, complete the first step

2.2 Learning the right-click extension of the deepin file manager

The deepin system is switched to the root user, and then enter the directory: cd /usr/share/deepin/dde-file-manager/oem-menuextensions
in this directory, create a deepin-send-blog.desktop file, the content is as follows:

[Desktop Entry]
Type=Application
Exec=/home/liwl/blog.py %U
Name=发送至博客园

Save and exit. Then launcher + e to open the file manager, after creating a blog, right-click and click "Send to Blog Park".
This blog is the way to do it.

Guess you like

Origin www.cnblogs.com/liwanliangblog/p/12755738.html