generated from obsidianmd/obsidian-sample-plugin
-
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
19 changed files
with
3,500 additions
and
225 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Build | ||
on: | ||
push: | ||
branches: | ||
- '*' | ||
tags: | ||
- '*' | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Build | ||
run: | | ||
npm install | ||
npm run build |
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,73 @@ | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- '*' | ||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
- name: Version | ||
id: version | ||
run: | | ||
echo "::set-output name=tag::$(git describe --exact-match --tags HEAD | head -n1)" | ||
- name: Build | ||
run: | | ||
npm install | ||
npm run test | ||
npm run build | ||
- name: Package | ||
run: | | ||
mkdir "${{ github.event.repository.name }}" | ||
cp main.js styles.css README.md manifest.json "${{ github.event.repository.name }}" | ||
zip -r "${{ github.event.repository.name }}.zip" "${{ github.event.repository.name }}" | ||
- name: Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_PAT }} | ||
VERSION: ${{ github.ref }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
- name: Upload .zip | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_PAT }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ${{ github.event.repository.name }}.zip | ||
asset_name: ${{ github.event.repository.name }}-${{steps.version.outputs.tag}}.zip | ||
asset_content_type: application/zip | ||
- name: Upload main.js | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_PAT }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: ./main.js | ||
asset_name: main.js | ||
asset_content_type: text/javascript | ||
- name: Upload manifest.json | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_PAT }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: manifest.json | ||
asset_name: manifest.json | ||
asset_content_type: application/json | ||
- name: Upload styles.css | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_PAT }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} | ||
asset_path: styles.css | ||
asset_name: styles.css | ||
asset_content_type: text/css |
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,44 @@ | ||
name: Version | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the master branch | ||
workflow_dispatch: | ||
inputs: | ||
type: | ||
description: 'Type of version bump (major, minor, patch)' | ||
required: true | ||
default: 'patch' | ||
jobs: | ||
bump: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
persist-credentials: false | ||
fetch-depth: 0 | ||
token: ${{ secrets.GITHUB_PAT }} | ||
- name: Update version | ||
id: version | ||
run: | | ||
git config --local user.email "action@github.com" | ||
git config --local user.name "GitHub Action" | ||
npm version ${{ github.event.inputs.type }} | ||
echo "::set-output name=tag::$(git describe --abbrev=0)" | ||
- name: Update manifest | ||
uses: jossef/action-set-json-field@v1 | ||
with: | ||
file: manifest.json | ||
field: version | ||
value: ${{ steps.version.outputs.tag }} | ||
- name: Commit | ||
run: | | ||
git branch --show-current | ||
git add -u | ||
git commit --amend --no-edit | ||
git tag -fa ${{ steps.version.outputs.tag }} -m "${{ steps.version.outputs.tag }}" | ||
- name: Push | ||
uses: ad-m/github-push-action@v0.6.0 | ||
with: | ||
github_token: ${{secrets.GITHUB_PAT}} | ||
tags: true | ||
branch: ${{github.ref}} |
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,14 @@ | ||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
Version 2, December 2004 | ||
|
||
Copyright (C) 2024 Mikhail Savin <jtprogru@gmail.com> | ||
|
||
Everyone is permitted to copy and distribute verbatim or modified | ||
copies of this license document, and changing it is allowed as long | ||
as the name is changed. | ||
|
||
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | ||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | ||
|
||
0. You just DO WHAT THE FUCK YOU WANT TO. | ||
|
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 |
---|---|---|
@@ -1,96 +1,101 @@ | ||
# Obsidian Sample Plugin | ||
# Obsidian Vault Full Statistics Plugin | ||
|
||
This is a sample plugin for Obsidian (https://obsidian.md). | ||
NOTE: This plugin is modified fork of the [Obsidian Vault Statistics Plugin](https://github.com/bkyle/obsidian-vault-full-statistics-plugin/) plugin. | ||
|
||
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. | ||
Status bar item with vault statistics including the number of notes, files, attachments, and links. | ||
|
||
**Note:** The Obsidian API is still in early alpha and is subject to change at any time! | ||
## Usage | ||
|
||
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. | ||
After the plugin is installed and enabled you will see a new item appear in the status bar showing you the number of notes in your vault. | ||
|
||
## First time developing plugins? | ||
- Click on the status bar item to cycle through the available statistics. | ||
- Hover over the status bar item to see all of the available statistics. | ||
|
||
Quick starting guide for new plugin devs: | ||
## Advanced Usage | ||
|
||
- 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. | ||
### Showing All Statistics | ||
|
||
## Releasing new releases | ||
All statistics can be shown by creating and enabling a CSS snippet with the following content. | ||
|
||
- 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. | ||
```css | ||
/* Show all vault statistics. */ | ||
.obsidian-vault-full-statistics--item { | ||
display: initial !important; | ||
} | ||
``` | ||
|
||
> 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` | ||
### Showing Selected Statistics | ||
|
||
## Adding your plugin to the community plugin list | ||
Similarly to the above, one can show certain statistics using a similar method to the above. Below is a snippet that hides all by the notes and attachments statistics. The snippet can be modified to include more or different statistics. | ||
|
||
- 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. | ||
``` css | ||
/* Hide all statistics. */ | ||
.obsidian-vault-full-statistics--item { | ||
display: none !important; | ||
} | ||
|
||
## How to use | ||
/* Always show the notes and attachments statistics. */ | ||
.obsidian-vault-full-statistics--item-notes, | ||
.obsidian-vault-full-statistics--item-attachments { | ||
display: initial !important; | ||
} | ||
``` | ||
|
||
- 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. | ||
## Version History | ||
|
||
## Manually installing the plugin | ||
All notable changes to this project will be documented in this file. | ||
|
||
- Copy over `main.js`, `styles.css`, `manifest.json` to your vault `VaultFolder/.obsidian/plugins/your-plugin-id/`. | ||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## 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\` | ||
### [Unreleased] | ||
|
||
## Funding URL | ||
- Added | ||
- Changed | ||
- Deprecated | ||
- Removed | ||
- Fixed | ||
- Comment sections are explicitly processed and do not count toward statistics (#22) | ||
|
||
You can include funding URLs where people who use your plugin can financially support it. | ||
### [0.1.3] - 2022-10-25 | ||
|
||
The simple way is to set the `fundingUrl` field to your link in your `manifest.json` file: | ||
- Fixed | ||
- Fixed issue with deleted and renamed files not correctly updating file statistics (#17) | ||
- Removed errant `debugger` statement (#14) | ||
|
||
```json | ||
{ | ||
"fundingUrl": "https://buymeacoffee.com" | ||
} | ||
``` | ||
### [0.1.2] - 2022-08-05 | ||
|
||
If you have multiple URLs, you can also do: | ||
- Added | ||
- Added Settings pane | ||
- Changed | ||
- Users can now optionally show all or a subset of metrics instead of the default click-to-cycle behaviour (#6) | ||
|
||
```json | ||
{ | ||
"fundingUrl": { | ||
"Buy Me a Coffee": "https://buymeacoffee.com", | ||
"GitHub Sponsor": "https://github.com/sponsors", | ||
"Patreon": "https://www.patreon.com/" | ||
} | ||
} | ||
``` | ||
### [0.1.1] - 2022-08-05 | ||
|
||
- Fixed | ||
- Fixed issue when processing files with admonitions (#12) | ||
|
||
### [0.1.0] - 2021-12-30 | ||
|
||
- Added | ||
- Added word count metric (#8) | ||
|
||
### [0.0.8] - 2021-12-18 | ||
|
||
- Added | ||
- Initial support for displaying multiple statistics at the same time. (#6) | ||
|
||
### [0.0.6] - 2021-12-14 | ||
|
||
- Fixed | ||
- FIXED: Reported values only contain 2 significant digits (#7) | ||
|
||
### [0.0.5] - 2021-12-12 | ||
|
||
- Changed | ||
- Displayed statistics are formatted with grouping for increase readability. | ||
- Added Vault Size statistic which calculates the total size of all files in the vault that are understood by Obsidian The display value is scaled to the appropriate unit. (#5) | ||
|
||
## API Documentation | ||
### [0.0.4] - 2021-02-25 | ||
|
||
See https://github.com/obsidianmd/obsidian-api | ||
- Fixed | ||
- Statistics will be calculated automatically as soon as the plugin loads. |
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
Oops, something went wrong.