-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
2,455 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
常规发布:可详细配置各种发布参数 | ||
发布预览 | ||
上传图片到图床 | ||
文章管理 | ||
设置 | ||
偏好设置 | ||
图床设置 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright (c) 2023, Terwer . All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Terwer designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Terwer in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com | ||
* or visit www.terwer.space if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
import { BlogApi } from "zhi-blog-api" | ||
|
||
/** | ||
* Github API 适配器 | ||
* | ||
* @author terwer | ||
* @version 1.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
class GithubApiAdaptor extends BlogApi { | ||
|
||
} | ||
|
||
export { GithubApiAdaptor } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# SiYuanApiAdaptor | ||
|
||
## Usage | ||
|
||
```ts | ||
import { SiYuanApiAdaptor, SiyuanConfig } from "zhi-siyuan-api" | ||
|
||
const siyuanCfg = new SiyuanConfig("http://127.0.0.1:6806", "") | ||
// 显示指定修复标题 | ||
siyuanCfg.fixTitle = true | ||
const siyuanApiAdaptor = new SiYuanApiAdaptor(siyuanCfg) | ||
const siyuanApi = Utils.blogApi(appInstance, siyuanApiAdaptor) | ||
const siyuanUsersBlogs = await siyuanApi.getUsersBlogs() | ||
console.log("siyuanUsersBlogs=>", siyuanUsersBlogs) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 2023, Terwer . All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Terwer designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Terwer in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com | ||
* or visit www.terwer.space if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
import { BlogApi, UserBlog } from "zhi-blog-api" | ||
import { WordpressConfig } from "~/src/adaptors/wordpress/config/wordpressConfig.ts" | ||
import { CommonXmlrpcClient } from "zhi-xmlrpc-middleware" | ||
import { AppInstance } from "~/src/appInstance.ts" | ||
import { createAppLogger } from "~/src/utils/appLogger.ts" | ||
import { WordpressConstants } from "~/src/adaptors/wordpress/wordpressConstants.ts" | ||
|
||
/** | ||
* WordPress API 适配器 | ||
* | ||
* @author terwer | ||
* @version 1.0.0 | ||
* @since 1.0.0 | ||
*/ | ||
class WordpressApiAdaptor extends BlogApi { | ||
private readonly logger | ||
private readonly cfg: WordpressConfig | ||
private readonly commonXmlrpcClient | ||
|
||
/** | ||
* 初始化 WordPress API 适配器 | ||
* | ||
* @param appInstance 应用实例 | ||
* @param cfg 配置项 | ||
*/ | ||
constructor(appInstance: AppInstance, cfg: WordpressConfig) { | ||
super() | ||
|
||
this.cfg = cfg | ||
this.logger = createAppLogger("wordpress-api-adaptor") | ||
this.commonXmlrpcClient = new CommonXmlrpcClient(appInstance, cfg.apiUrl) | ||
} | ||
|
||
public override async getUsersBlogs(): Promise<Array<UserBlog>> { | ||
let result: UserBlog[] = [] | ||
result = await this.wordpressCall(WordpressConstants.METHOD_GET_USERS_BLOGS, []) | ||
this.logger.debug("getUsersBlogs=>", result) | ||
return result | ||
} | ||
|
||
private async wordpressCall(method: string, params: string[]) { | ||
const parameters = ["wordpress", this.cfg.username, this.cfg.password] | ||
params.forEach((param) => parameters.push(param)) | ||
return await this.commonXmlrpcClient.methodCall(method, parameters, this.cfg.middlewareUrl) | ||
} | ||
} | ||
export { WordpressApiAdaptor } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright (c) 2023, Terwer . All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. Terwer designates this | ||
* particular file as subject to the "Classpath" exception as provided | ||
* by Terwer in the LICENSE file that accompanied this code. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com | ||
* or visit www.terwer.space if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
import { BlogConfig } from "zhi-blog-api" | ||
|
||
/** | ||
* WordPress 配置 | ||
* | ||
* @author terwer | ||
* @since 1.0.0 | ||
*/ | ||
class WordpressConfig extends BlogConfig { | ||
/** | ||
* API 地址 | ||
*/ | ||
public override apiUrl = "" | ||
|
||
/** | ||
* 用户名 | ||
*/ | ||
public override username = "" | ||
|
||
/** | ||
* 密码 | ||
*/ | ||
public override password = "" | ||
|
||
/** | ||
* 代理地址 | ||
*/ | ||
public override middlewareUrl = "" | ||
|
||
/** | ||
* WordPress 配置项 | ||
* | ||
* @param apiUrl API 地址 | ||
* @param username 用户名 | ||
* @param password 密码 | ||
* @param middlewareUrl 代理地址 | ||
*/ | ||
constructor(apiUrl: string, username: string, password: string, middlewareUrl?: string) { | ||
super() | ||
this.apiUrl = apiUrl | ||
this.username = username | ||
this.password = password | ||
this.middlewareUrl = middlewareUrl | ||
} | ||
} | ||
|
||
export { WordpressConfig } |
Oops, something went wrong.