From f6a8b75acd01ce492ea58403ed8a603679fd1649 Mon Sep 17 00:00:00 2001 From: appleex <771992522@qq.com> Date: Wed, 16 Oct 2024 15:43:13 +0800 Subject: [PATCH 1/3] =?UTF-8?q?docs:=20=E6=9B=B4=E6=96=B0=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README-zh.md | 104 ++++++++++++++++++++++++++++++++++++++++++++++ README.md | 111 ++++++++++++++++++-------------------------------- manifest.json | 2 +- 3 files changed, 144 insertions(+), 73 deletions(-) create mode 100644 README-zh.md diff --git a/README-zh.md b/README-zh.md new file mode 100644 index 0000000..b9ae811 --- /dev/null +++ b/README-zh.md @@ -0,0 +1,104 @@ +# Obsidian Upload Plugin + +This is a Upload plugin for Obsidian (https://obsidian.md). + +This project uses TypeScript to provide type checking and documentation. +The repo depends on the latest plugin API (obsidian.d.ts) in TypeScript Definition format, which contains TSDoc comments describing what it does. + +**Note:** The Obsidian API is still in early alpha and is subject to change at any time! + +This sample plugin demonstrates some of the basic functionality the plugin API can do. +- Adds a ribbon icon, which shows a Notice when clicked. +- Adds a command "Open Sample Modal" which opens a Modal. +- Adds a plugin setting tab to the settings page. +- Registers a global click event and output 'click' to the console. +- Registers a global interval which logs 'setInterval' to the console. + +## First time developing plugins? + +Quick starting guide for new plugin devs: + +- Check if [someone already developed a plugin for what you want](https://obsidian.md/plugins)! There might be an existing plugin similar enough that you can partner up with. +- Make a copy of this repo as a template with the "Use this template" button (login to GitHub if you don't see it). +- Clone your repo to a local development folder. For convenience, you can place this folder in your `.obsidian/plugins/your-plugin-name` folder. +- Install NodeJS, then run `npm i` in the command line under your repo folder. +- Run `npm run dev` to compile your plugin from `main.ts` to `main.js`. +- Make changes to `main.ts` (or create new `.ts` files). Those changes should be automatically compiled into `main.js`. +- Reload Obsidian to load the new version of your plugin. +- Enable plugin in settings window. +- For updates to the Obsidian API run `npm update` in the command line under your repo folder. + +## Releasing new releases + +- Update your `manifest.json` with your new version number, such as `1.0.1`, and the minimum Obsidian version required for your latest release. +- Update your `versions.json` file with `"new-plugin-version": "minimum-obsidian-version"` so older versions of Obsidian can download an older version of your plugin that's compatible. +- Create new GitHub release using your new version number as the "Tag version". Use the exact version number, don't include a prefix `v`. See here for an example: https://github.com/obsidianmd/obsidian-sample-plugin/releases +- Upload the files `manifest.json`, `main.js`, `styles.css` as binary attachments. Note: The manifest.json file must be in two places, first the root path of your repository and also in the release. +- Publish the release. + +> You can simplify the version bump process by running `npm version patch`, `npm version minor` or `npm version major` after updating `minAppVersion` manually in `manifest.json`. +> The command will bump version in `manifest.json` and `package.json`, and add the entry for the new version to `versions.json` + +## Adding your plugin to the community plugin list + +- Check the [plugin guidelines](https://docs.obsidian.md/Plugins/Releasing/Plugin+guidelines). +- Publish an initial version. +- Make sure you have a `README.md` file in the root of your repo. +- Make a pull request at https://github.com/obsidianmd/obsidian-releases to add your plugin. + +## How to use + +- Clone this repo. +- Make sure your NodeJS is at least v16 (`node --version`). +- `npm i` or `yarn` to install dependencies. +- `npm run dev` to start compilation in watch mode. + +## Manually installing the plugin + +- Copy over `main.js`, `styles.css`, `manifest.json` to your vault `VaultFolder/.obsidian/plugins/your-plugin-id/`. + +## Improve code quality with eslint (optional) +- [ESLint](https://eslint.org/) is a tool that analyzes your code to quickly find problems. You can run ESLint against your plugin to find common bugs and ways to improve your code. +- To use eslint with this project, make sure to install eslint from terminal: + - `npm install -g eslint` +- To use eslint to analyze this project use this command: + - `eslint main.ts` + - eslint will then create a report with suggestions for code improvement by file and line number. +- If your source code is in a folder, such as `src`, you can use eslint with this command to analyze all files in that folder: + - `eslint .\src\` + +## Funding URL + +You can include funding URLs where people who use your plugin can financially support it. + +The simple way is to set the `fundingUrl` field to your link in your `manifest.json` file: + +```json +{ + "fundingUrl": "https://buymeacoffee.com" +} +``` + +If you have multiple URLs, you can also do: + +```json +{ + "fundingUrl": { + "Buy Me a Coffee": "https://buymeacoffee.com", + "GitHub Sponsor": "https://github.com/sponsors", + "Patreon": "https://www.patreon.com/" + } +} +``` + +## API Documentation + +See https://github.com/obsidianmd/obsidian-api + +## References + +- [obsidian-image-upload-toolkit](https://github.com/addozhang/obsidian-image-upload-toolkit) +- [obsidian-image-uploader](https://github.com/Creling/obsidian-image-uploader) +- [obsidian-image-auto-upload-plugin](https://github.com/renmu123/obsidian-image-auto-upload-plugin) +- [obsidian-image-uploader](https://github.com/sancijun/obsidian-image-uploader) +- [obsidian-wordpress](https://github.com/devbean/obsidian-wordpress) diff --git a/README.md b/README.md index b9ae811..d9d58d8 100644 --- a/README.md +++ b/README.md @@ -1,101 +1,68 @@ # Obsidian Upload Plugin -This is a Upload plugin for Obsidian (https://obsidian.md). +## 介绍 -This project uses TypeScript to provide type checking and documentation. -The repo depends on the latest plugin API (obsidian.d.ts) in TypeScript Definition format, which contains TSDoc comments describing what it does. +这是 [Obsidian](https://obsidian.md) 插件,专用于上传文件到存储仓库。目前支持 Lskypro(兰空图床),后续有需求会引入其它存储方式,如:Github/Gitee等等。 -**Note:** The Obsidian API is still in early alpha and is subject to change at any time! +## 功能 -This sample plugin demonstrates some of the basic functionality the plugin API can do. -- Adds a ribbon icon, which shows a Notice when clicked. -- Adds a command "Open Sample Modal" which opens a Modal. -- Adds a plugin setting tab to the settings page. -- Registers a global click event and output 'click' to the console. -- Registers a global interval which logs 'setInterval' to the console. +- 支持多平台配置(Lskypro、Halo等) +- 支持右键菜单上传 -## First time developing plugins? +## 使用 -Quick starting guide for new plugin devs: +### 通过 Obsidian 社区插件中搜索并安装 -- Check if [someone already developed a plugin for what you want](https://obsidian.md/plugins)! There might be an existing plugin similar enough that you can partner up with. -- Make a copy of this repo as a template with the "Use this template" button (login to GitHub if you don't see it). -- Clone your repo to a local development folder. For convenience, you can place this folder in your `.obsidian/plugins/your-plugin-name` folder. -- Install NodeJS, then run `npm i` in the command line under your repo folder. -- Run `npm run dev` to compile your plugin from `main.ts` to `main.js`. -- Make changes to `main.ts` (or create new `.ts` files). Those changes should be automatically compiled into `main.js`. -- Reload Obsidian to load the new version of your plugin. -- Enable plugin in settings window. -- For updates to the Obsidian API run `npm update` in the command line under your repo folder. +尝试在 Obsidian 社区插件中搜索 `Upload Plugin`,若找到该插件,按照提示直接安装即可。 -## Releasing new releases +### 通过源码仓库或发布的文件下载安装 -- Update your `manifest.json` with your new version number, such as `1.0.1`, and the minimum Obsidian version required for your latest release. -- Update your `versions.json` file with `"new-plugin-version": "minimum-obsidian-version"` so older versions of Obsidian can download an older version of your plugin that's compatible. -- Create new GitHub release using your new version number as the "Tag version". Use the exact version number, don't include a prefix `v`. See here for an example: https://github.com/obsidianmd/obsidian-sample-plugin/releases -- Upload the files `manifest.json`, `main.js`, `styles.css` as binary attachments. Note: The manifest.json file must be in two places, first the root path of your repository and also in the release. -- Publish the release. +- 从 Release 或源码中下载文件,包含:`main.js`,`manifest.json`,`styles.css` +- 复制或移动 `main.js`, `styles.css`, `manifest.json` 到 `[VaultFolder]/.obsidian/plugins/[your-plugin-id]/` +- 找到该插件进行相应配置即可(重启 Obsidian ) -> You can simplify the version bump process by running `npm version patch`, `npm version minor` or `npm version major` after updating `minAppVersion` manually in `manifest.json`. -> The command will bump version in `manifest.json` and `package.json`, and add the entry for the new version to `versions.json` +> **注意:** `[VaultFolder]` 是根目录、`[your-plugin-id]` 是插件 id(`manifest.json => id`) -## Adding your plugin to the community plugin list +### 通过第三方下载并安装 -- Check the [plugin guidelines](https://docs.obsidian.md/Plugins/Releasing/Plugin+guidelines). -- Publish an initial version. -- Make sure you have a `README.md` file in the root of your repo. -- Make a pull request at https://github.com/obsidianmd/obsidian-releases to add your plugin. +可尝试使用第三方插件进行安装,如:[BRAT](https://github.com/TfTHacker/obsidian42-brat) -## How to use +## 开发 -- Clone this repo. -- Make sure your NodeJS is at least v16 (`node --version`). -- `npm i` or `yarn` to install dependencies. -- `npm run dev` to start compilation in watch mode. +该项目使用 TypeScript 提供类型检查和文档。 该存储库依赖于 TypeScript 定义格式的最新插件 API (obsidian.d.ts),其中包含描述其功能的 TSDoc 注释。 -## Manually installing the plugin +### 启动项目 -- Copy over `main.js`, `styles.css`, `manifest.json` to your vault `VaultFolder/.obsidian/plugins/your-plugin-id/`. +```sh +git clone https://github.com/Appleec/e-obsidian-upload-plugin.git obsidian-upload-plugin -## Improve code quality with eslint (optional) -- [ESLint](https://eslint.org/) is a tool that analyzes your code to quickly find problems. You can run ESLint against your plugin to find common bugs and ways to improve your code. -- To use eslint with this project, make sure to install eslint from terminal: - - `npm install -g eslint` -- To use eslint to analyze this project use this command: - - `eslint main.ts` - - eslint will then create a report with suggestions for code improvement by file and line number. -- If your source code is in a folder, such as `src`, you can use eslint with this command to analyze all files in that folder: - - `eslint .\src\` +cd obsidian-upload-plugin -## Funding URL +npm i -You can include funding URLs where people who use your plugin can financially support it. - -The simple way is to set the `fundingUrl` field to your link in your `manifest.json` file: - -```json -{ - "fundingUrl": "https://buymeacoffee.com" -} +npm run dev ``` -If you have multiple URLs, you can also do: +### 发布项目 -```json -{ - "fundingUrl": { - "Buy Me a Coffee": "https://buymeacoffee.com", - "GitHub Sponsor": "https://github.com/sponsors", - "Patreon": "https://www.patreon.com/" - } -} -``` +- 更新 `manifest.json` 版本,如:`1.0.1` +- 更新 `versions.json` 中的 `version` 和 `minAppVersion` 版本 +- 打一个版本标签并在代码仓库中创建一个发布任务,如:GitHub Release +- 将打包好的 `manifest.json`, `main.js`, `styles.css` 上传 +- 查看是否发布成功 -## API Documentation -See https://github.com/obsidianmd/obsidian-api +### API 文档 -## References +查看 https://github.com/obsidianmd/obsidian-api + +## 下一步 + +- [ ] 添加选中图片上传命令行 +- [ ] 添加所有图片上传命令行 +- [ ] 支持 GitHub 配置上传 + +## 致谢 - [obsidian-image-upload-toolkit](https://github.com/addozhang/obsidian-image-upload-toolkit) - [obsidian-image-uploader](https://github.com/Creling/obsidian-image-uploader) diff --git a/manifest.json b/manifest.json index e7da68b..59b2768 100644 --- a/manifest.json +++ b/manifest.json @@ -1,5 +1,5 @@ { - "id": "upload-plugin", + "id": "obsidian-upload-plugin", "name": "Upload Plugin", "version": "0.1.0", "minAppVersion": "0.15.0", From 9dfe25c217989279e9965cf2e7bdc9d515c6face Mon Sep 17 00:00:00 2001 From: appleex <771992522@qq.com> Date: Wed, 16 Oct 2024 15:54:27 +0800 Subject: [PATCH 2/3] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E7=9B=B8?= =?UTF-8?q?=E5=85=B3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +++ manifest.json | 4 ++-- package.json | 12 ++++++++++-- src/config.ts | 35 ++++++++++------------------------- versions.json | 4 ++-- 5 files changed, 27 insertions(+), 31 deletions(-) diff --git a/.gitignore b/.gitignore index de9c0b6..2c543a2 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ data.json # Exclude macOS Finder (System Explorer) View States .DS_Store + +# Other +backup diff --git a/manifest.json b/manifest.json index 59b2768..838471d 100644 --- a/manifest.json +++ b/manifest.json @@ -4,8 +4,8 @@ "version": "0.1.0", "minAppVersion": "0.15.0", "description": "Demonstrates some of the capabilities of the Obsidian API.", - "author": "appleex", + "author": "Appleex", "authorUrl": "https://github.com/Appleec/e-obsidian-upload-plugin", "fundingUrl": "https://github.com/Appleec/e-obsidian-upload-plugin", "isDesktopOnly": false -} +} \ No newline at end of file diff --git a/package.json b/package.json index 65b02dd..5aa651b 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "version": "node version-bump.mjs && git add manifest.json versions.json" }, "keywords": [], - "author": "", + "author": "appleex <771992522@qq.com>", "license": "MIT", "devDependencies": { "@types/lodash-es": "^4.17.12", @@ -32,5 +32,13 @@ "dependencies": { "axios": "^1.7.7", "qs": "^6.13.0" - } + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Appleec/e-obsidian-upload-plugin.git" + }, + "bugs": { + "url": "https://github.com/Appleec/e-obsidian-upload-plugin/issues" + }, + "homepage": "https://github.com/Appleec/e-obsidian-upload-plugin#readme" } diff --git a/src/config.ts b/src/config.ts index d619c8c..6e134f7 100644 --- a/src/config.ts +++ b/src/config.ts @@ -14,34 +14,19 @@ const config = { }, ], lskySetting: { - "apiURL": "https://img.elinzy.com/api/v1/upload", - "apiReqHeader": { - "Authorization": "Bearer Jq7mTKdjN7BxMjLoG8Jj8eaGGV2GuurwumOGFCBm", - "Accept": "application/json", - "Content-Type": "multipart/form-data" - }, - "apiReqBody": { - "file": "$FILE", - "strategy_id": 2 - }, - "imgUrlPath": "data.pathname", - "imgUrlPrefix": "https://blog.elinzy.com/upload/eblog/" + "apiURL": "", + "apiReqHeader": {}, + "apiReqBody": {}, + "imgUrlPath": "", + "imgUrlPrefix": "" }, haloSetting: { // See: https://api.halo.run/#/ - "apiURL": "https://blog.elinzy.com/apis/api.console.halo.run/v1alpha1/attachments/upload", - "apiReqHeader": { - "Authorization": "Bearer pat_eyJraWQiOiI1SG9MUWVvUW10bV9zd2JISFRSODFEd1dUWVNyUUlyc0N3NjE2R1dQTXpnIiwiYWxnIjoiUlMyNTYifQ.eyJpc3MiOiJodHRwczovL2Jsb2cuZWxpbnp5LmNvbS8iLCJzdWIiOiJhZG1pbiIsImlhdCI6MTcxMTk1NjY5MiwianRpIjoiN2E5NDY3NjEtY2QzYi1kODc4LTJkOGMtZWQxNmUwZDk4NzFjIiwicGF0X25hbWUiOiJwYXQtYWRtaW4tbkdnZG0ifQ.cl7n0f9SqP5qwYUW2ZM6DL6Ex6Xh9GvxL_hwEDJuUn8tlyuzOhcjUqkGSCO1D8E0lqym7RtV7xDQzSLkQybKbSwRqeMEDbLbdLMDpzD2Vu1aptz5m0ifsm9pvpm2Wqnn_px68arhqHqmMwP-8N9F1m-fMu1ovBuXI2gzHA56Ne1yWsSObeasxqNP1CNsez_abdv0fPKxbBsV_2JrQeHYc0y90M8V0WZ9d3_zdrgOMg6Hm481VprrHUwB9nxrsVsCxd_ROwf93ZhGo_VPV5YG8_Pz4CwRGzkIABVHO1leUXyMD24nOpG9csGo-mauuik7oi1h6eLUMi2902qKFUctwRsF4lKQSP6h2Li9UUt0FYQp78uaTDbke3eAxLq1nqWfOn3Lplpe1tz8MPXtZGclx2xz4zkQWs5TdOU4cuukMIJoXfc1VCbAR9AuaG1BVMZYnL-scgg9I9GNHjtcfgFMskUaEKQlyYTNiIweaqQHMlBHvdxJjCMko9jdB2qnMNw9cs2QfMreK278A6ucHMOB9WGVh0thpor1gk2MvAcV3k-ai21BKUdOLooxftdXbI7V9xif_fLEZwFvtf2RtRqChJpXLyGS2-xoOwg00kz0khckv43vntSCPZ8pqHnTAWsy_ssf80WOajs2guY25l04PXAshEGndvziB0Aod3AoXdY", - "Content-Type": "multipart/form-data", - "Host": "blog.elinzy.com", - }, - "apiReqBody": { - "file": "$FILE", - "policyName": "attachment-policy-gUpSV", // 策略 - "groupName": "attachment-group-JWlvm" // 分组 - }, - "imgUrlPath": "data.metadata.annotations['storage.halo.run/uri']", - "imgUrlPrefix": "https://blog.elinzy.com/" + "apiURL": "", + "apiReqHeader": {}, + "apiReqBody": {}, + "imgUrlPath": "", + "imgUrlPrefix": "" } } diff --git a/versions.json b/versions.json index 26382a1..37d5abe 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,3 @@ { - "1.0.0": "0.15.0" -} + "0.1.0": "0.15.0" +} \ No newline at end of file From 5f7103467a125e62c5ab01ec0f15b29bf5138969 Mon Sep 17 00:00:00 2001 From: appleex <771992522@qq.com> Date: Wed, 16 Oct 2024 16:03:14 +0800 Subject: [PATCH 3/3] 1.0.0 --- manifest.json | 2 +- package.json | 2 +- versions.json | 3 ++- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/manifest.json b/manifest.json index 838471d..59e70ca 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-upload-plugin", "name": "Upload Plugin", - "version": "0.1.0", + "version": "1.0.0", "minAppVersion": "0.15.0", "description": "Demonstrates some of the capabilities of the Obsidian API.", "author": "Appleex", diff --git a/package.json b/package.json index 5aa651b..985515b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-upload-plugin", - "version": "0.1.0", + "version": "1.0.0", "description": "This is a upload plugin for Obsidian (https://obsidian.md)", "main": "main.js", "scripts": { diff --git a/versions.json b/versions.json index 37d5abe..f3d257b 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,4 @@ { - "0.1.0": "0.15.0" + "0.1.0": "0.15.0", + "1.0.0": "0.15.0" } \ No newline at end of file