Skip to content

Commit

Permalink
fix: support upload images for metaweblog platforms
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Apr 1, 2024
1 parent 46c85ce commit dbd2d62
Show file tree
Hide file tree
Showing 12 changed files with 43 additions and 23 deletions.
11 changes: 6 additions & 5 deletions README.md
Expand Up @@ -54,11 +54,12 @@ configuration.
| Git Hosting | Gitlabvitepress || Compatible || Compatible || Supported | No | No | [Official Website](https://gitlab.com/) |
| Git Hosting | Gitlabantora | TODO | TODO | TODO | TODO | TODO | Supported | TODO | TODO | [Official Website](https://gitlab.com/) |
| Git Hosting | Gitlabdocsify | TODO | TODO | TODO | TODO | TODO | Supported | TODO | TODO | [Official Website](https://gitlab.com/) |
| Blog | Metaweblog || Fully Compatible || Partially Compatible || | | | [Official Website](http://xmlrpc.scripting.com/metaWeblog) |
| Blog | CnBlogs || Fully Compatible || Partially Compatible || | | | [Official Website](https://cnblogs.com) |
| Blog | Typecho || Fully Compatible || Partially Compatible || | | | [Official Website](https://typecho.org/) |
| Blog | Jvue || Fully Compatible || Partially Compatible || | | | [Official Website](https://github.com/terwer/jvue) |
| Blog | WordPress || Fully Compatible || Partially Compatible || | | | [Official Website](https://wordpress.org/) |
| Blog | Metaweblog || Compatible || Compatible || Supported | Bundled Proxy | No | [Official Website](http://xmlrpc.scripting.com/metaWeblog) |
| Blog | CnBlogs || Compatible || Compatible || Supported | Bundled Proxy | No | [Official Website](https://cnblogs.com) |
| Blog | Typecho || Compatible || Compatible || Supported | Bundled Proxy | No | [Official Website](https://typecho.org/) |
| Blog | Jvue || Compatible || Compatible || Supported | Bundled Proxy | No | [Official Website](https://github.com/terwer/jvue) |
| Blog | WordPress || Compatible || Compatible || Supported | Bundled Proxy | No | [Official Website](https://wordpress.org/) |
| Blog | WordPress.com || Compatible || Compatible || Supported | Bundled Proxy | No | [Official Website](https://wordpress.com) |
| Social Media | Zhihu || Fully Compatible || Partially Compatible, Requires PC Account Verification || | | | [Official Website](https://www.zhihu.com/) |
| Social Media | CSDN || Fully Compatible || Partially Compatible, Requires PC Account Verification || | | | [Official Website](https://www.csdn.net/) |
| Social Media | WeChat Official Account || Fully Compatible || Partially Compatible, Requires PC Account Verification || | | | [Official Website](https://mp.weixin.qq.com/) |
Expand Down
11 changes: 6 additions & 5 deletions README_zh_CN.md
Expand Up @@ -51,11 +51,12 @@
| Git 托管 | Gitlabvitepress || 完全兼容 || 完全兼容 || 支持 | 不需要 | 不需要 | [官网](https://gitlab.com/) |
| Git 托管 | Gitlabantora | TODO | TODO | TODO | TODO | TODO | TODO | TODO | TODO | [官网](https://gitlab.com/) |
| Git 托管 | Gitlabdocsify | TODO | TODO | TODO | TODO | TODO | TODO | TODO | TODO | [官网](https://gitlab.com/) |
| 博客 | Metaweblog || 完全兼容 || 部分兼容 || | | | [官网](http://xmlrpc.scripting.com/metaWeblog) |
| 博客 | CnBlogs || 完全兼容 || 部分兼容 || | | | [官网](https://cnblogs.com) |
| 博客 | Typecho || 完全兼容 || 部分兼容 || | | | [官网](https://typecho.org/) |
| 博客 | Jvue || 完全兼容 || 部分兼容 || | | | [官网](https://github.com/terwer/jvue) |
| 博客 | WordPress || 完全兼容 || 部分兼容 || | | | [官网](https://wordpress.org/) |
| 博客 | Metaweblog || 完全兼容 || 完全兼容 || 支持 | 内置代理 | 不需要 | [官网](http://xmlrpc.scripting.com/metaWeblog) |
| 博客 | CnBlogs || 完全兼容 || 完全兼容 || 支持 | 内置代理 | 不需要 | [官网](https://cnblogs.com) |
| 博客 | Typecho || 完全兼容 || 完全兼容 || 支持 | 内置代理 | 不需要 | [官网](https://typecho.org/) |
| 博客 | Jvue || 完全兼容 || 完全兼容 || 支持 | 内置代理 | 不需要 | [官网](https://github.com/terwer/jvue) |
| 博客 | WordPress || 完全兼容 || 完全兼容 || 支持 | 内置代理 | 不需要 | [官网](https://wordpress.org/) |
| 博客 | WordPress.com || 完全兼容 || 完全兼容 || 支持 | 内置代理 | 不需要 | [官网](https://wordpress.com) |
| 社交媒体 | 知乎 || 完全兼容 || PC 验证 || | | | [官网](https://www.zhihu.com/) |
| 社交媒体 | CSDN || 完全兼容 || PC 验证 || | | | [官网](https://www.csdn.net/) |
| 社交媒体 | 微信公众号 || 完全兼容 || PC 验证 || | | | [官网](https://mp.weixin.qq.com/) |
Expand Down
3 changes: 3 additions & 0 deletions src/adaptors/api/cnblogs/useCnblogsApi.ts
Expand Up @@ -91,6 +91,9 @@ export const useCnblogsApi = async (key?: string, newCfg?: CnblogsConfig) => {
cfg.categoryType = CategoryTypeEnum.CategoryType_Multi
cfg.allowCateChange = true
cfg.knowledgeSpaceEnabled = false
// picbed service
cfg.picgoPicbedSupported = true
cfg.bundledPicbedSupported = true

// 创建Cnblogs API适配器
const blogApi = new CnblogsApiAdaptor(appInstance, cfg)
Expand Down
3 changes: 3 additions & 0 deletions src/adaptors/api/jvue/useJvueApi.ts
Expand Up @@ -89,6 +89,9 @@ export const useJvueApi = async (key?: string, newCfg?: JvueConfig) => {
cfg.categoryType = CategoryTypeEnum.CategoryType_Multi
cfg.allowCateChange = true
cfg.knowledgeSpaceEnabled = false
// picbed service
cfg.picgoPicbedSupported = true
cfg.bundledPicbedSupported = true

// 创建Jvue API适配器
const blogApi = new JvueApiAdaptor(appInstance, cfg)
Expand Down
3 changes: 3 additions & 0 deletions src/adaptors/api/metaweblog/useMetaweblogApi.ts
Expand Up @@ -88,6 +88,9 @@ export const useMetaweblogApi = async (key?: string, newCfg?: MetaweblogConfig)
cfg.categoryType = CategoryTypeEnum.CategoryType_Multi
cfg.allowCateChange = true
cfg.knowledgeSpaceEnabled = false
// picbed service
cfg.picgoPicbedSupported = true
cfg.bundledPicbedSupported = true

// 创建Metaweblog API适配器
const blogApi = new MetaweblogBlogApiAdaptor(appInstance, cfg)
Expand Down
3 changes: 3 additions & 0 deletions src/adaptors/api/typecho/useTypechoApi.ts
Expand Up @@ -88,6 +88,9 @@ export const useTypechoApi = async (key?: string, newCfg?: TypechoConfig) => {
cfg.categoryType = CategoryTypeEnum.CategoryType_Multi
cfg.allowCateChange = true
cfg.knowledgeSpaceEnabled = false
// picbed service
cfg.picgoPicbedSupported = true
cfg.bundledPicbedSupported = true

// 创建Typecho API适配器
const blogApi = new TypechoApiAdaptor(appInstance, cfg)
Expand Down
3 changes: 3 additions & 0 deletions src/adaptors/api/wordpress-dot-com/useWordpressdotcomApi.ts
Expand Up @@ -92,6 +92,9 @@ export const useWordpressdotcomApi = async (key?: string, newCfg?: Wordpressdotc
cfg.categoryType = CategoryTypeEnum.CategoryType_Multi
cfg.allowCateChange = true
cfg.knowledgeSpaceEnabled = false
// picbed service
cfg.picgoPicbedSupported = true
cfg.bundledPicbedSupported = true

// 创建 Wordpress.com API 适配器
const blogApi = new WordpressdotcomApiAdaptor(appInstance, cfg)
Expand Down
3 changes: 3 additions & 0 deletions src/adaptors/api/wordpress/useWordpressApi.ts
Expand Up @@ -88,6 +88,9 @@ export const useWordpressApi = async (key?: string, newCfg?: WordpressConfig) =>
cfg.categoryType = CategoryTypeEnum.CategoryType_Multi
cfg.allowCateChange = true
cfg.knowledgeSpaceEnabled = false
// picbed service
cfg.picgoPicbedSupported = true
cfg.bundledPicbedSupported = true

// 创建Wordpress API适配器
const blogApi = new WordpressApiAdaptor(appInstance, cfg)
Expand Down
6 changes: 3 additions & 3 deletions src/composables/usePicgoBridge.ts
Expand Up @@ -47,10 +47,10 @@ const checkConfig = async (siyuanApi: SiyuanKernelApi, picgo: SiyuanPicgoPostApi
} else {
if (needUpdate) {
siyuanApi.pushMsg({
msg: "PicGO 图床历史配置迁移完成",
msg: "PicGo 图床历史配置迁移完成",
timeout: 7000,
})
console.log("PicGO 图床历史配置迁移完成")
console.log("PicGo 图床历史配置迁移完成")
needUpdate = false
}
console.log("picgo instance is ready")
Expand Down Expand Up @@ -99,7 +99,7 @@ const usePicgoBridge = () => {
const picgoPostResult = await picgoPostApi.uploadPostImagesToBed(siyuanData.pageId, siyuanData.meta, md)
// 有图片才上传
if (picgoPostResult.hasImages) {
// const picgoImageTip = `检测到图片,将使用 PicGO 自动上传图片,若图片较多可能会较慢请耐心等待`
// const picgoImageTip = `检测到图片,将使用 PicGo 自动上传图片,若图片较多可能会较慢请耐心等待`
// await kernelApi.pushMsg({
// msg: picgoImageTip,
// timeout: 3000,
Expand Down
4 changes: 2 additions & 2 deletions src/composables/useProxy.ts
Expand Up @@ -136,10 +136,10 @@ const useProxy = (middlewareUrl?: string, corsProxyUrl?: string) => {
const body = serializer.serializeMethodCall(reqMethod, reqParams)
let resText: string
if (forceProxy) {
const res = await proxyFetch(url, [], body, "POST", "text/xml", forceProxy)
const res = await proxyFetch(url, [], body, "POST", "text/xml", forceProxy, "base64")
resText = await res?.body["xml-body"]
} else {
resText = await proxyFetch(url, [], body, "POST", "text/xml", forceProxy)
resText = await proxyFetch(url, [], body, "POST", "text/xml", forceProxy, "base64")
}
resText = XmlrpcUtil.removeXmlHeader(resText)
const deserializer = new Deserializer()
Expand Down
8 changes: 4 additions & 4 deletions src/locales/en_US.ts
Expand Up @@ -319,7 +319,7 @@ export default {
"siyuan.browser.menu.preview.btn": "Preview",
"siyuan.browser.menu.manage.btn": "Manage",
"siyuan.browser.menu.anki.btn": "Anki",
"siyuan.browser.menu.picture.btn": "PicGO",
"siyuan.browser.menu.picture.btn": "PicGo",
"siyuan.browser.menu.setting.btn": "Setting",
"anki.siyuan.deck": "Deck",
"anki.siyuan.deck.new": "New deck",
Expand Down Expand Up @@ -492,7 +492,7 @@ export default {
"setting.picgo.refer.to": "For details, please refer to:",
"setting.picgo.refer.to.online.doc": "Picgo configuration online documentation",
"setting.picgo.picbed": "Picbed setting",
"setting.picgo.picgo": "PicGO setting",
"setting.picgo.picgo": "PicGo setting",
"main.opt.edit": "Edit",
"main.opt.delete": "Delete",
"setting.picgo.picgo.open.config.file": "Open config file",
Expand Down Expand Up @@ -692,8 +692,8 @@ export default {

"publisher.picbed.service": "Image Hosting Service",
"publisher.picbed.none": "Not in use",
"publisher.picbed.picgo": "PicGO Plugin",
"publisher.picbed.picgo.not.install": "PicGO plugin not detected. You may proceed to the plugin store for installation before enabling it.",
"publisher.picbed.picgo": "PicGo Plugin",
"publisher.picbed.picgo.not.install": "PicGo plugin not detected. You may proceed to the plugin store for installation before enabling it.",
"publisher.picbed.bundled": "Current Platform",
"publisher.picbed.recom1": "Strongly Recommended",
"publisher.picbed.recom2": "Recommended",
Expand Down
8 changes: 4 additions & 4 deletions src/locales/zh_CN.ts
Expand Up @@ -325,7 +325,7 @@ export default {
"anki.siyuan.tag": "标签",
"anki.siyuan.tag.new": "新标签",
"picgo.chrome.tip":
"您当前使用的是浏览器插件,需要从这里下载配置 PicGO 客户端:https://github.com/Molunerfinn/PicGo/releases",
"您当前使用的是浏览器插件,需要从这里下载配置 PicGo 客户端:https://github.com/Molunerfinn/PicGo/releases",
"picgo.siyuan.tip": "您当前使用的是思源笔记挂件,PicGO已内置,只需配置即可",
"post.detail.button.copy.id": "复制本文ID",
"post.detail.button.share.link": "复制分享链接",
Expand All @@ -344,7 +344,7 @@ export default {
"picgo.pic.preview": "图片预览",
"picgo.pic.setting": "图床设置",
"picgo.pic.setting.no.tip":
"由于您当前使用的是浏览器插件,无法直接集成 PicGO ,只能通过 HTTP 请求间接调用本地 PicGO 客户端上图片,请直接在本地 PicGO 客户端进行设置。如需体验更加完整的功能,请通过思源笔记挂件版挂载菜单打开新窗口的方式使用。详情请参考:https://docs.publish.terwer.space/post/the-pendant-mode-is-used-in-the-method-of-mounting-menu-169wrw.html",
"由于您当前使用的是浏览器插件,无法直接集成 PicGo ,只能通过 HTTP 请求间接调用本地 PicGo 客户端上图片,请直接在本地 PicGo 客户端进行设置。如需体验更加完整的功能,请通过思源笔记挂件版挂载菜单打开新窗口的方式使用。详情请参考:https://docs.publish.terwer.space/post/the-pendant-mode-is-used-in-the-method-of-mounting-menu-169wrw.html",
"github.use.permalink": "永久链接",
"github.use.permalink.no.warn":
"您已关闭永久链接,formatter将不会生成标记,这在某些特殊场景下可能有用,大部分情况下需要开启此选项,注意:目前仅仅在HUGO平台生效,主要是适配Docsy",
Expand Down Expand Up @@ -675,8 +675,8 @@ export default {

"publisher.picbed.service": "图床服务",
"publisher.picbed.none": "不使用",
"publisher.picbed.picgo": "PicGO 插件",
"publisher.picbed.picgo.not.install": "此功能需要「PicGO 图床」插件 1.9.0+ 支持,请先从集市安装",
"publisher.picbed.picgo": "PicGo 插件",
"publisher.picbed.picgo.not.install": "此功能需要「PicGo 图床」插件 1.9.0+ 支持,请先从集市安装",
"publisher.picbed.bundled": "当前平台",
"publisher.picbed.recom1": "强烈推荐",
"publisher.picbed.recom2": "推荐",
Expand Down

0 comments on commit dbd2d62

Please sign in to comment.