Skip to content

Commit

Permalink
feat: Define common blog models
Browse files Browse the repository at this point in the history
  • Loading branch information
terwer committed Mar 31, 2023
1 parent 3a98b91 commit 56823b1
Show file tree
Hide file tree
Showing 6 changed files with 329 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/zhi-blog-api/src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
export * from "./lib/zhi-blog-api"
import BlogConfig, { PasswordType, PageType } from "./lib/blogConfig"
import BlogPlaceholder from "./lib/blogPlaceholder"
export { BlogConfig, BlogPlaceholder, PasswordType, PageType }
143 changes: 143 additions & 0 deletions packages/zhi-blog-api/src/lib/blogConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
/*
* 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 BlogPlaceholder from "./blogPlaceholder"

/**
* 页面类型
*/
export enum PageType {
/**
* Markdown正文
*/
Markdown,
/**
* HTML
*/
Html,
/**
* 属性
*/
Formatter,
/**
* Markdown和属性
*/
Markdown_And_Formatter,
/**
* MDX
*
* @see https://mdxjs.com/
*/
MDX,
}

/**
* 密码类型
*/
export enum PasswordType {
/**
* 密码
*/
PasswordType_Password,
/**
* token
*/
PasswordType_Token,
}
/**
* 博客通用配置类
*/
abstract class BlogConfig {
/**
* 首页
*/
protected home: string

/**
* API地址
*/
protected apiUrl: string

/**
* 用户名
*/
protected username: string

/**
* 密码类型
*/
protected passwordType: PasswordType

/**
* 密码
*/
protected password: string

/**
* 是否发布
*/
protected apiStatus: boolean

/**
* 博客名(API获取)
*/
protected blogName: string

/**
* 文章别名key
*/
protected posidKey: string

/**
* 文章预览链接
*/
protected previewUrl: string

/**
* 文章类型
*/
protected pageType: PageType

/**
* 操作提示
*/
protected placeholder: BlogPlaceholder | undefined

protected constructor() {
this.home = ""
this.apiUrl = ""
this.username = ""
this.passwordType = PasswordType.PasswordType_Password
this.password = ""
this.apiStatus = false
this.blogName = ""
this.posidKey = ""
this.previewUrl = ""
this.pageType = PageType.Markdown
this.placeholder = undefined
}
}

export default BlogConfig
97 changes: 97 additions & 0 deletions packages/zhi-blog-api/src/lib/blogPlaceholder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* 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.
*/

/**
* 配置提示
*
* @author terwer
* @since 1.0.0
*/
abstract class BlogPlaceholder {
/**
* 首页操作提示
*/
protected homePlaceholder: string

/**
* API 地址操作提示
*/
protected apiUrlPlaceholder: string

/**
* 用户名操作提示
*/
protected usernamePlaceholder: string

/**
* 密码类型操作提示
*/
protected passwordTypePlaceholder: string

/**
* 密码操作提示
*/
protected passwordPlaceholder: string

/**
* API状态是否正常操作提示
*/
protected apiStatusPlaceholder: boolean

/**
* 博客名(API获取)操作提示
*/
protected blogNamePlaceholder: string

/**
* 文章别名key操作提示
*/
protected posidKeyPlaceholder: string

/**
* 文章预览链接操作提示
*/
protected previewUrlPlaceholder: string

/**
* 文章类型操作提示
*/
protected pageTypePlaceholder: string

constructor() {
this.homePlaceholder = ""
this.apiUrlPlaceholder = ""
this.usernamePlaceholder = ""
this.passwordTypePlaceholder = ""
this.passwordPlaceholder = ""
this.apiStatusPlaceholder = false
this.blogNamePlaceholder = ""
this.posidKeyPlaceholder = ""
this.previewUrlPlaceholder = ""
this.pageTypePlaceholder = ""
}
}

export default BlogPlaceholder
4 changes: 2 additions & 2 deletions packages/zhi-common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Note: ⚠️This library must be compatible with node, browser, electron and bro
## Usage

```ts
import zhiUtil from "zhi-common"
import zhiCommon from "zhi-common"

const dateUtil = zhiUtil.dateUtil
const dateUtil = zhiCommon.dateUtil
const now = dateUtil.nowDateZh()
console.log("now=>", now)
```
Expand Down
49 changes: 49 additions & 0 deletions packages/zhi-siyuan-api/src/lib/SiyuanConfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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, BlogPlaceholder, PasswordType } from "zhi-blog-api"
import SiyuanPlaceholder from "./SiyuanPlaceholder";

/**
* 思源笔记配置
*
* @author terwer
* @since 1.0.0
*/
class SiyuanConfig extends BlogConfig {
/**
* 思源笔记操作提示
*
* @protected
*/
protected override placeholder: SiyuanPlaceholder

constructor() {
super()
this.apiUrl = "http://127.0.0.1:6806"
this.passwordType = PasswordType.PasswordType_Token
this.password = ""
this.placeholder = new SiyuanPlaceholder()
}
}
35 changes: 35 additions & 0 deletions packages/zhi-siyuan-api/src/lib/SiyuanPlaceholder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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 { BlogPlaceholder } from "zhi-blog-api";

/**
* 思源笔记操作提示
*/
class SiyuanPlaceholder extends BlogPlaceholder{

}

export default SiyuanPlaceholder

0 comments on commit 56823b1

Please sign in to comment.