-
Notifications
You must be signed in to change notification settings - Fork 13
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
20 changed files
with
981 additions
and
47 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
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
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
76 changes: 76 additions & 0 deletions
76
src/adaptors/api/gitlab-vuepress/gitlabvuepressApiAdaptor.ts
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,76 @@ | ||
/* | ||
* 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, [email protected] | ||
* or visit www.terwer.space if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
import { BlogConfig, PageTypeEnum, Post, YamlConvertAdaptor } from "zhi-blog-api" | ||
import { CommonGitlabApiAdaptor } from "~/src/adaptors/api/base/gitlab/commonGitlabApiAdaptor.ts" | ||
import _ from "lodash" | ||
import { GitlabvuepressYamlConverterAdaptor } from "~/src/adaptors/api/gitlab-vuepress/gitlabvuepressYamlConverterAdaptor.ts" | ||
|
||
/** | ||
* Hexo API 适配器 | ||
* | ||
* @author terwer | ||
* @version 1.3.2 | ||
* @since 0.8.1 | ||
*/ | ||
class GitlabvuepressApiAdaptor extends CommonGitlabApiAdaptor { | ||
public override getYamlAdaptor(): YamlConvertAdaptor { | ||
return new GitlabvuepressYamlConverterAdaptor() | ||
} | ||
|
||
public override async preEditPost(post: Post, id?: string, publishCfg?: any): Promise<Post> { | ||
// 公共的属性预处理 | ||
const doc = await super.preEditPost(post, id, publishCfg) | ||
|
||
// HEXO 自带的处理 | ||
const cfg: BlogConfig = publishCfg?.cfg | ||
const updatedPost = _.cloneDeep(doc) as Post | ||
|
||
// 自定义处理 | ||
// 成功提示、信息提示、警告提示、错误提示 | ||
const md = updatedPost.markdown | ||
this.logger.info("准备处理 Gitlabvuepress 正文") | ||
this.logger.debug("md =>", { md: md }) | ||
let updatedMd = md | ||
|
||
// MD暂时无法处理标记,先搁置 | ||
// 处理MD | ||
|
||
updatedPost.markdown = updatedMd | ||
this.logger.info("Gitlabvuepress 正文处理完毕") | ||
this.logger.debug("updatedMd =>", { updatedMd: updatedMd }) | ||
|
||
// 发布格式 | ||
if (cfg?.pageType == PageTypeEnum.Markdown) { | ||
post.description = post.markdown | ||
} else { | ||
post.description = post.html | ||
} | ||
|
||
return updatedPost | ||
} | ||
} | ||
|
||
export { GitlabvuepressApiAdaptor } |
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,69 @@ | ||
/* | ||
* 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, [email protected] | ||
* or visit www.terwer.space if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
import { CategoryTypeEnum, PageTypeEnum, PasswordType } from "zhi-blog-api" | ||
import { VuepressConfig } from "~/src/adaptors/api/vuepress/vuepressConfig.ts" | ||
|
||
/** | ||
* Gitlabvuepress 配置 | ||
* | ||
* @author terwer | ||
* @since 1.14.0 | ||
*/ | ||
class GitlabvuepressConfig extends VuepressConfig { | ||
constructor( | ||
githubUsername: string, | ||
githubAuthToken: string, | ||
githubRepo: string, | ||
githubBranch: string, | ||
middlewareUrl?: string | ||
) { | ||
super(githubUsername, githubAuthToken, githubRepo, githubBranch, middlewareUrl) | ||
|
||
this.home = "[your-gitlab-home]" | ||
this.apiUrl = "[your-gitlab-api-url]" | ||
this.tokenSettingUrl = "[your-gitlab-host]/-/profile/personal_access_tokens" | ||
this.showTokenTip = true | ||
this.defaultPath = "docs" | ||
this.previewUrl = "/[user]/[repo]/blob/[branch]/[docpath]" | ||
this.previewPostUrl = "/post/[postid].html" | ||
this.mdFilenameRule = "[filename].md" | ||
this.pageType = PageTypeEnum.Markdown | ||
this.passwordType = PasswordType.PasswordType_Token | ||
this.allowPreviewUrlChange = false | ||
this.tagEnabled = true | ||
this.cateEnabled = true | ||
this.allowCateChange = true | ||
this.categoryType = CategoryTypeEnum.CategoryType_Multi | ||
this.knowledgeSpaceEnabled = true | ||
this.allowKnowledgeSpaceChange = false | ||
this.placeholder.knowledgeSpaceReadonlyModeTip = "Gitlabvuepress 平台暂不支持修改发布目录,如需修改,请删除之后重新发布" | ||
this.knowledgeSpaceType = CategoryTypeEnum.CategoryType_Tree_Single | ||
this.useMdFilename = true | ||
this.usePathCategory = true | ||
} | ||
} | ||
|
||
export { GitlabvuepressConfig } |
30 changes: 30 additions & 0 deletions
30
src/adaptors/api/gitlab-vuepress/gitlabvuepressPlaceHolder.ts
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,30 @@ | ||
/* | ||
* 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, [email protected] | ||
* or visit www.terwer.space if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
import { VuepressPlaceHolder } from "~/src/adaptors/api/vuepress/vuepressPlaceHolder.ts" | ||
|
||
class GitlabvuepressPlaceHolder extends VuepressPlaceHolder {} | ||
|
||
export { GitlabvuepressPlaceHolder } |
36 changes: 36 additions & 0 deletions
36
src/adaptors/api/gitlab-vuepress/gitlabvuepressYamlConverterAdaptor.ts
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,36 @@ | ||
/* | ||
* Copyright (c) 2022-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, [email protected] | ||
* or visit www.terwer.space if you need additional information or have any | ||
* questions. | ||
*/ | ||
|
||
import { VuepressYamlConverterAdaptor } from "~/src/adaptors/api/vuepress/vuepressYamlConverterAdaptor.ts" | ||
|
||
/** | ||
* Gitlabvuepress平台的YAML解析器 | ||
* | ||
* @author terwer | ||
* @since 1.14.0 | ||
*/ | ||
class GitlabvuepressYamlConverterAdaptor extends VuepressYamlConverterAdaptor {} | ||
|
||
export { GitlabvuepressYamlConverterAdaptor } |
Oops, something went wrong.